Market Example

Example: Market Creation and Swap

Let's walk through a concrete example to see how everything fits together.

Market Creation

Input Parameters:

  • Asset: sUSDe (yield-bearing)

  • Expiry: 1 year from now (31,536,000 seconds)

  • Rate range: 3% to 7% APY (rate_min = 0.03, rate_max = 0.07)

  • Initial fee rate: 1% (fee_rate = 1.01)

Step 1: Calculate Initial Anchor

years_to_expiry = 31,536,000 / 31,536,000 = 1.0
implied_rate_min = (1 + 0.03)^1 = 1.03
implied_rate_max = (1 + 0.07)^1 = 1.07
initial_anchor = (1.03 + 1.07) / 2 = 1.05

The initial anchor (1.05) represents the midpoint of the expected rate range.

Step 2: Calculate Scalar Root

The scalar root controls how sensitive the exchange rate is to pool imbalances. Higher values = more capital efficient but narrower tradable range.

Step 3: Calculate ln_fee_rate_root

This is the "root" fee rate that will be scaled by time to expiry for each swap.

Market Parameters Summary:

  • scalar_root: 158.9

  • initial_anchor: 1.05 (5% APY midpoint)

  • ln_fee_rate_root: 0.00995

Example: SY → PT Swap

Now let's see how fees work on an actual swap. Assume:

  • Current time: 6 months before expiry (15,768,000 seconds remaining)

  • Market state: 1,000 PT and 1,000 SY in the pool (balanced)

  • PY index: 1.0 (no yield accrued yet)

  • User wants to swap: SY for 100 PT

Step 1: Calculate Current Fee Rate

The fee rate is ~0.499% (half of the 1% annual rate, since we're halfway to expiry). This is the multiplier applied to the trade.

Step 2: Calculate Exchange Rate:

This means 1.05 PT = 1 SY (PT is at a discount, as expected for positive yield).

Step 3: Execute Swap with Fee User wants to swap SY for exact PT amount (e.g., wants 100 PT):

Alternative way to think about it: The post-fee exchange rate is: 1.05 / 1.00499 ≈ 1.0448 At this rate, to get 100 PT you need: 100 / 1.0448 ≈ 95.71 SY

Step 4: Fee Distribution

Final Result:

  • User wants: 100 PT

  • User pays: ~95.705 SY (includes fee)

  • Fee paid: ~0.475 SY (~0.5% of trade value)

  • Effective rate: 95.705 SY = 100 PT (includes fee)

  • Pre-fee rate would have been: 95.23 SY = 100 PT

Key Takeaway: The fee decreases as expiry approaches. If this same swap happened 1 month before expiry, the fee would be ~0.08% instead of ~0.5%, because time_to_expiry is smaller in the fee calculation.

Last updated