Skip to main content

Math and economics

This page derives the core equations of YieldBasis from first principles. It shows how continuous 2×2\times compounding leverage converts a concave p\sqrt{p} liquidity provider (LP) payoff into linear pp exposure, how LEVAMM prices and rebalances collateral, when trading fees outpace rebalancing drag, and how LT and YB distribute fees and emissions.

Notation​

SymbolMeaning
ppExternal spot price of the volatile asset (such as BTC or ETH) in USD
pop_oOracle price of one Curve LP token in USD (CryptopoolLPOracle.price())
VcV_cUSD value of Curve LP collateral held by LEVAMM
ddOutstanding crvUSD debt in LEVAMM
V∗V_*Net USD equity of the leveraged position (Vc−dV_c - d)
LLCompounding leverage factor (fixed to L=2L = 2 in YieldBasis)
x0(po),I(po)x_0(p_o), I(p_o)Anchor term and constant-product invariant of LEVAMM at oracle price pop_o
ϕ\phiFlash-loan amount (crvUSD) borrowed by VirtualPool
rpool,ρr_{\text{pool}}, \rhoUnlevered Curve pool fee APR and reserved profit fraction (reserved_profit_fraction())
rborrow,rrefuelr_{\text{borrow}}, r_{\text{refuel}}Effective crvUSD borrow APR and refueling offset APR
rreleverager_{\text{releverage}}Rebalancing cost APR paid to arbitrageurs before refueling
fa,fmin⁡f_a, f_{\min}Active admin-fee share and minimum admin fee (Factory.min_admin_fee())
s,Ts, TStaked yb-LP supply in the gauge and total yb-LP supply
vs,vs∗v_s, v_s^*Staked bucket value (staked) and watermark (ideal_staked)

Constant-product AMM p\sqrt{p} versus 2×2\times leveraged linear pp​

Why a standard LP scales as p\sqrt{p}​

A constant-product AMM enforces x⋅y=kx \cdot y = k, where xx is the USD reserve and yy is the volatile-asset reserve. Deposit equal USD value at p0=1p_0 = 1 with x0=1x_0 = 1 and y0=1y_0 = 1, so k=1k = 1. After the external price moves to pp, arbitrage aligns x/y=px / y = p, giving:

x=p,y=1p.x = \sqrt{p}, \qquad y = \frac{1}{\sqrt{p}}.

Ignoring trading fees, the USD value of the LP position is:

VLP(p)=x+p y=p+p⋅1p=2p.V_{\text{LP}}(p) = x + p\,y = \sqrt{p} + p \cdot \frac{1}{\sqrt{p}} = 2\sqrt{p}.

Normalized by the initial $2 deposit, LP value per initial dollar scales as VLP,norm(p)=pV_{\text{LP,norm}}(p) = \sqrt{p}. Holding the initial assets instead yields Vhold(p)=1+pV_{\text{hold}}(p) = 1 + p, producing a relative shortfall whenever p≠1p \neq 1:

IL(p)=2p1+p−1<0.\text{IL}(p) = \frac{2\sqrt{p}}{1 + p} - 1 < 0.

For example, if BTC doubles from $100,000 to $200,000 (p=2p = 2), a $200,000 constant-product LP grows to $282,843, while holding grows to $300,000 (a 5.72% shortfall).

Why passive AMMs cannot avoid concavity—and how IL differs from LVR​

A passive, oracle-free Constant Function Market Maker (CFMM) with reachable reserve set SS never initiates trades; external arbitrageurs minimize the pool's mark-to-market value at external price pp:

V(p)=inf⁡(x,y)∈S (x+p y).V(p) = \inf_{(x, y) \in S}\,(x + p\,y).

