Hedging
How the vault tracks users' net position on HyperCore and manages its HyperCore margin.
Users trade against the vault, so the vault takes the other side of their net
position. To stay neutral, it holds a matching perpetual position on HyperCore
and sends orders through CoreWriter to keep it in line. The HyperCore position
size, szi, is always read from the precompile and never tracked locally.
The gap between what users hold and what the vault has hedged is:
gap = internalNetSize − sziFills change internalNetSize immediately. Hedge orders change szi from the
next block. The unhedged cap keeps the gap, valued at the mark, at or below
maxUnhedgedUsdc for any open that adds risk.
hedge()
Anyone can call hedge(). It runs at most once every HEDGE_COOLDOWN
(2 seconds).
Read
Read szi from HyperCore and compute the gap.
Order
If the gap is at least $10, send one IOC order for the smaller of the gap and $250,000 of notional, with a limit price within 0.5% of the mark.
Reduce only
The order is reduce-only when it does not flip the HyperCore position, so it can never open exposure in the wrong direction.
An IOC fills what it can and cancels the rest. A missed or partial fill leaves a
smaller gap, which the next hedge() retries. Nothing rests on the book, so
there is no order state to track or cancel.
HyperCore margin
The vault's HyperCore account backs only the single net hedge. CoreWriter has no action to change leverage or margin mode, so the vault manages margin by moving USDC. These functions are permissionless.
| Function | Effect |
|---|---|
fundCorePerp() | Tops HyperCore account value up to the required margin. Uses free HyperCore spot USDC first and bridges only the rest from HyperEVM |
rebalanceCoreMargin() | Moves account value above the required margin plus a $10 band back to HyperCore spot, capped at HyperCore's withdrawable |
bridgeSpotUsdcToEvm() | Bridges at least $10 of free HyperCore spot USDC back to HyperEVM, so claims can be paid |
fundCoreHype() | Sends HYPE to the HyperCore account for gas |
The required margin is computed from the larger of the hedge and the book, so margin can be funded before the first hedge:
required = max(|szi|, |internalNetSize|) × mark / 3 + $10It is compared with HyperCore account value, the total perp equity including margin in use, not with free margin.
Once per block
fundCorePerp and rebalanceCoreMargin run at most once per block between
them. HyperCore balances only reflect a transfer from the next block, so a
second move in the same block would act on a stale balance.
Batch reads
execute reads the mark once per batch, and reads protocol equity and szi
once, at the first open that reaches the risk checks. The vault's own orders
settle in the next block, so szi does not change within the batch.
Continue with parameters for the hedge constants, or risks and privacy for what happens when HyperCore misbehaves.