Skip to content

feat: runoff plan#269

Open
blockgroot wants to merge 16 commits into
mainfrom
feat/sunset-runoff
Open

feat: runoff plan#269
blockgroot wants to merge 16 commits into
mainfrom
feat/sunset-runoff

Conversation

@blockgroot

@blockgroot blockgroot commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adopts the BNBx custody-sweep pattern across ETHx contracts to enable an orderly sunset/wind-down. Each touched contract gains a depositsPaused / assetCustodied gate and a delayed sweepToCustody flow so the multisig can pause new inflows, then sweep idle balances to a custody account after a public delay. Existing user redemption paths revert once assets are custodied so funds settle off-chain.

Changes by contract

  • SDUtilityPool: adds assetCustodied / sweepToCustodyTimestamp / depositsPaused; gates delegate, utilize, withdraw, finalize, maxApproveSD. New admin/manager entrypoints: setCustodyDelay (Admin), setDepositsPaused (Manager), sweepToCustody (Admin).
  • OperatorRewardsCollector: adds custody gates on claim / claimWithAmount / claimLiquidation. Replaces claimOnBehalf with adminSettleOperator (Manager) — pays liquidator, has treasury cover terminal SD interest, nets ETH→treasury, pushes the remainder to the operator.
  • SocializingPool: gates claim, claimAndDepositSD, maxApproveSD behind custody.
  • StaderStakePoolsManager: adds depositsPaused and custody state; gates deposit, validatorBatchDeposit, transferETHToUserWithdrawManager, depositETHOverTargetWeight. Adds setDepositsPaused (Manager), setCustodyDelay (Admin), sweepToCustody (Admin).
  • UserWithdrawalManager: gates requestWithdraw via the StakePoolsManager custody flag.
  • PermissionlessPool: gates preDepositOnBeaconChain / stakeUserETHToBeaconChain; adds setCustodyDelay / sweepToCustody.
  • Interfaces & mocks: extended with custody views/events; mocks return assetCustodied() == false so existing downstream tests keep passing.

Tests

  • New Foundry suites for the sunset paths on every touched contract (SDUtilityPool, OperatorRewardsCollector, SocializingPool, StaderStakePoolManager, PermissionlessPool, UserWithdrawalManager) — ~1,000 lines covering pause toggles, custody-delay enforcement, sweep authorization, and post-sweep revert behavior.
  • New fork test test/fork/sunset-runoff.ts exercising the end-to-end runoff flow.

Test plan

  • forge test passes across all touched suites
  • Fork test test/fork/sunset-runoff.ts passes against a mainnet fork
  • Manually verify: pause → wait delay → sweepToCustody → user-facing entrypoints revert
  • Manually verify adminSettleOperator payouts (liquidator, treasury SD interest, ETH netting, operator remainder)
  • Confirm role wiring: Manager for pause/settle, Admin for custody delay/sweep

Adopt BNBx custody-sweep pattern across ETHx contracts for orderly sunset.

- SDUtilityPool: add assetCustodied/sweepToCustodyTimestamp/depositsPaused; gate delegate/utilize/withdraw/finalize/maxApproveSD; setCustodyDelay (Admin), setDepositsPaused (Manager), sweepToCustody (Admin)
- OperatorRewardsCollector: add assetCustodied/sweepToCustodyTimestamp; gate claim/claimWithAmount/claimLiquidation; replace claimOnBehalf with adminSettleOperator (Manager) that pays liquidator, treasury covers terminal SD interest, nets ETH→treasury, pushes remainder to op
- SocializingPool: add assetCustodied/sweepToCustodyTimestamp; gate claim/claimAndDepositSD/maxApproveSD
- StaderStakePoolsManager: add depositsPaused/assetCustodied/sweepToCustodyTimestamp; gate deposit/validatorBatchDeposit/transferETHToUserWithdrawManager/depositETHOverTargetWeight; setDepositsPaused (Manager), setCustodyDelay (Admin), sweepToCustody (Admin)
- UserWithdrawalManager: gate requestWithdraw
- PermissionlessPool: gate preDepositOnBeaconChain/stakeUserETHToBeaconChain; setCustodyDelay/sweepToCustody
- interfaces + mocks updated
  Returns false so existing tests for downstream contracts (UWM, etc.) keep
  passing without false-positive reverts on the cross-contract gate.
@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.66667% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.14%. Comparing base (dbc8ee1) to head (25afe32).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
contracts/OperatorRewardsCollector.sol 95.23% 2 Missing ⚠️
contracts/SDUtilityPool.sol 94.73% 2 Missing ⚠️
contracts/SocializingPool.sol 90.47% 2 Missing ⚠️
contracts/PermissionlessPool.sol 95.00% 1 Missing ⚠️
contracts/StaderStakePoolsManager.sol 96.42% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #269      +/-   ##
==========================================
+ Coverage   92.67%   93.14%   +0.47%     
==========================================
  Files          45       45              
  Lines        3248     3428     +180     
  Branches      298      380      +82     
==========================================
+ Hits         3010     3193     +183     
+ Misses        234      230       -4     
- Partials        4        5       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant