Open lj92458 opened 1 year ago
If we want to call contract swapRouter.exactInputSingle directly on celo, we must use the correct abi:
import SwapRouter02Abi from '@uniswap/swap-router-contracts/artifacts/contracts/V3SwapRouter.sol/V3SwapRouter.json' assert {type: 'json'}
, and the params
object for exactInputSinglem
method need not have deadline
properties. That means params
should have 7 properties, not 8. See also How to swap Celo tokens on Uniswap programmatically with code , this example has 2 bugs, which have mentioned above.
Other wise, if we want to use js function swaprouter.swapCallParameters on celo, we must create a ts file which is named swapRouter02.ts : copy this code to swapRouter02.ts , then delete all the deadline
properties, and use the correct abi:
import SwapRouter02Abi from '@uniswap/swap-router-contracts/artifacts/contracts/V3SwapRouter.sol/V3SwapRouter.json' assert {type: 'json'}
There are DEXes using the interface with deadline
field, others are not using it. Even Uniswap as a DEX itself seems to not be using the deadline
field, so if you follow their docs which is using the deadline
field it's never gonna work.
This has become a nightmare become we want to support any DEX that is Uniswap compliant, but now there are two versions of the same contract.
Hello from 2024. This discrepancy is annoying. SwapRouter02
seems to be deployed everywhere though (the one without deadline).
celo only has SwapRouter2 celo not have SwapRouter