-
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
fix: enable/disable earning in HubPortal #20
base: main
Are you sure you want to change the base?
Conversation
LCOV of commit
|
Changes to gas cost
🧾 Summary (20% most significant diffs)
Full diff report 👇
|
super._initialize(); | ||
|
||
// set _disablePortalIndex to the default value on first deployment | ||
if (_disablePortalIndex == 0) { |
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.
why this check is required? isn't it 0 by default on initialize?
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 want to set _disablePortalIndex
to EXP_SCALED_ONE
only during first initialization, and do not override it after
/// @dev Array of indices at which earning was enabled or disabled. | ||
uint128[] internal _enableDisableEarningIndices; | ||
/// @dev The M token's index when earning was most recently enabled | ||
uint128 private _enableMTokenIndex; |
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.
why names_disablePortalIndex
and _enableMTokenIndex
are not symmetrical? why private and not internal?
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.
_disablePortalIndex
is the last index of the Portal when earning was disabled, it's "virtual" index.
_enableMTokenIndex
is the index of M Token when earning was enabled, the "actual" index.
Private
because we're not planning to inherit from HubPortal
e3c810f
to
6683a6e
Compare
Proposed changes:
isApproveEarner
check fromenableEarning()
anddisableEarning()
functions, since the same check already exists inMToken
startEarning()
andstopEarning(address)
functions.HubPortal
calculated proportionally to the current M Token index.Benefits of "virtual index":
EXP_SCALE_ONE
to the latest current index on the Hub but will be increased gradually.Drawbacks of "virtual index":