Skip to main content
yield-amm is an AMM purpose-built for trading a principal token (PT) against its underlying. The invariant xyt=kx \cdot y^t = k makes prices converge to 1:1 as time-to-maturity tt approaches 0.

Accounts

Pool

["pool", market].
FieldTypeNotes
marketPubkeyPaired split-engine market
underlying_mintPubkeyVault share mint
pt_mintPubkeyPT mint
lp_mintPubkeyLP share mint
underlying_reserve_accountPubkeyVault share token account
pt_reserve_accountPubkeyPT token account
underlying_reserves, pt_reservesu64Mirrors token accounts
total_lpu64LP supply
maturityi64unix
total_durationi64seconds (maturity − creation)

Pool methods

  • time_factor(now) = clamp((maturity - now) / total_duration, 0, 1).
  • compute_k(t) = underlying_reserves × pt_reserves^t.
  • get_pt_out(underlying_in, t), solve k / (x + amount_in) for the exponent tt.
  • get_underlying_out(pt_in, t), inverse.

Instructions

InstructionPurpose
create_poolSeed reserves, set maturity and total_duration
swapUnderlying ↔ PT with 30 bps fee, slippage-protected
add_liquidityBalanced add, mint LP
remove_liquidityBurn LP, withdraw proportional reserves
Swap is disabled within t < 0.001 of maturity to avoid exponent blow-up. At that point PT is essentially at par, just call redeem_pt on the split engine.

Math helpers (kimia-math)

  • pow_frac(base, exponent), exp(exponent × ln(base)) via range-reduced Taylor series. Error < 0.05%.
  • mul_fp, div_fp, u128-intermediate fixed-point ops, always rounds down.

Errors

SwapDisabledNearMaturity, SlippageExceeded, InsufficientLiquidity, MathOverflow, AlreadyMatured.

Yield-AMM concept

Full derivation of the invariant and fees.

Math reference

pow_frac, ln, exp.