Skip to content

Negative yield - yelay lite v4#37

Open
orlicekm wants to merge 19 commits into
mainfrom
feat/negative-yield
Open

Negative yield - yelay lite v4#37
orlicekm wants to merge 19 commits into
mainfrom
feat/negative-yield

Conversation

@orlicekm

@orlicekm orlicekm commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Overview

Major release (v4): emergency strategy removal, correct handling of strategies with management fee when fees create negative yield (loss from principal), and fixes so the vault remains operable after partial or total NAV drops.


Core changes

1. forceDeactivateStrategy (emergency deactivation)

Like deactivateStrategy, but does not require zero strategy assets. Callable by STRATEGY_AUTHORITY (vault not paused). Removes the strategy from the active set and updates deposit/withdraw queues; strategy stays registered and can be re-activated.

Stranded balance is dropped from totalAssets() while tokens may remain in the external protocol, loss is propagated to existing shareholders (same supply, lower NAV).

2. Share / asset conversion & recovery after total loss

  • Negative yield: accrueFee() updates lastTotalAssets down; fee shares mint only on positive interest.
  • _convertToAssets: explicit supply == 0 handling.
  • _convertToShares: reverts VaultInsolvent() if minting shares while totalAssets == 0 and supply > 0.
  • _convertToFeeShares: when lastTotalAssets == 0 and supply > 0, returns 0 instead of reverting so recovery do not brick the vault.

3. Allowance handling (replaces approveStrategy)

Removed approveStrategy, deposit and managedDeposit set exact underlying allowance to the strategy protocol per attempt (_setExactAllowance, zero-then-approve), cleared on failure.

4. YieldExtractor.addTreeRootAndAccrue

Callable by YIELD_PUBLISHER when not paused. Atomically addTreeRoot then IERC4626Plugin.accrue per plugin/claim pair.

5. onlyAnyRole modifier

Caller must hold either role, used for managedWithdraw (FUNDS_OPERATOR or EMERGENCY_WITHDRAW_OPERATOR), with AccessFacet.hasRole queried via delegatecall.

6. Tests

Unit tests were expanded for share/asset math, negative yield, forceDeactivateStrategy, insolvency, and allowance behavior.


Other minor changes

  • ERC4626Plugin.accrue may only be called by an account with ERC4626_ACCRUE_OPERATOR on the vault (not on the plugin).
  • The AccrueInterest event includes totalSupply.
  • New EMERGENCY_WITHDRAW_OPERATOR role.
  • previewRedeem reverts with MinRedeem() when converted assets are at or below WITHDRAW_MARGIN, matching redeem.
  • Obsolete deployment scripts were removed.
  • Setup checks were updated for new roles.

@orlicekm orlicekm changed the title Feat/negative yield Negative yield - yelay lite v4 Jun 3, 2026
@orlicekm orlicekm requested a review from WillSchiller June 3, 2026 20:22
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