Add scraped Polymarket documentation (117 files)
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
> ## 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.
|
||||
|
||||
# Data Feeds
|
||||
|
||||
> Real-time and historical data sources for market makers
|
||||
|
||||
## Overview
|
||||
|
||||
Market makers need fast, reliable data to price markets and manage inventory. Polymarket provides several data feeds at different latency and detail levels.
|
||||
|
||||
| Feed | Latency | Use Case | Access |
|
||||
| --------- | ---------- | ------------------------- | ------ |
|
||||
| WebSocket | \~100ms | Standard MM operations | Public |
|
||||
| Gamma API | \~1s | Market metadata, indexing | Public |
|
||||
| Onchain | Block time | Settlement, resolution | Public |
|
||||
|
||||
## WebSocket Feeds
|
||||
|
||||
The WebSocket API provides real-time market data with low latency. This is sufficient for most market making strategies.
|
||||
|
||||
### Connecting
|
||||
|
||||
```typescript theme={null}
|
||||
const ws = new WebSocket("wss://ws-subscriptions-clob.polymarket.com/ws/market");
|
||||
|
||||
ws.onopen = () => {
|
||||
// Subscribe to orderbook updates
|
||||
ws.send(JSON.stringify({
|
||||
type: "market",
|
||||
assets_ids: [tokenId]
|
||||
}));
|
||||
};
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
const data = JSON.parse(event.data);
|
||||
// Handle orderbook update
|
||||
};
|
||||
```
|
||||
|
||||
### Available Channels
|
||||
|
||||
| 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) |
|
||||
|
||||
### 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.
|
||||
};
|
||||
```
|
||||
|
||||
See [WebSocket Authentication](/developers/CLOB/websocket/wss-auth) for auth details.
|
||||
|
||||
### 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();
|
||||
```
|
||||
|
||||
### Get Events
|
||||
|
||||
```typescript theme={null}
|
||||
const response = await fetch(
|
||||
"https://gamma-api.polymarket.com/events?slug=us-presidential-election"
|
||||
);
|
||||
const event = await response.json();
|
||||
```
|
||||
|
||||
### Key Fields for MMs
|
||||
|
||||
| Field | Description |
|
||||
| --------------- | ------------------------ |
|
||||
| `conditionId` | Unique market identifier |
|
||||
| `clobTokenIds` | Outcome token IDs |
|
||||
| `outcomes` | Outcome names |
|
||||
| `outcomePrices` | Current outcome prices |
|
||||
| `volume` | Trading volume |
|
||||
| `liquidity` | Current liquidity |
|
||||
|
||||
See [Gamma API Overview](/developers/gamma-markets-api/overview) for complete documentation.
|
||||
|
||||
## Onchain Data
|
||||
|
||||
For settlement, resolution, and position tracking, market makers may query onchain data directly.
|
||||
|
||||
### Data Sources
|
||||
|
||||
| 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 |
|
||||
|
||||
### RPC Providers
|
||||
|
||||
Common providers for Polygon:
|
||||
|
||||
* Alchemy
|
||||
* QuickNode
|
||||
* Infura
|
||||
|
||||
### UMA Oracle
|
||||
|
||||
Markets are resolved via UMA's Optimistic Oracle. Monitor resolution events for risk management.
|
||||
|
||||
See [Resolution](/developers/resolution/UMA) for details on the resolution process.
|
||||
|
||||
## Related Documentation
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="WebSocket Overview" icon="plug" href="/developers/CLOB/websocket/wss-overview">
|
||||
Complete WebSocket documentation
|
||||
</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>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,76 @@
|
||||
> ## 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.
|
||||
|
||||
# Market Maker Introduction
|
||||
|
||||
> Overview of market making on Polymarket and available tools for liquidity providers
|
||||
|
||||
## What is a Market Maker?
|
||||
|
||||
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:
|
||||
|
||||
* **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:
|
||||
|
||||
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
|
||||
|
||||
## Available Tools
|
||||
|
||||
### 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) |
|
||||
|
||||
## Support
|
||||
|
||||
For market maker onboarding and support, contact [support@polymarket.com](mailto:support@polymarket.com).
|
||||
@@ -0,0 +1,247 @@
|
||||
> ## 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>
|
||||
@@ -0,0 +1,126 @@
|
||||
> ## 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>
|
||||
@@ -0,0 +1,246 @@
|
||||
> ## 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**, **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) | 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/cYugaGfLiC5yQnD1/polymarket-learn/media/fee_image_review.png?fit=max&auto=format&n=cYugaGfLiC5yQnD1&q=85&s=302c97e82876eac5b1bdf962872d6316" 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/cYugaGfLiC5yQnD1/polymarket-learn/media/fee_image_review.png?w=280&fit=max&auto=format&n=cYugaGfLiC5yQnD1&q=85&s=5c5ea33f6718c77bc5501eec7d284c7d 280w, https://mintcdn.com/polymarket-292d1b1b/cYugaGfLiC5yQnD1/polymarket-learn/media/fee_image_review.png?w=560&fit=max&auto=format&n=cYugaGfLiC5yQnD1&q=85&s=11f68c179d0f5d8bb20303d3f1847d65 560w, https://mintcdn.com/polymarket-292d1b1b/cYugaGfLiC5yQnD1/polymarket-learn/media/fee_image_review.png?w=840&fit=max&auto=format&n=cYugaGfLiC5yQnD1&q=85&s=2c150cef5a9b1688ee542644bea4a8b5 840w, https://mintcdn.com/polymarket-292d1b1b/cYugaGfLiC5yQnD1/polymarket-learn/media/fee_image_review.png?w=1100&fit=max&auto=format&n=cYugaGfLiC5yQnD1&q=85&s=1a8df2065e4c3e2634c55cbf5eae23a4 1100w, https://mintcdn.com/polymarket-292d1b1b/cYugaGfLiC5yQnD1/polymarket-learn/media/fee_image_review.png?w=1650&fit=max&auto=format&n=cYugaGfLiC5yQnD1&q=85&s=c8c9a753e1c286ebdf03e3e395452cf1 1650w, https://mintcdn.com/polymarket-292d1b1b/cYugaGfLiC5yQnD1/polymarket-learn/media/fee_image_review.png?w=2500&fit=max&auto=format&n=cYugaGfLiC5yQnD1&q=85&s=51b816a9f19219f061e404f35a4d0e13 2500w" />
|
||||
|
||||
### Fee Table (100 shares)
|
||||
|
||||
<Tabs>
|
||||
<Tab title="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 |
|
||||
| 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**
|
||||
* **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>
|
||||
@@ -0,0 +1,176 @@
|
||||
> ## 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.
|
||||
|
||||
# Setup
|
||||
|
||||
> One-time setup for market making on Polymarket: deposits, approvals, wallets, and API keys
|
||||
|
||||
## Overview
|
||||
|
||||
Before you can start market making on Polymarket, you need to complete these one-time setup steps:
|
||||
|
||||
1. Deposit bridged USDCe to Polygon
|
||||
2. Deploy a wallet (EOA or Safe)
|
||||
3. Approve tokens for trading
|
||||
4. Generate API credentials
|
||||
|
||||
## Deposit USDCe
|
||||
|
||||
Market makers need USDCe on Polygon to fund their trading operations.
|
||||
|
||||
### Options
|
||||
|
||||
| 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) |
|
||||
|
||||
### Using the Bridge API
|
||||
|
||||
```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)
|
||||
})
|
||||
});
|
||||
```
|
||||
|
||||
See [Bridge Deposit](/api-reference/bridge/create-deposit-addresses) for full API details.
|
||||
|
||||
## Wallet Options
|
||||
|
||||
### EOA (Externally Owned Account)
|
||||
|
||||
Standard Ethereum wallet. You pay for all onchain transactions (approvals, splits, merges, trade exedcution).
|
||||
|
||||
### Safe Wallet (Recommended)
|
||||
|
||||
Gnosis Safe-based wallet deployed via Polymarket's relayer. Benefits:
|
||||
|
||||
* **Gasless transactions** - Polymarket pays gas fees for onchain operations
|
||||
* **Contract wallet** - Enables advanced features like batched transactions.
|
||||
|
||||
Deploy a Safe wallet using the [Relayer Client](/developers/builders/relayer-client):
|
||||
|
||||
```typescript theme={null}
|
||||
import { RelayClient, RelayerTxType } from "@polymarket/builder-relayer-client";
|
||||
|
||||
const client = new RelayClient(
|
||||
"https://relayer-v2.polymarket.com/",
|
||||
137, // Polygon mainnet
|
||||
signer,
|
||||
builderConfig,
|
||||
RelayerTxType.SAFE
|
||||
);
|
||||
|
||||
// Deploy the Safe wallet
|
||||
const response = await client.deploy();
|
||||
const result = await response.wait();
|
||||
console.log("Safe Address:", result?.proxyAddress);
|
||||
```
|
||||
|
||||
## Token Approvals
|
||||
|
||||
Before trading, you must approve the exchange contracts to spend your tokens.
|
||||
|
||||
### Required Approvals
|
||||
|
||||
| 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 |
|
||||
|
||||
### Contract Addresses (Polygon Mainnet)
|
||||
|
||||
```typescript theme={null}
|
||||
const ADDRESSES = {
|
||||
USDCe: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
|
||||
CTF: "0x4d97dcd97ec945f40cf65f87097ace5ea0476045",
|
||||
CTF_EXCHANGE: "0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E",
|
||||
NEG_RISK_CTF_EXCHANGE: "0xC5d563A36AE78145C45a50134d48A1215220f80a",
|
||||
NEG_RISK_ADAPTER: "0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296"
|
||||
};
|
||||
```
|
||||
|
||||
### Approve via Relayer Client
|
||||
|
||||
```typescript theme={null}
|
||||
import { ethers } from "ethers";
|
||||
import { Interface } from "ethers/lib/utils";
|
||||
|
||||
const erc20Interface = new Interface([
|
||||
"function approve(address spender, uint256 amount) returns (bool)"
|
||||
]);
|
||||
|
||||
// Approve USDCe for CTF contract
|
||||
const approveTx = {
|
||||
to: ADDRESSES.USDCe,
|
||||
data: erc20Interface.encodeFunctionData("approve", [
|
||||
ADDRESSES.CTF,
|
||||
ethers.constants.MaxUint256
|
||||
]),
|
||||
value: "0"
|
||||
};
|
||||
|
||||
const response = await client.execute([approveTx], "Approve USDCe for CTF");
|
||||
await response.wait();
|
||||
```
|
||||
|
||||
See [Relayer Client](/developers/builders/relayer-client) for complete examples.
|
||||
|
||||
## API Key Generation
|
||||
|
||||
To place orders and access authenticated endpoints, you need L2 API credentials.
|
||||
|
||||
### Generate API Key
|
||||
|
||||
```typescript theme={null}
|
||||
import { ClobClient } from "@polymarket/clob-client";
|
||||
|
||||
const client = new ClobClient(
|
||||
"https://clob.polymarket.com",
|
||||
137,
|
||||
signer
|
||||
);
|
||||
|
||||
// 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);
|
||||
```
|
||||
|
||||
### Using Credentials
|
||||
|
||||
Once you have credentials, initialize the client for authenticated operations:
|
||||
|
||||
```typescript theme={null}
|
||||
const client = new ClobClient(
|
||||
"https://clob.polymarket.com",
|
||||
137,
|
||||
wallet,
|
||||
credentials
|
||||
);
|
||||
```
|
||||
|
||||
See [CLOB Authentication](/developers/CLOB/authentication) for full details.
|
||||
|
||||
## Next Steps
|
||||
|
||||
Once setup is complete:
|
||||
|
||||
<CardGroup cols={1}>
|
||||
<Card title="Start Trading" icon="chart-line" href="/developers/market-makers/trading">
|
||||
Post limit orders and manage quotes
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,203 @@
|
||||
> ## 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>
|
||||
Reference in New Issue
Block a user