opentool 0.18.0 → 0.19.1

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.
@@ -1,5 +1,5 @@
1
1
  import { h as WalletFullContext } from '../../types-BaTmu0gS.js';
2
- import 'viem';
2
+ import { PublicClient } from 'viem';
3
3
  import 'viem/accounts';
4
4
 
5
5
  type PolymarketEnvironment = "mainnet" | "testnet";
@@ -187,23 +187,20 @@ interface PolymarketPlaceOrderResponse {
187
187
  message?: string;
188
188
  [key: string]: unknown;
189
189
  }
190
- declare function createPolymarketApiKey(args: {
190
+ interface PolymarketApiKeyRequestArgs {
191
191
  wallet: WalletFullContext;
192
192
  environment?: PolymarketEnvironment;
193
193
  timestamp?: number;
194
194
  nonce?: number;
195
195
  message?: string;
196
- }): Promise<PolymarketApiKeyResponse>;
197
- declare function derivePolymarketApiKey(args: {
198
- wallet: WalletFullContext;
199
- environment?: PolymarketEnvironment;
200
- timestamp?: number;
201
- nonce?: number;
202
- message?: string;
203
- }): Promise<PolymarketApiKeyResponse>;
196
+ }
197
+ declare function createPolymarketApiKey(args: PolymarketApiKeyRequestArgs): Promise<PolymarketApiKeyResponse>;
198
+ declare function derivePolymarketApiKey(args: PolymarketApiKeyRequestArgs): Promise<PolymarketApiKeyResponse>;
199
+ declare function createOrDerivePolymarketApiKey(args: PolymarketApiKeyRequestArgs): Promise<PolymarketApiKeyResponse>;
204
200
  declare function placePolymarketOrder(args: {
205
201
  wallet: WalletFullContext;
206
202
  credentials?: PolymarketApiCredentials;
203
+ apiKeyNonce?: number;
207
204
  order: PolymarketOrderIntent;
208
205
  orderType?: PolymarketOrderType;
209
206
  environment?: PolymarketEnvironment;
@@ -213,6 +210,7 @@ declare function cancelPolymarketOrder(args: {
213
210
  wallet?: WalletFullContext;
214
211
  walletAddress?: `0x${string}`;
215
212
  credentials?: PolymarketApiCredentials;
213
+ apiKeyNonce?: number;
216
214
  environment?: PolymarketEnvironment;
217
215
  }): Promise<Record<string, unknown>>;
218
216
  declare function cancelPolymarketOrders(args: {
@@ -220,12 +218,14 @@ declare function cancelPolymarketOrders(args: {
220
218
  wallet?: WalletFullContext;
221
219
  walletAddress?: `0x${string}`;
222
220
  credentials?: PolymarketApiCredentials;
221
+ apiKeyNonce?: number;
223
222
  environment?: PolymarketEnvironment;
224
223
  }): Promise<Record<string, unknown>>;
225
224
  declare function cancelAllPolymarketOrders(args: {
226
225
  wallet?: WalletFullContext;
227
226
  walletAddress?: `0x${string}`;
228
227
  credentials?: PolymarketApiCredentials;
228
+ apiKeyNonce?: number;
229
229
  environment?: PolymarketEnvironment;
230
230
  }): Promise<Record<string, unknown>>;
231
231
  declare function cancelMarketPolymarketOrders(args: {
@@ -233,16 +233,19 @@ declare function cancelMarketPolymarketOrders(args: {
233
233
  wallet?: WalletFullContext;
234
234
  walletAddress?: `0x${string}`;
235
235
  credentials?: PolymarketApiCredentials;
236
+ apiKeyNonce?: number;
236
237
  environment?: PolymarketEnvironment;
237
238
  }): Promise<Record<string, unknown>>;
238
239
  declare class PolymarketExchangeClient {
239
240
  private readonly wallet;
240
241
  private readonly credentials;
242
+ private readonly apiKeyNonce;
241
243
  private readonly environment;
242
244
  private cachedCredentials;
243
245
  constructor(args: {
244
246
  wallet: WalletFullContext;
245
247
  credentials?: PolymarketApiCredentials;
248
+ apiKeyNonce?: number;
246
249
  environment?: PolymarketEnvironment;
247
250
  });
248
251
  private getCredentials;
@@ -253,6 +256,8 @@ declare class PolymarketExchangeClient {
253
256
  cancelMarket(tokenId: string): Promise<Record<string, unknown>>;
254
257
  }
255
258
 
259
+ type CsvStringInput = string | string[];
260
+ type CsvNumberInput = number | number[];
256
261
  type FetchParams = {
257
262
  environment?: PolymarketEnvironment;
258
263
  limit?: number;
@@ -267,6 +272,135 @@ type FetchParams = {
267
272
  active?: boolean;
268
273
  closed?: boolean;
269
274
  };
275
+ interface PolymarketUserPosition {
276
+ proxyWallet?: string | null;
277
+ asset?: string | null;
278
+ conditionId?: string | null;
279
+ size?: number | null;
280
+ avgPrice?: number | null;
281
+ initialValue?: number | null;
282
+ currentValue?: number | null;
283
+ cashPnl?: number | null;
284
+ percentPnl?: number | null;
285
+ totalBought?: number | null;
286
+ realizedPnl?: number | null;
287
+ percentRealizedPnl?: number | null;
288
+ curPrice?: number | null;
289
+ redeemable?: boolean;
290
+ mergeable?: boolean;
291
+ title?: string | null;
292
+ slug?: string | null;
293
+ icon?: string | null;
294
+ eventSlug?: string | null;
295
+ outcome?: string | null;
296
+ outcomeIndex?: number | null;
297
+ oppositeOutcome?: string | null;
298
+ oppositeAsset?: string | null;
299
+ endDate?: string | null;
300
+ negativeRisk?: boolean;
301
+ }
302
+ interface PolymarketClosedPosition {
303
+ proxyWallet?: string | null;
304
+ asset?: string | null;
305
+ conditionId?: string | null;
306
+ avgPrice?: number | null;
307
+ totalBought?: number | null;
308
+ realizedPnl?: number | null;
309
+ curPrice?: number | null;
310
+ timestamp?: number | null;
311
+ title?: string | null;
312
+ slug?: string | null;
313
+ icon?: string | null;
314
+ eventSlug?: string | null;
315
+ outcome?: string | null;
316
+ outcomeIndex?: number | null;
317
+ oppositeOutcome?: string | null;
318
+ oppositeAsset?: string | null;
319
+ endDate?: string | null;
320
+ }
321
+ type PolymarketActivityType = "TRADE" | "SPLIT" | "MERGE" | "REDEEM" | "REWARD" | "CONVERSION" | "MAKER_REBATE";
322
+ interface PolymarketUserActivity {
323
+ proxyWallet?: string | null;
324
+ timestamp?: number | null;
325
+ conditionId?: string | null;
326
+ type?: PolymarketActivityType | null;
327
+ size?: number | null;
328
+ usdcSize?: number | null;
329
+ transactionHash?: string | null;
330
+ price?: number | null;
331
+ asset?: string | null;
332
+ side?: "BUY" | "SELL" | null;
333
+ outcomeIndex?: number | null;
334
+ title?: string | null;
335
+ slug?: string | null;
336
+ icon?: string | null;
337
+ eventSlug?: string | null;
338
+ outcome?: string | null;
339
+ name?: string | null;
340
+ pseudonym?: string | null;
341
+ bio?: string | null;
342
+ profileImage?: string | null;
343
+ profileImageOptimized?: string | null;
344
+ }
345
+ interface PolymarketPositionValue {
346
+ user?: string | null;
347
+ value?: number | null;
348
+ }
349
+ interface PolymarketPublicProfileUser {
350
+ id?: string | null;
351
+ creator?: boolean;
352
+ mod?: boolean;
353
+ }
354
+ interface PolymarketPublicProfile {
355
+ createdAt?: string | null;
356
+ proxyWallet?: string | null;
357
+ profileImage?: string | null;
358
+ displayUsernamePublic?: boolean | null;
359
+ bio?: string | null;
360
+ pseudonym?: string | null;
361
+ name?: string | null;
362
+ users?: PolymarketPublicProfileUser[] | null;
363
+ xUsername?: string | null;
364
+ verifiedBadge?: boolean | null;
365
+ }
366
+ interface PolymarketUserQueryBase {
367
+ user: string;
368
+ environment?: PolymarketEnvironment;
369
+ market?: CsvStringInput;
370
+ eventId?: CsvNumberInput;
371
+ }
372
+ interface PolymarketUserPositionParams extends PolymarketUserQueryBase {
373
+ sizeThreshold?: number;
374
+ redeemable?: boolean;
375
+ mergeable?: boolean;
376
+ limit?: number;
377
+ offset?: number;
378
+ sortBy?: "CURRENT" | "INITIAL" | "TOKENS" | "CASHPNL" | "PERCENTPNL" | "TITLE" | "RESOLVING" | "PRICE" | "AVGPRICE";
379
+ sortDirection?: "ASC" | "DESC";
380
+ title?: string;
381
+ }
382
+ interface PolymarketClosedPositionParams extends PolymarketUserQueryBase {
383
+ limit?: number;
384
+ offset?: number;
385
+ sortBy?: "REALIZEDPNL" | "TITLE" | "PRICE" | "AVGPRICE" | "TIMESTAMP";
386
+ sortDirection?: "ASC" | "DESC";
387
+ title?: string;
388
+ }
389
+ interface PolymarketUserActivityParams extends PolymarketUserQueryBase {
390
+ limit?: number;
391
+ offset?: number;
392
+ type?: PolymarketActivityType | PolymarketActivityType[];
393
+ start?: number;
394
+ end?: number;
395
+ sortBy?: "TIMESTAMP" | "TOKENS" | "CASH";
396
+ sortDirection?: "ASC" | "DESC";
397
+ side?: "BUY" | "SELL";
398
+ }
399
+ interface PolymarketPositionValueParams {
400
+ user: string;
401
+ environment?: PolymarketEnvironment;
402
+ market?: CsvStringInput;
403
+ }
270
404
  declare class PolymarketInfoClient {
271
405
  private readonly environment;
272
406
  constructor(environment?: PolymarketEnvironment);
@@ -286,6 +420,11 @@ declare class PolymarketInfoClient {
286
420
  interval?: string;
287
421
  fidelity?: number;
288
422
  }): Promise<PolymarketPriceHistoryPoint[]>;
423
+ positions(params: Omit<PolymarketUserPositionParams, "environment">): Promise<PolymarketUserPosition[]>;
424
+ closedPositions(params: Omit<PolymarketClosedPositionParams, "environment">): Promise<PolymarketClosedPosition[]>;
425
+ activity(params: Omit<PolymarketUserActivityParams, "environment">): Promise<PolymarketUserActivity[]>;
426
+ positionValue(params: Omit<PolymarketPositionValueParams, "environment">): Promise<PolymarketPositionValue[]>;
427
+ publicProfile(address: string): Promise<PolymarketPublicProfile | null>;
289
428
  }
290
429
  declare function fetchPolymarketMarkets(params?: FetchParams): Promise<PolymarketMarket[]>;
291
430
  declare function fetchPolymarketMarket(params: {
@@ -315,5 +454,78 @@ declare function fetchPolymarketPriceHistory(params: {
315
454
  fidelity?: number;
316
455
  environment?: PolymarketEnvironment;
317
456
  }): Promise<PolymarketPriceHistoryPoint[]>;
457
+ declare function fetchPolymarketPositions(params: PolymarketUserPositionParams): Promise<PolymarketUserPosition[]>;
458
+ declare function fetchPolymarketClosedPositions(params: PolymarketClosedPositionParams): Promise<PolymarketClosedPosition[]>;
459
+ declare function fetchPolymarketActivity(params: PolymarketUserActivityParams): Promise<PolymarketUserActivity[]>;
460
+ declare function fetchPolymarketPositionValue(params: PolymarketPositionValueParams): Promise<PolymarketPositionValue[]>;
461
+ declare function fetchPolymarketPublicProfile(params: {
462
+ address: string;
463
+ environment?: PolymarketEnvironment;
464
+ }): Promise<PolymarketPublicProfile | null>;
465
+
466
+ interface PolymarketBootstrapContracts {
467
+ usdc: `0x${string}`;
468
+ ctf: `0x${string}`;
469
+ negRiskAdapter: `0x${string}`;
470
+ safeFactory: `0x${string}`;
471
+ safeMultisend: `0x${string}`;
472
+ relayerUrl: string;
473
+ bridgeUrl: string;
474
+ }
475
+ interface PolymarketBootstrapTransaction {
476
+ to: `0x${string}`;
477
+ data: `0x${string}`;
478
+ value: string;
479
+ description: string;
480
+ }
481
+ interface PolymarketDepositAddressSet {
482
+ evm?: string | null;
483
+ svm?: string | null;
484
+ btc?: string | null;
485
+ sol?: string | null;
486
+ [key: string]: unknown;
487
+ }
488
+ interface PolymarketDepositAddressesResponse {
489
+ address?: PolymarketDepositAddressSet | null;
490
+ note?: string | null;
491
+ [key: string]: unknown;
492
+ }
493
+ interface PolymarketApprovalState {
494
+ funder: `0x${string}`;
495
+ usdcAllowance: bigint;
496
+ usdcApproved: boolean;
497
+ ctfExchangeApproved: boolean;
498
+ negRiskExchangeApproved: boolean;
499
+ approvalsReady: boolean;
500
+ }
501
+ declare function resolvePolymarketBootstrapContracts(environment: PolymarketEnvironment): PolymarketBootstrapContracts;
502
+ declare function buildPolymarketUsdcApprovalTransaction(args?: {
503
+ environment?: PolymarketEnvironment;
504
+ amount?: bigint;
505
+ }): PolymarketBootstrapTransaction;
506
+ declare function buildPolymarketOutcomeTokenApprovalTransactions(args?: {
507
+ environment?: PolymarketEnvironment;
508
+ includeNegRisk?: boolean;
509
+ }): PolymarketBootstrapTransaction[];
510
+ declare function buildPolymarketApprovalTransactions(args?: {
511
+ environment?: PolymarketEnvironment;
512
+ amount?: bigint;
513
+ includeNegRisk?: boolean;
514
+ }): PolymarketBootstrapTransaction[];
515
+ declare function fetchPolymarketApprovalState(args: {
516
+ publicClient: Pick<PublicClient, "readContract">;
517
+ funder: `0x${string}`;
518
+ environment?: PolymarketEnvironment;
519
+ includeNegRisk?: boolean;
520
+ }): Promise<PolymarketApprovalState>;
521
+ declare function fetchPolymarketDepositAddresses(args: {
522
+ address: string;
523
+ environment?: PolymarketEnvironment;
524
+ }): Promise<PolymarketDepositAddressesResponse>;
525
+ declare function decodePolymarketBootstrapTransaction(transaction: PolymarketBootstrapTransaction): {
526
+ to: `0x${string}`;
527
+ functionName: string;
528
+ args: readonly unknown[];
529
+ };
318
530
 
319
- export { POLYMARKET_CHAIN_ID, POLYMARKET_CLOB_AUTH_DOMAIN, POLYMARKET_CLOB_DOMAIN, POLYMARKET_ENDPOINTS, POLYMARKET_EXCHANGE_ADDRESSES, type PolymarketApiCredentials, PolymarketApiError, type PolymarketApiKeyResponse, PolymarketAuthError, type PolymarketEnvironment, PolymarketExchangeClient, PolymarketInfoClient, type PolymarketMarket, type PolymarketOrderIntent, type PolymarketOrderType, type PolymarketOrderbook, type PolymarketPlaceOrderResponse, type PolymarketPriceHistoryPoint, type PolymarketSide, type PolymarketSignatureType, type PolymarketSignedOrderPayload, buildHmacSignature, buildL1Headers, buildL2Headers, buildPolymarketOrderAmounts, buildSignedOrderPayload, cancelAllPolymarketOrders, cancelMarketPolymarketOrders, cancelPolymarketOrder, cancelPolymarketOrders, createPolymarketApiKey, derivePolymarketApiKey, fetchPolymarketMarket, fetchPolymarketMarkets, fetchPolymarketMidpoint, fetchPolymarketOrderbook, fetchPolymarketPrice, fetchPolymarketPriceHistory, normalizeNumberArrayish, normalizeStringArrayish, placePolymarketOrder, resolveExchangeAddress, resolvePolymarketBaseUrl };
531
+ export { POLYMARKET_CHAIN_ID, POLYMARKET_CLOB_AUTH_DOMAIN, POLYMARKET_CLOB_DOMAIN, POLYMARKET_ENDPOINTS, POLYMARKET_EXCHANGE_ADDRESSES, type PolymarketActivityType, type PolymarketApiCredentials, PolymarketApiError, type PolymarketApiKeyResponse, type PolymarketApprovalState, PolymarketAuthError, type PolymarketBootstrapContracts, type PolymarketBootstrapTransaction, type PolymarketClosedPosition, type PolymarketClosedPositionParams, type PolymarketDepositAddressSet, type PolymarketDepositAddressesResponse, type PolymarketEnvironment, PolymarketExchangeClient, PolymarketInfoClient, type PolymarketMarket, type PolymarketOrderIntent, type PolymarketOrderType, type PolymarketOrderbook, type PolymarketPlaceOrderResponse, type PolymarketPositionValue, type PolymarketPositionValueParams, type PolymarketPriceHistoryPoint, type PolymarketPublicProfile, type PolymarketPublicProfileUser, type PolymarketSide, type PolymarketSignatureType, type PolymarketSignedOrderPayload, type PolymarketUserActivity, type PolymarketUserActivityParams, type PolymarketUserPosition, type PolymarketUserPositionParams, buildHmacSignature, buildL1Headers, buildL2Headers, buildPolymarketApprovalTransactions, buildPolymarketOrderAmounts, buildPolymarketOutcomeTokenApprovalTransactions, buildPolymarketUsdcApprovalTransaction, buildSignedOrderPayload, cancelAllPolymarketOrders, cancelMarketPolymarketOrders, cancelPolymarketOrder, cancelPolymarketOrders, createOrDerivePolymarketApiKey, createPolymarketApiKey, decodePolymarketBootstrapTransaction, derivePolymarketApiKey, fetchPolymarketActivity, fetchPolymarketApprovalState, fetchPolymarketClosedPositions, fetchPolymarketDepositAddresses, fetchPolymarketMarket, fetchPolymarketMarkets, fetchPolymarketMidpoint, fetchPolymarketOrderbook, fetchPolymarketPositionValue, fetchPolymarketPositions, fetchPolymarketPrice, fetchPolymarketPriceHistory, fetchPolymarketPublicProfile, normalizeNumberArrayish, normalizeStringArrayish, placePolymarketOrder, resolveExchangeAddress, resolvePolymarketBaseUrl, resolvePolymarketBootstrapContracts };