API

Read markets, accounts, and the chain, stream live data, and submit signed transactions.

Basics

  • Base URL: https://api.uplong.fun
  • Amounts are micro-USDC and prices are micro-USD, as integers: 1 USDC is 1000000.
  • Addresses are Solana public keys in base58. Hashes are 0x-prefixed hex.

REST

RequestReturns
GET /statuschainId, height, tip hash, prices, pool, mempool size
GET /marketsPrices, open interest, pool, payout queue, fees (withdrawalFee, longClaimFee), chainId, minNotional (smallest order value), maxSideGap, longRewards; per market longCap/shortCap and longRoom/shortRoom (new notional that fits on each side now; null is unlimited). Order clients need minNotional and the room fields.
GET /account/:addressLive balance, nextNonce, session key and agentExpiresMs, positions with PnL, queued winnings, longEarned and longClaimed
GET /positionsEvery open position on the exchange, largest first, valued at the latest block
GET /prices/history?market=BTC&windowMs=3600000&points=600&endMs=…Oracle price history for a stretch ending at endMs (default now, at most a week back), led by the last price before it; firstMs is the first recorded price
GET /markets/volume?windowMs=86400000Opened volume and trade count per market over a window (default 24h)
GET /stats?windowMs=86400000&bucketMs=1800000Exchange totals, activity per time bucket, volume per market, top traders
GET /trades?limit=40Recent opens, closes, and liquidations
GET /blocks?before=&limit=25&activeOnly=trueBlocks, newest first, optionally only ones with activity; before is a block height
GET /blocks/:height, /blocks/latestA block with its transactions and receipts
GET /tx/:hashA transaction and its receipt
GET /address/:addressCommitted account view with trading stats and withdrawals
GET /address/:address/txs?before=&limit=An account’s transactions, newest first; before is <height>:<index>
GET /deposit-address/:addressThe account’s deposit address
GET /deposit-transaction/:address?amount=An unsigned USDC transfer (base64) from the wallet to its deposit address, for the wallet to sign and send
POST /txSubmit a signed transaction; returns its hash

Paged lists take limit (default 25, at most 100) and before, an exclusive cursor: pass the last item’s height (or <height>:<index>) to get the next page.

WebSocket

For live prices, markets, accounts, open positions, blocks, and trades, connect to /ws. See WebSocket.

Signing transactions

A transaction names the chain (chainId from GET /status or /markets), the account, the account’s next nonce (nextNonce from GET /account/:address, which counts transactions already queued), and an action: open, close, withdraw, setAgent, or claimLong (wallet only), and for the admin account only, setLimits, setSideGap, and fundPool ({ "type": "fundPool", "amount": 5000000000 }, signed text action: fund pool / amount: 5000.000000 USDC). Sign the text below with ed25519, using the wallet’s key or an authorized session key, and post it.

  • The text is UTF-8, with \n line breaks and no trailing newline. Amounts have 6 decimals. The chain id is 16 hex digits without 0x.
  • The signature is the base58 encoding of the 64-byte ed25519 signature.
uplong.fun
chain: <chainId>
account: <base58 address>
nonce: <n>
action: open
market: BTC
side: long
margin: 10.000000 USDC
leverage: 1000x

The first four lines are the same for every action. The lines after them:

action: close
position: <position id>

action: withdraw
amount: 5.000000 USDC

action: claim $LONG

action: set session key
session key: <base58 address>
expires: 2026-10-13 04:20:00 UTC

action: set session key
session key: none

The expiry is UTC, with seconds; the last form revokes the session key.

POST /tx
{
  "tx": {
    "chain": "<chainId>",
    "signer": "<base58 address>",
    "nonce": 3,
    "action": { "type": "open", "market": "BTC", "side": "long", "margin": 10000000, "leverage": 1000 }
  },
  "signature": "<base58 signature>",
  "agent": "<session key address, when it signed>"
}
  • Other actions: { "type": "close", "positionId": 12 }, { "type": "withdraw", "amount": 5000000 }, { "type": "claimLong" }, { "type": "setAgent", "agent": "<address>", "expiresAtMs": 1791866400000 } (a session key for at most 24 hours), and { "type": "setAgent", "agent": null, "expiresAtMs": 0 } to revoke it.
  • The response is { "hash": "0x…" }. The transaction’s result (or error) is at GET /tx/:hash once its block is committed, usually within a second.
  • A request refused up front comes back as HTTP 400 with { "error": "…" }, for example invalid wallet signature, stale nonce: next is 12, or a session key that’s expired or not authorized.
  • Wallets that sign a Solana off-chain message envelope instead of the raw text (Ledger, for example) can send those signed bytes as the optional envelope field.
  • Session keys can sign only open and close.
  • A transaction signed for another chain id is refused without using up the nonce, so signatures can’t be replayed on a different uplong chain.

Wallet

Deposit USDC

Withdraw