|
| 1 | +import type { Wallet } from "@ethersproject/wallet"; |
| 2 | +import type { JsonRpcSigner } from "@ethersproject/providers"; |
| 3 | +import { SignatureType } from "@polymarket/order-utils"; |
| 4 | +import type { SignedOrder } from "@polymarket/order-utils"; |
| 5 | +import type { BuilderConfig } from "@polymarket/builder-signing-sdk"; |
| 6 | +import { OrderType, Side } from "./types.ts"; |
| 7 | +import type { ApiKeyCreds, ApiKeysResponse, Chain, CreateOrderOptions, MarketPrice, OpenOrderParams, OpenOrdersResponse, OrderMarketCancelParams, OrderBookSummary, OrderPayload, Trade, Notification, TradeParams, UserMarketOrder, UserOrder, BalanceAllowanceParams, BalanceAllowanceResponse, OrderScoringParams, OrderScoring, OpenOrder, TickSizes, TickSize, OrdersScoringParams, OrdersScoring, PriceHistoryFilterParams, PaginationPayload, MarketTradeEvent, DropNotificationParams, BookParams, UserEarning, RewardsPercentages, MarketReward, UserRewardsEarning, TotalUserEarning, NegRisk, BanStatus, PostOrdersArgs, FeeRates, BuilderTrade, BuilderApiKey, BuilderApiKeyResponse } from "./types.ts"; |
| 8 | +import { OrderBuilder } from "./order-builder/builder.ts"; |
| 9 | +export declare class ClobClient { |
| 10 | + readonly host: string; |
| 11 | + readonly chainId: Chain; |
| 12 | + readonly signer?: Wallet | JsonRpcSigner; |
| 13 | + readonly creds?: ApiKeyCreds; |
| 14 | + readonly orderBuilder: OrderBuilder; |
| 15 | + readonly tickSizes: TickSizes; |
| 16 | + readonly negRisk: NegRisk; |
| 17 | + readonly feeRates: FeeRates; |
| 18 | + readonly geoBlockToken?: string; |
| 19 | + readonly useServerTime?: boolean; |
| 20 | + readonly builderConfig?: BuilderConfig; |
| 21 | + constructor(host: string, chainId: Chain, signer?: Wallet | JsonRpcSigner, creds?: ApiKeyCreds, signatureType?: SignatureType, funderAddress?: string, geoBlockToken?: string, useServerTime?: boolean, builderConfig?: BuilderConfig, getSigner?: () => Promise<Wallet | JsonRpcSigner> | (Wallet | JsonRpcSigner)); |
| 22 | + getOk(): Promise<any>; |
| 23 | + getServerTime(): Promise<number>; |
| 24 | + getSamplingSimplifiedMarkets(next_cursor?: string): Promise<PaginationPayload>; |
| 25 | + getSamplingMarkets(next_cursor?: string): Promise<PaginationPayload>; |
| 26 | + getSimplifiedMarkets(next_cursor?: string): Promise<PaginationPayload>; |
| 27 | + getMarkets(next_cursor?: string): Promise<PaginationPayload>; |
| 28 | + getMarket(conditionID: string): Promise<any>; |
| 29 | + getOrderBook(tokenID: string): Promise<OrderBookSummary>; |
| 30 | + getOrderBooks(params: BookParams[]): Promise<OrderBookSummary[]>; |
| 31 | + getTickSize(tokenID: string): Promise<TickSize>; |
| 32 | + getNegRisk(tokenID: string): Promise<boolean>; |
| 33 | + getFeeRateBps(tokenID: string): Promise<number>; |
| 34 | + /** |
| 35 | + * Calculates the hash for the given orderbook |
| 36 | + * @param orderbook |
| 37 | + * @returns |
| 38 | + */ |
| 39 | + getOrderBookHash(orderbook: OrderBookSummary): Promise<string>; |
| 40 | + getMidpoint(tokenID: string): Promise<any>; |
| 41 | + getMidpoints(params: BookParams[]): Promise<any>; |
| 42 | + getPrice(tokenID: string, side: string): Promise<any>; |
| 43 | + getPrices(params: BookParams[]): Promise<any>; |
| 44 | + getSpread(tokenID: string): Promise<any>; |
| 45 | + getSpreads(params: BookParams[]): Promise<any>; |
| 46 | + getLastTradePrice(tokenID: string): Promise<any>; |
| 47 | + getLastTradesPrices(params: BookParams[]): Promise<any>; |
| 48 | + getPricesHistory(params: PriceHistoryFilterParams): Promise<MarketPrice[]>; |
| 49 | + /** |
| 50 | + * Creates a new API key for a user |
| 51 | + * @param nonce |
| 52 | + * @returns ApiKeyCreds |
| 53 | + */ |
| 54 | + createApiKey(nonce?: number): Promise<ApiKeyCreds>; |
| 55 | + /** |
| 56 | + * Derives an existing API key for a user |
| 57 | + * @param nonce |
| 58 | + * @returns ApiKeyCreds |
| 59 | + */ |
| 60 | + deriveApiKey(nonce?: number): Promise<ApiKeyCreds>; |
| 61 | + createOrDeriveApiKey(nonce?: number): Promise<ApiKeyCreds>; |
| 62 | + getApiKeys(): Promise<ApiKeysResponse>; |
| 63 | + getClosedOnlyMode(): Promise<BanStatus>; |
| 64 | + deleteApiKey(): Promise<any>; |
| 65 | + getOrder(orderID: string): Promise<OpenOrder>; |
| 66 | + getTrades(params?: TradeParams, only_first_page?: boolean, next_cursor?: string): Promise<Trade[]>; |
| 67 | + getTradesPaginated(params?: TradeParams, next_cursor?: string): Promise<{ |
| 68 | + trades: Trade[]; |
| 69 | + next_cursor: string; |
| 70 | + limit: number; |
| 71 | + count: number; |
| 72 | + }>; |
| 73 | + getBuilderTrades(params?: TradeParams, next_cursor?: string): Promise<{ |
| 74 | + trades: BuilderTrade[]; |
| 75 | + next_cursor: string; |
| 76 | + limit: number; |
| 77 | + count: number; |
| 78 | + }>; |
| 79 | + getNotifications(): Promise<Notification[]>; |
| 80 | + dropNotifications(params?: DropNotificationParams): Promise<void>; |
| 81 | + getBalanceAllowance(params?: BalanceAllowanceParams): Promise<BalanceAllowanceResponse>; |
| 82 | + updateBalanceAllowance(params?: BalanceAllowanceParams): Promise<void>; |
| 83 | + createOrder(userOrder: UserOrder, options?: Partial<CreateOrderOptions>): Promise<SignedOrder>; |
| 84 | + createMarketOrder(userMarketOrder: UserMarketOrder, options?: Partial<CreateOrderOptions>): Promise<SignedOrder>; |
| 85 | + createAndPostOrder<T extends OrderType.GTC | OrderType.GTD = OrderType.GTC>(userOrder: UserOrder, options?: Partial<CreateOrderOptions>, orderType?: T, deferExec?: boolean): Promise<any>; |
| 86 | + createAndPostMarketOrder<T extends OrderType.FOK | OrderType.FAK = OrderType.FOK>(userMarketOrder: UserMarketOrder, options?: Partial<CreateOrderOptions>, orderType?: T, deferExec?: boolean): Promise<any>; |
| 87 | + getOpenOrders(params?: OpenOrderParams, only_first_page?: boolean, next_cursor?: string): Promise<OpenOrdersResponse>; |
| 88 | + postOrder<T extends OrderType = OrderType.GTC>(order: SignedOrder, orderType?: T, deferExec?: boolean): Promise<any>; |
| 89 | + postOrders(args: PostOrdersArgs[], deferExec?: boolean): Promise<any>; |
| 90 | + cancelOrder(payload: OrderPayload): Promise<any>; |
| 91 | + cancelOrders(ordersHashes: string[]): Promise<any>; |
| 92 | + cancelAll(): Promise<any>; |
| 93 | + cancelMarketOrders(payload: OrderMarketCancelParams): Promise<any>; |
| 94 | + isOrderScoring(params?: OrderScoringParams): Promise<OrderScoring>; |
| 95 | + areOrdersScoring(params?: OrdersScoringParams): Promise<OrdersScoring>; |
| 96 | + getEarningsForUserForDay(date: string): Promise<UserEarning[]>; |
| 97 | + getTotalEarningsForUserForDay(date: string): Promise<TotalUserEarning[]>; |
| 98 | + getUserEarningsAndMarketsConfig(date: string, order_by?: string, position?: string, no_competition?: boolean): Promise<UserRewardsEarning[]>; |
| 99 | + getRewardPercentages(): Promise<RewardsPercentages>; |
| 100 | + getCurrentRewards(): Promise<MarketReward[]>; |
| 101 | + getRawRewardsForMarket(conditionId: string): Promise<MarketReward[]>; |
| 102 | + getMarketTradesEvents(conditionID: string): Promise<MarketTradeEvent[]>; |
| 103 | + calculateMarketPrice(tokenID: string, side: Side, amount: number, orderType?: OrderType): Promise<number>; |
| 104 | + createBuilderApiKey(): Promise<BuilderApiKey>; |
| 105 | + getBuilderApiKeys(): Promise<BuilderApiKeyResponse[]>; |
| 106 | + revokeBuilderApiKey(): Promise<any>; |
| 107 | + private canL1Auth; |
| 108 | + private canL2Auth; |
| 109 | + private mustBuilderAuth; |
| 110 | + private canBuilderAuth; |
| 111 | + private _resolveTickSize; |
| 112 | + private _resolveFeeRateBps; |
| 113 | + private _generateBuilderHeaders; |
| 114 | + private _getBuilderHeaders; |
| 115 | + private get; |
| 116 | + private post; |
| 117 | + private del; |
| 118 | +} |
0 commit comments