Negative yield - yelay lite v4#37
Open
orlicekm wants to merge 19 commits into
Open
Conversation
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.
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 bySTRATEGY_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
accrueFee()updateslastTotalAssetsdown; fee shares mint only on positive interest._convertToAssets: explicitsupply == 0handling._convertToShares: revertsVaultInsolvent()if minting shares whiletotalAssets == 0and supply > 0._convertToFeeShares: whenlastTotalAssets == 0andsupply > 0, returns 0 instead of reverting so recovery do not brick the vault.3. Allowance handling (replaces
approveStrategy)Removed
approveStrategy,depositandmanagedDepositset exact underlying allowance to the strategy protocol per attempt (_setExactAllowance, zero-then-approve), cleared on failure.4.
YieldExtractor.addTreeRootAndAccrueCallable by
YIELD_PUBLISHERwhen not paused. AtomicallyaddTreeRootthenIERC4626Plugin.accrueper plugin/claim pair.5.
onlyAnyRolemodifierCaller must hold either role, used for
managedWithdraw(FUNDS_OPERATORorEMERGENCY_WITHDRAW_OPERATOR), withAccessFacet.hasRolequeried via delegatecall.6. Tests
Unit tests were expanded for share/asset math, negative yield,
forceDeactivateStrategy, insolvency, and allowance behavior.Other minor changes
ERC4626Plugin.accruemay only be called by an account withERC4626_ACCRUE_OPERATORon the vault (not on the plugin).AccrueInterestevent includestotalSupply.EMERGENCY_WITHDRAW_OPERATORrole.previewRedeemreverts withMinRedeem()when converted assets are at or belowWITHDRAW_MARGIN, matchingredeem.