Closed fadeev closed 3 weeks ago
@andresaiello wdyt?
Important to handle edge case, where one of the tokens (input or output) is ZETA. If we swap directly without checking for that, Uniswap will return "identical addresses" error.
Once this is done, update the example contracts and share txs of successful transfers using this helper.
Keep the current functions under names appending "Directly" like "swapExactTokensForTokensDirectly".
New function (always through ZETA): swapExactTokensForTokens Current functionality: swapExactTokensForTokensDirectly
Maybe there is a better way where it first tries directly, and if fails (not enough liquidity), then through ZETA.
Isn't that already implemented here?🤔
@lukema95 the problem is when a pool exists, but there is no liquidity there. For example, for Ethereum USDC and BNB USDC a pool exists, but swap fails, because there is no liquidity.
@lukema95 the problem is when a pool exists, but there is no liquidity there. For example, for Ethereum USDC and BNB USDC a pool exists, but swap fails, because there is no liquidity.
Got it. I would like to complete it.
We have liquidity pools on testnet with zero liquidity in them. For example USDC Sepolia/tBTC. Our swap helpers try to swap using a direct pair and if it doesn't exist they swap through ZETA.
This may work in production, where pools actually have liquidity and direct pair is preferable, but on testnet, where we have pools with zero liquidity, it becomes impossible to swap between certain tokens, because the helper first tries to use a zero liquidity direct pool.
I propose changing the helpers to always swap through ZETA to ensure that all swaps go through.
https://github.com/zeta-chain/toolkit/blob/d952cd7b67526c218e07030263d0d5413ab0e64c/contracts/SwapHelperLib.sol