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

fix: tweaks to thawing pool management #1048

Merged
merged 8 commits into from
Oct 9, 2024
Merged

Conversation

tmigone
Copy link
Contributor

@tmigone tmigone commented Sep 20, 2024

A few notes:

Provision

  • Thawing pool reset condition is tokensThawing == 0 (empty pool)
  • When a provision is fully slashed any ongoing thawing is cancelled
    • sharesThawing is set to 0
    • a nonce tied to the thawing pool is incremented, this invalidates existing thaw requests which in practice means when they are fulfilled they get 0 tokens.

Delegation Pool

  • Delegation pool reset conditions are:
    • tokens ==0 && shares ==0 (empty pool) or tokens == thawingTokens (pool fully thawing)
  • When a delegation pool is fully slashed any ongoing thawing is cancelled
    • sharesThawing is set to
    • nonce incremente to invalidate thaw requests
  • Delegation pool invalid state
    • When the pool state is tokens == 0 && shares != 0 as a result of a delegation pool being fully slashed
    • Pool can be recovered by using addTokensToDelegationPool(). This is the only delegation pool action that can be performed on invalid state pools
    • Delegators with shares thawing at the moment the pool gets to the invalid state loose their thawing shares and are not given delegation pool shares in return (they are all worth 0 tokens aynways)

@tmigone tmigone marked this pull request as draft September 20, 2024 20:52
Copy link

openzeppelin-code bot commented Sep 20, 2024

fix: tweaks to thawing pool management

Generated at commit: 1b3263abe2c3e4c5f336955f66fc704f757d0578

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
2
4
0
15
40
61
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@tmigone tmigone marked this pull request as ready for review September 23, 2024 20:03
@tmigone tmigone changed the title fix: wip tweaks to thawing pool management fix: tweaks to thawing pool management Sep 23, 2024
@tmigone tmigone requested a review from Maikol October 1, 2024 17:25
Copy link
Member

@Maikol Maikol left a comment

Choose a reason for hiding this comment

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

Looks good to me 🥇

packages/horizon/test/staking/delegation/addToPool.t.sol Outdated Show resolved Hide resolved
Signed-off-by: Tomás Migone <[email protected]>
Copy link
Member

@pcarranzav pcarranzav left a comment

Choose a reason for hiding this comment

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

LGTM 🎸

@Maikol Maikol merged commit 7035403 into horizon Oct 9, 2024
5 checks passed
@Maikol Maikol deleted the tmigone/thawing-fixes branch October 9, 2024 15:12
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.

3 participants