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:
| Method | Headers Required |
|---|---|
| Wallet Signature | x-wallet-signature, x-wallet-message |
| API Key HMAC | x-api-key, x-api-timestamp, x-api-signature |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| wallet_addr | string | required | Wallet address (0x format, must match authenticated wallet) |
| market_id | integer | required | Market ID to trade on |
| side | string | required | yes, no, or draw (threeway only) |
| amount | number | required | Amount 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:
- Your USDC goes into the pool for the side you choose (YES/NO/DRAW)
- You receive shares proportional to the current pool price
- When the market resolves, the losing side's pool is distributed to winners
- A 5% protocol fee is deducted from the losing side only
- Winners get their original stake back + share of the losing pool (minus fees)
Error Responses
| Code | Error | Description |
|---|---|---|
| 400 | Insufficient balance | Not enough USDC in your balance |
| 400 | Market not active | Market is resolved, cancelled, or pending |
| 400 | Invalid side | Side must be yes, no, or draw (for threeway) |
| 400 | Minimum trade is 1 USDC | Amount too small |
| 401 | Signature required | Missing authentication headers |
| 403 | API key wallet mismatch | API key's wallet doesn't match wallet_addr |
| 429 | Rate limit exceeded | Too 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"
OddsForge