Documentation API Reference Tokenomics
API Trading Place Trade

Place Trade

Place a prediction market trade (bet). Requires HMAC authentication for API key access, or wallet signature for browser access.

⚠️
Authenticated Endpoint: This endpoint requires either a wallet signature or API Key + HMAC signature. See Authentication.
POST /api/pool/trade

Authentication

Choose one method:

MethodHeaders Required
Wallet Signaturex-wallet-signature, x-wallet-message
API Key HMACx-api-key, x-api-timestamp, x-api-signature

Request Body

ParameterTypeRequiredDescription
wallet_addrstringrequiredWallet address (0x format, must match authenticated wallet)
market_idintegerrequiredMarket ID to trade on
sidestringrequiredyes, no, or draw (threeway only)
amountnumberrequiredAmount in USDC (min: 1.00)

Response

Response 200 OK
{
  "success": true,
  "data": {
    "trade_id": 5421,
    "market_id": 142,
    "side": "yes",
    "amount": 100.00,
    "shares": 161.29,
    "price": 0.62,
    "new_yes_price": 0.635,
    "new_no_price": 0.365,
    "remaining_balance": 450.00,
    "pool": {
      "yes_pool": 8904.31,
      "no_pool": 5642.00,
      "total_volume": 14546.31
    }
  }
}

How It Works

OddsForge uses a parimutuel pool model:

  1. Your USDC goes into the pool for the side you choose (YES/NO/DRAW)
  2. You receive shares proportional to the current pool price
  3. When the market resolves, the losing side's pool is distributed to winners
  4. A 5% protocol fee is deducted from the losing side only
  5. Winners get their original stake back + share of the losing pool (minus fees)

Error Responses

CodeErrorDescription
400Insufficient balanceNot enough USDC in your balance
400Market not activeMarket is resolved, cancelled, or pending
400Invalid sideSide must be yes, no, or draw (for threeway)
400Minimum trade is 1 USDCAmount too small
401Signature requiredMissing authentication headers
403API key wallet mismatchAPI key's wallet doesn't match wallet_addr
429Rate limit exceededToo many trade requests

Example (API Key)

# Using API Key + HMAC
TIMESTAMP=$(date +%s)
BODY='{"wallet_addr":"0x1234...","market_id":142,"side":"yes","amount":100}'
PAYLOAD="${TIMESTAMP}POST/api/pool/trade${BODY}"
SIGNATURE=$(echo -n "$PAYLOAD" | openssl dgst -sha256 -hmac "YOUR_SECRET" | awk '{print $2}')

curl -X POST https://oddsforge.org/api/pool/trade \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-api-timestamp: $TIMESTAMP" \
  -H "x-api-signature: $SIGNATURE" \
  -d "$BODY"