@liberfi.io/react-predict 0.1.20 → 0.1.22
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 +170 -21
- package/dist/index.d.ts +170 -21
- package/dist/index.js +478 -62
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +462 -63
- package/dist/index.mjs.map +1 -1
- package/dist/{server-CiGfmztS.d.mts → server-lP60FIU5.d.mts} +295 -27
- package/dist/{server-CiGfmztS.d.ts → server-lP60FIU5.d.ts} +295 -27
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +209 -40
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +208 -42
- package/dist/server.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStatus, S as SimilarEventsParams, e as PredictMarket, O as Orderbook, f as ListMarketTradesParams, g as PredictTrade, h as PriceHistoryRange, i as PriceHistoryResponse, j as ListCandlesticksParams, C as Candlestick, k as PositionsResponse, B as BalanceResponse, l as ListOrdersParams, m as PredictOrder, n as CancelOrderResult, M as MatchesParams, o as MatchGroupPage, p as MatchGroup, q as ListTradesParams, D as DFlowQuoteRequest,
|
|
2
|
-
export {
|
|
1
|
+
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStatus, S as SimilarEventsParams, e as PredictMarket, O as Orderbook, f as ListMarketTradesParams, g as PredictTrade, h as PriceHistoryRange, i as PriceHistoryResponse, j as ListCandlesticksParams, C as Candlestick, k as PositionsResponse, B as BalanceResponse, l as ListOrdersParams, m as PredictOrder, n as CancelOrderResult, M as MatchesParams, o as MatchGroupPage, p as MatchGroup, q as MatchMarketParams, r as MatchMarketPage, s as ListTradesParams, D as DFlowQuoteRequest, t as DFlowQuoteResponse, u as DFlowSubmitResponse, v as DFlowSubmitRequest, w as DFlowKYCStatus, x as PolymarketSetupStatus, W as WithdrawBuildResponse, y as WithdrawBuildRequest, z as WithdrawSubmitResponse, A as WithdrawSubmitRequest, F as WithdrawStatusResponse, G as PolymarketDepositAddresses, H as PolymarketWithdrawResponse, I as PolymarketWithdrawRequest, J as WsConnectionStatus, K as WsDataMessage, N as WsPriceEvent, Q as WsOrderbookEvent, R as WsTradeEvent, T as CreateOrderInput } from './server-lP60FIU5.js';
|
|
2
|
+
export { aY as BuildClobAuthMessageInput, b9 as BuildOrderMessageInput, aP as CLOB_AUTH_DOMAIN, aQ as CLOB_AUTH_TYPES, aZ as CTF_EXCHANGE_ADDRESS, b2 as CTF_ORDER_TYPES, b8 as ClobOrderPayload, ab as DFlowOrderContext, ad as DepositBuildRequest, ae as DepositBuildResponse, ah as DepositStatusResponse, af as DepositSubmitRequest, ag as DepositSubmitResponse, a2 as EventSortField, a5 as EventSummary, aV as HttpMethod, a1 as MarketOutcome, a0 as MarketResult, $ as MarketStatus, a6 as MarketSummary, ao as MatchConfidenceTier, ak as MatchGroupEntry, al as MatchGroupMarket, ap as MatchMarketFlat, am as MatchSortField, aj as MatchStatus, an as MatchesStats, a_ as NEG_RISK_CTF_EXCHANGE_ADDRESS, b3 as ORDER_TYPE, ba as OrderMessage, aa as OrderSide, a9 as OrderStatus, a3 as OrderbookLevel, b0 as POLYGON_CHAIN_ID, aX as PolymarketL2Headers, aW as PolymarketL2HeadersInput, ac as PolymarketOrderType, a8 as PredictPosition, Z as PredictTag, X as PredictWsClientConfig, a7 as PricePoint, Y as ProviderMeta, aG as ResolveEventsParamsInput, b4 as SIDE, _ as SettlementSource, bb as SignedOrder, aH as TagSlugSelection, a4 as TradeType, a$ as USDC_ADDRESS, ai as UnsignedTx, aq as WsChannel, ar as WsChannelEvent, as as WsClientMessage, ay as WsErrorCode, az as WsErrorMessage, au as WsPingMessage, aw as WsPongMessage, av as WsServerMessage, at as WsSubscribeMessage, ax as WsSubscribedMessage, aR as buildClobAuthMessage, b7 as buildClobPayload, b1 as buildCtfExchangeDomain, b5 as buildOrderMessage, aT as buildPolymarketL2Headers, b6 as buildSignedOrder, U as createPredictClient, V as createPredictWsClient, aU as derivePolymarketApiKey, aA as eventQueryKey, aB as fetchEvent, aF as fetchEventsPage, aJ as fetchMarket, aO as fetchMatchMarketsPage, aM as fetchMatchesPage, aS as hmacSha256Base64, aE as infiniteEventsQueryKey, aI as marketQueryKey, aN as matchMarketsQueryKey, aL as matchQueryKey, aK as matchesQueryKey, aD as resolveEventsParams, aC as resolveTagSlug } from './server-lP60FIU5.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';
|
|
@@ -114,11 +114,11 @@ interface PolymarketCredentials {
|
|
|
114
114
|
* const signer: PolymarketSigner = {
|
|
115
115
|
* address: walletAddress,
|
|
116
116
|
* signatureType: 2, // EOA = 0, MAGIC_LINK = 1, POLY_PROXY = 2
|
|
117
|
-
* signTypedData: async (domain, types, value) => {
|
|
117
|
+
* signTypedData: async (domain, types, primaryType, value) => {
|
|
118
118
|
* const provider = await evmWalletAdapter.getEip1193Provider();
|
|
119
119
|
* return provider.request({
|
|
120
120
|
* method: "eth_signTypedData_v4",
|
|
121
|
-
* params: [walletAddress, JSON.stringify({ domain, types, message: value })],
|
|
121
|
+
* params: [walletAddress, JSON.stringify({ domain, types, primaryType, message: value })],
|
|
122
122
|
* });
|
|
123
123
|
* },
|
|
124
124
|
* };
|
|
@@ -137,8 +137,22 @@ interface PolymarketSigner {
|
|
|
137
137
|
/**
|
|
138
138
|
* Sign EIP-712 typed data and return the hex signature.
|
|
139
139
|
* The signature is used for L1 authentication with the Polymarket CLOB API.
|
|
140
|
+
*
|
|
141
|
+
* @param domain - EIP-712 domain separator.
|
|
142
|
+
* @param types - Type definitions (without EIP712Domain).
|
|
143
|
+
* @param primaryType - The primary type name (e.g. "ClobAuth", "Order").
|
|
144
|
+
* @param value - The message/struct values to sign.
|
|
145
|
+
*/
|
|
146
|
+
signTypedData: (domain: Record<string, unknown>, types: Record<string, unknown[]>, primaryType: string, value: Record<string, unknown>) => Promise<string>;
|
|
147
|
+
/**
|
|
148
|
+
* Sign a raw EVM transaction and return the signed transaction hex.
|
|
149
|
+
* Required for auto-deposit (native USDC → USDC.e via Uniswap V3).
|
|
150
|
+
* If not provided, auto-deposit will throw when a deposit is needed.
|
|
151
|
+
*
|
|
152
|
+
* @param txParams - Transaction parameters: `{ from, to, data, value, chainId, gas }`.
|
|
153
|
+
* @returns Signed raw transaction hex (0x-prefixed).
|
|
140
154
|
*/
|
|
141
|
-
|
|
155
|
+
signTransaction?: (txParams: Record<string, string>) => Promise<string>;
|
|
142
156
|
}
|
|
143
157
|
interface PolymarketContextValue {
|
|
144
158
|
/** In-memory credentials; `null` before the user authenticates. */
|
|
@@ -149,9 +163,11 @@ interface PolymarketContextValue {
|
|
|
149
163
|
authError: Error | null;
|
|
150
164
|
/**
|
|
151
165
|
* Trigger L1 authentication using the provided signer.
|
|
152
|
-
* Derives L2 credentials with `nonce=0
|
|
166
|
+
* Derives L2 credentials with `nonce=0`, stores them in memory,
|
|
167
|
+
* and returns them so the caller can use them immediately
|
|
168
|
+
* (without waiting for a re-render).
|
|
153
169
|
*/
|
|
154
|
-
authenticate: (signer: PolymarketSigner) => Promise<
|
|
170
|
+
authenticate: (signer: PolymarketSigner) => Promise<PolymarketCredentials>;
|
|
155
171
|
/** Clear all in-memory credentials (e.g. on wallet disconnect). */
|
|
156
172
|
clearCredentials: () => void;
|
|
157
173
|
}
|
|
@@ -206,7 +222,7 @@ interface UseEventParams {
|
|
|
206
222
|
*/
|
|
207
223
|
declare function useEvent(params: UseEventParams, queryOptions?: Omit<UseQueryOptions<PredictEvent, Error, PredictEvent, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<PredictEvent, Error>;
|
|
208
224
|
|
|
209
|
-
type InfiniteQueryOptions$
|
|
225
|
+
type InfiniteQueryOptions$2 = Omit<UseInfiniteQueryOptions<PredictPage<PredictEvent>, Error, InfiniteData<PredictPage<PredictEvent>>, unknown[], string | undefined>, "queryKey" | "queryFn" | "initialPageParam" | "getNextPageParam">;
|
|
210
226
|
/**
|
|
211
227
|
* TanStack Query infinite-query hook for `GET /api/v1/events` with cursor-based
|
|
212
228
|
* pagination via the prediction-server client.
|
|
@@ -221,7 +237,7 @@ type InfiniteQueryOptions$1 = Omit<UseInfiniteQueryOptions<PredictPage<PredictEv
|
|
|
221
237
|
* const { data, hasNextPage, fetchNextPage } = useInfiniteEvents(params);
|
|
222
238
|
* ```
|
|
223
239
|
*/
|
|
224
|
-
declare function useInfiniteEvents(params: ListEventsParams, queryOptions?: InfiniteQueryOptions$
|
|
240
|
+
declare function useInfiniteEvents(params: ListEventsParams, queryOptions?: InfiniteQueryOptions$2): _tanstack_react_query.UseInfiniteQueryResult<InfiniteData<PredictPage<PredictEvent>, unknown>, Error>;
|
|
225
241
|
|
|
226
242
|
interface UseSearchEventsParams {
|
|
227
243
|
/** Search keyword. */
|
|
@@ -337,12 +353,27 @@ interface UseCandlesticksParams {
|
|
|
337
353
|
declare function useCandlesticks(params: UseCandlesticksParams, queryOptions?: Omit<UseQueryOptions<Candlestick[], Error, Candlestick[], unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<Candlestick[], Error>;
|
|
338
354
|
|
|
339
355
|
declare function positionsQueryKey(user: string, source?: ProviderSource): unknown[];
|
|
356
|
+
declare function positionsMultiQueryKey(wallets: {
|
|
357
|
+
kalshi_user?: string;
|
|
358
|
+
polymarket_user?: string;
|
|
359
|
+
}): unknown[];
|
|
360
|
+
/** Single-source params (backward-compatible). */
|
|
340
361
|
interface UsePositionsParams {
|
|
341
|
-
/** Provider source. Omit to aggregate all providers. */
|
|
362
|
+
/** Provider source. Omit to aggregate all providers (same address). */
|
|
342
363
|
source?: ProviderSource;
|
|
343
364
|
user: string;
|
|
344
365
|
}
|
|
366
|
+
/** Multi-wallet params — each provider gets its own address. */
|
|
367
|
+
interface UsePositionsMultiParams {
|
|
368
|
+
kalshi_user?: string;
|
|
369
|
+
polymarket_user?: string;
|
|
370
|
+
}
|
|
345
371
|
declare function usePositions(params: UsePositionsParams, queryOptions?: Omit<UseQueryOptions<PositionsResponse, Error, PositionsResponse, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<PositionsResponse, Error>;
|
|
372
|
+
/**
|
|
373
|
+
* Fetch positions for multiple wallets in a single request.
|
|
374
|
+
* Each provider is queried with its own address.
|
|
375
|
+
*/
|
|
376
|
+
declare function usePositionsMulti(params: UsePositionsMultiParams, queryOptions?: Omit<UseQueryOptions<PositionsResponse, Error, PositionsResponse, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<PositionsResponse, Error>;
|
|
346
377
|
|
|
347
378
|
declare function balanceQueryKey(source: ProviderSource, user: string): unknown[];
|
|
348
379
|
interface UseBalanceParams {
|
|
@@ -352,11 +383,25 @@ interface UseBalanceParams {
|
|
|
352
383
|
declare function useBalance(params: UseBalanceParams, queryOptions?: Omit<UseQueryOptions<BalanceResponse, Error, BalanceResponse, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<BalanceResponse, Error>;
|
|
353
384
|
|
|
354
385
|
declare function ordersQueryKey(params: ListOrdersParams): unknown[];
|
|
355
|
-
|
|
386
|
+
interface UseOrdersOptions {
|
|
387
|
+
/**
|
|
388
|
+
* Async callback invoked before each request to obtain extra headers.
|
|
389
|
+
* Used by Polymarket orders to attach POLY_* HMAC authentication headers.
|
|
390
|
+
*/
|
|
391
|
+
getHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
|
|
392
|
+
}
|
|
393
|
+
declare function useOrders(params: ListOrdersParams, options?: UseOrdersOptions, queryOptions?: Omit<UseQueryOptions<PredictPage<PredictOrder>, Error, PredictPage<PredictOrder>, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<PredictPage<PredictOrder>, Error>;
|
|
356
394
|
|
|
357
395
|
type UseInfiniteOrdersParams = Omit<ListOrdersParams, "next_cursor">;
|
|
396
|
+
interface UseInfiniteOrdersOptions {
|
|
397
|
+
/**
|
|
398
|
+
* Async callback invoked before each request to obtain extra headers.
|
|
399
|
+
* Used by Polymarket orders to attach POLY_* HMAC authentication headers.
|
|
400
|
+
*/
|
|
401
|
+
getHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
|
|
402
|
+
}
|
|
358
403
|
declare function infiniteOrdersQueryKey(params: UseInfiniteOrdersParams): unknown[];
|
|
359
|
-
declare function useInfiniteOrders(params: UseInfiniteOrdersParams): _tanstack_react_query.UseInfiniteQueryResult<_tanstack_react_query.InfiniteData<PredictPage<PredictOrder>, unknown>, Error>;
|
|
404
|
+
declare function useInfiniteOrders(params: UseInfiniteOrdersParams, options?: UseInfiniteOrdersOptions): _tanstack_react_query.UseInfiniteQueryResult<_tanstack_react_query.InfiniteData<PredictPage<PredictOrder>, unknown>, Error>;
|
|
360
405
|
|
|
361
406
|
declare function orderQueryKey(id: string, source: ProviderSource): unknown[];
|
|
362
407
|
interface UseOrderParams {
|
|
@@ -375,19 +420,27 @@ interface CancelOrderVariables {
|
|
|
375
420
|
declare function useCancelOrder(mutationOptions?: Omit<UseMutationOptions<CancelOrderResult, Error, CancelOrderVariables>, "mutationFn">): _tanstack_react_query.UseMutationResult<CancelOrderResult, Error, CancelOrderVariables, unknown>;
|
|
376
421
|
|
|
377
422
|
type UseInfiniteMatchesParams = Omit<MatchesParams, "cursor">;
|
|
378
|
-
type InfiniteQueryOptions = Omit<UseInfiniteQueryOptions<MatchGroupPage, Error, InfiniteData<MatchGroupPage>, unknown[], string | undefined>, "queryKey" | "queryFn" | "initialPageParam" | "getNextPageParam">;
|
|
423
|
+
type InfiniteQueryOptions$1 = Omit<UseInfiniteQueryOptions<MatchGroupPage, Error, InfiniteData<MatchGroupPage>, unknown[], string | undefined>, "queryKey" | "queryFn" | "initialPageParam" | "getNextPageParam">;
|
|
379
424
|
/**
|
|
380
425
|
* TanStack Query infinite-query hook for `GET /api/v1/matches` with
|
|
381
426
|
* cursor-based pagination.
|
|
382
427
|
*
|
|
383
428
|
* Stats are available from the first page: `data.pages[0]?.stats`.
|
|
384
429
|
*/
|
|
385
|
-
declare function useInfiniteMatches(params: UseInfiniteMatchesParams, queryOptions?: InfiniteQueryOptions): _tanstack_react_query.UseInfiniteQueryResult<InfiniteData<MatchGroupPage, unknown>, Error>;
|
|
430
|
+
declare function useInfiniteMatches(params: UseInfiniteMatchesParams, queryOptions?: InfiniteQueryOptions$1): _tanstack_react_query.UseInfiniteQueryResult<InfiniteData<MatchGroupPage, unknown>, Error>;
|
|
386
431
|
/**
|
|
387
432
|
* TanStack Query hook for fetching a single match group by ID.
|
|
388
433
|
*/
|
|
389
434
|
declare function useMatch(id: number, queryOptions?: Omit<UseQueryOptions<MatchGroup, Error, MatchGroup, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<MatchGroup, Error>;
|
|
390
435
|
|
|
436
|
+
type UseInfiniteMatchMarketsParams = Omit<MatchMarketParams, "offset">;
|
|
437
|
+
type InfiniteQueryOptions = Omit<UseInfiniteQueryOptions<MatchMarketPage, Error, InfiniteData<MatchMarketPage>, unknown[], number>, "queryKey" | "queryFn" | "initialPageParam" | "getNextPageParam">;
|
|
438
|
+
/**
|
|
439
|
+
* TanStack Query infinite-query hook for `GET /api/v1/matches/markets`
|
|
440
|
+
* with offset-based pagination.
|
|
441
|
+
*/
|
|
442
|
+
declare function useInfiniteMatchMarkets(params: UseInfiniteMatchMarketsParams, queryOptions?: InfiniteQueryOptions): _tanstack_react_query.UseInfiniteQueryResult<InfiniteData<MatchMarketPage, unknown>, Error>;
|
|
443
|
+
|
|
391
444
|
declare function tradesQueryKey(params: ListTradesParams): unknown[];
|
|
392
445
|
declare function useTrades(params: ListTradesParams, queryOptions?: Omit<UseQueryOptions<PredictPage<PredictTrade>, Error, PredictPage<PredictTrade>, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<PredictPage<PredictTrade>, Error>;
|
|
393
446
|
|
|
@@ -413,6 +466,89 @@ declare function dflowKYCQueryKey(walletAddress: string): unknown[];
|
|
|
413
466
|
*/
|
|
414
467
|
declare function useDFlowKYC(walletAddress?: string, queryOptions?: Omit<UseQueryOptions<DFlowKYCStatus, Error, DFlowKYCStatus, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<DFlowKYCStatus, Error>;
|
|
415
468
|
|
|
469
|
+
declare function polymarketSetupQueryKey(walletAddress: string): unknown[];
|
|
470
|
+
/**
|
|
471
|
+
* Query hook that checks Polymarket wallet setup status
|
|
472
|
+
* (Safe deployed + USDC.e approved for CTF Exchange).
|
|
473
|
+
*/
|
|
474
|
+
declare function usePolymarketSetup(walletAddress?: string, queryOptions?: Omit<UseQueryOptions<PolymarketSetupStatus, Error, PolymarketSetupStatus, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<PolymarketSetupStatus, Error>;
|
|
475
|
+
/**
|
|
476
|
+
* Mutation hook to run Polymarket wallet setup
|
|
477
|
+
* (deploy Safe + approve USDC.e via Relayer).
|
|
478
|
+
* Automatically invalidates the setup status query on success.
|
|
479
|
+
*/
|
|
480
|
+
declare function useRunPolymarketSetup(walletAddress?: string): _tanstack_react_query.UseMutationResult<PolymarketSetupStatus, Error, string, unknown>;
|
|
481
|
+
|
|
482
|
+
declare function useWithdrawBuildMutation(mutationOptions?: Omit<UseMutationOptions<WithdrawBuildResponse, Error, WithdrawBuildRequest>, "mutationFn">): _tanstack_react_query.UseMutationResult<WithdrawBuildResponse, Error, WithdrawBuildRequest, unknown>;
|
|
483
|
+
|
|
484
|
+
declare function useWithdrawSubmitMutation(mutationOptions?: Omit<UseMutationOptions<WithdrawSubmitResponse, Error, WithdrawSubmitRequest>, "mutationFn">): _tanstack_react_query.UseMutationResult<WithdrawSubmitResponse, Error, WithdrawSubmitRequest, unknown>;
|
|
485
|
+
|
|
486
|
+
declare function withdrawStatusQueryKey(txHash: string, source: ProviderSource): unknown[];
|
|
487
|
+
interface UseWithdrawStatusQueryParams {
|
|
488
|
+
txHash: string | undefined;
|
|
489
|
+
source: ProviderSource;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Polls the withdraw transaction status every 3 seconds.
|
|
493
|
+
* Automatically stops polling when status is "confirmed" or "failed".
|
|
494
|
+
* Only enabled when `txHash` is defined.
|
|
495
|
+
*/
|
|
496
|
+
declare function useWithdrawStatusQuery(params: UseWithdrawStatusQueryParams, queryOptions?: Omit<UseQueryOptions<WithdrawStatusResponse, Error, WithdrawStatusResponse, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<WithdrawStatusResponse, Error>;
|
|
497
|
+
|
|
498
|
+
interface PolymarketDepositVariables {
|
|
499
|
+
from: string;
|
|
500
|
+
safeAddress: string;
|
|
501
|
+
/** Total USDC amount needed (human-readable, e.g. "50.0"). */
|
|
502
|
+
amount: string;
|
|
503
|
+
/** Signs a raw EVM transaction and returns the signed hex. */
|
|
504
|
+
signTransaction: (txParams: Record<string, string>) => Promise<string>;
|
|
505
|
+
}
|
|
506
|
+
interface PolymarketDepositResult {
|
|
507
|
+
/** Whether any deposit transactions were executed. */
|
|
508
|
+
deposited: boolean;
|
|
509
|
+
/** Number of transactions executed (0, 1 for swap-only, or 2 for approve+swap). */
|
|
510
|
+
txCount: number;
|
|
511
|
+
/** Shortfall that was swapped (human-readable). */
|
|
512
|
+
shortfall: string;
|
|
513
|
+
/** Safe balance before deposit. */
|
|
514
|
+
safeBalance: string;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Mutation hook for depositing native USDC into a Polymarket Safe wallet as USDC.e.
|
|
518
|
+
*
|
|
519
|
+
* Flow:
|
|
520
|
+
* 1. Calls `/deposit/polymarket/build` to check Safe USDC.e balance and get unsigned txs.
|
|
521
|
+
* 2. If shortfall > 0, signs and submits each tx (approve if needed, then swap).
|
|
522
|
+
* 3. Polls tx status until confirmed.
|
|
523
|
+
* 4. Returns the deposit result.
|
|
524
|
+
*/
|
|
525
|
+
declare function usePolymarketDeposit(mutationOptions?: Omit<UseMutationOptions<PolymarketDepositResult, Error, PolymarketDepositVariables>, "mutationFn">): _tanstack_react_query.UseMutationResult<PolymarketDepositResult, Error, PolymarketDepositVariables, unknown>;
|
|
526
|
+
|
|
527
|
+
declare const polymarketDepositAddressesQueryKey: (safeAddress: string) => readonly ["polymarket", "deposit-addresses", string];
|
|
528
|
+
/**
|
|
529
|
+
* Fetch multi-chain deposit addresses for a Polymarket Safe wallet.
|
|
530
|
+
*
|
|
531
|
+
* @param safeAddress - The Safe (proxy) wallet address. When empty/undefined the query is disabled.
|
|
532
|
+
*/
|
|
533
|
+
declare function usePolymarketDepositAddresses(safeAddress: string | undefined): _tanstack_react_query.UseQueryResult<PolymarketDepositAddresses, Error>;
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Mutation hook to execute a gasless USDC.e withdrawal from a Polymarket Safe
|
|
537
|
+
* wallet via the Relayer.
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```ts
|
|
541
|
+
* const { mutateAsync: withdraw } = usePolymarketWithdraw();
|
|
542
|
+
* await withdraw({
|
|
543
|
+
* wallet_address: "0xEOA...",
|
|
544
|
+
* safe_address: "0xSafe...",
|
|
545
|
+
* to: "0xRecipient...",
|
|
546
|
+
* amount: "10.5",
|
|
547
|
+
* });
|
|
548
|
+
* ```
|
|
549
|
+
*/
|
|
550
|
+
declare function usePolymarketWithdraw(): _tanstack_react_query.UseMutationResult<PolymarketWithdrawResponse, Error, PolymarketWithdrawRequest, unknown>;
|
|
551
|
+
|
|
416
552
|
interface UsePredictWsClientResult {
|
|
417
553
|
/** The WebSocket client instance, or `null` if not provided via `PredictProvider`. */
|
|
418
554
|
wsClient: PredictWsClient | null;
|
|
@@ -601,25 +737,37 @@ interface CreatePolymarketOrderVariables {
|
|
|
601
737
|
/**
|
|
602
738
|
* IoC signer — provided by the consuming app.
|
|
603
739
|
* Used to sign the EIP-712 order struct on the CTF Exchange contract.
|
|
740
|
+
* If `signTransaction` is provided on the signer, auto-deposit is enabled:
|
|
741
|
+
* before placing the order, the hook checks whether the Safe wallet has
|
|
742
|
+
* enough USDC.e and swaps native USDC → USDC.e via Uniswap V3 if needed.
|
|
604
743
|
*/
|
|
605
744
|
signer: PolymarketSigner;
|
|
606
745
|
}
|
|
607
746
|
/**
|
|
608
|
-
* Mutation hook for creating a Polymarket limit order.
|
|
747
|
+
* Mutation hook for creating a Polymarket limit order with auto-deposit.
|
|
609
748
|
*
|
|
610
749
|
* Flow:
|
|
611
750
|
* 1. If no L2 credentials exist, triggers L1 → L2 authentication automatically.
|
|
612
|
-
* 2.
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
751
|
+
* 2. **Auto-deposit** (when `signer.signTransaction` is provided):
|
|
752
|
+
* - Calls `/deposit/polymarket/build` to check Safe USDC.e balance.
|
|
753
|
+
* - If shortfall > 0, signs and submits approve + swap transactions.
|
|
754
|
+
* - Polls until the swap is confirmed on-chain.
|
|
755
|
+
* 3. Builds the EIP-712 `Order` typed data and prompts the wallet for a signature.
|
|
756
|
+
* 4. Constructs HMAC L2 auth headers from the stored credentials.
|
|
757
|
+
* 5. Submits the signed order via `POST /api/v1/orders/polymarket`.
|
|
758
|
+
* 6. Invalidates `orders` and `positions` queries on success.
|
|
616
759
|
*
|
|
617
760
|
* @example
|
|
618
761
|
* ```tsx
|
|
619
762
|
* const { mutateAsync: createOrder, isPending } = useCreatePolymarketOrder();
|
|
620
763
|
*
|
|
621
764
|
* await createOrder({
|
|
622
|
-
* signer:
|
|
765
|
+
* signer: {
|
|
766
|
+
* address: walletAddress,
|
|
767
|
+
* signatureType: 2,
|
|
768
|
+
* signTypedData: async (domain, types, value) => { ... },
|
|
769
|
+
* signTransaction: async (txParams) => { ... }, // enables auto-deposit
|
|
770
|
+
* },
|
|
623
771
|
* input: {
|
|
624
772
|
* tokenId: "123456789",
|
|
625
773
|
* price: 0.55,
|
|
@@ -627,10 +775,11 @@ interface CreatePolymarketOrderVariables {
|
|
|
627
775
|
* side: "BUY",
|
|
628
776
|
* tickSize: "0.01",
|
|
629
777
|
* negRisk: false,
|
|
778
|
+
* funderAddress: safeAddress,
|
|
630
779
|
* },
|
|
631
780
|
* });
|
|
632
781
|
* ```
|
|
633
782
|
*/
|
|
634
783
|
declare function useCreatePolymarketOrder(mutationOptions?: Omit<UseMutationOptions<PredictOrder, Error, CreatePolymarketOrderVariables>, "mutationFn">): _tanstack_react_query.UseMutationResult<PredictOrder, Error, CreatePolymarketOrderVariables, unknown>;
|
|
635
784
|
|
|
636
|
-
export { BalanceResponse, CancelOrderResult, type CancelOrderVariables, Candlestick, ChartRange, type ChartRangeType, CreateOrderInput, type CreatePolymarketOrderVariables, DFlowKYCStatus, DFlowQuoteRequest, DFlowQuoteResponse, DFlowSubmitRequest, DFlowSubmitResponse, EventStatus, ListCandlesticksParams, ListEventsParams, ListMarketTradesParams, ListOrdersParams, ListTradesParams, type MarketHistoryPoint, type MarketHistorySeries, MatchGroup, MatchGroupPage, MatchesParams, Orderbook, PolymarketContext, type PolymarketContextValue, type PolymarketCredentials, PolymarketProvider, type PolymarketProviderProps, type PolymarketSigner, PositionsResponse, PredictClient, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryRange, PriceHistoryResponse, ProviderSource, SimilarEventsParams, type UseBalanceParams, type UseCandlesticksParams, type UseEventParams, type UseInfiniteMatchesParams, type UseInfiniteOrdersParams, type UseInfiniteTradesParams, type UseMarketHistoryResult, type UseMarketParams, type UseMarketTradesParams, type UseOrderParams, type UseOrderbookParams, type UseOrderbookSubscriptionParams, type UseOrderbookSubscriptionResult, 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, WsConnectionStatus, WsDataMessage, WsOrderbookEvent, WsPriceEvent, WsTradeEvent, balanceQueryKey, candlesticksQueryKey, dflowKYCQueryKey, dflowQuoteQueryKey, eventsQueryKey, fetchEvents, infiniteOrdersQueryKey, infiniteTradesQueryKey, marketTradesQueryKey, orderQueryKey, orderbookQueryKey, ordersQueryKey, positionsQueryKey, priceHistoryQueryKey, similarEventsQueryKey, tradesQueryKey, useBalance, useCancelOrder, useCandlesticks, useCreatePolymarketOrder, useDFlowKYC, useDFlowQuote, useDFlowSubmit, useEvent, useEvents, useInfiniteEvents, useInfiniteMatches, useInfiniteOrders, useInfiniteTrades, useMarket, useMarketHistory, useMarketTrades, useMatch, useOrder, useOrderbook, useOrderbookSubscription, useOrders, usePolymarket, usePositions, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useSearchEvents, useSimilarEvents, useTrades, useTradesSubscription };
|
|
785
|
+
export { BalanceResponse, CancelOrderResult, type CancelOrderVariables, Candlestick, ChartRange, type ChartRangeType, CreateOrderInput, type CreatePolymarketOrderVariables, DFlowKYCStatus, DFlowQuoteRequest, DFlowQuoteResponse, DFlowSubmitRequest, DFlowSubmitResponse, EventStatus, ListCandlesticksParams, ListEventsParams, ListMarketTradesParams, ListOrdersParams, ListTradesParams, type MarketHistoryPoint, type MarketHistorySeries, MatchGroup, MatchGroupPage, MatchMarketPage, MatchMarketParams, MatchesParams, Orderbook, PolymarketContext, type PolymarketContextValue, type PolymarketCredentials, PolymarketDepositAddresses, type PolymarketDepositResult, type PolymarketDepositVariables, PolymarketProvider, type PolymarketProviderProps, type PolymarketSigner, PolymarketWithdrawRequest, PolymarketWithdrawResponse, PositionsResponse, PredictClient, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryRange, PriceHistoryResponse, ProviderSource, SimilarEventsParams, type UseBalanceParams, type UseCandlesticksParams, type UseEventParams, type UseInfiniteMatchMarketsParams, type UseInfiniteMatchesParams, type UseInfiniteOrdersOptions, type UseInfiniteOrdersParams, type UseInfiniteTradesParams, type UseMarketHistoryResult, type UseMarketParams, type UseMarketTradesParams, type UseOrderParams, type UseOrderbookParams, type UseOrderbookSubscriptionParams, type UseOrderbookSubscriptionResult, 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, WithdrawBuildRequest, WithdrawBuildResponse, WithdrawStatusResponse, WithdrawSubmitRequest, WithdrawSubmitResponse, WsConnectionStatus, WsDataMessage, WsOrderbookEvent, WsPriceEvent, WsTradeEvent, balanceQueryKey, candlesticksQueryKey, dflowKYCQueryKey, dflowQuoteQueryKey, eventsQueryKey, fetchEvents, infiniteOrdersQueryKey, infiniteTradesQueryKey, marketTradesQueryKey, orderQueryKey, orderbookQueryKey, ordersQueryKey, polymarketDepositAddressesQueryKey, polymarketSetupQueryKey, positionsMultiQueryKey, positionsQueryKey, priceHistoryQueryKey, similarEventsQueryKey, tradesQueryKey, useBalance, useCancelOrder, useCandlesticks, useCreatePolymarketOrder, useDFlowKYC, useDFlowQuote, useDFlowSubmit, useEvent, useEvents, useInfiniteEvents, useInfiniteMatchMarkets, useInfiniteMatches, useInfiniteOrders, useInfiniteTrades, useMarket, useMarketHistory, useMarketTrades, useMatch, useOrder, useOrderbook, useOrderbookSubscription, useOrders, usePolymarket, usePolymarketDeposit, usePolymarketDepositAddresses, usePolymarketSetup, usePolymarketWithdraw, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTrades, useTradesSubscription, useWithdrawBuildMutation, useWithdrawStatusQuery, useWithdrawSubmitMutation, withdrawStatusQueryKey };
|