Skip to content
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

Uniswap Oracle reports incorrect rates for certain YAM token addresses #77

Open
prestwich opened this issue Aug 16, 2020 · 2 comments
Open

Comments

@prestwich
Copy link

This line has the reserves out of order. If it is executed, it will cause the oracle to return an incorrect price. This will cause incorrect rebases.

https://github.com/yam-finance/yam-protocol/blob/master/contracts/lib/UniswapV2OracleLibrary.sol#L31

The bug depends on whether the YAM address is numerically higher or lower than the token it's paired with. Therefore it is either activated at deploy time, or never activated. Thankfully it does not seem that this bug was activated on the existing deploys.

It seems to have been caused by a copy-paste error when modifying the Uniswap library. Perhaps consider using the Uniswap library directly.

Fix is simple. Change to FixedPoint.fraction(reserve0, reserve1)._x)

@brockelmore
Copy link
Contributor

Amazing find. Thanks!

Unfortunately this wasn't caught in our test suite, but would have been had any test deployment resulted in isToken0 to be false. As we have a positive and negative rebase test that would have failed. But didn't have any deployments where we hit that.

@prestwich
Copy link
Author

cool. I'm happy to submit a PR for the fix if you'd like, but won't have time to spend on testing it

hamburglar1971 pushed a commit to its-ham/protocol that referenced this issue Oct 25, 2020
hamburglar1971 added a commit to its-ham/protocol that referenced this issue Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants