yield-amm) is purpose-built for trading a PT against its
underlying. A classic constant-product AMM wouldn’t work here: PT is contractually
worth 1 underlying at maturity, so price must approach par as time runs out.
The yield-space invariant
Instead of , Kimia uses: where:- = reserves of underlying (vault shares),
- = reserves of PT,
- = fraction of time remaining to maturity, in
[0, 1].
Time factor
- New pool: `now ≈ creation → t ≈ 1 → slippage tolerant**
- Near maturity: `t → 0 → pool behaves like a 1:1 swap**
t < 0.001 are disabled to avoid numerical blow-up in the exponent.
Swap math
Givenx, y, t, the pool maintains k = x · y^t through any swap.
Underlying → PT
PT → underlying
The exponentiation uses kimia-math::pow_frac(base, exponent), which implements
exp(exponent · ln(base)) with range-reduced Taylor series. Precision is
verified at < 0.05% error across the whole operating range.
Fees
- Swap fee: 30 bps (0.3%) deducted from the input.
- LP fee share: All fees stay in the pool, growing
kfor every LP.
LP mechanics
add_liquidity / remove_liquidity take balanced deposits, the pool won’t
accept a single-sided add because that would break the invariant without
compensating the other side.
- First LP:
lp_out = geometric_mean(underlying, pt). - Subsequent LPs:
lp_out = min(underlying_amt / x, pt_amt / y) · total_lp.
Pricing intuition
- PT discount = fixed rate. If PT trades at 0.98 underlying with 30 days left,
the annualized rate is
(1/0.98)^(365/30) − 1 ≈ 28%. - YT price = 1 − PT price (by conservation). YT is cheap early, expensive as yield accrues.
Read next
yield-amm reference
Instructions and account layout.
Fixed-rate intents
How the router uses the AMM to prove an achieved APY.
Math library
pow_frac, ln, exp, how we stay precise under 9-decimal fixed point.

