Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/ add ETCswap V3 and V2 connectors #340

Open
wants to merge 16 commits into
base: development
Choose a base branch
from

Conversation

vic-en
Copy link
Collaborator

@vic-en vic-en commented Jul 24, 2024

Before submitting this PR, please make sure:

  • Your code builds clean without any errors or warnings
  • You are using approved title ("feat/", "fix/", "docs/", "refactor/")

A description of the changes proposed in the pull request:
hummingbot/hummingbot#7110

Tests performed by the developer:

  • Curl tests for lp connector

Tips for QA testing:

  • Curl test, e.t.c.

@nikspz nikspz changed the title feat/ add etcswap lp connector feat/ add ETCswap V3 lp connector Jul 24, 2024
chris-mercer

This comment was marked as duplicate.

chris-mercer

This comment was marked as outdated.

@vic-en
Copy link
Collaborator Author

vic-en commented Jul 25, 2024

@chris-mercer Fyi, v3 connector basically adds concentrated lp functionality which is what I've done.
If you're not aware, v2 and v3 swap functionality is consolidated in Gateway. As a matter of fact, the SOR(smart order router sometimes referred as auto routers) are designed to route swaps between v2 pairs and v3 pools. So it doesn't make sense to separate them for your connectors.

However, if you insist, I'll gladly make changes as requested to fulfil this bounty. Just know the connectors will most definitely have issues down the road.

@vic-en
Copy link
Collaborator Author

vic-en commented Jul 25, 2024

@chris-mercer Also, resolve necessary comments/requests

@chris-mercer
Copy link

@chris-mercer Fyi, v3 connector basically adds concentrated lp functionality which is what I've done. If you're not aware, v2 and v3 swap functionality is consolidated in Gateway. As a matter of fact, the SOR(smart order router sometimes referred as auto routers) are designed to route swaps between v2 pairs and v3 pools. So it doesn't make sense to separate them for your connectors.

However, if you insist, I'll gladly make changes as requested to fulfil this bounty. Just know the connectors will most definitely have issues down the road.

No i don't insist. If you followed the pattern in the repo then thats perfect. I noticed the chain was not named correctly and wanted to make sure there wouldn't be any issues on the naming. I'm not as familar with the code base as you. Thanks for addressing the issues that made sense.

@nikspz
Copy link
Contributor

nikspz commented Jul 31, 2024

hi @vic-en Could you please check branch conflicts?

@nikspz
Copy link
Contributor

nikspz commented Jul 31, 2024

@vic-en

Steps:

  1. Clone latest development + gwPR340
  2. set up gateway to ONLINE
  3. gateway connect etcswapLP

Actual:
Failed to connect ETC wallet Unhandled error in background task: Error on POST https://localhost:15888/wallet/add

Expected:
Could connect wallet

logs_hummingbot.log
logs_gateway_app.log.2024-07-31.log

