Skip to main content

Discount Formula

The discount a swapper pays is derived from the opportunity cost of waiting in Lido's withdrawal queue.

Formula​

discount   = stEthAmount × apyBps × waitSeconds / (10_000 × SECONDS_PER_YEAR)
grossOut = stEthAmount − discount
feeAmount = grossOut × feeBps / 10_000
userOut = grossOut − feeAmount
VariableDescription
stEthAmountInput amount of stETH
apyBpsExpected ETH staking APY in basis points (e.g. 400 = 4%)
waitSecondsExpected Lido withdrawal wait time in seconds
feeBpsProtocol fee in basis points (default 0)

Example​

  • stETH amount: 10 ETH
  • Expected APY: 4% (apyBps = 400)
  • Expected wait: 14 days (waitSeconds = 1_209_600)
discount  = 10 × 400 × 1_209_600 / (10_000 × 31_536_000)
= 10 × 0.04 × (14/365)
≈ 0.01534 ETH

userOut = 10 − 0.01534 = 9.98466 ETH (WETH)

The swapper receives ~9.985 WETH instead of waiting ~14 days for 10 ETH.

Slippage protection​

Call getSwapQuote(stEthAmount) first to get the expected userOut. Pass this value as minEthAmountOut when calling swapStETHToWETH to protect against parameter changes between quote and execution.

Parameter bounds​

  • apyBps is capped at 10_000 (100%)
  • waitSeconds is capped at SECONDS_PER_YEAR (365 days)
  • These bounds guarantee grossOut ≥ 0