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

Use math lib for underfloweding #4

Open
alexisgayte opened this issue Jan 28, 2021 · 2 comments
Open

Use math lib for underfloweding #4

alexisgayte opened this issue Jan 28, 2021 · 2 comments

Comments

@alexisgayte
Copy link

alexisgayte commented Jan 28, 2021

https://github.com/brianmcmichael/dss-vest/blob/f808e8a942305dcc3409f00cf320d06283a761d8/src/DssVest.sol#L77

Or block.timestamp need to be casted as well

@brianmcmichael
Copy link
Contributor

None of these values should be able to underflow. See the init which ensures fin is always gt bgn and also no more than 5 years out.

@alexisgayte
Copy link
Author

alexisgayte commented Jan 29, 2021

Wrote on the other issue,
the issue is more that the code is not correct whatever if time is 5 years or not. if you cast block.timestamp it becomes correct as you will roll over with the top expression too.

(block.timestamp - _award.bgn) * WAD / (_award.fin - _award.bgn)

(_award.fin - _award.bgn) can go negative while (block.timestamp - _award.bgn) will stay positive.
you get a negative result.

Ok it is not underflow you got the point but the issue is still here.

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