The precompiles, price scales, CoreWriter encoding, action whitelist, account activation and rate limits that Counterbook depends on.
This page collects the HyperCore details the contracts rely on, with their sources. Hyperliquid's own documentation is authoritative: see Interacting with HyperCore. Counterbook's encoders and readers were checked against it and against hyper-evm-lib.
Read precompiles are system addresses on HyperEVM that return HyperCore state as of the moment the EVM block was built. Their input is the raw abi.encode of the arguments, with no 4-byte selector. The same addresses work on mainnet (999) and testnet (998).
| Address | Read | Input | Output | Gas | Counterbook uses it for |
|---|---|---|---|---|---|
0x…0801 | Spot balance | (address user, uint64 token) | (uint64 total, uint64 hold, uint64 entryNtl) | 12,400 | HyperCore leg of NAV; inferring order state from hold |
0x…0807 | Perp oracle price | (uint32 perpIndex) | uint64 | 6,160 | Basis check |
0x…0808 | Spot price | (uint32 spotIndex) | uint64 | 6,160 | Cross-check in the SDK and the app |
0x…080e | Best bid and offer | (uint32 asset) | (uint64 bid, uint64 ask) | 8,240 | Reference price and spread |
0x…0810 | Core user exists | (address user) | bool | 6,160 | Activation check before any order |
Full addresses are 0x0000000000000000000000000000000000000801 and so on. The BBO precompile takes the spot asset id, 10000 plus the spot index (10107 for HYPE/USDC on mainnet).
Gas. Hyperliquid documents the cost of a precompile call as
with lengths in bytes. Every ABI word is 32 bytes, so the BBO read costs .
Failure. A precompile called with invalid input returns an error and consumes all gas passed into the call frame. Counterbook's HyperCoreReader therefore:
READ_GAS of 30,000 to each read;| Value | Scale | HYPE (spot and perp szDecimals = 2) | Example, 2026-11-28 |
|---|---|---|---|
Spot price and BBO (0x808, 0x80e) | bid 62,844,000 = 62.844 | ||
Perp oracle (0x807) | 628,535 = 62.8535 | ||
CoreWriter limitPx and sz | 62.845 = 6,284,500,000 | ||
Spot balances (0x801) | HYPE in EVM units = total × ; USDC in EVM units = total / 100 |
The perp's size decimals can differ from the spot token's, so the contracts take them separately: MandateConfig.szDecimalsPerp scales the oracle price, and szDecimalsBase the spot price.
To a Uniswap v4 price. The pool's raw price is token1 base units per token0 base unit. From the BBO mid in spot units:
For HYPE/USDC the exponent is , so the contracts compute (FeeMath.refSqrtPriceX96).
Tick and lot rules for spot orders (Hyperliquid, "Tick and lot size"; enforced by PxRules):
CoreWriter is a system contract at 0x3333333333333333333333333333333333333333 with one function, sendRawAction(bytes). It burns about 25,000 gas before emitting a log that HyperCore processes as an action; a basic call costs about 47,000 gas in practice. HyperCore attributes the action to the address that called CoreWriter.
| Bytes | Content |
|---|---|
| 0 | Encoding version. Only 0x01 is supported. |
| 1 to 3 | Action id, a big-endian uint24 |
| 4 onward | abi.encode of the action's fields |
// Action 1, limit order. limitPx and sz are 1e8 x the human value.
bytes memory data = bytes.concat(
bytes1(0x01), // version
bytes3(uint24(1)), // action id
abi.encode(asset, isBuy, limitPx, sz, reduceOnly, tif, cloid)
);
ICoreWriter(0x3333333333333333333333333333333333333333).sendRawAction(data);Time in force is encoded as 1 for ALO (add liquidity only), 2 for GTC and 3 for IOC. Hyperliquid delays order actions and vault transfers sent from CoreWriter on-chain for a few seconds, so that HyperEVM cannot be used to bypass the HyperCore mempool.
The CoreAgent has encoders for three actions and no generic passthrough. Only the hook and the vault, both immutable, can call it.
| Id | Action | Fields | CoreAgent constraints |
|---|---|---|---|
| 1 | Limit order | (uint32 asset, bool isBuy, uint64 limitPx, uint64 sz, bool reduceOnly, uint8 tif, uint128 cloid) | Asset is the mandate's spot asset. reduceOnly is false. Time in force is ALO or IOC. Price is on a valid tick and within maxOrderDeviation of the live BBO mid. Size is a whole lot. Notional is at least 10 USDC. Free HyperCore balance covers it; a sell must also leave the HYPE transfer reserve (coreHypeReserveWei) untouched. cloid is non-zero. |
| 11 | Cancel by cloid | (uint32 asset, uint128 cloid) | Asset is the mandate's spot asset |
| 13 | Send asset | (address destination, address subAccount, uint32 sourceDex, uint32 destinationDex, uint64 token, uint64 wei) | Destination is the system address of one of the two mandate tokens, subAccount is zero, both dexes are spot (type(uint32).max) and the token is one of the two mandate tokens. HyperCore credits the CoreAgent's own address on HyperEVM. Vault only. |
No code path exists for any other action. These matter most:
| Id | Action | Why it is excluded |
|---|---|---|
| 2 | Vault transfer | Would move funds into a Hyperliquid vault |
| 3, 4, 5 | Token delegate, staking deposit, staking withdraw | Not part of the mandate; would lock funds |
| 7 | USD class transfer | Would move USDC between spot and perp balances |
| 9 | Add API wallet | Would give an off-chain key trading control of the account |
| 12 | Approve builder fee | Would let a third party charge fees on the account's orders |
| 6 | Spot send | Transfers use the constrained form of action 13 instead |
| 13 | Send asset (any other form) | Any destination other than a mandate token's system address, a sub-account, or a non-spot dex would allow transfers out of the vault |
| 15 | Borrow and lend | Lending idle float is Planned (v1), behind its own bounds |
Actions 8 (finalize EVM contract), 10 (cancel by oid), 16 (set abstraction) and 17 (outcome operation) are not reachable either.
HyperCore to HyperEVM transfers
Following Hyperliquid's transfer documentation and hyper-evm-lib's bridgeToEvm, the CoreAgent returns tokens with action 13 (send asset) to the token's system address. A transfer of a non-HYPE token costs 200k gas at the HyperEVM base fee, paid from the account's HYPE on HyperCore, so moving USDC back needs a small HYPE balance there. The vault keeps coreHypeReserveWei of HYPE on HyperCore for this (0.01 HYPE in both presets), and only sends a USDC pull while free HYPE covers twice the cost at the current block.basefee. See sweep.
| Direction | HYPE | USDC |
|---|---|---|
| HyperEVM to HyperCore | Send native HYPE as value to 0x2222222222222222222222222222222222222222 | Circle's CoreDepositWallet, deposit(amount, type(uint32).max) (spot balance) |
| HyperCore to HyperEVM | Send asset (action 13) to 0x2222…2222 | Send asset (action 13) to the USDC system address, 0x2000000000000000000000000000000000000000 (token index 0) |
Every token's HyperCore system address is 0x20 followed by zeros and the token index; HYPE is the exception, at 0x2222…2222. Transfers settle in a later block, never inside the sending transaction, which is why deposits and crystallisation wait while a transfer is in flight.
An address becomes a HyperCore user once it receives a HyperCore asset such as USDC, and an address that is not a HyperCore user cannot send CoreWriter actions. The deploy runbook credits the CoreAgent's HyperCore account with 1 USDC, then checks that 0x810 returns true for it. CoreAgent.coreAccountActive() exposes the same read. While it is false, the hook's fast loop skips rebalancing without reverting, and sweep() sends no HyperCore to HyperEVM pulls; transfers into the account are still allowed, because they fund it.
HyperCore limits requests per address (Hyperliquid, rate limits and user limits):
Counterbook stays inside this budget with cooldownBlocks (at least minCooldownBlocks), dispatching only when the skew passes the soft band, and cancelling before placing.
HyperEVM produces two kinds of block: small blocks every second with a 3M gas limit, and big blocks every minute with a 30M gas limit. Ordinary transactions, swaps included, go into small blocks. An address opts into big blocks with the HyperCore action {"type": "evmUserModify", "usingBigBlocks": true}, which requires the address to be a HyperCore user; the flag must be unset to return to small blocks. Contract deployments larger than a small block need big blocks. See the runbook.
| Constant | Mainnet (999) | Testnet (998) |
|---|---|---|
| Spot pair | @107 | @1035 |
| Spot asset id (orders, BBO) | 10107 | 11035 |
| Perp index (basis check) | 159 | 135 |
| HYPE token index | 150 (szDecimals 2, weiDecimals 8) | 1105 (szDecimals 2, weiDecimals 8) |
HYPE perp szDecimals (szDecimalsPerp) | 2 | 2 |
| USDC token index | 0 (weiDecimals 8) | 0 (weiDecimals 8) |
| USDC on HyperEVM | 0xb88339CB7199b77E23DB6E890353E22632Ba630f | 0x2B3370eE501B4a559b57D449569354196457D8Ab |
| CoreDepositWallet | 0x6B9E773128f453f5c2C60935Ee2DE2CBc5390A24 | 0x0B80659a4076E9E93C7DbE0f10675A16a3e5C206 |
| HYPE system address | 0x2222222222222222222222222222222222222222 | same |
| CoreWriter | 0x3333333333333333333333333333333333333333 | same |
Values were read from HyperCore's spotMeta and meta and from the token contracts on 2026-11-28. In the contracts they are a deployment-time MandateConfig, so mainnet and testnet run the same code.