TradrBot API

TradrBot backend API

Everything the app reads and sends: live prices, trading through the relayer, and the indexed history of the protocol on Robinhood Chain (chain id 4663). Collateral is USDG; the reward token is TRADR.

Three services, all public and CORS-open. Reads need no key. Trades and wallet actions are signed in the browser and sent to the relayer, which pays the gas.

Start here

Pick the service by what you need. Every service answers JSON and errors carry a stable code plus a human message in English.

ServiceProduction URLWhat it doesLocal (fork)
Indexer APIhttps://hmindexer-production.up.railway.appAccounts, positions, history, markets, stats, charts, leaderboard, profiles, tokenhttp://localhost:8096
Relayerhttps://hmrelayer-production.up.railway.appConfig for signing, open/close intents, wallet actions (deposit, withdraw, session keys, staking)http://localhost:8091
Priceshttps://hmprices-production.up.railway.appLive Pyth prices (websocket), candles and ticks, SPY and TSLA previewshttp://localhost:8090
Production status. All endpoints are live. Trading opens when the contracts team lists the markets on-chain (configure.ts) and the relayer wallet has ETH and its role; until then /api/markets shows listed: false, the relayer's /live answers 503 and every list is empty. Empty lists are real data, not errors.

Conventions

The same rules hold across the three services, so the front never guesses units.

ThingFormatExample
USDG amounts (indexer)Decimal string, 6 decimals already applied"1234.56"
TRADR amountsDecimal string, 18 decimals applied"20.4581"
Prices (indexer)Decimal string in USD"79783.68"
Prices (prices service, relayer)Integer string with expo (Pyth), or WAD (18 decimals) in relayer results; usd is a number for display only{"price":"7964500832418","expo":-8}
Amounts you send to the relayerRaw integer strings: USDG × 10⁶, TRADR × 10¹⁸"10000000" = 10 USDG
PercentagesNumber with 2 decimals; bps fields are basis points (1 bps = 0.01 %)161.33, winFeeBps: 200
TimesUnix seconds (chain time). Price ticks use milliseconds where noted1793072560
AddressesLowercase in responses; any case accepted in requests0x3c44…93bc
MarketsinstrumentId 0 = BTC/USD, 1 = ETH/USD (tradable). 100 = SPY/USD, 101 = TSLA/USD (previews, prices only)market=0
Errors (indexer, prices){ code, message } with HTTP 400/404/409/429/5xx{"code":"INVALID_REQUEST","message":"…"}
Errors (relayer){ status: "rejected", code, message }; codes are the contract's error names{"status":"rejected","code":"InvalidSize",…}
Strict query stringsNewer routes reject unknown or repeated params with 400. Build queries with URLSearchParams and omit defaults?window=7d
Rate limits (per IP)Indexer: 60 burst, 20/s. Prices: 30 burst, 10/s (/history costs 3). Relayer: 30 burst, 10/s, and 5 intents/s per signer. Over the limit: 429poll every 2–5 s

How a trade happens

The wallet signs once to create a session key. After that, opening and closing are signed by the session key in the browser, with no popups and no gas for the user.

1 · relayerLoad configGET /config: contracts, EIP-712 types, market limits and chain time (use it for signedAt).
2 · walletDepositPOST /action kind depositPermit: a USDG permit signature, no approve, no gas.
3 · walletRegister a session keyPOST /action kind registerSessionKey, up to 30 days. Keep the private key in the browser only.
4 · session keyOpenPOST /intent kind open with a priceLimit, then poll GET /intent/:id until executed.
5 · indexerShow it/api/positions/:user (live PnL, liquidation price) and /api/preview/:id before closing.
6 · session keyClosePOST /intent kind close. Profit is paid now or queued if the house is short (see queue).

Which screen uses what

A map from the app's pages to the calls behind them. Poll account data every 4 s; feeds every 4–10 s; charts every 30–60 s.

ScreenCalls
TradePrices websocket, /history + /api/volume (chart), /api/markets, /api/config, /api/positions/:user, /api/preview/:id, /api/activity?kind=trades (tape), relayer /config, /intent, /live
Portfolio/api/account/:user, /api/pnl/:user, /api/history/:user, /api/activity?user=, relayer /action (withdraw, deposit)
Leaderboard/api/leaderboard/accounts (sort by pnl, liquidations, staked…), /api/leaderboard/positions
Public profile/api/profile/by-username/:name, /api/account/:user, /api/pnl/:user, /api/activity?user=&kind=close,liquidation
House/api/house, /api/stats, /api/stats/history, /api/activity
Token/api/token, /api/token/history, /api/rate, /api/account/:user (staking), relayer /action (stake, unstake, claim)

Error codes

Show message by default and branch on code only where the UI does something different.

ServiceCodeHTTPMeaning