Update Polymarket documentation (2026-02-19)

- Added new documentation URLs from llms.txt index
- Updated TARGET.md with 244 total documentation pages
- Scraped new pages for trading, concepts, and API reference sections
- Updated changelog and new index pages
This commit is contained in:
AI Agent
2026-02-19 14:31:02 +01:00
parent 81f77eff3c
commit b2a29fe51f
250 changed files with 33306 additions and 9659 deletions
+116 -122
View File
@@ -2,165 +2,159 @@
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
> Use this file to discover all available pages before exploring further.
# Data Feeds
# Fetching Markets
> Real-time and historical data sources for market makers
> Three strategies for discovering and querying markets
## Overview
<Tip>
Both the events and markets endpoints are paginated. See
[pagination](#pagination) for details.
</Tip>
Market makers need fast, reliable data to price markets and manage inventory. Polymarket provides several data feeds at different latency and detail levels.
There are three main strategies for retrieving market data, each optimized for different use cases:
| Feed | Latency | Use Case | Access |
| --------- | ---------- | ------------------------- | ------ |
| WebSocket | \~100ms | Standard MM operations | Public |
| Gamma API | \~1s | Market metadata, indexing | Public |
| Onchain | Block time | Settlement, resolution | Public |
1. **By Slug** — Best for fetching specific individual markets or events
2. **By Tags** — Ideal for filtering markets by category or sport
3. **Via Events Endpoint** — Most efficient for retrieving all active markets
## WebSocket Feeds
***
The WebSocket API provides real-time market data with low latency. This is sufficient for most market making strategies.
## Fetch by Slug
### Connecting
**Use case:** When you need to retrieve a specific market or event that you already know about.
```typescript theme={null}
const ws = new WebSocket("wss://ws-subscriptions-clob.polymarket.com/ws/market");
Individual markets and events are best fetched using their unique slug identifier. The slug can be found directly in the Polymarket frontend URL.
ws.onopen = () => {
// Subscribe to orderbook updates
ws.send(JSON.stringify({
type: "market",
assets_ids: [tokenId]
}));
};
### How to Extract the Slug
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
// Handle orderbook update
};
From any Polymarket URL, the slug is the path segment after `/event/`:
```
https://polymarket.com/event/fed-decision-in-october
Slug: fed-decision-in-october
```
### Available Channels
### Examples
| Channel | Message Types | Documentation |
| -------- | ------------------------------------------ | ----------------------------------------------------------- |
| `market` | `book`, `price_change`, `last_trade_price` | [Market Channel](/developers/CLOB/websocket/market-channel) |
| `user` | Order fills, cancellations | [User Channel](/developers/CLOB/websocket/user-channel) |
```bash theme={null}
# Fetch an event by slug (query parameter)
curl "https://gamma-api.polymarket.com/events?slug=fed-decision-in-october"
### User Channel (Authenticated)
Monitor your order activity in real-time:
```typescript theme={null}
// Requires authentication
const userWs = new WebSocket("wss://ws-subscriptions-clob.polymarket.com/ws/user");
userWs.onopen = () => {
userWs.send(JSON.stringify({
type: "user",
auth: {
apiKey: "your-api-key",
secret: "your-secret",
passphrase: "your-passphrase"
},
markets: [conditionId] // Optional: filter to specific markets
}));
};
userWs.onmessage = (event) => {
const data = JSON.parse(event.data);
// Handle order fills, cancellations, etc.
};
# Or use the path endpoint
curl "https://gamma-api.polymarket.com/events/slug/fed-decision-in-october"
```
See [WebSocket Authentication](/developers/CLOB/websocket/wss-auth) for auth details.
```bash theme={null}
# Fetch a market by slug (query parameter)
curl "https://gamma-api.polymarket.com/markets?slug=fed-decision-in-october"
### Best Practices
1. **Reconnection logic** - Implement automatic reconnection with exponential backoff
2. **Heartbeats** - Respond to ping messages to maintain connection
3. **Local orderbook** - Maintain a local copy and apply incremental updates
4. **Sequence numbers** - Track sequence to detect missed messages
See [WebSocket Overview](/developers/CLOB/websocket/wss-overview) for complete documentation.
## Gamma API
The Gamma API provides market metadata and indexing. Use it for:
* Market titles, slugs, categories
* Event/condition mapping
* Volume and liquidity data
* Outcome token metadata
### Get Markets
```typescript theme={null}
const response = await fetch(
"https://gamma-api.polymarket.com/markets?active=true"
);
const markets = await response.json();
# Or use the path endpoint
curl "https://gamma-api.polymarket.com/markets/slug/fed-decision-in-october"
```
### Get Events
***
```typescript theme={null}
const response = await fetch(
"https://gamma-api.polymarket.com/events?slug=us-presidential-election"
);
const event = await response.json();
## Fetch by Tags
**Use case:** When you want to filter markets by category, sport, or topic.
Tags provide a way to categorize and filter markets. You can discover available tags and then use them to filter your requests.
### Discover Available Tags
**General tags:** `GET /tags` (Gamma API)
**Sports tags and metadata:** `GET /sports` (Gamma API)
The `/sports` endpoint returns metadata for sports including tag IDs, images, resolution sources, and series information.
### Filter by Tag
Once you have tag IDs, use the `tag_id` parameter in both events and markets endpoints:
```bash theme={null}
# Fetch events for a specific tag
curl "https://gamma-api.polymarket.com/events?tag_id=100381&limit=10&active=true&closed=false"
```
### Key Fields for MMs
### Additional Tag Filtering
| Field | Description |
| --------------- | ------------------------ |
| `conditionId` | Unique market identifier |
| `clobTokenIds` | Outcome token IDs |
| `outcomes` | Outcome names |
| `outcomePrices` | Current outcome prices |
| `volume` | Trading volume |
| `liquidity` | Current liquidity |
You can also:
See [Gamma API Overview](/developers/gamma-markets-api/overview) for complete documentation.
* Use `related_tags=true` to include related tag markets
* Exclude specific tags with `exclude_tag_id`
## Onchain Data
```bash theme={null}
# Include related tags
curl "https://gamma-api.polymarket.com/events?tag_id=100381&related_tags=true&active=true&closed=false"
```
For settlement, resolution, and position tracking, market makers may query onchain data directly.
***
### Data Sources
## Fetch All Active Markets
| Data | Source | Use Case |
| -------------------- | ------------------- | ---------------------------- |
| Token balances | ERC1155 `balanceOf` | Position tracking |
| Resolution | UMA Oracle events | Pre-resolution risk modeling |
| Condition resolution | CTF contract | Post-resolution redemption |
**Use case:** When you need to retrieve all available active markets, typically for broader analysis or market discovery.
### RPC Providers
The most efficient approach is to use the events endpoint with `active=true&closed=false`, as events contain their associated markets.
Common providers for Polygon:
```bash theme={null}
curl "https://gamma-api.polymarket.com/events?active=true&closed=false&limit=100"
```
* Alchemy
* QuickNode
* Infura
### Key Parameters
### UMA Oracle
| Parameter | Description |
| ----------- | ---------------------------------------------------------------------------------------------------------------- |
| `order` | Field to order by (`volume_24hr`, `volume`, `liquidity`, `start_date`, `end_date`, `competitive`, `closed_time`) |
| `ascending` | Sort direction (`true` for ascending, `false` for descending). Default: `false` |
| `active` | Filter by active status (`true` for live tradable events) |
| `closed` | Filter by closed status |
| `limit` | Results per page |
| `offset` | Number of results to skip for pagination |
Markets are resolved via UMA's Optimistic Oracle. Monitor resolution events for risk management.
```bash theme={null}
# Get the highest volume active events
curl "https://gamma-api.polymarket.com/events?active=true&closed=false&order=volume_24hr&ascending=false&limit=100"
```
See [Resolution](/developers/resolution/UMA) for details on the resolution process.
***
## Related Documentation
## Pagination
<CardGroup cols={3}>
<Card title="WebSocket Overview" icon="plug" href="/developers/CLOB/websocket/wss-overview">
Complete WebSocket documentation
All list endpoints return paginated responses with `limit` and `offset` parameters:
```bash theme={null}
# Page 1: First 50 results
curl "https://gamma-api.polymarket.com/events?active=true&closed=false&limit=50&offset=0"
# Page 2: Next 50 results
curl "https://gamma-api.polymarket.com/events?active=true&closed=false&limit=50&offset=50"
# Page 3: Next 50 results
curl "https://gamma-api.polymarket.com/events?active=true&closed=false&limit=50&offset=100"
```
***
## Best Practices
1. **For individual markets:** Use the slug method for direct lookups
2. **For category browsing:** Use tag filtering to reduce API calls
3. **For complete market discovery:** Use the events endpoint with pagination
4. **Always include `active=true&closed=false`** unless you specifically need historical data
5. **Use the events endpoint** and work backwards — events contain their associated markets, reducing the number of API calls needed
***
## Next Steps
<CardGroup cols={2}>
<Card title="API Reference" icon="code" href="/api-reference/introduction">
Full endpoint documentation with parameters and response schemas.
</Card>
<Card title="Gamma API" icon="database" href="/developers/gamma-markets-api/overview">
Market metadata and indexing
</Card>
<Card title="Resolution" icon="gavel" href="/developers/resolution/UMA">
UMA Oracle resolution process
<Card title="Subgraph" icon="share-nodes" href="/market-data/subgraph">
Query onchain data directly from the Polymarket subgraph.
</Card>
</CardGroup>
+61 -54
View File
@@ -2,74 +2,81 @@
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
> Use this file to discover all available pages before exploring further.
# Market Maker Introduction
# Overview
> Overview of market making on Polymarket and available tools for liquidity providers
> Market making on Polymarket
## What is a Market Maker?
A Market Maker (MM) on Polymarket is a trader who provides liquidity to prediction markets by continuously posting bid and ask orders. By laying the spread, market makers enable other users to trade efficiently while earning the spread as compensation for the risk they take.
A Market Maker (MM) on Polymarket is a sophisticated trader who provides liquidity to prediction markets by continuously posting bid and ask orders. By "laying the spread," market makers enable other users to trade efficiently while earning the spread as compensation for the risk they take.
Market makers are essential to Polymarket's ecosystem — they provide liquidity across markets, tighten spreads for better user experience, enable price discovery through continuous quoting, and absorb trading flow from retail and institutional users.
Market makers are essential to Polymarket's ecosystem:
<Note>
**Not a Market Maker?** If you're building an application that routes orders
for your users, see the [Builder Program](/builders/overview) instead.
</Note>
* **Provide liquidity** across all markets
* **Tighten spreads** for better user experience
* **Enable price discovery** through continuous quoting
* **Absorb trading flow** from retail and institutional users
**Not a Market Maker?** If you're building an application that routes orders for your
users, see the [Builders Program](/developers/builders/builder-intro) instead. Builders
get access to gasless transactions via the Relayer Client.
***
## Getting Started
To become a market maker on Polymarket:
<Steps>
<Step title="Complete Setup">
Deploy wallets, fund with USDC.e, and set token approvals. See the [Getting
Started](/market-makers/getting-started) guide.
</Step>
1. **Complete setup** - Deploy wallets, fund with USDCe, set token approvals
2. **Connect to data feeds** - WebSocket for orderbook, RTDS for low-latency data
3. **Start quoting** - Post orders via CLOB REST API
<Step title="Connect to Data Feeds">
WebSocket for real-time orderbook updates, Gamma API for market metadata.
See [Market Data](/market-data/overview).
</Step>
## Available Tools
<Step title="Start Quoting">
Post orders via the CLOB REST API. See [Trading ](/market-makers/trading).
</Step>
</Steps>
### By Action Type
<CardGroup cols={2}>
<Card title="Setup" icon="gear" href="/developers/market-makers/setup">
Deposits, token approvals, wallet deployment, API keys
</Card>
<Card title="Trading" icon="chart-line" href="/developers/market-makers/trading">
CLOB order entry, order types, quoting best practices
</Card>
<Card title="Data Feeds" icon="database" href="/developers/market-makers/data-feeds">
WebSocket, RTDS, Gamma API, on-chain data
</Card>
<Card title="Inventory Management" icon="boxes-stacked" href="/developers/market-makers/inventory">
Split, merge, and redeem outcome tokens
</Card>
<Card title="Liquidity Rewards" icon="gift" href="/developers/market-makers/liquidity-rewards">
Earn rewards for providing liquidity
</Card>
<Card title="Maker Rebates Program" icon="gift" href="/developers/market-makers/maker-rebates-program">
Earn rebates for providing liquidity
</Card>
</CardGroup>
***
## Quick Reference
| Action | Tool | Documentation |
| --------------------- | -------------- | ------------------------------------------------------------- |
| Deposit USDCe | Bridge API | [Bridge Overview](/developers/misc-endpoints/bridge-overview) |
| Approve tokens | Relayer Client | [Setup Guide](/developers/market-makers/setup) |
| Post limit orders | CLOB REST API | [CLOB Client](/developers/CLOB/clients/methods-l2) |
| Monitor orderbook | WebSocket | [WebSocket Overview](/developers/CLOB/websocket/wss-overview) |
| Low-latency data | RTDS | [Data Feeds](/developers/market-makers/data-feeds) |
| Split USDCe to tokens | CTF / Relayer | [Inventory](/developers/market-makers/inventory) |
| Merge tokens to USDCe | CTF / Relayer | [Inventory](/developers/market-makers/inventory) |
| Action | Tool | Documentation |
| ---------------------- | -------------- | ------------------------------------------------- |
| Deposit USDC.e | Bridge API | [Bridge](/trading/bridge/deposit) |
| Approve tokens | Relayer Client | [Getting Started](/market-makers/getting-started) |
| Post limit orders | CLOB REST API | [Create Orders](/trading/orders/create) |
| Monitor orderbook | WebSocket | [WebSocket](/market-data/websocket/overview) |
| Split USDC.e to tokens | CTF / Relayer | [Inventory](/market-makers/inventory) |
| Merge tokens to USDC.e | CTF / Relayer | [Inventory](/market-makers/inventory) |
***
## What's in This Section
<CardGroup cols={2}>
<Card title="Getting Started" icon="gear" href="/market-makers/getting-started">
Deposits, token approvals, wallet deployment, API keys
</Card>
<Card title="Trading" icon="chart-line" href="/market-makers/trading">
Quoting best practices, strategies, and risk controls
</Card>
<Card title="Inventory Management" icon="boxes-stacked" href="/market-makers/inventory">
Split, merge, and redeem outcome tokens
</Card>
<Card title="Liquidity Rewards" icon="gift" href="/market-makers/liquidity-rewards">
Earn rewards for providing liquidity
</Card>
</CardGroup>
## Risks
<Warning>
Be careful with spread management — if your bid price is higher than your ask
price (a "negative spread" or "crossed market"), you will lose money on every
fill. Always validate your quote prices before submission.
</Warning>
## Support
-247
View File
@@ -1,247 +0,0 @@
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
> Use this file to discover all available pages before exploring further.
# Inventory Management
> Split, merge, and redeem outcome tokens for market making
## Overview
Market makers need to manage their inventory of outcome tokens. This involves:
1. **Splitting** USDCe into YES/NO tokens to have inventory to quote
2. **Merging** tokens back to USDCe to reduce exposure
3. **Redeeming** winning tokens after market resolution
All these operations use the Conditional Token Framework (CTF) contract, typically via the Relayer Client for gasless execution.
<Note>
These examples assume you have initialized a RelayClient. See [Setup](/developers/market-makers/setup) for client initialization.
</Note>
## Splitting USDCe into Tokens
Split 1 USDCe into 1 YES + 1 NO token. This creates inventory for quoting both sides.
### Via Relayer Client (Recommended)
```typescript theme={null}
import { ethers } from "ethers";
import { Interface } from "ethers/lib/utils";
import { RelayClient, Transaction } from "@polymarket/builder-relayer-client";
const CTF_ADDRESS = "0x4d97dcd97ec945f40cf65f87097ace5ea0476045";
const USDCe_ADDRESS = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
const ctfInterface = new Interface([
"function splitPosition(address collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint[] partition, uint amount)"
]);
// Split $1000 USDCe into YES/NO tokens
const amount = ethers.utils.parseUnits("1000", 6); // USDCe has 6 decimals
const splitTx: Transaction = {
to: CTF_ADDRESS,
data: ctfInterface.encodeFunctionData("splitPosition", [
USDCe_ADDRESS, // collateralToken
ethers.constants.HashZero, // parentCollectionId (null for Polymarket)
conditionId, // conditionId from market
[1, 2], // partition: [YES, NO]
amount
]),
value: "0"
};
const response = await client.execute([splitTx], "Split USDCe into tokens");
const result = await response.wait();
console.log("Split completed:", result?.transactionHash);
```
### Result
After splitting 1000 USDCe:
* Receive 1000 YES tokens
* Receive 1000 NO tokens
* USDCe balance decreases by 1000
## Merging Tokens to USDCe
Merge equal amounts of YES + NO tokens back into USDCe. Useful for:
* Reducing inventory
* Exiting a market
* Converting profits to USDCe
### Via Relayer Client
```typescript theme={null}
const ctfInterface = new Interface([
"function mergePositions(address collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint[] partition, uint amount)"
]);
// Merge 500 YES + 500 NO back to 500 USDCe
const amount = ethers.utils.parseUnits("500", 6);
const mergeTx: Transaction = {
to: CTF_ADDRESS,
data: ctfInterface.encodeFunctionData("mergePositions", [
USDCe_ADDRESS,
ethers.constants.HashZero,
conditionId,
[1, 2],
amount
]),
value: "0"
};
const response = await client.execute([mergeTx], "Merge tokens to USDCe");
await response.wait();
```
### Result
After merging 500 of each:
* YES tokens decrease by 500
* NO tokens decrease by 500
* USDCe balance increases by 500
## Redeeming After Resolution
After a market resolves, redeem winning tokens for USDCe.
### Check Resolution Status
```typescript theme={null}
// Via CLOB API
const market = await clobClient.getMarket(conditionId);
if (market.closed) {
// Market is resolved
const winningToken = market.tokens.find(t => t.winner);
console.log("Winning outcome:", winningToken?.outcome);
}
```
### Redeem Winning Tokens
```typescript theme={null}
const ctfInterface = new Interface([
"function redeemPositions(address collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint[] indexSets)"
]);
const redeemTx: Transaction = {
to: CTF_ADDRESS,
data: ctfInterface.encodeFunctionData("redeemPositions", [
USDCe_ADDRESS,
ethers.constants.HashZero,
conditionId,
[1, 2] // Redeem both YES and NO (only winners pay out)
]),
value: "0"
};
const response = await client.execute([redeemTx], "Redeem winning tokens");
await response.wait();
```
### Payout
* If YES wins: Each YES token redeems for \$1 USDCe
* If NO wins: Each NO token redeems for \$1 USDCe
* Losing tokens are worthless (redeem for \$0)
## Negative Risk Markets
Multi-outcome markets use the Negative Risk CTF Exchange. The split/merge process is similar but uses different contract addresses.
```typescript theme={null}
const NEG_RISK_ADAPTER = "0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296";
const NEG_RISK_CTF_EXCHANGE = "0xC5d563A36AE78145C45a50134d48A1215220f80a";
```
See [Negative Risk Overview](/developers/neg-risk/overview) for details.
## Inventory Strategies
### Pre-market Preparation
Before quoting a market:
1. Check market metadata via Gamma API
2. Split sufficient USDCe to cover expected quoting size
3. Set token approvals if not already done
### During Trading
Monitor inventory and adjust:
* Skew quotes when inventory is imbalanced
* Merge excess tokens to free up capital
* Split more when inventory runs low
### Post-Resolution
After market closes:
1. Cancel all open orders
2. Wait for resolution
3. Redeem winning tokens
4. Merge any remaining pairs
## Batch Operations
For efficiency, batch multiple operations:
```typescript theme={null}
const transactions: Transaction[] = [
// Split on Market A
{
to: CTF_ADDRESS,
data: ctfInterface.encodeFunctionData("splitPosition", [
USDCe_ADDRESS,
ethers.constants.HashZero,
conditionIdA,
[1, 2],
ethers.utils.parseUnits("1000", 6)
]),
value: "0"
},
// Split on Market B
{
to: CTF_ADDRESS,
data: ctfInterface.encodeFunctionData("splitPosition", [
USDCe_ADDRESS,
ethers.constants.HashZero,
conditionIdB,
[1, 2],
ethers.utils.parseUnits("1000", 6)
]),
value: "0"
}
];
const response = await client.execute(transactions, "Batch inventory setup");
await response.wait();
```
## Related Documentation
<CardGroup cols={2}>
<Card title="CTF Overview" icon="coins" href="/developers/CTF/overview">
Conditional Token Framework basics
</Card>
<Card title="Split Positions" icon="code-branch" href="/developers/CTF/split">
Detailed split documentation
</Card>
<Card title="Merge Positions" icon="code-merge" href="/developers/CTF/merge">
Detailed merge documentation
</Card>
<Card title="Relayer Client" icon="paper-plane" href="/developers/builders/relayer-client">
Gasless transaction execution
</Card>
</CardGroup>
@@ -1,126 +0,0 @@
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
> Use this file to discover all available pages before exploring further.
# Liquidity Rewards
> Polymarket provides incentives aimed at catalyzing the supply and demand side of the marketplace. Specifically there is a public liquidity rewards program as well as one-off public pnl/volume competitions.
## Overview
By posting resting limit orders, liquidity providers (makers) are automatically eligible for Polymarket's incentive program. The overall goal of this program is to catalyze a healthy, liquid marketplace. We can further define this as creating incentives that:
* Catalyze liquidity across all markets
* Encourage liquidity throughout a market's entire lifecycle
* Motivate passive, balanced quoting tight to a market's mid-point
* Encourages trading activity
* Discourages blatantly exploitative behaviors
This program is heavily inspired by dYdX's liquidity provider rewards which you can read more about [here](https://www.dydx.foundation/blog/liquidity-provider-rewards). In fact, the incentive methodology is essentially a copy of dYdX's successful methodology but with some adjustments including specific adaptations for binary contract markets with distinct books, no staking mechanic a slightly modified order utility-relative depth function and reward amounts isolated per market. Rewards are distributed directly to the maker's addresses daily at midnight UTC.
## Methodology
Polymarket liquidity providers will be rewarded based on a formula that rewards participation in markets (complementary consideration!), boosts two-sided depth (single-sided orders still score), and spread (vs. mid-market, adjusted for the size cutoff!). Each market still configure a max spread and min size cutoff within which orders are considered the average of rewards earned is determined by the relative share of each participant's Q<sub>n</sub> in market m.
| Variable | Description |
| -------------- | ---------------------------------------------------------------- |
| \$ | order position scoring function |
| v | max spread from midpoint (in cents) |
| s | spread from size-cutoff-adjusted midpoint |
| b | in-game multiplier |
| m | market |
| m' | market complement (i.e NO if m = YES) |
| n | trader index |
| u | sample index |
| c | scaling factor (currently 3.0 on all markets) |
| Q<sub>ne</sub> | point total for book one for a sample |
| Q<sub>no</sub> | point total for book two for a sample |
| Spread% | distance from midpoint (bps or relative) for order n in market m |
| BidSize | share-denominated quantity of bid |
| AskSize | share-denominated quantity of ask |
## Equations
**Equation 1:**
$S(v,s)= (\frac{v-s}{v})^2 \cdot b$
**Equation 2:**
$Q_{one}= S(v,Spread_{m_1}) \cdot BidSize_{m_1} + S(v,Spread_{m_2}) \cdot BidSize_{m_2} + \dots $
$ + S(v, Spread_{m^\prime_1}) \cdot AskSize_{m^\prime_1} + S(v, Spread_{m^\prime_2}) \cdot AskSize_{m^\prime_2}$
**Equation 3:**
$Q_{two}= S(v,Spread_{m_1}) \cdot AskSize_{m_1} + S(v,Spread_{m_2}) \cdot AskSize_{m_2} + \dots $
$ + S(v, Spread_{m^\prime_1}) \cdot BidSize_{m^\prime_1} + S(v, Spread_{m^\prime_2}) \cdot BidSize_{m^\prime_2}$
**Equation 4:**
**Equation 4a:**
If midpoint is in range \[0.10,0.90] allow single sided liq to score:
$Q_{\min} = \max(\min({Q_{one}, Q_{two}}), \max(Q_{one}/c, Q_{two}/c))$
**Equation 4b:**
If midpoint is in either range \[0,0.10) or (.90,1.0] require liq to be double sided to score:
$Q_{\min} = \min({Q_{one}, Q_{two}})$
**Equation 5:**
$Q_{normal} = \frac{Q_{min}}{\sum_{n=1}^{N}{(Q_{min})_n}}$
**Equation 6:**
$Q_{epoch} = \sum_{u=1}^{10,080}{(Q_{normal})_u}$
**Equation 7:**
$Q_{final}=\frac{Q_{epoch}}{\sum_{n=1}^{N}{(Q_{epoch})_n}}$
## Steps
1. Quadratic scoring rule for an order based on position between the adjusted midpoint and the minimum qualifying spread
2. Calculate first market side score. Assume a trader has the following open orders:
* 100Q bid on m @0.49 (adjusted midpoint is 0.50 then spread of this order is 0.01 or 1c)
* 200Q bid on m @0.48
* 100Q ask on m' @0.51
and assume an adjusted market midpoint of 0.50 and maxSpread config of 3c for both m and m'. Then the trader's score is:
$$
Q_{ne} = \left( \frac{(3-1)}{3} \right)^2 \cdot 100 + \left( \frac{(3-2)}{3} \right)^2 \cdot 200 + \left( \frac{(3-1)}{3} \right)^2 \cdot 100
$$
$Q_{ne}$ is calculated every minute using random sampling
3. Calculate second market side score. Assume a trader has the following open orders:
* 100Q bid on m @0.485
* 100Q bid on m' @0.48
* 200Q ask on m' @0.505
and assume an adjusted market midpoint of 0.50 and maxSpread config of 3c for both m and m'. Then the trader's score is:
$$
Q_{no} = \left( \frac{(3-1.5)}{3} \right)^2 \cdot 100 + \left( \frac{(3-2)}{3} \right)^2 \cdot 100 + \left( \frac{(3-.5)}{3} \right)^2 \cdot 200
$$
$Q_{no}$ is calculated every minute using random sampling
4. Boosts 2-sided liquidity by taking the minimum of $Q_{ne}$ and $Q_{no}$, and rewards 1-side liquidity at a reduced rate (divided by c)
Calculated every minute
5. $Q_{normal}$ is the $Q_{min}$ of a market maker divided by the sum of all the $Q_{min}$ of other market makers in a given sample
6. $Q_{epoch}$ is the sum of all $Q_{normal}$ for a trader in a given epoch
7. $Q_{final}$ normalizes $Q_{epoch}$ by dividing it by the sum of all other market maker's $Q_{epoch}$ in a given epoch this value is multiplied by the rewards available for the market to get a trader's reward
<Tip>Both min\_incentive\_size and max\_incentive\_spread can be fetched alongside full market objects via both the CLOB API and Markets API. Reward allocations for an epoch can be fetched via the Markets API. </Tip>
@@ -1,248 +0,0 @@
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
> Use this file to discover all available pages before exploring further.
# Maker Rebates Program
> Technical guide for handling taker fees and earning maker rebates on Polymarket
Polymarket has enabled taker fees on **15-minute crypto markets**, **5-minute crypto markets**, **NCAAB (college basketball)**, and **Serie A** markets.
These fees fund a Maker Rebates program that pays daily USDC rebates to liquidity providers.
<Note>
Starting **Wednesday, February 18th, 2026 at midnight (UTC)**, taker fees and maker rebates will apply to all **new** NCAAB and Serie A markets created after that time. Existing markets are not affected. The first payout will be on February 19th at midnight (UTC).
</Note>
## Fee Handling by Implementation Type
### Option 1: Official CLOB Clients (Recommended)
The official CLOB clients **automatically handle fees** for you
<Card title="TypeScript Client" icon="js" href="https://github.com/Polymarket/clob-client">
npm install @polymarket/clob-client\@latest
</Card>
<CardGroup cols={2}>
<Card title="Python Client" icon="python" href="https://github.com/Polymarket/py-clob-client">
pip install --upgrade py-clob-client
</Card>
<Card title="Rust Client" icon="rust" href="https://github.com/Polymarket/rs-clob-client">
cargo add polymarket-client-sdk
</Card>
</CardGroup>
**What the client does automatically:**
1. Fetches the fee rate for the market's token ID
2. Includes `feeRateBps` in the order structure
3. Signs the order with the fee rate included
**You don't need to do anything extra**. Your orders will work on fee-enabled markets.
***
### Option 2: REST API / Custom Implementations
If you're calling the REST API directly or building your own order signing, you must manually include the fee rate in your signed order payload.
#### Step 1: Fetch the Fee Rate
Query the fee rate for the token ID before creating your order:
```bash theme={null}
GET https://clob.polymarket.com/fee-rate?token_id={token_id}
```
**Response:**
```json theme={null}
{
"fee_rate_bps": 1000
}
```
* **Fee-enabled markets** return a value like `1000`
* **Fee-free markets** return `0`
#### Step 2: Include in Your Signed Order
Add the `feeRateBps` field to your order object. This value is part of the signed payload, the CLOB validates your signature against it.
```json theme={null}
{
"salt": "12345",
"maker": "0x...",
"signer": "0x...",
"taker": "0x...",
"tokenId": "71321045679252212594626385532706912750332728571942532289631379312455583992563",
"makerAmount": "50000000",
"takerAmount": "100000000",
"expiration": "0",
"nonce": "0",
"feeRateBps": "1000",
"side": "0",
"signatureType": 2,
"signature": "0x..."
}
```
#### Step 3: Sign and Submit
1. Include `feeRateBps` in the order object **before signing**
2. Sign the complete order
3. POST to `/order` endpoint
<Note>
**Important:** Always fetch `fee_rate_bps` dynamically, do not hardcode. The fee rate varies by market type and may change over time. You only need to pass `feeRateBps`
</Note>
See the [Create Order documentation](/developers/CLOB/orders/create-order) for full signing details.
***
## Fee Behavior
Fees are calculated using the following formula:
```text theme={null}
fee = C × p × feeRate × (p × (1 - p))^exponent
```
Where **C** = number of shares traded and **p** = price of the shares. The fee parameters differ by market type:
| Parameter | Sports (NCAAB, Serie A) | 5-Min & 15-Min Crypto |
| -------------- | ----------------------- | --------------------- |
| Fee Rate | 0.0175 | 0.25 |
| Exponent | 1 | 2 |
| Maker Rebate % | 25% | 20% |
Taker fees are calculated in USDC and vary based on the share price. However, fees are collected in shares on buy orders and USDC on sell orders.
The effective rate **peaks at 50%** probability and decreases symmetrically toward the extremes.
<img src="https://mintcdn.com/polymarket-292d1b1b/12mKTb6PQ_jJnYbI/polymarket-learn/media/fee_image_review.png?fit=max&auto=format&n=12mKTb6PQ_jJnYbI&q=85&s=9e5b1d1a262fb6c787af5b6a0fa4d6c2" alt="Fee Curves" data-og-width="1484" width="1484" data-og-height="882" height="882" data-path="polymarket-learn/media/fee_image_review.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/polymarket-292d1b1b/12mKTb6PQ_jJnYbI/polymarket-learn/media/fee_image_review.png?w=280&fit=max&auto=format&n=12mKTb6PQ_jJnYbI&q=85&s=111b6dc97e2b301501c02e2df5e3df35 280w, https://mintcdn.com/polymarket-292d1b1b/12mKTb6PQ_jJnYbI/polymarket-learn/media/fee_image_review.png?w=560&fit=max&auto=format&n=12mKTb6PQ_jJnYbI&q=85&s=063f99ef8ec728e399a7cd0b27e704a0 560w, https://mintcdn.com/polymarket-292d1b1b/12mKTb6PQ_jJnYbI/polymarket-learn/media/fee_image_review.png?w=840&fit=max&auto=format&n=12mKTb6PQ_jJnYbI&q=85&s=c7d74e4ca10bd953f1f08a9851017f3c 840w, https://mintcdn.com/polymarket-292d1b1b/12mKTb6PQ_jJnYbI/polymarket-learn/media/fee_image_review.png?w=1100&fit=max&auto=format&n=12mKTb6PQ_jJnYbI&q=85&s=bc3dbf551ae32d6c4e7d85558831fb1f 1100w, https://mintcdn.com/polymarket-292d1b1b/12mKTb6PQ_jJnYbI/polymarket-learn/media/fee_image_review.png?w=1650&fit=max&auto=format&n=12mKTb6PQ_jJnYbI&q=85&s=d082a6e2029bc3f4797d758d689e2c37 1650w, https://mintcdn.com/polymarket-292d1b1b/12mKTb6PQ_jJnYbI/polymarket-learn/media/fee_image_review.png?w=2500&fit=max&auto=format&n=12mKTb6PQ_jJnYbI&q=85&s=417d0c9a66a64d31588d15c908cebf39 2500w" />
### Fee Table (100 shares)
<Tabs>
<Tab title="5-Min & 15-Min Crypto">
| Price | Trade Value | Fee (USDC) | Effective Rate |
| ------ | ----------- | ---------- | -------------- |
| \$0.01 | \$1 | \$0.00 | 0.00% |
| \$0.05 | \$5 | \$0.003 | 0.06% |
| \$0.10 | \$10 | \$0.02 | 0.20% |
| \$0.15 | \$15 | \$0.06 | 0.41% |
| \$0.20 | \$20 | \$0.13 | 0.64% |
| \$0.25 | \$25 | \$0.22 | 0.88% |
| \$0.30 | \$30 | \$0.33 | 1.10% |
| \$0.35 | \$35 | \$0.45 | 1.29% |
| \$0.40 | \$40 | \$0.58 | 1.44% |
| \$0.45 | \$45 | \$0.69 | 1.53% |
| \$0.50 | \$50 | \$0.78 | **1.56%** |
| \$0.55 | \$55 | \$0.84 | 1.53% |
| \$0.60 | \$60 | \$0.86 | 1.44% |
| \$0.65 | \$65 | \$0.84 | 1.29% |
| \$0.70 | \$70 | \$0.77 | 1.10% |
| \$0.75 | \$75 | \$0.66 | 0.88% |
| \$0.80 | \$80 | \$0.51 | 0.64% |
| \$0.85 | \$85 | \$0.35 | 0.41% |
| \$0.90 | \$90 | \$0.18 | 0.20% |
| \$0.95 | \$95 | \$0.05 | 0.06% |
| \$0.99 | \$99 | \$0.00 | 0.00% |
The maximum effective fee rate is **1.56%** at 50% probability. Fees decrease symmetrically toward both extremes.
</Tab>
<Tab title="Sports (NCAAB, Serie A)">
| Price | Trade Value | Fee (USDC) | Effective Rate |
| ------ | ----------- | ---------- | -------------- |
| \$0.01 | \$1 | \$0.00 | 0.02% |
| \$0.05 | \$5 | \$0.00 | 0.08% |
| \$0.10 | \$10 | \$0.02 | 0.16% |
| \$0.15 | \$15 | \$0.03 | 0.22% |
| \$0.20 | \$20 | \$0.06 | 0.28% |
| \$0.25 | \$25 | \$0.08 | 0.33% |
| \$0.30 | \$30 | \$0.11 | 0.37% |
| \$0.35 | \$35 | \$0.14 | 0.40% |
| \$0.40 | \$40 | \$0.17 | 0.42% |
| \$0.45 | \$45 | \$0.19 | 0.43% |
| \$0.50 | \$50 | \$0.22 | **0.44%** |
| \$0.55 | \$55 | \$0.24 | 0.43% |
| \$0.60 | \$60 | \$0.25 | 0.42% |
| \$0.65 | \$65 | \$0.26 | 0.40% |
| \$0.70 | \$70 | \$0.26 | 0.37% |
| \$0.75 | \$75 | \$0.25 | 0.33% |
| \$0.80 | \$80 | \$0.22 | 0.28% |
| \$0.85 | \$85 | \$0.19 | 0.22% |
| \$0.90 | \$90 | \$0.14 | 0.16% |
| \$0.95 | \$95 | \$0.08 | 0.08% |
| \$0.99 | \$99 | \$0.02 | 0.02% |
The maximum effective fee rate is **0.44%** at 50% probability. Fees decrease symmetrically toward both extremes.
</Tab>
</Tabs>
***
## Maker Rebates
Your rebate for each market:
```text theme={null}
fee_equivalent = C × p × feeRate × (p × (1 - p))^exponent
rebate = (your_fee_equivalent / total_fee_equivalent) * rebate_pool
```
### How Rebates Work
* **Eligibility:** Your orders must add liquidity (maker orders) and get filled
* **Calculation:** Proportional to your share of executed maker volume in each eligible market. Totals are calculated per market, so you only compete with other makers in the same market
* **Fee collection:** Fees are calculated in USDC but collected in shares on buy orders and USDC on sell orders
* **Payment:** Daily in USDC, paid directly to your wallet
### Rebate Pool
Each market's rebate pool is funded by taker fees collected in that market. The payout percentage is subject to change:
| Market Type | Period | Maker Rebate | Distribution Method |
| ----------------------- | ------------- | ------------ | ------------------- |
| 15-Min Crypto | Jan 19, 2026+ | 20% | Fee-curve weighted |
| 5-Min Crypto | Feb 12, 2026+ | 20% | Fee-curve weighted |
| Sports (NCAAB, Serie A) | Feb 18, 2026+ | 25% | Fee-curve weighted |
The rebate percentage is at the sole discretion of Polymarket and may change over time.
***
## Which Markets Have Fees?
The following market types have fees enabled:
* **15-minute crypto markets**
* **5-minute crypto markets**
* **NCAAB (college basketball) markets** (starting February 18, 2026 for new markets)
* **Serie A markets** (starting February 18, 2026 for new markets)
Query the fee-rate endpoint to check any specific market:
```bash theme={null}
GET https://clob.polymarket.com/fee-rate?token_id={token_id}
# Fee-enabled: { "fee_rate_bps": 1000 }
# Fee-free: { "fee_rate_bps": 0 }
```
***
## Related Documentation
<CardGroup cols={2}>
<Card title="Maker Rebates Program" icon="coins" href="/polymarket-learn/trading/maker-rebates-program">
User-facing overview with full fee tables
</Card>
<Card title="Create CLOB Order via REST API" icon="code" href="/developers/CLOB/orders/create-order">
Full order structure and signing documentation
</Card>
</CardGroup>
+179 -123
View File
@@ -2,175 +2,231 @@
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
> Use this file to discover all available pages before exploring further.
# Setup
# Getting Started
> One-time setup for market making on Polymarket: deposits, approvals, wallets, and API keys
> One-time setup for market making on Polymarket
## Overview
Before you can start market making, you need to complete these one-time setup steps — deposit USDC.e to Polygon, deploy a wallet, approve tokens for trading, and generate API credentials.
Before you can start market making on Polymarket, you need to complete these one-time setup steps:
<Steps>
<Step title="Deposit USDC.e">
Market makers need USDC.e on Polygon to fund their trading operations.
1. Deposit bridged USDCe to Polygon
2. Deploy a wallet (EOA or Safe)
3. Approve tokens for trading
4. Generate API credentials
| Method | Best For | Documentation |
| ----------------------- | ------------------------------------ | ---------------------------------------------------- |
| Bridge API | Automated deposits from other chains | [Bridge Deposit](/trading/bridge/deposit) |
| Direct Polygon transfer | Already have USDC.e on Polygon | N/A |
| Cross-chain bridge | Large deposits from Ethereum | [Supported Assets](/trading/bridge/supported-assets) |
## Deposit USDCe
### Using the Bridge API
Market makers need USDCe on Polygon to fund their trading operations.
```typescript theme={null}
// Get deposit addresses for your Polymarket wallet
const deposit = await fetch("https://bridge.polymarket.com/deposit", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
address: "YOUR_POLYMARKET_WALLET_ADDRESS",
}),
});
### Options
// Returns deposit addresses for EVM, SVM, and BTC networks
const addresses = await deposit.json();
// Send USDC to the appropriate address for your source chain
```
</Step>
| Method | Best For | Documentation |
| ----------------------- | ------------------------------------ | ----------------------------------------------------------------------- |
| Bridge API | Automated deposits from other chains | [Bridge Overview](/developers/misc-endpoints/bridge-overview) |
| Direct Polygon transfer | Already have USDCe on Polygon | N/A |
| Cross-chain bridge | Large deposits from Ethereum | [Large Deposits](/polymarket-learn/deposits/large-cross-chain-deposits) |
<Step title="Deploy a Wallet">
### EOA (Externally Owned Account)
### Using the Bridge API
Standard Ethereum wallet. You pay for all onchain transactions (approvals, splits, merges, trade execution).
```typescript theme={null}
// Deposit USDCe from Ethereum to Polygon
const deposit = await fetch("https://clob.polymarket.com/deposit", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
chainId: "1",
fromChain: "ethereum",
toChain: "polygon",
asset: "USDCe",
amount: "100000000000" // $100,000 in USDCe (6 decimals)
})
});
```
### Safe Wallet (Recommended)
See [Bridge Deposit](/api-reference/bridge/create-deposit-addresses) for full API details.
Gnosis Safe-based wallet deployed via Polymarket's relayer. Benefits:
## Wallet Options
* **Gasless transactions** — Polymarket pays gas fees for onchain operations
* **Contract wallet** — Enables advanced features like batched transactions
### EOA (Externally Owned Account)
Deploy a Safe wallet using the Relayer Client:
Standard Ethereum wallet. You pay for all onchain transactions (approvals, splits, merges, trade exedcution).
<CodeGroup>
```typescript TypeScript theme={null}
import { RelayClient, RelayerTxType } from "@polymarket/builder-relayer-client";
### Safe Wallet (Recommended)
const client = new RelayClient(
"https://relayer-v2.polymarket.com/",
137, // Polygon mainnet
signer,
builderConfig,
RelayerTxType.SAFE,
);
Gnosis Safe-based wallet deployed via Polymarket's relayer. Benefits:
// Deploy the Safe wallet
const response = await client.deploy();
const result = await response.wait();
console.log("Safe Address:", result?.proxyAddress);
```
* **Gasless transactions** - Polymarket pays gas fees for onchain operations
* **Contract wallet** - Enables advanced features like batched transactions.
```python Python theme={null}
from py_builder_relayer_client.client import RelayClient
Deploy a Safe wallet using the [Relayer Client](/developers/builders/relayer-client):
# client initialized with builder_config
```typescript theme={null}
import { RelayClient, RelayerTxType } from "@polymarket/builder-relayer-client";
# Deploy the Safe wallet
response = client.deploy()
result = response.wait()
print("Safe Address:", result.get("proxyAddress"))
```
</CodeGroup>
const client = new RelayClient(
"https://relayer-v2.polymarket.com/",
137, // Polygon mainnet
signer,
builderConfig,
RelayerTxType.SAFE
);
<Info>
See [Gasless Transactions](/trading/gasless) for full Relayer Client setup
including local and remote signing configurations.
</Info>
</Step>
// Deploy the Safe wallet
const response = await client.deploy();
const result = await response.wait();
console.log("Safe Address:", result?.proxyAddress);
```
<Step title="Approve Tokens">
Before trading, you must approve the exchange contracts to spend your tokens.
## Token Approvals
### Required Approvals
Before trading, you must approve the exchange contracts to spend your tokens.
| Token | Spender | Purpose |
| -------------------- | --------------------- | -------------------------------- |
| USDC.e | CTF Contract | Split USDC.e into outcome tokens |
| CTF (outcome tokens) | CTF Exchange | Trade outcome tokens |
| CTF (outcome tokens) | Neg Risk CTF Exchange | Trade neg-risk market tokens |
### Required Approvals
### Contract Addresses (Polygon Mainnet)
| Token | Spender | Purpose |
| -------------------- | --------------------- | ------------------------------- |
| USDCe | CTF Contract | Split USDCe into outcome tokens |
| CTF (outcome tokens) | CTF Exchange | Trade outcome tokens |
| CTF (outcome tokens) | Neg Risk CTF Exchange | Trade neg-risk market tokens |
```typescript theme={null}
const ADDRESSES = {
USDCe: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
CTF: "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045",
CTF_EXCHANGE: "0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E",
NEG_RISK_CTF_EXCHANGE: "0xC5d563A36AE78145C45a50134d48A1215220f80a",
NEG_RISK_ADAPTER: "0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296",
};
```
### Contract Addresses (Polygon Mainnet)
### Approve via Relayer Client
```typescript theme={null}
const ADDRESSES = {
USDCe: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
CTF: "0x4d97dcd97ec945f40cf65f87097ace5ea0476045",
CTF_EXCHANGE: "0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E",
NEG_RISK_CTF_EXCHANGE: "0xC5d563A36AE78145C45a50134d48A1215220f80a",
NEG_RISK_ADAPTER: "0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296"
};
```
<CodeGroup>
```typescript TypeScript theme={null}
import { ethers } from "ethers";
import { Interface } from "ethers/lib/utils";
### Approve via Relayer Client
const erc20Interface = new Interface([
"function approve(address spender, uint256 amount) returns (bool)",
]);
```typescript theme={null}
import { ethers } from "ethers";
import { Interface } from "ethers/lib/utils";
// Approve USDCe for CTF contract
const approveTx = {
to: ADDRESSES.USDCe,
data: erc20Interface.encodeFunctionData("approve", [
ADDRESSES.CTF,
ethers.constants.MaxUint256,
]),
value: "0",
};
const erc20Interface = new Interface([
"function approve(address spender, uint256 amount) returns (bool)"
]);
const response = await client.execute([approveTx], "Approve USDCe for CTF");
await response.wait();
```
// Approve USDCe for CTF contract
const approveTx = {
to: ADDRESSES.USDCe,
data: erc20Interface.encodeFunctionData("approve", [
ADDRESSES.CTF,
ethers.constants.MaxUint256
]),
value: "0"
};
```python Python theme={null}
from web3 import Web3
const response = await client.execute([approveTx], "Approve USDCe for CTF");
await response.wait();
```
USDC = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"
CTF = "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045"
MAX_UINT256 = 2**256 - 1
See [Relayer Client](/developers/builders/relayer-client) for complete examples.
approve_tx = {
"to": USDC,
"data": Web3().eth.contract(
address=USDC,
abi=[{
"name": "approve",
"type": "function",
"inputs": [
{"name": "spender", "type": "address"},
{"name": "amount", "type": "uint256"}
],
"outputs": [{"type": "bool"}]
}]
).encode_abi(abi_element_identifier="approve", args=[CTF, MAX_UINT256]),
"value": "0"
}
## API Key Generation
response = client.execute([approve_tx], "Approve USDC for CTF")
response.wait()
```
</CodeGroup>
</Step>
To place orders and access authenticated endpoints, you need L2 API credentials.
<Step title="Generate API Credentials">
To place orders and access authenticated endpoints, you need L2 API credentials derived from your wallet.
### Generate API Key
<CodeGroup>
```typescript TypeScript theme={null}
import { ClobClient } from "@polymarket/clob-client";
```typescript theme={null}
import { ClobClient } from "@polymarket/clob-client";
const client = new ClobClient("https://clob.polymarket.com", 137, signer);
const client = new ClobClient(
"https://clob.polymarket.com",
137,
signer
);
// Derive API credentials from your wallet
const credentials = await client.createOrDeriveApiKey();
console.log("API Key:", credentials.key);
console.log("Secret:", credentials.secret);
console.log("Passphrase:", credentials.passphrase);
```
// Derive API credentials from your wallet
const credentials = await client.deriveApiKey();
console.log("API Key:", credentials.key);
console.log("Secret:", credentials.secret);
console.log("Passphrase:", credentials.passphrase);
```
```python Python theme={null}
from py_clob_client.client import ClobClient
import os
### Using Credentials
private_key = os.getenv("PRIVATE_KEY")
Once you have credentials, initialize the client for authenticated operations:
temp_client = ClobClient("https://clob.polymarket.com", key=private_key, chain_id=137)
credentials = temp_client.create_or_derive_api_creds()
```
</CodeGroup>
```typescript theme={null}
const client = new ClobClient(
"https://clob.polymarket.com",
137,
wallet,
credentials
);
```
Once you have credentials, initialize the client for authenticated operations:
See [CLOB Authentication](/developers/CLOB/authentication) for full details.
<CodeGroup>
```typescript TypeScript theme={null}
const tradingClient = new ClobClient(
"https://clob.polymarket.com",
137,
wallet,
credentials,
);
```
```python Python theme={null}
client = ClobClient(
"https://clob.polymarket.com",
key=private_key,
chain_id=137,
creds=credentials,
)
```
</CodeGroup>
See [Authentication](/trading/overview#authentication) for full details on signature types and REST API headers.
</Step>
</Steps>
***
## Next Steps
Once setup is complete:
<CardGroup cols={1}>
<Card title="Start Trading" icon="chart-line" href="/developers/market-makers/trading">
<CardGroup cols={2}>
<Card title="Trading" icon="chart-line" href="/market-makers/trading">
Post limit orders and manage quotes
</Card>
<Card title="Market Data" icon="database" href="/market-data/overview">
Connect to real-time market data
</Card>
</CardGroup>
-203
View File
@@ -1,203 +0,0 @@
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
> Use this file to discover all available pages before exploring further.
# Trading
> CLOB order entry and management for market makers
## Overview
Market makers primarily interact with Polymarket through the CLOB (Central Limit Order Book) API to post and manage limit orders.
## Order Entry
### Posting Limit Orders
Use the CLOB client to create and post limit orders:
```typescript theme={null}
import { ClobClient, Side, OrderType } from "@polymarket/clob-client";
const client = new ClobClient(
"https://clob.polymarket.com",
137,
wallet,
credentials,
signatureType,
funder
);
// Post a bid (buy order)
const bidOrder = await client.createAndPostOrder({
tokenID: "34097058504275310827233323421517291090691602969494795225921954353603704046623",
side: Side.BUY,
price: 0.48,
size: 1000,
orderType: OrderType.GTC
});
// Post an ask (sell order)
const askOrder = await client.createAndPostOrder({
tokenID: "34097058504275310827233323421517291090691602969494795225921954353603704046623",
side: Side.SELL,
price: 0.52,
size: 1000,
orderType: OrderType.GTC
});
```
See [Create Order](/developers/CLOB/clients/methods-l1#createandpostorder) for full documentation.
### Batch Orders
For efficiency, post multiple orders in a single request:
```typescript theme={null}
const orders = await Promise.all([
client.createOrder({ tokenID, side: Side.BUY, price: 0.48, size: 500 }),
client.createOrder({ tokenID, side: Side.BUY, price: 0.47, size: 500 }),
client.createOrder({ tokenID, side: Side.SELL, price: 0.52, size: 500 }),
client.createOrder({ tokenID, side: Side.SELL, price: 0.53, size: 500 })
]);
const response = await client.postOrders(
orders.map(order => ({ order, orderType: OrderType.GTC }))
);
```
See [Post Orders Batch](/developers/CLOB/clients/methods-l2#postorders) for details.
## Order Types
| Type | Behavior | MM Use Case |
| ----------------------------- | --------------------------------------- | --------------------------------------- |
| **GTC** (Good Till Cancelled) | Rests on book until filled or cancelled | Default for passive quoting |
| **GTD** (Good Till Date) | Auto-expires at specified time | Auto-expire before events |
| **FOK** (Fill or Kill) | Fill entirely immediately or cancel | Aggressive rebalancing (all or nothing) |
| **FAK** (Fill and Kill) | Fill available immediately, cancel rest | Partial rebalancing acceptable |
### When to Use Each
**For passive market making (maker orders):**
* **GTC** - Standard quotes that sit on the book
* **GTD** - Time-limited quotes (e.g., expire before market close)
**For rebalancing (taker orders):**
* **FOK** - When you need exact size or nothing
* **FAK** - When partial fills are acceptable
```typescript theme={null}
// GTD example: expire in 1 hour
const expiringOrder = await client.createOrder({
tokenID,
side: Side.BUY,
price: 0.50,
size: 1000,
orderType: OrderType.GTD,
expiration: Math.floor(Date.now() / 1000) + 3600 // 1 hour from now
});
```
## Order Management
### Cancel Orders
Cancel individual orders or all orders:
```typescript theme={null}
// Cancel single order
await client.cancelOrder(orderId);
// Cancel multiple orders in a single calls
await client.cancelOrders(orderIds: string[]);
// Cancel all orders for a market
await client.cancelMarketOrders(conditionId);
// Cancel all orders
await client.cancelAll();
```
See [Cancel Orders](/developers/CLOB/clients/methods-l2#cancelorder) for full documentation.
### Get Active Orders
Monitor your open orders:
```typescript theme={null}
// Get active order
const order = await client.getOrder(orderId);
// Get active orders optionally filtered
const orders = await client.getOpenOrders({
id?: string; // Order ID (hash)
market?: string; // Market condition ID
asset_id?: string; // Token ID
});
```
See [Get Active Orders](/developers/CLOB/clients/methods-l2#getorder) for details.
## Best Practices
### Quote Management
1. **Two-sided quoting** - Post both bids and asks to earn maximum [liquidity rewards](/developers/market-makers/liquidity-rewards)
2. **Monitor inventory** - Skew quotes based on your position
3. **Cancel stale quotes** - Remove orders when market conditions change
4. **Use GTD for events** - Auto-expire quotes before known events
### Latency Optimization
1. **Batch orders** - Use `postOrders()` instead of multiple `createAndPostOrder()` calls
2. **WebSocket for data** - Use WebSocket feeds instead of polling REST endpoints
### Risk Management
1. **Size limits** - Check token balances before quoting; don't exceed inventory
2. **Price guards** - Validate against book midpoint; reject outlier prices
3. **Kill switch** - Use `cancelAll()` on error or position breach
4. **Monitor fills** - Subscribe to WebSocket user channel for real-time fill updates
## Tick Sizes
Markets have different minimum price increments:
```typescript theme={null}
const tickSize = await client.getTickSize(tokenID);
// Returns: "0.1" | "0.01" | "0.001" | "0.0001"
```
Ensure your prices conform to the market's tick size.
## Fee Structure
| Role | Fee |
| ----- | ----- |
| Maker | 0 bps |
| Taker | 0 bps |
Current fees are 0% for both makers and takers. See [CLOB Introduction](/developers/CLOB/introduction) for fee calculation details.
## Related Documentation
<CardGroup cols={2}>
<Card title="CLOB Client Overview" icon="code" href="/developers/CLOB/clients/methods-overview">
Complete client method reference
</Card>
<Card title="L2 Methods" icon="lock" href="/developers/CLOB/clients/methods-l2">
Authenticated order management methods
</Card>
<Card title="WebSocket Feeds" icon="plug" href="/developers/CLOB/websocket/wss-overview">
Real-time order and market data
</Card>
<Card title="Liquidity Rewards" icon="gift" href="/developers/market-makers/liquidity-rewards">
Earn rewards for providing liquidity
</Card>
</CardGroup>