Overview
Your contract on Elysium calls sendRawAction(bytes) on the KeeperLane contract, with the same bytes HyperEVM's CoreWriter takes. The lane checks the limits the account owner set, then emits an Intent event.
The keeper reads the event, signs the order as the account's trade-only agent and sends it to HyperCore. HyperCore's answer is written back on Elysium with deliver, which can call your contract.
Kinetiq has announced its own keeper lane for an upgrade after mainnet. Code written for Onbook uses the same encoding, so it keeps working when the native lane ships.
Quick start
Import CoreActions, build the order and hand it to the lane. Prices and sizes are scaled by 1e8.
The account that trades is the caller by default. A contract that trades for several accounts uses sendRawActionFor(account, data), and each account must grant it first.
CoreWriter encoding
Byte 0 is the version (1). Bytes 1 to 3 are the action id. The rest is abi.encode of the parameters.
| Action | Id | Parameters |
|---|---|---|
| Limit order | 1 | uint32 asset, bool isBuy, uint64 limitPx, uint64 sz, bool reduceOnly, uint8 tif, uint128 cloid |
| Cancel by order id | 10 | uint32 asset, uint64 oid |
| Cancel by client id | 11 | uint32 asset, uint128 cloid |
tif: 1 add liquidity only, 2 good till cancelled, 3 immediate or cancel.asset: a perp's index in Hyperliquid's universe, or 10000 plus the index for spot.cloid: your own 16-byte id. With 0, the keeper derives one from the lane and the nonce, so an order is never sent twice.- Every other action id is refused by the lane.
Prices follow Hyperliquid's rules: at most 5 significant figures, and at most 6 minus the market's size decimals after the point (8 on spot). Sizes take at most the market's size decimals. The keeper refuses an order that breaks a rule. It never rounds it, because that would change what your contract asked for.
Limits
Each account decides which contracts may trade for it, and how much. Limits live in the lane, so anyone can read them.
grantBySig takes the same grant signed off-chain (EIP-712, domain "KeeperLane", version 1), so an account with no HYPE on Elysium can start: the keeper pays the gas.
Results
The registrar writes HyperCore's answer back with deliver(nonce, status, oid, filledSz, avgPx). If the sending contract implements ICoreResultReceiver, the lane calls it, paid from HYPE the contract deposited with deposit(sender).
| Status | Meaning |
|---|---|
| 2 | Resting on the book |
| 3 | Filled |
| 4 | Partly filled (the keeper keeps following it) |
| 5 | Refused by HyperCore or by the keeper's price rules |
| 6 | Cancelled |
The agent
Each account gets its own Hyperliquid API agent, generated by the keeper. The account approves it once, with approveAgent signed in its wallet. HyperCore lets an agent place and cancel orders, and never lets it withdraw or transfer. Revoke it on Hyperliquid at any time.
Public API
No key, CORS open, JSON. Try every route live in the builder hub.
| Route | Returns |
|---|---|
GET /api/v1/markets | Every live perp: asset id, size decimals, max price decimals, live prices |
GET /api/v1/markets/:coin | One market |
GET /api/v1/encode | The exact bytes for sendRawAction, refused rather than rounded if a rule is broken |
GET /api/v1/lane | Chain, addresses, owner, keeper, fee, pause state, Kinetiq's native lane, read live |
GET /api/v1/stats | From the keeper: latency p50 p90 p99, success rate, filled volume, days ahead |
GET /api/v1/intents | From the keeper: latest intents and their results |
GET /api/v1/intents/:nonce | From the keeper: one intent |
GET /api/v1/health | From the keeper: network, registrar, dry run or live |
The keeper also takes POST /v1/agents (issues the trade-only agent for an account) and POST /v1/grant (relays a signed grant and pays its gas).
Run your own keeper
Name your own registrar with setRegistrar(address). From then on, only that address can deliver results for your account, and the lane does not depend on Onbook. The keeper is a small Node service: it reads intents, signs with your agents and writes results back.
The code is open (MIT): github.com/351Origin/onbook. Clone it, copy keeper/.env.example to .env, fill in your keeper wallet and an agent secret, then run npx tsx --env-file=.env src/main.ts. It starts read-only: set KEEPER_LIVE=true when you are ready to trade.
Addresses
| Contract | Elysium mainnet (99901) |
|---|---|
| KeeperLane | 0xfaF3501406e6694e929e3B8c46695DDD56904E9D |
| Playground | 0x6F43BF56c6ef654631e8839846115549Dbe7c272 |
| Kinetiq's native lane | 0x3333333333333333333333333333333333333333 (empty until their upgrade) |
