You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
It took quite some effort to figure out how to parse the number into something sensible.
The article makes it seem like when you calculate (price0CumulativeLast2 - price0CumulativeLast1) / (timestamp2 - timestamp1) you will get the price of token 0 in terms of token 1 as an integer.
This is however not the case, and instead you get back an UQ112 representation, which you then need to divide by 2**(112-Math.log2(1e18)) or alternatively divide by 2**(112)/1e18.
This is not at all clear from reading the guide.
Note: I assume the 18 is only because of the token having 18 decimals. So in fact it should probably be 2**(112-Math.log2(10**d)) where d is the number of decimals the token has.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It took quite some effort to figure out how to parse the number into something sensible.
The article makes it seem like when you calculate (price0CumulativeLast2 - price0CumulativeLast1) / (timestamp2 - timestamp1) you will get the price of token 0 in terms of token 1 as an integer.
This is however not the case, and instead you get back an UQ112 representation, which you then need to divide by
2**(112-Math.log2(1e18))
or alternatively divide by2**(112)/1e18
.This is not at all clear from reading the guide.
Note: I assume the 18 is only because of the token having 18 decimals. So in fact it should probably be
2**(112-Math.log2(10**d))
where d is the number of decimals the token has.The text was updated successfully, but these errors were encountered: