@polymarket/client 0.4.0 → 0.5.0
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/actions/index.d.ts +4 -4
- package/dist/actions/index.js +1 -1
- package/dist/chunk-E5XS4GYG.js +2 -0
- package/dist/{chunk-KZISI26J.js.map → chunk-E5XS4GYG.js.map} +1 -1
- package/dist/chunk-MIRUWWDK.js +6 -0
- package/dist/chunk-MIRUWWDK.js.map +1 -0
- package/dist/chunk-WDPLMZVQ.js +3 -0
- package/dist/chunk-WDPLMZVQ.js.map +1 -0
- package/dist/ethers-v5.d.ts +1 -1
- package/dist/ethers-v5.js +1 -1
- package/dist/ethers-v5.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/node.js +1 -1
- package/dist/privy.js +1 -1
- package/dist/{sports-CT3xKd9T.d.ts → sports-CM15YKJi.d.ts} +1 -1
- package/dist/{types-DcsPnLma.d.ts → types-BBaRrND2.d.ts} +143 -43
- package/dist/viem.d.ts +1 -1
- package/dist/viem.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-4LDMO37Q.js +0 -6
- package/dist/chunk-4LDMO37Q.js.map +0 -1
- package/dist/chunk-HFDKKOAD.js +0 -3
- package/dist/chunk-HFDKKOAD.js.map +0 -1
- package/dist/chunk-KZISI26J.js +0 -2
package/dist/node.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {e}from'./chunk-
|
|
1
|
+
import {e}from'./chunk-E5XS4GYG.js';import g from'process';import {invariant}from'@polymarket/types';async function u(t,e,r,i,n){let s=`${e}${r}${i}`;n!==void 0&&(s+=n);let y=await globalThis.crypto.subtle.importKey("raw",l(t),{name:"HMAC",hash:"SHA-256"},false,["sign"]),c=await globalThis.crypto.subtle.sign("HMAC",y,new TextEncoder().encode(s));return f(d(c))}function l(t){let e=t.replace(/-/g,"+").replace(/_/g,"/").replace(/[^A-Za-z0-9+/=]/g,""),r=atob(e),i=new Uint8Array(r.length);for(let n=0;n<r.length;n+=1)i[n]=r.charCodeAt(n);return i.buffer}function d(t){let e=new Uint8Array(t),r="";for(let i of e)r+=String.fromCharCode(i);return btoa(r)}function f(t){return t.replace(/\+/g,"-").replace(/\//g,"_")}invariant(g.release.name==="node","The @polymarket/client/node entrypoint requires a Node.js runtime.");invariant(typeof window>"u"&&typeof document>"u","The @polymarket/client/node entrypoint cannot be imported in a browser-like runtime.");function K(t){return new o(t)}var o=class{#e;constructor(e){this.#e=e;}get isBuilderKey(){return true}get supportGasless(){return true}async authorize(e){return this.#r(e)}async#r(e$1){try{let r=Math.floor(Date.now()/1e3);return {POLY_BUILDER_API_KEY:this.#e.key,POLY_BUILDER_PASSPHRASE:this.#e.passphrase,POLY_BUILDER_SIGNATURE:await u(this.#e.secret,r,e$1.method,e$1.path,e$1.body),POLY_BUILDER_TIMESTAMP:`${r}`}}catch(r){throw e.fromError(r,"Could not sign the builder-authenticated request")}}};
|
|
2
2
|
export{K as builderApiKey};//# sourceMappingURL=node.js.map
|
|
3
3
|
//# sourceMappingURL=node.js.map
|
package/dist/privy.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {e as e$1,d,c,b as b$1,a}from'./chunk-
|
|
1
|
+
import {e as e$1,d,c,b as b$1,a}from'./chunk-E5XS4GYG.js';import h from'process';import {invariant,expectEvmAddress,expectTxHash,expectEvmSignature,never}from'@polymarket/types';import {Hex}from'ox';import {createPublicClient,http,WaitForTransactionReceiptTimeoutError}from'viem';import {waitForTransactionReceipt}from'viem/actions';import*as E from'viem/chains';invariant(h.release.name==="node","The @polymarket/client/privy entrypoint requires a Node.js runtime.");invariant(typeof window>"u"&&typeof document>"u","The @polymarket/client/privy entrypoint cannot be imported in a browser-like runtime.");var P=Object.values(E);function D(r){return {getAddress(){return b(r)},signTypedData(t){return A(r,t)},signMessage(t){return H(r,t)},async sendTransaction(t){return new o(await I(r,t),t.chainId)}}}async function b(r){try{let t=await r.privy.wallets().get(r.walletId);return expectEvmAddress(t.address)}catch(t){throw e$1.fromError(t,"Could not resolve signer address")}}async function I(r,t){try{let n=await r.privy.wallets().ethereum().sendTransaction(r.walletId,{authorization_context:r.authorizationContext,caip2:`eip155:${t.chainId}`,params:{transaction:{chain_id:t.chainId,data:t.data,to:t.to,value:t.value?.toString()}}});return expectTxHash(n.hash)}catch(n){s(n);}}async function A(r,t){try{let n=await r.privy.wallets().ethereum().signTypedData(r.walletId,{authorization_context:r.authorizationContext,params:{typed_data:{domain:e(t.domain),message:e(t.message),primary_type:t.primaryType,types:t.types}}});return expectEvmSignature(n.signature)}catch(n){s(n);}}async function H(r,t){try{let n=await r.privy.wallets().ethereum().signMessage(r.walletId,{authorization_context:r.authorizationContext,message:Hex.toBytes(t)});return expectEvmSignature(n.signature)}catch(n){s(n);}}function e(r){return typeof r=="bigint"?`${r}`:Array.isArray(r)?r.map(t=>e(t)):typeof r=="object"&&r!==null?Object.fromEntries(Object.entries(r).flatMap(([t,n])=>n===void 0?[]:[[t,e(n)]])):r}function s(r){throw i(r)?new d("User rejected the signing request",{cause:r}):e$1.fromError(r)}function i(r,t=new Set){if(t.has(r)||r===null||typeof r!="object")return false;t.add(r);let n=r;return n.code===4001||n.code==="ACTION_REJECTED"||n.name==="APIUserAbortError"||i(n.error,t)||i(n.cause,t)}var o=class{transactionId=null;#r;#t;constructor(t,n){this.#r=n,this.#t=t;}get transactionHash(){return this.#t}async wait(){try{let t=await waitForTransactionReceipt(createPublicClient({chain:S(this.#r),transport:http()}),{hash:this.#t}),n=expectTxHash(t.transactionHash);if(this.#t=n,t.status==="reverted")throw new c(`Transaction ${n} reverted`);return {transactionHash:n,transactionId:null}}catch(t){throw t instanceof WaitForTransactionReceiptTimeoutError?new b$1(`Timed out waiting for transaction ${this.#t} to settle`,{cause:t}):a.fromError(t)}}};function S(r){let t=P.find(n=>n.id===r);if(t!==void 0)return t;never(`Unsupported chain ID for direct Privy transaction wait: ${r}`);}export{D as signerFrom};//# sourceMappingURL=privy.js.map
|
|
2
2
|
//# sourceMappingURL=privy.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OrderResponse } from '@polymarket/bindings/clob';
|
|
2
|
-
import {
|
|
2
|
+
import { bT as RateLimitError, bW as RequestRejectedError, cF as SigningError, cN as TransportError, cQ as UnexpectedResponseError, U as UserInputError, aC as InsufficientLiquidityError, k as BaseSecureClient, fk as PrepareLimitOrderRequest, eZ as OrderWorkflow, eY as OrderPostingWorkflow, fm as PrepareMarketOrderRequest, s as CancelledSigningError, bJ as PostOrderError, cI as TimeoutError, cJ as TransactionFailedError, fY as SignedOrder, B as BaseClient } from './types-BBaRrND2.js';
|
|
3
3
|
import { SportsMarketTypesResponse, SportsMetadata } from '@polymarket/bindings/gamma';
|
|
4
4
|
|
|
5
5
|
type PrepareMarketOrderError = InsufficientLiquidityError | RateLimitError | RequestRejectedError | SigningError | TransportError | UnexpectedResponseError | UserInputError;
|
|
@@ -10,7 +10,7 @@ import * as _polymarket_bindings_data from '@polymarket/bindings/data';
|
|
|
10
10
|
import { Activity, ComboActivity, Trade, Value, Traded, ClosedPosition, ComboPosition, Position, MetaMarketPosition, LeaderboardEntry, BuilderVolumeEntry, TraderLeaderboardEntry, LiveVolume, OpenInterest, MetaHolder } from '@polymarket/bindings/data';
|
|
11
11
|
import * as _polymarket_bindings_combos from '@polymarket/bindings/combos';
|
|
12
12
|
import { ComboMarket, RfqQuoteRequest, RfqRequestedSize, RfqSide, RfqQuoteAck, RfqConfirmationRequest, RfqConfirmationAck as RfqConfirmationAck$1, RfqExecutionUpdate, RfqTrade, RfqQuoteCancelAck, RfqErrorCode, RfqId, RfqQuoteId, CollateralReturnPlanResponse } from '@polymarket/bindings/combos';
|
|
13
|
-
import { PerpsInstrument, PerpsTicker, PerpsBook, PerpsCandle, PerpsFundingRate, PerpsPublicTrade, PerpsFeeScheduleEntry, PerpsWithdrawalId, PerpsSortDirection, PerpsDepositStatus, PerpsWithdrawalStatus, PerpsPnlInterval, PerpsDecimalInput, PerpsTimeInForce, PerpsCredentials, PerpsBalance, PerpsPortfolio, PerpsAccountStats, PerpsAccountConfig,
|
|
13
|
+
import { PerpsInstrument, PerpsTicker, PerpsBook, PerpsCandle, PerpsFundingRate, PerpsPublicTrade, PerpsFeeScheduleEntry, PerpsWithdrawalId, PerpsSortDirection, PerpsDepositStatus, PerpsWithdrawalStatus, PerpsPnlInterval, PerpsDecimalInput, PerpsTimeInForce, PerpsOrder, PerpsOrderId, PerpsCredentials, PerpsBalance, PerpsPortfolio, PerpsAccountStats, PerpsAccountConfig, PerpsAutoCancelStatus, PerpsAccountFill, PerpsAccountFundingPayment, PerpsDeposit, PerpsWithdrawal, PerpsEquityPoint, PerpsPnlPoint, PerpsNotificationEntry, PerpsPostOrderAck, PerpsCancelOrderResult, PerpsUpdateLeverageResult, PerpsInstrumentCategory, PerpsKlineInterval } from '@polymarket/bindings/perps';
|
|
14
14
|
import { PerpsSessionEvent, CommentsEvent, CryptoPricesTopic, CryptoPricesChainlinkTwapTopic, CryptoPricesChainlinkTwapWindowSeconds, EquityPricesTopic, EquityPricesEvent, MarketEvent, StandardMarketEvent, CryptoPricesChainlinkTwapThirtyEvent, CryptoPricesChainlinkTwapSixtyEvent, CryptoPricesChainlinkTwapEvent, UserEvent, SportsEvent, CryptoPricesBinanceEvent, CryptoPricesChainlinkEvent, PerpsTradeEvent, PerpsBboEvent, PerpsBookEvent, PerpsCandleEvent, PerpsTickerEvent, PerpsStatisticEvent, CryptoPricesEvent, PerpsMarketDataEvent } from '@polymarket/bindings/subscriptions';
|
|
15
15
|
import { Hex } from 'ox';
|
|
16
16
|
|
|
@@ -159,6 +159,18 @@ declare class InsufficientLiquidityError extends PolymarketError {
|
|
|
159
159
|
name: "InsufficientLiquidityError";
|
|
160
160
|
constructor(message: string, options?: ErrorOptions);
|
|
161
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Error thrown when arming auto-cancel is rejected because the account has
|
|
164
|
+
* reached its daily auto-cancel trigger limit. Arming is rejected until the
|
|
165
|
+
* daily counter resets at the next UTC midnight; clearing an existing
|
|
166
|
+
* schedule is always allowed.
|
|
167
|
+
*
|
|
168
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
169
|
+
*/
|
|
170
|
+
declare class AutoCancelDailyLimitError extends PolymarketError {
|
|
171
|
+
name: "AutoCancelDailyLimitError";
|
|
172
|
+
constructor(message: string, options?: ErrorOptions);
|
|
173
|
+
}
|
|
162
174
|
/**
|
|
163
175
|
* Error thrown when the SDK cannot produce a required signature or
|
|
164
176
|
* authentication payload.
|
|
@@ -6554,7 +6566,7 @@ type PlacePerpsOrderRequest = {
|
|
|
6554
6566
|
postOnly?: boolean;
|
|
6555
6567
|
/** Whether the order may only reduce or close an existing position. */
|
|
6556
6568
|
reduceOnly?: boolean;
|
|
6557
|
-
/** Optional caller-supplied idempotency identifier. */
|
|
6569
|
+
/** Optional caller-supplied idempotency identifier. Generated when omitted. */
|
|
6558
6570
|
clientOrderId?: string;
|
|
6559
6571
|
/** Optional command expiration timestamp in milliseconds. */
|
|
6560
6572
|
expiresAt?: number;
|
|
@@ -6574,7 +6586,7 @@ type PlacePerpsOrderRequest = {
|
|
|
6574
6586
|
postOnly?: never;
|
|
6575
6587
|
/** Whether the order may only reduce or close an existing position. */
|
|
6576
6588
|
reduceOnly?: boolean;
|
|
6577
|
-
/** Optional caller-supplied idempotency identifier. */
|
|
6589
|
+
/** Optional caller-supplied idempotency identifier. Generated when omitted. */
|
|
6578
6590
|
clientOrderId?: string;
|
|
6579
6591
|
/** Optional command expiration timestamp in milliseconds. */
|
|
6580
6592
|
expiresAt?: number;
|
|
@@ -6594,7 +6606,7 @@ type PlacePerpsOrderRequest = {
|
|
|
6594
6606
|
postOnly?: never;
|
|
6595
6607
|
/** Whether the order may only reduce or close an existing position. */
|
|
6596
6608
|
reduceOnly?: boolean;
|
|
6597
|
-
/** Optional caller-supplied idempotency identifier. */
|
|
6609
|
+
/** Optional caller-supplied idempotency identifier. Generated when omitted. */
|
|
6598
6610
|
clientOrderId?: string;
|
|
6599
6611
|
/** Optional command expiration timestamp in milliseconds. */
|
|
6600
6612
|
expiresAt?: number;
|
|
@@ -6619,7 +6631,7 @@ type PlacePerpsOrderWithTpSlRequest = {
|
|
|
6619
6631
|
postOnly?: boolean;
|
|
6620
6632
|
/** Whether the order may only reduce or close an existing position. */
|
|
6621
6633
|
reduceOnly?: boolean;
|
|
6622
|
-
/** Optional caller-supplied idempotency identifier. */
|
|
6634
|
+
/** Optional caller-supplied idempotency identifier. Generated when omitted. */
|
|
6623
6635
|
clientOrderId?: string;
|
|
6624
6636
|
/** Optional command expiration timestamp in milliseconds. */
|
|
6625
6637
|
expiresAt?: number;
|
|
@@ -6642,7 +6654,7 @@ type PlacePerpsOrderWithTpSlRequest = {
|
|
|
6642
6654
|
postOnly?: boolean;
|
|
6643
6655
|
/** Whether the order may only reduce or close an existing position. */
|
|
6644
6656
|
reduceOnly?: boolean;
|
|
6645
|
-
/** Optional caller-supplied idempotency identifier. */
|
|
6657
|
+
/** Optional caller-supplied idempotency identifier. Generated when omitted. */
|
|
6646
6658
|
clientOrderId?: string;
|
|
6647
6659
|
/** Optional command expiration timestamp in milliseconds. */
|
|
6648
6660
|
expiresAt?: number;
|
|
@@ -6664,7 +6676,7 @@ type PlacePerpsOrderWithTpSlRequest = {
|
|
|
6664
6676
|
postOnly?: never;
|
|
6665
6677
|
/** Whether the order may only reduce or close an existing position. */
|
|
6666
6678
|
reduceOnly?: boolean;
|
|
6667
|
-
/** Optional caller-supplied idempotency identifier. */
|
|
6679
|
+
/** Optional caller-supplied idempotency identifier. Generated when omitted. */
|
|
6668
6680
|
clientOrderId?: string;
|
|
6669
6681
|
/** Optional command expiration timestamp in milliseconds. */
|
|
6670
6682
|
expiresAt?: number;
|
|
@@ -6686,7 +6698,7 @@ type PlacePerpsOrderWithTpSlRequest = {
|
|
|
6686
6698
|
postOnly?: never;
|
|
6687
6699
|
/** Whether the order may only reduce or close an existing position. */
|
|
6688
6700
|
reduceOnly?: boolean;
|
|
6689
|
-
/** Optional caller-supplied idempotency identifier. */
|
|
6701
|
+
/** Optional caller-supplied idempotency identifier. Generated when omitted. */
|
|
6690
6702
|
clientOrderId?: string;
|
|
6691
6703
|
/** Optional command expiration timestamp in milliseconds. */
|
|
6692
6704
|
expiresAt?: number;
|
|
@@ -6708,7 +6720,7 @@ type PlacePerpsOrderWithTpSlRequest = {
|
|
|
6708
6720
|
postOnly?: never;
|
|
6709
6721
|
/** Whether the order may only reduce or close an existing position. */
|
|
6710
6722
|
reduceOnly?: boolean;
|
|
6711
|
-
/** Optional caller-supplied idempotency identifier. */
|
|
6723
|
+
/** Optional caller-supplied idempotency identifier. Generated when omitted. */
|
|
6712
6724
|
clientOrderId?: string;
|
|
6713
6725
|
/** Optional command expiration timestamp in milliseconds. */
|
|
6714
6726
|
expiresAt?: number;
|
|
@@ -6730,7 +6742,7 @@ type PlacePerpsOrderWithTpSlRequest = {
|
|
|
6730
6742
|
postOnly?: never;
|
|
6731
6743
|
/** Whether the order may only reduce or close an existing position. */
|
|
6732
6744
|
reduceOnly?: boolean;
|
|
6733
|
-
/** Optional caller-supplied idempotency identifier. */
|
|
6745
|
+
/** Optional caller-supplied idempotency identifier. Generated when omitted. */
|
|
6734
6746
|
clientOrderId?: string;
|
|
6735
6747
|
/** Optional command expiration timestamp in milliseconds. */
|
|
6736
6748
|
expiresAt?: number;
|
|
@@ -6739,6 +6751,31 @@ type PlacePerpsOrderWithTpSlRequest = {
|
|
|
6739
6751
|
/** Stop-loss trigger to place with the entry order. */
|
|
6740
6752
|
stopLoss: PerpsTpSlTrigger;
|
|
6741
6753
|
};
|
|
6754
|
+
/**
|
|
6755
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6756
|
+
*/
|
|
6757
|
+
type PerpsPlacedTpSlOrder = {
|
|
6758
|
+
orderId: PerpsOrderId;
|
|
6759
|
+
};
|
|
6760
|
+
/**
|
|
6761
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6762
|
+
*/
|
|
6763
|
+
type PerpsPlacedTpSlOrders = {
|
|
6764
|
+
takeProfit?: PerpsPlacedTpSlOrder;
|
|
6765
|
+
stopLoss?: PerpsPlacedTpSlOrder;
|
|
6766
|
+
};
|
|
6767
|
+
/**
|
|
6768
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6769
|
+
*/
|
|
6770
|
+
type PlacePerpsOrderResult = {
|
|
6771
|
+
order: PerpsOrder;
|
|
6772
|
+
};
|
|
6773
|
+
/**
|
|
6774
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6775
|
+
*/
|
|
6776
|
+
type PlacePerpsOrderWithTpSlResult = PlacePerpsOrderResult & {
|
|
6777
|
+
tpSl: PerpsPlacedTpSlOrders;
|
|
6778
|
+
};
|
|
6742
6779
|
/**
|
|
6743
6780
|
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6744
6781
|
*/
|
|
@@ -6761,6 +6798,12 @@ type PlacePerpsPositionTpSlRequest = {
|
|
|
6761
6798
|
/** Optional command expiration timestamp in milliseconds. */
|
|
6762
6799
|
expiresAt?: number;
|
|
6763
6800
|
};
|
|
6801
|
+
/**
|
|
6802
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6803
|
+
*/
|
|
6804
|
+
type PlacePerpsPositionTpSlResult = {
|
|
6805
|
+
tpSl: PerpsPlacedTpSlOrders;
|
|
6806
|
+
};
|
|
6764
6807
|
/**
|
|
6765
6808
|
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6766
6809
|
*/
|
|
@@ -6802,6 +6845,35 @@ type CancelAllPerpsOrdersRequest = {
|
|
|
6802
6845
|
/** Optional command expiration timestamp in milliseconds. */
|
|
6803
6846
|
expiresAt?: number;
|
|
6804
6847
|
};
|
|
6848
|
+
/**
|
|
6849
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6850
|
+
*/
|
|
6851
|
+
type ArmPerpsAutoCancelRequest = {
|
|
6852
|
+
/**
|
|
6853
|
+
* Unix timestamp in milliseconds at which all open orders are cancelled.
|
|
6854
|
+
* Must be at least five seconds in the future.
|
|
6855
|
+
*/
|
|
6856
|
+
cancelAt: number;
|
|
6857
|
+
/** Optional command expiration timestamp in milliseconds. */
|
|
6858
|
+
expiresAt?: number;
|
|
6859
|
+
};
|
|
6860
|
+
/**
|
|
6861
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6862
|
+
*/
|
|
6863
|
+
type ArmPerpsAutoCancelError = AutoCancelDailyLimitError | RateLimitError | RequestRejectedError | SigningError | TransportError | UnexpectedResponseError | UserInputError;
|
|
6864
|
+
/**
|
|
6865
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6866
|
+
*/
|
|
6867
|
+
declare const ArmPerpsAutoCancelError: {
|
|
6868
|
+
isError(error: unknown): error is SigningError | TransportError | UserInputError | UnexpectedResponseError | RequestRejectedError | RateLimitError | AutoCancelDailyLimitError;
|
|
6869
|
+
};
|
|
6870
|
+
/**
|
|
6871
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6872
|
+
*/
|
|
6873
|
+
type DisarmPerpsAutoCancelRequest = {
|
|
6874
|
+
/** Optional command expiration timestamp in milliseconds. */
|
|
6875
|
+
expiresAt?: number;
|
|
6876
|
+
};
|
|
6805
6877
|
/**
|
|
6806
6878
|
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6807
6879
|
*/
|
|
@@ -6867,38 +6939,7 @@ type PerpsSessionAccountError = RateLimitError | RequestRejectedError | Transpor
|
|
|
6867
6939
|
/**
|
|
6868
6940
|
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6869
6941
|
*/
|
|
6870
|
-
type PerpsSessionTradingError = RateLimitError | RequestRejectedError | SigningError | TransportError | UnexpectedResponseError | UserInputError;
|
|
6871
|
-
/**
|
|
6872
|
-
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6873
|
-
*/
|
|
6874
|
-
type PerpsPlacedTpSlOrder = {
|
|
6875
|
-
orderId: PerpsOrderId;
|
|
6876
|
-
};
|
|
6877
|
-
/**
|
|
6878
|
-
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6879
|
-
*/
|
|
6880
|
-
type PerpsPlacedTpSlOrders = {
|
|
6881
|
-
takeProfit?: PerpsPlacedTpSlOrder;
|
|
6882
|
-
stopLoss?: PerpsPlacedTpSlOrder;
|
|
6883
|
-
};
|
|
6884
|
-
/**
|
|
6885
|
-
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6886
|
-
*/
|
|
6887
|
-
type PlacePerpsOrderResult = {
|
|
6888
|
-
order: PerpsOrder;
|
|
6889
|
-
};
|
|
6890
|
-
/**
|
|
6891
|
-
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6892
|
-
*/
|
|
6893
|
-
type PlacePerpsOrderWithTpSlResult = PlacePerpsOrderResult & {
|
|
6894
|
-
tpSl: PerpsPlacedTpSlOrders;
|
|
6895
|
-
};
|
|
6896
|
-
/**
|
|
6897
|
-
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6898
|
-
*/
|
|
6899
|
-
type PlacePerpsPositionTpSlResult = {
|
|
6900
|
-
tpSl: PerpsPlacedTpSlOrders;
|
|
6901
|
-
};
|
|
6942
|
+
type PerpsSessionTradingError = RateLimitError | RequestRejectedError | SigningError | TimeoutError | TransportError | UnexpectedResponseError | UserInputError;
|
|
6902
6943
|
/**
|
|
6903
6944
|
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6904
6945
|
*/
|
|
@@ -6982,6 +7023,17 @@ declare class PerpsSession implements AsyncIterable<PerpsSessionEvent> {
|
|
|
6982
7023
|
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
6983
7024
|
*/
|
|
6984
7025
|
fetchAccountConfig(request?: FetchPerpsAccountConfigRequest): Promise<PerpsAccountConfig[]>;
|
|
7026
|
+
/**
|
|
7027
|
+
* Fetches the auto-cancel status for the authenticated account, including
|
|
7028
|
+
* the armed deadline, today's trigger count, the daily trigger limit, and
|
|
7029
|
+
* when the daily counter resets.
|
|
7030
|
+
*
|
|
7031
|
+
* @throws {@link PerpsSessionAccountError}
|
|
7032
|
+
* Thrown on failure.
|
|
7033
|
+
*
|
|
7034
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
7035
|
+
*/
|
|
7036
|
+
fetchAutoCancelStatus(): Promise<PerpsAutoCancelStatus>;
|
|
6985
7037
|
/**
|
|
6986
7038
|
* Fetches currently open Perps orders, optionally filtered by instrument.
|
|
6987
7039
|
*
|
|
@@ -7231,6 +7283,54 @@ declare class PerpsSession implements AsyncIterable<PerpsSessionEvent> {
|
|
|
7231
7283
|
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
7232
7284
|
*/
|
|
7233
7285
|
cancelAllOrders(request?: CancelAllPerpsOrdersRequest): Promise<void>;
|
|
7286
|
+
/**
|
|
7287
|
+
* Arms the auto-cancel switch that cancels all open Perps orders for the
|
|
7288
|
+
* authenticated account at `cancelAt`.
|
|
7289
|
+
*
|
|
7290
|
+
* @remarks
|
|
7291
|
+
* The switch is one-shot: once it fires and open orders are cancelled, the
|
|
7292
|
+
* schedule clears itself and orders placed afterwards are unprotected.
|
|
7293
|
+
* Re-arm periodically to keep protection active. Arming again replaces the
|
|
7294
|
+
* previous schedule, and `cancelAt` must be at least five seconds in the
|
|
7295
|
+
* future. Accounts may only trigger auto-cancel a limited number of times
|
|
7296
|
+
* per UTC day; use {@link PerpsSession.fetchAutoCancelStatus} to inspect the
|
|
7297
|
+
* limit, today's trigger count, and when the counter resets.
|
|
7298
|
+
*
|
|
7299
|
+
* @example
|
|
7300
|
+
* ```ts
|
|
7301
|
+
* // Keep a 60-second dead man's switch alive by re-arming every 20 seconds.
|
|
7302
|
+
* await session.armAutoCancel({ cancelAt: Date.now() + 60_000 });
|
|
7303
|
+
* const rearm = setInterval(() => {
|
|
7304
|
+
* // A missed re-arm is fail-safe: the previously armed switch still fires.
|
|
7305
|
+
* session.armAutoCancel({ cancelAt: Date.now() + 60_000 }).catch(() => {});
|
|
7306
|
+
* }, 20_000);
|
|
7307
|
+
*
|
|
7308
|
+
* // On graceful shutdown, stop re-arming and disarm the schedule.
|
|
7309
|
+
* clearInterval(rearm);
|
|
7310
|
+
* await session.disarmAutoCancel();
|
|
7311
|
+
* ```
|
|
7312
|
+
*
|
|
7313
|
+
* @throws {@link ArmPerpsAutoCancelError}
|
|
7314
|
+
* Thrown on failure, including `AutoCancelDailyLimitError` when the daily
|
|
7315
|
+
* trigger limit has been reached.
|
|
7316
|
+
*
|
|
7317
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
7318
|
+
*/
|
|
7319
|
+
armAutoCancel(request: ArmPerpsAutoCancelRequest): Promise<void>;
|
|
7320
|
+
/**
|
|
7321
|
+
* Disarms the auto-cancel schedule for the authenticated account without
|
|
7322
|
+
* triggering it.
|
|
7323
|
+
*
|
|
7324
|
+
* @remarks
|
|
7325
|
+
* Disarming is always allowed, even when the daily trigger limit has been
|
|
7326
|
+
* reached.
|
|
7327
|
+
*
|
|
7328
|
+
* @throws {@link PerpsSessionTradingError}
|
|
7329
|
+
* Thrown on failure.
|
|
7330
|
+
*
|
|
7331
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
7332
|
+
*/
|
|
7333
|
+
disarmAutoCancel(request?: DisarmPerpsAutoCancelRequest): Promise<void>;
|
|
7234
7334
|
/**
|
|
7235
7335
|
* Updates Perps leverage and margin mode for an instrument.
|
|
7236
7336
|
*
|
|
@@ -8778,4 +8878,4 @@ type Signer = {
|
|
|
8778
8878
|
sendTransaction(request: SignerTransactionRequest): Promise<TransactionHandle>;
|
|
8779
8879
|
};
|
|
8780
8880
|
|
|
8781
|
-
export { FetchMarketTagsError as $, type ApiKeyAuthorization as A, type BaseClient as B, CancelAllError as C, type CryptoPricesChainlinkTwapSubscription as D, type DataActions as E, DepositToPerpsError as F, type DepositToPerpsRequest as G, type DiscoveryActions as H, DownloadAccountingSnapshotError as I, DropNotificationsError as J, type EnvironmentConfig as K, type EnvironmentConfigFork as L, type EnvironmentContracts as M, EstimateMarketPriceError as N, ExecuteCollateralReturnPlanError as O, type ExecuteCollateralReturnPlanRequest as P, FetchClosedOnlyModeError as Q, FetchCommentsByIdError as R, type Signer as S, type TypedDataPayload as T, UserInputError as U, FetchEventError as V, FetchEventLiveVolumeError as W, FetchEventTagsError as X, FetchLastTradePriceError as Y, FetchLastTradePricesError as Z, FetchMarketError as _, type TypedData as a, type ListPerpsPnlHistoryRequest as a$, FetchMidpointError as a0, FetchMidpointsError as a1, FetchNotificationsError as a2, FetchOrderBookError as a3, FetchOrderBooksError as a4, FetchOrderError as a5, FetchOrderScoringError as a6, FetchOrdersScoringError as a7, type FetchPerpsAccountConfigRequest as a8, FetchPerpsBookError as a9, ListActivityError as aA, ListBuilderLeaderboardError as aB, ListBuilderTradesError as aC, ListBuilderVolumeError as aD, ListClosedPositionsError as aE, ListComboActivityError as aF, ListComboMarketsError as aG, ListComboPositionsError as aH, ListCommentsByUserAddressError as aI, ListCommentsError as aJ, ListCurrentRewardsError as aK, ListEventsError as aL, ListMarketHoldersError as aM, ListMarketPositionsError as aN, ListMarketRewardsError as aO, ListMarketsError as aP, ListOpenInterestError as aQ, ListOpenOrdersError as aR, ListPerpsCandlesError as aS, type ListPerpsCandlesRequest as aT, type ListPerpsDepositsRequest as aU, type ListPerpsEquityHistoryRequest as aV, type ListPerpsFillsRequest as aW, ListPerpsFundingHistoryError as aX, type ListPerpsFundingHistoryRequest as aY, type ListPerpsFundingPaymentsRequest as aZ, type ListPerpsNotificationsRequest as a_, type FetchPerpsBookRequest as aa, FetchPerpsFeesError as ab, FetchPerpsInstrumentsError as ac, type FetchPerpsInstrumentsRequest as ad, type FetchPerpsOpenOrdersRequest as ae, type FetchPerpsOrdersRequest as af, FetchPerpsTickerError as ag, type FetchPerpsTickerRequest as ah, FetchPerpsTickersError as ai, type FetchPerpsTickersRequest as aj, FetchPortfolioValueError as ak, FetchPriceError as al, FetchPriceHistoryError as am, FetchPricesError as an, FetchPublicProfileError as ao, FetchRelatedTagResourcesError as ap, FetchRelatedTagsError as aq, FetchRewardPercentagesError as ar, FetchSeriesError as as, FetchSpreadError as at, FetchSpreadsError as au, FetchTagError as av, FetchTotalEarningsForUserForDayError as aw, FetchTradedMarketCountError as ax, InsufficientLiquidityError as ay, ListAccountTradesError as az, type TransactionCall as b, type RfqCancelQuoteRejectedErrorOptions as b$, ListPerpsTradesError as b0, type ListPerpsTradesRequest as b1, type ListPerpsWithdrawalsRequest as b2, ListPositionsError as b3, ListSeriesError as b4, ListTagsError as b5, ListTeamsError as b6, ListTraderLeaderboardError as b7, ListTradesError as b8, ListUserEarningsAndMarketsConfigError as b9, type PlacePerpsOrderWithTpSlRequest as bA, type PlacePerpsOrderWithTpSlResult as bB, type PlacePerpsPositionTpSlRequest as bC, type PlacePerpsPositionTpSlResult as bD, PlanCollateralReturnError as bE, PostOrderError as bF, PostOrdersError as bG, type PostPerpsOrdersRequest as bH, type PublicAccountActions as bI, type PublicActions as bJ, type PublicClient as bK, type PublicClientOptions as bL, type PublicPerpsActions as bM, type PublicRewardsActions as bN, type PublicSubscriptionsActions as bO, RateLimitError as bP, type RateLimitErrorOptions as bQ, RedeemPositionsError as bR, RequestRejectedError as bS, type RequestRejectedErrorOptions as bT, type RestEndpoint as bU, type ResumePerpsSessionRequest as bV, RevokePerpsCredentialsError as bW, type RevokePerpsCredentialsRequest as bX, type RfqCancelQuoteAck as bY, RfqCancelQuoteError as bZ, RfqCancelQuoteRejectedError as b_, ListUserEarningsForDayError as ba, type MarkPerpsNotificationsReadRequest as bb, MergePositionsError as bc, OpenPerpsSessionError as bd, type OpenPerpsSessionRequest as be, OpenRfqSessionError as bf, type Page as bg, PageSizeSchema as bh, type Paginated as bi, type PerpsActions as bj, type PerpsBookDepth as bk, type PerpsEndpoints as bl, type PerpsOrderRequest as bm, type PerpsPlaceFokOrderRequest as bn, type PerpsPlaceGtcOrderRequest as bo, type PerpsPlaceIocOrderRequest as bp, type PerpsPlacedTpSlOrder as bq, type PerpsPlacedTpSlOrders as br, type PerpsPositionTpSlTrigger as bs, PerpsSession as bt, type PerpsSessionAccountError as bu, type PerpsSessionLifecycleError as bv, type PerpsSessionTradingError as bw, type PerpsTpSlTrigger as bx, type PlacePerpsOrderRequest as by, type PlacePerpsOrderResult as bz, type AccountIdentity as c, analyticsActions as c$, type RfqConfirmationAck as c0, RfqConfirmationError as c1, RfqConfirmationRejectedError as c2, type RfqConfirmationRequestEvent as c3, type RfqEvent as c4, RfqQuoteError as c5, type RfqQuoteReference as c6, RfqQuoteRejectedError as c7, type RfqQuoteRejectedErrorOptions as c8, type RfqQuoteRequestEvent as c9, type SignerTransactionRequest as cA, SigningError as cB, SplitPositionError as cC, SubscribeError as cD, TimeoutError as cE, TransactionFailedError as cF, type TransactionHandle as cG, type TransactionOutcome as cH, TransferErc20Error as cI, TransportError as cJ, type TypedDataDomain as cK, type TypedDataField as cL, UnexpectedResponseError as cM, UpdatePerpsLeverageError as cN, type UpdatePerpsLeverageRequest as cO, UpdatePerpsMarginError as cP, type UpdatePerpsMarginRequest as cQ, WaitForOrderFillSettlementError as cR, WaitForTransactionError as cS, type WalletDerivationConfig as cT, type WebSocketCloseCode as cU, type WebSocketEndpoint as cV, WebSocketKnownCloseCode as cW, WithdrawFromPerpsError as cX, type WithdrawFromPerpsRequest as cY, accountActions as cZ, allActions as c_, type RfqQuoteResponse as ca, type RfqQuoteSource as cb, type RfqSession as cc, type RfqTradeEvent as cd, SearchError as ce, SearchSort as cf, type SecureAccountActions as cg, type SecureActions as ch, type SecureClient as ci, type SecureClientOptions as cj, type SecureDownloadAccountingSnapshotRequest as ck, type SecureFetchPortfolioValueRequest as cl, type SecureFetchTradedMarketCountRequest as cm, type SecureListActivityRequest as cn, type SecureListClosedPositionsRequest as co, type SecureListComboActivityRequest as cp, type SecureListComboPositionsRequest as cq, type SecureListPositionsRequest as cr, type SecurePerpsActions as cs, type SecureRewardsActions as ct, type SecureRfqActions as cu, type SecureSubscriptionsActions as cv, type SecureTradingActions as cw, type SecureWalletActions as cx, SetupGaslessWalletError as cy, SetupTradingApprovalsError as cz, type AnalyticsActions as d, type FetchOrdersScoringRequest as d$, createPublicClient as d0, createSecureClient as d1, dataActions as d2, discoveryActions as d3, forkEnvironmentConfig as d4, makeErrorGuard as d5, perpsActions as d6, production as d7, rewardsActions as d8, rfqActions as d9, type EventForSubscriptionSpec as dA, type EventForSubscriptionSpecs as dB, FetchBalanceAllowanceError as dC, type FetchBalanceAllowanceRequest as dD, FetchBuilderFeeRatesError as dE, type FetchBuilderFeeRatesRequest as dF, type FetchCommentsByIdRequest as dG, type FetchEventLiveVolumeRequest as dH, type FetchEventRequest as dI, type FetchEventTagsRequest as dJ, FetchExecuteParamsError as dK, type FetchExecuteParamsRequest as dL, type FetchGaslessTransactionRequest as dM, type FetchLastTradePriceRequest as dN, type FetchLastTradePricesRequest as dO, FetchMarketInfoError as dP, type FetchMarketInfoRequest as dQ, type FetchMarketRequest as dR, type FetchMarketTagsRequest as dS, type FetchMidpointRequest as dT, type FetchMidpointsRequest as dU, FetchNegRiskError as dV, type FetchNegRiskRequest as dW, type FetchOrderBookRequest as dX, type FetchOrderBooksRequest as dY, type FetchOrderRequest as dZ, type FetchOrderScoringRequest as d_, subscriptionsActions as da, tradingActions as db, walletActions as dc, type CancelMarketOrdersRequest as dd, type CancelOrderRequest as de, type CancelOrdersRequest as df, type CollateralReturnExecutionWorkflow as dg, type CommentsEventType as dh, type CommentsSubscription as di, type CryptoPricesEventType as dj, type CryptoPricesSubscription as dk, DeployDepositWalletError as dl, type DownloadAccountingSnapshotRequest as dm, type DropNotificationsRequest as dn, type EquityPricesEventType as dp, type EquityPricesSubscription as dq, type Erc1155ApprovalForAllWorkflow as dr, type Erc1155ApprovalForAllWorkflowRequest as ds, type Erc20ApprovalWorkflow as dt, type Erc20ApprovalWorkflowRequest as du, type Erc20TransferWorkflow as dv, type Erc20TransferWorkflowRequest as dw, type EstimateMarketBuyPriceRequest as dx, type EstimateMarketPriceRequest as dy, type EstimateMarketSellPriceRequest as dz, ApproveErc1155ForAllError as e, type PerpsDepositWorkflowRequest as e$, type FetchPortfolioValueRequest as e0, type FetchPriceHistoryRequest as e1, type FetchPriceRequest as e2, type FetchPricesRequest as e3, type FetchPublicProfileRequest as e4, type FetchRelatedTagResourcesRequest as e5, type FetchRelatedTagsRequest as e6, type FetchSeriesRequest as e7, type FetchSpreadRequest as e8, type FetchSpreadsRequest as e9, type ListMarketPositionsRequest as eA, type ListMarketRewardsRequest as eB, type ListMarketsRequest as eC, type ListOpenInterestRequest as eD, type ListOpenOrdersRequest as eE, type ListPositionsRequest as eF, type ListSeriesRequest as eG, type ListTagsRequest as eH, type ListTeamsRequest as eI, type ListTraderLeaderboardRequest as eJ, type ListTradesRequest as eK, type ListUserEarningsAndMarketsConfigRequest as eL, type ListUserEarningsForDayRequest as eM, type MarketEventType as eN, type MarketSubscription as eO, MergeComboPositionError as eP, MergeMarketPositionError as eQ, type MergePositionsWorkflow as eR, type MergePositionsWorkflowRequest as eS, type OrderDraft as eT, type OrderPostingWorkflow as eU, type OrderWorkflow as eV, type OrderWorkflowRequest as eW, type PerpsBboSubscription as eX, type PerpsBookSubscription as eY, type PerpsCandlesSubscription as eZ, type PerpsDepositWorkflow as e_, type FetchTagRequest as ea, FetchTickSizeError as eb, type FetchTickSizeRequest as ec, type FetchTotalEarningsForUserForDayRequest as ed, type FetchTradedMarketCountRequest as ee, GaslessTransactionMetadataSchema as ef, type GaslessWorkflow as eg, type GaslessWorkflowRequest as eh, IsWalletDeployedError as ei, type IsWalletDeployedRequest as ej, type ListAccountTradesRequest as ek, type ListActivityRequest as el, type ListBuilderLeaderboardRequest as em, type ListBuilderTradesRequest as en, type ListBuilderVolumeRequest as eo, type ListClosedPositionsRequest as ep, type ListComboActivityRequest as eq, type ListComboMarketsRequest as er, type ListComboPositionsRequest as es, type ListCommentsByUserAddressRequest as et, type ListCommentsRequest as eu, type ListCurrentRewardsRequest as ev, type ListEventsRequest as ew, ListMarketClarificationsError as ex, type ListMarketClarificationsRequest as ey, type ListMarketHoldersRequest as ez, ApproveErc20Error as f, type SubscriptionHandle as f$, type PerpsMarketDataEventType as f0, type PerpsMarketDataSubscription as f1, type PerpsStatisticsSubscription as f2, type PerpsStreamingCandleInterval as f3, type PerpsTickersSubscription as f4, type PerpsTradesSubscription as f5, type PostOrdersRequest as f6, PrepareCollateralReturnExecutionError as f7, PrepareErc1155ApprovalForAllError as f8, type PrepareErc1155ApprovalForAllRequest as f9, type PrepareSplitComboPositionRequest as fA, PrepareSplitMarketPositionError as fB, type PrepareSplitMarketPositionRequest as fC, PrepareSplitPositionError as fD, type PrepareSplitPositionRequest as fE, PrepareTradingApprovalsError as fF, type PublicRealtimeEvent as fG, type PublicRealtimeTopic as fH, type PublicSubscriptionSpec as fI, type RedeemPositionsWorkflow as fJ, type RedeemPositionsWorkflowRequest as fK, ResolveConditionByTokenError as fL, type ResolveConditionByTokenRequest as fM, type RfqConfirmationRejectedErrorOptions as fN, type RfqExecutionUpdateEvent as fO, type SearchRequest as fP, type SearchResults as fQ, type SecureRealtimeEvent as fR, type SecureRealtimeTopic as fS, type SecureSubscriptionSpec as fT, type SignedOrder as fU, SplitComboPositionError as fV, SplitMarketPositionError as fW, type SplitPositionWorkflow as fX, type SplitPositionWorkflowRequest as fY, type SportsEventType as fZ, type SportsSubscription as f_, PrepareErc20ApprovalError as fa, type PrepareErc20ApprovalRequest as fb, PrepareErc20TransferError as fc, type PrepareErc20TransferRequest as fd, PrepareGaslessTransactionError as fe, type PrepareGaslessTransactionRequest as ff, type PrepareLimitOrderRequest as fg, type PrepareMarketBuyOrderRequest as fh, type PrepareMarketOrderRequest as fi, type PrepareMarketSellOrderRequest as fj, PrepareMergeComboPositionError as fk, type PrepareMergeComboPositionRequest as fl, PrepareMergeMarketPositionError as fm, type PrepareMergeMarketPositionRequest as fn, PrepareMergePositionsError as fo, type PrepareMergePositionsRequest as fp, PreparePerpsDepositError as fq, PrepareRedeemComboPositionError as fr, type PrepareRedeemComboPositionRequest as fs, type PrepareRedeemMarketPositionsByConditionIdRequest as ft, type PrepareRedeemMarketPositionsByMarketIdRequest as fu, PrepareRedeemMarketPositionsError as fv, type PrepareRedeemMarketPositionsRequest as fw, PrepareRedeemPositionsError as fx, type PrepareRedeemPositionsRequest as fy, PrepareSplitComboPositionError as fz, BasePublicClient as g, fetchTransaction as g$, type TradingApprovalsWorkflow as g0, type TradingApprovalsWorkflowRequest as g1, UpdateBalanceAllowanceError as g2, type UpdateBalanceAllowanceRequest as g3, type UserEventType as g4, type UserSubscription as g5, WaitForGaslessTransactionError as g6, type WaitForOrderFillSettlementRequest as g7, approveErc1155ForAll as g8, approveErc20 as g9, fetchNegRisk as gA, fetchNotifications as gB, fetchOrder as gC, fetchOrderBook as gD, fetchOrderBooks as gE, fetchOrderScoring as gF, fetchOrdersScoring as gG, fetchPerpsBook as gH, fetchPerpsFees as gI, fetchPerpsInstruments as gJ, fetchPerpsTicker as gK, fetchPerpsTickers as gL, fetchPortfolioValue as gM, fetchPrice as gN, fetchPriceHistory as gO, fetchPrices as gP, fetchPublicProfile as gQ, fetchRelatedTagResources as gR, fetchRelatedTags as gS, fetchRewardPercentages as gT, fetchSeries as gU, fetchSpread as gV, fetchSpreads as gW, fetchTag as gX, fetchTickSize as gY, fetchTotalEarningsForUserForDay as gZ, fetchTradedMarketCount as g_, cancelAll as ga, cancelMarketOrders as gb, cancelOrder as gc, cancelOrders as gd, deployDepositWallet as ge, depositToPerps as gf, downloadAccountingSnapshot as gg, dropNotifications as gh, estimateMarketPrice as gi, executeCollateralReturnPlan as gj, fetchBalanceAllowance as gk, fetchBuilderFeeRates as gl, fetchBuilderVolume as gm, fetchClosedOnlyMode as gn, fetchCommentsById as go, fetchEvent as gp, fetchEventLiveVolume as gq, fetchEventTags as gr, fetchExecuteParams as gs, fetchLastTradePrice as gt, fetchLastTradePrices as gu, fetchMarket as gv, fetchMarketInfo as gw, fetchMarketTags as gx, fetchMidpoint as gy, fetchMidpoints as gz, BaseSecureClient as h, subscribe as h$, isWalletDeployed as h0, listAccountTrades as h1, listActivity as h2, listBuilderLeaderboard as h3, listBuilderTrades as h4, listClosedPositions as h5, listComboActivity as h6, listComboMarkets as h7, listComboPositions as h8, listComments as h9, planCollateralReturn as hA, postOrder as hB, postOrders as hC, prepareCollateralReturnExecution as hD, prepareErc1155ApprovalForAll as hE, prepareErc20Approval as hF, prepareErc20Transfer as hG, prepareGaslessTransaction as hH, prepareMergeComboPosition as hI, prepareMergeMarketPosition as hJ, prepareMergePositions as hK, preparePerpsDeposit as hL, prepareRedeemComboPosition as hM, prepareRedeemMarketPositions as hN, prepareRedeemPositions as hO, prepareSplitComboPosition as hP, prepareSplitMarketPosition as hQ, prepareSplitPosition as hR, prepareTradingApprovals as hS, redeemPositions as hT, resolveConditionByToken as hU, revokePerpsCredentials as hV, search as hW, setupTradingApprovals as hX, splitComboPosition as hY, splitMarketPosition as hZ, splitPosition as h_, listCommentsByUserAddress as ha, listCurrentRewards as hb, listEvents as hc, listMarketClarifications as hd, listMarketHolders as he, listMarketPositions as hf, listMarketRewards as hg, listMarkets as hh, listOpenInterest as hi, listOpenOrders as hj, listPerpsCandles as hk, listPerpsFundingHistory as hl, listPerpsTrades as hm, listPositions as hn, listSeries as ho, listTags as hp, listTeams as hq, listTraderLeaderboard as hr, listTrades as hs, listUserEarningsAndMarketsConfig as ht, listUserEarningsForDay as hu, mergeComboPosition as hv, mergeMarketPosition as hw, mergePositions as hx, openPerpsSession as hy, openRfqSession as hz, type BeginAuthenticationRequest as i, transferErc20 as i0, updateBalanceAllowance as i1, waitForOrderFillSettlement as i2, withdrawFromPerps as i3, type CancelAllPerpsOrdersRequest as j, CancelMarketOrdersError as k, CancelOrderError as l, CancelOrdersError as m, type CancelPerpsOrderRequest as n, type CancelPerpsOrdersRequest as o, CancelledSigningError as p, type Client as q, type ClientActions as r, type ClientDecorator as s, type ClobEndpoints as t, ComboPositionSort as u, type CombosEndpoints as v, ConnectionLostError as w, type ConnectionLostErrorOptions as x, type CreatePerpsSessionRequest as y, CreateSecureClientError as z };
|
|
8881
|
+
export { FetchEventTagsError as $, type ApiKeyAuthorization as A, type BaseClient as B, CancelAllError as C, type ConnectionLostErrorOptions as D, type CreatePerpsSessionRequest as E, CreateSecureClientError as F, type CryptoPricesChainlinkTwapSubscription as G, type DataActions as H, DepositToPerpsError as I, type DepositToPerpsRequest as J, type DisarmPerpsAutoCancelRequest as K, type DiscoveryActions as L, DownloadAccountingSnapshotError as M, DropNotificationsError as N, type EnvironmentConfig as O, type EnvironmentConfigFork as P, type EnvironmentContracts as Q, EstimateMarketPriceError as R, type Signer as S, type TypedDataPayload as T, UserInputError as U, ExecuteCollateralReturnPlanError as V, type ExecuteCollateralReturnPlanRequest as W, FetchClosedOnlyModeError as X, FetchCommentsByIdError as Y, FetchEventError as Z, FetchEventLiveVolumeError as _, type TypedData as a, ListPerpsFundingHistoryError as a$, FetchLastTradePriceError as a0, FetchLastTradePricesError as a1, FetchMarketError as a2, FetchMarketTagsError as a3, FetchMidpointError as a4, FetchMidpointsError as a5, FetchNotificationsError as a6, FetchOrderBookError as a7, FetchOrderBooksError as a8, FetchOrderError as a9, FetchTotalEarningsForUserForDayError as aA, FetchTradedMarketCountError as aB, InsufficientLiquidityError as aC, ListAccountTradesError as aD, ListActivityError as aE, ListBuilderLeaderboardError as aF, ListBuilderTradesError as aG, ListBuilderVolumeError as aH, ListClosedPositionsError as aI, ListComboActivityError as aJ, ListComboMarketsError as aK, ListComboPositionsError as aL, ListCommentsByUserAddressError as aM, ListCommentsError as aN, ListCurrentRewardsError as aO, ListEventsError as aP, ListMarketHoldersError as aQ, ListMarketPositionsError as aR, ListMarketRewardsError as aS, ListMarketsError as aT, ListOpenInterestError as aU, ListOpenOrdersError as aV, ListPerpsCandlesError as aW, type ListPerpsCandlesRequest as aX, type ListPerpsDepositsRequest as aY, type ListPerpsEquityHistoryRequest as aZ, type ListPerpsFillsRequest as a_, FetchOrderScoringError as aa, FetchOrdersScoringError as ab, type FetchPerpsAccountConfigRequest as ac, FetchPerpsBookError as ad, type FetchPerpsBookRequest as ae, FetchPerpsFeesError as af, FetchPerpsInstrumentsError as ag, type FetchPerpsInstrumentsRequest as ah, type FetchPerpsOpenOrdersRequest as ai, type FetchPerpsOrdersRequest as aj, FetchPerpsTickerError as ak, type FetchPerpsTickerRequest as al, FetchPerpsTickersError as am, type FetchPerpsTickersRequest as an, FetchPortfolioValueError as ao, FetchPriceError as ap, FetchPriceHistoryError as aq, FetchPricesError as ar, FetchPublicProfileError as as, FetchRelatedTagResourcesError as at, FetchRelatedTagsError as au, FetchRewardPercentagesError as av, FetchSeriesError as aw, FetchSpreadError as ax, FetchSpreadsError as ay, FetchTagError as az, type TransactionCall as b, type RevokePerpsCredentialsRequest as b$, type ListPerpsFundingHistoryRequest as b0, type ListPerpsFundingPaymentsRequest as b1, type ListPerpsNotificationsRequest as b2, type ListPerpsPnlHistoryRequest as b3, ListPerpsTradesError as b4, type ListPerpsTradesRequest as b5, type ListPerpsWithdrawalsRequest as b6, ListPositionsError as b7, ListSeriesError as b8, ListTagsError as b9, type PerpsSessionTradingError as bA, type PerpsTpSlTrigger as bB, type PlacePerpsOrderRequest as bC, type PlacePerpsOrderResult as bD, type PlacePerpsOrderWithTpSlRequest as bE, type PlacePerpsOrderWithTpSlResult as bF, type PlacePerpsPositionTpSlRequest as bG, type PlacePerpsPositionTpSlResult as bH, PlanCollateralReturnError as bI, PostOrderError as bJ, PostOrdersError as bK, type PostPerpsOrdersRequest as bL, type PublicAccountActions as bM, type PublicActions as bN, type PublicClient as bO, type PublicClientOptions as bP, type PublicPerpsActions as bQ, type PublicRewardsActions as bR, type PublicSubscriptionsActions as bS, RateLimitError as bT, type RateLimitErrorOptions as bU, RedeemPositionsError as bV, RequestRejectedError as bW, type RequestRejectedErrorOptions as bX, type RestEndpoint as bY, type ResumePerpsSessionRequest as bZ, RevokePerpsCredentialsError as b_, ListTeamsError as ba, ListTraderLeaderboardError as bb, ListTradesError as bc, ListUserEarningsAndMarketsConfigError as bd, ListUserEarningsForDayError as be, type MarkPerpsNotificationsReadRequest as bf, MergePositionsError as bg, OpenPerpsSessionError as bh, type OpenPerpsSessionRequest as bi, OpenRfqSessionError as bj, type Page as bk, PageSizeSchema as bl, type Paginated as bm, type PerpsActions as bn, type PerpsBookDepth as bo, type PerpsEndpoints as bp, type PerpsOrderRequest as bq, type PerpsPlaceFokOrderRequest as br, type PerpsPlaceGtcOrderRequest as bs, type PerpsPlaceIocOrderRequest as bt, type PerpsPlacedTpSlOrder as bu, type PerpsPlacedTpSlOrders as bv, type PerpsPositionTpSlTrigger as bw, PerpsSession as bx, type PerpsSessionAccountError as by, type PerpsSessionLifecycleError as bz, type AccountIdentity as c, WithdrawFromPerpsError as c$, type RfqCancelQuoteAck as c0, RfqCancelQuoteError as c1, RfqCancelQuoteRejectedError as c2, type RfqCancelQuoteRejectedErrorOptions as c3, type RfqConfirmationAck as c4, RfqConfirmationError as c5, RfqConfirmationRejectedError as c6, type RfqConfirmationRequestEvent as c7, type RfqEvent as c8, RfqQuoteError as c9, type SecureTradingActions as cA, type SecureWalletActions as cB, SetupGaslessWalletError as cC, SetupTradingApprovalsError as cD, type SignerTransactionRequest as cE, SigningError as cF, SplitPositionError as cG, SubscribeError as cH, TimeoutError as cI, TransactionFailedError as cJ, type TransactionHandle as cK, type TransactionOutcome as cL, TransferErc20Error as cM, TransportError as cN, type TypedDataDomain as cO, type TypedDataField as cP, UnexpectedResponseError as cQ, UpdatePerpsLeverageError as cR, type UpdatePerpsLeverageRequest as cS, UpdatePerpsMarginError as cT, type UpdatePerpsMarginRequest as cU, WaitForOrderFillSettlementError as cV, WaitForTransactionError as cW, type WalletDerivationConfig as cX, type WebSocketCloseCode as cY, type WebSocketEndpoint as cZ, WebSocketKnownCloseCode as c_, type RfqQuoteReference as ca, RfqQuoteRejectedError as cb, type RfqQuoteRejectedErrorOptions as cc, type RfqQuoteRequestEvent as cd, type RfqQuoteResponse as ce, type RfqQuoteSource as cf, type RfqSession as cg, type RfqTradeEvent as ch, SearchError as ci, SearchSort as cj, type SecureAccountActions as ck, type SecureActions as cl, type SecureClient as cm, type SecureClientOptions as cn, type SecureDownloadAccountingSnapshotRequest as co, type SecureFetchPortfolioValueRequest as cp, type SecureFetchTradedMarketCountRequest as cq, type SecureListActivityRequest as cr, type SecureListClosedPositionsRequest as cs, type SecureListComboActivityRequest as ct, type SecureListComboPositionsRequest as cu, type SecureListPositionsRequest as cv, type SecurePerpsActions as cw, type SecureRewardsActions as cx, type SecureRfqActions as cy, type SecureSubscriptionsActions as cz, type AnalyticsActions as d, type FetchOrderBookRequest as d$, type WithdrawFromPerpsRequest as d0, accountActions as d1, allActions as d2, analyticsActions as d3, createPublicClient as d4, createSecureClient as d5, dataActions as d6, discoveryActions as d7, forkEnvironmentConfig as d8, makeErrorGuard as d9, type Erc20TransferWorkflowRequest as dA, type EstimateMarketBuyPriceRequest as dB, type EstimateMarketPriceRequest as dC, type EstimateMarketSellPriceRequest as dD, type EventForSubscriptionSpec as dE, type EventForSubscriptionSpecs as dF, FetchBalanceAllowanceError as dG, type FetchBalanceAllowanceRequest as dH, FetchBuilderFeeRatesError as dI, type FetchBuilderFeeRatesRequest as dJ, type FetchCommentsByIdRequest as dK, type FetchEventLiveVolumeRequest as dL, type FetchEventRequest as dM, type FetchEventTagsRequest as dN, FetchExecuteParamsError as dO, type FetchExecuteParamsRequest as dP, type FetchGaslessTransactionRequest as dQ, type FetchLastTradePriceRequest as dR, type FetchLastTradePricesRequest as dS, FetchMarketInfoError as dT, type FetchMarketInfoRequest as dU, type FetchMarketRequest as dV, type FetchMarketTagsRequest as dW, type FetchMidpointRequest as dX, type FetchMidpointsRequest as dY, FetchNegRiskError as dZ, type FetchNegRiskRequest as d_, perpsActions as da, production as db, rewardsActions as dc, rfqActions as dd, subscriptionsActions as de, tradingActions as df, walletActions as dg, type CancelMarketOrdersRequest as dh, type CancelOrderRequest as di, type CancelOrdersRequest as dj, type CollateralReturnExecutionWorkflow as dk, type CommentsEventType as dl, type CommentsSubscription as dm, type CryptoPricesEventType as dn, type CryptoPricesSubscription as dp, DeployDepositWalletError as dq, type DownloadAccountingSnapshotRequest as dr, type DropNotificationsRequest as ds, type EquityPricesEventType as dt, type EquityPricesSubscription as du, type Erc1155ApprovalForAllWorkflow as dv, type Erc1155ApprovalForAllWorkflowRequest as dw, type Erc20ApprovalWorkflow as dx, type Erc20ApprovalWorkflowRequest as dy, type Erc20TransferWorkflow as dz, ApproveErc1155ForAllError as e, type PerpsBboSubscription as e$, type FetchOrderBooksRequest as e0, type FetchOrderRequest as e1, type FetchOrderScoringRequest as e2, type FetchOrdersScoringRequest as e3, type FetchPortfolioValueRequest as e4, type FetchPriceHistoryRequest as e5, type FetchPriceRequest as e6, type FetchPricesRequest as e7, type FetchPublicProfileRequest as e8, type FetchRelatedTagResourcesRequest as e9, type ListEventsRequest as eA, ListMarketClarificationsError as eB, type ListMarketClarificationsRequest as eC, type ListMarketHoldersRequest as eD, type ListMarketPositionsRequest as eE, type ListMarketRewardsRequest as eF, type ListMarketsRequest as eG, type ListOpenInterestRequest as eH, type ListOpenOrdersRequest as eI, type ListPositionsRequest as eJ, type ListSeriesRequest as eK, type ListTagsRequest as eL, type ListTeamsRequest as eM, type ListTraderLeaderboardRequest as eN, type ListTradesRequest as eO, type ListUserEarningsAndMarketsConfigRequest as eP, type ListUserEarningsForDayRequest as eQ, type MarketEventType as eR, type MarketSubscription as eS, MergeComboPositionError as eT, MergeMarketPositionError as eU, type MergePositionsWorkflow as eV, type MergePositionsWorkflowRequest as eW, type OrderDraft as eX, type OrderPostingWorkflow as eY, type OrderWorkflow as eZ, type OrderWorkflowRequest as e_, type FetchRelatedTagsRequest as ea, type FetchSeriesRequest as eb, type FetchSpreadRequest as ec, type FetchSpreadsRequest as ed, type FetchTagRequest as ee, FetchTickSizeError as ef, type FetchTickSizeRequest as eg, type FetchTotalEarningsForUserForDayRequest as eh, type FetchTradedMarketCountRequest as ei, GaslessTransactionMetadataSchema as ej, type GaslessWorkflow as ek, type GaslessWorkflowRequest as el, IsWalletDeployedError as em, type IsWalletDeployedRequest as en, type ListAccountTradesRequest as eo, type ListActivityRequest as ep, type ListBuilderLeaderboardRequest as eq, type ListBuilderTradesRequest as er, type ListBuilderVolumeRequest as es, type ListClosedPositionsRequest as et, type ListComboActivityRequest as eu, type ListComboMarketsRequest as ev, type ListComboPositionsRequest as ew, type ListCommentsByUserAddressRequest as ex, type ListCommentsRequest as ey, type ListCurrentRewardsRequest as ez, ApproveErc20Error as f, type SplitPositionWorkflow as f$, type PerpsBookSubscription as f0, type PerpsCandlesSubscription as f1, type PerpsDepositWorkflow as f2, type PerpsDepositWorkflowRequest as f3, type PerpsMarketDataEventType as f4, type PerpsMarketDataSubscription as f5, type PerpsStatisticsSubscription as f6, type PerpsStreamingCandleInterval as f7, type PerpsTickersSubscription as f8, type PerpsTradesSubscription as f9, type PrepareRedeemMarketPositionsRequest as fA, PrepareRedeemPositionsError as fB, type PrepareRedeemPositionsRequest as fC, PrepareSplitComboPositionError as fD, type PrepareSplitComboPositionRequest as fE, PrepareSplitMarketPositionError as fF, type PrepareSplitMarketPositionRequest as fG, PrepareSplitPositionError as fH, type PrepareSplitPositionRequest as fI, PrepareTradingApprovalsError as fJ, type PublicRealtimeEvent as fK, type PublicRealtimeTopic as fL, type PublicSubscriptionSpec as fM, type RedeemPositionsWorkflow as fN, type RedeemPositionsWorkflowRequest as fO, ResolveConditionByTokenError as fP, type ResolveConditionByTokenRequest as fQ, type RfqConfirmationRejectedErrorOptions as fR, type RfqExecutionUpdateEvent as fS, type SearchRequest as fT, type SearchResults as fU, type SecureRealtimeEvent as fV, type SecureRealtimeTopic as fW, type SecureSubscriptionSpec as fX, type SignedOrder as fY, SplitComboPositionError as fZ, SplitMarketPositionError as f_, type PostOrdersRequest as fa, PrepareCollateralReturnExecutionError as fb, PrepareErc1155ApprovalForAllError as fc, type PrepareErc1155ApprovalForAllRequest as fd, PrepareErc20ApprovalError as fe, type PrepareErc20ApprovalRequest as ff, PrepareErc20TransferError as fg, type PrepareErc20TransferRequest as fh, PrepareGaslessTransactionError as fi, type PrepareGaslessTransactionRequest as fj, type PrepareLimitOrderRequest as fk, type PrepareMarketBuyOrderRequest as fl, type PrepareMarketOrderRequest as fm, type PrepareMarketSellOrderRequest as fn, PrepareMergeComboPositionError as fo, type PrepareMergeComboPositionRequest as fp, PrepareMergeMarketPositionError as fq, type PrepareMergeMarketPositionRequest as fr, PrepareMergePositionsError as fs, type PrepareMergePositionsRequest as ft, PreparePerpsDepositError as fu, PrepareRedeemComboPositionError as fv, type PrepareRedeemComboPositionRequest as fw, type PrepareRedeemMarketPositionsByConditionIdRequest as fx, type PrepareRedeemMarketPositionsByMarketIdRequest as fy, PrepareRedeemMarketPositionsError as fz, ArmPerpsAutoCancelError as g, fetchTag as g$, type SplitPositionWorkflowRequest as g0, type SportsEventType as g1, type SportsSubscription as g2, type SubscriptionHandle as g3, type TradingApprovalsWorkflow as g4, type TradingApprovalsWorkflowRequest as g5, UpdateBalanceAllowanceError as g6, type UpdateBalanceAllowanceRequest as g7, type UserEventType as g8, type UserSubscription as g9, fetchMarketInfo as gA, fetchMarketTags as gB, fetchMidpoint as gC, fetchMidpoints as gD, fetchNegRisk as gE, fetchNotifications as gF, fetchOrder as gG, fetchOrderBook as gH, fetchOrderBooks as gI, fetchOrderScoring as gJ, fetchOrdersScoring as gK, fetchPerpsBook as gL, fetchPerpsFees as gM, fetchPerpsInstruments as gN, fetchPerpsTicker as gO, fetchPerpsTickers as gP, fetchPortfolioValue as gQ, fetchPrice as gR, fetchPriceHistory as gS, fetchPrices as gT, fetchPublicProfile as gU, fetchRelatedTagResources as gV, fetchRelatedTags as gW, fetchRewardPercentages as gX, fetchSeries as gY, fetchSpread as gZ, fetchSpreads as g_, WaitForGaslessTransactionError as ga, type WaitForOrderFillSettlementRequest as gb, approveErc1155ForAll as gc, approveErc20 as gd, cancelAll as ge, cancelMarketOrders as gf, cancelOrder as gg, cancelOrders as gh, deployDepositWallet as gi, depositToPerps as gj, downloadAccountingSnapshot as gk, dropNotifications as gl, estimateMarketPrice as gm, executeCollateralReturnPlan as gn, fetchBalanceAllowance as go, fetchBuilderFeeRates as gp, fetchBuilderVolume as gq, fetchClosedOnlyMode as gr, fetchCommentsById as gs, fetchEvent as gt, fetchEventLiveVolume as gu, fetchEventTags as gv, fetchExecuteParams as gw, fetchLastTradePrice as gx, fetchLastTradePrices as gy, fetchMarket as gz, type ArmPerpsAutoCancelRequest as h, setupTradingApprovals as h$, fetchTickSize as h0, fetchTotalEarningsForUserForDay as h1, fetchTradedMarketCount as h2, fetchTransaction as h3, isWalletDeployed as h4, listAccountTrades as h5, listActivity as h6, listBuilderLeaderboard as h7, listBuilderTrades as h8, listClosedPositions as h9, mergeMarketPosition as hA, mergePositions as hB, openPerpsSession as hC, openRfqSession as hD, planCollateralReturn as hE, postOrder as hF, postOrders as hG, prepareCollateralReturnExecution as hH, prepareErc1155ApprovalForAll as hI, prepareErc20Approval as hJ, prepareErc20Transfer as hK, prepareGaslessTransaction as hL, prepareMergeComboPosition as hM, prepareMergeMarketPosition as hN, prepareMergePositions as hO, preparePerpsDeposit as hP, prepareRedeemComboPosition as hQ, prepareRedeemMarketPositions as hR, prepareRedeemPositions as hS, prepareSplitComboPosition as hT, prepareSplitMarketPosition as hU, prepareSplitPosition as hV, prepareTradingApprovals as hW, redeemPositions as hX, resolveConditionByToken as hY, revokePerpsCredentials as hZ, search as h_, listComboActivity as ha, listComboMarkets as hb, listComboPositions as hc, listComments as hd, listCommentsByUserAddress as he, listCurrentRewards as hf, listEvents as hg, listMarketClarifications as hh, listMarketHolders as hi, listMarketPositions as hj, listMarketRewards as hk, listMarkets as hl, listOpenInterest as hm, listOpenOrders as hn, listPerpsCandles as ho, listPerpsFundingHistory as hp, listPerpsTrades as hq, listPositions as hr, listSeries as hs, listTags as ht, listTeams as hu, listTraderLeaderboard as hv, listTrades as hw, listUserEarningsAndMarketsConfig as hx, listUserEarningsForDay as hy, mergeComboPosition as hz, AutoCancelDailyLimitError as i, splitComboPosition as i0, splitMarketPosition as i1, splitPosition as i2, subscribe as i3, transferErc20 as i4, updateBalanceAllowance as i5, waitForOrderFillSettlement as i6, withdrawFromPerps as i7, BasePublicClient as j, BaseSecureClient as k, type BeginAuthenticationRequest as l, type CancelAllPerpsOrdersRequest as m, CancelMarketOrdersError as n, CancelOrderError as o, CancelOrdersError as p, type CancelPerpsOrderRequest as q, type CancelPerpsOrdersRequest as r, CancelledSigningError as s, type Client as t, type ClientActions as u, type ClientDecorator as v, type ClobEndpoints as w, ComboPositionSort as x, type CombosEndpoints as y, ConnectionLostError as z };
|
package/dist/viem.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PrivateKey } from '@polymarket/types';
|
|
2
2
|
import { Chain, Transport, WalletClient } from 'viem';
|
|
3
|
-
import { S as Signer } from './types-
|
|
3
|
+
import { S as Signer } from './types-BBaRrND2.js';
|
|
4
4
|
import '@polymarket/bindings';
|
|
5
5
|
import '@polymarket/bindings/gamma';
|
|
6
6
|
import '@polymarket/bindings/relayer';
|
package/dist/viem.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a,
|
|
1
|
+
import {a,m,j,i,h,c as c$1}from'./chunk-MIRUWWDK.js';import {invariant,expectEvmAddress,expectEvmSignature,isPrivateKey,expectTxHash}from'@polymarket/types';import {createWalletClient,http,UserRejectedRequestError,TransactionExecutionError,WaitForTransactionReceiptTimeoutError}from'viem';import {privateKeyToAccount}from'viem/accounts';import {waitForTransactionReceipt}from'viem/actions';import {polygon}from'viem/chains';function H(t){return t.account!==void 0}function q(t){invariant(H(t),"Wallet client with account is required");let n=t.account,e=expectEvmAddress(typeof t.account=="string"?t.account:t.account.address);return {getAddress(){return Promise.resolve(e)},async signTypedData(r){return expectEvmSignature(await I(t,{account:n,...r}))},async signMessage(r){return expectEvmSignature(await R(t,{account:n,message:{raw:r}}))},async sendTransaction({chainId:r,...f}){await K(t,r);let m=await A(t,{account:n,...f});return new s(m,t)}}}function b(t,n={}){if(!isPrivateKey(t))throw new a("Expected a hex-encoded 32-byte private key.");return q(createWalletClient({account:privateKeyToAccount(t),chain:n.chain??polygon,transport:n.transport??http()}))}async function A(t,n){try{let e=await t.sendTransaction(n);return expectTxHash(e)}catch(e){c(e);}}async function K(t,n){try{let e=t.chain?.id??await t.getChainId();if(e!==n)throw new m(`Wallet client is connected to chain ${e}, expected ${n}`)}catch(e){throw e instanceof m?e:m.fromError(e,"Could not resolve wallet client chain ID")}}async function I(t,n){try{return await t.signTypedData(n)}catch(e){c(e);}}async function R(t,n){try{return await t.signMessage(n)}catch(e){c(e);}}function c(t){if(t instanceof UserRejectedRequestError)throw j.fromError(t);if(t instanceof TransactionExecutionError){let n=t.walk(e=>e instanceof UserRejectedRequestError);if(n)throw j.fromError(n)}throw m.fromError(t)}var s=class{transactionId=null;#t;#n;constructor(n,e){this.#t=expectTxHash(n),this.#n=e;}get transactionHash(){return this.#t}async wait(){try{let n=await waitForTransactionReceipt(this.#n,{hash:this.#t}),e=expectTxHash(n.transactionHash);if(this.#t=e,n.status==="reverted")throw new i(`Transaction ${e} reverted`);return {transactionHash:e,transactionId:null}}catch(n){throw n instanceof WaitForTransactionReceiptTimeoutError?new h(`Timed out waiting for transaction ${this.#t} to settle`,{cause:n}):c$1.fromError(n)}}};export{b as privateKey,q as signerFrom};//# sourceMappingURL=viem.js.map
|
|
2
2
|
//# sourceMappingURL=viem.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymarket/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "The Polymarket TypeScript client",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"ky": "^1.14.3",
|
|
94
94
|
"ox": "^0.14.16",
|
|
95
95
|
"zod": "^4.3.6",
|
|
96
|
-
"@polymarket/bindings": "0.
|
|
96
|
+
"@polymarket/bindings": "0.5.0",
|
|
97
97
|
"@polymarket/types": "0.1.0"
|
|
98
98
|
},
|
|
99
99
|
"publishConfig": {
|
package/dist/chunk-4LDMO37Q.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import {PolymarketError}from'@polymarket/types';var v=/^[$A-Z_a-z][$\w]*$/;function i(s){let r=c(s.issues);return r.length===0?"It was not possible to determine a more specific reason.":["Fix the following issues:",p(r)].join(`
|
|
2
|
-
`)}function u(s,r){let e=c(s.issues);return e.length===0?["Received an incompatible API response.",`Endpoint: ${r.endpoint}`,"This usually means the API response shape changed in a breaking way or the SDK is outdated.","It was not possible to determine a more specific reason."].join(`
|
|
3
|
-
`):["Received an incompatible API response.",`Endpoint: ${r.endpoint}`,"This usually means the API response shape changed in a breaking way or the SDK is outdated.","Fix the following issues:",p(e)].join(`
|
|
4
|
-
`)}function p(s){return s.map(e=>e.path===null?`- ${e.message}`:`- ${e.path}: ${e.message}`).join(`
|
|
5
|
-
`)}function c(s){return d(s).slice(0,99)}function d(s,r=[]){let e=s.flatMap(n=>{let a=[...r,...n.path];return n.code==="invalid_union"?n.errors.flatMap(A=>d(A,a)):[{code:n.code,message:n.message,path:a.length===0?null:U(a)}]});return O(e)}function O(s){let r=new Set,e=[];for(let n of s){let a=`${n.code}:${n.path??""}:${n.message}`;r.has(a)||(r.add(a),e.push(n));}return e.sort(Z)}function Z(s,r){return s.path===null&&r.path!==null?-1:s.path!==null&&r.path===null?1:(s.path??"").localeCompare(r.path??"")}function U(s){return s.reduce((r,e)=>typeof e=="number"?`${r}[${e.toString()}]`:typeof e!="string"?r:e.includes('"')?`${r}["${e.replaceAll('"','\\"')}"]`:v.test(e)?r.length===0?e:`${r}.${e}`:`${r}["${e}"]`,"")}var m=class s extends PolymarketError{name="UserInputError";constructor(r,e={}){super(r,e);}static fromZodError(r){return new s(i(r),{cause:r})}},l=class s extends PolymarketError{name="UnexpectedResponseError";constructor(r,e={}){super(r,e);}static fromZodError(r,e){return new s(u(r,e),{cause:r})}},f=class s extends PolymarketError{name="TransportError";constructor(r,e={}){super(r,e);}static fromError(r){return new s(r instanceof Error?r.message:"Request failed",{cause:r})}},P=(t=>(t[t.NormalClosure=1e3]="NormalClosure",t[t.GoingAway=1001]="GoingAway",t[t.ProtocolError=1002]="ProtocolError",t[t.UnsupportedData=1003]="UnsupportedData",t[t.NoStatusReceived=1005]="NoStatusReceived",t[t.AbnormalClosure=1006]="AbnormalClosure",t[t.InvalidFramePayload=1007]="InvalidFramePayload",t[t.PolicyViolation=1008]="PolicyViolation",t[t.MessageTooBig=1009]="MessageTooBig",t[t.InternalError=1011]="InternalError",t[t.ServiceRestart=1012]="ServiceRestart",t[t.TryAgainLater=1013]="TryAgainLater",t))(P||{}),g=class extends PolymarketError{name="ConnectionLostError";code;reason;constructor(r,e){super(r,e),this.code=e.code,this.reason=e.reason;}},y=class extends PolymarketError{name="RequestRejectedError";status;retryAfter;constructor(r,e){super(r,e),this.status=e.status,this.retryAfter=e.retryAfter;}},E=class extends PolymarketError{name="RateLimitError";retryAfter;constructor(r,e={}){super(r,e),this.retryAfter=e.retryAfter;}},I=class extends PolymarketError{name="TimeoutError";constructor(r,e={}){super(r,e);}},x=class extends PolymarketError{name="TransactionFailedError";constructor(r,e={}){super(r,e);}},h=class s extends PolymarketError{name="CancelledSigningError";constructor(r,e={}){super(r,e);}static fromError(r){return new s(r.message,{cause:r})}},$=class extends PolymarketError{name="InsufficientLiquidityError";constructor(r,e={}){super(r,e);}},R=class s extends PolymarketError{name="SigningError";constructor(r,e={}){super(r,e);}static fromError(r,e){let n=e??(r instanceof Error?r.message:"Signing failed");return new s(n,{cause:r})}};function M(...s){return {isError(r){return s.some(e=>r instanceof e)}}}export{m as a,l as b,f as c,P as d,g as e,y as f,E as g,I as h,x as i,h as j,$ as k,R as l,M as m};//# sourceMappingURL=chunk-4LDMO37Q.js.map
|
|
6
|
-
//# sourceMappingURL=chunk-4LDMO37Q.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/validation.ts","../src/errors.ts"],"names":["identifierRegex","formatInputZodError","error","issues","flattenIssues","formatIssues","formatResponseZodError","context","issue","flattenIssueBranches","pathPrefix","flattened","path","branch","formatPath","dedupeIssues","seen","deduped","key","compareIssues","left","right","result","segment","UserInputError","_UserInputError","PolymarketError","message","options","UnexpectedResponseError","_UnexpectedResponseError","TransportError","_TransportError","WebSocketKnownCloseCode","ConnectionLostError","RequestRejectedError","RateLimitError","TimeoutError","TransactionFailedError","CancelledSigningError","_CancelledSigningError","InsufficientLiquidityError","SigningError","_SigningError","msg","makeErrorGuard","classes","c"],"mappings":"gDAGA,IAAMA,CAAAA,CAAkB,oBAAA,CAejB,SAASC,CAAAA,CAAoBC,CAAAA,CAAyB,CAC3D,IAAMC,CAAAA,CAASC,CAAAA,CAAcF,CAAAA,CAAM,MAAM,CAAA,CAEzC,OAAIC,CAAAA,CAAO,MAAA,GAAW,CAAA,CACb,0DAAA,CAGF,CAAC,2BAAA,CAA6BE,CAAAA,CAAaF,CAAM,CAAC,CAAA,CAAE,IAAA,CAAK;AAAA,CAAI,CACtE,CAKO,SAASG,CAAAA,CACdJ,CAAAA,CACAK,CAAAA,CACQ,CACR,IAAMJ,CAAAA,CAASC,CAAAA,CAAcF,CAAAA,CAAM,MAAM,CAAA,CAEzC,OAAIC,CAAAA,CAAO,MAAA,GAAW,CAAA,CACb,CACL,wCAAA,CACA,CAAA,UAAA,EAAaI,CAAAA,CAAQ,QAAQ,CAAA,CAAA,CAC7B,6FAAA,CACA,0DACF,CAAA,CAAE,IAAA,CAAK;AAAA,CAAI,CAAA,CAGN,CACL,wCAAA,CACA,CAAA,UAAA,EAAaA,CAAAA,CAAQ,QA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AA,SAAqBjB,eAAgB,CACvC,IAAA,CAAO,cAAA,CAEhB,WAAA,CAAYC,CAAAA,CAAiBC,CAAAA,CAAwB,EAAC,CAAG,CACvD,KAAA,CAAMD,CAAAA,CAASC,CAAO,EACxB,CAEA,OAAO,SAAA,CAAU1B,EAAgByB,CAAAA,CAAgC,CAC/D,IAAMiB,CAAAA,CACJjB,CAAAA,GAAYzB,CAAAA,YAAiB,KAAA,CAAQA,CAAAA,CAAM,QAAU,gBAAA,CAAA,CACvD,OAAO,IAAIyC,CAAAA,CAAaC,EAAK,CAAE,KAAA,CAAO1C,CAAM,CAAC,CAC/C,CACF,EAEO,SAAS2C,CAAAA,CAAAA,GAIXC,CAAAA,CACmE,CACtE,OAAO,CACL,QAAQ5C,CAAAA,CAAyD,CAC/D,OAAO4C,CAAAA,CAAQ,KAAMC,CAAAA,EAAM7C,CAAAA,YAAiB6C,CAAC,CAC/C,CACF,CACF","file":"chunk-4LDMO37Q.js","sourcesContent":["import type { core, ZodError } from 'zod';\n\nconst maxIssuesInMessage = 99;\nconst identifierRegex = /^[$A-Z_a-z][$\\w]*$/;\n\ntype UserInputIssue = {\n code: string;\n message: string;\n path: string | null;\n};\n\nexport type ResponseValidationContext = {\n endpoint: string;\n};\n\n/**\n * Formats a `ZodError` into an SDK-oriented input validation message.\n */\nexport function formatInputZodError(error: ZodError): string {\n const issues = flattenIssues(error.issues);\n\n if (issues.length === 0) {\n return 'It was not possible to determine a more specific reason.';\n }\n\n return ['Fix the following issues:', formatIssues(issues)].join('\\n');\n}\n\n/**\n * Formats a `ZodError` into an SDK-oriented response validation message.\n */\nexport function formatResponseZodError(\n error: ZodError,\n context: ResponseValidationContext,\n): string {\n const issues = flattenIssues(error.issues);\n\n if (issues.length === 0) {\n return [\n 'Received an incompatible API response.',\n `Endpoint: ${context.endpoint}`,\n 'This usually means the API response shape changed in a breaking way or the SDK is outdated.',\n 'It was not possible to determine a more specific reason.',\n ].join('\\n');\n }\n\n return [\n 'Received an incompatible API response.',\n `Endpoint: ${context.endpoint}`,\n 'This usually means the API response shape changed in a breaking way or the SDK is outdated.',\n 'Fix the following issues:',\n formatIssues(issues),\n ].join('\\n');\n}\n\nfunction formatIssues(issues: readonly UserInputIssue[]): string {\n const lines = issues.map((issue) => {\n if (issue.path === null) {\n return `- ${issue.message}`;\n }\n\n return `- ${issue.path}: ${issue.message}`;\n });\n\n return lines.join('\\n');\n}\n\nfunction flattenIssues(issues: readonly core.$ZodIssue[]): UserInputIssue[] {\n return flattenIssueBranches(issues).slice(0, maxIssuesInMessage);\n}\n\nfunction flattenIssueBranches(\n issues: readonly core.$ZodIssue[],\n pathPrefix: readonly PropertyKey[] = [],\n): UserInputIssue[] {\n const flattened = issues.flatMap((issue) => {\n const path = [...pathPrefix, ...issue.path];\n\n if (issue.code === 'invalid_union') {\n return issue.errors.flatMap((branch) =>\n flattenIssueBranches(branch, path),\n );\n }\n\n return [\n {\n code: issue.code,\n message: issue.message,\n path: path.length === 0 ? null : formatPath(path),\n } satisfies UserInputIssue,\n ];\n });\n\n return dedupeIssues(flattened);\n}\n\nfunction dedupeIssues(issues: readonly UserInputIssue[]): UserInputIssue[] {\n const seen = new Set<string>();\n const deduped: UserInputIssue[] = [];\n\n for (const issue of issues) {\n const key = `${issue.code}:${issue.path ?? ''}:${issue.message}`;\n\n if (seen.has(key)) {\n continue;\n }\n\n seen.add(key);\n deduped.push(issue);\n }\n\n return deduped.sort(compareIssues);\n}\n\nfunction compareIssues(left: UserInputIssue, right: UserInputIssue): number {\n if (left.path === null && right.path !== null) {\n return -1;\n }\n\n if (left.path !== null && right.path === null) {\n return 1;\n }\n\n return (left.path ?? '').localeCompare(right.path ?? '');\n}\n\nfunction formatPath(path: readonly PropertyKey[]): string {\n return path.reduce<string>((result, segment) => {\n if (typeof segment === 'number') {\n return `${result}[${segment.toString()}]`;\n }\n\n if (typeof segment !== 'string') {\n return result;\n }\n\n if (segment.includes('\"')) {\n return `${result}[\"${segment.replaceAll('\"', '\\\\\"')}\"]`;\n }\n\n if (!identifierRegex.test(segment)) {\n return `${result}[\"${segment}\"]`;\n }\n\n if (result.length === 0) {\n return segment;\n }\n\n return `${result}.${segment}`;\n }, '');\n}\n","import { PolymarketError } from '@polymarket/types';\nimport type { ZodError } from 'zod';\nimport {\n formatInputZodError,\n formatResponseZodError,\n type ResponseValidationContext,\n} from './validation';\n\n/**\n * Error thrown when an action input fails SDK validation before a request is\n * sent.\n */\nexport class UserInputError extends PolymarketError {\n override name = 'UserInputError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromZodError(error: ZodError): UserInputError {\n return new UserInputError(formatInputZodError(error), {\n cause: error,\n });\n }\n}\n\n/**\n * Error thrown when a service response does not match the action's expected\n * response shape.\n */\nexport class UnexpectedResponseError extends PolymarketError {\n override name = 'UnexpectedResponseError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromZodError(\n error: ZodError,\n context: ResponseValidationContext,\n ): UnexpectedResponseError {\n return new UnexpectedResponseError(formatResponseZodError(error, context), {\n cause: error,\n });\n }\n}\n\n/**\n * Error thrown when the SDK cannot complete a request because of a network or\n * runtime transport failure.\n */\nexport class TransportError extends PolymarketError {\n override name = 'TransportError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromError(error: unknown): TransportError {\n return new TransportError(\n error instanceof Error ? error.message : 'Request failed',\n {\n cause: error,\n },\n );\n }\n}\n\n/**\n * WebSocket close codes defined by RFC 6455 and the IANA WebSocket Close Code\n * Number registry. Codes 4000-4999 are reserved for application use and are\n * intentionally not modeled here.\n */\nexport enum WebSocketKnownCloseCode {\n NormalClosure = 1000,\n GoingAway = 1001,\n ProtocolError = 1002,\n UnsupportedData = 1003,\n /** Synthesized locally when the peer closed without a status code. */\n NoStatusReceived = 1005,\n /** Synthesized locally when the connection dropped without a close frame. */\n AbnormalClosure = 1006,\n InvalidFramePayload = 1007,\n PolicyViolation = 1008,\n MessageTooBig = 1009,\n InternalError = 1011,\n ServiceRestart = 1012,\n TryAgainLater = 1013,\n}\n\n/**\n * A WebSocket close code. Codes enumerated in\n * {@link WebSocketKnownCloseCode} are defined by RFC 6455; other values, such\n * as application-defined 4000-4999 codes, flow through as plain numbers.\n */\nexport type WebSocketCloseCode = WebSocketKnownCloseCode | (number & {});\n\nexport type ConnectionLostErrorOptions = {\n /** WebSocket close code reported for the lost connection. */\n code: WebSocketCloseCode;\n /** Close reason provided by the peer. Empty when none was sent. */\n reason: string;\n};\n\n/**\n * Error thrown when a live connection ends without the SDK requesting it.\n */\nexport class ConnectionLostError extends PolymarketError {\n override name = 'ConnectionLostError' as const;\n\n readonly code: WebSocketCloseCode;\n readonly reason: string;\n\n constructor(\n message: string,\n options: ErrorOptions & ConnectionLostErrorOptions,\n ) {\n super(message, options);\n this.code = options.code;\n this.reason = options.reason;\n }\n}\n\nexport type RequestRejectedErrorOptions = {\n status: number;\n /**\n * Server-requested delay in seconds before retrying, when the response\n * provided one.\n */\n retryAfter?: number;\n};\n\n/**\n * Error thrown when a service responds with a non-success status other than\n * rate limiting.\n */\nexport class RequestRejectedError extends PolymarketError {\n override name = 'RequestRejectedError' as const;\n\n readonly status: number;\n /**\n * Server-requested delay in seconds before retrying, when the response\n * provided one.\n */\n readonly retryAfter?: number;\n\n constructor(\n message: string,\n options: ErrorOptions & RequestRejectedErrorOptions,\n ) {\n super(message, options);\n this.status = options.status;\n this.retryAfter = options.retryAfter;\n }\n}\n\nexport type RateLimitErrorOptions = {\n /**\n * Server-requested delay in seconds before retrying, when the response\n * provided one.\n */\n retryAfter?: number;\n};\n\n/**\n * Error thrown when the service rejects a request because the rate limit has\n * been exceeded.\n */\nexport class RateLimitError extends PolymarketError {\n override name = 'RateLimitError' as const;\n\n /**\n * Server-requested delay in seconds before retrying, when the response\n * provided one.\n */\n readonly retryAfter?: number;\n\n constructor(\n message: string,\n options: ErrorOptions & RateLimitErrorOptions = {},\n ) {\n super(message, options);\n this.retryAfter = options.retryAfter;\n }\n}\n\n/**\n * Error thrown when an async wait operation exceeds its allotted polling time.\n */\nexport class TimeoutError extends PolymarketError {\n override name = 'TimeoutError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n}\n\n/**\n * Error thrown when a submitted transaction reaches a terminal failure state.\n */\nexport class TransactionFailedError extends PolymarketError {\n override name = 'TransactionFailedError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n}\n\n/**\n * Error thrown when the user cancels a required wallet signing action.\n */\nexport class CancelledSigningError extends PolymarketError {\n override name = 'CancelledSigningError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromError(error: Error): CancelledSigningError {\n return new CancelledSigningError(error.message, {\n cause: error,\n });\n }\n}\n\n/**\n * Error thrown when there is not enough resting market liquidity to satisfy the\n * requested execution semantics.\n */\nexport class InsufficientLiquidityError extends PolymarketError {\n override name = 'InsufficientLiquidityError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n}\n\n/**\n * Error thrown when the SDK cannot produce a required signature or\n * authentication payload.\n */\nexport class SigningError extends PolymarketError {\n override name = 'SigningError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromError(error: unknown, message?: string): SigningError {\n const msg =\n message ?? (error instanceof Error ? error.message : 'Signing failed');\n return new SigningError(msg, { cause: error });\n }\n}\n\nexport function makeErrorGuard<\n // biome-ignore lint/suspicious/noExplicitAny: constructor rest args require any[]\n TClasses extends ReadonlyArray<new (...args: any[]) => unknown>,\n>(\n ...classes: TClasses\n): { isError(error: unknown): error is InstanceType<TClasses[number]> } {\n return {\n isError(error: unknown): error is InstanceType<TClasses[number]> {\n return classes.some((c) => error instanceof c);\n },\n };\n}\n"]}
|