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

Optional claim/stash SP ETH rewards #158

Merged
merged 8 commits into from
May 9, 2024
Merged

Optional claim/stash SP ETH rewards #158

merged 8 commits into from
May 9, 2024

Conversation

RickGriff
Copy link
Collaborator

@RickGriff RickGriff commented May 4, 2024

  • Depositor passes a bool doClaim when providing/withdrawing from SP. They can choose to either have their ETH gains paid out, or stashed for future claiming
  • A new function claimAllETHGains pays out a depositor's total ETH gain (current gains accrued since last touch, and stashed gains)

Closes #122

@bingen bingen linked an issue May 7, 2024 that may be closed by this pull request
Copy link
Collaborator

@bingen bingen left a comment

Choose a reason for hiding this comment

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

LGTM!


// If they have a deposit, update it and update its snapshots
if (initialDeposit > 0) {
currentETHGain = getDepositorETHGain(msg.sender); // Only active deposits can only have a current ETH gain
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess only one only is enough 😉

Copy link
Collaborator Author

@RickGriff RickGriff May 8, 2024

Choose a reason for hiding this comment

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

Only one comment? I was trying to say two things here: the second line aims to point out that their current gain must be zero if their deposit initial value is zero.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I meant that the second comment says “only” twice. And I guess it doesn’t mean that active deposits cannot have stashed gains.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh! haha, right. Should just be one. Fixed.

uint256 stashedETHGain = stashedETH[msg.sender];
uint256 ETHToSend = currentETHGain + stashedETHGain;

stashedETH[msg.sender] = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Aren’t these 3 lines the same as _getTotalETHGainAndZeroStash? Can’t we reuse that function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, good point! I've refactored that

@RickGriff RickGriff merged commit 963df88 into main May 9, 2024
7 checks passed
@danielattilasimon danielattilasimon deleted the stash_sp_rewards branch June 13, 2024 04:42
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

Successfully merging this pull request may close these issues.

Allow to not claim rewards
2 participants