Usage
result = client.settle_position(
market_id="0x1234...abcd",
token_id="12345678901234567890" # Optional
)
Parameters
The market ID (condition ID) to settle.
Optional. Specific token ID to settle (for markets where you hold multiple outcomes).
Requirements
- Market must be closed on Polymarket
- Market must have a winning outcome determined
- You must have an active position in the market
Response
Whether settlement was successful.
Amount credited to your balance (0 if lost, shares × $1 if won).
Number of shares that were settled.
Which outcome won the market.
Whether you held winning shares.
Example
from polyhush import PolyhushClient, PolyhushAPIError
client = PolyhushClient(api_key="your-api-key")
try:
result = client.settle_position(
market_id="0x1234...abcd",
token_id="12345678901234567890"
)
if result['settled']:
if result['was_winner']:
print(f"🎉 You won! Payout: ${result['payout']:.2f}")
else:
print(f"📉 Position settled (lost)")
print(f"Shares settled: {result['original_size']}")
print(f"Winning outcome: {result['winning_outcome']}")
else:
print(f"Settlement failed: {result['message']}")
except PolyhushAPIError as e:
print(f"Error: {e.message}")
Response (Winner)
{
"settled": true,
"payout": 100.00,
"original_size": 100,
"winning_outcome": "Yes",
"was_winner": true,
"message": "Position settled successfully"
}
Response (Loser)
{
"settled": true,
"payout": 0,
"original_size": 50,
"winning_outcome": "No",
"was_winner": false,
"message": "Position settled successfully"
}
Payout Calculation
| Position | Market Outcome | Payout |
|---|
| Yes shares | Yes wins | shares × $1.00 |
| Yes shares | No wins | $0.00 |
| No shares | No wins | shares × $1.00 |
| No shares | Yes wins | $0.00 |
Winning shares are always worth 1.00eachatsettlement.Ifyouboughtat0.60, your profit is $0.40 per share.
Settlement Workflow
# Recommended workflow
pending = client.get_pending_settlements()
for market in pending:
if market['can_settle']:
print(f"Settling: {market['market_question']}")
print(f"Your bet: {market['your_outcome']}")
result = client.settle_position(
market['market_id'],
market['token_id']
)
if result['settled']:
print(f"Payout: ${result['payout']:.2f}")