-
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
Add thoughts for possibility of start earning #18
Conversation
LCOV of commit
|
f5f3f4c
to
1ad5b73
Compare
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.
One issue I see with being able to start/stop when the wrapper is earning, is the difficulty to account for earned WM between earning and non earning period.
For example:
- at t0, the wrapper is earning and one user starts earning WM and we record the index at which he started earning
- at t1, the wrapper stops earning but the user is still earning and nobody calls
stopEarningFor
on behalf of the user - at t2, the wrapper starts earning again, the user then decide to claim their yield. Since they haven't claimed or stopped earning before, their last recorded index is the one at t0 and the current index is the one at t2, so they can claim all the yield between t0 and t2 when they should only be able to claim the yield between t0 and t1.
One fix could be to store two indexes:
- the one when
startEarningM
was last called - the one when
stopEarningM
was last called
This way, you could claim the yield between t0 and t1 as well as the yield between t2 and a future t3 but not in between t1 and t2. That being said, if you haven't claimed before stopEarningM
is called again, you would forfeit any yield you haven't claimed.
@@ -89,7 +117,7 @@ contract WrappedM is IWrappedM, Migratable, ERC20Extended { | |||
_addTotalEarningSupply(rawBalance_, currentIndex_); | |||
} | |||
|
|||
function stopEarningFor(address account_) external { | |||
function stopEarningFor(address account_) external onlyWhenEarner { |
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 don't think onlyWhenEarner
is necessary since you can't be earning if the wrapper hasn't been earning in the past and you should be able to stop earning if the wrapper is not earning anymore.
function stopEarningFor(address account_) external onlyWhenEarner { | |
function stopEarningFor(address account_) external { |
@@ -48,6 +57,22 @@ contract WrappedM is IWrappedM, Migratable, ERC20Extended { | |||
|
|||
/* ============ Interactive Functions ============ */ | |||
|
|||
function wrap(address destination_, uint256 amount_) external onlyWhenEarner { |
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.
Users should be able to wrap even if the wrapper is not currently earning.
function wrap(address destination_, uint256 amount_) external onlyWhenEarner { | |
function wrap(address destination_, uint256 amount_) external { |
uint128 public lastIndexOfTotalEarningSupply; | ||
|
||
modifier onlyWhenEarner() { | ||
if (isEarner == true) revert NotInEarnerState(); |
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.
if (isEarner == true) revert NotInEarnerState(); | |
if (!isEarner) revert NotInEarnerState(); |
1ad5b73
to
72ceab3
Compare
good idea, worth experimenting with it for the next version |
No description provided.