Because V(p)V(p) is the pointwise infimum of affine functions, it is necessarily concave (V′′(p)≤0V''(p) \le 0) with slope V′(p)=y∗(p)V'(p) = y^*(p) (Angeris, Evans, Chitra 2021; Angeris, Diamandis, Boyd 2023). Concavity is required for a stable interior price: if V′′(p)=0V''(p) = 0, the pool never trades; if V′′(p)>0V''(p) > 0, any price move lets arbitrageurs drain 100% of one reserve. Consequently, no passive, unleveraged, oracle-free AMM can simultaneously provide stable liquidity and match holding (V(p)≥Vhold(p)V(p) \ge V_{\text{hold}}(p)) before fees.

This concavity creates two distinct effects that are often conflated:

  • Static divergence loss (Impermanent Loss, IL): A path-independent gap comparing V(PT)V(P_T) against holding initial reserves at endpoints (P0,PT)(P_0, P_T). The moment arbitrageurs move the pool from P0P_0 to P1≠P0P_1 \ne P_0, IL is immediately present on a mark-to-market basis even if zero further trades occur. If PTP_T returns to P0P_0, endpoint IL closes to zero.
  • Loss-Versus-Rebalancing (LVR): A strictly path-dependent adverse-selection cost comparing the passive pool against a frictionless strategy that holds the same inventory y∗(Pt)y^*(P_t) but trades at external market prices rather than on a stale curve (Milionis, Moallemi, Roughgarden, Zhang 2022). Under geometric Brownian motion with volatility σ\sigma, instantaneous LVR is ℓ(Pt)=−12σ2Pt2V′′(Pt)≥0\ell(P_t) = -\frac{1}{2}\sigma^2 P_t^2 V''(P_t) \ge 0 (equal to σ28V(Pt)\frac{\sigma^2}{8} V(P_t) for a fee-free constant-product pool). LVR accumulates on every stale-price arbitrage swap and stays strictly positive even if price returns to P0P_0.

YieldBasis addresses these two costs at separate layers: continuous 2×2\times compounding leverage reshapes the LP's static payoff curve from p\sqrt{p} back to linear pp (conditional on rebalancing keeping up with market moves), while Curve Cryptoswap's concentrated liquidity and optional oracle-backed dynamic fees (YBOraclizedPolicy) work to out-earn and recapture LVR on the underlying pool.

Options-replication and Predictable Loss framing

In derivatives terms (Clark 2020/2021; Lambert), a passive AMM LP is effectively short gamma (short volatility): its payoff replicates a portfolio of short options whose streaming premia are swap fees. Continuous 2×2\times compounding leverage cancels that short-gamma curvature back to linear spot exposure, trading short-gamma convexity for releveraging volatility decay. Similarly, Cartea, Drissi, and Monga (2023/2024) formalize this continuous adverse-selection and convexity drag as Predictable Loss (PL)—a model-free baseline that concentrated liquidity and dynamic fee sizing must out-earn.

How 2×2\times compounding leverage produces linear pp exposure​

To track linear pp exposure, YieldBasis maintains crvUSD debt dd at a constant fraction of LP collateral value VcV_c:

d=Vc(1−1L),V∗=Vc−d=VcL.d = V_c \left(1 - \frac{1}{L}\right), \qquad V_* = V_c - d = \frac{V_c}{L}.

For an infinitesimal collateral move δVc\delta V_c before debt adjusts, dd is fixed, so δV∗=δVc\delta V_* = \delta V_c:

δV∗V∗=δVcVc/L=L δVcVc.\frac{\delta V_*}{V_*} = \frac{\delta V_c}{V_c / L} = L\,\frac{\delta V_c}{V_c}.

Integrating both sides yields ln⁡V∗=Lln⁡Vc+C\ln V_* = L \ln V_c + C, or the compounding-leverage power law:

V∗∝Vc L.V_* \propto V_c^{\,L}.

Because Curve Cryptoswap LP value scales approximately as Vc∝pV_c \propto \sqrt{p}, substituting gives:

V∗∝(p) L=p L/2.V_* \propto (\sqrt{p})^{\,L} = p^{\,L/2}.

Setting L=2L = 2 gives V∗∝pV_* \propto p: the leveraged position keeps full price exposure to BTC or ETH, up and down, while earning Curve pool trading fees on 2×2\times notional liquidity. At L=2L = 2, debt equals 50% of collateral value—matching the crvUSD half of a balanced Curve LP position so unwinding the LP repays the debt cleanly.

LEVAMM invariant, safe bounds, and flash-loan sizing​

Each market's LEVAMM (AMM.vy) holds yy Curve LP tokens against dd crvUSD debt and reads pop_o from CryptopoolLPOracle.price().

Invariant and anchor term x0(po)x_0(p_o)​

At equilibrium for oracle price pop_o, ideal debt d~\tilde{d} and ideal collateral y~\tilde{y} satisfy:

d~=L−1L po y~.\tilde{d} = \frac{L - 1}{L}\,p_o\,\tilde{y}.

Defining the virtual stablecoin reserve x≡x0(po)−dx \equiv x_0(p_o) - d, LEVAMM enforces the constant-product invariant:

(x0(po)−d) y=I(po).\bigl(x_0(p_o) - d\bigr)\,y = I(p_o).

Requiring the marginal price at (y~,d~)(\tilde{y}, \tilde{d}) to equal pop_o gives (x0−d~)/y~=po(x_0 - \tilde{d}) / \tilde{y} = p_o, which implies:

x0(po)=2L−1L po y~,I(po)=x02po(L2L−1)2.x_0(p_o) = \frac{2L - 1}{L}\,p_o\,\tilde{y}, \qquad I(p_o) = \frac{x_0^2}{p_o}\left(\frac{L}{2L - 1}\right)^2.

Equating I(po)I(p_o) to the live product (x0−d) y(x_0 - d)\,y yields a quadratic in x0x_0. The @internal helper get_x0 in AMM.vy (not an external getter) takes the larger root:

x0(po)=poy+(poy)2−4 po y d (L2L−1)22(L2L−1)2.x_0(p_o) = \frac{p_o y + \sqrt{(p_o y)^2 - 4\,p_o\,y\,d\,\left(\tfrac{L}{2L - 1}\right)^2}}{2\left(\tfrac{L}{2L - 1}\right)^2}.

In AMM.vy, LEV_RATIO stores (L2L−1)2\left(\frac{L}{2L - 1}\right)^2 scaled by 1e18 (equal to 4/9×10184/9 \times 10^{18} at L=2L = 2). The sandwich-resistant USD equity of the vault at pop_o (AMM.value_oracle()) is:

V=y~ po−d~=x02L−1.V = \tilde{y}\,p_o - \tilde{d} = \frac{x_0}{2L - 1}.

Safe debt bounds​

When safe_limits is True, the @internal helper get_x0 in AMM.vy enforces a debt-to-collateral band around 50%:

  • MIN_SAFE_DEBT: 14L2\dfrac{1}{4L^2} of collateral value (1/16=6.25%1/16 = 6.25\% at L=2L = 2).
  • MAX_SAFE_DEBT: (2L−1)24L2−18L2\dfrac{(2L - 1)^2}{4L^2} - \dfrac{1}{8L^2} of collateral value (9/16−1/32=17/32=53.125%9/16 - 1/32 = 17/32 = 53.125\% at L=2L = 2).

At L=2L = 2, the quadratic discriminant vanishes at d/Vc=9/16d / V_c = 9/16; MAX_SAFE_DEBT leaves a 1/321/32 buffer below that solvability boundary. Deposits revert with "Unsafe min" or "Unsafe max" outside this band. AMM.exchange() relaxes the check only when a trade moves coll_value / debt strictly closer to 2.02.0 without crossing it. Withdrawals bypass the band because they remove collateral and debt proportionally.

VirtualPool flash-loan sizing (ϕ\phi)​

