@liberfi.io/react-predict 0.3.38 → 0.3.40

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) {
@@ -2402,19 +2395,15 @@ function useCreatePolymarketOrder(mutationOptions = {}) {
2402
2395
  input,
2403
2396
  owner: creds.apiKey
2404
2397
  });
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
2398
+ const result2 = await client.executePolymarketOrder({
2399
+ payload: v2Payload,
2400
+ l2_api_key: creds.apiKey,
2401
+ l2_secret: creds.secret,
2402
+ l2_passphrase: creds.passphrase,
2403
+ signer_address: creds.address,
2404
+ owner: creds.apiKey
2413
2405
  });
2414
- return client.createPolymarketOrder(
2415
- v2Payload,
2416
- headers2
2417
- );
2406
+ return result2.raw;
2418
2407
  }
2419
2408
  if (signer.signTransaction && input.funderAddress) {
2420
2409
  const orderCost = computeOrderCost(input);
@@ -2456,19 +2445,15 @@ function useCreatePolymarketOrder(mutationOptions = {}) {
2456
2445
  input.orderType
2457
2446
  );
2458
2447
  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
2448
+ const result = await client.executePolymarketOrder({
2449
+ payload: clobPayload,
2450
+ l2_api_key: creds.apiKey,
2451
+ l2_secret: creds.secret,
2452
+ l2_passphrase: creds.passphrase,
2453
+ signer_address: creds.address,
2454
+ owner: creds.apiKey
2467
2455
  });
2468
- return client.createPolymarketOrder(
2469
- clobPayload,
2470
- headers
2471
- );
2456
+ return result.raw;
2472
2457
  },
2473
2458
  onSuccess: () => {
2474
2459
  queryClient.invalidateQueries({ queryKey: ["predict", "orders"] });