Engine
Paper & live modes
Paper mode trades real markets with simulated fills. Live mode moves real money and needs an explicit opt-in.
The engine has two execution modes, set by EXECUTION_MODE. Paper is the default, and it is what the deployment blueprint uses.
Paper mode
Real market data, simulated fills, no keys, no money. Every fill is stored with paper = true.
How HyperCore fills are simulated
- Quotes rest in memory. A quote that would cross the current best bid or ask is rejected, like Hyperliquid's post-only (
Alo) orders. - An existing quote is kept if its side, level and price are unchanged and its remaining size is within 10 %; otherwise it is cancelled and replaced.
- Every real trade on Hyperliquid's tape is matched against our quotes. A sell print at or below our bid, or a buy print at or above our ask, fills us. Best-priced orders fill first.
- A print through our price can fill us for its whole size. A print exactly at our price fills only 25 % of its size (
QUEUE_SHARE), because we would be behind others in the queue. - Sizes are rounded down to the market's size decimals. Spot buys need enough USDC (plus 0.1 %), spot sells need the tokens; perps skip this check.
- Fees use Hyperliquid's base tier: perp maker 1.5 bps, taker 4.5 bps; spot maker 4 bps, taker 7 bps.
- Immediate-or-cancel orders (used by the hedge) walk the real book level by level up to their limit price and pay the taker fee.
How Montra fills are simulated
Every pool swap is priced by Montra's own on-chain quoter (quoteExactInputSingle) against the live pool. If the quote is below the trade's minOut, the swap fails with a slippage error, as it would on chain. The pool fee comes from Montra's metadata (totalFeePips, 1 % if missing).
Paper treasury
On first start the engine seeds a pretend treasury of PAPER_CAPITAL_USD (default $25,000) at current prices: 35 % HYPE on Elysium, 40 % USDC, 15 % HYPE and 10 % KNTQ on HyperCore. PAPER_RESET=true wipes it on the next start (set it back to false afterwards). The kill switch and strategy pauses survive a reset.
Live mode
Live mode trades the protocol's real money. The engine refuses to start unless all of these are set:
| Variable | Value |
|---|---|
EXECUTION_MODE | live |
CONFIRM_LIVE | exactly yes |
OPERATOR_KEY | the Treasury keeper's private key (OPERATOR_ROLE) |
HL_ACCOUNT | the protocol's HyperCore account address |
HL_AGENT_KEY | a Hyperliquid API wallet approved by that account |
Otherwise it exits with EXECUTION_MODE=live needs <list>. Live mode trades the protocol's real money. Montra trading also needs SWAP_ADAPTER_ADDRESS (the deployed adapter).
What changes in live mode
- HyperCore: orders are signed by the API wallet. On start the engine cancels any of its own orders left on the account. Quotes are post-only (
Alo), hedges immediate-or-cancel (Ioc). - Fills are read back from Hyperliquid every 3 s (
userFillsByTime), deduplicated and attributed to the strategy that placed the order. - Montra: the keeper simulates, then sends
Treasury.execute(adapter, value, data)with a 120 s deadline, and waits for the receipt. The amounts booked are the measured change in the Treasury's balances. - Balances come from the venues every 15 s: the Treasury's HYPE, USDC and WHYPE (and MOTION once set), HyperCore spot balances, and the perp position. "The venues are the truth for balances; fills only attribute P&L."
- Funding arrives in the account itself, so the engine does not book it separately.
Danger
Do not switch to live mode from this page alone. Follow the going-live checklist: the Treasury admin must be a Safe, the adapter deployed and allow-listed, and paper mode run for a while with the real token.