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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

update(TwabLib): uniform uint types for calculations #170

Merged
merged 2 commits into from
Oct 6, 2021

Conversation

kamescg
Copy link
Contributor

@kamescg kamescg commented Oct 5, 2021

No description provided.

@kamescg kamescg added the documentation Improvements or additions to documentation label Oct 5, 2021
@kamescg kamescg self-assigned this Oct 5, 2021
@linear
Copy link

linear bot commented Oct 5, 2021

POOL-1670 TwabLib: _computeNextTwab should be casted to uint224

Line: https://github.com/pooltogether/pooltogether-contract-tsunami/blob/ec1e547eb5027b6c5323be8f9dcb25d89ae9b59c/contracts/libraries/TwabLib.sol#L322

In the **_computeNextTwab **function, we cast amount to uint208 but in the ObservationLib we can see that amount in theObservation struct is casted touint224.

(https://github.com/pooltogether/pooltogether-contract-tsunami/blob/3e535ef0acccd270324d47c22aa0215773173c25/contracts/libraries/ObservationLib.sol#L25)

Fix:

``**toUint208 **should be replaced by **toUint224**

Also see if we can pass _currentBalance in uint224

_currentTwab.amount +
_currentBalance *
(_time.checkedSub(_currentTwab.timestamp, _time))
).toUint224(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to cast here? current balance is uint224 and currentTwab.amount is uint 224. I think we can skip the cast

@asselstine asselstine merged commit 5946881 into master Oct 6, 2021
@asselstine asselstine deleted the pool-1670-twablib-_computenexttwab-should-be branch October 6, 2021 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants