Protocol mechanics / LEVAMM rebalancing
Rebalancing through arbitrage
Yield Basis does not rebalance this LEVAMM path with a scheduled keeper. Price moves create a spread between Curve LP fair value and the LEVAMM marginal price; arbitrageurs close that spread, and the side effect moves DTV back toward the 2x target.
Balanced starting state
BTC rises, price_scale lags
VirtualPool arbitrage when BTC rises
The arbitrageur brings BTC. VirtualPool handles the flash crvUSD leg, Curve mints LP, and LEVAMM buys LP at a premium. The trade is profitable for the bot and increases LEVAMM leverage toward target.
BTC has moved up; LEVAMM is below target DTV.
Borrowed and repaid atomically inside the same transaction.
BTC and flash crvUSD are deposited at the Curve pool ratio.
LEVAMM pays above oracle LP because x_initial expanded.
DTV moves from 47.67% toward the 50% target.
BTC has moved up; LEVAMM is below target DTV.
Borrowed and repaid atomically inside the same transaction.
BTC and flash crvUSD are deposited at the Curve pool ratio.
LEVAMM pays above oracle LP because x_initial expanded.
DTV moves from 47.67% toward the 50% target.
Before and after the re-lever trade
| Metric | Before | After | Delta | Interpretation |
|---|---|---|---|---|
| Collateral (LP) | 200,000.00 | 200,209.7618 | +209.7618 | LEVAMM bought LP |
| Debt (crvUSD) | 100,000.00 | 100,237.45 | +237.4512 | LEVAMM minted new debt |
| x0 virtual reserve | 328,129.17 | 328,133.18 | +4.0151 | Recomputed at same oracle |
| DTV | 47.67% | 47.74% | +0.06% | Moves toward 50% |
Both collateral and debt increase. The premium paid to the arbitrageur is the protocol cost of restoring the 2x leverage state.
Profit versus oracle LP price
Small-trade profit is positive when DTV is below 50%. At larger size the hyperbolic curve eats the premium through price impact, so real arbitrage is naturally incremental.
| Oracle LP | DTV | LEVAMM/LP | Premium | out_amt | BTC cost | Net Profit | Profit % | Note |
|---|---|---|---|---|---|---|---|---|
| 0.9500 | 52.63% | 0.8398 | -11.60% | 65.1211 | 89.2737 | -24.1526 | -27.05% | |
| 0.9800 | 51.02% | 0.9387 | -4.22% | 85.8045 | 95.5665 | -9.7620 | -10.21% | |
| 1.0000 | 50.00% | 1.0000 | +0.00% | 99.0000 | 99.7618 | -0.7618 | -0.76% | T0 balanced |
| 1.0200 | 49.02% | 1.0589 | +3.81% | 111.5289 | 103.9570 | +7.5719 | +7.28% | |
| 1.0500 | 47.62% | 1.1440 | +8.95% | 129.2201 | 110.2499 | +18.9702 | +17.21% | |
| 1.0488 | 47.67% | 1.1406 | +8.76% | 128.1657 | 110.0000 | +18.1657 | +16.51% | T1 actual |
| 1.0800 | 46.30% | 1.2261 | +13.53% | 146.3502 | 116.5427 | +29.8075 | +25.58% | |
| 1.1000 | 45.45% | 1.2796 | +16.33% | 157.2422 | 120.7379 | +36.5043 | +30.23% | |
| 1.1500 | 43.48% | 1.4102 | +22.63% | 184.6167 | 131.2260 | +53.3906 | +40.69% |
De-leverage when BTC falls
Quadratic flash leg, input = 1,000 crvUSD
In the falling-price direction the arbitrageur provides crvUSD, LEVAMM sells LP cheaply, and the VirtualPool computes the flash leg with a quadratic equation so Curve withdrawal remains symmetric.
Implementation-level formulas
Full formulas are shown wrapped, not clipped. They are explanatory references, not live pool calculations.
cv = p_o * collateral k = 4 / 9 # LEV_RATIO for 2x leverage x0 = (cv + sqrt(cv^2 - 4 * cv * k * debt)) / (2 * k) # DTV = 50%: x0 = 3 * debt, x_initial = 2 * debt # DTV < 50%: x0 grows -> premium (re-lever) # DTV > 50%: x0 shrinks -> discount (de-lever)
x_initial = x0 - debt y_after = collateral + lp_amount x_after = ceil(x_initial * collateral / y_after) out = (x_initial - x_after) * (1 - fee) # Hyperbolic invariant: x_initial * collateral = k # LEVAMM overpays when x_initial grew (DTV < 50%)
# Simple proportion, no quadratic flash = in_btc * S / B lp = supply * in_btc / B out = AMM.get_dy(1, 0, lp) - flash # S = crvUSD in pool, B = BTC in pool # symmetric add_liquidity proportional to pool
# Quadratic equation r0fee = S * (1 - fee) / supply b = x0 - debt + in_crvusd - r0fee * collateral D = b^2 + 4 * r0fee * collateral * in_crvusd flash = (sqrt(D) - b) / 2 out = flash * B / S # BTC from symmetric remove_liquidity
What the mechanism does
When BTC rises, the LEVAMM oracle anchor inflates x0 and creates a premium above Curve LP fair value. Arbitrageurs provide BTC, flash-borrow crvUSD, mint LP, and sell that LP to LEVAMM for a profit; the side effect is that LEVAMM gains leverage and DTV moves toward 50%. When BTC falls, the mirror trade reduces leverage pressure. Every arbitrage trade nudges the system back toward the 2x target.