Start here

Overview

How a trade works in sufwan-local-test, from sign-in to withdrawal, and where to start

sufwan-local-test is a white-label prediction market aggregator. Your users trade markets listed on several venues, such as Polymarket, Hyperliquid, and Limitless, through one API. sufwan-local-test matches the same market across venues, quotes the best split, executes it, and tracks every order.

See Fees.

What are you building?

You are buildingWho signs inCredentialsStart here
A trading bot or AI agent that trades its own fundsThe bot, with its own wallet keyx-app-id and the bot's access tokenQuickstart: trading bot / agent
A platform where many users tradeEach user, on your clientx-app-id and each user's access token. Your backend adds x-app-api-key for server features.Quickstart: REST, then Choose your integration
A trading terminal or other UIEach user, in the browserx-app-id and the user's token, managed by the SDK. Never ship x-app-api-key to a browser.Quickstart: React

The API reference has two tabs. Trading API is every call made with x-app-id, plus a user's access token where one is needed: markets, quotes, orders, funding, and the user's account. Server API is the calls your backend makes with x-app-api-key: partner admin reads, webhooks, and paper accounts.

The trade lifecycle

Every integration follows the same six steps. Each links to the page that explains it.

StepWhat happensMain calls
1. AuthenticateThe user signs in with a wallet, OAuth, email, or Privy. You get an access token.POST /auth/start, POST /auth/verify
2. Find a marketBrowse or search events and markets. You trade an outcome, identified by venueMarketOutcomeId. See Ids.GET /venue-events, GET /venue-markets
3. FundThe user deposits USDC to their deposit address on a supported chain.GET /execution/deposit-addresses, GET /execution/balances
4. Quotesufwan-local-test prices the trade across every venue that lists the outcome and returns a quoteId.GET /orderbook/{venueMarketOutcomeId}/route
5. Execute & trackYou fill the quote, then poll until the trade reaches a terminal state.POST /execution/fill, GET /execution/status
6. Settle & withdrawWinning positions are redeemed after resolution. The user withdraws to any address.POST /execution/redeem, POST /execution/withdraw

Execution and custody models

ModelWho holds the fundsWho signsUse it for
ManagedA managed balance sufwan-local-test holds for the usersufwan-local-testThe default. Simplest flow, best-price routing across venues.
Self-custodyThe user's own EVM walletThe user's wallet, one request at a timeUsers who must keep their own keys.
Hosted venue accountAn account sufwan-local-test hosts for the user on one venuesufwan-local-testVenues where a native account is needed.

Every wallet and venue account, and which address to pass where, is on Accounts & wallets. Every venue is on Venues.

Choose your integration is five styles inside these three custody models. Privy, paper admin, and ProphetX direct accounts are not in that table.

Within the managed model you can fill a quote, place a direct order on one venue, or rest a limit order.

How you integrate

sufwan-local-test ships as a REST API and four npm packages. Pick the layer that fits:

  • REST API: any language. Start with Quickstart: REST.
  • @agg-build/sdk: a TypeScript client for browsers, Node.js, and React Native. Find methods and their API endpoints in the SDK reference.
  • @agg-build/hooks: React hooks with caching and WebSocket subscriptions.
  • @agg-build/ui and @agg-build/auth: drop-in trading and sign-in components. Start with Quickstart: React.

Each package includes the layers below it. See the Packages overview.

Start here

On this page