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.

Target DTV
2x leverage equilibrium
50.00%
T1 DTV
after BTC rises to 110k
47.67%
Re-lever edge
small-trade profit on BTC input
+15.9%
T0

Balanced starting state

BTC price
100,000 crvUSD
Curve pool
1,000,000 crvUSD / 10 BTC
LP supply
2,000,000
price_scale
100,000 crvUSD/BTC
LP oracle price
1.0000 crvUSD/LP
Collateral
200,000 LP
Debt
100,000 crvUSD
DTV
50.00%
LEVAMM price/LP
1.0000 crvUSD/LP
T1

BTC rises, price_scale lags

BTC price
110,000 crvUSD
Curve pool
1,048,808.85 crvUSD / 9.534626 BTC
price_scale
100,000 crvUSD/BTC (lagging)
LP market price
1.048809 crvUSD/LP
DTV
47.67%
x0
328,129.17
x_initial
228,129.17
LEVAMM price/LP
1.1406 crvUSD/LP
Premium vs oracle
+8.76%
Re-leverage flow

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.

Input
1
Arbitrageur sells BTC
0.001BTC

BTC has moved up; LEVAMM is below target DTV.

input value = 110.00 crvUSD
VirtualPool
2
Flash-borrow crvUSD
110.00crvUSD

Borrowed and repaid atomically inside the same transaction.

flash = in_btc * S / B = 0.001 * 1,048,808.85 / 9.534626
Curve
3
Mint LP symmetrically
209.7618LP

BTC and flash crvUSD are deposited at the Curve pool ratio.

lp = supply * in_btc / B = 2,000,000 * 0.001 / 9.534626
LEVAMM
4
Sell LP into premium
237.4512crvUSD

LEVAMM pays above oracle LP because x_initial expanded.

out = get_dy(1, 0, 209.7618 LP) after 0.3% fee
Output
5
Repay flash, keep spread
+17.4512crvUSD

DTV moves from 47.67% toward the 50% target.

237.4512 - 110.00 - 110.00 = 17.4512 crvUSD profit
State change

Before and after the re-lever trade

Collateral (LP)
+209.7618
Before
200,000.00
After
200,209.7618
LEVAMM bought LP
Debt (crvUSD)
+237.4512
Before
100,000.00
After
100,237.45
LEVAMM minted new debt
x0 virtual reserve
+4.0151
Before
328,129.17
After
328,133.18
Recomputed at same oracle
DTV
+0.06%
Before
47.67%
After
47.74%
Moves toward 50%

Both collateral and debt increase. The premium paid to the arbitrageur is the protocol cost of restoring the 2x leverage state.

1At T0, x0 = 3 * debt and x_initial = 2 * debt. LEVAMM marginal price equals the Curve LP oracle.
2After BTC rises, collateral value increases while debt is fixed. x0 grows and LEVAMM bids LP above oracle.
3The bot mints LP at Curve fair value and sells it into LEVAMM at the premium. That is the rebalance loop.
Sensitivity

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
0.9500
Net
-24.1526
DTV
52.63%
LEVAMM/LP
0.8398
Premium
-11.60%
out_amt
65.1211
BTC cost
89.2737
Profit %
-27.05%
Oracle LP
0.9800
Net
-9.7620
DTV
51.02%
LEVAMM/LP
0.9387
Premium
-4.22%
out_amt
85.8045
BTC cost
95.5665
Profit %
-10.21%
Oracle LP
1.0000
Net
-0.7618
DTV
50.00%
LEVAMM/LP
1.0000
Premium
+0.00%
out_amt
99.0000
BTC cost
99.7618
Profit %
-0.76%
T0 balanced
Oracle LP
1.0200
Net
+7.5719
DTV
49.02%
LEVAMM/LP
1.0589
Premium
+3.81%
out_amt
111.5289
BTC cost
103.9570
Profit %
+7.28%
Oracle LP
1.0500
Net
+18.9702
DTV
47.62%
LEVAMM/LP
1.1440
Premium
+8.95%
out_amt
129.2201
BTC cost
110.2499
Profit %
+17.21%
Oracle LP
1.0488
Net
+18.1657
DTV
47.67%
LEVAMM/LP
1.1406
Premium
+8.76%
out_amt
128.1657
BTC cost
110.0000
Profit %
+16.51%
T1 actual
Oracle LP
1.0800
Net
+29.8075
DTV
46.30%
LEVAMM/LP
1.2261
Premium
+13.53%
out_amt
146.3502
BTC cost
116.5427
Profit %
+25.58%
Oracle LP
1.1000
Net
+36.5043
DTV
45.45%
LEVAMM/LP
1.2796
Premium
+16.33%
out_amt
157.2422
BTC cost
120.7379
Profit %
+30.23%
Oracle LP
1.1500
Net
+53.3906
DTV
43.48%
LEVAMM/LP
1.4102
Premium
+22.63%
out_amt
184.6167
BTC cost
131.2260
Profit %
+40.69%
Mirror path

De-leverage when BTC falls

BTC market price
90,000 crvUSD
LP oracle price
0.948683 crvUSD
LEVAMM DTV
52.70% (> 50%)
x0
267,042.47
x_initial
167,042.47
LEVAMM/LP discount
-11.96%
Arb direction
i = 0 (crvUSD -> BTC)
i = 0

Quadratic flash leg, input = 1,000 crvUSD

r0fee
S * (1 - fee) / supply = 0.474342
K
r0fee * collateral = 94,868.33
b
x0 - debt + in - K = 73,174.14
D
b^2 + 4 * K * in = 5,733,927,874.41
flash
(sqrt(D) - b) / 2 = 1,274.28 crvUSD
out_BTC
flash * B / S = 0.01416 BTC
Net profit
1,274.28 - 1,000.00 = +274.28 crvUSD (+27.43%)

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.

Formula reference

Implementation-level formulas

Full formulas are shown wrapped, not clipped. They are explanatory references, not live pool calculations.

LEVAMM get_x0: virtual reserve anchor
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)
LEVAMM get_dy(1, 0, lp): LP -> crvUSD
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%)
VirtualPool i=1: re-lever, BTC rises
# 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
VirtualPool i=0: de-lever, BTC falls
# 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
Summary

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.