Skip to main content

Math Primer

0. Notation & Symbols

SymbolMeaning
ppBTC spot price in USD
pop_oOracle BTC/USD price used by the Rebalancing‑AMM
VcV_cValue of collateral (Curve LP tokens)
VV_*Value of the leveraged position (after borrowing)
ddOutstanding crvUSD debt
LLCompounding leverage factor (fixed to 2 in YieldBasis)
yyLP token amount held by the Rebalancing‑AMM
x0(po)x_0(p_o)Anchor term in the Rebalancing‑AMM pricing formula
I(po)I(p_o)Invariant constant of the Rebalancing‑AMM for a fixed oracle price
ϕ\phiFlash‑loan size (crvUSD) solved via a quadratic
faf_aAdmin‑fee fraction routed to veYB
fminf_{\min}Minimum admin fee when nobody stakes
s,Ts, TStaked vs total supply of ybBTC
rpoolr_{\text{pool}}Fee APR earned by the underlying Curve pool (unlevered)
rborrowr_{\text{borrow}}Borrow APR on the crvUSD CDP line
rrebalancingr_{\text{rebalancing}}Effective APR “cost” of maintaining leverage (rebalancing losses/subsidy)

1. The Constant‑Product Problem (Why p\sqrt{p} Shows Up)

Classic AMMs (e.g. Uniswap v2) enforce

xy=k(1.1)x \cdot y = k \tag{1.1}

where xx is the USD side and yy is the BTC side. Let the external BTC price be pp (USD per BTC).

1.1 Normalising the start

Assume you deposit equal USD value at p0=1p_0 = 1:

  • x0=1x_0 = 1 USD
  • y0=1y_0 = 1 BTC (worth $1 at p0p_0)

So

k=x0y0=1.(1.2)k = x_0 \cdot y_0 = 1. \tag{1.2}

1.2 After a price move

Arbitrage pushes the AMM price to pp. In a constant‑product AMM,

p=xy.(1.3)p = \frac{x}{y}. \tag{1.3}

Combine (1.1) and (1.3):

x=kp,y=kp.(1.4)x = \sqrt{k p}, \qquad y = \sqrt{\frac{k}{p}}. \tag{1.4}

With k=1k = 1:

x=p,y=1p.(1.5)x = \sqrt{p}, \qquad y = \frac{1}{\sqrt{p}}. \tag{1.5}

1.3 LP value scales as p\sqrt{p}

Ignoring fees, LP USD value is

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

We started with $2 total, so per‑initial‑dollar scaling is

VLP,norm(p)=p(1.7)\boxed{V_{\text{LP,norm}}(p) = \sqrt{p}} \tag{1.7}

1.4 Impermanent loss (IL)

If you just held instead:

Vhold(p)=p+1.(1.8)V_{\text{hold}}(p) = p + 1. \tag{1.8}

Impermanent loss (relative underperformance) is

IL(p)=VLP(p)Vhold(p)1=2p1+p1.(1.9)\text{IL}(p) = \frac{V_{\text{LP}}(p)}{V_{\text{hold}}(p)} - 1 = \frac{2\sqrt{p}}{1+p} - 1. \tag{1.9}

Since 2p<1+p2\sqrt{p} < 1+p for any p1p \neq 1, IL(p)<0\text{IL}(p) < 0: the LP underperforms HODLing whenever price drifts.

Takeaway. Constant‑product LP value p\propto \sqrt{p}. 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 a linear value function. YieldBasis provides such a design by engineering exposure to scale linearly with pp, not as p\sqrt{p}.


2. Compounding Leverage — Turning p\sqrt{p} into pp

YieldBasis borrows against the LP collateral to keep a constant compounding leverage of LL.

2.1 Defining “compounding leverage”

By construction, the protocol keeps debt at a fixed fraction of collateral:

d=Vc(11L).(2.1)d = V_c \left(1 - \frac{1}{L}\right). \tag{2.1}

So the net position value is

V=Vcd=VcL.(2.2)V_* = V_c - d = \frac{V_c}{L}. \tag{2.2}

Consider a small change in collateral value dVcdV_c. After re‑leveraging to restore the ratio, the relative change of VV_* is amplified by LL:

δVV=LδVcVc.(2.3)\frac{\delta V_*}{V_*} = L \, \frac{\delta V_c}{V_c}. \tag{2.3}

Integrate both sides:

δVV=LδVcVc    lnV=LlnVc+const.(2.4)\int \frac{\delta V_*}{V_*} = L \int \frac{\delta V_c}{V_c} \;\Longrightarrow\; \ln V_* = L \ln V_c + \text{const}. \tag{2.4}

Exponentiate:

VVcL(2.5)\boxed{V_* \propto V_c^{\,L}} \tag{2.5}
Why is the relative change amplified?

Growth of the price of collateral

If the collateral grows in price, the value VV_* changes as (dd is kept constant at this step): V+δV=Vcd+δVcδd=(Vcd)+δVc=V+δVc=V+yδpV_* + \delta V_* = V_c - d + \delta V_c - \delta d = (V_c - d) + \delta V_c = V_* + \delta V_c = V_* + y\delta p δVV=yδpypL=Lδpp=LδVcVc\frac{\delta V_*}{V_*} = \frac{y \delta p}{\frac{yp}{L}} = L\frac{\delta p}{p} = L\frac{\delta V_c}{V_c}

Adjustment of the debt value and of the collateral amount

By definition: d=Vc(11L)d = V_c(1-\frac{1}{L}) Then: V+δV=Vcd+δVcδd=(Vc+δVc)d(11L)δVc=V+1LδVc=V+1LpδyV_*+\delta V_* = V_c - d +\delta V_c - \delta d = (V_c + \delta V_c)-d-(1-\frac{1}{L})\delta V_c = V_*+\frac{1}{L}\delta V_c = V_*+\frac{1}{L}p\delta y Whence it follows that δVV=pδyLpyL=δyy=δVcVc\frac{\delta V_*}{V_*} = \frac{\frac{p\delta y}{L}}{\frac{py}{L}} = \frac{\delta y}{y} = \frac{\delta V_c}{V_c}

As in this step the value of the leveraged position tracks the value of the collateral linearly, the total scaling factor is exactly equal to the scaling factor of the previous step. For more details, refer to the General Idea section of the Whitepaper.

2.2 Pick L=2L = 2 to linearise BTC exposure

Curve Cryptoswap LP value scales approximately as VcpV_c \propto \sqrt{p}. Plug that in:

V(p)L=pL/2.(2.6)V_* \propto (\sqrt{p})^{\,L} = p^{\,L/2}. \tag{2.6}

Set L=2L = 2:

Vp(2.7)\boxed{V_* \propto p} \tag{2.7}

Result: With L=2L = 2, your position tracks BTC 1:1 — the p\sqrt{p} curvature (and thus impermanent loss) is eliminated while you still earn trading fees.

2.3 What if L2L \neq 2?

  • L>2L > 2: VpL/2V_* \propto p^{L/2} — outperform on the way up, underperform on the way down (re‑introduces divergence vs. “just hold”).
  • L<2L < 2: You under‑hedge the p\sqrt{p} curve and still suffer residual IL.

Hence, locking L=2L = 2 is the sweet spot: linear BTC exposure, zero IL, and manageable debt that can always be unwound with the LP’s USD side.


3. Rebalancing‑AMM & Virtual Pool

To keep leverage fixed at L=2L = 2 (i.e. debt = 50% of value), YieldBasis uses a second AMM (“Rebalancing‑AMM”). It holds Curve LP tokens on one side and implicit crvUSD debt on the other, and is anchored to an oracle price pop_o (BTC/USD).

We first state the target (“ideal”) state at p=pop = p_o, then derive the invariant and solve for the anchor variable x0(po)x_0(p_o).

3.1 Ideal debt at the oracle price

If the live market price equals the oracle price pop_o, “perfect” leverage is:

d~  =  L1Lpoy~(ideal debt when p=po),(3.1)\tilde{d} \;=\; \frac{L-1}{L}\,p_o\,\tilde{y} \qquad\text{(ideal debt when } p = p_o\text{)}, \tag{3.1}

where y~\tilde{y} is the LP amount in the AMM at that oracle touch point (tildes = “ideal” values).

For L=2L = 2: d~=12poy~\tilde{d} = \tfrac{1}{2} p_o \tilde{y}.

3.2 Rebalancing‑AMM Invariant & Pricing

Define xx0(po)dx \equiv x_0(p_o) - d. The Rebalancing‑AMM uses a constant‑product‑like invariant:

(x0(po)d)  y  =  I(po),(3.2)\big(x_0(p_o) - d\big)\; y \;=\; I(p_o), \tag{3.2}

with I(po)I(p_o) constant as long as pop_o stays fixed.

At p=pop = p_o, the AMM’s instantaneous price should equal the oracle:

x0(po)d~y~=po.(3.3)\frac{x_0(p_o) - \tilde{d}}{\tilde{y}} = p_o. \tag{3.3}

Substitute d~\tilde{d} from (3.1):

x0(po)=2L1Lpoy~.(3.4)x_0(p_o) = \frac{2L - 1}{L}\,p_o\,\tilde{y}. \tag{3.4}

3.3 Solving for x0x_0 with arbitrary y,dy, d

Away from the ideal point, we don’t know y~\tilde{y} directly. From (3.4):

y~  =  L2L1x0po.(3.5)\tilde{y} \;=\; \frac{L}{2L - 1}\,\frac{x_0}{p_o}. \tag{3.5}

Evaluate the invariant at the ideal point:

I(po)  =  (x0d~)y~  =  (x0L1Lpoy~)y~.(3.6)I(p_o) \;=\; \big(x_0 - \tilde{d}\big)\,\tilde{y} \;=\; \left(x_0 - \frac{L-1}{L} p_o \tilde{y}\right)\tilde{y}. \tag{3.6}

Set that equal to the current‑state invariant (x0d)y(x_0 - d)\,y, substitute (3.5), and rearrange. You obtain a quadratic in x0x_0:

x02(L2L1)2poyx0+poyd=0.(3.7)x_0^{2}\left(\frac{L}{2L-1}\right)^{2} - p_o y\,x_0 + p_o y\,d = 0. \tag{3.7}

Choose the larger root (matches the ideal‑state intuition):

x0(po)=poy+(poy)24poyd(L2L1)22(L2L1)2(3.8)\boxed{ 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}} } \tag{3.8}

For L=2L = 2, you can simplify numerically in code, but keep the general form for clarity.

3.4 Useful derived quantities

Pool value at oracle price. It’s cleaner to value the AMM at p=pop = p_o to avoid sandwich games:

V  =  y~pod~  =  1Ly~po  =  x02L1.(3.9)V \;=\; \tilde{y}\,p_o - \tilde{d} \;=\; \frac{1}{L}\,\tilde{y}\,p_o \;=\; \frac{x_0}{2L - 1}. \tag{3.9}

Invariant in closed form.

I(po)  =  (x0d~)y~  =  x02po(L2L1)2.(3.10)I(p_o) \;=\; \big(x_0 - \tilde{d}\big)\,\tilde{y} \;=\; \frac{x_0^{2}}{p_o}\left(\frac{L}{2L-1}\right)^{2}. \tag{3.10}

An alternative expression for VV follows from (3.10):

V  =  2I(po)pox0.(3.11)V \;=\; 2\,\sqrt{I(p_o)\,p_o} - x_0. \tag{3.11}

3.5 Flash‑Loan Sizing (ϕ\phi)

When the arbitrageur comes with xx 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),
  • The flash loan is repaid inside the same tx.

Let:

  • ff — Rebalancing‑AMM fee
  • dd — current debt
  • yy — LP amount in the Rebalancing‑AMM
  • x0x_0 — anchor term from Eq. (3.8)
  • xx — user‑provided crvUSD for this swap
  • xc,yc,Scx_c, y_c, S_c — Curve pool’s stablecoin reserves, crypto reserves, total LP supply

Define a convenience constant

r  =  xcSc(1f).(3.12)r \;=\; \frac{x_c}{S_c}\,(1 - f). \tag{3.12}

The required flash amount ϕ\phi solves the quadratic (whitepaper Eq. 39):

ϕ2  +  ϕ(x0d+xry)    yxr  =  0.(3.13)\phi^{2} \;+\; \phi\Big(x_0 - d + x - r\,y\Big) \;-\; y\,x\,r \;=\; 0. \tag{3.13}

Discriminant:

D  =  (x0d+xry)2+4yxr.(3.14)D \;=\; \Big(x_0 - d + x - r\,y\Big)^2 + 4\,y\,x\,r. \tag{3.14}

Choose the positive root:

ϕ=D(x0d+xry)2(3.15)\boxed{ \phi = \frac{\sqrt{D} - (x_0 - d + x - r\,y)}{2} } \tag{3.15}

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 (no new math)

  • Debt too low (price up): d/V<0.5d/V < 0.5. Then x0dx_0 - d is large → LP is “expensive” in crvUSD. Arb brings in crvUSD, mints LP, increases dd.
  • Debt too high (price down): d/V>0.5d/V > 0.5. Then x0dx_0 - d 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.


4. Net APR & Cost Terms

We want an explicit expression for the BTC‑denominated return of an unstaked ybBTC position.

4.1 Components

Let

  • rpoolr_{\text{pool}} — APR the Curve BTC/crvUSD pool would earn without leverage (pure trading fees, in BTC terms).
  • LL — compounding leverage (YieldBasis: L=2L = 2).
  • rborrowr_{\text{borrow}} — effective borrow APR on the protocol’s crvUSD line (set by governance).
  • rrebalancingr_{\text{rebalancing}} — drag from maintaining constant leverage (AMM fees/price edge paid to arbs, flash‑loan interest, slippage).

Because we supply twice as much notional liquidity (BTC + borrowed crvUSD) to Curve, fee flow scales ~linearly with LL:

Gross fee APR  =  Lrpool.(4.1)\text{Gross fee APR} \;=\; L \cdot r_{\text{pool}}. \tag{4.1}

For L=2L = 2:

Gross fee APR  =  2rpool.(4.2)\text{Gross fee APR} \;=\; 2\,r_{\text{pool}}. \tag{4.2}

We then subtract the two costs:

  1. Borrow cost — interest paid on the crvUSD debt.
  2. Rebalancing cost — continuous “leak” to arbitrageurs that keep the ratio at 50%.

Putting it together:

APRnet=Lrpool(rborrow+rrebalancing)(4.3)\boxed{ \text{APR}_{\text{net}} = L\,r_{\text{pool}} - \bigl(r_{\text{borrow}} + r_{\text{rebalancing}}\bigr) } \tag{4.3}

For YieldBasis’ fixed L=2L = 2:

APRnet=2rpool(rborrow+rrebalancing)(4.4)\boxed{ \text{APR}_{\text{net}} = 2\,r_{\text{pool}} - \bigl(r_{\text{borrow}} + r_{\text{rebalancing}}\bigr) } \tag{4.4}

4.2 Heuristic for rrebalancingr_{\text{rebalancing}}

Backtests (Jan 2019 – Oct 2024) show:

  • Optimised constant‑product pools (no leverage) earn 3%\sim 3\% APR over that window.
  • Empirically, rrebalancing2×r_{\text{rebalancing}} \approx 2\times 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 xy=kx\cdot y = k AMM (fees not big enough), but works on Curve Cryptoswap where rpoolr_{\text{pool}} is materially higher.

We do not hard‑code this heuristic on‑chain; it’s just a modelling shortcut:

rrebalancing2rxy=kopt(empirical).(4.5)r_{\text{rebalancing}} \approx 2 \cdot r_{x y = k}^{\text{opt}} \quad \text{(empirical)}. \tag{4.5}

4.3 Continuous vs. discrete compounding

All rates above are quoted as simple APRs for intuition. If you want continuous compounding:

APYnet=exp ⁣(APRnet)1.(4.6)\text{APY}_{\text{net}} = \exp\!\big(\text{APR}_{\text{net}}\big) - 1. \tag{4.6}

