Overview
Filling an order means taking the other side of an existing maker order on the orderbook. As a taker, you get immediate execution at the price a maker has posted. SX Bet usesPOST /orders/fill/v2 to submit fills. The exchange matches your fill against the best available orders after a short betting delay.
Prerequisites
- Create an account at sx.bet and export your private key from the assets page
- Fund your account with USDC
- Enable betting by approving the
TokenTransferProxycontract — see Enabling Betting
Fill fields
Each fill submitted toPOST /orders/fill/v2 requires these fields:
| Field | Type | Description |
|---|---|---|
market | string | User-facing string for the market. Set to "N/A" when using the API |
baseToken | string | The token this fill is denominated in (e.g., USDC). See References for token addresses |
isTakerBettingOutcomeOne | boolean | true if you’re betting on outcome one, false for outcome two |
stakeWei | string | Your stake in base token units (Ethereum format). See Unit Conversion |
desiredOdds | string | The worst taker odds you’ll accept, in SX protocol format (implied * 10^20) |
oddsSlippage | integer | Percentage tolerance (0–100) applied to desiredOdds. 0 means exact odds only |
fillSalt | string | A random 32-byte value to identify this fill |
taker | string | Your wallet address |
takerSig | string | Your wallet signature over the fill payload |
message | string | A user-facing message included in the signing payload. Can be anything (e.g., "N/A") |
Understanding desiredOdds
This is the implied probability from your perspective as the taker. It’s the inverse of the maker’s percentageOdds:
percentageOdds = "52500000000000000000" (52.5%), the taker odds for betting outcome one are:
desiredOdds = "47500000000000000000" to fill at that price.
Orders with taker odds better than your
desiredOdds will also fill. The desiredOdds is a floor, not an exact match.Understanding oddsSlippage
The oddsSlippage field is an integer from 0 to 100 representing a percentage tolerance on your desiredOdds. This is useful for volatile in-play markets where odds shift quickly.
0— only acceptdesiredOddsor better (no slippage)5— accept up to 5% worse thandesiredOdds
0 is usually fine. For in-play markets, a small slippage (2–5) helps ensure your fill goes through.
Understanding stakeWei
This is the amount of tokens you are putting up for the bet. It’s in Ethereum units — for USDC (6 decimals), "50000000" = 50 USDC.
If there isn’t enough liquidity to fill your full stake, the exchange will partially fill you for the available amount.
The minimum taker stake is 1 USDC.
Step 1: Find orders to fill
Check what odds are available on the market you want to bet on usingGET /orders/odds/best:
GET /orders to see all open orders and their available sizes. See Navigating the Orderbook for more on reading depth.
Step 2: Sign and submit the fill
Fills require a typed data signature from your wallet. This is a different signing method from maker orders — the code below handles it for you. See Order Signing for the full reference.How filling works
After you submit a fill:- The exchange queues your fill and applies a short betting delay (a few seconds for pre-game, optimized for in-play)
- After the delay, the exchange matches your fill against the best available maker orders at or better than your
desiredOdds(accounting foroddsSlippage) - If enough liquidity exists, your fill executes. If not, you get a partial fill for the available amount
- The resulting trade(s) appear in your trade history
The betting delay prevents front-running on in-play markets where odds shift rapidly. Your fill is matched against the orderbook state after the delay, not at submission time.
Monitoring your fills
Subscribe to therecent_trades:global WebSocket channel to get real-time notifications when fills execute. This is a global feed — filter messages to your address in the handler:
GET /trades with the bettor parameter.
Real-time orderbook and odds
If you’re actively scanning markets before filling — especially in-play — polling REST adds latency. Two WebSocket channels are useful here:order_book:market_{marketHash}— full orderbook updates for a specific market. Subscribe withpositioned: true, recoverable: truebefore fetching the snapshot to avoid gaps. See Fetching Odds → Real-time orderbook for the correct subscribe-then-fetch pattern.best_odds:global— fires whenever the best available odds change across any market. Useful for watching multiple markets without subscribing to each orderbook individually. See Fetching Odds → Real-time best odds.
Common issues
Fill rejected — betting not enabled
You need to approve theTokenTransferProxy contract for each token you trade. See Enabling Betting.
Fill rejected — insufficient balance
Your wallet must have enough of the base token to coverstakeWei. Fund your account before submitting.
Fill returns no trades
This means there wasn’t enough liquidity at yourdesiredOdds (accounting for oddsSlippage). Either relax your odds, increase slippage, or wait for more maker orders to appear on the book.
In-play fills timing out
For in-play markets, odds move quickly. Use a smalloddsSlippage (2–5) to give your fill a better chance of executing. Check the latest odds via GET /orders/odds/best before each fill.
Related
Order Signing →
Full signing reference for fills and orders.
POST /orders/fill/v2 →
Full API reference for the fill endpoint.
Navigating the Orderbook →
Reading depth and finding the best prices.
Unit Conversion →
Converting between raw values and human-readable amounts.
