-
Notifications
You must be signed in to change notification settings - Fork 151
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
Calculation of Quoting for WETH to USDC is Wrong #42
Comments
Hey @arjunaskykok , I've ran into the same problem, and here's what I've found after a bit of debugging: In the example, you're using the token addresses returned by the Like so:
Whereas, what appears to be the case, is that the order in which the contract returns token0 and token1 isn't guaranteed, in fact it appears to be returning the tokens in alphabetical order. One might call it consistently inconsistent. The solution is quite simple, albeit, the examples should be updated to reflect this. Simply don't use the token addresses returned by the pool contract when calling quoteExactInputSingle, as you already know the token addresses anyways.
|
@balazsotakomaiya , Thanks for the solution. It works! |
@balazsotakomaiya fantastic, great investigation and thank you for this. However, I'd like to find out: what are
But it's weird, what data might me needed that we don't already have? Is it possible to get token address for example without knowing it beforehand? |
Using this configuration in
v3-sdk/quoting/config.ts
:I got this result (which is correct):
On Mar 4th, 2023, 1 ETH is $1570. So with $1000, we would get around 0.63 ETH.
But when I switched the tokens, I got the wrong result. I used this configuration:
The result should be ~1570 USDC.
The text was updated successfully, but these errors were encountered: