Refresh osToken converter after harvest and haircut withdrawable cap - #822
Open
cyc60 wants to merge 1 commit into
Open
Refresh osToken converter after harvest and haircut withdrawable cap#822cyc60 wants to merge 1 commit into
cyc60 wants to merge 1 commit into
Conversation
This was referenced Aug 18, 2026
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.
Description
Fixes deterministic
InvalidReceivedAssetsreverts on cap-bound partial redemptions by (1) recreating the osToken converter afterupdate_vaults_statesettles and (2) applying a small haircut when a position is capped to the vault's withdrawable assets.OsTokenVaultController.convertToAssetsgrows every second viaavgRewardPerSecond. The converter used for the shares↔assets math was snapshotted beforeupdate_vaults_statewaited for harvest receipts, so by the time a redemption transaction landed, the true rate had moved past the snapshot.That mattered exactly in the partial-redemption path: when a position is capped to the vault's withdrawable assets, the operator computed
shares_to_redeem = to_shares(withdrawable)with the stale rate, i.e. shares whose true value already equals (or exceeds) everything the vault can pay out. On-chain,_redeemOsTokenrecomputesreceivedAssetswith the current rate and reverts withInvalidReceivedAssetswhen it exceedsavailableAssets(OsTokenUtils.sol) — and the margin for error is < 2 wei of flooring slack against ~1e10 wei of rate growth per 12 seconds of lag.Example. Vault has 5 ETH withdrawable; the position is worth 8 ETH, so it is capped. Converter snapshot says 5 ETH = 4.75 osETH shares; the operator submits 4.75 shares. Twenty-four seconds later the transaction is included, 4.75 shares now convert to 5.00000002 ETH > 5 ETH available → revert. Every cycle replays the same math with the same lag, so the vault contributes 0 toward the queue until it is topped up past the full position value.
Fix.
update_vaults_state(harvests change state and take receipt-wait time; a pre-harvest snapshot is guaranteed stale)._apply_withdrawable_haircuttargets 99.9% of the withdrawable amount (WITHDRAWABLE_ASSETS_HAIRCUT = 0.999), leaving ~5 ETH × 0.001 = 0.005 ETH of headroom — several orders of magnitude more than the rate drifts between simulation and inclusion, while the residual remains redeemable in the next cycle.Final PR of the redeem-loop stack — based on #821's branch, which builds on #820.