Arbitrageurs rebalance LEVAMM atomically through VirtualPool, which flash-borrows crvUSD to add or remove Curve liquidity in exact balance:

  • Asset →\to crvUSD (i == 1, debt too low): ϕ=in_amount⋅xc/yc\phi = \text{in\_amount} \cdot x_c / y_c, matching the Curve pool's reserve ratio.
  • crvUSD →\to asset (i == 0, debt too high): With LEVAMM fee ff, arbitrageur input xx (discounted by ROUNDING_DISCOUNT = 1e-8), Curve reserves xc,ycx_c, y_c, LP supply ScS_c, and r=xcSc(1−f)r = \frac{x_c}{S_c}(1 - f), VirtualPool solves:
ϕ2+ϕ(x0−d+x−r y)−y x r=0,ϕ=(x0−d+x−r y)2+4 y x r−(x0−d+x−r y)2.\phi^2 + \phi\bigl(x_0 - d + x - r\,y\bigr) - y\,x\,r = 0, \qquad \phi = \frac{\sqrt{\bigl(x_0 - d + x - r\,y\bigr)^2 + 4\,y\,x\,r} - \bigl(x_0 - d + x - r\,y\bigr)}{2}.

Rebalancing cost versus trading fee profitability​

Because L=2L = 2 deploys twice the notional liquidity into Curve, gross pool fee APR scales linearly with LL. Subtracting borrow interest and rebalancing drag gives the net simple APR:

APRnet=L rpool−(rborrow+rreleverage)=2 rpool−(rborrow+rreleverage).\text{APR}_{\text{net}} = L\,r_{\text{pool}} - \bigl(r_{\text{borrow}} + r_{\text{releverage}}\bigr) = 2\,r_{\text{pool}} - \bigl(r_{\text{borrow}} + r_{\text{releverage}}\bigr).

Why concentrated liquidity is required​

Reshaping a concave p\sqrt{p} curve into linear pp exposure does not make convexity free. Maintaining constant L=2L = 2 leverage requires borrowing more crvUSD to add LP collateral as price rises and repaying crvUSD by removing LP collateral as price falls. In choppy, mean-reverting markets, this convex rebalancing rule bleeds execution friction—the onchain equivalent of leveraged-ETF volatility decay—quantified here as rreleverager_{\text{releverage}}. Linear pp exposure is also conditional on continuous arbitrage: during extreme gas spikes or crvUSD peg dislocations, leverage can temporarily drift away from 2×2\times.

Empirical simulations from the YieldBasis whitepaper show that rebalancing drag rreleverager_{\text{releverage}} is roughly twice the fee APR of an optimized unlevered constant-product pool (rxy=koptr_{xy=k}^{\text{opt}}):

rreleverage≈2 rxy=kopt.r_{\text{releverage}} \approx 2\,r_{xy=k}^{\text{opt}}.

On a standard x⋅y=kx \cdot y = k pool, 2 rxy=kopt−rreleverage≈02\,r_{xy=k}^{\text{opt}} - r_{\text{releverage}} \approx 0, leaving no margin to pay borrow costs or yield. YieldBasis achieves positive net return by pairing LEVAMM with Curve Cryptoswap, where concentrated liquidity generates a higher fee APR rpoolr_{\text{pool}} per unit of capital.

Inside Cryptoswap, the pool protects a fraction ρ\rho of fee profit (reserved_profit_fraction()) for LPs and spends the remainder on price_scale recentering. Under frequent recentering (with zero pool admin fee), realized pool fee yield is approximately:

rpool,realised≈ρ⋅rpool,raw,r_{\text{pool,realised}} \approx \rho \cdot r_{\text{pool,raw}},

plus LEVAMM's own swap fees (AMM.fee()). Under continuous compounding, APYnet=exp⁡(APRnet)−1\text{APY}_{\text{net}} = \exp(\text{APR}_{\text{net}}) - 1.

