Hedged vaults

Each hedged vault holds a share of the reserve and borrows the other token, so its depositors keep one token's exposure at about 2× gross. The program rebuilds both vaults at every trade's endpoint without scanning holders.

Updated Nov 15, 2026

Each market has a base vault and a quote vault. The base vault holds a funded srLP position whose net exposure is base; quote is symmetric.

The market account stores each vault's srLP shares, its funding debt as shares of the borrowed token's borrow index plus the principal, its hLP supply, a residual-exposure checkpoint, a funding-rate average and per-source yield indexes. The program recomputes a vault's equity and its claim on the other token from current srLP claims and indexed debt each time, and keeps the last value only as a checkpoint. That value and the residual exposure are counted in the market's amount scale, the larger of twelve decimals and the two tokens' own, even in fields whose names end in _nad. Each hLP mint has its own cohort account, which is how a closed vault gets replaced by a new mint. The accounts reference lists the fields.

The endpoint

Writing Eb,EqE_b, E_q for the vaults' target-asset equities and (U,V)(U, V) for the ordinary tranche, the canonical endpoint after any trade is

Xb=U+Eb+EqUVXq=V+Eq+EbVUDbh,∗=EqUV,Dqh,∗=EbVU\begin{aligned} X_b &= U + E_b + E_q\frac{U}{V} \\ X_q &= V + E_q + E_b\frac{V}{U} \\ D_b^{h,*} &= E_q\frac{U}{V},\qquad D_q^{h,*} = E_b\frac{V}{U} \end{aligned}

Dbh,∗D_b^{h,*} is the base the quote vault owes, and Dqh,∗D_q^{h,*} the quote the base vault owes. The opposite-asset claim each vault holds equals its funding obligation, so neither vault has net exposure to the other token. Vault-owned shares are reconstructed from the ordinary supply SoS_o:

sb=⌊SoEbU⌋,sq=⌊SoEqV⌋S=So+sb+sq\begin{aligned} s_b &= \left\lfloor \frac{S_o E_b}{U} \right\rfloor,\qquad s_q = \left\lfloor \frac{S_o E_q}{V} \right\rfloor \\ S &= S_o + s_b + s_q \end{aligned}

Every product here rounds down in the program. Each vault's debt also carries any funding interest a swap has carried, and a frozen vault keeps the debt it had.

None of this scans hLP holders, so a rebuild costs the same however many there are. A trader is quoted on (U,V)(U, V); the program then rebuilds both vaults at the quoted endpoint and certifies the result:

  • each rebuilt debt is within one raw atom of the vault's share of the opposite reserve;
  • the prepared rebuild matches the exact state it was quoted on: which vaults are frozen, the curve revision, the srLP supply, and each vault's shares and debt;
  • each side's curve reserve reconciles within three raw atoms.

Any miss fails with BrokenInvariant. Swaps rebuild the endpoint, and so do compounded fees, oracle updates, hLP deposits and partial flash recoveries. A withdrawal burns a proportional slice instead.

Worked example

Take a constant-product SOL/USDC market at 150 USDC, with an ordinary tranche of UU = 10,000 SOL and VV = 1,500,000 USDC, an ordinary supply of 1,000,000 srLP, and vault equities EbE_b = 1,000 SOL and EqE_q = 150,000 USDC:

QuantityValue
Reserves XbX_b, XqX_q12,000 SOL and 1,800,000 USDC
Base vault's debt Dqh,∗D_q^{h,*}150,000 USDC
Quote vault's debt Dbh,∗D_b^{h,*}1,000 SOL
Shares sbs_b, sqs_q, SS100,000, 100,000 and 1,200,000 srLP
Base vault's claim, sb/Ss_b/S of the reserves1,000 SOL and 150,000 USDC

The base vault's claim includes exactly the 150,000 USDC it owes, so its holders keep 1,000 SOL of SOL exposure on 2,000 SOL worth of assets.

Leverage of a vault

Gross leverage of the base vault relative to its equity is

Lb=1+VUp,Lq=1+UpV\mathcal L_b = 1 + \frac{V}{U p},\qquad \mathcal L_q = 1 + \frac{U p}{V}

with pp the price of base in quote. It follows from the endpoint: the base vault holds its equity EbE_b in base plus a quote claim worth EbV/(Up)E_b V/(Up) in base. Both are exactly 2 at a balanced constant-product point and drift with the inventory weights on a concentrated curve away from the centre. The market's target_hlp_leverage_bps must be 20,000, and nothing else in the program reads it. The program rebuilds each vault to zero net exposure to the other token, and the leverage follows from the reserves.

Funding

Funding debt sits on the borrowed token's borrow index together with public and leverage debt, so it bears the full borrow rate, the protocol's markup included, and counts toward utilization. Its accrual leaves the reserves unchanged, since only cash-backed debt grows them.

Each rebuild settles what has accrued, the debt above its principal. The vault pays it from the srLP it holds: its debt shrinks, and only the protocol's share of the payment leaves reserve cash, since the LP part was credited to holders as it accrued. When that share would take cash a spot trader is due, or the last atom of either reserve, the swap is quoted again with the unpaid interest left on the vault's indexed debt, and that carried payment funds no recovery bonus. The vault's own leverage needs no cash: its borrowed leg is live reserve depth with no cash behind it, so a swap never waits for cash to rebuild a vault.

Funding interest is credited as it accrues. After the protocol's and the operator's shares, the LP part goes to Junior LP and the srLP held outside both vaults, through their interest indexes. Neither vault earns funding interest, its own or the other's.

Each vault's srLP also earns public interest. At accrual, the vault that borrows a token first nets its new public interest in that token against the funding interest it owes there, by burning debt shares, and credits only the rest to its holders' index. Netting moves neither the vault's principal nor the price, and it is skipped when reserve cash cannot cover its protocol share. Interest already credited to holders is never spent this way. A vault's value excludes the interest credited to its holders, so a withdrawal converts no coupon.

Between rebuilds, each checkpoint records the rebalance a vault would need as its residual exposure:

r=e(1+OT),e=O−Dr = e\left(1 + \frac{O}{T}\right), \qquad e = O - D

OO and TT are the values of its opposite and target holdings and DD the value of its debt, with the gross-up's magnitude rounded down. The checkpoint stores zero when rr is within the lesser of 0.00001 target tokens and a millionth of the vault's value. Any rebuild of an unfrozen vault resets it to zero.

Deposits and withdrawals

deposit_single_sided takes deposit_amount and min_hlp_amount. It needs a started market that is not reduce-only, no recorded interest deficit in either token (InterestDeficit), no flash recovery open on either vault (LiquidationSessionActive) and an unfrozen target vault (HlpSettlementUnavailable). The program credits the deposit net of any transfer fee, adds it to the target vault's equity, rebuilds the endpoint and mints

h=⌊Δ HN1−Δ⌋,Δ=min⁡(N1−N0, x)h = \left\lfloor \frac{\Delta\,H}{N_1 - \Delta} \right\rfloor, \qquad \Delta = \min(N_1 - N_0,\ x)

where N0N_0 and N1N_1 are the vault's value before and after, both at the price taken before the deposit, xx is the deposit's value and HH the supply before. The denominator is N0N_0 unless the deposit raises the vault's value by more than xx, as rounding in the rebuild can; the new hLP is then priced against the larger value, so the surplus stays with the existing holders. The first deposit into an empty vault mints one hLP per atom deposited. Rounding down, and the cap at xx, keep existing holders whole. A vault's value is its two srLP claims less its debt at the live curve price; a negative value fails with Undercollateralized.

After the rebuild, the deposit must also pass these checks:

  • wherever it raised a vault's funding principal, the borrowed token's reserve cash must cover all hLP funding debt in that token (InsufficientBorrowHeadroom);
  • every vault that already existed must end with its residual exposure inside the dust bound, or no worse than before if rounding already held it there (HlpSettlementUnavailable);
  • market health must hold, and the mint must reach min_hlp_amount (SlippageExceeded).

The cash check runs only on deposits. Swaps rebuild the vaults without it, so funding debt can later exceed the reserve's cash.

withdraw_single_sided takes hlp_amount and min_target_amount_out and needs only a started market, so it works in reduce-only. It is refused while a flash recovery holds the vault, and while the vault is frozen, since one holder could otherwise take its backing and leave the deficit to the rest. It burns a proportional slice, rounded down, of the vault's srLP and live legs. It also burns enough debt shares to repay at least the same fraction of the vault's debt, rounded up, so none of the leaving holder's debt stays with the others. The difference between the borrowed token it redeems and the debt it repays is settled on the curve. A surplus is sold for the target token, with the output rounded down; a shortfall is bought with the target token, with the input rounded up, and fails with HlpSettlementUnavailable when the target claim cannot cover it. An exit too small to buy back its share of the debt therefore fails. Market health must hold, and the minimum applies to what reaches the owner's account.

Recovery and closeout

Let DD be a vault's indexed funding debt and AA its claim on the borrowed token, its srLP share of that side's live reserve, both rounded down. With YY the revenue available for netting, the recovery gap is g=max⁡(D−Y−A,0)g = \max(D - Y - A, 0); the program passes Y=0Y = 0, so the bonus below comes from the vault's equity alone. Gaps under 25 basis points of AA are ignored; above that the market offers swaps that supply the borrowed asset a discount

d=min⁡ ⁣(0.05, 0.8 gA)d = \min\!\left(0.05,\ \frac{0.8\,g}{A}\right)

in whole basis points, which reaches the 5% cap once gg is 6.25% of AA. Previews and events also flag a vault as critical once D≥9A/8D \ge 9A/8; nothing else reads that flag.

Only spot swaps qualify, and only while the vault has supply, srLP and debt and no flash recovery is open. The whole input trades on the ordinary curve, and the discount is paid on top as extra target-asset output out of that vault's equity:

f=⌊min⁡(g, x)⋅UtVo⌋bonus=min⁡ ⁣(⌊f d1−d⌋, E)\begin{aligned} f &= \left\lfloor \min(g,\ x)\cdot\frac{U_t}{V_o} \right\rfloor \\ \text{bonus} &= \min\!\left(\left\lfloor \frac{f\,d}{1 - d} \right\rfloor,\ E\right) \end{aligned}

Here xx is the swap's input, Ut/VoU_t/V_o the ordinary reserves' ratio of target token to borrowed token, and EE the vault's equity. A frozen vault has no active equity and pays nothing. If the example's base vault came to owe 153,000 USDC against its 150,000 USDC claim, gg would be 3,000 USDC, 2% of AA, and dd would be 1.6%. A swap paying in 1,000 USDC is matched in full: ff is 6.666666666 SOL at the reserve ratio, and the trader receives 0.108401084 SOL on top of the curve's output.

Solvent gaps can also use preview_hlp_flash followed by atomic begin_hlp_flash and settle_hlp_flash, where the caller brings the fixed payment from any source and nothing has to trade through Dusk's curve. A vault qualifies when it is frozen or D>AD > A, with no 25 bps floor. The discount ceiling is the same dd, or 5% when AA is zero, priced at the symmetric average.

  • Full recovery, when the vault's holdings at the symmetric average are worth no more than DD: the buyer takes the vault's whole target claim and pays its value at the symmetric average less the discount, rounded up. Begin freezes the vault and settle closes it terminally.
  • Partial recovery otherwise: the payment is the largest of gg, the part of the protocol's share of unpaid interest that the reserve's cash cannot cover, and one atom if the vault is frozen. The collateral released is that payment at the symmetric average grossed up by the discount, rounded up, at the largest discount up to the ceiling that keeps the vault's value positive (HlpSettlementUnavailable if none does). Settle unfreezes a frozen vault and rebuilds the endpoint.

Begin must be a top-level instruction and names the later instruction that settles it. Settle must be that instruction, in the same slot, with the hLP supply unchanged (InvalidLiquidationSession), and the payment must arrive in full (InsufficientAmount). While a session is open, deposits into either vault and withdrawals from the recovering one fail with LiquidationSessionActive.

close_insolvent_hlp closes a vault once

D≥A+Tc pˉD \ge A + T_c\,\bar p

where TcT_c is its claim on the target token and pˉ\bar p the symmetric average refreshed to the current slot; the live curve price plays no part. The close values recovery as AA plus the target claim sold on the curve rebuilt at the symmetric average and depth average with full fees, the quote the internal unwind uses. Recovery repays principal first, then interest. Principal still unpaid is written off, junior first and then senior, and may not exceed the caller's max_socialized_loss (LiquidationSocializationExceeded). Interest the recovery cannot pay is written off too; its LP and operator part was already credited, so it is a pool loss absorbed the same way. The vault's srLP is burned and the vault zeroed.

The caller earns 0.5% of the interest paid, rounded down and checked against min_caller_bounty_out. It is paid from pool cash and counted in the loss, junior first. The close skips the market health floor, so a fee change on either mint cannot strand the debt. A full flash recovery reaches the same end at settle, re-checking insolvency against the claims fixed when it began, and pays no bounty.

Yield already credited to holders stays claimable, and holders can still burn the emptied receipts. Lifecycles covers freezing and replacement.

Parameters

TermValue
Recovery threshold25 bps of AA
Recovery discount0.8 g/A0.8\,g/A, at most 5%
Critical flagD≥9A/8D \ge 9A/8, reported only
Terminal caller bounty0.5% of the interest paid
Residual dustThe lesser of 0.00001 target tokens and a millionth of the vault's value
Rebuild toleranceOne raw atom on debt, three per side on reserves
Funding average half-life12 hours

All of these are program constants, and no creator or operator setting changes them.