A liquidity position is long the token it holds, whether you want that exposure or not. HedgedLPVault is an LPVault paired with a short perp on Hyperliquid, sized to the position's delta, so you keep the fee income and shed most of the price risk. The short lives on a venue Elysium cannot read, so the vault takes the hedge's value from reports sent by one key. This chapter covers what that key can and cannot do, how reports are checked, and where the margin lives: in a Hyperliquid account owned by the vault's funder key.
- Open, with no deposit cap. Elyra's hedged vaults sit on EQX stock pools, each hedged with the stock's HIP-3 market on Hyperliquid: EQNVDA with
xyz:NVDA, EQSPY withxyz:SP500. - The short runs on a Hyperliquid account owned by the vault's funder key, an ordinary wallet key the operator holds offline, because a contract cannot own a Hyperliquid account that trades. Whoever holds that key can withdraw the margin there.
- Two keys with separate jobs. The hot hedger key can only report; the cold funder key moves margin out, as a USDC transfer to its own address, at most
10 %of the vault's on-chain assets per call, out of an allowance of25 %that refills over a day. Each hedged vault has its own funder, and the funder can replace the hedger key (setHedger). - The hedger's figure is believed only within
15 %an hour of an anchor and up to three times the margin ever funded, reports are at least five minutes apart, and a larger move is walked in at that rate. Exits stay open and count the hedge at the lower of the reported and believed figure, and at zero when the last report is older than1 h; deposits wait until the two agree and the report is fresh. - Margin on its way between the vault and Hyperliquid still counts:
fundHedgeandreturnHedgemove the stored equity in the same transaction, and the hedger reports the USDC still travelling, so the share price does not dip while margin crosses the bridge. - An exit larger than the vault's on-chain holdings reverts until the funder brings margin back with
returnHedge.
How the hedge is counted
On chain, the hedge is a few numbers. hedgeCollateralUsd() is the USDC the vault has ever sent out as margin. hedgeState() gives the last report as said (reportedEquityUsd) and the figure the vault believes (equityUsd, 6 decimals like USDC); both carry the USDC funded and returned since (see Margin in transit). The share price adds the lower of the two to the plain vault's figure:
totalAssets() = LP position + idle balances (as in LPVault)
+ min(equityUsd, reportedEquityUsd) in the vault's asset
When the vault's asset is not USDC, the equity is converted through Elyra's keeper-updated HYPE/USD feed. If the feed reverts, answers zero or less, or is older than 1 h (FeedGuard.MAX_FEED_AGE; the keeper pushes it at least every 15 minutes), the hedge counts as zero rather than reverting, and deposits wait. Reverting would freeze withdrawals during a feed outage; under-counting only makes exits cheaper for whoever leaves then.
Two keys, two jobs
| Key | What it can do | What it cannot do |
|---|---|---|
| Hedger (hot, on the API server) | Call reportHedge | Move any funds |
| Funder (cold, operator-held, one per vault) | Call fundHedge, within its caps, and returnHedge. Own the vault's Hyperliquid account, so withdraw the margin there | Make the vault pay any address but its own |
| Signer's agent wallet for the funder's account | Open, close and resize the perp in that account | Withdraw or transfer from the account |
initializeHedged reverts BadFunder if the funder is unset or is the hedger. The agent wallet lives in the signer; the funder approves it once for its Hyperliquid account.
Where the margin lives
A Hyperliquid account is an address, and only that address's key can approve an agent wallet or withdraw. A vault contract has no key, so it could never trade an account of its own. fundHedge therefore sends the margin to the vault's funder instead, and the funder's Hyperliquid account is the vault's hedge account: the signer holds an agent wallet for it, the hedger trades and reports it, and fundingConfig().funderKey names it on chain.
Whoever holds the funder key can withdraw the margin on Hyperliquid. What bounds it is on chain: the funder can take at most 10 % of the vault's on-chain assets per call, out of an allowance of 25 % that refills linearly over a day (so no burst moves more than 25 %, and no day more than twice that), measured against the position and idle balance, never against reported equity. The funder key is cold, held by the operator and used for that vault alone.
Hyperliquid accounts are one per address, so one account shared by two vaults would mix their equity and net their shorts. Each hedged vault therefore gets its own funder, the deploy refuses a funder that is the deployer, the owner, the hedger or the keeper, or that two vaults share, and the hedger skips any two vaults that resolve to the same account. The manifest records them under funders.
Funding the hedge
fundHedge(assetAmount) turns vault assets into USDC margin at the funder's address. Only the funder calls it; nothing in the API does.
- 01Refuse while deposits wait
EquityJumpwhile the reported and believed figures differ,HedgePaused_on a stale report or a silent feed, so the caller can tell them apart. - 02Check the capsAt most
maxFundBpsPerCallof the on-chain assets (LP position plus idle balance) per call, out of an allowance ofmaxFundBpsPerPeriodthat refills linearly over a day. Both are measured against on-chain value, never the reported equity. Over either revertsFundCapExceeded. - 03Free the assetIf the idle balance is short, the vault pulls it from the LP position as a withdrawal would, with that swap floored at the LP pool's spot quote less
maxSlippageBps. - 04Swap at a TWAP floorWhen the asset is not USDC,
HedgeFundingrunsTwapGuard.checkon the asset/USDC pool and sells with a floor of the TWAP quote lessmaxSlippageBps. - 05Transfer to the funderThe USDC goes to the funder's address on Elysium, the only recipient the function knows. From there the funder bridges it to HyperEVM and into the vault's Hyperliquid account.
- 06Count it at onceThe USDC delivered is added to
hedgeCollateralUsdand to the stored equity, the crossing time is recorded, andHedgeFundedis emitted. The share price loses the swap's cost and nothing else.
Bringing margin back
The funder withdraws USDC from Hyperliquid with its own key (Elyra's agent wallet cannot), brings it back to Elysium, approves the vault for it and calls returnHedge(stableAmount). It works in every state, deposits waiting or not, because bringing margin home is the emergency procedure. The vault takes the USDC, sells it for its asset behind the same TWAP floor as the funding swap when the asset is not USDC, keeps it as idle asset and lowers the stored equity by the same USDC, all in one transaction. The share price moves by the swap's cost only, and the next report, which no longer sees that USDC anywhere, matches what the vault already stores.
Never transfer USDC straight to a vault whose asset is not USDC: totalAssets() does not count it, and no function can move it again. Use returnHedge.
Margin in transit
Margin takes time to cross either way: a withdrawal from Elysium to HyperEVM takes about 24 hours before the funder can move it into Hyperliquid. If only the Hyperliquid account counted, the share price would dip by up to a tenth while margin travelled, and anyone could deposit in the dip and redeem after the next report, taking the difference from the other holders. So the margin is counted wherever it is:
- The two crossings the chain sees move the stored equity in the same transaction, in the units reports use:
fundHedgeadds the USDC it delivered,returnHedgetakes off the USDC it received. A report dated at or before the last crossing revertsStaleReport, because it was read before the crossing and would undo it. - Everything in between is the hedger's. The report is the Hyperliquid account's equity, plus the funder's USDC that is still on its way: in the funder's wallet on Elysium, in the bridge, and on HyperEVM at the funder's address. The funder wallet belongs to its vault by construction: one per vault, used for nothing else.
- When pieces move during a read, they are counted twice rather than not at all. The hedger reads the travelling margin before the Hyperliquid account and the chain last, so a transfer that lands mid-read appears in two places for one report. That makes the reported figure briefly high, which the band and the deposit gate keep anyone from buying against; never low, which is the sandwich. A piece that cannot be read at all stops the report: the last one stands, and after
1 hdeposits wait and exits count the hedge at zero.
Onboarding the hedge account
The funder's Hyperliquid account trades once it holds USDC and the funder has approved the signer's agent wallet for it, with the same onboard and approval steps the web makes, signed by the funder key. Until that is done the hedger skips the vault with an alert, and the app takes no deposits into a hedged vault that has never been reported on.
The hedger bot
The hedger runs inside the API process when BOTS includes it, once every HEDGER_INTERVAL_MS (30 s). It works on every manifest vault whose name contains "Hedged", plus any address in HEDGED_VAULTS.
For each vault, one tick does this:
- Read the position:
positionTokenId(),pool()andasset()on the vault, thenpositions(tokenId)andslot0(). A vault without liquidity is skipped. - Size the target short: the vault's asset is the numeraire, and the other pool token, the EQX stock, is the risk asset, whichever side of the pair it sorts to. Core's
lpDeltareturns the position's current balance of the risk asset; shorting that much cancels the price exposure for now, and the balance changes as the price moves, so the bot re-sizes. - Find the current short on the vault's hedge account,
fundingConfig().funderKey. The market comes fromVAULT_MARKETSor the HIP-3 market for the stock (xyz:SP500for EQSPY). A long position counts as zero; the bot never opens longs. An account with no agent wallet approved is skipped with thehedger.account_not_onboardedalert: no order and no report. - Decide: drift is the gap between target and current short, in bps of the target. The tick acts if a report is due (
HEDGE_REPORT_INTERVAL_MS,15 min) or drift exceedsHEDGE_DRIFT_BPS(200); otherwise it does nothing. - Trade: core's
hedgeOrdersreturns at most one market order. It skips differences underHEDGE_MIN_NOTIONAL_USD($50at the mark) and rounds down to the market's size precision. Sells grow the short; buys shrink it and are alwaysreduceOnly, so the account cannot flip long by accident. - Report: it reads the hedge account back and sends
reportHedgewith signed notional (negative for a short), summed pnl, the account's equity plus the margin in transit, floored at zero, and its own clock less10 sasasOf, taken before the first read. Reporting pays no bounty; it is sent whenever the simulation passes.
Three rails sit on top of the tick. HEDGER_MODE is the kill switch: report-only places no order but keeps reporting, and off does nothing, so after 1 h deposits wait and exits count the hedge at zero. HEDGE_MAX_ORDER_USD ($25,000, at most the signer's MAX_ORDER_NOTIONAL_USD) splits a large re-hedge into one order per tick. HEDGE_DAILY_LOSS_USD ($2,500) stops orders for the rest of the UTC day once the hedges have lost that much, net of margin moved in or out; reports continue. A per-vault ceiling on the short, HEDGE_MAX_NOTIONAL_USD, is off by default, so a vault is hedged in full whatever its size. The vault takes one report every five minutes, so a report that would follow an order sooner waits for the next tick past it.
On the vault card, the delta chip shows the residual exposure: (LP value + notional) / LP value, green at 5 % or less. Until the exposure reaches the hedger's minimum order, the card shows "Not hedged yet" with the exposure and the minimum.
When deposits wait
reportHedge has three reverts and never rejects a number: NotHedger for any other caller, StaleReport for an asOf in the future, not after the previous report, or not after the last fundHedge/returnHedge, and ReportTooSoon within five minutes (block time) of the previous report. It is also nonReentrant, so a report can never land in the middle of a deposit, withdrawal or funding. Every other report is stored as said and emits HedgeReported, because hiding a real loss would be worse than showing it; the vault then decides how much of it to believe.
The believed figure follows the reports inside a band around an hourly anchor:
anchor = the believed equity at the first report of each hour (crossings move it too)
believed = reported, clamped to anchor × (1 ± maxEquityJumpBps), and to
3 × USDC ever funded − USDC ever returned
exits = min(believed, reported), or 0 when now − lastReportAt > maxHedgeAge or the feed is silent
paused() = believed ≠ reported, or the report is stale, or the feed is silent (deposits wait)
A report beyond the band is believed up to its edge, and the next hour's anchor starts there, so a larger move is walked in at 15 % an hour: a 40 % drop is believed in full three hours after it is reported, a doubling four hours after. Across one hour boundary two bands can follow each other within minutes, so the worst case is about 32 % in a few minutes and 15 % an hour after that. Around a zero anchor nothing above zero is believed: margin arrives through fundHedge, never through a report, and a vault that never received margin believes nothing at all. A first report is checked against the margin funded before it. An Income note runs the same code for its sleeve, with the band measured on the anchor plus the note's collateral and a ceiling of half that collateral, since its collateral never leaves the note.
A drop to zero (a liquidation) counts for exits at once but is never reached by the walk, so the funder, who can see the account, calls acceptReport(): the believed figure and the anchor move down to the reported one. It only ever lowers the figure, since the funder already holds the margin that left the chain. HedgePaused("jump") (or "ceiling") marks the two figures parting and HedgeResumed their meeting again; staleness needs no transaction. A vault that was never reported on is not stale.
While paused() is true, _deposit reverts HedgePaused_: the vault cannot say what a share is worth, and a deposit at the lower figure would buy below value. Withdrawals never wait on it; they value the hedge conservatively instead, so a stale or broken hedge cannot freeze anyone in and cannot be inflated on the way out. A paused hedged vault also stops the deposits of a Protected note that holds a slice of it, not its exits. The vault card's status chip says "Deposits paused: stale report", "Deposits paused: equity jump" or "Deposits paused: price feed".
Limits
Exits are bounded by on-chain holdings. The hedge equity sits in a Hyperliquid account the vault cannot unwind, so a withdrawal is sized against the LP position and idle balance alone. While a large part of the value is in the hedge, an exit bigger than the on-chain holdings reverts Shortfall until the funder returns margin with returnHedge, which takes at least the bridge's time.
The bounds are a rate, not a verdict. A dishonest or broken reporter can still move the believed figure by 15 % an hour, up to three times the margin funded, and exits pay at that figure. What the contract buys is time: hours, not one block, for the operator to compare the on-chain figure with the Hyperliquid account (public) and rotate the hedger with setHedger.
The margin is in the operator's account. The contract bounds how much can leave for Hyperliquid, not what happens to it there: a lost, stolen or misused funder key, or a failure on the bridge or on Hyperliquid, can cost the vault the margin outside it: up to a quarter of its on-chain assets at once, and no more than half in a day, as the allowance refills.
Reference
Settings
| Name | Allowed | Default | Effect |
|---|---|---|---|
base | LPVault.Init | No default | Everything a plain vault needs. |
hedger | address | env HEDGER | The only caller of reportHedge. |
funder | address, not the hedger | one per vault | The only caller of fundHedge and returnHedge, the only recipient of margin, and the owner of the vault's Hyperliquid account. |
maxFundBpsPerCall | 1 - maxFundBpsPerPeriod bps | 1000 | Largest single funding, as a share of on-chain assets. |
maxFundBpsPerPeriod | up to 10 000 bps | 2500 | The funding allowance, refilling linearly over a day. |
usdc / usdcPool | token / asset-USDC pool | No default | Margin token and the pool fundHedge sells through when the asset is not USDC. |
price feed | Elyra's HYPE/USD feed | No default | Converts equityUsd into the asset. Required: initializeHedged reverts NoFeed without one. |
maxHedgeAge | uint32 seconds | 1 h | Report age after which exits count the hedge at zero and deposits wait. |
maxEquityJumpBps | uint16 bps | 1500 | The band around each hour's anchor the believed equity moves in. |
hedgeConfig() returns a vault's staleness bound, band, report window (1 h) and report spacing (5 min) and its addresses; fundingConfig() returns the funder, its caps and the allowance in use. The hedged vaults Elyra deploys are named in the deployment manifest, with the plain vaults' policy and no deposit cap (NO_CAP).
Reverts and events
| Revert | Raised by | Meaning |
|---|---|---|
NotHedger | reportHedge | The caller is not the hedger. |
NotFunder | fundHedge, returnHedge | The caller is not the funder. |
FundCapExceeded | fundHedge | Over the per-call cap or the allowance in use. |
TwapWindowTooShort / PriceDeviation | fundHedge, returnHedge (TwapGuard) | The asset/USDC pool has under ten minutes of history, or spot is off its TWAP. |
EquityJump / HedgePaused_ | fundHedge | The reported and believed figures differ, or the report is stale or the feed silent. |
HedgePaused_ | deposit | paused() is true. Withdrawals never raise it. |
CapExceeded | deposit, mint | Over the cap. Elyra's hedged vaults have none. |
StaleReport | reportHedge | asOf is in the future, not after the last report, or not after the last fundHedge/returnHedge. |
Shortfall | withdraw | The exit needs more than the on-chain holdings can raise. |
NotAsset, BadFunder, BadFundCap, NoFeed | initializeHedged | Wrong asset or pool, a bad funder, caps that are zero, unordered or above 100 %, or no price feed. |
The plain vault's reverts also apply; see Vaults. Also ReportTooSoon (reportHedge within five minutes), NothingToAccept (acceptReport with nothing lower to believe) and BadHedger (setHedger to zero or the funder). Events: HedgeFunded, HedgeReturned, HedgeReported(notionalUsd, unrealizedPnlUsd, equityUsd, asOf) with the figure as said, HedgeBelieved(equityUsd, anchorUsd) with the figure believed, HedgePaused(reason) when the two part, HedgeResumed() when they meet, and HedgerSet(hedger).
Elyra