Skip to content

Fix zero-shares penalty routing in staking vault - #1909

Merged
Olowodarey merged 1 commit into
Arena1X:mainfrom
wanda8028379:drips/1809
Sep 28, 2026
Merged

Olowodarey merged 1 commit into
Arena1X:mainfrom
wanda8028379:drips/1809

Conversation

@wanda8028379

Copy link
Copy Markdown
Contributor

Summary

Fix zero-shares penalty routing in staking vault

What was solved

#1809 — [Contract] — staking-vault: route_penalty_to_pool When Pool Has Zero Total Shares

Add zero-total-shares handling to route_penalty_to_pool in the staking-vault contract so penalties are parked as pending rewards (consistent with test_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:

  • Changed: contracts/staking-vault/src/fees.rs, contracts/staking-vault/src/pool.rs
  • Confirm route_penalty_to_pool in contracts/staking-vault/src/fees.rs does not divide by zero when total_shares == 0.
  • Define where the penalty goes when total_shares == 0 (park as pending rewards, consistent with test_deposit_fees_with_zero_shares_parks_in_pending_rewards).
  • Ensure penalty routed with zero shares is recoverable once a new staker joins the pool.

Changes

  • contracts/staking-vault/src/fees.rs (modify)
  • contracts/staking-vault/src/pool.rs (modify)

Approach

  1. Inspect contracts/staking-vault/src/fees.rs route_penalty_to_pool and contracts/staking-vault/src/pool.rs to confirm the zero-total_shares division path and existing pending-reward fields.
  2. Update route_penalty_to_pool to park the penalty as pending rewards when total_shares == 0, mirroring the existing zero-shares deposit behavior, and keep proportional distribution when shares are nonzero.
  3. Ensure parked pending rewards are folded into the pool when a new staker joins, so the penalty is recoverable.
  4. Add tests in contracts/staking-vault/tests/staking_tests.rs for zero-share routing without panic, recovery after a new staker joins, and proportional distribution with nonzero shares.

Issues

Closes #1809

@drips-wave

drips-wave Bot commented Sep 27, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@vercel

vercel Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
insight-arena-4rll Error Error Sep 27, 2026 3:17am UTC

@Olowodarey
Olowodarey merged commit 251cbc8 into Arena1X:main Sep 28, 2026
1 of 5 checks passed

This branch had an error being deployed

1 failed deployment
Preview — ac5e51ce Deployed Sep 27, 2026 by vercel[bot]
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.

[Contract] — staking-vault: route_penalty_to_pool When Pool Has Zero Total Shares

2 participants