ResoMarket/Docs/Trading API

Trading API v1

HTTP and WebSocket protocol for automated trading and market making across ADI Mainnet and Polygon. USDC / pUSD · EIP-712 · HMAC.

Protocol v1Wallet-nativeADI Mainnet · Chain 36900Polygon · Chain 137USDC / pUSDEIP-712 + HMAC
Download JavaScript API demov0.1.2 · SHA-256 1920806fdb8c... · Node 20crypto: Previewsports: Previewbtc-3m: Preview

Preview means the API and offline demo are available, but the current release ZIP has not completed per-product runtime and real-funds closed-loop acceptance. Validate with a controlled wallet and the minimum amount before production funding.

Orders require an owner-wallet signature. Only a signed-in session with a managed owner signer may have one order server-signed; L2 credentials cannot sign orders or withdraw funds.

Funding and inventory

Trading V2 reuses the Sports & Contracts balance and Funding Hub. There are no /api/trading/deposits or /api/trading/withdrawals endpoints, and API credentials cannot withdraw. Split moves USDC into market backing and creates equal UP and DOWN; merge reverses complete sets.

Clients use the Funding API for deposits and status reads. The external funding wallet authorizes onboarding and sensitive actions; Reso separately manages the Trading Account owner and deposit wallet. Withdrawals require a WITHDRAW challenge signed by the bound funding wallet, always pay that wallet, and are executed by platform Provider/vault executors. Callers cannot supply Provider authorization or withdrawal wallet calls.

GET/api/funding/assetsRead supported assets and funding domains
POST/api/funding/redeemL2 builds owner WALLET redeem calls for resolved Crypto positions
POST/api/funding/intentsL2 deposit intent; funding-wallet L1 withdrawal intent
POST/api/funding/intents/cancelSession/L2 cancellation before any deposit is detected
POST/api/funding/intents/confirm-polymarket-withdrawalL2 confirmation of the Crypto owner transfer
GET/api/funding/statusL2 private funding status

Choose the funding domain

targetAccountProductsCredited collateral
adi_vaultSports and BTC 3mADI Mainnet (36900) USDC
polymarket_collateralCryptoPolygon (137) pUSD

Deposit

Code example
# 1. Select an enabled asset whose targetAccounts allows your target.GET /api/funding/assets# 2. Choose the product funding domain, then sign the exact JSON bytes with Reso L2 HMAC.# Sports and BTC 3m: targetAccount=adi_vault (ADI Mainnet USDC).# Crypto: targetAccount=polymarket_collateral (Polygon pUSD).POST /api/funding/intentsIdempotency-Key: deposit-0001{"flow":"deposit","targetAccount":"adi_vault","gasReady":true,"quote":{ "fromAmountBaseUnit":"10000000","fromChainId":"137", "fromTokenAddress":"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359"}}# Response amountUsdc is gross, feeUsdc is the fixed fee, and netAmountUsdc# is the credited amount. Use the returned depositAddress and statusAddress.# {"intent":{"intentId":"...","amountUsdc":10,"feeUsdc":1,"netAmountUsdc":9,# "depositAddress":{"evm":"0x..."},"statusAddress":"0x..."},"replayed":false}# 3. Crypto only: wait for polymarketFunderWallet, register the CLOB Credential,# and approve pUSD spenders from that wallet through the official relayer WALLET flow.# 4. Transfer the selected token to intent.depositAddress only from an allowedSenderWallet.# If wallet preparation returns 409, retry these exact bytes with the same key.# Poll the returned statusAddress every 10-30 seconds until DONE or FAILED.GET /api/funding/status?address=<statusAddress>

Crypto redeem

Code example
# Resolved Crypto positions cannot be sold on the CLOB. Sign this body with Reso L2:POST /api/funding/redeem{"providerId":"polymarket","marketId":"<public market id>","side":"YES"}# If execution.calls is non-empty, submit it as one official relayer WALLET batch:const redeemed = await relayer.executeDepositWalletBatch(  response.execution.calls, response.execution.sourceWallet,  String(Math.floor(Date.now() / 1000) + 600)).then((pending) => pending.wait());if (!redeemed?.transactionHash) throw new Error("redeem was not confirmed");# Then refresh /api/portfolio until redeemable is false and pUSD is available.

Withdrawal

Code example
# 1. Read the managed owner, then issue WITHDRAW. Reso fixes destinationWallet to the bound funding wallet.POST /api/trading/auth/challenges{"fundingWallet":"0x...","action":"WITHDRAW","resource":{ "ownerWallet":"0x<managed-owner>","targetAccount":"adi_vault","amountBaseUnit":"2000000", "fromChainId":"36900","fromTokenAddress":"0x9cb8142aebbcdc60af7c97af897a67a8f3ca71c2", "toChainId":"137","toTokenAddress":"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359", "destinationWallet":"0x<bound-funding-wallet>","idempotencyKey":"withdraw-0001"}}# 2. Sign only the Reso challenge with the bound funding wallet.const resoSignature = await ownerAccount.signTypedData(challenge.typedData);# 3. No L2 headers. Reso executes Provider/vault actions after risk and ledger checks.POST /api/funding/intentsIdempotency-Key: withdraw-0001{"fundingWallet":"0x...","challengeId":"0x...","signature":"<resoSignature>", "flow":"withdraw","targetAccount":"adi_vault","gasReady":true, "quote":{"fromAmountBaseUnit":"2000000","fromChainId":"36900","fromTokenAddress":"0x9cb8142aebbcdc60af7c97af897a67a8f3ca71c2", "toChainId":"137","toTokenAddress":"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359"}}# Crypto uses targetAccount=polymarket_collateral and Polygon pUSD as the source.# For both domains, poll statusAddress until DONE or FAILED; callers receive no Provider wallet calls.GET /api/funding/status?address=<statusAddress>

Withdrawal authorization and Crypto confirmation errors

HTTPerrorClient action
401 / 403WITHDRAW_AUTHORIZATION_INVALIDRequest and sign a new challenge with the bound funding wallet
409WITHDRAW_STATE_CONFLICTQuery the original intent; do not change or duplicate it
503WITHDRAW_EXECUTION_UNAVAILABLEKeep the original request and wait for platform recovery

Funding status

statusTerminalClient action
AWAITING_ONCHAIN_TRANSFER / PENDING / PROCESSINGNoPoll the same statusAddress every 10-30 seconds
PAYOUT_POOL_LOW / MANUAL_REVIEWNoKeep the original intent. For Crypto deposits check credentials/allowance; for withdrawals wait for platform executor or payout-pool recovery
DONEYesFunding completed; refresh the portfolio
FAILEDYesResolve the cause first; use a new Idempotency-Key for a new request

Settlement and root

Order and fill status is database finality, not chain status. A FINALIZED settlement batch means payout has posted. rootChainStatus=CONFIRMED proves only the asynchronous batch audit commitment; it never credits funds again.

New settlement leaves return acquisitionCostBaseUnit and realizedPnlBaseUnit as payoutBaseUnit minus cost. Both are null when a legacy leaf has no immutable cost evidence.

GET/api/trading/settlement-batchesCaller-owned batches and leaves
GET/api/trading/settlement-batches/{batchId}Caller leaves, Merkle proof and root evidence
GET/api/trading/accounting/snapshotImmutable ZIP at one account/ledger cursor