v3-sdk
v3-sdk copied to clipboard
Difference outputAmount returned by Pool.getOutputAmount() in uniV3-SDK and SwapRouter.exactInputSingle() in uniV3-periphery for only one pool
Hello everyone, I tried to use Pool.getOutputAmount() in uniV3-SDK and SwapRouter.exactInputSingle() in uniV3-periphery to perform a swap within a given pool then compare the two results. I use hardhat for forking the mainnet and execute the script for Pool.getOutputAmount() at first (because it doesn't change the state of EVM) then the script for SwapRouter.exactInputSingle() at the seconds. I take 6 pools for the test:
- ZDEX - WETH: '0x46087cEeD975CFfC0074C5d4A7e8f1150E7CECf6'
- USDC - WETH: '0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8'
- YAY - WETH: '0xC3e4E5c19984BE13bB52F5D14FfBf6a13ea0838B'
- DFM - WETH: '0x919F58bc429c7cF96905EB79395F5B77D9b98b52'
- WETH - MRXe: '0x7eC0bE8aa9fBc1d8aB40Aa5b1fd0E46d66120eDf'
- WETH - R64X: '0xAb44Da6A8180D0f75d214d3616970E0C93BBFBAa'
In each test, I swap 1 WETH for another token in each pool. I have only one pair of outputAmount which has difference result for the pool DFM - WETH: '0x919F58bc429c7cF96905EB79395F5B77D9b98b52' . The results of the others pools are good. Here is my SDK scripts :
And here is my periphery script:
For example of the result:
- Pool 2 (USDC - WETH): Input 1 WETH +) SDK output: 3243438919 +) Periphery output: 3243438919
- Pool 4 (DFM - WETH): input 1 WETH (the problem is here) +) SDK output: 28785598159162986664347 +) Periphery output: 28785598159162986644716
I don't know why. Can you explain to me please? Thank you!
Open
446477chancey # #
Hey @Tien-Thao-NGUYEN this is likely due to incomplete tick data in your SDK pool entity.I'd suggest you use the Quoter instead of pool in this case.
Hello everyone, I tried to use Pool.getOutputAmount() in uniV3-SDK and SwapRouter.exactInputSingle() in uniV3-periphery to perform a swap within a given pool then compare the two results. I use hardhat for forking the mainnet and execute the script for Pool.getOutputAmount() at first (because it doesn't change the state of EVM) then the script for SwapRouter.exactInputSingle() at the seconds. I take 6 pools for the test:
- ZDEX - WETH: '0x46087cEeD975CFfC0074C5d4A7e8f1150E7CECf6'
- USDC - WETH: '0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8'
- YAY - WETH: '0xC3e4E5c19984BE13bB52F5D14FfBf6a13ea0838B'
- DFM - WETH: '0x919F58bc429c7cF96905EB79395F5B77D9b98b52'
- WETH - MRXe: '0x7eC0bE8aa9fBc1d8aB40Aa5b1fd0E46d66120eDf'
- WETH - R64X: '0xAb44Da6A8180D0f75d214d3616970E0C93BBFBAa'
In each test, I swap 1 WETH for another token in each pool. I have only one pair of outputAmount which has difference result for the pool DFM - WETH: '0x919F58bc429c7cF96905EB79395F5B77D9b98b52' . The results of the others pools are good. Here is my SDK scripts :
![]()
And here is my periphery script:
![]()
For example of the result:
- Pool 2 (USDC - WETH): Input 1 WETH +) SDK output: 3243438919 +) Periphery output: 3243438919
- Pool 4 (DFM - WETH): input 1 WETH (the problem is here) +) SDK output: 28785598159162986664347 +) Periphery output: 28785598159162986644716
I don't know why. Can you explain to me please? Thank you!
Hey @Tien-Thao-NGUYEN , I've seen your code and I was wondering why are you putting "inputAmount" as a parameter in the CurrencyAmount's fromRawAmount function. I can see that inputAmount is a JSBI variable, but the parameter must be a "BigIntIsh" type. How did you solve that? Sorry for the newbie question, I'm trying to understand that
Any solutions ?