Math Primer
Single source of truth for YieldBasis math. Notation table in §0 is authoritative; downstream pages reference equation numbers here rather than restating derivations.
Before you read this
This page is dense. The derivations use standard tools. For the basics in one place, see Concepts.
- Algebra and basic calculus notation. Comfort with , exponents, and single-variable derivatives. The integration step in §2 uses .
- LP value-function derivations. The idea that an LP's dollar value can be written as a closed-form function of the external price. §1 does this from scratch for constant product.
- The invariant. The constant-product bonding curve used by Uniswap v2 and the starting point for §1.
- Whitepaper pointer. The YB whitepaper has the full derivations with additional algebraic steps and edge-case discussion. This page is the on-site reference; the whitepaper is the long form.
0. Notation & symbols
| Symbol | Meaning |
|---|---|
| BTC spot price in USD | |
| Oracle BTC/USD price used by the LEVAMM | |
| Value of collateral (Curve LP tokens) | |
| Value of the leveraged position (after borrowing) | |
| Outstanding crvUSD debt | |
| Compounding leverage factor (fixed to 2 in YieldBasis) | |
| LP token amount held by the LEVAMM | |
| 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 routed to veYB | |
| Minimum admin fee when nobody stakes | |
| Staked vs total supply of LT tokens | |
| Current and ideal (watermark) value of the staked bucket | |
| Fee APR earned by the underlying Curve pool (unlevered) | |
| Borrow APR on the crvUSD CDP line | |
| Effective APR cost of maintaining leverage (releverage losses, gross of refuel) | |
| Donation-funded offset to (from recycled borrower interest) |
1. The constant-product problem (why √p shows up)
Classic AMMs (e.g. Uniswap v2) enforce
where is the USD side and is the BTC side. Let the external BTC price be (USD per BTC).
1.1 Normalising the start
Suppose equal USD value is deposited at :
- USD
- BTC (worth $1 at )
So
1.2 After a price move
Arbitrage pushes the AMM price to . In a constant-product AMM,
Combine (1.1) and (1.3):
With :
1.3 LP value scales as √p
Ignoring fees, LP USD value is
The initial deposit totals $2, so the per-initial-dollar scaling is
1.4 Impermanent loss (IL)
If the assets had been held without providing liquidity:
Impermanent loss (relative underperformance) is
Since for any , : the LP underperforms a simple hold whenever price drifts.
Takeaway. Constant-product LP value . Other, more complicated, AMM formulae are not immune to the IL problem either, and the source thereof is the sublinearity of the value function, for which reason the only way of eliminating IL is to design an AMM with an at least linear value function. YieldBasis provides such a design by engineering exposure to scale linearly with , not as .
2. Compounding leverage — turning √p into p
YieldBasis borrows against the LP collateral to keep a constant compounding leverage of .
2.1 Defining "compounding leverage"
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 re-leveraging to restore the ratio, the relative change of is amplified by :
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 ( is kept 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, so the total scaling factor equals the scaling factor from the previous step. See the General Idea section of the whitepaper for more.
2.2 Pick L = 2 to linearise BTC exposure
Curve Cryptoswap LP value scales approximately as . Substituting into (2.5):
Set :
Result. With , the position tracks BTC one-to-one. The curvature, and with it impermanent loss, is eliminated while trading fees continue to accrue.
2.3 What if L ≠ 2?
- : — outperform on the way up, underperform on the way down (reintroduces divergence vs. just holding).
- : You under-hedge the curve and still suffer residual IL.
Hence locking is the sweet spot: linear BTC exposure, zero IL, manageable debt always unwindable with the LP's USD side.
3. LEVAMM & Virtual Pool
To keep leverage fixed at (debt = 50% of value), YieldBasis uses a second AMM ("LEVAMM"). It holds Curve LP tokens on one side and implicit crvUSD debt on the other, anchored to an oracle price (BTC/USD).
The derivation first states the target (ideal) state at , then derives the invariant and solves for the anchor variable .
3.1 Ideal debt at the oracle price
If the live market price equals the oracle price , "perfect" leverage is:
where is the LP amount in the AMM at that oracle touch point (tildes = "ideal" values).
For : .
3.2 LEVAMM invariant & pricing
Define . The LEVAMM uses a constant-product-like invariant:
with constant as long as stays fixed.
At , the AMM's instantaneous price should equal the oracle:
Substitute from (3.1):
3.3 Solving for x₀ with arbitrary y, d
Away from the ideal point, is not directly known. 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 (matches the ideal-state intuition):
For , numerical simplification is applied in code; the general form is retained here for clarity.
3.4 Useful derived quantities
Pool value at oracle price (sandwich-resistant valuation):
Invariant in closed form.
An alternative expression for follows from (3.10):
3.5 Flash-loan sizing (φ)
When the arbitrageur comes with crvUSD (or needs extra), the Virtual Pool computes how much crvUSD to flash-borrow so that Curve liquidity is added/removed symmetrically (no spot price move) and the flash loan is repaid inside the same tx.
Let:
- — LEVAMM fee
- — current debt
- — LP amount in the LEVAMM
- — anchor term from Eq. (3.8)
- — user-provided crvUSD for this swap
- — Curve pool's stablecoin reserves, crypto reserves, total LP supply
Define
The required flash amount solves the quadratic (whitepaper Eq. 39):
Discriminant:
Choose the positive root:
This is evaluated inside the Virtual Pool before executing the swap, ensuring the flash loan is exactly covered by the LP redemption and AMM trade proceeds.
3.6 Directional intuition
- Debt too low (price up): . Then is large → LP is "expensive" in crvUSD. Arb brings in crvUSD, mints LP, increases .
- Debt too high (price down): . Then is small → LP is "cheap". Arb buys LP, unwraps, repays debt.
All legs (flash loan, LP mint/burn, CDP mint/repay) run atomically in the Virtual Pool wrapper.
3.7 Safe debt bounds
The protocol enforces safe operating bounds on the debt ratio to prevent edge cases:
- MIN_SAFE_DEBT: minimum debt as fraction of collateral value (prevents under-leveraging edge cases).
- MAX_SAFE_DEBT: maximum debt as fraction of collateral value (prevents approaching liquidation).
For , the critical debt value corresponds to . The protocol uses tighter bounds than the mathematical limits for safety margin.
4. Net APR & cost terms
Explicit expression for the crypto-denominated return of an unstaked yb-LP position.
4.1 Components
Let:
- — APR the Curve BTC/crvUSD pool would earn without leverage (pure trading fees, in BTC terms).
- — compounding leverage (YieldBasis: ).
- — effective borrow APR on the protocol's crvUSD line (set by governance).
- — drag from maintaining constant leverage (AMM fees/price edge paid to arbs, slippage).
- — subsidy from recycled borrower interest (see §4.2a).
Because the protocol supplies twice as much notional liquidity (BTC plus borrowed crvUSD) to Curve, gross fee flow scales approximately linearly with :
For :
Subtract the two costs:
- Borrow cost — interest paid on the crvUSD debt.
- Leverage cost — continuous leak to arbitrageurs that keep the ratio at 50%.
Combining:
For YieldBasis' fixed :
4.2 Heuristic for r_releverage
Backtests (Jan 2019 – Oct 2024) show:
- Optimised constant-product pools (no leverage) earn APR over that window.
- Empirically, that value. The cost of keeping leverage perfect is roughly twice what a plain Uniswap-style pool can earn under the same conditions.
This is why the method fails on a pure AMM (fees not big enough) but works on Curve Cryptoswap where is materially higher. Not hard-coded on-chain; a modelling shortcut:
4.2a Implementation nuance: Cryptoswap 50/50 + refueling loop
Equations (4.1)–(4.4) are the whitepaper-clean theoretical model. Two effects shift the realised numbers:
- Cryptoswap's internal 50/50 fee split (the Twocrypto pool's built-in
admin_fee = 50%). Half of every pool trading fee stays inside the pool as rebalance reserve (tracked viaxcp_profitvsvirtual_price). Only the LP half reaches LEVAMM's collateral value. Practical substitution:
LEVAMM's own trading-fee capture adds on top.
- Refueling loop. Borrower interest is not paid to an external creditor. It is swept out of LEVAMM and donated entirely to the Cryptoswap pool, where it funds
price_scalerebalance cost. At steady state, interest paid becomes rebalance subsidy. So and part of cancel via the donation flow:
Net realised LP drag is the residual , not :
Eq. (4.4) remains useful as the whitepaper-clean envelope; Eq. (4.8) describes what an LP actually sees on-chain.
4.3 Continuous vs. discrete compounding
All rates above are quoted as simple APRs for intuition. For continuous compounding:
Given the magnitudes (single-digit percentages for costs, double-digit for fees), APR ≈ APY within a few bps.
Takeaway. YieldBasis only wins if the doubled fee stream outpaces borrow + rebalance drag. Governance controls those drags (via borrow rate and AMM params), keeping net APR attractive in most regimes.
5. Token incentives & admin-fee function
YieldBasis splits real fee flow between unstaked yb-LP holders (they want BTC/ETH-denominated fees) and veYB holders (protocol value capture). The split is governed by an admin-fee curve that depends on how much of the liquidity is staked.
5.1 Admin-fee formula
Let:
- = total yb-LP supply,
- = amount of yb-LP staked,
- = minimum admin fee when nobody stakes,
- = actual admin-fee fraction routed to veYB.
The curve:
Limits:
- (unstaked LPs keep of fees).
- (all fees to veYB; stakers opted out of fee yield anyway).
The square root makes the increase gentle at first (so early stakers do not massively penalise LPs), then accelerates near full staking to avoid an "everyone stakes, no one gets fees" equilibrium.
5.2 Splitting fee gains / sharing losses
After each accounting tick (deposit, withdraw, or checkpoint), let
- = total value of the leveraged position (in BTC terms) before fees this period,
- = total value after market moves + fees, before anything is allocated,
- = value change.
Further, let and be the staked bucket's current value and watermark; is the outstanding watermark shortfall.
LT applies admin fee in two regimes, matching the regime split inside LT's value-update routine:
Recovery regime (watermark open, , ):
The first slice of value_change covers the watermark at 100 percent; no admin fee applies to that portion. Only the remainder is subject to the admin fee:
Post-recovery regime (, ) or loss regime ():
Admin fee applies uniformly:
Losses share pro-rata between buckets (no admin fee on a negative value_change in this regime):
In the recovery regime, the staked share of is capped at the watermark gap:
Unstaked gets whatever remains:
Intent. Admin fee is taken only on value that is genuinely new from the staked bucket's perspective. Losses from prior periods must be restored to stakers before veYB begins collecting. This is what gives the watermark mechanism its economic meaning rather than leaving it cosmetic.
5.3 Negative rebase for staked supply
Staked yb-LP rebases down when value allocated 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 :
Post-rebase supplies:
Numerical cap. As (staking ratio approaches 100%), the denominator in (5.8) collapses and would blow up. The protocol caps it by clamping the per-step rebase to:
where — the floor on the unstaked fraction below which the cap kicks in. At staking ratios below that floor, is clamped rather than allowed to diverge. The on-chain constant name and exact integer scale live in Dev: LT.
Unstaked tokens never rebase; they simply accumulate (or lose) value via the fee stream.
Intuition. Stakers opt into emissions instead of cash fees. If their side under-earns (because they took earlier losses), their token count is cut (negative rebase) so each remaining token still represents its fair slice of .
Where this is used elsewhere
| Topic page | Refers to |
|---|---|
| Compounding Leverage | §1, §2 (identity), Eq (2.7) |
| Compounding Leverage | §3.2–§3.7 (invariant, x₀, safety bounds) |
| Fee Mechanics | §5.1 (), §5.2 (recovery-first) |
| Volatility Decay | §1.4 (IL), §4 (APR decomposition) |
| yb-LP Share Value Derivation | §3.4 (Eq 3.9), §3.5 (flash-loan) |
| Emission Dynamics | §4 (APR context) |