docs: sync Polymarket documentation (2026-05-03)

Updated 55 files with latest documentation changes
This commit is contained in:
Etherdrake
2026-05-03 14:55:37 +02:00
parent 3695c0249e
commit a54a713360
58 changed files with 799 additions and 637 deletions
+5 -5
View File
@@ -37,14 +37,14 @@ Builder attribution in V2 is handled natively through the order struct — you a
```
```python Python theme={null}
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OrderArgs
from py_clob_client.order_builder.constants import BUY
from py_clob_client_v2 import ClobClient
from py_clob_client_v2 import OrderArgs, PartialCreateOrderOptions
from py_clob_client_v2.order_builder.constants import BUY
import os
client = ClobClient(
host="https://clob.polymarket.com",
chain=137,
chain_id=137,
key=os.getenv("PRIVATE_KEY"),
creds=creds,
signature_type=signature_type,
@@ -60,7 +60,7 @@ Builder attribution in V2 is handled natively through the order struct — you a
side=BUY,
builder_code=os.environ["POLY_BUILDER_CODE"],
),
options={"tick_size": "0.01", "neg_risk": False},
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
)
```
</CodeGroup>
+47 -7
View File
@@ -14,9 +14,11 @@ L1 methods require the client to initialize with a signer.
<Tab title="TypeScript">
```typescript theme={null}
import { ClobClient } from "@polymarket/clob-client-v2";
import { Wallet } from "ethers";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
const signer = new Wallet(process.env.PRIVATE_KEY);
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const signer = createWalletClient({ account, transport: http() });
const client = new ClobClient({
host: "https://clob.polymarket.com",
@@ -31,14 +33,14 @@ L1 methods require the client to initialize with a signer.
<Tab title="Python">
```python theme={null}
from py_clob_client.client import ClobClient
from py_clob_client_v2 import ClobClient
import os
private_key = os.getenv("PRIVATE_KEY")
client = ClobClient(
host="https://clob.polymarket.com",
chain=137,
chain_id=137,
key=private_key # Signer required for L1 methods
)
@@ -134,6 +136,13 @@ async createOrDeriveApiKey(nonce?: number): Promise<ApiKeyCreds>
## Order Signing
<Note>
In CLOB V2, `expiration` is still accepted in order payloads for GTD/order
expiry handling, but it is not part of the EIP-712 signed order struct. The
signed struct uses `timestamp`, `metadata`, and `builder` instead of the V1
`expiration`, `nonce`, `feeRateBps`, and `taker` fields.
</Note>
### createOrder
Create and sign a limit order locally without posting it to the CLOB. Use this when you want to sign orders in advance or implement custom submission logic. Submit via [`postOrder()`](/trading/clients/l2#postorder) or [`postOrders()`](/trading/clients/l2#postorders).
@@ -162,7 +171,8 @@ async createOrder(
</ResponseField>
<ResponseField name="expiration" type="number">
Optional expiration timestamp for the order. Optional.
Optional expiration timestamp included in the order payload for GTD/order
expiry handling. This is not part of the CLOB V2 EIP-712 signed order struct.
</ResponseField>
<ResponseField name="tickSize" type="TickSize">
@@ -202,7 +212,22 @@ async createOrder(
</ResponseField>
<ResponseField name="expiration" type="string">
The expiration timestamp as a string.
The expiration timestamp included in the order payload. This is not part of
the CLOB V2 EIP-712 signed order struct.
</ResponseField>
<ResponseField name="timestamp" type="string">
Order creation timestamp in milliseconds, used for order uniqueness in CLOB
V2.
</ResponseField>
<ResponseField name="metadata" type="string">
Reserved `bytes32` metadata field.
</ResponseField>
<ResponseField name="builder" type="string">
Builder code (`bytes32`) for attribution, or zero if no builder code is
attached.
</ResponseField>
<ResponseField name="signatureType" type="number">
@@ -275,7 +300,22 @@ async createMarketOrder(
</ResponseField>
<ResponseField name="expiration" type="string">
The expiration timestamp as a string.
The expiration timestamp included in the order payload. This is not part of
the CLOB V2 EIP-712 signed order struct.
</ResponseField>
<ResponseField name="timestamp" type="string">
Order creation timestamp in milliseconds, used for order uniqueness in CLOB
V2.
</ResponseField>
<ResponseField name="metadata" type="string">
Reserved `bytes32` metadata field.
</ResponseField>
<ResponseField name="builder" type="string">
Builder code (`bytes32`) for attribution, or zero if no builder code is
attached.
</ResponseField>
<ResponseField name="signatureType" type="number">
+8 -6
View File
@@ -14,12 +14,14 @@ L2 methods require the client to initialize with a signer, signature type, API c
<Tab title="TypeScript">
```typescript theme={null}
import { ClobClient } from "@polymarket/clob-client-v2";
import { Wallet } from "ethers";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
const signer = new Wallet(process.env.PRIVATE_KEY);
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const signer = createWalletClient({ account, transport: http() });
const apiCreds = {
apiKey: process.env.API_KEY,
key: process.env.API_KEY,
secret: process.env.SECRET,
passphrase: process.env.PASSPHRASE,
};
@@ -40,8 +42,8 @@ L2 methods require the client to initialize with a signer, signature type, API c
<Tab title="Python">
```python theme={null}
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import ApiCreds
from py_clob_client_v2 import ClobClient
from py_clob_client_v2 import ApiCreds
import os
api_creds = ApiCreds(
@@ -52,7 +54,7 @@ L2 methods require the client to initialize with a signer, signature type, API c
client = ClobClient(
host="https://clob.polymarket.com",
chain=137,
chain_id=137,
key=os.getenv("PRIVATE_KEY"),
creds=api_creds,
signature_type=2, # GNOSIS_SAFE
+2 -2
View File
@@ -27,11 +27,11 @@ Public methods require the client to initialize with the host URL and Polygon ch
<Tab title="Python">
```python theme={null}
from py_clob_client.client import ClobClient
from py_clob_client_v2 import ClobClient
client = ClobClient(
host="https://clob.polymarket.com",
chain=137
chain_id=137
)
# Ready to call public methods
+10 -2
View File
@@ -20,11 +20,19 @@ Before merging, you need:
2. **Condition ID** of the market
3. **Sufficient gas** for the transaction
<Note>
Polymarket uses thin collateral adapter contracts for pUSD-native CTF actions.
Approve the adapter once, then route split, merge, and redeem actions through
it. For merge flows, the adapter calls the underlying CTF contract, receives
the released USDC.e collateral, wraps it into pUSD, and returns pUSD to your
wallet automatically.
</Note>
## How It Works
1. You call `mergePositions()` with the amount and market details
1. You call the adapter's merge flow with the amount and market details
2. One unit of each position in a full set is burned in return for 1 collateral unit
3. The CTF contract releases pUSD back to your wallet
3. The adapter converts the released collateral into pUSD and returns pUSD to your wallet
The operation is atomic — if you don't have enough of both tokens, the transaction reverts.
+10 -2
View File
@@ -41,6 +41,14 @@ Before redeeming:
2. **Hold winning tokens** — only the winning outcome can be redeemed
3. **Know the condition ID** — required for the redemption call
<Note>
Polymarket uses thin collateral adapter contracts for pUSD-native CTF actions.
Approve the adapter once, then route split, merge, and redeem actions through
it. On redeem, the adapter burns the ERC1155 outcome tokens through the CTF
contract, receives USDC.e collateral, wraps it into pUSD, and returns pUSD to
your wallet automatically.
</Note>
## Function Parameters
<ResponseField name="collateralToken" type="IERC20">
@@ -74,11 +82,11 @@ The CTF uses a **payout vector** to determine redemption values:
| Yes wins | `[1, 0]` | Yes = $1, No = $0 |
| No wins | `[0, 1]` | Yes = $0, No = $1 |
When you call `redeemPositions()`:
When you redeem through the adapter:
* Your token balance is multiplied by the payout
* Winning tokens are burned
* pUSD is transferred to your wallet
* The released collateral is wrapped into pUSD and transferred to your wallet
* Losing tokens are burned as well, but produce a \$0 payout
## Next Steps
+11 -4
View File
@@ -17,9 +17,16 @@ $100 pUSD → 100 Yes tokens + 100 No tokens
Before splitting, ensure you have:
1. **pUSD balance** on Polygon
2. **pUSD approval** for the CTF contract to spend your tokens
2. **pUSD approval** for the CTF collateral adapter to spend your tokens
3. **Condition ID** of the market — the condition must already be prepared on the CTF contract (via `prepareCondition`)
<Note>
Polymarket uses thin collateral adapter contracts for pUSD-native CTF actions.
Approve the adapter once, then route split, merge, and redeem actions through
it. The adapter handles the CTF collateral plumbing so user-facing flows stay
in pUSD.
</Note>
<Note>
If the partition is trivial, invalid, or refers to more slots than the
condition is prepared with, the transaction will revert.
@@ -27,9 +34,9 @@ Before splitting, ensure you have:
## How It Works
1. You approve the CTF contract to spend your pUSD
2. You call `splitPosition()` with the amount and market details
3. The CTF contract transfers pUSD from your wallet and mints both outcome tokens
1. You approve the CTF collateral adapter to spend your pUSD
2. You call the adapter's split flow with the amount and market details
3. The adapter calls the underlying CTF contract and mints both outcome tokens
The operation is atomic — if any step fails, the entire transaction reverts.
+4
View File
@@ -33,6 +33,10 @@ Polymarket pays gas for all operations routed through the relayer:
The relayer uses **Relayer API Keys**. You can create one from [Settings > API Keys](https://polymarket.com/settings?tab=api-keys) on the Polymarket website.
<Note>
**Already have a builder signing key?** Your existing HMAC-based builder API key keeps working with the Relayer — no need to rotate or reissue. Only order-signing moved to the native `builderCode` field in CLOB V2. See [Migrating to CLOB V2](/v2-migration#builder-program) for context.
</Note>
Include these headers with your requests:
| Header | Description |
+12 -12
View File
@@ -16,15 +16,15 @@ The orderbook is a public endpoint — no authentication required. You can read
```
```python Python theme={null}
from py_clob_client.client import ClobClient
from py_clob_client_v2 import ClobClient
client = ClobClient("https://clob.polymarket.com", chain=137)
client = ClobClient("https://clob.polymarket.com", chain_id=137)
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::Client;
use polymarket_client_sdk_v2::clob::{Client, Config};
let client = Client::default(); // https://clob.polymarket.com
let client = Client::new("https://clob.polymarket.com", Config::default())?;
```
```bash REST theme={null}
@@ -57,7 +57,7 @@ Fetch the full orderbook for a token, including all resting bid and ask levels:
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::request::OrderBookSummaryRequest;
use polymarket_client_sdk_v2::clob::types::request::OrderBookSummaryRequest;
let token_id = "TOKEN_ID".parse()?;
let request = OrderBookSummaryRequest::builder().token_id(token_id).build();
@@ -130,7 +130,7 @@ Get the best available price for buying or selling a token:
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::{Side, request::PriceRequest};
use polymarket_client_sdk_v2::clob::types::{Side, request::PriceRequest};
let token_id = "TOKEN_ID".parse()?;
@@ -170,7 +170,7 @@ The midpoint is the average of the best bid and best ask. This is the price disp
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::request::MidpointRequest;
use polymarket_client_sdk_v2::clob::types::request::MidpointRequest;
let token_id = "TOKEN_ID".parse()?;
let request = MidpointRequest::builder().token_id(token_id).build();
@@ -206,7 +206,7 @@ The spread is the difference between the best ask and the best bid. Tighter spre
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::request::SpreadRequest;
use polymarket_client_sdk_v2::clob::types::request::SpreadRequest;
let token_id = "TOKEN_ID".parse()?;
let request = SpreadRequest::builder().token_id(token_id).build();
@@ -256,7 +256,7 @@ Fetch historical price data for a token over various time intervals:
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::{Interval, TimeRange, request::PriceHistoryRequest};
use polymarket_client_sdk_v2::clob::types::{Interval, TimeRange, request::PriceHistoryRequest};
let token_id = "TOKEN_ID".parse()?;
let request = PriceHistoryRequest::builder()
@@ -316,7 +316,7 @@ Calculate the effective price you'd pay for a market order of a given size, acco
```
```python Python theme={null}
from py_clob_client.clob_types import OrderType
from py_clob_client_v2 import OrderType
price = client.calculate_market_price(
token_id="TOKEN_ID",
@@ -384,7 +384,7 @@ All orderbook queries have batch variants for fetching data across multiple toke
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::{Side, request::PriceRequest};
use polymarket_client_sdk_v2::clob::types::{Side, request::PriceRequest};
let token_a = "TOKEN_A".parse()?;
let token_b = "TOKEN_B".parse()?;
@@ -424,7 +424,7 @@ Get the price and side of the most recent trade for a token:
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::request::LastTradePriceRequest;
use polymarket_client_sdk_v2::clob::types::request::LastTradePriceRequest;
let token_id = "TOKEN_ID".parse()?;
let request = LastTradePriceRequest::builder().token_id(token_id).build();
+5 -5
View File
@@ -57,13 +57,13 @@ Pass `builderCode` in the order struct on every order you submit. The SDK serial
```
```python Python theme={null}
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY
from py_clob_client_v2 import ClobClient
from py_clob_client_v2 import OrderArgs, OrderType, PartialCreateOrderOptions
from py_clob_client_v2.order_builder.constants import BUY
client = ClobClient(
host="https://clob.polymarket.com",
chain=137,
chain_id=137,
key=private_key,
creds=api_creds,
signature_type=2,
@@ -78,7 +78,7 @@ Pass `builderCode` in the order struct on every order you submit. The SDK serial
side=BUY,
builder_code="0xabc123...", # your builder code from polymarket.com/settings?tab=builder
),
options={"tick_size": "0.01", "neg_risk": False},
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
order_type=OrderType.GTC,
)
```
+6 -6
View File
@@ -126,7 +126,7 @@ Cancel all orders for a specific market, optionally filtered to a single token.
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::request::CancelMarketOrderRequest;
use polymarket_client_sdk_v2::clob::types::request::CancelMarketOrderRequest;
let request = CancelMarketOrderRequest::builder()
.market("0xbd31dc8a...".parse()?)
@@ -191,7 +191,7 @@ Retrieve all open orders, optionally filtered by market or token:
```
```python Python theme={null}
from py_clob_client.clob_types import OpenOrderParams
from py_clob_client_v2 import OpenOrderParams
# All open orders
orders = client.get_orders()
@@ -203,7 +203,7 @@ Retrieve all open orders, optionally filtered by market or token:
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::request::OrdersRequest;
use polymarket_client_sdk_v2::clob::types::request::OrdersRequest;
// All open orders
let orders = client.orders(&OrdersRequest::default(), None).await?;
@@ -262,7 +262,7 @@ When an order is matched, it creates a trade. Trades progress through these stat
```
```python Python theme={null}
from py_clob_client.clob_types import TradeParams
from py_clob_client_v2 import TradeParams
trades = client.get_trades()
@@ -272,7 +272,7 @@ When an order is matched, it creates a trade. Trades progress through these stat
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::request::TradesRequest;
use polymarket_client_sdk_v2::clob::types::request::TradesRequest;
// All trades
let trades = client.trades(&TradesRequest::default(), None).await?;
@@ -356,7 +356,7 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
```
```python Python theme={null}
from py_clob_client.clob_types import OrderScoringParams, OrdersScoringParams
from py_clob_client_v2 import OrderScoringParams, OrdersScoringParams
scoring = client.is_order_scoring(
OrderScoringParams(orderId="0x...")
+41 -41
View File
@@ -60,8 +60,8 @@ The simplest way to place a limit order — create, sign, and submit in one call
```
```python Python theme={null}
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY
from py_clob_client_v2 import OrderArgs, OrderType, PartialCreateOrderOptions
from py_clob_client_v2.order_builder.constants import BUY
response = client.create_and_post_order(
OrderArgs(
@@ -70,10 +70,7 @@ The simplest way to place a limit order — create, sign, and submit in one call
size=10,
side=BUY,
),
options={
"tick_size": "0.01",
"neg_risk": False,
},
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
order_type=OrderType.GTC
)
@@ -82,8 +79,8 @@ The simplest way to place a limit order — create, sign, and submit in one call
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::Side;
use polymarket_client_sdk::types::dec;
use polymarket_client_sdk_v2::clob::types::Side;
use polymarket_client_sdk_v2::types::dec;
let token_id = "TOKEN_ID".parse()?;
let order = client
@@ -132,10 +129,7 @@ For more control, you can separate signing from submission. This is useful for b
size=10,
side=BUY,
),
options={
"tick_size": "0.01",
"neg_risk": False,
}
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)
)
# Step 2: Submit to the CLOB
@@ -197,17 +191,14 @@ GTD orders auto-expire at a specified time. Useful for quoting around known even
side=BUY,
expiration=expiration,
),
options={
"tick_size": "0.01",
"neg_risk": False,
},
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
order_type=OrderType.GTD
)
```
```rust Rust theme={null}
use chrono::{TimeDelta, Utc};
use polymarket_client_sdk::clob::types::OrderType;
use polymarket_client_sdk_v2::clob::types::OrderType;
let order = client
.limit_order()
@@ -266,32 +257,36 @@ Market orders execute immediately against resting liquidity using FOK or FAK typ
```
```python Python theme={null}
from py_clob_client.order_builder.constants import BUY, SELL
from py_clob_client.clob_types import OrderType
from py_clob_client_v2.order_builder.constants import BUY, SELL
from py_clob_client_v2 import MarketOrderArgs, OrderType, PartialCreateOrderOptions
# FOK BUY: spend exactly $100 or cancel entirely
buy_order = client.create_market_order(
token_id="TOKEN_ID",
side=BUY,
amount=100, # dollar amount
price=0.50, # worst-price limit (slippage protection)
options={"tick_size": "0.01", "neg_risk": False},
order_args=MarketOrderArgs(
token_id="TOKEN_ID",
side=BUY,
amount=100, # dollar amount
price=0.50, # worst-price limit (slippage protection)
),
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
)
client.post_order(buy_order, OrderType.FOK)
# FOK SELL: sell exactly 200 shares or cancel entirely
sell_order = client.create_market_order(
token_id="TOKEN_ID",
side=SELL,
amount=200, # number of shares
price=0.45, # worst-price limit (slippage protection)
options={"tick_size": "0.01", "neg_risk": False},
order_args=MarketOrderArgs(
token_id="TOKEN_ID",
side=SELL,
amount=200, # number of shares
price=0.45, # worst-price limit (slippage protection)
),
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
)
client.post_order(sell_order, OrderType.FOK)
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::{Amount, OrderType, Side};
use polymarket_client_sdk_v2::clob::types::{Amount, OrderType, Side};
let token_id = "TOKEN_ID".parse()?;
@@ -347,12 +342,17 @@ For convenience, `createAndPostMarketOrder` handles creation, signing, and submi
```
```python Python theme={null}
from py_clob_client_v2 import MarketOrderArgs, OrderType, PartialCreateOrderOptions
from py_clob_client_v2.order_builder.constants import BUY
response = client.create_and_post_market_order(
token_id="TOKEN_ID",
side=BUY,
amount=100,
price=0.50,
options={"tick_size": "0.01", "neg_risk": False},
order_args=MarketOrderArgs(
token_id="TOKEN_ID",
side=BUY,
amount=100,
price=0.50,
),
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
order_type=OrderType.FOK,
)
```
@@ -446,26 +446,26 @@ Place up to **15 orders** in a single request:
```
```python Python theme={null}
from py_clob_client.clob_types import OrderArgs, OrderType, PostOrdersArgs
from py_clob_client.order_builder.constants import BUY, SELL
from py_clob_client_v2 import OrderArgs, OrderType, PostOrdersV2Args, PartialCreateOrderOptions
from py_clob_client_v2.order_builder.constants import BUY, SELL
response = client.post_orders([
PostOrdersArgs(
PostOrdersV2Args(
order=client.create_order(OrderArgs(
price=0.48,
size=500,
side=BUY,
token_id="TOKEN_ID",
), options={"tick_size": "0.01", "neg_risk": False}),
), options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)),
orderType=OrderType.GTC,
),
PostOrdersArgs(
PostOrdersV2Args(
order=client.create_order(OrderArgs(
price=0.52,
size=500,
side=SELL,
token_id="TOKEN_ID",
), options={"tick_size": "0.01", "neg_risk": False}),
), options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)),
orderType=OrderType.GTC,
),
])
+12 -9
View File
@@ -106,6 +106,9 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
```
```python Python theme={null}
from py_clob_client_v2 import OrderArgs, PartialCreateOrderOptions
from py_clob_client_v2.order_builder.constants import BUY
response = client.create_and_post_order(
OrderArgs(
token_id="TOKEN_ID",
@@ -113,10 +116,10 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
size=10,
side=BUY,
),
options={
"tick_size": "0.01",
"neg_risk": True, # Required for multi-outcome markets
}
options=PartialCreateOrderOptions(
tick_size="0.01",
neg_risk=True, # Required for multi-outcome markets
)
)
```
@@ -232,7 +235,7 @@ Retrieve your open orders, optionally filtered by market or asset:
```
```python Python theme={null}
from py_clob_client.clob_types import OpenOrderParams
from py_clob_client_v2 import OpenOrderParams
# All open orders
orders = client.get_orders()
@@ -246,7 +249,7 @@ Retrieve your open orders, optionally filtered by market or asset:
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::request::OrdersRequest;
use polymarket_client_sdk_v2::clob::types::request::OrdersRequest;
// All open orders
let orders = client.orders(&OrdersRequest::default(), None).await?;
@@ -360,7 +363,7 @@ Retrieve your trades with the SDK:
```
```python Python theme={null}
from py_clob_client.clob_types import TradeParams
from py_clob_client_v2 import TradeParams
# All trades
trades = client.get_trades()
@@ -374,7 +377,7 @@ Retrieve your trades with the SDK:
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::request::TradesRequest;
use polymarket_client_sdk_v2::clob::types::request::TradesRequest;
// All trades
let trades = client.trades(&TradesRequest::default(), None).await?;
@@ -445,7 +448,7 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
```
```python Python theme={null}
from py_clob_client.clob_types import OrderScoringParams, OrdersScoringParams
from py_clob_client_v2 import OrderScoringParams, OrdersScoringParams
# Single order
scoring = client.is_order_scoring(
+15 -13
View File
@@ -13,7 +13,7 @@ We recommend using the open-source SDK clients, which handle order signing, auth
<CardGroup cols={3}>
<Card title="TypeScript Client" icon="github" href="https://github.com/Polymarket/clob-client-v2">
<p className="font-mono text-[0.8rem]">
npm install @polymarket/clob-client-v2
npm install @polymarket/clob-client-v2 viem
</p>
</Card>
@@ -22,7 +22,7 @@ We recommend using the open-source SDK clients, which handle order signing, auth
</Card>
<Card title="Rust Client" icon="github" href="https://github.com/Polymarket/rs-clob-client-v2">
<p className="font-mono text-[0.8rem]">cargo add polymarket-client-sdk</p>
<p className="font-mono text-[0.8rem]">cargo add polymarket\_client\_sdk\_v2 --features clob</p>
</Card>
</CardGroup>
@@ -51,9 +51,11 @@ You use your private key once to derive **L2 credentials** (API key, secret, pas
<CodeGroup>
```typescript TypeScript theme={null}
import { ClobClient } from "@polymarket/clob-client-v2";
import { Wallet } from "ethers"; // v5.8.0
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
const signer = new Wallet(process.env.PRIVATE_KEY);
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const signer = createWalletClient({ account, transport: http() });
// Derive L2 API credentials
const tempClient = new ClobClient({ host: "https://clob.polymarket.com", chain: 137, signer });
@@ -61,21 +63,21 @@ You use your private key once to derive **L2 credentials** (API key, secret, pas
```
```python Python theme={null}
from py_clob_client.client import ClobClient
from py_clob_client_v2 import ClobClient
import os
private_key = os.getenv("PRIVATE_KEY")
# Derive L2 API credentials
temp_client = ClobClient("https://clob.polymarket.com", key=private_key, chain=137)
api_creds = temp_client.create_or_derive_api_creds()
temp_client = ClobClient("https://clob.polymarket.com", key=private_key, chain_id=137)
api_creds = temp_client.create_or_derive_api_key()
```
```rust Rust theme={null}
use std::str::FromStr;
use polymarket_client_sdk::POLYGON;
use polymarket_client_sdk::auth::{LocalSigner, Signer};
use polymarket_client_sdk::clob::{Client, Config};
use polymarket_client_sdk_v2::POLYGON;
use polymarket_client_sdk_v2::auth::{LocalSigner, Signer};
use polymarket_client_sdk_v2::clob::{Client, Config};
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
let signer = LocalSigner::from_str(&private_key)?
@@ -125,7 +127,7 @@ When initializing the trading client, you must specify your wallet's **signature
client = ClobClient(
"https://clob.polymarket.com",
key=private_key,
chain=137,
chain_id=137,
creds=api_creds,
signature_type=2, # GNOSIS_SAFE
funder="0x..." # Your proxy wallet address
@@ -133,7 +135,7 @@ When initializing the trading client, you must specify your wallet's **signature
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::SignatureType;
use polymarket_client_sdk_v2::clob::types::SignatureType;
let client = Client::new("https://clob.polymarket.com", Config::default())?
.authentication_builder(&signer)
@@ -192,7 +194,7 @@ If you're using the REST API directly (without the SDK), you need to attach auth
</Card>
<Card title="Builder Methods" icon="hammer" href="/trading/clients/builder">
Track attributed trades and manage builder credentials.
Track orders and trades attributed to your builder code.
</Card>
</CardGroup>
+23 -21
View File
@@ -12,7 +12,7 @@ This guide walks you through placing an order on Polymarket end-to-end.
<Step title="Install the SDK">
<CodeGroup>
```bash TypeScript theme={null}
npm install @polymarket/clob-client-v2 ethers@5
npm install @polymarket/clob-client-v2 viem
```
```bash Python theme={null}
@@ -20,7 +20,7 @@ This guide walks you through placing an order on Polymarket end-to-end.
```
```bash Rust theme={null}
cargo add polymarket-client-sdk --features clob
cargo add polymarket_client_sdk_v2 --features clob
```
</CodeGroup>
</Step>
@@ -31,11 +31,13 @@ This guide walks you through placing an order on Polymarket end-to-end.
<CodeGroup>
```typescript TypeScript theme={null}
import { ClobClient } from "@polymarket/clob-client-v2";
import { Wallet } from "ethers"; // v5.8.0
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
const HOST = "https://clob.polymarket.com";
const CHAIN_ID = 137; // Polygon mainnet
const signer = new Wallet(process.env.PRIVATE_KEY);
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const signer = createWalletClient({ account, transport: http() });
// Derive API credentials
const tempClient = new ClobClient({ host: HOST, chain: CHAIN_ID, signer });
@@ -48,12 +50,12 @@ This guide walks you through placing an order on Polymarket end-to-end.
signer,
creds: apiCreds,
signatureType: 0, // EOA
funderAddress: signer.address,
funderAddress: account.address,
});
```
```python Python theme={null}
from py_clob_client.client import ClobClient
from py_clob_client_v2 import ClobClient
import os
host = "https://clob.polymarket.com"
@@ -61,14 +63,14 @@ This guide walks you through placing an order on Polymarket end-to-end.
private_key = os.getenv("PRIVATE_KEY")
# Derive API credentials
temp_client = ClobClient(host, key=private_key, chain=chain)
api_creds = temp_client.create_or_derive_api_creds()
temp_client = ClobClient(host, key=private_key, chain_id=chain)
api_creds = temp_client.create_or_derive_api_key()
# Initialize trading client
client = ClobClient(
host,
key=private_key,
chain=chain,
chain_id=chain,
creds=api_creds,
signature_type=0, # EOA
funder="YOUR_WALLET_ADDRESS"
@@ -77,9 +79,9 @@ This guide walks you through placing an order on Polymarket end-to-end.
```rust Rust theme={null}
use std::str::FromStr;
use polymarket_client_sdk::POLYGON;
use polymarket_client_sdk::auth::{LocalSigner, Signer};
use polymarket_client_sdk::clob::{Client, Config};
use polymarket_client_sdk_v2::POLYGON;
use polymarket_client_sdk_v2::auth::{LocalSigner, Signer};
use polymarket_client_sdk_v2::clob::{Client, Config};
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
let signer = LocalSigner::from_str(&private_key)?
@@ -132,8 +134,8 @@ This guide walks you through placing an order on Polymarket end-to-end.
```
```python Python theme={null}
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY
from py_clob_client_v2 import OrderArgs, OrderType, PartialCreateOrderOptions
from py_clob_client_v2.order_builder.constants import BUY
response = client.create_and_post_order(
OrderArgs(
@@ -142,10 +144,10 @@ This guide walks you through placing an order on Polymarket end-to-end.
size=10,
side=BUY,
),
options={
"tick_size": "0.01",
"neg_risk": False, # Set to True for multi-outcome markets
},
options=PartialCreateOrderOptions(
tick_size="0.01",
neg_risk=False, # Set to True for multi-outcome markets
),
order_type=OrderType.GTC
)
@@ -154,8 +156,8 @@ This guide walks you through placing an order on Polymarket end-to-end.
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::Side;
use polymarket_client_sdk::types::dec;
use polymarket_client_sdk_v2::clob::types::Side;
use polymarket_client_sdk_v2::types::dec;
let token_id = "YOUR_TOKEN_ID".parse()?;
@@ -212,7 +214,7 @@ This guide walks you through placing an order on Polymarket end-to-end.
```
```rust Rust theme={null}
use polymarket_client_sdk::clob::types::request::{OrdersRequest, TradesRequest};
use polymarket_client_sdk_v2::clob::types::request::{OrdersRequest, TradesRequest};
// View all open orders
let open_orders = client.orders(&OrdersRequest::default(), None).await?;