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.

text
 engine ──writes──► Postgres ◄──reads── /api/v1 (Vercel) ◄── /app (browser)
                                          browser ──► Hyperliquid + Montra directly (books, candles)

The parts

PartCodeRuns on
Engine: strategies, risk, accountingengine/Render (blueprint render.yaml) or any Docker host. It must stay up, so it cannot run on Vercel
Databaseschema lib/protocol/schema.ts, migrations db/migrationsNeon or any Postgres. The engine applies migrations when it starts
API /api/v1/*app/api/v1/[...path]/route.ts → lib/server/api.tsVercel, in the same Next.js project as the site. Optionally also served by the engine
Site and appapp/(site), app/app, components/Vercel
Phase 2 contractscontracts/Elysium, not deployed yet
Shared library: addresses, ABIs, markets, DB schema, response typeslib/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:

SourceUsed forRefresh
https://api.hyperliquid.xyz/infometaAndAssetCtxs, spotMetaAndAssetCtxs, candleSnapshotcontexts every 15 s
wss://api.hyperliquid.xyz/wsLive L2 books and tradesstreaming, ping every 25 s
https://api.montramarkets.xyzToken info, trades, candles10 s, 6 s, 15 s
Elysium RPC, from the visitor's walletThe permissionless FeeSplitter.claim() buttonon click

If one of those sources is down, only that part of the page is empty.

Chain and venues

ElysiumKinetiq's Arbitrum Orbit L2, chain id 99901 (testnet 99801), gas token HYPE. RPC https://rpc.elysium.kinetiq.xyz, explorer https://elysium.kinetiq.xyz/explorer
MontraUniswap v4 launchpad on Elysium. Every pool is HYPE/token with a dynamic fee and the Montra hook
HyperCoreHyperliquid'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.