Math primer
A constant-product liquidity provider (LP) position grows with the square root of the price. Compounding leverage of 2× turns it into a position that grows with the price. The equations below show why. The other economics pages cite them by equation number.
Each equation number starts with its section number, and other pages cite sections the same way:
- §1: constant-product LP value, from the invariant of Uniswap v2, and impermanent loss.
- §2: compounding leverage.
- §3: LEVAMM, the leveraged automated market maker (AMM), and the VirtualPool.
- §4: net annual percentage rate (APR) and cost terms.
- §5: admin-fee curve and staked accounting.
The derivations use , exponents, and single-variable derivatives. The integration step in §2 uses .
The worked numbers use the canonical position from How YieldBasis works: 1 cbBTC deposited at a BTC price of $100,000. The YB whitepaper has the full derivations, with more algebraic steps and edge cases.
For short definitions of terms, read the Glossary. For the symbols in the equations, the notation table is authoritative.
Notation
The table defines the main symbols. Some symbols, such as and , have a different meaning in different sections, and the table gives each meaning:
| Symbol | Meaning |
|---|---|
| BTC spot price in USD | |
Oracle price of one Curve LP token, in USD, used by the LEVAMM (CryptopoolLPOracle.price()) | |
| Value of collateral (Curve LP tokens) | |
| Value of the leveraged position (after borrowing) | |
| Outstanding crvUSD debt | |
| Compounding leverage factor (fixed to 2 in YieldBasis) | |
| §1: USD reserve of a constant-product pool. §3, Eq (3.2): in the LEVAMM invariant. §3, flash-loan sizing: the crvUSD that the arbitrageur provides for the swap | |
| §1: BTC reserve of a constant-product pool. §3: LP token amount held by the LEVAMM | |
| , | Ideal LP amount and ideal debt of the LEVAMM at the oracle price, Eq (3.1) |
| Anchor term in the LEVAMM pricing formula | |
| Invariant constant of the LEVAMM for a fixed oracle price | |
| Flash-loan size (crvUSD) solved via a quadratic | |
| Admin-fee fraction: the share of a value gain that LT, the market's vault contract, takes as admin fees | |
| Minimum admin fee when nobody stakes | |
| Staked and total supply of yb-LP shares | |
| Current and ideal (watermark) value of the staked bucket | |
| Fee rate (APR) earned by the underlying Curve pool (unlevered) | |
| Borrow rate (APR) on the crvUSD collateralized debt position (CDP) line | |
| Rebalancing cost as an effective rate (APR): the cost of keeping leverage constant, before refueling | |
| Refueling offset to : the donation of recycled borrower interest | |
Reserved profit fraction: the share of its fee profit that the Cryptoswap pool protects for LPs (reserved_profit_fraction()) |
Constant-product LP value
If BTC doubles from $100,000 to $200,000, a constant-product LP position that starts at $200,000 grows to $282,843. Holding the same assets grows to $300,000. The LP trails the hold by 5.72%, from Eq (1.6) and (1.9) at . This section derives that shortfall.
Classic AMMs, for example Uniswap v2, enforce
where is the USD side and is the BTC side. Let the external BTC price be (USD per BTC).
Normalized start
Suppose that an LP deposits equal USD value at :
- USD
- BTC (worth $1 at )
So
Reserves after a price move
Arbitrage pushes the AMM price to . In a constant-product AMM,
Combine (1.1) and (1.3):
With :
LP value proportional to √p
Ignoring fees, LP USD value is
The initial deposit totals $2, so the per-initial-dollar scaling is
Impermanent loss
If the LP holds the assets and does not provide liquidity:
Impermanent loss (IL), the underperformance relative to a hold, is
Since for any , : the LP underperforms a hold whenever price drifts.
Takeaway. Constant-product LP value . More complex AMM formulas also have IL. The source is a value function that grows more slowly than price. To match a linear hold, a position needs a value that is linear in price. A yb-LP share gives such exposure: it keeps full price exposure to BTC or ETH, up and down.
Compounding leverage
On the canonical position, the same doubling of BTC takes the yb-LP position from $100,000 to $200,000, before costs. The leverage turns the curve of §1 into a straight line, Eq (2.7).
YieldBasis borrows against the LP collateral to keep a constant compounding leverage of .
Compounding leverage identity
By construction, the protocol keeps debt at a fixed fraction of collateral:
So the net position value is
Consider a small change in collateral value . After the protocol re-leverages to restore the ratio, amplifies the relative change of :
Integrate both sides:
Exponentiate:
Why is the relative change amplified?
Growth of the price of collateral.
If the collateral grows in price, the value changes as follows ( stays constant at this step):
Adjustment of the debt value and of the collateral amount.
By definition:
Then:
Whence it follows that
In this step, the value of the leveraged position tracks the collateral value linearly. The total scaling factor equals the scaling factor from the previous step. The General Idea section of the whitepaper gives the full argument.
Linear exposure at L = 2
Curve Cryptoswap LP value scales approximately as . Substituting into (2.5):
Set :
Result. With , the position tracks BTC one-to-one. The leverage straightens the concave curve, while trading fees continue to accrue.
Exposure at other leverage values
Other leverage values do not give linear exposure:
- : . The position outperforms a plain hold when the price rises and underperforms it when the price falls.
- : The position under-hedges the curve and still has residual IL.
is the only value that makes exposure linear in price. At , the debt equals the LP's stablecoin side on average. So the stablecoin side can repay the debt when the position closes.
LEVAMM and VirtualPool
On the canonical position, LEVAMM holds Curve LP tokens worth $200,000 against $100,000 of crvUSD debt. The position is worth $100,000 at 2× leverage, Eq (3.1). Arbitrage trades against LEVAMM keep the debt near half of the collateral value.
To keep leverage fixed at (debt = 50% of collateral value), YieldBasis uses a second AMM, LEVAMM. It holds Curve LP tokens on one side and implicit crvUSD debt on the other. An oracle price anchors it: the USD price of one Curve LP token from CryptopoolLPOracle. In this section, counts LP tokens, so is the collateral value. The VirtualPool is the contract that wraps LEVAMM, Cryptoswap, and a flash loan to offer direct swaps between crvUSD and the asset, in both directions.
Ideal debt at the oracle price
If the live market price equals the oracle price , "perfect" leverage is:
where is the LP amount in LEVAMM at that oracle touch point. A tilde marks an ideal value.
For : .
LEVAMM invariant and pricing
Define . The LEVAMM uses a constant-product-like invariant:
with constant as long as stays fixed.
At , the instantaneous price of LEVAMM should equal the oracle price:
Substitute from (3.1):
Anchor term x₀ for any y and d
Away from the ideal point, is not known directly. From (3.4):
Evaluate the invariant at the ideal point:
Set that equal to the current-state invariant , substitute (3.5), and rearrange. The result is a quadratic in :
Choose the larger root, which matches the ideal state:
For , the code simplifies the numbers. The equations here keep the general form.
Position value and invariant at the oracle price
The pool value at the oracle price is a sandwich-resistant valuation:
In closed form, the invariant is:
An alternative expression for follows from (3.10):
Flash-loan sizing (φ)
The arbitrageur brings crvUSD, or needs extra. The VirtualPool computes how much crvUSD to flash-borrow. The goal is to add or remove Curve liquidity in balance (no spot price move) and to repay the flash loan in the same transaction.
Let:
- : LEVAMM fee
- : current debt
- : LP amount in the LEVAMM
- : anchor term from Eq. (3.8)
- : crvUSD that the arbitrageur provides for this swap (not the of §1 or Eq (3.2))
- : Curve pool's stablecoin reserves, crypto reserves, total LP supply
Define
The required flash amount solves the quadratic (whitepaper Eq. 39):
The discriminant is:
Choose the positive root:
The VirtualPool evaluates this before it executes the swap. The LP redemption and LEVAMM trade proceeds then cover the flash loan exactly.
Arbitrage direction
The arbitrage trade depends on which side of the 50% target the debt sits:
- Debt too low (price up): . Then is large → LP is "expensive" in crvUSD. The arbitrageur brings the asset, mints LP with it and flash-borrowed crvUSD, and sells the LP to the LEVAMM. The LEVAMM debt increases.
- Debt too high (price down): . Then is small → LP is "cheap". The arbitrageur buys LP, unwraps it, and repays debt.
All legs (flash loan, LP mint/burn, CDP mint/repay) run atomically in the VirtualPool wrapper.
Safe debt bounds
The protocol enforces safe bounds on the debt ratio. On the canonical position, with $200,000 of collateral, the band runs from $12,500 to $106,250 of debt:
MIN_SAFE_DEBTof collateral value. At : (prevents under-leveraging edge cases).MAX_SAFE_DEBTof collateral value. At : .
For , the critical debt value corresponds to . MAX_SAFE_DEBT sits a buffer below that mathematical limit.
A deposit reverts with "Unsafe min" or "Unsafe max" if it leaves debt outside the band. So does a LEVAMM trade that moves debt further from the target. The band does not block withdrawals, which take a proportional share of collateral and debt.
Net APR and cost terms
This section gives the return of an unstaked yb-LP position, in the deposited asset. Every rate in it is a simple APR: a yearly rate on the position value, not compounded. Eq (4.9) converts it to a compounded rate. On the canonical $100,000 position, a net rate of 10% APR is $10,000 a year if the rate stays the same.
These are model rates. Fundamental yield (FT APY), the rate that the docs quote for unstaked yb-LP, comes from measured Fundamental Value growth over a trailing window. The equations here do not compute it.
Return components
Let:
- : the rate that the Curve BTC/crvUSD pool earns without leverage (pure trading fees, in BTC terms). On a pool that runs the oracle-report policy (
YBOraclizedPolicy), the policy sets the fee of each swap. For what each policy sets, read Pool policies. - : compounding leverage (YieldBasis: ).
- : effective borrow rate on the protocol's crvUSD line (set by governance).
- : the rebalancing cost, the rate lost to keeping leverage constant (AMM fees and price gaps paid to arbitrageurs, and slippage).
- : the refueling offset from recycled borrower interest, Eq (4.7).
Because the protocol supplies twice as much notional liquidity (BTC plus borrowed crvUSD) to Curve, gross fee flow scales approximately linearly with :
For :
The net rate subtracts two costs from the gross fee rate:
- Borrow interest: the interest paid on the crvUSD debt.
- Rebalancing cost: the continuous loss to the arbitrageurs who keep the debt ratio at 50%.
Subtracting both costs from Eq (4.1) gives the net rate:
For YieldBasis' fixed :
Rebalancing cost heuristic
The whitepaper gives an empirical rule of thumb from simulation. The rebalancing cost is about 2× the fee APR of an optimized constant-product pool without leverage, .
So the method fails on a pure AMM, where fees are too small. It works on Curve Cryptoswap, where is higher. The contracts do not hard-code the rule below. It is a modeling shortcut:
Realized return: pool profit split and refueling
Equations (4.1)–(4.4) are the theoretical model of the whitepaper. Two effects shift the realized numbers: the profit split inside Cryptoswap, and refueling.
Cryptoswap's internal profit split. The pool protects a fraction of its fee profit for LPs (lp_xcp_profit). is the reserved profit fraction. price_scale moves (changes to the pool's internal price) can spend the rest. When the pool re-pegs (moves price_scale) often, LPs keep about of the fee profit (with a zero pool admin fee). On the older pools of markets 0 to 6, is one half. On v3 pools, the Curve DAO sets per pool. To check, call reserved_profit_fraction() on the pool. The realized pool rate is then approximately:
LEVAMM's own trading fees add to this.
Refueling loop. Borrower interest does not go to an external creditor. LT collects it from LEVAMM and donates all of it to the Cryptoswap pool. There it pays for price_scale moves. At steady state, the interest paid funds rebalancing. So and part of cancel through the donation flow:
Net realised LP drag is the residual , not :
Eq. (4.4) remains useful as the envelope of the whitepaper model. Eq. (4.8) describes what an LP sees onchain.
APR and compounded rate
With continuous compounding, the annual percentage yield (APY) is:
The gap grows with the rate. At 5% APR the difference is 13 basis points (bp). At 10% it is 52 bp: on the $100,000 position, $10,517 a year compounded against $10,000 simple. At 20% it is 214 bp.
Takeaway. A yb-LP position earns when the doubled fee stream is larger than the rebalancing cost that remains after refueling, Eq. (4.8). The whitepaper envelope, Eq. (4.4), also subtracts borrow interest. Governance sets the borrow rate and the AMM fee.
Admin-fee curve and staked accounting
LT splits each fee gain between unstaked yb-LP holders, who want fees in BTC or ETH, and admin fees. An admin-fee curve sets the split. The curve depends on the staking ratio, the share of yb-LP that is staked. The FeeSplitter then sends a DAO-set share (split_fraction()) of admin fees to the net-pressure reserve and the rest to veYB holders. For the fee flow, and for a table that evaluates Eq (5.1) at four staking ratios and at the full-staking limit, read Fees and veYB revenue.
Admin-fee formula
Let:
- = total yb-LP supply,
- = amount of yb-LP staked,
- = minimum admin fee when nobody stakes,
- = actual admin-fee fraction.
The curve is:
The curve has two limits:
- (unstaked LPs keep of fees).
- (all fee gains become admin fees; stakers already give up fee growth for YB emissions).
The square root makes the increase gentle at first, so early stakers do not take a large share from unstaked LPs. The increase then accelerates near full staking, which prevents an "everyone stakes, no one gets fees" equilibrium.
Gain and loss sharing
At each accounting tick (a deposit, a withdrawal, or a checkpoint), let:
- = total value of the leveraged position (in BTC terms) before fees this period,
- = total value after market moves and fees, before LT allocates anything,
- = value change.
Further, let and be the staked bucket's current value and watermark. Then is the outstanding watermark shortfall.
LT applies the admin fee in three regimes, which match the regime split inside LT's value-update routine (_calculate_values):
Recovery regime (watermark open, , ):
The first part of the gain, up to the amount that restores the staked watermark, pays no admin fee. The admin fee applies only to the rest:
Post-recovery regime (, ):
Admin fee applies to the whole gain:
Loss regime ():
No admin fee applies to a loss: , (LT.vy _calculate_values).
Small-stake case ( base units, that is 0.01 staked yb-LP, MIN_STAKED_FOR_FEES): the three regimes do not apply. The admin fee applies to gains and losses alike: and , for any sign of .
Losses split pro rata between the staked and unstaked buckets:
For any gain (), LT caps the staked share at the watermark shortfall. With no watermark gap, the staked side gets no share of the gain:
The unstaked bucket gets the rest:
Intent. LT charges no admin fee on a gain until the staked side's share of it has covered the staked loss. Staked and unstaked holders share that gain pro rata by balance, and LT caps the staked share at the staked loss.
Negative rebase of staked supply
Staked yb-LP rebases down when the value that LT allocates to stakers (after fees) is less than proportional to total value. Let:
- = new total value after admin fee (),
- = new staked value after sharing profit/loss,
- = staked token supply before rebase,
- = total token supply before rebase,
- = staked tokens burned (negative rebase).
The value share must match the token share:
Solve for :
The supplies after the rebase are:
Numerical cap. As (staking ratio approaches 100%), the denominator in (5.8) collapses, and in the continuous model diverges. Onchain, the contract caps it by clamping the per-step rebase to:
where (SQRT_MIN_UNSTAKED_FRACTION), so is the floor on the unstaked fraction. When the unstaked fraction is below that floor (the staking ratio is above ), the cap limits so that it does not diverge. For the onchain constant name and its exact integer scale, read Dev: LT.
Unstaked tokens never rebase. They gain (or lose) value through the fee stream.
Intuition. Stakers opt into emissions instead of cash fees. If their side under-earns because of earlier losses, LT cuts their token count (negative rebase). Each remaining token then still holds its fair slice of .
Pages that cite these equations
Each page in the table summarizes a result and cites equations from this primer:
| Topic page | Cites |
|---|---|
| Arbitrage and MEV | §3: flash-loan sizing, Eq (3.15) |
| Compounding leverage | §1 and §2: the √p law and the 2× leverage identity, Eq (1.7), (2.5), (2.7) |
| Fees and veYB revenue | §5: admin-fee curve , Eq (5.1); recovery-first sharing, Eq (5.2a)–(5.6) |
| Volatility decay | §1: √p law and IL, Eq (1.6)–(1.9). §2: the case, Eq (2.5)–(2.7). §4: net APR, Eq (4.3)–(4.8). §5: gain and loss sharing, Eq (5.2a)–(5.6) |
| yb-LP share value derivation | §3: anchor term and value at the oracle price, Eq (3.8), (3.9) |