ERROR - Unhandled error in background task: Error on POST https://localhost:15888/wallet/add Error: {'message': 'No validator exists for ethereum-classic., chain must be "ethereum", "avalanche", "near", "harmony", "cosmos", "osmosis", "binance-smart-chain", or "kujira"', 'httpErrorCode': 404, 'errorCode': -1, 'stack': 'Error: No validator exists for ethereum-classic., chain must be "ethereum", "avalanche", "near", "harmony", "cosmos", "osmosis", "binance-smart-chain", or "kujira"\n    at throwIfErrorsExist (/home/hummingbot/gwetc340/dist/src/services/validators.js:38:15)\n    at /home/hummingbot/gwetc340/dist/src/services/validators.js:103:40\n    at /home/hummingbot/gwetc340/dist/src/services/wallet/wallet.routes.js:25:58\n    at Generator.next (<anonymous>)\n    at /home/hummingbot/gwetc340/dist/src/services/wallet/wallet.routes.js:8:71\n    at new Promise (<anonymous>)\n    at __awaiter (/home/hummingbot/gwetc340/dist/src/services/wallet/wallet.routes.js:4:12)\n    at /home/hummingbot/gwetc340/dist/src/services/wallet/wallet.routes.js:24:86\n    at /home/hummingbot/gwetc340/dist/src/services/error-handler.js:38:28\n    at Layer.handle [as handle_request] (/home/hummingbot/gwetc340/node_modules/express/lib/router/layer.js:95:5)'}
Traceback (most recent call last):
  File "/home/hummingbot/development1/hummingbot/core/utils/async_utils.py", line 9, in safe_wrapper
    return await c
  File "/home/hummingbot/development1/hummingbot/client/command/gateway_command.py", line 303, in _gateway_connect
    wallet_address, additional_prompt_values = await self._prompt_for_wallet_address(
  File "/home/hummingbot/development1/hummingbot/client/command/gateway_command.py", line 438, in _prompt_for_wallet_address
    response: Dict[str, Any] = await self._get_gateway_instance().add_wallet(
  File "/home/hummingbot/development1/hummingbot/core/gateway/gateway_http_client.py", line 269, in add_wallet
    return await self.api_request(method="post", path_url="wallet/add", params=request)
  File "/home/hummingbot/development1/hummingbot/core/gateway/gateway_http_client.py", line 222, in api_request
    raise e
  File "/home/hummingbot/development1/hummingbot/core/gateway/gateway_http_client.py", line 210, in api_request
    raise ValueError(f"Error on {method.upper()} {url} Error: {parsed_response}")
ValueError: Error on POST https://localhost:15888/wallet/add Error: {'message': 'No validator exists for ethereum-classic., chain must be "ethereum", "avalanche", "near", "harmony", "cosmos", "osmosis", "binance-smart-chain", or "kujira"', 'httpErrorCode': 404, 'errorCode': -1, 'stack': 'Error: No validator exists for ethereum-classic., chain must be "ethereum", "avalanche", "near", "harmony", "cosmos", "osmosis", "binance-smart-chain", or "kujira"\n    at throwIfErrorsExist (/home/hummingbot/gwetc340/dist/src/services/validators.js:38:15)\n    at /home/hummingbot/gwetc340/dist/src/services/validators.js:103:40\n    at /home/hummingbot/gwetc340/dist/src/services/wallet/wallet.routes.js:25:58\n    at Generator.next (<anonymous>)\n    at /home/hummingbot/gwetc340/dist/src/services/wallet/wallet.routes.js:8:71\n    at new Promise (<anonymous>)\n    at __awaiter (/home/hummingbot/gwetc340/dist/src/services/wallet/wallet.routes.js:4:12)\n    at /home/hummingbot/gwetc340/dist/src/services/wallet/wallet.routes.js:24:86\n    at /home/hummingbot/gwetc340/dist/src/services/error-handler.js:38:28\n    at Layer.handle [as handle_request] (/home/hummingbot/gwetc340/node_modules/express/lib/router/layer.js:95:5)'}

image

@vic-en
Copy link
Collaborator Author

vic-en commented Aug 5, 2024

@nikspz All updated.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ethereum Classic's testnet is Mordor, not Goerli.
https://chainlist.org/chain/63
Recommended Funded Endpoint: https://rpc.mordor.etccooperative.org

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chris-mercer The point of replacing that url is to prevent calls to the default endpoint.
Workflows shouldn't access external services except in special cases.

@nikspz
Copy link
Contributor

nikspz commented Aug 6, 2024

bd9a268

@vic-en please create PR to add "ethereum-classic": "ETC", line

2024-08-06 16:12:05,738 - 270114 - hummingbot.core.gateway.gateway_status_monitor - INFO - Gateway Service is ONLINE.
2024-08-06 16:18:25,957 - 270114 - hummingbot.core.utils.async_utils - ERROR - Unhandled error in background task: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/home/hummingbot/development1/hummingbot/core/utils/async_utils.py", line 9, in safe_wrapper
    return await c
  File "/home/hummingbot/development1/hummingbot/client/command/gateway_command.py", line 524, in _get_balances
    bal_resp = await asyncio.wait_for(
  File "/home/hummingbot/miniconda3/envs/hummingbot/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
    return fut.result()
  File "/home/hummingbot/development1/hummingbot/client/command/gateway_command.py", line 718, in all_balances_all_exc
    await self.update_exchange(client_config_map)
  File "/home/hummingbot/development1/hummingbot/client/command/gateway_command.py", line 713, in update_exchange
    results = await safe_gather(*tasks)
  File "/home/hummingbot/development1/hummingbot/core/utils/async_utils.py", line 22, in safe_gather
    return await asyncio.gather(*args, **kwargs)
  File "/home/hummingbot/development1/hummingbot/client/command/gateway_command.py", line 673, in update_exchange_balances
    return await self.add_gateway_exchange(exchange_name, client_config_map, **api_keys)
  File "/home/hummingbot/development1/hummingbot/client/command/gateway_command.py", line 649, in add_gateway_exchange
    market = GatewayCommand.connect_markets(
  File "/home/hummingbot/development1/hummingbot/client/command/gateway_command.py", line 602, in connect_markets
    connector_class = get_connector_class(exchange)
  File "/home/hummingbot/development1/hummingbot/client/config/config_helpers.py", line 563, in get_connector_class
    mod = __import__(conn_setting.module_path(),
  File "/home/hummingbot/development1/hummingbot/client/settings.py", line 213, in module_path
    return f"hummingbot.connector.{self.module_name()}"
  File "/home/hummingbot/development1/hummingbot/client/settings.py", line 203, in module_name
    return f"gateway.{self.type.name.lower()}.gateway_{connector_spec['chain_type'].lower()}_{self._get_module_package()}"
TypeError: 'NoneType' object is not subscriptable

image

Test performed:

  • cloned latest development Client + gwPR340
  • added "ethereum-classic": "ETC", line to Client
  • started Client and gateway connect etcswapLP successfully
  • added gateway connector-tokens etcswapLP_ethereum-classic_mainnet tokens
  • Review tokens added to gateway balance
  • Created amm_v3_lp strategy using etcswapLP_ethereum-classic_mainnet, WETC-USC pair
  • started amm_v3_lp startegy
  • Review error and the bot stuck on connector is not ready
    https://etcerscan.com/address/0x930a6f15DA31912c0D0f3819D932E3397Cc1d410

logs_conf_amm_v3_lp_1.log

2024-08-06 17:23:11,377 - 284316 - hummingbot.core.utils.async_utils - ERROR - Unhandled error in background task: Error on POST https://localhost:15888/chain/allowances Error: {'message': 'The spender param is not a valid Ethereum address (0x followed by 40 hexidecimal characters).', 'httpErrorCode': 404, 'errorCode': -1, 'stack': 'Error: The spender param is not a valid Ethereum address (0x followed by 40 hexidecimal characters).\n    at throwIfErrorsExist (/home/hummingbot/gwetc340/dist/src/services/validators.js:38:15)\n    at /home/hummingbot/gwetc340/dist/src/services/validators.js:103:40\n    at EVMController.<anonymous> (/home/hummingbot/gwetc340/dist/src/chains/ethereum/evm.controllers.js:155:65)\n    at Generator.next (<anonymous>)\n    at /home/hummingbot/gwetc340/dist/src/chains/ethereum/evm.controllers.js:8:71\n    at new Promise (<anonymous>)\n    at __awaiter (/home/hummingbot/gwetc340/dist/src/chains/ethereum/evm.controllers.js:4:12)\n    at EVMController.allowances (/home/hummingbot/gwetc340/dist/src/chains/ethereum/evm.controllers.js:154:16)\n    at /home/hummingbot/gwetc340/dist/src/chains/chain.controller.js:49:51\n    at Generator.next (<anonymous>)'}
Traceback (most recent call last):
  File "/home/hummingbot/development1/hummingbot/core/utils/async_utils.py", line 9, in safe_wrapper
    return await c
  File "/home/hummingbot/development1/hummingbot/connector/gateway/amm_lp/gateway_evm_amm_lp.py", line 288, in auto_approve
    await self.update_allowances()
  File "/home/hummingbot/development1/hummingbot/connector/gateway/amm_lp/gateway_evm_amm_lp.py", line 328, in update_allowances
    self._allowances = await self.get_allowances()
  File "/home/hummingbot/development1/hummingbot/connector/gateway/amm_lp/gateway_evm_amm_lp.py", line 336, in get_allowances
    approval_lists: List[str] = await safe_gather(*[
  File "/home/hummingbot/development1/hummingbot/core/utils/async_utils.py", line 22, in safe_gather
    return await asyncio.gather(*args, **kwargs)
  File "/home/hummingbot/development1/hummingbot/core/gateway/gateway_http_client.py", line 374, in get_allowances
    return await self.api_request("post", "chain/allowances", {
  File "/home/hummingbot/development1/hummingbot/core/gateway/gateway_http_client.py", line 222, in api_request
    raise e
  File "/home/hummingbot/development1/hummingbot/core/gateway/gateway_http_client.py", line 210, in api_request
    raise ValueError(f"Error on {method.upper()} {url} Error: {parsed_response}")
ValueError: Error on POST https://localhost:15888/chain/allowances Error: {'message': 'The spender param is not a valid Ethereum address (0x followed by 40 hexidecimal characters).', 'httpErrorCode': 404, 'errorCode': -1, 'stack': 'Error: The spender param is not a valid Ethereum address (0x followed by 40 hexidecimal characters).\n    at throwIfErrorsExist (/home/hummingbot/gwetc340/dist/src/services/validators.js:38:15)\n    at /home/hummingbot/gwetc340/dist/src/services/validators.js:103:40\n    at EVMController.<anonymous> (/home/hummingbot/gwetc340/dist/src/chains/ethereum/evm.controllers.js:155:65)\n    at Generator.next (<anonymous>)\n    at /home/hummingbot/gwetc340/dist/src/chains/ethereum/evm.controllers.js:8:71\n    at new Promise (<anonymous>)\n    at __awaiter (/home/hummingbot/gwetc340/dist/src/chains/ethereum/evm.controllers.js:4:12)\n    at EVMController.allowances (/home/hummingbot/gwetc340/dist/src/chains/ethereum/evm.controllers.js:154:16)\n    at /home/hummingbot/gwetc340/dist/src/chains/chain.controller.js:49:51\n    at Generator.next (<anonymous>)'}
2024-08-06 17:23:12,001 - 284316 - hummingbot.strategy.amm_v3_lp.amm_v3_lp - WARNING - etcswapLP_ethereum-classic_mainnet connector is not ready. Please wait...
2024-08-06 17:23:13,001 - 284316 - hummingbot.strategy.amm_v3_lp.amm_v3_lp - WARNING - etcswapLP_ethereum-classic_mainnet connector is not ready. Please wait...

image

@vic-en
Copy link
Collaborator Author

vic-en commented Aug 6, 2024

@nikspz hummingbot/hummingbot#7159
The reason it was stuck was because it was attempting to check allowance for etcSwap which is yet to be added.
It should work now.

@nikspz
Copy link
Contributor

nikspz commented Aug 7, 2024

Test performed:

  • cloned latest development Client + gwPR340
  • added "ethereum-classic": "ETC", line to Client
  • started Client and gateway connect etcswapLP successfully
  • Created amm_v3_lp strategy using etcswapLP_ethereum-classic_mainnet, WETC-USC pair
  • started amm_v3_lp startegy
  • Review tokens approved but Client strategy not started to creating position

https://etcerscan.com/address/0x930a6f15DA31912c0D0f3819D932E3397Cc1d410

logs_conf_amm_v3_lp_1.log

logs_gateway_app.log.2024-08-07.log

image
image

@vic-en
Copy link
Collaborator Author

vic-en commented Aug 7, 2024

@nikspz The price says 0. What fee tier are you using?

@nikspz
Copy link
Contributor

nikspz commented Aug 7, 2024

@nikspz The price says 0. What fee tier are you using?

image

@vic-en
Copy link
Collaborator Author

vic-en commented Aug 7, 2024

@nikspz There are just 2 pools for that pair. LOWEST and MEDIUM

@nikspz
Copy link
Contributor

nikspz commented Aug 8, 2024

@nikspz There are just 2 pools for that pair. LOWEST and MEDIUM

LOWEST: Failed to add liquidity, Client stuck on WARNING - etcswapLP_ethereum-classic_mainnet connector is not ready. Please wait...

logs_conf_amm_v3_lp_2.log

image
image

MEDIUM:
Created successffully ✅
Amount is correct ✅
No message in logs about position was created ❌
logs_conf_amm_v3_lp_3.log

image
image

@nikspz
Copy link
Contributor

nikspz commented Aug 8, 2024

Upd: retested LOWEST,
created position ✅
status reported correct amount and ID ✅
No message in logs about position was created ❌

image
image

Remove liquidity: ok
image

@chris-mercer
Copy link

For any block explorer links, please use the primary funded explorer:
https://etc.blockscout.com/

@chris-mercer
Copy link

chris-mercer commented Aug 8, 2024

Apologies- info.etcswap.org analytics UI page had its archival node corrupt due to bad SSD this past week. it is currently resyncing and should functional once synced.

8/11 update: 50% through the resync.
8/13: Can review the progress of resync here: https://explorer-expedition.etc-network.info/?network=Ethereum%20Classic%20at%20etc-network.info%20GETH%20-%20AT
8/22: Node resync complete and https://info.etcswap.org service is restored.

@vic-en
Copy link
Collaborator Author

vic-en commented Aug 12, 2024

@nikspz I guess the node issue may have affected it. I tested over the weekend and it worked fine.

@nikspz
Copy link
Contributor

nikspz commented Aug 13, 2024

@chris-mercer
Copy link

@nikspz I guess the node issue may have affected it. I tested over the weekend and it worked fine.

If you're using etc.rivet.link as the rpc endpoint, nothing should be affected in your work. The v3.etcswap.org app does not interact with the archival node/subgraph at all.

The info.etcswap.org archival node is messing with the subgraphs ability to read new events. This is entirely different and simply related to that display app of activity (charts, volume, recent trades). I mentioned this in case you are using that for visibility into your actions. Again, ETCswap V3 is entirely functional: v3.etcswap.org

@vic-en
Copy link
Collaborator Author

vic-en commented Aug 14, 2024

@nikspz I fixed the failling test. The workflow was failing as a result of recent refactor to the Uniswap connector.

Failing workflow in #345 will pass as well when this pr is merged.

@chris-mercer
Copy link

chris-mercer commented Aug 26, 2024

@nikspz @fengtality I'm kind of confused on where we are on this bounty.

What are all the blockers here and what are the steps to get our network participants able to build the ETC/USC market for V3 with HB?

I noticed this is open too: hummingbot/hummingbot#7159

@vic-en vic-en changed the title feat/ add ETCswap V3 lp connector feat/ add ETCswap V3 and V2 connectors Sep 8, 2024
@chris-mercer
Copy link

chris-mercer commented Sep 11, 2024

Copy link
Contributor

@nikspz nikspz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test performed:

  • Cloned PR7159 + gwPR340
  • Installed Client and gateway PR
  • Reviewed gateway ONLINE
  • Curl:
    • Etcswap connector
      • wallet/add: ok
      • /chain/status: ok
      • /chain/tokens?chain=ethereum-classic&network=mainnet: ok
      • /chain/allowances: ok
      • /chain/approve: ok
      • /wallet/remove: ok
      • /amm/price: ok
      • /amm/trade: ok

Pending:
- EtcswapLP
- Amm_arb strategy

Copy link
Contributor

@nikspz nikspz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test performed:

  • Cloned PR7159 + gwPR340
  • Installed Client and gateway PR
  • Reviewed gateway ONLINE
  • Curl:
    • Etcswap connector
      • wallet/add: ok
      • /chain/status: ok
      • /chain/tokens?chain=ethereum-classic&network=mainnet: ok
      • /chain/allowances: ok
      • /chain/approve: ok
      • /wallet/remove: ok
      • /amm/price: ok
      • /amm/trade: ok
  • EtcswapLP
    • wallet/add: ok
    • created/started amm_v3_lp strategy successfully
    • review position id matched with exchange
    • amm/liquidity/add: ok
    • amm/liquidity/position: ok
    • amm/liquidity/collect_fees: ok
    • amm/liquidity/remove: ok
  • Amm_arb strategy
    • created/started amm_arb strategy using etcswap_ethereum-classic_mainnet
    • review rate oracle issue related to USC token not available on rate oracle sources (binance and etc.)
      • changed tokenname from USC to USDC
    • started new amm_arb strategy using etcswap_ethereum-classic_mainnet and kucoin
    • review filled orders for both connector_1 and connector_2: ok

@nikspz
Copy link
Contributor

nikspz commented Sep 25, 2024

@vic-en Could you please fix branch conflicts?
I think could be related to this PR: #362

@chris-mercer
Copy link

Please test ETCswap V2 and ETCswap V3 protocols as @vic-en mentioned this PR addressed both bounties. You can find charts for WETC/USC markets in GeckoTerminal now.

https://www.geckoterminal.com/ethereum_classic/etcswap-v2/pools
https://www.geckoterminal.com/ethereum_classic/etcswap-v3/pools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Under Review
Development

Successfully merging this pull request may close these issues.

New Connector Request: Ethereum Classic Network, ETCswap V3
4 participants