这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@vic-en
Copy link
Collaborator

@vic-en vic-en commented Apr 5, 2023

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:
This pr adds the a Zigzag connector which connector to the Zigzag contract on Arbitrum.
[ch 37878]

Tests performed by the developer:

  • Curl tests
  • Unit tests
  • End-to end testing between client and Gateway.

Tips for QA testing:

  • Perform curl tests using newly added curl commands in this pr.
  • Perform end-to end testing between client and Gateway.

@rapcmia rapcmia requested review from fengtality, nikspz and rapcmia April 5, 2023 04:03
@vic-en vic-en changed the title Feat/zigzag Feat/zigzag connector Apr 5, 2023
@vic-en vic-en mentioned this pull request Apr 12, 2023
2 tasks
@nikspz
Copy link
Contributor

nikspz commented Apr 12, 2023

Initial tests:

  • Tests performed:
  • cloned and install gateway zigzag + latest development
  • start the client and gwPR82 successfully
  • checked zigzag successfully added to gateway list
  • connect zigzag successfully
  • balance matched with the exchange
  • created amm_arb strategy using zigzag
  • bot failed to start amm_arb strategy, stuck on waiting for allowances: use trading interface to do manual approval
  • approved manually on the exchange, still couldn't start the amm_arb profitability calculation

image

image

exchange reported not enough liquidity to do swap:
image

Curl:
./requests/eth_zigzag_trade.json)" https://localhost:15888/amm/trade - Failed to trade using Curl command

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/eth_zigzag_trade.json)" https://localhost:15888/amm/trade | jq

Pending:
Curl tests

@rapcmia
Copy link
Contributor

rapcmia commented Apr 13, 2023

PR update:

  • Tested on local using WSL Ubuntu20.04
  • Setup with latest client development branch
  • Gateway connection successful
  • Import latest gateway collections and env
  • Ran endpoint tests using thunder client
    • Port and connectors ok
    • Wallet {add, get, remove} ok
    • nonce and nextNonce ok
    • allowance {WETH, USDC, USDT, DAI} ok
    • approve {WETH, USDC}
      image
      • screenshot above shows successful tx however on the exchange when checking prices and swap we are prompted to approve again for both WETH-USDC
        image
        • Tested swapping values 9 and 13 still the same behavior
    • price
      • Observed that for SELL the price is showing 0, while the BUY shows infinity
        image
        image
    • trade
      image
      image
      • Observed that issues on prices affects trade endpoint resulting errors on the screenshot above

Basic tests like setting up wallet and connector works, this PR is good to be approved under bronze tier standard noted that community is advise of known issues of the exchange.

@nikspz
Copy link
Contributor

nikspz commented Apr 13, 2023

Update:
have same issue with the infinite price reported above, so bot failed to start amm_arb

Observed that for SELL the price is showing 0, while the BUY shows infinity

Steps to reproduce:

  1. Clone the repo
  2. connect zigzag on arbitrum
  3. create/start amm_arb strategy using WETH-USDC, make sure both tokens approved

Actual:
Bot spammed with Unhandled error in background task: [<class 'decimal.InvalidOperation'>] (See log file for stack trace dump)

logs_ammzigzag.log

