-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: introduce max change per trade #228
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## fix/oracle-struct #228 +/- ##
==================================================
Coverage 88.21% 88.21%
==================================================
Files 12 12
Lines 611 611
==================================================
Hits 539 539
Misses 72 72 ☔ View full report in Codecov by Sentry. |
} else { | ||
assert(aPrevClampedPrice > aCurrRawPrice); | ||
rClampedPrice = aPrevClampedPrice.fullMulDiv(1e18 - maxChangeRate * aTimeElapsed, 1e18); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the auditors missed this. This underflow vuln has got to be a critical, and is live on our production pairs right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the vuln, it freezes the pair if it overflows? How realistic is 1e18 seconds elapsed, surely that's like super far away?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's the product of maxChangeRate
and aTimeElapsed
that's easy to overflow 1e18
.
e.g. 86400 (seconds in a day) * 0.00003e18 (0.3bp / s) = 2.592e18 > 1e18
Yes it freezes the pair as it's an arithmetic underflow. I discovered it during regression testing. Kinda weird that it didn't show up before
Motivation
Solution
with the implementation of this extra check (max change per trade), there are 4 possible scenarios: