Market Example
Last updated
rate_diff = 1.07 - 1.05 = 0.02
LN_MAX_PROPORTION = ln(0.96/0.04) ≈ 3.178
scalar_root = (3.178 * 1.0) / 0.02 ≈ 158.9ln_fee_rate = ln(1.01) ≈ 0.00995
ln_fee_rate_root = 0.00995 * 31,536,000 / 31,536,000 = 0.00995time_to_expiry = 15,768,000 seconds (6 months)
fee_rate = e^(ln_fee_rate_root * time_to_expiry / seconds_per_year)
fee_rate = e^(0.00995 * 15,768,000 / 31,536,000)
fee_rate = e^(0.00995 * 0.5)
fee_rate = e^(0.004975)
fee_rate ≈ 1.00499proportion (p) = 1,000 / (1,000 + 1,000) = 0.5
ln(p/(1-p)) = ln(0.5/0.5) = ln(1) = 0
rate_scalar = scalar_root * seconds_per_year / time_to_expiry
rate_scalar = 158.9 * 31,536,000 / 15,768,000 = 317.8
rate_anchor ≈ 1.05 (calibrated from last_ln_implied_rate)
exchange_rate = ln(p/(1-p)) / rate_scalar + rate_anchor
exchange_rate = 0 / 317.8 + 1.05 = 1.05Pre-fee exchange rate: 1.05 (from Step 2)
Pre-fee SY needed: 100 / 1.05 = 95.23 SY
Fee calculation (for swap_sy_for_exact_pt):
fee = pre_fee_asset_to_account * (fee_rate - 1)
fee = 95.23 * (1.00499 - 1)
fee = 95.23 * 0.00499
fee ≈ 0.475 SY
Total SY needed (including fee):
net_asset_to_account = 95.23 + 0.475 = 95.705 SYTotal fee: 0.475 SY
Protocol fee (if 50%): 0.2375 SY → goes to protocol reserve
LP fee (50%): 0.2375 SY → goes to liquidity providers