Calculate swap fee against cross price rather than par value#224
Merged
Conversation
naddison36
added a commit
that referenced
this pull request
May 14, 2026
* Pro-rata losses to redeemers and remaining LPs * Calculate swap fee against cross price rather than par value (#224)
naddison36
added a commit
that referenced
this pull request
May 14, 2026
* WIP multi base assets * - Move reusable multi-base asset config and swap accounting into AbstractARM - Replace protocol-specific ARM redemption logic with generic asset adapters - removed legacy max-cap sentinel handling - Upgrade all ARMs to multi base assets - Added wstETH to the Lido ARM - Added weETH to EtherFi ARM * Updated AI context * Added wOETH to OETH ARM * Updated ARM contract dependencies * Updated Hardhat tasks * Proxied the adapters * Lido ARM upgrade checks * Added Ethena upgrade guard * Updated migration error * More cleanup of legacy immutables * fmt * Update EtherFi ABI * Update claimEthenaWithdrawals Hardhat task * Fixed fork tests * Fixed smoke tests * Fix invariant tests * Updated contract diagrams * Renamed the ARM adapter-facing methods to requestBaseAssetRedeem and claimBaseAssetRedeem * Used modifiers on adapters * Pro-rata losses to redeemers and remaining LPs (#223) * Pro-rata losses to redeemers and remaining LPs * Calculate swap fee against cross price rather than par value (#224)
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.
Summary
Fixes buy-side swap fee accrual so fees are bounded by the economic gain recognized in
totalAssets().Previously,
_accrueSwapFeecalculated fees from the discount to par:PRICE_SCALE - buyPricebut base inventory is valued in NAV at
crossPrice. WhencrossPrice < PRICE_SCALE, this could allow accrued swap fees to exceed the actual NAV gain from buying base assets, causing LP value to be transferred to thefeeCollectorthrough buy/sell round trips.This PR changes fee accrual to use the recognized NAV spread:
crossPrice - buyPriceChanges
crossPriceinto_accrueSwapFee.crossPrice - buyPriceinstead ofPRICE_SCALE - buyPrice.crossPriceis slightly abovebuyPrice,feeis high,Notes
For appreciating base assets such as sUSDe, the appreciation is still handled by the asset adapter’s
convertToAssets()result.crossPrice,buyPrice, andsellPriceare then applied to that converted liquidity-asset value, so the fee remains bounded by the NAV spread after conversion.Tests