Repository navigation
Fix zero-shares penalty routing in staking vault - #1909
Merged
Merged
Conversation
|
@wanda8028379 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix zero-shares penalty routing in staking vault
What was solved
#1809 — [Contract] — staking-vault:
route_penalty_to_poolWhen Pool Has Zero Total SharesAdd zero-total-shares handling to
route_penalty_to_poolin the staking-vault contract so penalties are parked as pending rewards (consistent withtest_deposit_fees_with_zero_shares_parks_in_pending_rewards) instead of dividing by zero, and cover the behavior with tests for zero-share routing, recovery after a new staker joins, and proportional distribution with nonzero shares.Addressed:
route_penalty_to_poolincontracts/staking-vault/src/fees.rsdoes not divide by zero whentotal_shares == 0.total_shares == 0(park as pending rewards, consistent withtest_deposit_fees_with_zero_shares_parks_in_pending_rewards).Changes
contracts/staking-vault/src/fees.rs(modify)contracts/staking-vault/src/pool.rs(modify)Approach
contracts/staking-vault/src/fees.rsroute_penalty_to_poolandcontracts/staking-vault/src/pool.rsto confirm the zero-total_sharesdivision path and existing pending-reward fields.route_penalty_to_poolto park the penalty as pending rewards whentotal_shares == 0, mirroring the existing zero-shares deposit behavior, and keep proportional distribution when shares are nonzero.contracts/staking-vault/tests/staking_tests.rsfor zero-share routing without panic, recovery after a new staker joins, and proportional distribution with nonzero shares.Issues
Closes #1809