Getting started
Architecture
The parts of Motion, where each runs, and how data flows between them.
Motion is one repository with four deployable parts and a shared library.
engine ──writes──► Postgres ◄──reads── /api/v1 (Vercel) ◄── /app (browser)
browser ──► Hyperliquid + Montra directly (books, candles)The parts
| Part | Code | Runs on |
|---|---|---|
| Engine: strategies, risk, accounting | engine/ | Render (blueprint render.yaml) or any Docker host. It must stay up, so it cannot run on Vercel |
| Database | schema lib/protocol/schema.ts, migrations db/migrations | Neon or any Postgres. The engine applies migrations when it starts |
API /api/v1/* | app/api/v1/[...path]/route.ts → lib/server/api.ts | Vercel, in the same Next.js project as the site. Optionally also served by the engine |
| Site and app | app/(site), app/app, components/ | Vercel |
| Phase 2 contracts | contracts/ | Elysium, not deployed yet |
| Shared library: addresses, ABIs, markets, DB schema, response types | lib/protocol/ | Imported by all of the above |
Who writes, who reads
- Only the engine writes trading data. Balances, positions, orders, fills, revenue, snapshots and ledger events all come from it.
- The API reads. The only writes it makes are the two admin calls, which set a flag in
engine_state(kill switch, strategy pause) and log an event. It holds no keys and sends no transactions. - The engine polls its control flags every 3 seconds, so an admin call takes effect within about 3 s.
See Database for every table.
What the browser fetches directly
Market data does not go through the API. The app reads it straight from the venues:
| Source | Used for | Refresh |
|---|---|---|
https://api.hyperliquid.xyz/info | metaAndAssetCtxs, spotMetaAndAssetCtxs, candleSnapshot | contexts every 15 s |
wss://api.hyperliquid.xyz/ws | Live L2 books and trades | streaming, ping every 25 s |
https://api.montramarkets.xyz | Token info, trades, candles | 10 s, 6 s, 15 s |
| Elysium RPC, from the visitor's wallet | The permissionless FeeSplitter.claim() button | on click |
If one of those sources is down, only that part of the page is empty.
Chain and venues
| Elysium | Kinetiq's Arbitrum Orbit L2, chain id 99901 (testnet 99801), gas token HYPE. RPC https://rpc.elysium.kinetiq.xyz, explorer https://elysium.kinetiq.xyz/explorer |
| Montra | Uniswap v4 launchpad on Elysium. Every pool is HYPE/token with a dynamic fee and the Montra hook |
| HyperCore | Hyperliquid's order-book layer. The engine uses the public API and WebSocket, and in live mode an API wallet |
Running without a database
The site and the app work without DATABASE_URL. In that case /api/v1/status reports "database": false, the app shows live markets and on-chain contract data, and the vault panels say No engine data. The endpoints that need the database answer 503 DATABASE_NOT_CONFIGURED. This is the current state of the public deployment until the database and the engine are connected.