Repository navigation
fix(H5): mark wstETH at the Lido exchange rate, not the DEX spot - #16
Merged
Merged
Conversation
Audit H5: wstethUsdWad marked wstETH at the lower of the exchange rate and the instantaneous UniV3 slot0 spot. slot0 is flash-loan manipulable within a block, and because it was the lower-of, an attacker could push the mark DOWN (front-run settleEpoch, depress the pool, mint extra shares cheaply, back-run) to skew share pricing. Fix: mark wstETH purely at stEthPerToken x ETH/USD, the fundamental redemption value and the standard wstETH-collateral marking (Aave/Morpho). It is not flash-manipulable, so it cannot skew NAV or settlement pricing. The pool spot is kept ONLY as a depeg gate on BUYING more wstETH (wstethBuyAllowed), where a manipulated spot is fail-safe: it can only block a buy, never inflate value. Regression: a basis breach keeps the mark at the exchange rate while blocking buys; an extreme flash-pushed pool spot leaves the mark unchanged. 116 -> 117.
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.
Audit finding H5 (High)
wstethUsdWad()marked wstETH at the lower of the Lido exchange rate and the instantaneous UniV3slot0spot.slot0is flash-loan manipulable within one block, and because it was the lower-of, an attacker could only push the mark down (front-runsettleEpoch, depress the pool, mint extra shares cheaply, back-run), skewing share pricing. That mark feeds NAV and settlement directly.Fix
Mark wstETH purely at
stEthPerToken x ETH/USD(the Lido exchange rate). This is the fundamental redemption value (wstETH -> stETH -> ETH), is not flash-manipulable, and is the standard wstETH-collateral marking used by Aave and Morpho. Chosen over an on-chain UniV3 TWAP because it is materially lower-risk (no TickMath vendoring, where a wrong constant would silently mis-price). The pool spot is retained only inwstethBuyAllowedas a depeg gate on buying more wstETH, where a manipulated spot is fail-safe: it can only block a buy, never inflate value.Trade-off noted: during a real severe wstETH market depeg, NAV marks wstETH at redemption value rather than the discounted market price. The wstETH sleeve is capped at 50% and defaults to 0, and the buy gate still prevents adding wstETH during a depeg.
Tests
test_h5_basisBreach_marksAtRate_blocksBuys: a 5% pool depeg keeps the mark at the exchange rate but blocks buys.test_h5_poolPushDownCannotLowerTheMark: an extreme flash-pushed pool spot leaves the value mark unchanged.Independent of the other PRs; branches off main. Suite 116 -> 117.