yield-amm is an AMM purpose-built for trading a principal token (PT) against
its underlying. The invariant makes prices converge to 1:1 as
time-to-maturity approaches 0.
Accounts
Pool
["pool", market].
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), solvek / (x + amount_in)for the exponent .get_underlying_out(pt_in, t), inverse.
Instructions
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.
Read next
Yield-AMM concept
Full derivation of the invariant and fees.
Math reference
pow_frac, ln, exp.

