@liberfi.io/react-predict 0.3.32 → 0.3.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +79 -4
- package/dist/index.d.ts +79 -4
- package/dist/index.js +154 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +150 -1
- package/dist/index.mjs.map +1 -1
- package/dist/{server-FZwoxwxh.d.mts → server-DfzGla54.d.mts} +64 -2
- package/dist/{server-FZwoxwxh.d.ts → server-DfzGla54.d.ts} +64 -2
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +24 -0
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +24 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as Orderbook, h as ListMarketTradesParams, i as PredictTrade, j as PriceHistoryRange, k as PriceHistoryResponse, l as ListCandlesticksParams, C as Candlestick, m as ListCommentsParams, n as PredictComment, o as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, p as ListOrdersParams, q as PredictOrder, r as ListOrdersMultiParams, s as PredictOrdersResponse, t as CancelOrderResult, M as MatchesParams, u as MatchGroupPage, v as MatchGroup, w as MatchMarketParams, x as MatchMarketPage, y as ListTradesParams, z as ListTradesMultiParams, D as DFlowQuoteRequest, F as DFlowQuoteResponse, G as DFlowSubmitResponse, H as DFlowSubmitRequest, I as DFlowKYCStatus, J as PolymarketSetupStatus, W as WithdrawBuildResponse,
|
|
2
|
-
export {
|
|
1
|
+
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as Orderbook, h as ListMarketTradesParams, i as PredictTrade, j as PriceHistoryRange, k as PriceHistoryResponse, l as ListCandlesticksParams, C as Candlestick, m as ListCommentsParams, n as PredictComment, o as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, p as ListOrdersParams, q as PredictOrder, r as ListOrdersMultiParams, s as PredictOrdersResponse, t as CancelOrderResult, M as MatchesParams, u as MatchGroupPage, v as MatchGroup, w as MatchMarketParams, x as MatchMarketPage, y as ListTradesParams, z as ListTradesMultiParams, D as DFlowQuoteRequest, F as DFlowQuoteResponse, G as DFlowSubmitResponse, H as DFlowSubmitRequest, I as DFlowKYCStatus, J as PolymarketSetupStatus, K as PolymarketDepositWalletDeployResponse, W as WithdrawBuildResponse, N as WithdrawBuildRequest, Q as WithdrawSubmitResponse, R as WithdrawSubmitRequest, T as WithdrawStatusResponse, U as PolymarketDepositAddresses, V as PolymarketSupportedAsset, X as PolymarketWithdrawResponse, Y as PolymarketWithdrawRequest, Z as PolymarketRedeemResponse, _ as TickSizeResponse, $ as FeeRateResponse, a0 as RebateConfig, a1 as WsConnectionStatus, a2 as WsDataMessage, a3 as WsPriceEvent, a4 as WsOrderbookEvent, a5 as WsTradeEvent, a6 as CreateOrderInput } from './server-DfzGla54.mjs';
|
|
2
|
+
export { bl as BuildClobAuthMessageInput, bz as BuildOrderMessageInput, bc as CLOB_AUTH_DOMAIN, bd as CLOB_AUTH_TYPES, bm as CTF_EXCHANGE_ADDRESS, br as CTF_ORDER_TYPES, by as ClobOrderPayload, ap as DFlowOrderContext, at as DepositBuildRequest, au as DepositBuildResponse, ax as DepositStatusResponse, av as DepositSubmitRequest, aw as DepositSubmitResponse, ai as EventSummary, bi as HttpMethod, af as MarketOutcome, ae as MarketResult, ad as MarketStatus, aj as MarketSummary, aI as MatchConfidenceTier, aE as MatchGroupEntry, aF as MatchGroupMarket, aK as MatchLeg, aL as MatchMarketFlat, aG as MatchSortField, aD as MatchStatus, aH as MatchesStats, bn as NEG_RISK_CTF_EXCHANGE_ADDRESS, bs as ORDER_TYPE, bA as OrderMessage, ao as OrderSide, an as OrderStatus, ag as OrderbookLevel, bp as POLYGON_CHAIN_ID, az as PolymarketBridgeToken, as as PolymarketDepositWalletDeployRequest, bk as PolymarketL2Headers, bj as PolymarketL2HeadersInput, aq as PolymarketOrderType, aY as PolymarketRedeemInput, aW as PolymarketRedeemPrepareInput, aX as PolymarketRedeemPrepareResponse, aA as PolymarketSupportedAssetsResponse, ar as PolymarketWalletKind, aB as PolymarketWithdrawPrepareRequest, aC as PolymarketWithdrawPrepareResponse, ak as PredictCommentProfile, am as PredictPosition, ab as PredictTag, a9 as PredictWsClientConfig, al as PricePoint, aa as ProviderMeta, b3 as ResolveEventsParamsInput, bt as SIDE, ac as SettlementSource, aJ as SignalTag, bB as SignedOrder, b4 as TagSlugSelection, ah as TradeType, bo as USDC_ADDRESS, ay as UnsignedTx, aM as WsChannel, aN as WsChannelEvent, aO as WsClientMessage, aU as WsErrorCode, aV as WsErrorMessage, aQ as WsPingMessage, aS as WsPongMessage, aR as WsServerMessage, aP as WsSubscribeMessage, aT as WsSubscribedMessage, be as buildClobAuthMessage, bw as buildClobPayload, bq as buildCtfExchangeDomain, bu as buildOrderMessage, bg as buildPolymarketL2Headers, bv as buildSignedOrder, a7 as createPredictClient, a8 as createPredictWsClient, bh as derivePolymarketApiKey, aZ as eventQueryKey, a_ as fetchEvent, b2 as fetchEventsPage, b6 as fetchMarket, bb as fetchMatchMarketsPage, b9 as fetchMatchesPage, bx as getPolymarketSharesPrecision, bf as hmacSha256Base64, b1 as infiniteEventsQueryKey, b5 as marketQueryKey, ba as matchMarketsQueryKey, b8 as matchQueryKey, b7 as matchesQueryKey, b0 as resolveEventsParams, a$ as resolveTagSlug } from './server-DfzGla54.mjs';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { PropsWithChildren } from 'react';
|
|
6
6
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
7
|
import { UseQueryOptions, UseInfiniteQueryOptions, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
|
|
8
|
+
import { orderToJsonV2 } from '@polymarket/clob-client-v2';
|
|
8
9
|
|
|
9
10
|
type PredictProviderProps = PropsWithChildren<{
|
|
10
11
|
/**
|
|
@@ -132,8 +133,9 @@ interface PolymarketSigner {
|
|
|
132
133
|
* - `0` = EOA (MetaMask, Coinbase, etc.)
|
|
133
134
|
* - `1` = Magic Link
|
|
134
135
|
* - `2` = Polymarket proxy (Gnosis Safe)
|
|
136
|
+
* - `3` = POLY_1271 (CLOB V2 deposit wallet, ERC-7739-wrapped ERC-1271)
|
|
135
137
|
*/
|
|
136
|
-
signatureType: 0 | 1 | 2;
|
|
138
|
+
signatureType: 0 | 1 | 2 | 3;
|
|
137
139
|
/**
|
|
138
140
|
* Sign EIP-712 typed data and return the hex signature.
|
|
139
141
|
* The signature is used for L1 authentication with the Polymarket CLOB API.
|
|
@@ -562,6 +564,12 @@ declare function usePolymarketSetup(walletAddress?: string, queryOptions?: Omit<
|
|
|
562
564
|
* Automatically invalidates the setup status query on success.
|
|
563
565
|
*/
|
|
564
566
|
declare function useRunPolymarketSetup(walletAddress?: string): _tanstack_react_query.UseMutationResult<PolymarketSetupStatus, Error, string, unknown>;
|
|
567
|
+
/**
|
|
568
|
+
* Mutation hook to deploy a Polymarket CLOB V2 deposit wallet for new
|
|
569
|
+
* (non-Safe) users via a gasless WALLET-CREATE relayer request. No user
|
|
570
|
+
* signature is required. Invalidates the setup status query on success.
|
|
571
|
+
*/
|
|
572
|
+
declare function useDeployPolymarketDepositWallet(walletAddress?: string): _tanstack_react_query.UseMutationResult<PolymarketDepositWalletDeployResponse, Error, string, unknown>;
|
|
565
573
|
|
|
566
574
|
declare function useWithdrawBuildMutation(mutationOptions?: Omit<UseMutationOptions<WithdrawBuildResponse, Error, WithdrawBuildRequest>, "mutationFn">): _tanstack_react_query.UseMutationResult<WithdrawBuildResponse, Error, WithdrawBuildRequest, unknown>;
|
|
567
575
|
|
|
@@ -712,6 +720,16 @@ declare function feeRateQueryKey(tokenId: string): unknown[];
|
|
|
712
720
|
*/
|
|
713
721
|
declare function useFeeRate(tokenId?: string, queryOptions?: Omit<UseQueryOptions<FeeRateResponse, Error, FeeRateResponse, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<FeeRateResponse, Error>;
|
|
714
722
|
|
|
723
|
+
declare function rebateConfigQueryKey(): unknown[];
|
|
724
|
+
/**
|
|
725
|
+
* Query hook for the builder-attribution / rebate config
|
|
726
|
+
* (`GET /api/v1/referral/config`). Consumers read `builder_enabled` +
|
|
727
|
+
* `builder_code` to attach our builder code to CLOB V2 orders for rebates.
|
|
728
|
+
*
|
|
729
|
+
* The config is process-global and rarely changes, so it is cached aggressively.
|
|
730
|
+
*/
|
|
731
|
+
declare function useRebateConfig(queryOptions?: Omit<UseQueryOptions<RebateConfig, Error, RebateConfig, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<RebateConfig, Error>;
|
|
732
|
+
|
|
715
733
|
interface UsePredictWsClientResult {
|
|
716
734
|
/** The WebSocket client instance, or `null` if not provided via `PredictProvider`. */
|
|
717
735
|
wsClient: PredictWsClient | null;
|
|
@@ -945,6 +963,63 @@ interface CreatePolymarketOrderVariables {
|
|
|
945
963
|
*/
|
|
946
964
|
declare function useCreatePolymarketOrder(mutationOptions?: Omit<UseMutationOptions<PredictOrder, Error, CreatePolymarketOrderVariables>, "mutationFn">): _tanstack_react_query.UseMutationResult<PredictOrder, Error, CreatePolymarketOrderVariables, unknown>;
|
|
947
965
|
|
|
966
|
+
/**
|
|
967
|
+
* Polymarket CLOB V2 (POLY_1271 / signatureType=3) order construction.
|
|
968
|
+
*
|
|
969
|
+
* Deposit-wallet orders use an ERC-7739-wrapped ERC-1271 signature over the V2
|
|
970
|
+
* `Order` struct on the CTF Exchange V2 contracts. Reproducing that wrapper by
|
|
971
|
+
* hand is error-prone, so we delegate signing to the official
|
|
972
|
+
* `@polymarket/clob-client-v2` `OrderBuilder`, then submit the resulting payload
|
|
973
|
+
* through the existing prediction-server CLOB proxy (with our own L2 HMAC).
|
|
974
|
+
*
|
|
975
|
+
* The legacy Safe path (signatureType=2, V1 exchange) stays in
|
|
976
|
+
* `polymarket-order.ts`.
|
|
977
|
+
*
|
|
978
|
+
* @see https://docs.polymarket.com/trading/deposit-wallets
|
|
979
|
+
*/
|
|
980
|
+
|
|
981
|
+
/** V2 CLOB order payload (mirrors `orderToJsonV2` output). */
|
|
982
|
+
type ClobOrderV2Payload = ReturnType<typeof orderToJsonV2>;
|
|
983
|
+
interface BuildV2OrderParams {
|
|
984
|
+
/** App-provided signer (the deposit wallet owner EOA). Must be POLY_1271. */
|
|
985
|
+
signer: PolymarketSigner;
|
|
986
|
+
/** Deposit wallet address — used as both `maker` and `signer` of the order. */
|
|
987
|
+
depositWalletAddress: string;
|
|
988
|
+
/** Order parameters (token, price, size, side, tick, etc.). */
|
|
989
|
+
input: CreateOrderInput;
|
|
990
|
+
/** CLOB owner (L2 API key) attached to the submitted payload. */
|
|
991
|
+
owner: string;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Build and sign a CLOB V2 deposit-wallet order, returning the JSON payload
|
|
995
|
+
* ready to POST to Polymarket's `/order` endpoint (via the server proxy).
|
|
996
|
+
*
|
|
997
|
+
* `maker` and `signer` are both set to the deposit wallet address (enforced by
|
|
998
|
+
* the SDK for POLY_1271). The owner EOA signs the ERC-7739 wrapper.
|
|
999
|
+
*/
|
|
1000
|
+
declare function buildSignedV2OrderPayload(params: BuildV2OrderParams): Promise<ClobOrderV2Payload>;
|
|
1001
|
+
interface SyncBalanceAllowanceParams {
|
|
1002
|
+
/** App-provided signer (the deposit wallet owner EOA). */
|
|
1003
|
+
signer: PolymarketSigner;
|
|
1004
|
+
/** In-memory L2 credentials obtained from PolymarketContext. */
|
|
1005
|
+
credentials: PolymarketCredentials;
|
|
1006
|
+
/** Deposit wallet address (the order funder). */
|
|
1007
|
+
depositWalletAddress: string;
|
|
1008
|
+
/** Override the CLOB host (defaults to the public CLOB endpoint). */
|
|
1009
|
+
clobHost?: string;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Best-effort sync of the deposit wallet's CLOB collateral buying power.
|
|
1013
|
+
*
|
|
1014
|
+
* After deploy/approve/deposit, the CLOB's cached balance-allowance for the
|
|
1015
|
+
* deposit wallet can lag the on-chain state. Calling
|
|
1016
|
+
* `updateBalanceAllowance({ asset_type: COLLATERAL })` with `signature_type=3`
|
|
1017
|
+
* forces a refresh so the first order isn't rejected for insufficient
|
|
1018
|
+
* buying power. The CLOB also syncs lazily on order match, so callers should
|
|
1019
|
+
* treat failures here as non-fatal.
|
|
1020
|
+
*/
|
|
1021
|
+
declare function updatePolymarketBalanceAllowance(params: SyncBalanceAllowanceParams): Promise<void>;
|
|
1022
|
+
|
|
948
1023
|
/**
|
|
949
1024
|
* Orderbook-aware pricing utilities for prediction-market orders.
|
|
950
1025
|
*
|
|
@@ -1012,4 +1087,4 @@ interface WalkOrderbookParams {
|
|
|
1012
1087
|
*/
|
|
1013
1088
|
declare function walkOrderbook({ orderbook, outcome, side, sharesNeeded, slippageBps, }: WalkOrderbookParams): WalkResult;
|
|
1014
1089
|
|
|
1015
|
-
export { AvailableSharesResponse, BalanceResponse, CancelOrderResult, type CancelOrderVariables, Candlestick, ChartRange, type ChartRangeType, CreateOrderInput, type CreatePolymarketOrderVariables, DFlowKYCStatus, DFlowQuoteRequest, DFlowQuoteResponse, DFlowSubmitRequest, DFlowSubmitResponse, EventSortField, EventStats, EventStatus, FeeRateResponse, ListCandlesticksParams, ListCommentsParams, ListEventsParams, ListMarketTradesParams, ListOrdersMultiParams, ListOrdersParams, ListTradesMultiParams, ListTradesParams, type MarketHistoryPoint, type MarketHistorySeries, MatchGroup, MatchGroupPage, MatchMarketPage, MatchMarketParams, MatchesParams, Orderbook, PolymarketContext, type PolymarketContextValue, type PolymarketCredentials, PolymarketDepositAddresses, type PolymarketDepositResult, type PolymarketDepositVariables, PolymarketProvider, type PolymarketProviderProps, PolymarketRedeemResponse, type PolymarketSigner, PolymarketSupportedAsset, PolymarketWithdrawRequest, PolymarketWithdrawResponse, PositionsResponse, PredictClient, PredictComment, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictOrdersResponse, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryRange, PriceHistoryResponse, ProviderSource, type RedeemPositionVariables, SimilarEventsParams, TickSizeResponse, type UseAvailableSharesOptions, type UseAvailableSharesParams, type UseBalanceParams, type UseCancelOrderOptions, type UseCandlesticksParams, type UseEventParams, type UseInfiniteCommentsParams, type UseInfiniteMatchMarketsParams, type UseInfiniteMatchesParams, type UseInfiniteOrdersOptions, type UseInfiniteOrdersParams, type UseInfiniteTradesMultiParams, type UseInfiniteTradesParams, type UseMarketHistoryResult, type UseMarketParams, type UseMarketTradesParams, type UseOrderParams, type UseOrderbookParams, type UseOrderbookSubscriptionParams, type UseOrderbookSubscriptionResult, type UseOrdersMultiOptions, type UseOrdersOptions, type UsePositionsMultiParams, type UsePositionsParams, type UsePredictWsClientResult, type UsePriceHistoryParams, type UsePricesSubscriptionParams, type UsePricesSubscriptionResult, type UseRealtimeOrderbookParams, type UseRealtimePricesParams, type UseRealtimeTradesParams, type UseRealtimeTradesResult, type UseSearchEventsParams, type UseSimilarEventsParams, type UseTradesSubscriptionParams, type UseTradesSubscriptionResult, type UseWithdrawStatusQueryParams, type WalkOrderbookParams, type WalkOutcome, type WalkResult, type WalkSide, type WalkStatus, WithdrawBuildRequest, WithdrawBuildResponse, WithdrawStatusResponse, WithdrawSubmitRequest, WithdrawSubmitResponse, WsConnectionStatus, WsDataMessage, WsOrderbookEvent, WsPriceEvent, WsTradeEvent, availableSharesQueryKey, balanceQueryKey, candlesticksQueryKey, dflowKYCQueryKey, dflowQuoteQueryKey, eventStatsQueryKey, eventsQueryKey, feeRateQueryKey, fetchEvents, infiniteCommentsQueryKey, infiniteOrdersQueryKey, infiniteTradesMultiQueryKey, infiniteTradesQueryKey, marketTradesQueryKey, orderQueryKey, orderbookQueryKey, ordersMultiQueryKey, ordersQueryKey, pickBestAsk, pickBestBid, polymarketDepositAddressesQueryKey, polymarketSetupQueryKey, polymarketSupportedAssetsQueryKey, positionsMultiQueryKey, positionsQueryKey, priceHistoryQueryKey, similarEventsQueryKey, tickSizeQueryKey, tradesQueryKey, useAvailableShares, useBalance, useCancelOrder, useCandlesticks, useCreatePolymarketOrder, useDFlowKYC, useDFlowQuote, useDFlowSubmit, useEvent, useEventStats, useEvents, useFeeRate, useInfiniteComments, useInfiniteEvents, useInfiniteMatchMarkets, useInfiniteMatches, useInfiniteOrders, useInfiniteTrades, useInfiniteTradesMulti, useMarket, useMarketHistory, useMarketTrades, useMatch, useOrder, useOrderbook, useOrderbookSubscription, useOrders, useOrdersMulti, usePolymarket, usePolymarketDeposit, usePolymarketDepositAddresses, usePolymarketSetup, usePolymarketSupportedAssets, usePolymarketWithdraw, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRedeemPosition, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTickSize, useTrades, useTradesSubscription, useWithdrawBuildMutation, useWithdrawStatusQuery, useWithdrawSubmitMutation, walkOrderbook, withdrawStatusQueryKey };
|
|
1090
|
+
export { AvailableSharesResponse, BalanceResponse, type BuildV2OrderParams, CancelOrderResult, type CancelOrderVariables, Candlestick, ChartRange, type ChartRangeType, type ClobOrderV2Payload, CreateOrderInput, type CreatePolymarketOrderVariables, DFlowKYCStatus, DFlowQuoteRequest, DFlowQuoteResponse, DFlowSubmitRequest, DFlowSubmitResponse, EventSortField, EventStats, EventStatus, FeeRateResponse, ListCandlesticksParams, ListCommentsParams, ListEventsParams, ListMarketTradesParams, ListOrdersMultiParams, ListOrdersParams, ListTradesMultiParams, ListTradesParams, type MarketHistoryPoint, type MarketHistorySeries, MatchGroup, MatchGroupPage, MatchMarketPage, MatchMarketParams, MatchesParams, Orderbook, PolymarketContext, type PolymarketContextValue, type PolymarketCredentials, PolymarketDepositAddresses, type PolymarketDepositResult, type PolymarketDepositVariables, PolymarketDepositWalletDeployResponse, PolymarketProvider, type PolymarketProviderProps, PolymarketRedeemResponse, PolymarketSetupStatus, type PolymarketSigner, PolymarketSupportedAsset, PolymarketWithdrawRequest, PolymarketWithdrawResponse, PositionsResponse, PredictClient, PredictComment, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictOrdersResponse, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryRange, PriceHistoryResponse, ProviderSource, RebateConfig, type RedeemPositionVariables, SimilarEventsParams, type SyncBalanceAllowanceParams, TickSizeResponse, type UseAvailableSharesOptions, type UseAvailableSharesParams, type UseBalanceParams, type UseCancelOrderOptions, type UseCandlesticksParams, type UseEventParams, type UseInfiniteCommentsParams, type UseInfiniteMatchMarketsParams, type UseInfiniteMatchesParams, type UseInfiniteOrdersOptions, type UseInfiniteOrdersParams, type UseInfiniteTradesMultiParams, type UseInfiniteTradesParams, type UseMarketHistoryResult, type UseMarketParams, type UseMarketTradesParams, type UseOrderParams, type UseOrderbookParams, type UseOrderbookSubscriptionParams, type UseOrderbookSubscriptionResult, type UseOrdersMultiOptions, type UseOrdersOptions, type UsePositionsMultiParams, type UsePositionsParams, type UsePredictWsClientResult, type UsePriceHistoryParams, type UsePricesSubscriptionParams, type UsePricesSubscriptionResult, type UseRealtimeOrderbookParams, type UseRealtimePricesParams, type UseRealtimeTradesParams, type UseRealtimeTradesResult, type UseSearchEventsParams, type UseSimilarEventsParams, type UseTradesSubscriptionParams, type UseTradesSubscriptionResult, type UseWithdrawStatusQueryParams, type WalkOrderbookParams, type WalkOutcome, type WalkResult, type WalkSide, type WalkStatus, WithdrawBuildRequest, WithdrawBuildResponse, WithdrawStatusResponse, WithdrawSubmitRequest, WithdrawSubmitResponse, WsConnectionStatus, WsDataMessage, WsOrderbookEvent, WsPriceEvent, WsTradeEvent, availableSharesQueryKey, balanceQueryKey, buildSignedV2OrderPayload, candlesticksQueryKey, dflowKYCQueryKey, dflowQuoteQueryKey, eventStatsQueryKey, eventsQueryKey, feeRateQueryKey, fetchEvents, infiniteCommentsQueryKey, infiniteOrdersQueryKey, infiniteTradesMultiQueryKey, infiniteTradesQueryKey, marketTradesQueryKey, orderQueryKey, orderbookQueryKey, ordersMultiQueryKey, ordersQueryKey, pickBestAsk, pickBestBid, polymarketDepositAddressesQueryKey, polymarketSetupQueryKey, polymarketSupportedAssetsQueryKey, positionsMultiQueryKey, positionsQueryKey, priceHistoryQueryKey, rebateConfigQueryKey, similarEventsQueryKey, tickSizeQueryKey, tradesQueryKey, updatePolymarketBalanceAllowance, useAvailableShares, useBalance, useCancelOrder, useCandlesticks, useCreatePolymarketOrder, useDFlowKYC, useDFlowQuote, useDFlowSubmit, useDeployPolymarketDepositWallet, useEvent, useEventStats, useEvents, useFeeRate, useInfiniteComments, useInfiniteEvents, useInfiniteMatchMarkets, useInfiniteMatches, useInfiniteOrders, useInfiniteTrades, useInfiniteTradesMulti, useMarket, useMarketHistory, useMarketTrades, useMatch, useOrder, useOrderbook, useOrderbookSubscription, useOrders, useOrdersMulti, usePolymarket, usePolymarketDeposit, usePolymarketDepositAddresses, usePolymarketSetup, usePolymarketSupportedAssets, usePolymarketWithdraw, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRebateConfig, useRedeemPosition, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTickSize, useTrades, useTradesSubscription, useWithdrawBuildMutation, useWithdrawStatusQuery, useWithdrawSubmitMutation, walkOrderbook, withdrawStatusQueryKey };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as Orderbook, h as ListMarketTradesParams, i as PredictTrade, j as PriceHistoryRange, k as PriceHistoryResponse, l as ListCandlesticksParams, C as Candlestick, m as ListCommentsParams, n as PredictComment, o as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, p as ListOrdersParams, q as PredictOrder, r as ListOrdersMultiParams, s as PredictOrdersResponse, t as CancelOrderResult, M as MatchesParams, u as MatchGroupPage, v as MatchGroup, w as MatchMarketParams, x as MatchMarketPage, y as ListTradesParams, z as ListTradesMultiParams, D as DFlowQuoteRequest, F as DFlowQuoteResponse, G as DFlowSubmitResponse, H as DFlowSubmitRequest, I as DFlowKYCStatus, J as PolymarketSetupStatus, W as WithdrawBuildResponse,
|
|
2
|
-
export {
|
|
1
|
+
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as Orderbook, h as ListMarketTradesParams, i as PredictTrade, j as PriceHistoryRange, k as PriceHistoryResponse, l as ListCandlesticksParams, C as Candlestick, m as ListCommentsParams, n as PredictComment, o as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, p as ListOrdersParams, q as PredictOrder, r as ListOrdersMultiParams, s as PredictOrdersResponse, t as CancelOrderResult, M as MatchesParams, u as MatchGroupPage, v as MatchGroup, w as MatchMarketParams, x as MatchMarketPage, y as ListTradesParams, z as ListTradesMultiParams, D as DFlowQuoteRequest, F as DFlowQuoteResponse, G as DFlowSubmitResponse, H as DFlowSubmitRequest, I as DFlowKYCStatus, J as PolymarketSetupStatus, K as PolymarketDepositWalletDeployResponse, W as WithdrawBuildResponse, N as WithdrawBuildRequest, Q as WithdrawSubmitResponse, R as WithdrawSubmitRequest, T as WithdrawStatusResponse, U as PolymarketDepositAddresses, V as PolymarketSupportedAsset, X as PolymarketWithdrawResponse, Y as PolymarketWithdrawRequest, Z as PolymarketRedeemResponse, _ as TickSizeResponse, $ as FeeRateResponse, a0 as RebateConfig, a1 as WsConnectionStatus, a2 as WsDataMessage, a3 as WsPriceEvent, a4 as WsOrderbookEvent, a5 as WsTradeEvent, a6 as CreateOrderInput } from './server-DfzGla54.js';
|
|
2
|
+
export { bl as BuildClobAuthMessageInput, bz as BuildOrderMessageInput, bc as CLOB_AUTH_DOMAIN, bd as CLOB_AUTH_TYPES, bm as CTF_EXCHANGE_ADDRESS, br as CTF_ORDER_TYPES, by as ClobOrderPayload, ap as DFlowOrderContext, at as DepositBuildRequest, au as DepositBuildResponse, ax as DepositStatusResponse, av as DepositSubmitRequest, aw as DepositSubmitResponse, ai as EventSummary, bi as HttpMethod, af as MarketOutcome, ae as MarketResult, ad as MarketStatus, aj as MarketSummary, aI as MatchConfidenceTier, aE as MatchGroupEntry, aF as MatchGroupMarket, aK as MatchLeg, aL as MatchMarketFlat, aG as MatchSortField, aD as MatchStatus, aH as MatchesStats, bn as NEG_RISK_CTF_EXCHANGE_ADDRESS, bs as ORDER_TYPE, bA as OrderMessage, ao as OrderSide, an as OrderStatus, ag as OrderbookLevel, bp as POLYGON_CHAIN_ID, az as PolymarketBridgeToken, as as PolymarketDepositWalletDeployRequest, bk as PolymarketL2Headers, bj as PolymarketL2HeadersInput, aq as PolymarketOrderType, aY as PolymarketRedeemInput, aW as PolymarketRedeemPrepareInput, aX as PolymarketRedeemPrepareResponse, aA as PolymarketSupportedAssetsResponse, ar as PolymarketWalletKind, aB as PolymarketWithdrawPrepareRequest, aC as PolymarketWithdrawPrepareResponse, ak as PredictCommentProfile, am as PredictPosition, ab as PredictTag, a9 as PredictWsClientConfig, al as PricePoint, aa as ProviderMeta, b3 as ResolveEventsParamsInput, bt as SIDE, ac as SettlementSource, aJ as SignalTag, bB as SignedOrder, b4 as TagSlugSelection, ah as TradeType, bo as USDC_ADDRESS, ay as UnsignedTx, aM as WsChannel, aN as WsChannelEvent, aO as WsClientMessage, aU as WsErrorCode, aV as WsErrorMessage, aQ as WsPingMessage, aS as WsPongMessage, aR as WsServerMessage, aP as WsSubscribeMessage, aT as WsSubscribedMessage, be as buildClobAuthMessage, bw as buildClobPayload, bq as buildCtfExchangeDomain, bu as buildOrderMessage, bg as buildPolymarketL2Headers, bv as buildSignedOrder, a7 as createPredictClient, a8 as createPredictWsClient, bh as derivePolymarketApiKey, aZ as eventQueryKey, a_ as fetchEvent, b2 as fetchEventsPage, b6 as fetchMarket, bb as fetchMatchMarketsPage, b9 as fetchMatchesPage, bx as getPolymarketSharesPrecision, bf as hmacSha256Base64, b1 as infiniteEventsQueryKey, b5 as marketQueryKey, ba as matchMarketsQueryKey, b8 as matchQueryKey, b7 as matchesQueryKey, b0 as resolveEventsParams, a$ as resolveTagSlug } from './server-DfzGla54.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { PropsWithChildren } from 'react';
|
|
6
6
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
7
|
import { UseQueryOptions, UseInfiniteQueryOptions, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
|
|
8
|
+
import { orderToJsonV2 } from '@polymarket/clob-client-v2';
|
|
8
9
|
|
|
9
10
|
type PredictProviderProps = PropsWithChildren<{
|
|
10
11
|
/**
|
|
@@ -132,8 +133,9 @@ interface PolymarketSigner {
|
|
|
132
133
|
* - `0` = EOA (MetaMask, Coinbase, etc.)
|
|
133
134
|
* - `1` = Magic Link
|
|
134
135
|
* - `2` = Polymarket proxy (Gnosis Safe)
|
|
136
|
+
* - `3` = POLY_1271 (CLOB V2 deposit wallet, ERC-7739-wrapped ERC-1271)
|
|
135
137
|
*/
|
|
136
|
-
signatureType: 0 | 1 | 2;
|
|
138
|
+
signatureType: 0 | 1 | 2 | 3;
|
|
137
139
|
/**
|
|
138
140
|
* Sign EIP-712 typed data and return the hex signature.
|
|
139
141
|
* The signature is used for L1 authentication with the Polymarket CLOB API.
|
|
@@ -562,6 +564,12 @@ declare function usePolymarketSetup(walletAddress?: string, queryOptions?: Omit<
|
|
|
562
564
|
* Automatically invalidates the setup status query on success.
|
|
563
565
|
*/
|
|
564
566
|
declare function useRunPolymarketSetup(walletAddress?: string): _tanstack_react_query.UseMutationResult<PolymarketSetupStatus, Error, string, unknown>;
|
|
567
|
+
/**
|
|
568
|
+
* Mutation hook to deploy a Polymarket CLOB V2 deposit wallet for new
|
|
569
|
+
* (non-Safe) users via a gasless WALLET-CREATE relayer request. No user
|
|
570
|
+
* signature is required. Invalidates the setup status query on success.
|
|
571
|
+
*/
|
|
572
|
+
declare function useDeployPolymarketDepositWallet(walletAddress?: string): _tanstack_react_query.UseMutationResult<PolymarketDepositWalletDeployResponse, Error, string, unknown>;
|
|
565
573
|
|
|
566
574
|
declare function useWithdrawBuildMutation(mutationOptions?: Omit<UseMutationOptions<WithdrawBuildResponse, Error, WithdrawBuildRequest>, "mutationFn">): _tanstack_react_query.UseMutationResult<WithdrawBuildResponse, Error, WithdrawBuildRequest, unknown>;
|
|
567
575
|
|
|
@@ -712,6 +720,16 @@ declare function feeRateQueryKey(tokenId: string): unknown[];
|
|
|
712
720
|
*/
|
|
713
721
|
declare function useFeeRate(tokenId?: string, queryOptions?: Omit<UseQueryOptions<FeeRateResponse, Error, FeeRateResponse, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<FeeRateResponse, Error>;
|
|
714
722
|
|
|
723
|
+
declare function rebateConfigQueryKey(): unknown[];
|
|
724
|
+
/**
|
|
725
|
+
* Query hook for the builder-attribution / rebate config
|
|
726
|
+
* (`GET /api/v1/referral/config`). Consumers read `builder_enabled` +
|
|
727
|
+
* `builder_code` to attach our builder code to CLOB V2 orders for rebates.
|
|
728
|
+
*
|
|
729
|
+
* The config is process-global and rarely changes, so it is cached aggressively.
|
|
730
|
+
*/
|
|
731
|
+
declare function useRebateConfig(queryOptions?: Omit<UseQueryOptions<RebateConfig, Error, RebateConfig, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<RebateConfig, Error>;
|
|
732
|
+
|
|
715
733
|
interface UsePredictWsClientResult {
|
|
716
734
|
/** The WebSocket client instance, or `null` if not provided via `PredictProvider`. */
|
|
717
735
|
wsClient: PredictWsClient | null;
|
|
@@ -945,6 +963,63 @@ interface CreatePolymarketOrderVariables {
|
|
|
945
963
|
*/
|
|
946
964
|
declare function useCreatePolymarketOrder(mutationOptions?: Omit<UseMutationOptions<PredictOrder, Error, CreatePolymarketOrderVariables>, "mutationFn">): _tanstack_react_query.UseMutationResult<PredictOrder, Error, CreatePolymarketOrderVariables, unknown>;
|
|
947
965
|
|
|
966
|
+
/**
|
|
967
|
+
* Polymarket CLOB V2 (POLY_1271 / signatureType=3) order construction.
|
|
968
|
+
*
|
|
969
|
+
* Deposit-wallet orders use an ERC-7739-wrapped ERC-1271 signature over the V2
|
|
970
|
+
* `Order` struct on the CTF Exchange V2 contracts. Reproducing that wrapper by
|
|
971
|
+
* hand is error-prone, so we delegate signing to the official
|
|
972
|
+
* `@polymarket/clob-client-v2` `OrderBuilder`, then submit the resulting payload
|
|
973
|
+
* through the existing prediction-server CLOB proxy (with our own L2 HMAC).
|
|
974
|
+
*
|
|
975
|
+
* The legacy Safe path (signatureType=2, V1 exchange) stays in
|
|
976
|
+
* `polymarket-order.ts`.
|
|
977
|
+
*
|
|
978
|
+
* @see https://docs.polymarket.com/trading/deposit-wallets
|
|
979
|
+
*/
|
|
980
|
+
|
|
981
|
+
/** V2 CLOB order payload (mirrors `orderToJsonV2` output). */
|
|
982
|
+
type ClobOrderV2Payload = ReturnType<typeof orderToJsonV2>;
|
|
983
|
+
interface BuildV2OrderParams {
|
|
984
|
+
/** App-provided signer (the deposit wallet owner EOA). Must be POLY_1271. */
|
|
985
|
+
signer: PolymarketSigner;
|
|
986
|
+
/** Deposit wallet address — used as both `maker` and `signer` of the order. */
|
|
987
|
+
depositWalletAddress: string;
|
|
988
|
+
/** Order parameters (token, price, size, side, tick, etc.). */
|
|
989
|
+
input: CreateOrderInput;
|
|
990
|
+
/** CLOB owner (L2 API key) attached to the submitted payload. */
|
|
991
|
+
owner: string;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Build and sign a CLOB V2 deposit-wallet order, returning the JSON payload
|
|
995
|
+
* ready to POST to Polymarket's `/order` endpoint (via the server proxy).
|
|
996
|
+
*
|
|
997
|
+
* `maker` and `signer` are both set to the deposit wallet address (enforced by
|
|
998
|
+
* the SDK for POLY_1271). The owner EOA signs the ERC-7739 wrapper.
|
|
999
|
+
*/
|
|
1000
|
+
declare function buildSignedV2OrderPayload(params: BuildV2OrderParams): Promise<ClobOrderV2Payload>;
|
|
1001
|
+
interface SyncBalanceAllowanceParams {
|
|
1002
|
+
/** App-provided signer (the deposit wallet owner EOA). */
|
|
1003
|
+
signer: PolymarketSigner;
|
|
1004
|
+
/** In-memory L2 credentials obtained from PolymarketContext. */
|
|
1005
|
+
credentials: PolymarketCredentials;
|
|
1006
|
+
/** Deposit wallet address (the order funder). */
|
|
1007
|
+
depositWalletAddress: string;
|
|
1008
|
+
/** Override the CLOB host (defaults to the public CLOB endpoint). */
|
|
1009
|
+
clobHost?: string;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Best-effort sync of the deposit wallet's CLOB collateral buying power.
|
|
1013
|
+
*
|
|
1014
|
+
* After deploy/approve/deposit, the CLOB's cached balance-allowance for the
|
|
1015
|
+
* deposit wallet can lag the on-chain state. Calling
|
|
1016
|
+
* `updateBalanceAllowance({ asset_type: COLLATERAL })` with `signature_type=3`
|
|
1017
|
+
* forces a refresh so the first order isn't rejected for insufficient
|
|
1018
|
+
* buying power. The CLOB also syncs lazily on order match, so callers should
|
|
1019
|
+
* treat failures here as non-fatal.
|
|
1020
|
+
*/
|
|
1021
|
+
declare function updatePolymarketBalanceAllowance(params: SyncBalanceAllowanceParams): Promise<void>;
|
|
1022
|
+
|
|
948
1023
|
/**
|
|
949
1024
|
* Orderbook-aware pricing utilities for prediction-market orders.
|
|
950
1025
|
*
|
|
@@ -1012,4 +1087,4 @@ interface WalkOrderbookParams {
|
|
|
1012
1087
|
*/
|
|
1013
1088
|
declare function walkOrderbook({ orderbook, outcome, side, sharesNeeded, slippageBps, }: WalkOrderbookParams): WalkResult;
|
|
1014
1089
|
|
|
1015
|
-
export { AvailableSharesResponse, BalanceResponse, CancelOrderResult, type CancelOrderVariables, Candlestick, ChartRange, type ChartRangeType, CreateOrderInput, type CreatePolymarketOrderVariables, DFlowKYCStatus, DFlowQuoteRequest, DFlowQuoteResponse, DFlowSubmitRequest, DFlowSubmitResponse, EventSortField, EventStats, EventStatus, FeeRateResponse, ListCandlesticksParams, ListCommentsParams, ListEventsParams, ListMarketTradesParams, ListOrdersMultiParams, ListOrdersParams, ListTradesMultiParams, ListTradesParams, type MarketHistoryPoint, type MarketHistorySeries, MatchGroup, MatchGroupPage, MatchMarketPage, MatchMarketParams, MatchesParams, Orderbook, PolymarketContext, type PolymarketContextValue, type PolymarketCredentials, PolymarketDepositAddresses, type PolymarketDepositResult, type PolymarketDepositVariables, PolymarketProvider, type PolymarketProviderProps, PolymarketRedeemResponse, type PolymarketSigner, PolymarketSupportedAsset, PolymarketWithdrawRequest, PolymarketWithdrawResponse, PositionsResponse, PredictClient, PredictComment, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictOrdersResponse, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryRange, PriceHistoryResponse, ProviderSource, type RedeemPositionVariables, SimilarEventsParams, TickSizeResponse, type UseAvailableSharesOptions, type UseAvailableSharesParams, type UseBalanceParams, type UseCancelOrderOptions, type UseCandlesticksParams, type UseEventParams, type UseInfiniteCommentsParams, type UseInfiniteMatchMarketsParams, type UseInfiniteMatchesParams, type UseInfiniteOrdersOptions, type UseInfiniteOrdersParams, type UseInfiniteTradesMultiParams, type UseInfiniteTradesParams, type UseMarketHistoryResult, type UseMarketParams, type UseMarketTradesParams, type UseOrderParams, type UseOrderbookParams, type UseOrderbookSubscriptionParams, type UseOrderbookSubscriptionResult, type UseOrdersMultiOptions, type UseOrdersOptions, type UsePositionsMultiParams, type UsePositionsParams, type UsePredictWsClientResult, type UsePriceHistoryParams, type UsePricesSubscriptionParams, type UsePricesSubscriptionResult, type UseRealtimeOrderbookParams, type UseRealtimePricesParams, type UseRealtimeTradesParams, type UseRealtimeTradesResult, type UseSearchEventsParams, type UseSimilarEventsParams, type UseTradesSubscriptionParams, type UseTradesSubscriptionResult, type UseWithdrawStatusQueryParams, type WalkOrderbookParams, type WalkOutcome, type WalkResult, type WalkSide, type WalkStatus, WithdrawBuildRequest, WithdrawBuildResponse, WithdrawStatusResponse, WithdrawSubmitRequest, WithdrawSubmitResponse, WsConnectionStatus, WsDataMessage, WsOrderbookEvent, WsPriceEvent, WsTradeEvent, availableSharesQueryKey, balanceQueryKey, candlesticksQueryKey, dflowKYCQueryKey, dflowQuoteQueryKey, eventStatsQueryKey, eventsQueryKey, feeRateQueryKey, fetchEvents, infiniteCommentsQueryKey, infiniteOrdersQueryKey, infiniteTradesMultiQueryKey, infiniteTradesQueryKey, marketTradesQueryKey, orderQueryKey, orderbookQueryKey, ordersMultiQueryKey, ordersQueryKey, pickBestAsk, pickBestBid, polymarketDepositAddressesQueryKey, polymarketSetupQueryKey, polymarketSupportedAssetsQueryKey, positionsMultiQueryKey, positionsQueryKey, priceHistoryQueryKey, similarEventsQueryKey, tickSizeQueryKey, tradesQueryKey, useAvailableShares, useBalance, useCancelOrder, useCandlesticks, useCreatePolymarketOrder, useDFlowKYC, useDFlowQuote, useDFlowSubmit, useEvent, useEventStats, useEvents, useFeeRate, useInfiniteComments, useInfiniteEvents, useInfiniteMatchMarkets, useInfiniteMatches, useInfiniteOrders, useInfiniteTrades, useInfiniteTradesMulti, useMarket, useMarketHistory, useMarketTrades, useMatch, useOrder, useOrderbook, useOrderbookSubscription, useOrders, useOrdersMulti, usePolymarket, usePolymarketDeposit, usePolymarketDepositAddresses, usePolymarketSetup, usePolymarketSupportedAssets, usePolymarketWithdraw, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRedeemPosition, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTickSize, useTrades, useTradesSubscription, useWithdrawBuildMutation, useWithdrawStatusQuery, useWithdrawSubmitMutation, walkOrderbook, withdrawStatusQueryKey };
|
|
1090
|
+
export { AvailableSharesResponse, BalanceResponse, type BuildV2OrderParams, CancelOrderResult, type CancelOrderVariables, Candlestick, ChartRange, type ChartRangeType, type ClobOrderV2Payload, CreateOrderInput, type CreatePolymarketOrderVariables, DFlowKYCStatus, DFlowQuoteRequest, DFlowQuoteResponse, DFlowSubmitRequest, DFlowSubmitResponse, EventSortField, EventStats, EventStatus, FeeRateResponse, ListCandlesticksParams, ListCommentsParams, ListEventsParams, ListMarketTradesParams, ListOrdersMultiParams, ListOrdersParams, ListTradesMultiParams, ListTradesParams, type MarketHistoryPoint, type MarketHistorySeries, MatchGroup, MatchGroupPage, MatchMarketPage, MatchMarketParams, MatchesParams, Orderbook, PolymarketContext, type PolymarketContextValue, type PolymarketCredentials, PolymarketDepositAddresses, type PolymarketDepositResult, type PolymarketDepositVariables, PolymarketDepositWalletDeployResponse, PolymarketProvider, type PolymarketProviderProps, PolymarketRedeemResponse, PolymarketSetupStatus, type PolymarketSigner, PolymarketSupportedAsset, PolymarketWithdrawRequest, PolymarketWithdrawResponse, PositionsResponse, PredictClient, PredictComment, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictOrdersResponse, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryRange, PriceHistoryResponse, ProviderSource, RebateConfig, type RedeemPositionVariables, SimilarEventsParams, type SyncBalanceAllowanceParams, TickSizeResponse, type UseAvailableSharesOptions, type UseAvailableSharesParams, type UseBalanceParams, type UseCancelOrderOptions, type UseCandlesticksParams, type UseEventParams, type UseInfiniteCommentsParams, type UseInfiniteMatchMarketsParams, type UseInfiniteMatchesParams, type UseInfiniteOrdersOptions, type UseInfiniteOrdersParams, type UseInfiniteTradesMultiParams, type UseInfiniteTradesParams, type UseMarketHistoryResult, type UseMarketParams, type UseMarketTradesParams, type UseOrderParams, type UseOrderbookParams, type UseOrderbookSubscriptionParams, type UseOrderbookSubscriptionResult, type UseOrdersMultiOptions, type UseOrdersOptions, type UsePositionsMultiParams, type UsePositionsParams, type UsePredictWsClientResult, type UsePriceHistoryParams, type UsePricesSubscriptionParams, type UsePricesSubscriptionResult, type UseRealtimeOrderbookParams, type UseRealtimePricesParams, type UseRealtimeTradesParams, type UseRealtimeTradesResult, type UseSearchEventsParams, type UseSimilarEventsParams, type UseTradesSubscriptionParams, type UseTradesSubscriptionResult, type UseWithdrawStatusQueryParams, type WalkOrderbookParams, type WalkOutcome, type WalkResult, type WalkSide, type WalkStatus, WithdrawBuildRequest, WithdrawBuildResponse, WithdrawStatusResponse, WithdrawSubmitRequest, WithdrawSubmitResponse, WsConnectionStatus, WsDataMessage, WsOrderbookEvent, WsPriceEvent, WsTradeEvent, availableSharesQueryKey, balanceQueryKey, buildSignedV2OrderPayload, candlesticksQueryKey, dflowKYCQueryKey, dflowQuoteQueryKey, eventStatsQueryKey, eventsQueryKey, feeRateQueryKey, fetchEvents, infiniteCommentsQueryKey, infiniteOrdersQueryKey, infiniteTradesMultiQueryKey, infiniteTradesQueryKey, marketTradesQueryKey, orderQueryKey, orderbookQueryKey, ordersMultiQueryKey, ordersQueryKey, pickBestAsk, pickBestBid, polymarketDepositAddressesQueryKey, polymarketSetupQueryKey, polymarketSupportedAssetsQueryKey, positionsMultiQueryKey, positionsQueryKey, priceHistoryQueryKey, rebateConfigQueryKey, similarEventsQueryKey, tickSizeQueryKey, tradesQueryKey, updatePolymarketBalanceAllowance, useAvailableShares, useBalance, useCancelOrder, useCandlesticks, useCreatePolymarketOrder, useDFlowKYC, useDFlowQuote, useDFlowSubmit, useDeployPolymarketDepositWallet, useEvent, useEventStats, useEvents, useFeeRate, useInfiniteComments, useInfiniteEvents, useInfiniteMatchMarkets, useInfiniteMatches, useInfiniteOrders, useInfiniteTrades, useInfiniteTradesMulti, useMarket, useMarketHistory, useMarketTrades, useMatch, useOrder, useOrderbook, useOrderbookSubscription, useOrders, useOrdersMulti, usePolymarket, usePolymarketDeposit, usePolymarketDepositAddresses, usePolymarketSetup, usePolymarketSupportedAssets, usePolymarketWithdraw, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRebateConfig, useRedeemPosition, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTickSize, useTrades, useTradesSubscription, useWithdrawBuildMutation, useWithdrawStatusQuery, useWithdrawSubmitMutation, walkOrderbook, withdrawStatusQueryKey };
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var utils = require('@liberfi.io/utils');
|
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var reactQuery = require('@tanstack/react-query');
|
|
7
|
+
var clobClientV2 = require('@polymarket/clob-client-v2');
|
|
7
8
|
|
|
8
9
|
// src/client/client.ts
|
|
9
10
|
function buildQuery(params) {
|
|
@@ -281,6 +282,15 @@ var PredictClient = class {
|
|
|
281
282
|
const url = `${this.endpoint}/api/v1/polymarket/fee-rate?token_id=${encodeURIComponent(tokenId)}`;
|
|
282
283
|
return await utils.httpGet(url);
|
|
283
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Builder-attribution / rebate config. Maps to `GET /api/v1/referral/config`.
|
|
287
|
+
* The front-end uses `builder_code` (when `builder_enabled`) to attribute
|
|
288
|
+
* CLOB V2 orders to our builder program.
|
|
289
|
+
*/
|
|
290
|
+
async getRebateConfig() {
|
|
291
|
+
const url = `${this.endpoint}/api/v1/referral/config`;
|
|
292
|
+
return await utils.httpGet(url);
|
|
293
|
+
}
|
|
284
294
|
// -------------------------------------------------------------------------
|
|
285
295
|
// DFlow trading
|
|
286
296
|
// -------------------------------------------------------------------------
|
|
@@ -331,6 +341,21 @@ var PredictClient = class {
|
|
|
331
341
|
wallet_address: walletAddress
|
|
332
342
|
});
|
|
333
343
|
}
|
|
344
|
+
/**
|
|
345
|
+
* Deploy a Polymarket CLOB V2 deposit wallet (gasless WALLET-CREATE).
|
|
346
|
+
*
|
|
347
|
+
* No user signature is required — the relayer deploys the per-user
|
|
348
|
+
* ERC-1967 proxy and the server waits until it is confirmed on-chain.
|
|
349
|
+
* Used for new (non-Safe) users on the POLY_1271 path.
|
|
350
|
+
*
|
|
351
|
+
* Maps to `POST /api/v1/setup/polymarket/deposit/deploy`.
|
|
352
|
+
*/
|
|
353
|
+
async deployPolymarketDepositWallet(walletAddress) {
|
|
354
|
+
const url = `${this.endpoint}/api/v1/setup/polymarket/deposit/deploy`;
|
|
355
|
+
return await utils.httpPost(url, {
|
|
356
|
+
wallet_address: walletAddress
|
|
357
|
+
});
|
|
358
|
+
}
|
|
334
359
|
// -------------------------------------------------------------------------
|
|
335
360
|
// Cross-platform matches
|
|
336
361
|
// -------------------------------------------------------------------------
|
|
@@ -1668,6 +1693,20 @@ function useRunPolymarketSetup(walletAddress) {
|
|
|
1668
1693
|
}
|
|
1669
1694
|
});
|
|
1670
1695
|
}
|
|
1696
|
+
function useDeployPolymarketDepositWallet(walletAddress) {
|
|
1697
|
+
const client = usePredictClient();
|
|
1698
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1699
|
+
return reactQuery.useMutation({
|
|
1700
|
+
mutationFn: (address) => client.deployPolymarketDepositWallet(address),
|
|
1701
|
+
onSuccess: () => {
|
|
1702
|
+
if (walletAddress) {
|
|
1703
|
+
queryClient.invalidateQueries({
|
|
1704
|
+
queryKey: polymarketSetupQueryKey(walletAddress)
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1671
1710
|
function useWithdrawBuildMutation(mutationOptions = {}) {
|
|
1672
1711
|
const client = usePredictClient();
|
|
1673
1712
|
return reactQuery.useMutation({
|
|
@@ -1850,6 +1889,18 @@ function useFeeRate(tokenId, queryOptions = {}) {
|
|
|
1850
1889
|
...queryOptions
|
|
1851
1890
|
});
|
|
1852
1891
|
}
|
|
1892
|
+
function rebateConfigQueryKey() {
|
|
1893
|
+
return ["predict", "referral", "config"];
|
|
1894
|
+
}
|
|
1895
|
+
function useRebateConfig(queryOptions = {}) {
|
|
1896
|
+
const client = usePredictClient();
|
|
1897
|
+
return reactQuery.useQuery({
|
|
1898
|
+
queryKey: rebateConfigQueryKey(),
|
|
1899
|
+
queryFn: () => client.getRebateConfig(),
|
|
1900
|
+
staleTime: 10 * 6e4,
|
|
1901
|
+
...queryOptions
|
|
1902
|
+
});
|
|
1903
|
+
}
|
|
1853
1904
|
function usePredictWsClient() {
|
|
1854
1905
|
const context = react.useContext(PredictContext);
|
|
1855
1906
|
if (!context) {
|
|
@@ -2246,6 +2297,82 @@ function getPolymarketSharesPrecision(tickSize) {
|
|
|
2246
2297
|
const rc = ROUNDING_CONFIG[tickSize] ?? DEFAULT_ROUNDING;
|
|
2247
2298
|
return rc.size;
|
|
2248
2299
|
}
|
|
2300
|
+
var POLYGON_CHAIN_ID2 = 137;
|
|
2301
|
+
var ORDER_VERSION = 2;
|
|
2302
|
+
function toWalletClientLike(signer) {
|
|
2303
|
+
return {
|
|
2304
|
+
account: { address: signer.address },
|
|
2305
|
+
getAddresses: async () => [signer.address],
|
|
2306
|
+
signTypedData: async (args) => signer.signTypedData(
|
|
2307
|
+
args.domain,
|
|
2308
|
+
args.types,
|
|
2309
|
+
args.primaryType,
|
|
2310
|
+
args.message
|
|
2311
|
+
)
|
|
2312
|
+
};
|
|
2313
|
+
}
|
|
2314
|
+
async function buildSignedV2OrderPayload(params) {
|
|
2315
|
+
const { signer, depositWalletAddress, input, owner } = params;
|
|
2316
|
+
const builder = new clobClientV2.OrderBuilder(
|
|
2317
|
+
toWalletClientLike(signer),
|
|
2318
|
+
POLYGON_CHAIN_ID2,
|
|
2319
|
+
clobClientV2.SignatureTypeV2.POLY_1271,
|
|
2320
|
+
depositWalletAddress
|
|
2321
|
+
);
|
|
2322
|
+
const side = input.side === "BUY" ? clobClientV2.Side.BUY : clobClientV2.Side.SELL;
|
|
2323
|
+
const options = { tickSize: input.tickSize, negRisk: input.negRisk ?? false };
|
|
2324
|
+
const isMarketOrder = input.orderType === "FOK" || input.orderType === "FAK";
|
|
2325
|
+
const builderCode = input.builderCode;
|
|
2326
|
+
const signedOrder = isMarketOrder ? await builder.buildMarketOrder(
|
|
2327
|
+
{
|
|
2328
|
+
tokenID: input.tokenId,
|
|
2329
|
+
price: input.price,
|
|
2330
|
+
// Market order: BUY = collateral to spend, SELL = shares to sell.
|
|
2331
|
+
amount: input.size,
|
|
2332
|
+
side,
|
|
2333
|
+
...builderCode && { builderCode }
|
|
2334
|
+
},
|
|
2335
|
+
options,
|
|
2336
|
+
ORDER_VERSION
|
|
2337
|
+
) : await builder.buildOrder(
|
|
2338
|
+
{
|
|
2339
|
+
tokenID: input.tokenId,
|
|
2340
|
+
price: input.price,
|
|
2341
|
+
// Limit order: size is always shares.
|
|
2342
|
+
size: input.size,
|
|
2343
|
+
side,
|
|
2344
|
+
expiration: input.expiration,
|
|
2345
|
+
...builderCode && { builderCode }
|
|
2346
|
+
},
|
|
2347
|
+
options,
|
|
2348
|
+
ORDER_VERSION
|
|
2349
|
+
);
|
|
2350
|
+
const orderType = clobClientV2.OrderType[input.orderType ?? "GTC"];
|
|
2351
|
+
return clobClientV2.orderToJsonV2(
|
|
2352
|
+
signedOrder,
|
|
2353
|
+
owner,
|
|
2354
|
+
orderType
|
|
2355
|
+
);
|
|
2356
|
+
}
|
|
2357
|
+
var DEFAULT_CLOB_HOST = "https://clob.polymarket.com";
|
|
2358
|
+
async function updatePolymarketBalanceAllowance(params) {
|
|
2359
|
+
const { signer, credentials, depositWalletAddress, clobHost } = params;
|
|
2360
|
+
const client = new clobClientV2.ClobClient({
|
|
2361
|
+
host: clobHost ?? DEFAULT_CLOB_HOST,
|
|
2362
|
+
chain: POLYGON_CHAIN_ID2,
|
|
2363
|
+
signer: toWalletClientLike(signer),
|
|
2364
|
+
creds: {
|
|
2365
|
+
key: credentials.apiKey,
|
|
2366
|
+
secret: credentials.secret,
|
|
2367
|
+
passphrase: credentials.passphrase
|
|
2368
|
+
},
|
|
2369
|
+
signatureType: clobClientV2.SignatureTypeV2.POLY_1271,
|
|
2370
|
+
funderAddress: depositWalletAddress
|
|
2371
|
+
});
|
|
2372
|
+
await client.updateBalanceAllowance({
|
|
2373
|
+
asset_type: "COLLATERAL"
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2249
2376
|
|
|
2250
2377
|
// src/hooks/polymarket/useCreatePolymarketOrder.ts
|
|
2251
2378
|
var TX_POLL_INTERVAL2 = 3e3;
|
|
@@ -2260,6 +2387,28 @@ function useCreatePolymarketOrder(mutationOptions = {}) {
|
|
|
2260
2387
|
signer
|
|
2261
2388
|
}) => {
|
|
2262
2389
|
const creds = credentials ?? await authenticate(signer);
|
|
2390
|
+
if (signer.signatureType === 3) {
|
|
2391
|
+
const depositWalletAddress = input.funderAddress ?? signer.address;
|
|
2392
|
+
const v2Payload = await buildSignedV2OrderPayload({
|
|
2393
|
+
signer,
|
|
2394
|
+
depositWalletAddress,
|
|
2395
|
+
input,
|
|
2396
|
+
owner: creds.apiKey
|
|
2397
|
+
});
|
|
2398
|
+
const body2 = JSON.stringify(v2Payload);
|
|
2399
|
+
const headers2 = await buildPolymarketL2Headers(creds.address, {
|
|
2400
|
+
apiKey: creds.apiKey,
|
|
2401
|
+
secret: creds.secret,
|
|
2402
|
+
passphrase: creds.passphrase,
|
|
2403
|
+
method: "POST",
|
|
2404
|
+
requestPath: "/order",
|
|
2405
|
+
body: body2
|
|
2406
|
+
});
|
|
2407
|
+
return client.createPolymarketOrder(
|
|
2408
|
+
v2Payload,
|
|
2409
|
+
headers2
|
|
2410
|
+
);
|
|
2411
|
+
}
|
|
2263
2412
|
if (signer.signTransaction && input.funderAddress) {
|
|
2264
2413
|
const orderCost = computeOrderCost(input);
|
|
2265
2414
|
const buildResult = await client.depositBuild({
|
|
@@ -2470,6 +2619,7 @@ exports.buildCtfExchangeDomain = buildCtfExchangeDomain;
|
|
|
2470
2619
|
exports.buildOrderMessage = buildOrderMessage;
|
|
2471
2620
|
exports.buildPolymarketL2Headers = buildPolymarketL2Headers;
|
|
2472
2621
|
exports.buildSignedOrder = buildSignedOrder;
|
|
2622
|
+
exports.buildSignedV2OrderPayload = buildSignedV2OrderPayload;
|
|
2473
2623
|
exports.candlesticksQueryKey = candlesticksQueryKey;
|
|
2474
2624
|
exports.createPredictClient = createPredictClient;
|
|
2475
2625
|
exports.createPredictWsClient = createPredictWsClient;
|
|
@@ -2510,11 +2660,13 @@ exports.polymarketSupportedAssetsQueryKey = polymarketSupportedAssetsQueryKey;
|
|
|
2510
2660
|
exports.positionsMultiQueryKey = positionsMultiQueryKey;
|
|
2511
2661
|
exports.positionsQueryKey = positionsQueryKey;
|
|
2512
2662
|
exports.priceHistoryQueryKey = priceHistoryQueryKey;
|
|
2663
|
+
exports.rebateConfigQueryKey = rebateConfigQueryKey;
|
|
2513
2664
|
exports.resolveEventsParams = resolveEventsParams;
|
|
2514
2665
|
exports.resolveTagSlug = resolveTagSlug;
|
|
2515
2666
|
exports.similarEventsQueryKey = similarEventsQueryKey;
|
|
2516
2667
|
exports.tickSizeQueryKey = tickSizeQueryKey;
|
|
2517
2668
|
exports.tradesQueryKey = tradesQueryKey;
|
|
2669
|
+
exports.updatePolymarketBalanceAllowance = updatePolymarketBalanceAllowance;
|
|
2518
2670
|
exports.useAvailableShares = useAvailableShares;
|
|
2519
2671
|
exports.useBalance = useBalance;
|
|
2520
2672
|
exports.useCancelOrder = useCancelOrder;
|
|
@@ -2523,6 +2675,7 @@ exports.useCreatePolymarketOrder = useCreatePolymarketOrder;
|
|
|
2523
2675
|
exports.useDFlowKYC = useDFlowKYC;
|
|
2524
2676
|
exports.useDFlowQuote = useDFlowQuote;
|
|
2525
2677
|
exports.useDFlowSubmit = useDFlowSubmit;
|
|
2678
|
+
exports.useDeployPolymarketDepositWallet = useDeployPolymarketDepositWallet;
|
|
2526
2679
|
exports.useEvent = useEvent;
|
|
2527
2680
|
exports.useEventStats = useEventStats;
|
|
2528
2681
|
exports.useEvents = useEvents;
|
|
@@ -2558,6 +2711,7 @@ exports.usePricesSubscription = usePricesSubscription;
|
|
|
2558
2711
|
exports.useRealtimeOrderbook = useRealtimeOrderbook;
|
|
2559
2712
|
exports.useRealtimePrices = useRealtimePrices;
|
|
2560
2713
|
exports.useRealtimeTrades = useRealtimeTrades;
|
|
2714
|
+
exports.useRebateConfig = useRebateConfig;
|
|
2561
2715
|
exports.useRedeemPosition = useRedeemPosition;
|
|
2562
2716
|
exports.useRunPolymarketSetup = useRunPolymarketSetup;
|
|
2563
2717
|
exports.useSearchEvents = useSearchEvents;
|