Build on Mkrv
One intent from Elysium, managed execution on HyperCore. Integrate from a contract, a script, or an AI agent.
JavaScript SDK
One file, ethers v6 as the only dependency. In the browser import it straight from the site.
import { Mkrv } from 'https://mkrv.trade/sdk/mkrv.js'
const mkrv = await Mkrv.connect({ signer }) // ethers Signer on Elysium
await mkrv.ensureAccount() // your Execution Account, created once
const { id, report } = await mkrv.twap({ coin: 'HYPE', side: 'buy', usd: 50, minutes: 10, slices: 4 })
await mkrv.limit({ coin: 'BTC', side: 'sell', usd: 25, price: 98000 })
await mkrv.bracket({ coin: 'ETH', side: 'buy', usd: 30, tp: 3900, sl: 3500 })
await mkrv.scale({ coin: 'HYPE', side: 'buy', usd: 60, from: 58, to: 56, orders: 3 })
const intent = await mkrv.instruction(id) // slices, fills, receipts
await mkrv.cancel(id)
Read only
import { api } from 'https://mkrv.trade/sdk/mkrv.js'
const mkrv = api()
await mkrv.stats()
await mkrv.instructions({ account: '0x..' })
From a contract
Your contract owns its own Execution Account and submits intents from it. Prices and sizes are scaled by 1e8. Send the fee per slice as value.
IMkrvAccount account = IMkrvAccount(IMkrvFactory(FACTORY).createAccount(address(this)));
IMkrvAccount.Params memory p;
p.kind = IMkrvAccount.Kind.Twap;
p.asset = 159; // HYPE perp
p.isBuy = true;
p.sz = 1e8; // 1 HYPE
p.duration = 600;
p.interval = 150; // 4 slices
p.maxSlippageBps = 50;
account.submit{value: 4 * account.feePerSlice()}(p);
Order types
| Kind | Fields | Behaviour |
|---|---|---|
| Limit | limitPx | Rests post only at your price |
| TWAP | duration, interval | Equal slices on a schedule |
| Iceberg | limitPx, visibleSz | Shows one slice, refills on every fill |
| Stop | triggerPx | Reduce only exit when the mark crosses |
| Take profit | triggerPx | Reduce only exit at your target |
| Bracket | tpPx, slPx | Entry now, exits at target or stop |
API
| Endpoint | Returns | |
|---|---|---|
| GET | /api/config | Chain id, RPC, factory, fee per slice, Hyperliquid endpoint |
| GET | /api/stats | Intents, slices filled, volume executed on HyperCore |
| GET | /api/instructions?account=0x..&limit=50 | Intents, newest first, optionally for one account |
| GET | /api/instructions/{account}:{id} | One intent with every slice, fill, order id and receipt |
| POST | /api/instructions {account,id} | Index an intent right after you submit it |
| GET | /api/accounts/{address} | Execution Account by account or owner, with its Hyperliquid state |
| POST | /api/accounts/register {owner} | Register a new account after createAccount |
| GET | /api/activity?limit=50 | Live feed of submits, orders, slices and completions |
| GET | /i/{account}/{id} | Execution report page for one intent |
| GET | /api/quantum/keys/{hlUser} | Quantum keys for a Hyperliquid user, with signatures left |
| POST | /api/quantum/relay {key,action,params|id,leaf,sig,path} | Relay a hash signed submit or cancel |
Events
event InstructionSubmitted(uint256 indexed id, uint8 kind, uint32 asset, bool isBuy, uint64 sz, uint64 limitPx, uint64 triggerPx); event Execution(uint256 indexed id, uint32 sliceIndex, uint64 hlOid, uint64 avgPx, uint64 sz, bytes16 cloid); event InstructionCompleted(uint256 indexed id, uint64 filledSz); event HyperCoreIntent(bytes32 intentId, address account, uint32 asset, bool isBuy, uint64 limitPx, uint64 sz, uint8 tif, bool reduceOnly, uint64 deadline, bytes32 cloid);
Quantum safe accounts
An Execution Account can be owned by a QuantumKey instead of a wallet. Every intent is signed with a Winternitz one time signature over keccak256, checked on chain against a Merkle root of 256 keys. No elliptic curve is involved, so the account stays safe from a quantum computer. Your seed never leaves your device and the relay can only send exactly what you signed.
import { newSeed, buildTree, signSubmit, QUANTUM_FACTORY_ABI } from 'https://mkrv.trade/sdk/quantum.js'
const seed = newSeed() // keep this safe, it is the account
const tree = await buildTree(seed) // 256 one time keys, about 5 seconds
await new Contract(cfg.quantumFactory, QUANTUM_FACTORY_ABI, wallet).create(tree.root, hlUser)
const { keys: [k] } = await (await fetch('/api/quantum/keys/' + hlUser)).json()
const signed = signSubmit({ seed, tree, chainId: cfg.chainId, key: k.key, leaf: k.nextLeaf, params })
await fetch('/api/quantum/relay', { method: 'POST', headers: { 'content-type': 'application/json' },
body: JSON.stringify({ key: k.key, action: 'submit', params, slices: 4, ...signed }) })
Every Hyperliquid order id cloid is keccak256(abi.encode(id, sliceIndex)) cut to 16 bytes, so any fill maps back to its intent.