-
Notifications
You must be signed in to change notification settings - Fork 3
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
refactor: Auto _setBalanceInfo
#20
refactor: Auto _setBalanceInfo
#20
Conversation
Changes to gas cost
🧾 Summary (20% most significant diffs)
Full diff report 👇
|
LCOV of commit
|
_setBalanceInfo(account_, true, currentIndex_, rawBalance_); | ||
if (currentIndex_ == index_) return 0; | ||
|
||
_updateIndex(account_, currentIndex_); |
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.
different suggestion: move yield calculation inside updateIndex
. Rename updateIndex
into updateEarnerIndex
to improve comprehension and readability.
uint256 yield_ = updateEarnerIndex(account_, currentIndex_);
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 prefer not to since it will result in a cleaner change to the next PR that tackles start/stop (as well as more complex upgrades). Further, since _updateIndex
never needs to compute yield, doing this creates unnecessary coupling to overcomplicate an otherwise straightforward and single-task _updateIndex
.
1ad5b73
to
72ceab3
Compare
ffc457f
to
67a75a7
Compare
_setBalanceInfo
now always takes the amount and index (if any) and computes the principal, so no more awkward handling of "raw balance" that is either pincipla or present amounts. Similarly,_getBalanceInfo
now returns explicit principal and present amounts for the balance, saving lines elsewhere and getting rid of the awkward handling of "raw balance".