@liberfi.io/react-predict 0.3.39 → 0.3.41

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.mjs CHANGED
@@ -253,22 +253,15 @@ var PredictClient = class {
253
253
  // Polymarket trading
254
254
  // -------------------------------------------------------------------------
255
255
  /**
256
- * Create a Polymarket limit order via the prediction-server proxy.
256
+ * Execute an already signed Polymarket CLOB order through prediction-server.
257
257
  *
258
- * Maps to `POST /api/v1/orders/polymarket`.
259
- *
260
- * The caller must attach Polymarket CLOB authentication headers:
261
- * - `POLY_ADDRESS` — the EVM wallet address.
262
- * - `POLY_SIGNATURE` — L1 signature or L2 API key.
263
- * - `POLY_TIMESTAMP` — Unix milliseconds string.
264
- * - `POLY_NONCE` — credential nonce (use `"0"` for in-session derived creds).
265
- *
266
- * @param input - Order parameters.
267
- * @param headers - Polymarket CLOB auth headers (`POLY_*`).
258
+ * Maps to `POST /api/v1/orders/polymarket/execute`. The server builds the
259
+ * CLOB HMAC headers from the provided L2 credentials, forwards `payload`
260
+ * unchanged to `/order`, and records rebate identity mappings.
268
261
  */
269
- async createPolymarketOrder(input, headers) {
270
- const url = `${this.endpoint}/api/v1/orders/polymarket`;
271
- return await httpPost(url, input, { headers });
262
+ async executePolymarketOrder(req) {
263
+ const url = `${this.endpoint}/api/v1/orders/polymarket/execute`;
264
+ return await httpPost(url, req);
272
265
  }
273
266
  /** Maps to `GET /api/v1/polymarket/tick-size?token_id=xxx`. */
274
267
  async getPolymarketTickSize(tokenId) {
@@ -472,6 +465,11 @@ var PredictClient = class {
472
465
  // -------------------------------------------------------------------------
473
466
  // Polymarket Relayer Withdraw
474
467
  // -------------------------------------------------------------------------
468
+ /** Maps to `POST /api/v1/withdraw/polymarket/quote`. */
469
+ async quotePolymarketWithdraw(body) {
470
+ const url = `${this.endpoint}/api/v1/withdraw/polymarket/quote`;
471
+ return await httpPost(url, body);
472
+ }
475
473
  /**
476
474
  * Prepare a Polymarket withdrawal by obtaining a Bridge deposit address.
477
475
  *
@@ -481,6 +479,22 @@ var PredictClient = class {
481
479
  const url = `${this.endpoint}/api/v1/withdraw/polymarket/prepare`;
482
480
  return await httpPost(url, body);
483
481
  }
482
+ /** Maps to `POST /api/v1/withdraw/polymarket/build-relay`. */
483
+ async buildPolymarketWithdrawRelay(body) {
484
+ const url = `${this.endpoint}/api/v1/withdraw/polymarket/build-relay`;
485
+ return await httpPost(url, body);
486
+ }
487
+ /** Maps to `POST /api/v1/withdraw/polymarket/submit-relay`. */
488
+ async submitPolymarketWithdrawRelay(body) {
489
+ const url = `${this.endpoint}/api/v1/withdraw/polymarket/submit-relay`;
490
+ return await httpPost(url, body);
491
+ }
492
+ /** Maps to `GET /api/v1/withdraw/polymarket/status`. */
493
+ async getPolymarketWithdrawStatus(params) {
494
+ const query = buildQuery(params);
495
+ const url = `${this.endpoint}/api/v1/withdraw/polymarket/status${query}`;
496
+ return await httpGet(url);
497
+ }
484
498
  /**
485
499
  * Execute a gasless USDC.e withdrawal from a Polymarket Safe wallet via Relayer.
486
500
  *
@@ -1832,6 +1846,49 @@ function usePolymarketWithdraw() {
1832
1846
  mutationFn: (req) => client.executePolymarketWithdraw(req)
1833
1847
  });
1834
1848
  }
1849
+ function usePolymarketWithdrawQuoteMutation() {
1850
+ const client = usePredictClient();
1851
+ return useMutation({
1852
+ mutationFn: (req) => client.quotePolymarketWithdraw(req)
1853
+ });
1854
+ }
1855
+ function usePolymarketWithdrawPrepareMutation() {
1856
+ const client = usePredictClient();
1857
+ return useMutation({
1858
+ mutationFn: (req) => client.preparePolymarketWithdraw(req)
1859
+ });
1860
+ }
1861
+ function usePolymarketWithdrawRelayBuildMutation() {
1862
+ const client = usePredictClient();
1863
+ return useMutation({
1864
+ mutationFn: (req) => client.buildPolymarketWithdrawRelay(req)
1865
+ });
1866
+ }
1867
+ function usePolymarketWithdrawRelaySubmitMutation() {
1868
+ const client = usePredictClient();
1869
+ return useMutation({
1870
+ mutationFn: (req) => client.submitPolymarketWithdrawRelay(req)
1871
+ });
1872
+ }
1873
+ var polymarketWithdrawStatusQueryKey = (bridgeAddress, transactionId) => ["polymarket", "withdraw-status", bridgeAddress ?? "", transactionId ?? ""];
1874
+ function usePolymarketWithdrawStatusQuery(params) {
1875
+ const client = usePredictClient();
1876
+ return useQuery({
1877
+ queryKey: polymarketWithdrawStatusQueryKey(
1878
+ params.bridge_address,
1879
+ params.transaction_id
1880
+ ),
1881
+ queryFn: () => client.getPolymarketWithdrawStatus(params),
1882
+ enabled: Boolean(params.bridge_address || params.transaction_id),
1883
+ refetchInterval: (query) => {
1884
+ const data = query.state.data;
1885
+ if (data?.bridge_status === "completed" || data?.bridge_status === "failed" || data?.relayer_status === "STATE_FAILED") {
1886
+ return false;
1887
+ }
1888
+ return 3e3;
1889
+ }
1890
+ });
1891
+ }
1835
1892
  function useRedeemPosition() {
1836
1893
  const client = usePredictClient();
1837
1894
  const queryClient = useQueryClient();
@@ -2402,19 +2459,15 @@ function useCreatePolymarketOrder(mutationOptions = {}) {
2402
2459
  input,
2403
2460
  owner: creds.apiKey
2404
2461
  });
2405
- const body2 = JSON.stringify(v2Payload);
2406
- const headers2 = await buildPolymarketL2Headers(creds.address, {
2407
- apiKey: creds.apiKey,
2408
- secret: creds.secret,
2409
- passphrase: creds.passphrase,
2410
- method: "POST",
2411
- requestPath: "/order",
2412
- body: body2
2462
+ const result2 = await client.executePolymarketOrder({
2463
+ payload: v2Payload,
2464
+ l2_api_key: creds.apiKey,
2465
+ l2_secret: creds.secret,
2466
+ l2_passphrase: creds.passphrase,
2467
+ signer_address: creds.address,
2468
+ owner: creds.apiKey
2413
2469
  });
2414
- return client.createPolymarketOrder(
2415
- v2Payload,
2416
- headers2
2417
- );
2470
+ return result2.raw;
2418
2471
  }
2419
2472
  if (signer.signTransaction && input.funderAddress) {
2420
2473
  const orderCost = computeOrderCost(input);
@@ -2456,19 +2509,15 @@ function useCreatePolymarketOrder(mutationOptions = {}) {
2456
2509
  input.orderType
2457
2510
  );
2458
2511
  const clobPayload = buildClobPayload(signedOrder, creds.apiKey);
2459
- const body = JSON.stringify(clobPayload);
2460
- const headers = await buildPolymarketL2Headers(creds.address, {
2461
- apiKey: creds.apiKey,
2462
- secret: creds.secret,
2463
- passphrase: creds.passphrase,
2464
- method: "POST",
2465
- requestPath: "/order",
2466
- body
2512
+ const result = await client.executePolymarketOrder({
2513
+ payload: clobPayload,
2514
+ l2_api_key: creds.apiKey,
2515
+ l2_secret: creds.secret,
2516
+ l2_passphrase: creds.passphrase,
2517
+ signer_address: creds.address,
2518
+ owner: creds.apiKey
2467
2519
  });
2468
- return client.createPolymarketOrder(
2469
- clobPayload,
2470
- headers
2471
- );
2520
+ return result.raw;
2472
2521
  },
2473
2522
  onSuccess: () => {
2474
2523
  queryClient.invalidateQueries({ queryKey: ["predict", "orders"] });
@@ -2596,6 +2645,6 @@ function walkOrderbook({
2596
2645
  };
2597
2646
  }
2598
2647
 
2599
- export { CLOB_AUTH_DOMAIN, CLOB_AUTH_TYPES, CTF_EXCHANGE_ADDRESS, CTF_ORDER_TYPES, ChartRange, NEG_RISK_CTF_EXCHANGE_ADDRESS, ORDER_TYPE, POLYGON_CHAIN_ID, PolymarketContext, PolymarketProvider, PredictClient, PredictContext, PredictProvider, PredictWsClient, SIDE, USDC_ADDRESS, availableSharesQueryKey, balanceQueryKey, buildClobAuthMessage, buildClobPayload, buildCtfExchangeDomain, buildOrderMessage, buildPolymarketL2Headers, buildSignedOrder, buildSignedV2OrderPayload, candlesticksQueryKey, createPredictClient, createPredictWsClient, derivePolymarketApiKey, dflowKYCQueryKey, dflowQuoteQueryKey, eventQueryKey, eventStatsQueryKey, eventsQueryKey, feeRateQueryKey, fetchEvent, fetchEvents, fetchEventsPage, fetchMarket, fetchMatchMarketsPage, fetchMatchesPage, getPolymarketSharesPrecision, hmacSha256Base64, infiniteCommentsQueryKey, infiniteEventsQueryKey, infiniteOrdersQueryKey, infiniteTradesMultiQueryKey, infiniteTradesQueryKey, marketQueryKey, marketTradesQueryKey, matchMarketsQueryKey, matchQueryKey, matchesQueryKey, orderQueryKey, orderbookQueryKey, ordersMultiQueryKey, ordersQueryKey, pickBestAsk, pickBestBid, polymarketDepositAddressesQueryKey, polymarketSetupQueryKey, polymarketSupportedAssetsQueryKey, positionsMultiQueryKey, positionsQueryKey, priceHistoryQueryKey, rebateConfigQueryKey, resolveEventsParams, resolveTagSlug, 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 };
2648
+ export { CLOB_AUTH_DOMAIN, CLOB_AUTH_TYPES, CTF_EXCHANGE_ADDRESS, CTF_ORDER_TYPES, ChartRange, NEG_RISK_CTF_EXCHANGE_ADDRESS, ORDER_TYPE, POLYGON_CHAIN_ID, PolymarketContext, PolymarketProvider, PredictClient, PredictContext, PredictProvider, PredictWsClient, SIDE, USDC_ADDRESS, availableSharesQueryKey, balanceQueryKey, buildClobAuthMessage, buildClobPayload, buildCtfExchangeDomain, buildOrderMessage, buildPolymarketL2Headers, buildSignedOrder, buildSignedV2OrderPayload, candlesticksQueryKey, createPredictClient, createPredictWsClient, derivePolymarketApiKey, dflowKYCQueryKey, dflowQuoteQueryKey, eventQueryKey, eventStatsQueryKey, eventsQueryKey, feeRateQueryKey, fetchEvent, fetchEvents, fetchEventsPage, fetchMarket, fetchMatchMarketsPage, fetchMatchesPage, getPolymarketSharesPrecision, hmacSha256Base64, infiniteCommentsQueryKey, infiniteEventsQueryKey, infiniteOrdersQueryKey, infiniteTradesMultiQueryKey, infiniteTradesQueryKey, marketQueryKey, marketTradesQueryKey, matchMarketsQueryKey, matchQueryKey, matchesQueryKey, orderQueryKey, orderbookQueryKey, ordersMultiQueryKey, ordersQueryKey, pickBestAsk, pickBestBid, polymarketDepositAddressesQueryKey, polymarketSetupQueryKey, polymarketSupportedAssetsQueryKey, polymarketWithdrawStatusQueryKey, positionsMultiQueryKey, positionsQueryKey, priceHistoryQueryKey, rebateConfigQueryKey, resolveEventsParams, resolveTagSlug, 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, usePolymarketWithdrawPrepareMutation, usePolymarketWithdrawQuoteMutation, usePolymarketWithdrawRelayBuildMutation, usePolymarketWithdrawRelaySubmitMutation, usePolymarketWithdrawStatusQuery, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRebateConfig, useRedeemPosition, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTickSize, useTrades, useTradesSubscription, useWithdrawBuildMutation, useWithdrawStatusQuery, useWithdrawSubmitMutation, walkOrderbook, withdrawStatusQueryKey };
2600
2649
  //# sourceMappingURL=index.mjs.map
2601
2650
  //# sourceMappingURL=index.mjs.map