2023-04-13 16:47:41,858 - 69 - hummingbot.core.utils.async_utils - ERROR - Unhandled error in background task: [<class 'decimal.InvalidOperation'>]
Traceback (most recent call last):
  File "/home/etozhe/development/hummingbot/core/utils/async_utils.py", line 9, in safe_wrapper
    return await c
  File "/home/etozhe/development/hummingbot/strategy/amm_arb/amm_arb.py", line 213, in main
    profitable_arb_proposals: List[ArbProposal] = [
  File "/home/etozhe/development/hummingbot/strategy/amm_arb/amm_arb.py", line 215, in <listcomp>
    if t.profit_pct(
  File "/home/etozhe/development/hummingbot/strategy/amm_arb/data_types.py", line 145, in profit_pct
    ((sell_gained_net_in_buy_quote_currency - buy_spent_net) / buy_spent_net)
decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]

image

@vic-en
Copy link
Collaborator Author

vic-en commented Apr 13, 2023

@rapcmia @nikspz
The issue you're getting with the price and trade is due to the recent contract upgrade on their end.
I updated the contract address and code to work with recent update.

@rapcmia
Copy link
Contributor

rapcmia commented Apr 14, 2023

@rapcmia @nikspz
The issue you're getting with the price and trade is due to the recent contract upgrade on their end.
I updated the contract address and code to work with recent update.

@vic-en thanks for the update 🚀

  • Test latest commit eb874fa17012e
  • Run tests on thunder client
    • Approve
      image
      • Confirmed that we are not being prompted to approve on exchange anymore
    • Trade
      image
      • Getting Cannot read properties of undefined (reading 'split') for both buy and sell
      • Check gateway logs
         2023-04-14 02:40:28 | error | 	Cannot read properties of undefined (reading 'split') | TypeError: Cannot read properties of undefined (reading 'split')
             at EVMTxBroadcaster.<anonymous> (/home/rapcmia/github/gateway/82/dist/src/chains/ethereum/evm.broadcaster.js:74:90)
             at Generator.throw (<anonymous>)
             at rejected (/home/rapcmia/github/gateway/82/dist/src/chains/ethereum/evm.broadcaster.js:6:65)
             at processTicksAndRejections (node:internal/process/task_queues:96:5)
        
        • Getting the same error on endpoint tests
        • Observed this is the same case for client when tested

logs_amm-zigzag.log
logs_gateway_app.log - Copy.2023-04-14.log

@vic-en
Copy link
Collaborator Author

vic-en commented Apr 15, 2023

@rapcmia @nikspz
The issue you're getting with the price and trade is due to the recent contract upgrade on their end.
I updated the contract address and code to work with recent update.

@vic-en thanks for the update 🚀

  • Test latest commit eb874fa17012e

  • Run tests on thunder client

    • Approve
      image

      • Confirmed that we are not being prompted to approve on exchange anymore
    • Trade
      image

      • Getting Cannot read properties of undefined (reading 'split') for both buy and sell

      • Check gateway logs

         2023-04-14 02:40:28 | error | 	Cannot read properties of undefined (reading 'split') | TypeError: Cannot read properties of undefined (reading 'split')
             at EVMTxBroadcaster.<anonymous> (/home/rapcmia/github/gateway/82/dist/src/chains/ethereum/evm.broadcaster.js:74:90)
             at Generator.throw (<anonymous>)
             at rejected (/home/rapcmia/github/gateway/82/dist/src/chains/ethereum/evm.broadcaster.js:6:65)
             at processTicksAndRejections (node:internal/process/task_queues:96:5)
        
        • Getting the same error on endpoint tests
        • Observed this is the same case for client when tested

logs_amm-zigzag.log logs_gateway_app.log - Copy.2023-04-14.log

@rapcmia I improved the logging in this case.
Base on my testing in the past, the node most likely rejected the transaction due to insufficient gas to cover for the transaction, or some other reason which will be clearly stated in the logs now.

Copy link
Contributor

@rapcmia rapcmia left a comment

Choose a reason for hiding this comment

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

LGTM

  • Tested local using WSL ubuntu20.04
  • Successfully created docker image on gateway
  • Tested using source with latest client development branch
  • Setup wallet successfully, ran gateway connector tokens {connector} {tokens}, balances displayed ok
  • Ran gateway list, zigzag now available
  • Ran endpoint tests using thunder client
    • port, wallet and balances ok
    • price and approve ok
    • reported issues on trade has been fixed
      • if balance is insufficient, not possible to trade with error on client and docker logs
    • Tested on client with AMM arbitrage, same results with endpoint

@fengtality fengtality mentioned this pull request Apr 20, 2023
2 tasks
@fengtality
Copy link
Contributor

See updated version in #89

@fengtality fengtality closed this Apr 20, 2023
@fengtality
Copy link
Contributor

I have reviewed and approve these changes, so I will merge in the new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants