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 for the vaults' target-asset equities and for the ordinary tranche, the canonical endpoint after any trade is
is the base the quote vault owes, and 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 :
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 ; 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 = 10,000 SOL and = 1,500,000 USDC, an ordinary supply of 1,000,000 srLP, and vault equities = 1,000 SOL and = 150,000 USDC:
| Quantity | Value |
|---|---|
| Reserves , | 12,000 SOL and 1,800,000 USDC |
| Base vault's debt | 150,000 USDC |
| Quote vault's debt | 1,000 SOL |
| Shares , , | 100,000, 100,000 and 1,200,000 srLP |
| Base vault's claim, of the reserves | 1,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
with the price of base in quote. It follows from the endpoint: the base vault holds its equity in base plus a quote claim worth 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:
and are the values of its opposite and target holdings and the value of its debt, with the gross-up's magnitude rounded down. The checkpoint stores zero when 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
where and are the vault's value before and after, both at the price taken before the deposit, is the deposit's value and the supply before. The denominator is unless the deposit raises the vault's value by more than , 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 , 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 be a vault's indexed funding debt and its claim on the borrowed token, its srLP share of that side's live reserve, both rounded down. With the revenue available for netting, the recovery gap is ; the program passes , so the bonus below comes from the vault's equity alone. Gaps under 25 basis points of are ignored; above that the market offers swaps that supply the borrowed asset a discount
in whole basis points, which reaches the 5% cap once is 6.25% of . Previews and events also flag a vault as critical once ; 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:
Here is the swap's input, the ordinary reserves' ratio of target token to borrowed token, and 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, would be 3,000 USDC, 2% of , and would be 1.6%. A swap paying in 1,000 USDC is matched in full: 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 , with no 25 bps floor. The discount ceiling is the same , or 5% when is zero, priced at the symmetric average.
- Full recovery, when the vault's holdings at the symmetric average are worth no more than : 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 , 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 (
HlpSettlementUnavailableif 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
where is its claim on the target token and the symmetric average refreshed to the current slot; the live curve price plays no part. The close values recovery as 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
| Term | Value |
|---|---|
| Recovery threshold | 25 bps of |
| Recovery discount | , at most 5% |
| Critical flag | , reported only |
| Terminal caller bounty | 0.5% of the interest paid |
| Residual dust | The lesser of 0.00001 target tokens and a millionth of the vault's value |
| Rebuild tolerance | One raw atom on debt, three per side on reserves |
| Funding average half-life | 12 hours |
All of these are program constants, and no creator or operator setting changes them.