Given the relatively small magnitudes (single‑digit percentages for costs, double‑digit for fees), APR ≈ APY within a few bps, so we stick to APR in docs.

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 LPs (they want BTC fees) and veYB stakers (they want 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

  • TT = total ybBTC supply (all LP shares),
  • ss = amount of ybBTC staked (earning YB emissions),
  • fminf_{\min} = minimum admin fee when nobody stakes,
  • faf_a = actual admin‑fee fraction skimmed from fees and sent to veYB.

The curve:

fa  =  1(1fmin)1sT(5.1)\boxed{ f_a \;=\; 1 - (1 - f_{\min}) \, \sqrt{1 - \frac{s}{T}} } \tag{5.1}

Limits:

  • s=0fa=fmins = 0 \Rightarrow f_a = f_{\min} (LPs keep 1fmin1-f_{\min} of fees)
  • s=Tfa1s = T \Rightarrow f_a \to 1 (all fees to veYB; stakers opted out of fee yield anyway)

The square‑root makes the increase gentle at first (so early stakers don’t massively penalize LPs), then accelerates near full staking to avoid “everyone stakes, no one gets fees” equilibria.

5.2 Splitting fee gains / sharing losses

After each accounting tick (or harvest), let

  • v1v_{-1} = total value of the leveraged position (in BTC terms) before fees this period,
  • v1v_1 = total value after market moves + fees, before admin fee is taken,
  • Δvuse=(v1v1)(1fa)\Delta v_{\text{use}} = (v_1 - v_{-1})(1 - f_a) = value left for LPs after admin fee,
  • Δa=(v1v1)fa\Delta a = (v_1 - v_{-1}) f_a = admin fee sent to veYB.

We split Δvuse\Delta v_{\text{use}} between staked and unstaked portions:

  • If Δvuse<0\Delta v_{\text{use}} < 0 (loss): share it pro‑rata by stake.

    Δvs=ΔvusesT,Δvus=ΔvuseΔvs(5.2)\Delta v_s = \Delta v_{\text{use}} \cdot \frac{s}{T}, \qquad \Delta v_{us} = \Delta v_{\text{use}} - \Delta v_s \tag{5.2}
  • If Δvuse>0\Delta v_{\text{use}} > 0 (profit): first bring staked value vsv_s back up to its “ideal” target vsv_s^* (if previous losses hit stakers), then split the remainder pro‑rata.

    Δvs=min ⁣(ΔvusesT,  max(vsvs,0))(5.3)\Delta v_s = \min\!\left(\Delta v_{\text{use}} \cdot \frac{s}{T}, \; \max(v_s^* - v_s, 0)\right) \tag{5.3}

Unstaked side gets whatever is left:

Δvus=ΔvuseΔvs(5.4)\Delta v_{us} = \Delta v_{\text{use}} - \Delta v_s \tag{5.4}

5.3 Negative rebase for staked supply

Staked ybBTC rebases down when value allocated to stakers (after fees) is less than proportional to total value. Let

  • v1v_1' = new total value after admin fee (i.e. v1+Δvusev_{-1} + \Delta v_{\text{use}}),
  • vsv_s' = new staked value after sharing profit/loss,
  • ss = staked token supply before rebase,
  • TT = total token supply before rebase,
  • δs\delta s = how many staked tokens are burned (negative rebase).

We want the value share to match the token share:

sδsTδs  =  vsv1.(5.5)\frac{s - \delta s}{T - \delta s} \;=\; \frac{v_s'}{v_1'}. \tag{5.5}

Solve for δs\delta s:

δs=sv1Tvsv1vs(5.6)\boxed{ \delta s = \frac{s\,v_1' - T\,v_s'}{\,v_1' - v_s'\,} } \tag{5.6}

So the post‑rebase supplies become:

snew=sδs,Tnew=Tδs.(5.7)s_{\text{new}} = s - \delta s, \qquad T_{\text{new}} = T - \delta s. \tag{5.7}

Unstaked tokens never rebase; they simply accumulate (or lose) value via the (1fa)(1-f_a) 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 vsv_s'.