Skip to content

WIP ARM fees charged on buying base assets#212

Closed
naddison36 wants to merge 9 commits into
mainfrom
nicka/swap-fee
Closed

WIP ARM fees charged on buying base assets#212
naddison36 wants to merge 9 commits into
mainfrom
nicka/swap-fee

Conversation

@naddison36
Copy link
Copy Markdown
Collaborator

@naddison36 naddison36 commented Apr 13, 2026

Changes

  • Replace the old performance-fee-on-asset-growth model with swap-only fee accrual, so fees accrue only on discounted base-asset buy swaps.
  • Update swap fee math to charge (convertedBaseAmountIn - liquidityAmountOut) * fee / FEE_SCALE on qualifying swaps, including appreciating-base-asset paths like sUSDe -> USDe.
  • Change totalAssets() to subtract only stored accrued swap fees instead of fees derived from passive asset growth.
  • Replace legacy lastAvailableAssets fee accounting with explicit stored feesAccrued, and stop maintaining the deprecated legacy field after upgrade.
  • Reuse the old fee storage slot via a packed FeeData struct that holds fee and feesAccrued in a single slot.
  • Keep feesAccrued at a 1 wei sentinel after collection to avoid a more expensive 0 -> nonzero storage write on the next fee-bearing swap.
  • Add migration initializers to LidoARM, EtherFiARM, EthenaARM, and OriginARM to clear the reused legacy fee storage during upgrade.
  • Preserve the external fee() and feesAccrued() interfaces while moving internal fee state to the packed struct layout.

Gas impact

  • Before upgrade, the full Lido stETH -> WETH fee-bearing swap transaction used 96,864 gas.
  • After upgrade, the full swap transaction used 105,354 gas.
  • Net change: +8,490 gas, which is about an 8.8% increase.

@naddison36
Copy link
Copy Markdown
Collaborator Author

Closing as this is now in #208

@naddison36 naddison36 closed this Apr 30, 2026
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