Measuring realized LP profitability (three-surface markout PnL): Headline fee APR hides adverse selection. Empirical market-microstructure studies evaluate LP profitability using trade-level markout PnL (Δstablepool+Δassetpool⋅Pref(t+h)\Delta \text{stable}_{\text{pool}} + \Delta \text{asset}_{\text{pool}} \cdot P_{\text{ref}}(t + h) across post-trade horizons hh). In YieldBasis, an accurate markout attribution must separate three distinct execution surfaces—direct swaps on the underlying Curve Cryptoswap pool, atomic flash-routed rebalances through VirtualPool, and direct collateral-debt swaps against LEVAMM (AMM.vy)—without double-counting swap fees already embedded in execution prices.

Interest recycling (refueling loop)​

Borrow interest accrued on LEVAMM's pooled crvUSD debt does not leave the market. Calling LT.distribute_borrower_fees() collects accrued borrow interest and donates 100% of it into the market's Curve Cryptoswap pool (add_liquidity(..., donation=True)).

Interest recycling loop: LEVAMM accrues borrow interest on crvUSD debt, LT donates it to the Curve Cryptoswap pool, and the donation subsidizes pool rebalancing costsInterest recycling loop: LEVAMM accrues borrow interest on crvUSD debt, LT donates it to the Curve Cryptoswap pool, and the donation subsidizes pool rebalancing costs

Refueling loop: borrower interest recycles into the Curve pool's donation buffer to subsidize rebalancing.

A donation mints no LP shares; instead, it releases gradually over the pool's donation window to fund price_scale recentering alongside the rebalance budget. Including refueling alongside borrow interest gives:

APRnet,realised≈L rpool,realised−rreleverage−(rborrow−rrefuel).\text{APR}_{\text{net,realised}} \approx L\,r_{\text{pool,realised}} - r_{\text{releverage}} - \bigl(r_{\text{borrow}} - r_{\text{refuel}}\bigr).

In steady state (rrefuel≈rborrowr_{\text{refuel}} \approx r_{\text{borrow}}), this reduces to L rpool,realised−rreleverageL\,r_{\text{pool,realised}} - r_{\text{releverage}}, so profitability holds whenever 2 rpool,realised>rreleverage2\,r_{\text{pool,realised}} > r_{\text{releverage}}. When net rebalancing costs exceed trading fees, Fundamental Value (LT.pricePerShare()) declines (PPS drag).

Admin-fee curve and staked accounting​

LT._calculate_values() splits eligible positive value gains between unstaked yb-LP holders and protocol admin fees using a square-root function of the staking ratio s/Ts / T:

fa=1−(1−fmin⁡) 1−sT,f_a = 1 - (1 - f_{\min})\,\sqrt{1 - \frac{s}{T}},

where fmin⁡f_{\min} is Factory.min_admin_fee().

  • At s=0s = 0, fa=fmin⁡f_a = f_{\min} (unstaked LPs keep 1−fmin⁡1 - f_{\min}).
  • As s→Ts \to T, fa→1f_a \to 1, while fewer unstaked shares split the remaining 1−fa1 - f_a pool, raising yield per unstaked share and pulling the market toward equilibrium.

Accounting below the watermark​

Let Δv\Delta v be the period value change, vsv_s be the staked bucket value, vs∗v_s^* be its watermark (ideal_staked), and vs,loss=max⁡(vs∗−vs,0)v_{s,\text{loss}} = \max(v_s^* - v_s, 0) be the watermark shortfall.

