Skip to content

Conversation

@kyzooghost
Copy link
Contributor

@kyzooghost kyzooghost commented Dec 18, 2025

  • Add check in fundYieldProvider to pause staking if target reserve deficit > 0
  • Update test helpers to use target reserve amount instead of minimum
  • Add test assertions to verify staking is paused after funding with deficit
  • Update test setup to properly configure withdrawal reserve state

This PR implements issue(s) #

Checklist

  • I wrote new tests for my new core changes.
  • I have successfully ran tests, style checker and build against my new changes locally.
  • I have informed the team of any breaking changes if there are any.

Note

Pauses staking during fundYieldProvider if getTargetReserveDeficit() > 0, and updates test helpers/tests to use target reserve and verify pause behavior.

  • Smart Contract (contracts/contracts/yield/YieldManager.sol):
    • Pause staking in fundYieldProvider when getTargetReserveDeficit() > 0 via _pauseStakingIfNotAlready.
  • Tests/Helpers:
    • Switch helper funding precondition from minimumWithdrawalReserveAmount to targetWithdrawalReserveAmount in helpers/setup.ts.
    • Add setWithdrawalReserveToMinimum (and reserve-balance helpers) to configure reserve state using effective thresholds.
    • Update unit tests (YieldManager.funds.ts):
      • Add assertions that isStakingPaused is true after funding with target deficit.
      • Adjust scenarios to set reserve to minimum/target as needed (e.g., before safeAddToWithdrawalReserve).

Written by Cursor Bugbot for commit f55662a. This will update automatically on new commits. Configure here.

…eficit exists

- Add check in fundYieldProvider to pause staking if target reserve deficit > 0
- Update test helpers to use target reserve amount instead of minimum
- Add test assertions to verify staking is paused after funding with deficit
- Update test setup to properly configure withdrawal reserve state
@kyzooghost kyzooghost requested a review from a team as a code owner December 18, 2025 06:58
const minimumReserveAmount = await testYieldManager.minimumWithdrawalReserveAmount();
const targetReserveAmount = await testYieldManager.targetWithdrawalReserveAmount();
const l1MessageServiceAddress = await testYieldManager.getL1MessageService();
await ethers.provider.send("hardhat_setBalance", [l1MessageServiceAddress, ethers.toBeHex(minimumReserveAmount)]);
Copy link

Choose a reason for hiding this comment

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

Bug: Test helpers use absolute target instead of effective target

The helpers fundYieldProviderForWithdrawal and fundLidoStVaultYieldProvider use targetWithdrawalReserveAmount() (absolute value), but getTargetReserveDeficit() in production code checks against _getEffectiveTargetWithdrawalReserve() (effective value that considers percentage-based calculation). The existing helper setWithdrawalReserveToTarget correctly uses getEffectiveTargetWithdrawalReserve(). For large withdrawAmount values where totalSystemBalance exceeds 5000 ETH, the effective target becomes percentage-based and exceeds the absolute target, causing an unexpected deficit and triggering the pause even though the helper's intent was to avoid one.

Additional Locations (1)

Fix in Cursor Fix in Web

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.

2 participants