pub struct ClobClient {
pub host: String,
pub chain_id: i64,
pub http_client: Client,
pub signer: Option<Arc<EthersSigner>>,
pub creds: Option<ApiKeyCreds>,
pub use_server_time: bool,
pub geo_block_token: Option<String>,
pub tick_sizes: DashMap<String, String>,
pub neg_risk: DashMap<String, bool>,
pub fee_rates: DashMap<String, Decimal>,
pub builder_signer: Option<BuilderSigner>,
pub builder_config: Option<BuilderConfig>,
}Fields§
§host: String§chain_id: i64§http_client: ClientHTTP 客户端实例。
- 调用方传入
Some(client)时使用该实例(可自定义代理、超时等)。 - 传入
None时使用全局共享默认实例(http_helpers::default_client()clone), 所有未自定义的 ClobClient 共享同一连接池。
signer: Option<Arc<EthersSigner>>§creds: Option<ApiKeyCreds>§use_server_time: bool§geo_block_token: Option<String>Optional geo block token passed as query parameter geo_block_token.
tick_sizes: DashMap<String, String>§neg_risk: DashMap<String, bool>§fee_rates: DashMap<String, Decimal>§builder_signer: Option<BuilderSigner>Optional Builder signer for builder-authenticated flows
builder_config: Option<BuilderConfig>Optional default builder config for order creation
Implementations§
Source§impl ClobClient
impl ClobClient
Sourcepub async fn getMarkets(
&self,
params: Option<HashMap<String, String>>,
) -> Result<Vec<Market>, ClobError>
pub async fn getMarkets( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Market>, ClobError>
TS parity alias for get_markets (camelCase). Prefer get_markets in Rust.
Sourcepub async fn getMarket(
&self,
market_id: &str,
params: Option<HashMap<String, String>>,
) -> Result<Market, ClobError>
pub async fn getMarket( &self, market_id: &str, params: Option<HashMap<String, String>>, ) -> Result<Market, ClobError>
TS parity alias for getMarket -> get_market.
pub async fn getOrderBook( &self, token_id: &str, ) -> Result<OrderBookSummary, ClobError>
pub async fn getTickSize(&self, token_id: &str) -> Result<String, ClobError>
pub async fn getNegRisk(&self, token_id: &str) -> Result<bool, ClobError>
pub async fn getFeeRate(&self, token_id: &str) -> Result<Decimal, ClobError>
pub async fn getOpenOrders( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<SignedOrder>, ClobError>
pub async fn getOrder(&self, order_id: &str) -> Result<OpenOrder, ClobError>
pub async fn postSignedOrder( &self, signed_order: &SignedOrder, ) -> Result<OrderResponse, ClobError>
pub async fn postOrders( &self, orders: Vec<PostOrdersArgs>, defer_exec: bool, default_post_only: bool, ) -> Result<Vec<Order>, ClobError>
pub async fn createOrder( &self, user_order: UserOrder, options_tick: Option<&str>, ) -> Result<SignedOrder, ClobError>
pub async fn createMarketOrder( &self, user_market_order: UserMarketOrder, options_tick: Option<&str>, ) -> Result<SignedOrder, ClobError>
pub async fn createAndPostOrder( &self, user_order: UserOrder, options_tick: Option<&str>, order_type: Option<OrderType>, defer_exec: bool, post_only: bool, ) -> Result<OrderResponse, ClobError>
pub async fn createAndPostMarketOrder( &self, user_market_order: UserMarketOrder, options_tick: Option<&str>, order_type: Option<OrderType>, defer_exec: bool, ) -> Result<OrderResponse, ClobError>
Sourcepub async fn cancelOrder(
&self,
payload: OrderPayloadParity,
) -> Result<Value, ClobError>
pub async fn cancelOrder( &self, payload: OrderPayloadParity, ) -> Result<Value, ClobError>
TypeScript parity: cancelOrder({ orderID }) 发送 DELETE /orders 携带 JSON body。
pub async fn cancelOrders( &self, order_ids: Vec<String>, ) -> Result<Vec<Order>, ClobError>
pub async fn cancelAll(&self) -> Result<Vec<Order>, ClobError>
pub async fn cancelMarketOrders( &self, payload: OrderMarketCancelParams, ) -> Result<Vec<Order>, ClobError>
pub async fn isOrderScoring( &self, params: Option<HashMap<String, String>>, ) -> Result<OrderScoring, ClobError>
pub async fn areOrdersScoring( &self, order_ids: Option<Vec<String>>, ) -> Result<OrdersScoring, ClobError>
pub async fn getTrades( &self, params: Option<HashMap<String, String>>, only_first_page: bool, next_cursor: Option<String>, ) -> Result<Vec<Value>, ClobError>
pub async fn getTradesTyped( &self, params: Option<HashMap<String, String>>, only_first_page: bool, next_cursor: Option<String>, ) -> Result<Vec<Trade>, ClobError>
pub async fn getNotifications(&self) -> Result<Vec<Notification>, ClobError>
pub async fn dropNotifications( &self, ids: Option<&Vec<String>>, ) -> Result<(), ClobError>
pub async fn getBalanceAllowance( &self, params: Option<HashMap<String, String>>, ) -> Result<BalanceAllowanceResponse, ClobError>
pub async fn updateBalanceAllowance( &self, params: Option<HashMap<String, String>>, ) -> Result<(), ClobError>
pub async fn getTime(&self) -> Result<u64, ClobError>
pub async fn getApiKeys(&self) -> Result<Vec<ApiKeyCreds>, ClobError>
pub async fn deleteApiKey(&self) -> Result<(), ClobError>
pub async fn getClosedOnlyMode(&self) -> Result<BanStatus, ClobError>
pub async fn createApiKey( &self, nonce: Option<u64>, ) -> Result<ApiKeyCreds, ClobError>
pub async fn deriveApiKey( &self, params: Option<HashMap<String, String>>, ) -> Result<ApiKeyCreds, ClobError>
pub async fn createBuilderApiKey(&self) -> Result<ApiKeyCreds, ClobError>
pub async fn getBuilderApiKeys(&self) -> Result<Vec<ApiKeyCreds>, ClobError>
pub async fn revokeBuilderApiKey(&self) -> Result<(), ClobError>
pub async fn getSimplifiedMarkets( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Market>, ClobError>
pub async fn getSamplingMarkets( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Market>, ClobError>
pub async fn getSamplingSimplifiedMarkets( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Market>, ClobError>
pub async fn getOrderBooks( &self, params: &[BookParams], ) -> Result<Vec<OrderBookSummary>, ClobError>
pub async fn getMidpoint( &self, params: Option<HashMap<String, String>>, ) -> Result<MidpointResponse, ClobError>
pub async fn getMidpoints( &self, params: &[BookParams], ) -> Result<Value, ClobError>
pub async fn getPrices(&self, params: &[BookParams]) -> Result<Value, ClobError>
pub async fn getSpreads( &self, params: &[BookParams], ) -> Result<Value, ClobError>
pub async fn getLastTradesPrices( &self, params: &[BookParams], ) -> Result<Value, ClobError>
pub async fn getPricesHistory( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<MarketPrice>, ClobError>
pub async fn getMarketTradesEvents( &self, market_id: &str, params: Option<HashMap<String, String>>, ) -> Result<Vec<Trade>, ClobError>
pub async fn getBuilderTrades( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<BuilderTrade>, ClobError>
pub async fn getEarningsForUserForDay( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Reward>, ClobError>
pub async fn getEarningsForUserForDayTyped( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Reward>, ClobError>
pub async fn getTotalEarningsForUserForDay( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Reward>, ClobError>
pub async fn getLiquidityRewardPercentages( &self, params: Option<HashMap<String, String>>, ) -> Result<HashMap<String, f64>, ClobError>
pub async fn getRewardsMarketsCurrent( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<RewardsMarket>, ClobError>
pub async fn getRewardsEarningsPercentages( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Reward>, ClobError>
Sourcepub fn new(
host: &str,
chain_id: i64,
signer: Option<Arc<EthersSigner>>,
creds: Option<ApiKeyCreds>,
use_server_time: bool,
http_client: Option<Client>,
) -> Self
pub fn new( host: &str, chain_id: i64, signer: Option<Arc<EthersSigner>>, creds: Option<ApiKeyCreds>, use_server_time: bool, http_client: Option<Client>, ) -> Self
创建 ClobClient。
http_client:
None— 使用全局共享默认连接池(所有传 None 的实例共享同一个池,与原有行为一致)Some(client)— 使用调用方自定义的reqwest::Client(可配置代理、独立连接池等)
pub fn with_geo_block_token(self, token: String) -> Self
pub fn set_geo_block_token(&mut self, token: Option<String>)
Sourcepub fn with_builder_signer(
self,
key: String,
secret_b64: String,
passphrase: String,
) -> Self
pub fn with_builder_signer( self, key: String, secret_b64: String, passphrase: String, ) -> Self
Configure Builder API signer (builder auth). Secret must be base64 encoded.
Sourcepub fn with_builder_config(self, cfg: ObBuilderConfig) -> Self
pub fn with_builder_config(self, cfg: ObBuilderConfig) -> Self
Set a default builder config for order creation (tick size, neg risk, signature type, funder).
Sourcepub fn rfq(&self) -> RfqClient<'_>
pub fn rfq(&self) -> RfqClient<'_>
RFQ entrypoint.
使用方式:client.rfq().get_rfq_quotes(...)。
注意:RFQ 的 accept/approve 需要在本地创建并签名订单,因此会对 self 持有可变借用。
pub async fn get_order_book( &self, token_id: &str, ) -> Result<OrderBookSummary, ClobError>
pub async fn get_tick_size(&self, token_id: &str) -> Result<String, ClobError>
pub async fn get_neg_risk(&self, token_id: &str) -> Result<bool, ClobError>
pub async fn get_fee_rate(&self, token_id: &str) -> Result<Decimal, ClobError>
Sourcepub async fn post_order(
&self,
signed_order: &SignedOrder,
) -> Result<OrderResponse, ClobError>
pub async fn post_order( &self, signed_order: &SignedOrder, ) -> Result<OrderResponse, ClobError>
Convenience method that accepts a typed SignedOrder and posts it to the
API. Delegates to post_signed_order which performs serialization,
header creation and response parsing. Uses default orderType=GTC.
pub async fn get_api_keys(&self) -> Result<Vec<ApiKeyCreds>, ClobError>
Sourcepub async fn create_readonly_api_key(
&self,
) -> Result<ReadonlyApiKeyResponse, ClobError>
pub async fn create_readonly_api_key( &self, ) -> Result<ReadonlyApiKeyResponse, ClobError>
Creates a new readonly API key for the current (L2 authenticated) user.
TS parity: createReadonlyApiKey(): Promise<{ apiKey: string }>
Sourcepub async fn get_readonly_api_keys(&self) -> Result<Vec<String>, ClobError>
pub async fn get_readonly_api_keys(&self) -> Result<Vec<String>, ClobError>
Lists readonly API keys for the current (L2 authenticated) user.
TS parity: getReadonlyApiKeys(): Promise<string[]>
Sourcepub async fn delete_readonly_api_key(
&self,
key: &str,
) -> Result<bool, ClobError>
pub async fn delete_readonly_api_key( &self, key: &str, ) -> Result<bool, ClobError>
Deletes a readonly API key for the current (L2 authenticated) user.
TS parity: deleteReadonlyApiKey(key: string): Promise<boolean>
Sourcepub async fn validate_readonly_api_key(
&self,
address: &str,
key: &str,
) -> Result<String, ClobError>
pub async fn validate_readonly_api_key( &self, address: &str, key: &str, ) -> Result<String, ClobError>
Validates a readonly API key for a given address.
TS parity: validateReadonlyApiKey(address: string, key: string): Promise<string>
Note: This endpoint is treated as public (no L1/L2 auth headers).
pub async fn createReadonlyApiKey( &self, ) -> Result<ReadonlyApiKeyResponse, ClobError>
pub async fn getReadonlyApiKeys(&self) -> Result<Vec<String>, ClobError>
pub async fn deleteReadonlyApiKey(&self, key: &str) -> Result<bool, ClobError>
pub async fn validateReadonlyApiKey( &self, address: &str, key: &str, ) -> Result<String, ClobError>
pub async fn get_closed_only_mode(&self) -> Result<BanStatus, ClobError>
pub async fn delete_api_key(&self) -> Result<(), ClobError>
pub async fn get_trades( &self, params: Option<HashMap<String, String>>, only_first_page: bool, next_cursor: Option<String>, ) -> Result<Vec<Value>, ClobError>
Sourcepub async fn get_trades_typed(
&self,
params: Option<HashMap<String, String>>,
only_first_page: bool,
next_cursor: Option<String>,
) -> Result<Vec<Trade>, ClobError>
pub async fn get_trades_typed( &self, params: Option<HashMap<String, String>>, only_first_page: bool, next_cursor: Option<String>, ) -> Result<Vec<Trade>, ClobError>
Typed variant of get_trades that deserializes each trade into Trade.
pub async fn get_notifications(&self) -> Result<Vec<Notification>, ClobError>
Sourcepub async fn get_notifications_typed(
&self,
) -> Result<Vec<Notification>, ClobError>
pub async fn get_notifications_typed( &self, ) -> Result<Vec<Notification>, ClobError>
Typed variant of get_notifications that deserializes notifications into Notification.
pub async fn drop_notifications( &self, ids: Option<&Vec<String>>, ) -> Result<(), ClobError>
pub async fn get_balance_allowance( &self, params: Option<HashMap<String, String>>, ) -> Result<BalanceAllowanceResponse, ClobError>
pub async fn update_balance_allowance( &self, params: Option<HashMap<String, String>>, ) -> Result<(), ClobError>
Sourcepub async fn get_rewards_user_for_day_typed(
&self,
params: Option<HashMap<String, String>>,
) -> Result<Vec<Reward>, ClobError>
pub async fn get_rewards_user_for_day_typed( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Reward>, ClobError>
Typed helper to fetch user rewards for a day (deserializes into Reward).
This endpoint may be public or require params depending on server; we accept optional query params.
pub async fn create_order( &self, user_order: UserOrder, options_tick: Option<&str>, ) -> Result<SignedOrder, ClobError>
pub async fn create_market_order( &self, user_market_order: UserMarketOrder, options_tick: Option<&str>, ) -> Result<SignedOrder, ClobError>
Sourcepub async fn post_orders(
&self,
orders: Vec<PostOrdersArgs>,
defer_exec: bool,
default_post_only: bool,
) -> Result<Vec<Order>, ClobError>
pub async fn post_orders( &self, orders: Vec<PostOrdersArgs>, defer_exec: bool, default_post_only: bool, ) -> Result<Vec<Order>, ClobError>
Post multiple orders to the API (v5.2.0 signature)
This method matches the TypeScript SDK’s postOrders signature.
It supports PostOrdersArgs which includes post_only support.
§Arguments
orders- Vector of PostOrdersArgs containing signed orders with their optionsdefer_exec- Whether to defer execution (default: false)default_post_only- Default post_only value if not specified per-order (default: false)
§Returns
- Vector of Order responses
Sourcepub async fn post_signed_order(
&self,
signed_order: &SignedOrder,
order_type: OrderType,
defer_exec: bool,
post_only: Option<bool>,
) -> Result<OrderResponse, ClobError>
pub async fn post_signed_order( &self, signed_order: &SignedOrder, order_type: OrderType, defer_exec: bool, post_only: Option<bool>, ) -> Result<OrderResponse, ClobError>
Helper: post a single SignedOrder (typed) to the API. Wraps SignedOrder in NewOrder with orderType and performs L2-authenticated POST to POST_ORDER endpoint.
§Arguments
signed_order- The signed order to postorder_type- Type of order (GTC, FOK, GTD, FAK)defer_exec- Whether to defer executionpost_only- If true, order will be rejected if it would immediately match (v5.2.0). Only supported for GTC and GTD orders.
Sourcepub async fn post_signed_order_typed(
&self,
signed_order: &SignedOrder,
order_type: OrderType,
defer_exec: bool,
post_only: Option<bool>,
) -> Result<OrderResponse, ClobError>
pub async fn post_signed_order_typed( &self, signed_order: &SignedOrder, order_type: OrderType, defer_exec: bool, post_only: Option<bool>, ) -> Result<OrderResponse, ClobError>
Typed variant of posting a signed order: posts the signed order and attempts to
deserialize the response into an OrderResponse (or into the data field if present).
Sourcepub async fn create_and_post_order(
&self,
user_order: UserOrder,
options_tick: Option<&str>,
order_type: Option<OrderType>,
defer_exec: bool,
post_only: Option<bool>,
) -> Result<OrderResponse, ClobError>
pub async fn create_and_post_order( &self, user_order: UserOrder, options_tick: Option<&str>, order_type: Option<OrderType>, defer_exec: bool, post_only: Option<bool>, ) -> Result<OrderResponse, ClobError>
Convenience: create (build & sign) then immediately post a limit order. orderType defaults to GTC (Good Till Cancelled). Matches TypeScript SDK signature: createAndPostOrder(userOrder, options, orderType, deferExec, postOnly)
Sourcepub async fn create_and_post_market_order(
&self,
user_market_order: UserMarketOrder,
options_tick: Option<&str>,
order_type: Option<OrderType>,
defer_exec: bool,
) -> Result<OrderResponse, ClobError>
pub async fn create_and_post_market_order( &self, user_market_order: UserMarketOrder, options_tick: Option<&str>, order_type: Option<OrderType>, defer_exec: bool, ) -> Result<OrderResponse, ClobError>
Convenience: create (build & sign) then immediately post a market order. orderType defaults to FOK (Fill Or Kill). Matches TypeScript SDK signature: createAndPostMarketOrder(userMarketOrder, options, orderType, deferExec)
Sourcepub async fn post_orders_typed(
&self,
orders: Vec<SignedOrder>,
_defer_exec: bool,
) -> Result<Value, ClobError>
pub async fn post_orders_typed( &self, orders: Vec<SignedOrder>, _defer_exec: bool, ) -> Result<Value, ClobError>
Helper: accept typed SignedOrder list and post them to POST_ORDERS endpoint.
Sourcepub async fn post_orders_typed_parsed(
&self,
orders: Vec<SignedOrder>,
_defer_exec: bool,
) -> Result<Vec<Order>, ClobError>
pub async fn post_orders_typed_parsed( &self, orders: Vec<SignedOrder>, _defer_exec: bool, ) -> Result<Vec<Order>, ClobError>
Post typed orders and return parsed Vec<Order> from the response.
This wraps the existing post_orders_typed which returns a raw JSON Value
and attempts to parse either a top-level array or data field into Vec<Order>.
pub async fn cancel_all(&self) -> Result<Vec<Order>, ClobError>
pub async fn cancel_market_orders( &self, payload: OrderMarketCancelParams, ) -> Result<Vec<Order>, ClobError>
pub async fn is_order_scoring( &self, params: Option<HashMap<String, String>>, ) -> Result<OrderScoring, ClobError>
pub async fn are_orders_scoring( &self, order_ids: Option<Vec<String>>, ) -> Result<OrdersScoring, ClobError>
Sourcepub async fn cancel_order_payload(
&self,
payload: OrderPayloadParity,
) -> Result<Order, ClobError>
pub async fn cancel_order_payload( &self, payload: OrderPayloadParity, ) -> Result<Order, ClobError>
Parity version using JSON body { orderID } instead of query param.
Sourcepub async fn cancel_order_payload_raw(
&self,
payload: OrderPayloadParity,
) -> Result<Value, ClobError>
pub async fn cancel_order_payload_raw( &self, payload: OrderPayloadParity, ) -> Result<Value, ClobError>
Raw JSON variant: return the API response as serde_json::Value (parity with TS any).
pub async fn cancel_orders( &self, order_ids: Vec<String>, ) -> Result<Vec<Order>, ClobError>
pub async fn get_order(&self, order_id: &str) -> Result<OpenOrder, ClobError>
Sourcepub async fn get_order_typed(
&self,
order_id: &str,
) -> Result<OpenOrder, ClobError>
pub async fn get_order_typed( &self, order_id: &str, ) -> Result<OpenOrder, ClobError>
Typed variant: try to deserialize an order response into OpenOrder.
pub async fn get_open_orders( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<SignedOrder>, ClobError>
Sourcepub async fn get_open_orders_typed(
&self,
params: Option<HashMap<String, String>>,
) -> Result<Vec<SignedOrder>, ClobError>
pub async fn get_open_orders_typed( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<SignedOrder>, ClobError>
Typed variant: try to deserialize open orders data into Vec
pub async fn get_markets( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Market>, ClobError>
pub async fn get_market( &self, market_id: &str, params: Option<HashMap<String, String>>, ) -> Result<Market, ClobError>
pub async fn get_simplified_markets( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Market>, ClobError>
pub async fn get_sampling_markets( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Market>, ClobError>
pub async fn get_server_time(&self) -> Result<u64, ClobError>
pub async fn create_api_key( &self, nonce: Option<u64>, ) -> Result<ApiKeyCreds, ClobError>
pub async fn derive_api_key( &self, params: Option<HashMap<String, String>>, ) -> Result<ApiKeyCreds, ClobError>
pub async fn create_builder_api_key(&self) -> Result<ApiKeyCreds, ClobError>
pub async fn get_builder_api_keys(&self) -> Result<Vec<ApiKeyCreds>, ClobError>
pub async fn revoke_builder_api_key(&self) -> Result<(), ClobError>
pub async fn get_sampling_simplified_markets( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Market>, ClobError>
Sourcepub async fn get_order_books(
&self,
params: &[BookParams],
) -> Result<Vec<OrderBookSummary>, ClobError>
pub async fn get_order_books( &self, params: &[BookParams], ) -> Result<Vec<OrderBookSummary>, ClobError>
POST /books with [{"token_id":"..."}] → array of OrderBookSummary
Sourcepub async fn get_midpoint(
&self,
params: Option<HashMap<String, String>>,
) -> Result<MidpointResponse, ClobError>
pub async fn get_midpoint( &self, params: Option<HashMap<String, String>>, ) -> Result<MidpointResponse, ClobError>
GET /midpoint?token_id=... → {"mid": "0.77"}
Sourcepub async fn get_midpoints(
&self,
params: &[BookParams],
) -> Result<Value, ClobError>
pub async fn get_midpoints( &self, params: &[BookParams], ) -> Result<Value, ClobError>
POST /midpoints with [{"token_id":"..."}] → {"TOKEN_ID": "0.77"}
Sourcepub async fn get_price(
&self,
token_id: &str,
side: &str,
) -> Result<PriceResponse, ClobError>
pub async fn get_price( &self, token_id: &str, side: &str, ) -> Result<PriceResponse, ClobError>
GET /price?token_id=...&side=BUY → {"price": "0.76"}
Sourcepub async fn get_prices(
&self,
params: &[BookParams],
) -> Result<Value, ClobError>
pub async fn get_prices( &self, params: &[BookParams], ) -> Result<Value, ClobError>
POST /prices with [{"token_id":"...","side":"BUY"}] → {"TOKEN_ID": {"BUY": "0.76"}}
Sourcepub async fn get_spread(
&self,
token_id: &str,
) -> Result<SpreadResponse, ClobError>
pub async fn get_spread( &self, token_id: &str, ) -> Result<SpreadResponse, ClobError>
GET /spread?token_id=... → {"spread": "0.02"}
Sourcepub async fn get_spreads(
&self,
params: &[BookParams],
) -> Result<Value, ClobError>
pub async fn get_spreads( &self, params: &[BookParams], ) -> Result<Value, ClobError>
POST /spreads with [{"token_id":"..."}] → {"TOKEN_ID": "0.02"}
Sourcepub async fn get_last_trade_price(
&self,
token_id: &str,
) -> Result<LastTradePriceResponse, ClobError>
pub async fn get_last_trade_price( &self, token_id: &str, ) -> Result<LastTradePriceResponse, ClobError>
GET /last-trade-price?token_id=... → {"price": "0.8", "side": "BUY"}
Sourcepub async fn get_last_trades_prices(
&self,
params: &[BookParams],
) -> Result<Value, ClobError>
pub async fn get_last_trades_prices( &self, params: &[BookParams], ) -> Result<Value, ClobError>
POST /last-trades-prices with [{"token_id":"..."}] → [{"price":"0.8","side":"BUY","token_id":"..."}]
Sourcepub async fn get_prices_history(
&self,
params: Option<HashMap<String, String>>,
) -> Result<Vec<MarketPrice>, ClobError>
pub async fn get_prices_history( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<MarketPrice>, ClobError>
GET /prices-history?market=TOKEN_ID&interval=...&fidelity=... → {"history": [{t, p}]}
pub async fn get_market_trades_events( &self, market_id: &str, params: Option<HashMap<String, String>>, ) -> Result<Vec<Trade>, ClobError>
pub async fn get_earnings_for_user_for_day( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Reward>, ClobError>
pub async fn get_total_earnings_for_user_for_day( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Reward>, ClobError>
Sourcepub async fn get_total_earnings_for_user_for_day_typed(
&self,
params: Option<HashMap<String, String>>,
) -> Result<Vec<Reward>, ClobError>
pub async fn get_total_earnings_for_user_for_day_typed( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Reward>, ClobError>
Typed wrapper for total earnings for user for day. Attempts to parse an array of Reward.
pub async fn get_liquidity_reward_percentages( &self, params: Option<HashMap<String, String>>, ) -> Result<HashMap<String, f64>, ClobError>
Sourcepub async fn get_liquidity_reward_percentages_typed(
&self,
params: Option<HashMap<String, String>>,
) -> Result<HashMap<String, f64>, ClobError>
pub async fn get_liquidity_reward_percentages_typed( &self, params: Option<HashMap<String, String>>, ) -> Result<HashMap<String, f64>, ClobError>
Typed wrapper for liquidity reward percentages. Attempts to parse into a map of market -> percentage.
pub async fn get_rewards_markets_current( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<RewardsMarket>, ClobError>
pub async fn get_rewards_markets( &self, market_id: &str, params: Option<HashMap<String, String>>, ) -> Result<Vec<Reward>, ClobError>
Sourcepub async fn get_rewards_markets_typed(
&self,
market_id: &str,
params: Option<HashMap<String, String>>,
) -> Result<Vec<Reward>, ClobError>
pub async fn get_rewards_markets_typed( &self, market_id: &str, params: Option<HashMap<String, String>>, ) -> Result<Vec<Reward>, ClobError>
Typed wrapper for get_rewards_markets (per-market rewards). Returns Vec
pub async fn get_rewards_earnings_percentages( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Reward>, ClobError>
Sourcepub async fn get_rewards_earnings_percentages_typed(
&self,
params: Option<HashMap<String, String>>,
) -> Result<Vec<Reward>, ClobError>
pub async fn get_rewards_earnings_percentages_typed( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Reward>, ClobError>
Typed wrapper for rewards earnings percentages. Returns Vec
pub async fn get_builder_trades( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<BuilderTrade>, ClobError>
Sourcepub async fn get_builder_trades_typed(
&self,
params: Option<HashMap<String, String>>,
) -> Result<Vec<BuilderTrade>, ClobError>
pub async fn get_builder_trades_typed( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<BuilderTrade>, ClobError>
Typed variant for builder trades (kept for compatibility)
Sourcepub async fn get_earnings_for_user_for_day_typed(
&self,
params: Option<HashMap<String, String>>,
) -> Result<Vec<Reward>, ClobError>
pub async fn get_earnings_for_user_for_day_typed( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<Reward>, ClobError>
Typed wrapper for get_earnings_for_user_for_day -> Vec
Sourcepub async fn get_rewards_markets_current_typed(
&self,
params: Option<HashMap<String, String>>,
) -> Result<Vec<RewardsMarket>, ClobError>
pub async fn get_rewards_markets_current_typed( &self, params: Option<HashMap<String, String>>, ) -> Result<Vec<RewardsMarket>, ClobError>
Typed wrapper for current rewards markets
Sourcepub async fn post_heartbeat(
&self,
heartbeat_id: Option<&str>,
) -> Result<HeartbeatResponse, ClobError>
pub async fn post_heartbeat( &self, heartbeat_id: Option<&str>, ) -> Result<HeartbeatResponse, ClobError>
Post a heartbeat to keep the session alive (added in v5.2.0)
Heartbeats must be sent within 10 seconds of each other. If a heartbeat is not received within 10 seconds, all orders will be cancelled.
Use heartbeat_id=None for the first heartbeat, then chain subsequent heartbeats using the returned heartbeat_id.
§Arguments
heartbeat_id- Optional heartbeat ID from a previous heartbeat to chain them
§Returns
HeartbeatResponsecontaining the heartbeat_id to use for the next heartbeat
Auto Trait Implementations§
impl Freeze for ClobClient
impl !RefUnwindSafe for ClobClient
impl Send for ClobClient
impl Sync for ClobClient
impl Unpin for ClobClient
impl UnsafeUnpin for ClobClient
impl !UnwindSafe for ClobClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more