While the gauge holds at least 0.01 yb-LP (MIN_STAKED_FOR_FEES = 10**16 base units):

  1. Below the watermark (vs,loss>0v_{s,\text{loss}} > 0 and Δv>0\Delta v > 0): LT waives the admin fee on gains until the staked side's pro rata share closes vs,lossv_{s,\text{loss}}, charging faf_a only on the excess: vloss=min⁡ ⁣(Δv,  vs,loss⋅Ts),Δvuse=vloss+(Δv−vloss)(1−fa),Δa=(Δv−vloss) fa.v_{\text{loss}} = \min\!\left(\Delta v,\; v_{s,\text{loss}} \cdot \frac{T}{s}\right), \quad \Delta v_{\text{use}} = v_{\text{loss}} + (\Delta v - v_{\text{loss}})(1 - f_a), \quad \Delta a = (\Delta v - v_{\text{loss}})\,f_a.
  2. At the watermark (vs,loss=0v_{s,\text{loss}} = 0 and Δv>0\Delta v > 0): Δvuse=Δv (1−fa)\Delta v_{\text{use}} = \Delta v\,(1 - f_a) and Δa=Δv fa\Delta a = \Delta v\,f_a.
  3. Loss (Δv≤0\Delta v \le 0): No admin fee (Δa=0\Delta a = 0); losses split pro rata between staked and unstaked buckets.

(Below 0.01 yb-LP staked, LT applies faf_a symmetrically to both gains and losses.)

On gains, the staked bucket receives Δvs=min⁡(Δvuse⋅s/T,  vs,loss)\Delta v_s = \min(\Delta v_{\text{use}} \cdot s / T,\; v_{s,\text{loss}})—zero when at the watermark—and unstaked holders receive Δvus=Δvuse−Δvs\Delta v_{us} = \Delta v_{\text{use}} - \Delta v_s.

Negative rebase of staked shares​

Because unstaked shares retain post-watermark fee growth while staked shares do not, LT burns δs\delta s shares from the gauge contract so every yb-LP share keeps the same underlying value:

δs=s v1′−T vs′v1′−vs′,snew=s−δs,Tnew=T−δs,\delta s = \frac{s\,v_1' - T\,v_s'}{v_1' - v_s'}, \qquad s_{\text{new}} = s - \delta s, \qquad T_{\text{new}} = T - \delta s,

where v1′=max⁡(v−1+Δvuse,0)v_1' = \max(v_{-1} + \Delta v_{\text{use}}, 0) and vs′=max⁡(vs+Δvs,0)v_s' = \max(v_s + \Delta v_s, 0). To prevent divergence as s/T→1s / T \to 1, LT clamps ∣δs∣|\delta s| using SQRT_MIN_UNSTAKED_FRACTION = 10**14 (ϵmin⁡=10−4\sqrt{\epsilon_{\min}} = 10^{-4}):

δsmax⁡=∣Δv⋅Tv−1+Δv+1⋅1−faϵmin⁡∣.\delta s_{\max} = \left|\frac{\Delta v \cdot T}{v_{-1} + \Delta v + 1} \cdot \frac{1 - f_a}{\sqrt{\epsilon_{\min}}}\right|.

YB emission decay curve​

YB.emit() mints continuously from the 300,000,000 YB emission reserve using the immutable rate constant YB.max_mint_rate() (≈7.93×10−9 s−1\approx 7.93 \times 10^{-9}\ \text{s}^{-1}, a 4-year e-folding time):

emissions=reserve⋅(1−e−Δt⋅max_mint_rate⋅rate_factor).\text{emissions} = \text{reserve} \cdot \left(1 - e^{-\Delta t \cdot \text{max\_mint\_rate} \cdot \text{rate\_factor}}\right).

GaugeController computes rate_factor from raw veYB gauge weights and each market's staking ratio:

adjusted_weight(g)=raw_weight(g)⋅min⁡ ⁣(staked(g)totalSupply(g),  1),rate_factor=∑gadjusted_weight(g)∑graw_weight(g).\text{adjusted\_weight}(g) = \text{raw\_weight}(g) \cdot \min\!\left(\sqrt{\frac{\text{staked}(g)}{\text{totalSupply}(g)}},\; 1\right), \qquad \text{rate\_factor} = \frac{\sum_g \text{adjusted\_weight}(g)}{\sum_g \text{raw\_weight}(g)}.

When staking drops across voted gauges, rate_factor falls and stretches the reserve's decay horizon; when all voted gauges are 100% staked, rate_factor = 1 and emissions run at max_mint_rate.