@polymarket/client 0.1.0-beta.10 → 0.1.0-beta.12

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,12 +1,12 @@
1
- import { aR as RateLimitError, aT as RequestRejectedError, bG as TransportError, bJ as UnexpectedResponseError, bz as SigningError, B as BaseClient, h as BaseSecureClient } from '../types-M1U0um0G.js';
2
- export { e as ApproveErc1155ForAllError, f as ApproveErc20Error, C as CancelAllError, j as CancelMarketOrdersError, c3 as CancelMarketOrdersRequest, k as CancelOrderError, c4 as CancelOrderRequest, l as CancelOrdersError, c5 as CancelOrdersRequest, c6 as CancelPerpsOrderRequest, c7 as CancelPerpsOrdersRequest, c8 as CommentsEventType, c9 as CommentsSubscription, ca as CreatePerpsSessionRequest, cb as CryptoPricesEventType, cc as CryptoPricesSubscription, cd as DeployDepositWalletError, ce as DepositToPerpsError, cf as DepositToPerpsRequest, cg as DeprecatedTransactionHandle, t as DownloadAccountingSnapshotError, ch as DownloadAccountingSnapshotRequest, u as DropNotificationsError, ci as DropNotificationsRequest, cj as EquityPricesEventType, ck as EquityPricesSubscription, cl as Erc1155ApprovalForAllWorkflow, cm as Erc1155ApprovalForAllWorkflowRequest, cn as Erc20ApprovalWorkflow, co as Erc20ApprovalWorkflowRequest, cp as Erc20TransferWorkflow, cq as Erc20TransferWorkflowRequest, cr as EstimateMarketBuyPriceRequest, x as EstimateMarketPriceError, cs as EstimateMarketPriceRequest, ct as EstimateMarketSellPriceRequest, cu as EventForSubscriptionSpec, cv as EventForSubscriptionSpecs, cw as FetchBalanceAllowanceError, cx as FetchBalanceAllowanceRequest, cy as FetchBuilderFeeRatesError, cz as FetchBuilderFeeRatesRequest, F as FetchClosedOnlyModeError, y as FetchCommentsByIdError, cA as FetchCommentsByIdRequest, z as FetchEventError, G as FetchEventLiveVolumeError, cB as FetchEventLiveVolumeRequest, cC as FetchEventRequest, H as FetchEventTagsError, cD as FetchEventTagsRequest, cE as FetchExecuteParamsError, cF as FetchExecuteParamsRequest, cG as FetchGaslessTransactionRequest, I as FetchLastTradePriceError, cH as FetchLastTradePriceRequest, J as FetchLastTradePricesError, cI as FetchLastTradePricesRequest, K as FetchMarketError, cJ as FetchMarketInfoError, cK as FetchMarketInfoRequest, cL as FetchMarketRequest, L as FetchMarketTagsError, cM as FetchMarketTagsRequest, M as FetchMidpointError, cN as FetchMidpointRequest, N as FetchMidpointsError, cO as FetchMidpointsRequest, cP as FetchNegRiskError, cQ as FetchNegRiskRequest, O as FetchNotificationsError, P as FetchOrderBookError, cR as FetchOrderBookRequest, Q as FetchOrderBooksError, cS as FetchOrderBooksRequest, R as FetchOrderError, cT as FetchOrderRequest, V as FetchOrderScoringError, cU as FetchOrderScoringRequest, W as FetchOrdersScoringError, cV as FetchOrdersScoringRequest, cW as FetchPerpsAccountConfigRequest, cX as FetchPerpsBookError, cY as FetchPerpsBookRequest, cZ as FetchPerpsFeesError, c_ as FetchPerpsInstrumentsError, c$ as FetchPerpsInstrumentsRequest, d0 as FetchPerpsOpenOrdersRequest, d1 as FetchPerpsOrdersRequest, d2 as FetchPerpsTickerError, d3 as FetchPerpsTickerRequest, d4 as FetchPerpsTickersError, d5 as FetchPerpsTickersRequest, X as FetchPortfolioValueError, d6 as FetchPortfolioValueRequest, Y as FetchPriceError, Z as FetchPriceHistoryError, d7 as FetchPriceHistoryRequest, d8 as FetchPriceRequest, _ as FetchPricesError, d9 as FetchPricesRequest, $ as FetchPublicProfileError, da as FetchPublicProfileRequest, a0 as FetchRelatedTagResourcesError, db as FetchRelatedTagResourcesRequest, a1 as FetchRelatedTagsError, dc as FetchRelatedTagsRequest, a2 as FetchRewardPercentagesError, a3 as FetchSeriesError, dd as FetchSeriesRequest, a4 as FetchSpreadError, de as FetchSpreadRequest, a5 as FetchSpreadsError, df as FetchSpreadsRequest, a6 as FetchTagError, dg as FetchTagRequest, dh as FetchTickSizeError, di as FetchTickSizeRequest, a7 as FetchTotalEarningsForUserForDayError, dj as FetchTotalEarningsForUserForDayRequest, a8 as FetchTradedMarketCountError, dk as FetchTradedMarketCountRequest, dl as GaslessTransactionMetadataSchema, dm as GaslessWorkflow, dn as GaslessWorkflowRequest, dp as IsWalletDeployedError, dq as IsWalletDeployedRequest, aa as ListAccountTradesError, dr as ListAccountTradesRequest, ab as ListActivityError, ds as ListActivityRequest, ac as ListBuilderLeaderboardError, dt as ListBuilderLeaderboardRequest, ad as ListBuilderTradesError, du as ListBuilderTradesRequest, ae as ListBuilderVolumeError, dv as ListBuilderVolumeRequest, af as ListClosedPositionsError, dw as ListClosedPositionsRequest, ag as ListComboMarketsError, dx as ListComboMarketsRequest, ah as ListComboPositionsError, dy as ListComboPositionsRequest, ai as ListCommentsByUserAddressError, dz as ListCommentsByUserAddressRequest, aj as ListCommentsError, dA as ListCommentsRequest, ak as ListCurrentRewardsError, dB as ListCurrentRewardsRequest, al as ListEventsError, dC as ListEventsRequest, am as ListMarketHoldersError, dD as ListMarketHoldersRequest, an as ListMarketPositionsError, dE as ListMarketPositionsRequest, ao as ListMarketRewardsError, dF as ListMarketRewardsRequest, ap as ListMarketsError, dG as ListMarketsRequest, aq as ListOpenInterestError, dH as ListOpenInterestRequest, ar as ListOpenOrdersError, dI as ListOpenOrdersRequest, dJ as ListPerpsCandlesError, dK as ListPerpsCandlesRequest, dL as ListPerpsDepositsRequest, dM as ListPerpsEquityHistoryRequest, dN as ListPerpsFillsRequest, dO as ListPerpsFundingHistoryError, dP as ListPerpsFundingHistoryRequest, dQ as ListPerpsFundingPaymentsRequest, dR as ListPerpsPnlHistoryRequest, dS as ListPerpsTradesError, dT as ListPerpsTradesRequest, dU as ListPerpsWithdrawalsRequest, as as ListPositionsError, dV as ListPositionsRequest, at as ListSeriesError, dW as ListSeriesRequest, au as ListTagsError, dX as ListTagsRequest, av as ListTeamsError, dY as ListTeamsRequest, aw as ListTraderLeaderboardError, dZ as ListTraderLeaderboardRequest, ax as ListTradesError, d_ as ListTradesRequest, ay as ListUserEarningsAndMarketsConfigError, d$ as ListUserEarningsAndMarketsConfigRequest, az as ListUserEarningsForDayError, e0 as ListUserEarningsForDayRequest, e1 as MarketEventType, e2 as MarketSubscription, e3 as MergeComboPositionError, e4 as MergeMarketPositionError, aA as MergePositionsError, e5 as MergePositionsWorkflow, e6 as MergePositionsWorkflowRequest, e7 as OpenPerpsSessionError, e8 as OpenPerpsSessionRequest, aB as OpenRfqSessionError, e9 as OrderDraft, ea as OrderPostingWorkflow, eb as OrderWorkflow, ec as OrderWorkflowRequest, ed as PerpsBboSubscription, ee as PerpsBookDepth, ef as PerpsBookSubscription, eg as PerpsCandlesSubscription, eh as PerpsDepositWorkflow, ei as PerpsDepositWorkflowRequest, ej as PerpsMarketDataEventType, ek as PerpsMarketDataSubscription, el as PerpsPlaceFokOrderRequest, em as PerpsPlaceGtcOrderRequest, en as PerpsPlaceIocOrderRequest, aH as PerpsSession, eo as PerpsStatisticsSubscription, ep as PerpsStreamingCandleInterval, eq as PerpsTickersSubscription, er as PerpsTradesSubscription, es as PlacePerpsOrderRequest, aI as PostOrderError, aJ as PostOrdersError, et as PostOrdersRequest, eu as PostPerpsOrdersRequest, ev as PrepareErc1155ApprovalForAllError, ew as PrepareErc1155ApprovalForAllRequest, ex as PrepareErc20ApprovalError, ey as PrepareErc20ApprovalRequest, ez as PrepareErc20TransferError, eA as PrepareErc20TransferRequest, eB as PrepareGaslessTransactionError, eC as PrepareGaslessTransactionRequest, eD as PrepareLimitOrderRequest, eE as PrepareMarketBuyOrderRequest, eF as PrepareMarketOrderRequest, eG as PrepareMarketSellOrderRequest, eH as PrepareMergeComboPositionError, eI as PrepareMergeComboPositionRequest, eJ as PrepareMergeMarketPositionError, eK as PrepareMergeMarketPositionRequest, eL as PrepareMergePositionsError, eM as PrepareMergePositionsRequest, eN as PreparePerpsDepositError, eO as PrepareRedeemComboPositionError, eP as PrepareRedeemComboPositionRequest, eQ as PrepareRedeemMarketPositionsByConditionIdRequest, eR as PrepareRedeemMarketPositionsByMarketIdRequest, eS as PrepareRedeemMarketPositionsError, eT as PrepareRedeemMarketPositionsRequest, eU as PrepareRedeemPositionsError, eV as PrepareRedeemPositionsRequest, eW as PrepareSplitComboPositionError, eX as PrepareSplitComboPositionRequest, eY as PrepareSplitMarketPositionError, eZ as PrepareSplitMarketPositionRequest, e_ as PrepareSplitPositionError, e$ as PrepareSplitPositionRequest, f0 as PrepareTradingApprovalsError, f1 as PublicRealtimeEvent, f2 as PublicRealtimeTopic, f3 as PublicSubscriptionSpec, aS as RedeemPositionsError, f4 as RedeemPositionsWorkflow, f5 as RedeemPositionsWorkflowRequest, f6 as ResolveConditionByTokenError, f7 as ResolveConditionByTokenRequest, f8 as ResumePerpsSessionRequest, f9 as RevokePerpsCredentialsError, fa as RevokePerpsCredentialsRequest, aW as RfqCancelQuoteAck, aX as RfqCancelQuoteError, aY as RfqCancelQuoteRejectedError, aZ as RfqCancelQuoteRejectedErrorOptions, a_ as RfqConfirmationAck, a$ as RfqConfirmationError, b0 as RfqConfirmationRejectedError, fb as RfqConfirmationRejectedErrorOptions, b1 as RfqConfirmationRequestEvent, b3 as RfqEvent, fc as RfqExecutionUpdateEvent, b4 as RfqQuoteError, b5 as RfqQuoteReference, b6 as RfqQuoteRejectedError, b7 as RfqQuoteRejectedErrorOptions, b8 as RfqQuoteRequestEvent, b9 as RfqQuoteResponse, ba as RfqQuoteSource, bb as RfqSession, bc as RfqTradeEvent, bd as SearchError, fd as SearchRequest, fe as SearchResults, be as SearchSort, ff as SecureRealtimeEvent, fg as SecureRealtimeTopic, fh as SecureSubscriptionSpec, bx as SetupTradingApprovalsError, fi as SignedOrder, fj as SplitComboPositionError, fk as SplitMarketPositionError, bA as SplitPositionError, fl as SplitPositionWorkflow, fm as SplitPositionWorkflowRequest, fn as SportsEventType, fo as SportsSubscription, fp as SubscribeError, fq as SubscriptionHandle, fr as TradingApprovalsWorkflow, fs as TradingApprovalsWorkflowRequest, bF as TransferErc20Error, ft as UpdateBalanceAllowanceError, fu as UpdateBalanceAllowanceRequest, bK as UpdatePerpsLeverageError, fv as UpdatePerpsLeverageRequest, bL as UpdatePerpsMarginError, fw as UpdatePerpsMarginRequest, fx as UserEventType, fy as UserSubscription, fz as WaitForGaslessTransactionError, fA as WithdrawFromPerpsError, fB as WithdrawFromPerpsRequest, fC as approveErc1155ForAll, fD as approveErc20, fE as cancelAll, fF as cancelMarketOrders, fG as cancelOrder, fH as cancelOrders, fI as deployDepositWallet, fJ as depositToPerps, fK as downloadAccountingSnapshot, fL as dropNotifications, fM as estimateMarketPrice, fN as fetchBalanceAllowance, fO as fetchBuilderFeeRates, fP as fetchBuilderVolume, fQ as fetchClosedOnlyMode, fR as fetchCommentsById, fS as fetchEvent, fT as fetchEventLiveVolume, fU as fetchEventTags, fV as fetchExecuteParams, fW as fetchLastTradePrice, fX as fetchLastTradePrices, fY as fetchMarket, fZ as fetchMarketInfo, f_ as fetchMarketTags, f$ as fetchMidpoint, g0 as fetchMidpoints, g1 as fetchNegRisk, g2 as fetchNotifications, g3 as fetchOrder, g4 as fetchOrderBook, g5 as fetchOrderBooks, g6 as fetchOrderScoring, g7 as fetchOrdersScoring, g8 as fetchPerpsBook, g9 as fetchPerpsFees, ga as fetchPerpsInstruments, gb as fetchPerpsTicker, gc as fetchPerpsTickers, gd as fetchPortfolioValue, ge as fetchPrice, gf as fetchPriceHistory, gg as fetchPrices, gh as fetchPublicProfile, gi as fetchRelatedTagResources, gj as fetchRelatedTags, gk as fetchRewardPercentages, gl as fetchSeries, gm as fetchSpread, gn as fetchSpreads, go as fetchTag, gp as fetchTickSize, gq as fetchTotalEarningsForUserForDay, gr as fetchTradedMarketCount, gs as fetchTransaction, gt as isWalletDeployed, gu as listAccountTrades, gv as listActivity, gw as listBuilderLeaderboard, gx as listBuilderTrades, gy as listClosedPositions, gz as listComboMarkets, gA as listComboPositions, gB as listComments, gC as listCommentsByUserAddress, gD as listCurrentRewards, gE as listEvents, gF as listMarketHolders, gG as listMarketPositions, gH as listMarketRewards, gI as listMarkets, gJ as listOpenInterest, gK as listOpenOrders, gL as listPerpsCandles, gM as listPerpsFundingHistory, gN as listPerpsTrades, gO as listPositions, gP as listSeries, gQ as listTags, gR as listTeams, gS as listTraderLeaderboard, gT as listTrades, gU as listUserEarningsAndMarketsConfig, gV as listUserEarningsForDay, gW as mergeComboPosition, gX as mergeMarketPosition, gY as mergePositions, gZ as openPerpsSession, g_ as openRfqSession, g$ as postOrder, h0 as postOrders, h1 as prepareErc1155ApprovalForAll, h2 as prepareErc20Approval, h3 as prepareErc20Transfer, h4 as prepareGaslessTransaction, h5 as prepareMergeComboPosition, h6 as prepareMergeMarketPosition, h7 as prepareMergePositions, h8 as preparePerpsDeposit, h9 as prepareRedeemComboPosition, ha as prepareRedeemMarketPositions, hb as prepareRedeemPositions, hc as prepareSplitComboPosition, hd as prepareSplitMarketPosition, he as prepareSplitPosition, hf as prepareTradingApprovals, hg as redeemPositions, hh as resolveConditionByToken, hi as revokePerpsCredentials, hj as search, hk as setupTradingApprovals, hl as splitComboPosition, hm as splitMarketPosition, hn as splitPosition, ho as subscribe, hp as transferErc20, hq as updateBalanceAllowance, hr as withdrawFromPerps } from '../types-M1U0um0G.js';
1
+ import { aR as RateLimitError, aT as RequestRejectedError, bG as TransportError, bJ as UnexpectedResponseError, bz as SigningError, B as BaseClient, h as BaseSecureClient } from '../types-BiMOyijM.js';
2
+ export { e as ApproveErc1155ForAllError, f as ApproveErc20Error, C as CancelAllError, j as CancelMarketOrdersError, c2 as CancelMarketOrdersRequest, k as CancelOrderError, c3 as CancelOrderRequest, l as CancelOrdersError, c4 as CancelOrdersRequest, c5 as CancelPerpsOrderRequest, c6 as CancelPerpsOrdersRequest, c7 as CommentsEventType, c8 as CommentsSubscription, c9 as CreatePerpsSessionRequest, ca as CryptoPricesEventType, cb as CryptoPricesSubscription, cc as DeployDepositWalletError, cd as DepositToPerpsError, ce as DepositToPerpsRequest, cf as DeprecatedTransactionHandle, t as DownloadAccountingSnapshotError, cg as DownloadAccountingSnapshotRequest, u as DropNotificationsError, ch as DropNotificationsRequest, ci as EquityPricesEventType, cj as EquityPricesSubscription, ck as Erc1155ApprovalForAllWorkflow, cl as Erc1155ApprovalForAllWorkflowRequest, cm as Erc20ApprovalWorkflow, cn as Erc20ApprovalWorkflowRequest, co as Erc20TransferWorkflow, cp as Erc20TransferWorkflowRequest, cq as EstimateMarketBuyPriceRequest, x as EstimateMarketPriceError, cr as EstimateMarketPriceRequest, cs as EstimateMarketSellPriceRequest, ct as EventForSubscriptionSpec, cu as EventForSubscriptionSpecs, cv as FetchBalanceAllowanceError, cw as FetchBalanceAllowanceRequest, cx as FetchBuilderFeeRatesError, cy as FetchBuilderFeeRatesRequest, F as FetchClosedOnlyModeError, y as FetchCommentsByIdError, cz as FetchCommentsByIdRequest, z as FetchEventError, G as FetchEventLiveVolumeError, cA as FetchEventLiveVolumeRequest, cB as FetchEventRequest, H as FetchEventTagsError, cC as FetchEventTagsRequest, cD as FetchExecuteParamsError, cE as FetchExecuteParamsRequest, cF as FetchGaslessTransactionRequest, I as FetchLastTradePriceError, cG as FetchLastTradePriceRequest, J as FetchLastTradePricesError, cH as FetchLastTradePricesRequest, K as FetchMarketError, cI as FetchMarketInfoError, cJ as FetchMarketInfoRequest, cK as FetchMarketRequest, L as FetchMarketTagsError, cL as FetchMarketTagsRequest, M as FetchMidpointError, cM as FetchMidpointRequest, N as FetchMidpointsError, cN as FetchMidpointsRequest, cO as FetchNegRiskError, cP as FetchNegRiskRequest, O as FetchNotificationsError, P as FetchOrderBookError, cQ as FetchOrderBookRequest, Q as FetchOrderBooksError, cR as FetchOrderBooksRequest, R as FetchOrderError, cS as FetchOrderRequest, V as FetchOrderScoringError, cT as FetchOrderScoringRequest, W as FetchOrdersScoringError, cU as FetchOrdersScoringRequest, cV as FetchPerpsAccountConfigRequest, cW as FetchPerpsBookError, cX as FetchPerpsBookRequest, cY as FetchPerpsFeesError, cZ as FetchPerpsInstrumentsError, c_ as FetchPerpsInstrumentsRequest, c$ as FetchPerpsOpenOrdersRequest, d0 as FetchPerpsOrdersRequest, d1 as FetchPerpsTickerError, d2 as FetchPerpsTickerRequest, d3 as FetchPerpsTickersError, d4 as FetchPerpsTickersRequest, X as FetchPortfolioValueError, d5 as FetchPortfolioValueRequest, Y as FetchPriceError, Z as FetchPriceHistoryError, d6 as FetchPriceHistoryRequest, d7 as FetchPriceRequest, _ as FetchPricesError, d8 as FetchPricesRequest, $ as FetchPublicProfileError, d9 as FetchPublicProfileRequest, a0 as FetchRelatedTagResourcesError, da as FetchRelatedTagResourcesRequest, a1 as FetchRelatedTagsError, db as FetchRelatedTagsRequest, a2 as FetchRewardPercentagesError, a3 as FetchSeriesError, dc as FetchSeriesRequest, a4 as FetchSpreadError, dd as FetchSpreadRequest, a5 as FetchSpreadsError, de as FetchSpreadsRequest, a6 as FetchTagError, df as FetchTagRequest, dg as FetchTickSizeError, dh as FetchTickSizeRequest, a7 as FetchTotalEarningsForUserForDayError, di as FetchTotalEarningsForUserForDayRequest, a8 as FetchTradedMarketCountError, dj as FetchTradedMarketCountRequest, dk as GaslessTransactionMetadataSchema, dl as GaslessWorkflow, dm as GaslessWorkflowRequest, dn as IsWalletDeployedError, dp as IsWalletDeployedRequest, aa as ListAccountTradesError, dq as ListAccountTradesRequest, ab as ListActivityError, dr as ListActivityRequest, ac as ListBuilderLeaderboardError, ds as ListBuilderLeaderboardRequest, ad as ListBuilderTradesError, dt as ListBuilderTradesRequest, ae as ListBuilderVolumeError, du as ListBuilderVolumeRequest, af as ListClosedPositionsError, dv as ListClosedPositionsRequest, ag as ListComboMarketsError, dw as ListComboMarketsRequest, ah as ListComboPositionsError, dx as ListComboPositionsRequest, ai as ListCommentsByUserAddressError, dy as ListCommentsByUserAddressRequest, aj as ListCommentsError, dz as ListCommentsRequest, ak as ListCurrentRewardsError, dA as ListCurrentRewardsRequest, al as ListEventsError, dB as ListEventsRequest, am as ListMarketHoldersError, dC as ListMarketHoldersRequest, an as ListMarketPositionsError, dD as ListMarketPositionsRequest, ao as ListMarketRewardsError, dE as ListMarketRewardsRequest, ap as ListMarketsError, dF as ListMarketsRequest, aq as ListOpenInterestError, dG as ListOpenInterestRequest, ar as ListOpenOrdersError, dH as ListOpenOrdersRequest, dI as ListPerpsCandlesError, dJ as ListPerpsCandlesRequest, dK as ListPerpsDepositsRequest, dL as ListPerpsEquityHistoryRequest, dM as ListPerpsFillsRequest, dN as ListPerpsFundingHistoryError, dO as ListPerpsFundingHistoryRequest, dP as ListPerpsFundingPaymentsRequest, dQ as ListPerpsPnlHistoryRequest, dR as ListPerpsTradesError, dS as ListPerpsTradesRequest, dT as ListPerpsWithdrawalsRequest, as as ListPositionsError, dU as ListPositionsRequest, at as ListSeriesError, dV as ListSeriesRequest, au as ListTagsError, dW as ListTagsRequest, av as ListTeamsError, dX as ListTeamsRequest, aw as ListTraderLeaderboardError, dY as ListTraderLeaderboardRequest, ax as ListTradesError, dZ as ListTradesRequest, ay as ListUserEarningsAndMarketsConfigError, d_ as ListUserEarningsAndMarketsConfigRequest, az as ListUserEarningsForDayError, d$ as ListUserEarningsForDayRequest, e0 as MarketEventType, e1 as MarketSubscription, e2 as MergeComboPositionError, e3 as MergeMarketPositionError, aA as MergePositionsError, e4 as MergePositionsWorkflow, e5 as MergePositionsWorkflowRequest, e6 as OpenPerpsSessionError, e7 as OpenPerpsSessionRequest, aB as OpenRfqSessionError, e8 as OrderDraft, e9 as OrderPostingWorkflow, ea as OrderWorkflow, eb as OrderWorkflowRequest, ec as PerpsBboSubscription, ed as PerpsBookDepth, ee as PerpsBookSubscription, ef as PerpsCandlesSubscription, eg as PerpsDepositWorkflow, eh as PerpsDepositWorkflowRequest, ei as PerpsMarketDataEventType, ej as PerpsMarketDataSubscription, ek as PerpsOrderRequest, el as PerpsPlaceFokOrderRequest, em as PerpsPlaceGtcOrderRequest, en as PerpsPlaceIocOrderRequest, eo as PerpsPlacedTpSlOrder, ep as PerpsPlacedTpSlOrders, eq as PerpsPositionTpSlTrigger, aH as PerpsSession, er as PerpsStatisticsSubscription, es as PerpsStreamingCandleInterval, et as PerpsTickersSubscription, eu as PerpsTpSlTrigger, ev as PerpsTradesSubscription, ew as PlacePerpsOrderRequest, ex as PlacePerpsOrderResult, ey as PlacePerpsOrderWithTpSlRequest, ez as PlacePerpsOrderWithTpSlResult, eA as PlacePerpsPositionTpSlRequest, eB as PlacePerpsPositionTpSlResult, aI as PostOrderError, aJ as PostOrdersError, eC as PostOrdersRequest, eD as PostPerpsOrdersRequest, eE as PrepareErc1155ApprovalForAllError, eF as PrepareErc1155ApprovalForAllRequest, eG as PrepareErc20ApprovalError, eH as PrepareErc20ApprovalRequest, eI as PrepareErc20TransferError, eJ as PrepareErc20TransferRequest, eK as PrepareGaslessTransactionError, eL as PrepareGaslessTransactionRequest, eM as PrepareLimitOrderRequest, eN as PrepareMarketBuyOrderRequest, eO as PrepareMarketOrderRequest, eP as PrepareMarketSellOrderRequest, eQ as PrepareMergeComboPositionError, eR as PrepareMergeComboPositionRequest, eS as PrepareMergeMarketPositionError, eT as PrepareMergeMarketPositionRequest, eU as PrepareMergePositionsError, eV as PrepareMergePositionsRequest, eW as PreparePerpsDepositError, eX as PrepareRedeemComboPositionError, eY as PrepareRedeemComboPositionRequest, eZ as PrepareRedeemMarketPositionsByConditionIdRequest, e_ as PrepareRedeemMarketPositionsByMarketIdRequest, e$ as PrepareRedeemMarketPositionsError, f0 as PrepareRedeemMarketPositionsRequest, f1 as PrepareRedeemPositionsError, f2 as PrepareRedeemPositionsRequest, f3 as PrepareSplitComboPositionError, f4 as PrepareSplitComboPositionRequest, f5 as PrepareSplitMarketPositionError, f6 as PrepareSplitMarketPositionRequest, f7 as PrepareSplitPositionError, f8 as PrepareSplitPositionRequest, f9 as PrepareTradingApprovalsError, fa as PublicRealtimeEvent, fb as PublicRealtimeTopic, fc as PublicSubscriptionSpec, aS as RedeemPositionsError, fd as RedeemPositionsWorkflow, fe as RedeemPositionsWorkflowRequest, ff as ResolveConditionByTokenError, fg as ResolveConditionByTokenRequest, fh as ResumePerpsSessionRequest, fi as RevokePerpsCredentialsError, fj as RevokePerpsCredentialsRequest, aW as RfqCancelQuoteAck, aX as RfqCancelQuoteError, aY as RfqCancelQuoteRejectedError, aZ as RfqCancelQuoteRejectedErrorOptions, a_ as RfqConfirmationAck, a$ as RfqConfirmationError, b0 as RfqConfirmationRejectedError, fk as RfqConfirmationRejectedErrorOptions, b1 as RfqConfirmationRequestEvent, b3 as RfqEvent, fl as RfqExecutionUpdateEvent, b4 as RfqQuoteError, b5 as RfqQuoteReference, b6 as RfqQuoteRejectedError, b7 as RfqQuoteRejectedErrorOptions, b8 as RfqQuoteRequestEvent, b9 as RfqQuoteResponse, ba as RfqQuoteSource, bb as RfqSession, bc as RfqTradeEvent, bd as SearchError, fm as SearchRequest, fn as SearchResults, be as SearchSort, fo as SecureRealtimeEvent, fp as SecureRealtimeTopic, fq as SecureSubscriptionSpec, bx as SetupTradingApprovalsError, fr as SignedOrder, fs as SplitComboPositionError, ft as SplitMarketPositionError, bA as SplitPositionError, fu as SplitPositionWorkflow, fv as SplitPositionWorkflowRequest, fw as SportsEventType, fx as SportsSubscription, fy as SubscribeError, fz as SubscriptionHandle, fA as TradingApprovalsWorkflow, fB as TradingApprovalsWorkflowRequest, bF as TransferErc20Error, fC as UpdateBalanceAllowanceError, fD as UpdateBalanceAllowanceRequest, bK as UpdatePerpsLeverageError, fE as UpdatePerpsLeverageRequest, fF as UserEventType, fG as UserSubscription, fH as WaitForGaslessTransactionError, fI as WithdrawFromPerpsError, fJ as WithdrawFromPerpsRequest, fK as approveErc1155ForAll, fL as approveErc20, fM as cancelAll, fN as cancelMarketOrders, fO as cancelOrder, fP as cancelOrders, fQ as deployDepositWallet, fR as depositToPerps, fS as downloadAccountingSnapshot, fT as dropNotifications, fU as estimateMarketPrice, fV as fetchBalanceAllowance, fW as fetchBuilderFeeRates, fX as fetchBuilderVolume, fY as fetchClosedOnlyMode, fZ as fetchCommentsById, f_ as fetchEvent, f$ as fetchEventLiveVolume, g0 as fetchEventTags, g1 as fetchExecuteParams, g2 as fetchLastTradePrice, g3 as fetchLastTradePrices, g4 as fetchMarket, g5 as fetchMarketInfo, g6 as fetchMarketTags, g7 as fetchMidpoint, g8 as fetchMidpoints, g9 as fetchNegRisk, ga as fetchNotifications, gb as fetchOrder, gc as fetchOrderBook, gd as fetchOrderBooks, ge as fetchOrderScoring, gf as fetchOrdersScoring, gg as fetchPerpsBook, gh as fetchPerpsFees, gi as fetchPerpsInstruments, gj as fetchPerpsTicker, gk as fetchPerpsTickers, gl as fetchPortfolioValue, gm as fetchPrice, gn as fetchPriceHistory, go as fetchPrices, gp as fetchPublicProfile, gq as fetchRelatedTagResources, gr as fetchRelatedTags, gs as fetchRewardPercentages, gt as fetchSeries, gu as fetchSpread, gv as fetchSpreads, gw as fetchTag, gx as fetchTickSize, gy as fetchTotalEarningsForUserForDay, gz as fetchTradedMarketCount, gA as fetchTransaction, gB as isWalletDeployed, gC as listAccountTrades, gD as listActivity, gE as listBuilderLeaderboard, gF as listBuilderTrades, gG as listClosedPositions, gH as listComboMarkets, gI as listComboPositions, gJ as listComments, gK as listCommentsByUserAddress, gL as listCurrentRewards, gM as listEvents, gN as listMarketHolders, gO as listMarketPositions, gP as listMarketRewards, gQ as listMarkets, gR as listOpenInterest, gS as listOpenOrders, gT as listPerpsCandles, gU as listPerpsFundingHistory, gV as listPerpsTrades, gW as listPositions, gX as listSeries, gY as listTags, gZ as listTeams, g_ as listTraderLeaderboard, g$ as listTrades, h0 as listUserEarningsAndMarketsConfig, h1 as listUserEarningsForDay, h2 as mergeComboPosition, h3 as mergeMarketPosition, h4 as mergePositions, h5 as openPerpsSession, h6 as openRfqSession, h7 as postOrder, h8 as postOrders, h9 as prepareErc1155ApprovalForAll, ha as prepareErc20Approval, hb as prepareErc20Transfer, hc as prepareGaslessTransaction, hd as prepareMergeComboPosition, he as prepareMergeMarketPosition, hf as prepareMergePositions, hg as preparePerpsDeposit, hh as prepareRedeemComboPosition, hi as prepareRedeemMarketPositions, hj as prepareRedeemPositions, hk as prepareSplitComboPosition, hl as prepareSplitMarketPosition, hm as prepareSplitPosition, hn as prepareTradingApprovals, ho as redeemPositions, hp as resolveConditionByToken, hq as revokePerpsCredentials, hr as search, hs as setupTradingApprovals, ht as splitComboPosition, hu as splitMarketPosition, hv as splitPosition, hw as subscribe, hx as transferErc20, hy as updateBalanceAllowance, hz as withdrawFromPerps } from '../types-BiMOyijM.js';
3
3
  import { ApiKey } from '@polymarket/bindings';
4
4
  import { ApiKeyCreds, BuilderApiKeyCreds, BuilderApiKey } from '@polymarket/bindings/clob';
5
5
  import { EvmAddress, EvmSignature } from '@polymarket/types';
6
- export { C as CreateLimitOrderError, a as CreateMarketOrderError, F as FetchSportsMarketTypesError, L as ListSportsError, P as PlaceLimitOrderError, b as PlaceMarketOrderError, c as PrepareLimitOrderError, d as PrepareLimitOrderPostingError, e as PrepareMarketOrderError, f as PrepareMarketOrderPostingError, g as createLimitOrder, h as createMarketOrder, i as fetchSportsMarketTypes, l as listSports, p as placeLimitOrder, j as placeMarketOrder, k as prepareLimitOrder, m as prepareLimitOrderPosting, n as prepareMarketOrder, o as prepareMarketOrderPosting } from '../sports-BGrBawu_.js';
6
+ export { C as CreateLimitOrderError, a as CreateMarketOrderError, F as FetchSportsMarketTypesError, L as ListSportsError, P as PlaceLimitOrderError, b as PlaceMarketOrderError, c as PrepareLimitOrderError, d as PrepareLimitOrderPostingError, e as PrepareMarketOrderError, f as PrepareMarketOrderPostingError, g as createLimitOrder, h as createMarketOrder, i as fetchSportsMarketTypes, l as listSports, p as placeLimitOrder, j as placeMarketOrder, k as prepareLimitOrder, m as prepareLimitOrderPosting, n as prepareMarketOrder, o as prepareMarketOrderPosting } from '../sports-BHPoQjk0.js';
7
7
  export { ComboPositionStatus } from '@polymarket/bindings/data';
8
8
  export { CommentsEvent, CryptoPricesBinanceEvent, CryptoPricesChainlinkEvent, CryptoPricesEvent, CustomMarketEvent, EquityPricesEvent, MarketEvent, PerpsBboEvent, PerpsBookEvent, PerpsCandleEvent, PerpsMarketDataEvent, PerpsSessionEvent, PerpsStatisticEvent, PerpsTickerEvent, PerpsTradeEvent, SportsEvent, StandardMarketEvent, UserEvent } from '@polymarket/bindings/subscriptions';
9
- export { PerpsCancelOrderResult, PerpsPostOrderAck } from '@polymarket/bindings/perps';
9
+ export { PerpsCancelOrderResult, PerpsPostOrderAck, PerpsUpdateLeverageResult } from '@polymarket/bindings/perps';
10
10
  export { RfqConfirmationDecision, RfqConfirmationRequest, RfqDirection, RfqErrorCode, RfqExecutionStatus, RfqExecutionUpdate, RfqId, RfqQuoteId, RfqQuoteRequest, RfqRequestedSize, RfqRequestedSizeUnit, RfqRequestorPublicId, RfqSide, RfqTrade } from '@polymarket/bindings/rfq';
11
11
  import '@polymarket/bindings/gamma';
12
12
  import '@polymarket/bindings/relayer';
@@ -21,7 +21,7 @@ type ApiKeyAuthRequest = {
21
21
  };
22
22
  type CreateApiKeyError = RateLimitError | RequestRejectedError | TransportError | UnexpectedResponseError;
23
23
  declare const CreateApiKeyError: {
24
- isError(error: unknown): error is TransportError | UnexpectedResponseError | RequestRejectedError | RateLimitError;
24
+ isError(error: unknown): error is UnexpectedResponseError | TransportError | RequestRejectedError | RateLimitError;
25
25
  };
26
26
  /**
27
27
  * Creates a new API key from a signed L1 auth payload.
@@ -40,7 +40,7 @@ declare const CreateApiKeyError: {
40
40
  declare function createApiKey(client: BaseClient, request: ApiKeyAuthRequest): Promise<ApiKeyCreds>;
41
41
  type DeriveApiKeyError = RateLimitError | RequestRejectedError | TransportError | UnexpectedResponseError;
42
42
  declare const DeriveApiKeyError: {
43
- isError(error: unknown): error is TransportError | UnexpectedResponseError | RequestRejectedError | RateLimitError;
43
+ isError(error: unknown): error is UnexpectedResponseError | TransportError | RequestRejectedError | RateLimitError;
44
44
  };
45
45
  /**
46
46
  * Derives an existing API key from a signed L1 auth payload.
@@ -59,7 +59,7 @@ declare const DeriveApiKeyError: {
59
59
  declare function deriveApiKey(client: BaseClient, request: ApiKeyAuthRequest): Promise<ApiKeyCreds>;
60
60
  type CreateOrDeriveApiKeyError = RateLimitError | RequestRejectedError | TransportError | UnexpectedResponseError;
61
61
  declare const CreateOrDeriveApiKeyError: {
62
- isError(error: unknown): error is TransportError | UnexpectedResponseError | RequestRejectedError | RateLimitError;
62
+ isError(error: unknown): error is UnexpectedResponseError | TransportError | RequestRejectedError | RateLimitError;
63
63
  };
64
64
  /**
65
65
  * Creates an API key and falls back to derivation when it already exists.
@@ -78,7 +78,7 @@ declare const CreateOrDeriveApiKeyError: {
78
78
  declare function createOrDeriveApiKey(client: BaseClient, request: ApiKeyAuthRequest): Promise<ApiKeyCreds>;
79
79
  type FetchApiKeysError = RateLimitError | RequestRejectedError | SigningError | TransportError | UnexpectedResponseError;
80
80
  declare const FetchApiKeysError: {
81
- isError(error: unknown): error is SigningError | TransportError | UnexpectedResponseError | RequestRejectedError | RateLimitError;
81
+ isError(error: unknown): error is UnexpectedResponseError | TransportError | RequestRejectedError | RateLimitError | SigningError;
82
82
  };
83
83
  /**
84
84
  * Fetches all API keys associated with the authenticated client.
@@ -97,7 +97,7 @@ declare const FetchApiKeysError: {
97
97
  declare function fetchApiKeys(client: BaseSecureClient): Promise<ApiKey[]>;
98
98
  type DeleteApiKeyError = RateLimitError | RequestRejectedError | SigningError | TransportError | UnexpectedResponseError;
99
99
  declare const DeleteApiKeyError: {
100
- isError(error: unknown): error is SigningError | TransportError | UnexpectedResponseError | RequestRejectedError | RateLimitError;
100
+ isError(error: unknown): error is UnexpectedResponseError | TransportError | RequestRejectedError | RateLimitError | SigningError;
101
101
  };
102
102
  /**
103
103
  * Deletes the authenticated API key.
@@ -117,7 +117,7 @@ declare const DeleteApiKeyError: {
117
117
  declare function deleteApiKey(client: BaseSecureClient): Promise<void>;
118
118
  type CreateBuilderApiKeyError = RateLimitError | RequestRejectedError | SigningError | TransportError | UnexpectedResponseError;
119
119
  declare const CreateBuilderApiKeyError: {
120
- isError(error: unknown): error is SigningError | TransportError | UnexpectedResponseError | RequestRejectedError | RateLimitError;
120
+ isError(error: unknown): error is UnexpectedResponseError | TransportError | RequestRejectedError | RateLimitError | SigningError;
121
121
  };
122
122
  /**
123
123
  * Creates a new builder API key for the authenticated client.
@@ -137,7 +137,7 @@ declare const CreateBuilderApiKeyError: {
137
137
  declare function createBuilderApiKey(client: BaseSecureClient): Promise<BuilderApiKeyCreds>;
138
138
  type FetchBuilderApiKeysError = RateLimitError | RequestRejectedError | SigningError | TransportError | UnexpectedResponseError;
139
139
  declare const FetchBuilderApiKeysError: {
140
- isError(error: unknown): error is SigningError | TransportError | UnexpectedResponseError | RequestRejectedError | RateLimitError;
140
+ isError(error: unknown): error is UnexpectedResponseError | TransportError | RequestRejectedError | RateLimitError | SigningError;
141
141
  };
142
142
  /**
143
143
  * Fetches builder API keys associated with the authenticated client.
@@ -157,7 +157,7 @@ declare const FetchBuilderApiKeysError: {
157
157
  declare function fetchBuilderApiKeys(client: BaseSecureClient): Promise<BuilderApiKey[]>;
158
158
  type RevokeBuilderApiKeyError = RateLimitError | RequestRejectedError | SigningError | TransportError | UnexpectedResponseError;
159
159
  declare const RevokeBuilderApiKeyError: {
160
- isError(error: unknown): error is SigningError | TransportError | UnexpectedResponseError | RequestRejectedError | RateLimitError;
160
+ isError(error: unknown): error is UnexpectedResponseError | TransportError | RequestRejectedError | RateLimitError | SigningError;
161
161
  };
162
162
  /**
163
163
  * Revokes a builder API key.
@@ -1,2 +1,2 @@
1
- export{La as ApproveErc1155ForAllError,Ha as ApproveErc20Error,Bc as CancelAllError,Dc as CancelMarketOrdersError,xc as CancelOrderError,zc as CancelOrdersError,Zd as ComboPositionStatus,Ra as CreateApiKeyError,$a as CreateBuilderApiKeyError,$c as CreateLimitOrderError,Xc as CreateMarketOrderError,Va as CreateOrDeriveApiKeyError,Za as DeleteApiKeyError,za as DeployDepositWalletError,Gd as DepositToPerpsError,Ta as DeriveApiKeyError,Xd as DownloadAccountingSnapshotError,W as DropNotificationsError,Fc as EstimateMarketPriceError,Xa as FetchApiKeysError,Y as FetchBalanceAllowanceError,bb as FetchBuilderApiKeysError,tb as FetchBuilderFeeRatesError,M as FetchClosedOnlyModeError,Tb as FetchCommentsByIdError,Zb as FetchEventError,bc as FetchEventLiveVolumeError,$b as FetchEventTagsError,ua as FetchExecuteParamsError,Hb as FetchLastTradePriceError,Jb as FetchLastTradePricesError,nc as FetchMarketError,rb as FetchMarketInfoError,pc as FetchMarketTagsError,hb as FetchMidpointError,jb as FetchMidpointsError,nb as FetchNegRiskError,U as FetchNotificationsError,zb as FetchOrderBookError,Bb as FetchOrderBooksError,Q as FetchOrderError,aa as FetchOrderScoringError,ca as FetchOrdersScoringError,td as FetchPerpsBookError,Bd as FetchPerpsFeesError,nd as FetchPerpsInstrumentsError,pd as FetchPerpsTickerError,rd as FetchPerpsTickersError,Td as FetchPortfolioValueError,vb as FetchPriceError,Lb as FetchPriceHistoryError,xb as FetchPricesError,Ee as FetchPublicProfileError,kf as FetchRelatedTagResourcesError,if as FetchRelatedTagsError,ka as FetchRewardPercentagesError,Ze as FetchSeriesError,bf as FetchSportsMarketTypesError,Db as FetchSpreadError,Fb as FetchSpreadsError,gf as FetchTagError,lb as FetchTickSizeError,ga as FetchTotalEarningsForUserForDayError,Vd as FetchTradedMarketCountError,ya as GaslessTransactionMetadataSchema,wa as IsWalletDeployedError,S as ListAccountTradesError,oa as ListActivityError,dc as ListBuilderLeaderboardError,fb as ListBuilderTradesError,fc as ListBuilderVolumeError,Pd as ListClosedPositionsError,lc as ListComboMarketsError,Qd as ListComboPositionsError,Vb as ListCommentsByUserAddressError,Rb as ListCommentsError,Nb as ListCurrentRewardsError,Xb as ListEventsError,rc as ListMarketHoldersError,vc as ListMarketPositionsError,Pb as ListMarketRewardsError,jc as ListMarketsError,tc as ListOpenInterestError,O as ListOpenOrdersError,vd as ListPerpsCandlesError,xd as ListPerpsFundingHistoryError,zd as ListPerpsTradesError,Nd as ListPositionsError,Xe as ListSeriesError,$e as ListSportsError,ef as ListTagsError,mf as ListTeamsError,hc as ListTraderLeaderboardError,ma as ListTradesError,ia as ListUserEarningsAndMarketsConfigError,ea as ListUserEarningsForDayError,ve as MergeComboPositionError,ue as MergeMarketPositionError,te as MergePositionsError,Dd as OpenPerpsSessionError,Me as OpenRfqSessionError,bd as PlaceLimitOrderError,Zc as PlaceMarketOrderError,Ic as PostOrderError,Jc as PostOrdersError,Ja as PrepareErc1155ApprovalForAllError,Fa as PrepareErc20ApprovalError,of as PrepareErc20TransferError,Ca as PrepareGaslessTransactionError,Rc as PrepareLimitOrderError,Vc as PrepareLimitOrderPostingError,Pc as PrepareMarketOrderError,Tc as PrepareMarketOrderPostingError,de as PrepareMergeComboPositionError,ce as PrepareMergeMarketPositionError,be as PrepareMergePositionsError,Fd as PreparePerpsDepositError,ge as PrepareRedeemComboPositionError,fe as PrepareRedeemMarketPositionsError,ee as PrepareRedeemPositionsError,ae as PrepareSplitComboPositionError,$d as PrepareSplitMarketPositionError,_d as PrepareSplitPositionError,Na as PrepareTradingApprovalsError,Ce as RedeemPositionsError,pb as ResolveConditionByTokenError,db as RevokeBuilderApiKeyError,Ed as RevokePerpsCredentialsError,Je as RfqCancelQuoteError,Ie as RfqCancelQuoteRejectedError,Oe as RfqConfirmationDecision,Le as RfqConfirmationError,Ke as RfqConfirmationRejectedError,Pe as RfqDirection,Qe as RfqErrorCode,Re as RfqExecutionStatus,He as RfqQuoteError,Ge as RfqQuoteRejectedError,Se as RfqRequestedSizeUnit,Te as RfqSide,Ve as SearchError,Ue as SearchSort,Pa as SetupTradingApprovalsError,me as SplitComboPositionError,le as SplitMarketPositionError,ke as SplitPositionError,qf as TransferErc20Error,_ as UpdateBalanceAllowanceError,kd as UpdatePerpsLeverageError,ld as UpdatePerpsMarginError,Ea as WaitForGaslessTransactionError,Hd as WithdrawFromPerpsError,Ma as approveErc1155ForAll,Ia as approveErc20,Cc as cancelAll,Ec as cancelMarketOrders,yc as cancelOrder,Ac as cancelOrders,Sa as createApiKey,ab as createBuilderApiKey,ad as createLimitOrder,Yc as createMarketOrder,Wa as createOrDeriveApiKey,_a as deleteApiKey,Aa as deployDepositWallet,Ld as depositToPerps,Ua as deriveApiKey,Yd as downloadAccountingSnapshot,X as dropNotifications,Gc as estimateMarketPrice,Ya as fetchApiKeys,Z as fetchBalanceAllowance,cb as fetchBuilderApiKeys,ub as fetchBuilderFeeRates,gc as fetchBuilderVolume,N as fetchClosedOnlyMode,Ub as fetchCommentsById,_b as fetchEvent,cc as fetchEventLiveVolume,ac as fetchEventTags,va as fetchExecuteParams,Ib as fetchLastTradePrice,Kb as fetchLastTradePrices,oc as fetchMarket,sb as fetchMarketInfo,qc as fetchMarketTags,ib as fetchMidpoint,kb as fetchMidpoints,ob as fetchNegRisk,V as fetchNotifications,R as fetchOrder,Ab as fetchOrderBook,Cb as fetchOrderBooks,ba as fetchOrderScoring,da as fetchOrdersScoring,ud as fetchPerpsBook,Cd as fetchPerpsFees,od as fetchPerpsInstruments,qd as fetchPerpsTicker,sd as fetchPerpsTickers,Ud as fetchPortfolioValue,wb as fetchPrice,Mb as fetchPriceHistory,yb as fetchPrices,Fe as fetchPublicProfile,lf as fetchRelatedTagResources,jf as fetchRelatedTags,la as fetchRewardPercentages,_e as fetchSeries,cf as fetchSportsMarketTypes,Eb as fetchSpread,Gb as fetchSpreads,hf as fetchTag,mb as fetchTickSize,ha as fetchTotalEarningsForUserForDay,Wd as fetchTradedMarketCount,Ba as fetchTransaction,xa as isWalletDeployed,T as listAccountTrades,pa as listActivity,ec as listBuilderLeaderboard,gb as listBuilderTrades,Rd as listClosedPositions,mc as listComboMarkets,Sd as listComboPositions,Sb as listComments,Wb as listCommentsByUserAddress,Ob as listCurrentRewards,Yb as listEvents,sc as listMarketHolders,wc as listMarketPositions,Qb as listMarketRewards,kc as listMarkets,uc as listOpenInterest,P as listOpenOrders,wd as listPerpsCandles,yd as listPerpsFundingHistory,Ad as listPerpsTrades,Od as listPositions,Ye as listSeries,af as listSports,ff as listTags,nf as listTeams,ic as listTraderLeaderboard,na as listTrades,ja as listUserEarningsAndMarketsConfig,fa as listUserEarningsForDay,xe as mergeComboPosition,we as mergeMarketPosition,ye as mergePositions,Id as openPerpsSession,Ne as openRfqSession,cd as placeLimitOrder,_c as placeMarketOrder,Kc as postOrder,Lc as postOrders,Ka as prepareErc1155ApprovalForAll,Ga as prepareErc20Approval,pf as prepareErc20Transfer,Da as prepareGaslessTransaction,Sc as prepareLimitOrder,Wc as prepareLimitOrderPosting,Qc as prepareMarketOrder,Uc as prepareMarketOrderPosting,re as prepareMergeComboPosition,qe as prepareMergeMarketPosition,se as prepareMergePositions,Kd as preparePerpsDeposit,Ae as prepareRedeemComboPosition,ze as prepareRedeemMarketPositions,Be as prepareRedeemPositions,ie as prepareSplitComboPosition,he as prepareSplitMarketPosition,je as prepareSplitPosition,Oa as prepareTradingApprovals,De as redeemPositions,qb as resolveConditionByToken,Hc as resolveEstimatedMarketPrice,eb as revokeBuilderApiKey,Jd as revokePerpsCredentials,We as search,Qa as setupTradingApprovals,Oc as signOrder,oe as splitComboPosition,ne as splitMarketPosition,pe as splitPosition,df as subscribe,rf as transferErc20,$ as updateBalanceAllowance,Md as withdrawFromPerps}from'../chunk-FMBJ7ZRK.js';import'../chunk-E2CLUN5M.js';//# sourceMappingURL=index.js.map
1
+ export{La as ApproveErc1155ForAllError,Ha as ApproveErc20Error,Bc as CancelAllError,Dc as CancelMarketOrdersError,xc as CancelOrderError,zc as CancelOrdersError,Yd as ComboPositionStatus,Ra as CreateApiKeyError,$a as CreateBuilderApiKeyError,$c as CreateLimitOrderError,Xc as CreateMarketOrderError,Va as CreateOrDeriveApiKeyError,Za as DeleteApiKeyError,za as DeployDepositWalletError,Fd as DepositToPerpsError,Ta as DeriveApiKeyError,Wd as DownloadAccountingSnapshotError,W as DropNotificationsError,Fc as EstimateMarketPriceError,Xa as FetchApiKeysError,Y as FetchBalanceAllowanceError,bb as FetchBuilderApiKeysError,tb as FetchBuilderFeeRatesError,M as FetchClosedOnlyModeError,Tb as FetchCommentsByIdError,Zb as FetchEventError,bc as FetchEventLiveVolumeError,$b as FetchEventTagsError,ua as FetchExecuteParamsError,Hb as FetchLastTradePriceError,Jb as FetchLastTradePricesError,nc as FetchMarketError,rb as FetchMarketInfoError,pc as FetchMarketTagsError,hb as FetchMidpointError,jb as FetchMidpointsError,nb as FetchNegRiskError,U as FetchNotificationsError,zb as FetchOrderBookError,Bb as FetchOrderBooksError,Q as FetchOrderError,aa as FetchOrderScoringError,ca as FetchOrdersScoringError,sd as FetchPerpsBookError,Ad as FetchPerpsFeesError,md as FetchPerpsInstrumentsError,od as FetchPerpsTickerError,qd as FetchPerpsTickersError,Sd as FetchPortfolioValueError,vb as FetchPriceError,Lb as FetchPriceHistoryError,xb as FetchPricesError,De as FetchPublicProfileError,jf as FetchRelatedTagResourcesError,hf as FetchRelatedTagsError,ka as FetchRewardPercentagesError,Ye as FetchSeriesError,af as FetchSportsMarketTypesError,Db as FetchSpreadError,Fb as FetchSpreadsError,ff as FetchTagError,lb as FetchTickSizeError,ga as FetchTotalEarningsForUserForDayError,Ud as FetchTradedMarketCountError,ya as GaslessTransactionMetadataSchema,wa as IsWalletDeployedError,S as ListAccountTradesError,oa as ListActivityError,dc as ListBuilderLeaderboardError,fb as ListBuilderTradesError,fc as ListBuilderVolumeError,Od as ListClosedPositionsError,lc as ListComboMarketsError,Pd as ListComboPositionsError,Vb as ListCommentsByUserAddressError,Rb as ListCommentsError,Nb as ListCurrentRewardsError,Xb as ListEventsError,rc as ListMarketHoldersError,vc as ListMarketPositionsError,Pb as ListMarketRewardsError,jc as ListMarketsError,tc as ListOpenInterestError,O as ListOpenOrdersError,ud as ListPerpsCandlesError,wd as ListPerpsFundingHistoryError,yd as ListPerpsTradesError,Md as ListPositionsError,We as ListSeriesError,_e as ListSportsError,df as ListTagsError,lf as ListTeamsError,hc as ListTraderLeaderboardError,ma as ListTradesError,ia as ListUserEarningsAndMarketsConfigError,ea as ListUserEarningsForDayError,ue as MergeComboPositionError,te as MergeMarketPositionError,se as MergePositionsError,Cd as OpenPerpsSessionError,Le as OpenRfqSessionError,bd as PlaceLimitOrderError,Zc as PlaceMarketOrderError,Ic as PostOrderError,Jc as PostOrdersError,Ja as PrepareErc1155ApprovalForAllError,Fa as PrepareErc20ApprovalError,nf as PrepareErc20TransferError,Ca as PrepareGaslessTransactionError,Rc as PrepareLimitOrderError,Vc as PrepareLimitOrderPostingError,Pc as PrepareMarketOrderError,Tc as PrepareMarketOrderPostingError,ce as PrepareMergeComboPositionError,be as PrepareMergeMarketPositionError,ae as PrepareMergePositionsError,Ed as PreparePerpsDepositError,fe as PrepareRedeemComboPositionError,ee as PrepareRedeemMarketPositionsError,de as PrepareRedeemPositionsError,$d as PrepareSplitComboPositionError,_d as PrepareSplitMarketPositionError,Zd as PrepareSplitPositionError,Na as PrepareTradingApprovalsError,Be as RedeemPositionsError,pb as ResolveConditionByTokenError,db as RevokeBuilderApiKeyError,Dd as RevokePerpsCredentialsError,Ie as RfqCancelQuoteError,He as RfqCancelQuoteRejectedError,Ne as RfqConfirmationDecision,Ke as RfqConfirmationError,Je as RfqConfirmationRejectedError,Oe as RfqDirection,Pe as RfqErrorCode,Qe as RfqExecutionStatus,Ge as RfqQuoteError,Fe as RfqQuoteRejectedError,Re as RfqRequestedSizeUnit,Se as RfqSide,Ue as SearchError,Te as SearchSort,Pa as SetupTradingApprovalsError,le as SplitComboPositionError,ke as SplitMarketPositionError,je as SplitPositionError,pf as TransferErc20Error,_ as UpdateBalanceAllowanceError,kd as UpdatePerpsLeverageError,Ea as WaitForGaslessTransactionError,Gd as WithdrawFromPerpsError,Ma as approveErc1155ForAll,Ia as approveErc20,Cc as cancelAll,Ec as cancelMarketOrders,yc as cancelOrder,Ac as cancelOrders,Sa as createApiKey,ab as createBuilderApiKey,ad as createLimitOrder,Yc as createMarketOrder,Wa as createOrDeriveApiKey,_a as deleteApiKey,Aa as deployDepositWallet,Kd as depositToPerps,Ua as deriveApiKey,Xd as downloadAccountingSnapshot,X as dropNotifications,Gc as estimateMarketPrice,Ya as fetchApiKeys,Z as fetchBalanceAllowance,cb as fetchBuilderApiKeys,ub as fetchBuilderFeeRates,gc as fetchBuilderVolume,N as fetchClosedOnlyMode,Ub as fetchCommentsById,_b as fetchEvent,cc as fetchEventLiveVolume,ac as fetchEventTags,va as fetchExecuteParams,Ib as fetchLastTradePrice,Kb as fetchLastTradePrices,oc as fetchMarket,sb as fetchMarketInfo,qc as fetchMarketTags,ib as fetchMidpoint,kb as fetchMidpoints,ob as fetchNegRisk,V as fetchNotifications,R as fetchOrder,Ab as fetchOrderBook,Cb as fetchOrderBooks,ba as fetchOrderScoring,da as fetchOrdersScoring,td as fetchPerpsBook,Bd as fetchPerpsFees,nd as fetchPerpsInstruments,pd as fetchPerpsTicker,rd as fetchPerpsTickers,Td as fetchPortfolioValue,wb as fetchPrice,Mb as fetchPriceHistory,yb as fetchPrices,Ee as fetchPublicProfile,kf as fetchRelatedTagResources,if as fetchRelatedTags,la as fetchRewardPercentages,Ze as fetchSeries,bf as fetchSportsMarketTypes,Eb as fetchSpread,Gb as fetchSpreads,gf as fetchTag,mb as fetchTickSize,ha as fetchTotalEarningsForUserForDay,Vd as fetchTradedMarketCount,Ba as fetchTransaction,xa as isWalletDeployed,T as listAccountTrades,pa as listActivity,ec as listBuilderLeaderboard,gb as listBuilderTrades,Qd as listClosedPositions,mc as listComboMarkets,Rd as listComboPositions,Sb as listComments,Wb as listCommentsByUserAddress,Ob as listCurrentRewards,Yb as listEvents,sc as listMarketHolders,wc as listMarketPositions,Qb as listMarketRewards,kc as listMarkets,uc as listOpenInterest,P as listOpenOrders,vd as listPerpsCandles,xd as listPerpsFundingHistory,zd as listPerpsTrades,Nd as listPositions,Xe as listSeries,$e as listSports,ef as listTags,mf as listTeams,ic as listTraderLeaderboard,na as listTrades,ja as listUserEarningsAndMarketsConfig,fa as listUserEarningsForDay,we as mergeComboPosition,ve as mergeMarketPosition,xe as mergePositions,Hd as openPerpsSession,Me as openRfqSession,cd as placeLimitOrder,_c as placeMarketOrder,Kc as postOrder,Lc as postOrders,Ka as prepareErc1155ApprovalForAll,Ga as prepareErc20Approval,of as prepareErc20Transfer,Da as prepareGaslessTransaction,Sc as prepareLimitOrder,Wc as prepareLimitOrderPosting,Qc as prepareMarketOrder,Uc as prepareMarketOrderPosting,qe as prepareMergeComboPosition,pe as prepareMergeMarketPosition,re as prepareMergePositions,Jd as preparePerpsDeposit,ze as prepareRedeemComboPosition,ye as prepareRedeemMarketPositions,Ae as prepareRedeemPositions,he as prepareSplitComboPosition,ge as prepareSplitMarketPosition,ie as prepareSplitPosition,Oa as prepareTradingApprovals,Ce as redeemPositions,qb as resolveConditionByToken,Hc as resolveEstimatedMarketPrice,eb as revokeBuilderApiKey,Id as revokePerpsCredentials,Ve as search,Qa as setupTradingApprovals,Oc as signOrder,ne as splitComboPosition,me as splitMarketPosition,oe as splitPosition,cf as subscribe,qf as transferErc20,$ as updateBalanceAllowance,Ld as withdrawFromPerps}from'../chunk-AYGGMWA6.js';import'../chunk-E2CLUN5M.js';//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import {k,e,d,j,c,b,a,f as f$1,g as g$1,h as h$1,i}from'./chunk-E2CLUN5M.js';import {PaginationCursorSchema,TransactionIdSchema,EvmAddressSchema,BuilderCodeSchema,TokenIdSchema,CtfConditionIdSchema,OrderSideSchema,CommentParentEntityTypeSchema,EventIdSchema,CommentIdSchema,IsoDateTimeStringSchema,IsoCalendarDateStringSchema,PositionIdSchema,OrderType,PositiveDecimalNumberSchema,OrderSide,TxHashSchema,ComboConditionIdSchema,MarketIdSchema,toDecimalString,toComboConditionId,toPositionId,toPaginationCursor}from'@polymarket/bindings';import {AssetTypeSchema,PriceHistoryIntervalSchema,SignatureType,AssetType,ClosedOnlyModeSchema,OpenOrdersPageSchema,END_CURSOR,OpenOrderSchema,ClobTradesPageSchema,NotificationsResponseSchema,BalanceAllowanceResponseSchema,OrderScoringResponseSchema,OrdersScoringResponseSchema,UserEarningsPageSchema,TotalUserEarningsResponseSchema,UserRewardsEarningsPageSchema,RewardsPercentagesSchema,ApiKeyCredsSchema,ApiKeysResponseSchema,BuilderApiKeyCredsSchema,BuilderApiKeysResponseSchema,PaginatedBuilderTradesSchema,MidpointSchema,MidpointsSchema,FetchTickSizeResponseSchema,FetchNegRiskResponseSchema,ResolveConditionByTokenResponseSchema,FetchMarketInfoResponseSchema,FetchBuilderFeeRatesResponseSchema,PriceSchema,PricesSchema,FetchOrderBookResponseSchema,OrderBooksSchema,SpreadSchema,SpreadsSchema,LastTradePriceSchema,LastTradePricesSchema,PriceHistorySchema,PaginatedCurrentRewardsSchema,PaginatedMarketRewardsSchema,CancelOrdersResponseSchema,OrderResponseSchema,OrderResponsesSchema}from'@polymarket/bindings/clob';import {isHexString,expectNonEmptyArray,isPrivateKey,expectEvmAddress,PolymarketError,expectHexString,isSameEvmAddress,never,unwrap,invariant,delay,expectEvmSignature,ZERO_ADDRESS,expectErc1271Signature,ResultAsync,setNonBlockingInterval,setNonBlockingTimeout,expectPresent,expectPrivateKey,isPresent,ok,err}from'@polymarket/types';import {z}from'zod';import {WalletType,SeriesIdSchema,ListCommentsResponseSchema,ListEventsKeysetResponseSchema,EventSchema,FetchEventTagsResponseSchema,ListMarketsKeysetResponseSchema,FetchMarketTagsResponseSchema,MarketSchema,PublicProfileSchema,PublicSearchResponseSchema,ListSeriesResponseSchema,SeriesSchema,ListSportsMetadataResponseSchema,SportsMarketTypesResponseSchema,ListTagsResponseSchema,TagSchema,ListRelatedTagsResponseSchema,ListRelatedTagResourcesResponseSchema,ListTeamsResponseSchema}from'@polymarket/bindings/gamma';import {AbiFunction,Hash,Bytes,AbiParameters,ContractAddress,TypedData,Secp256k1,Address,Signature}from'ox';import Jt from'ky';import {SideSchema,ActivityTypeSchema,TimePeriodSchema,LeaderboardOrderBySchema,LeaderboardCategorySchema,ComboPositionStatusSchema,ListTradesResponseSchema,ListActivityResponseSchema,FetchEventLiveVolumeResponseSchema,ListBuilderLeaderboardResponseSchema,ListBuilderVolumeResponseSchema,ListTraderLeaderboardResponseSchema,ListMarketHoldersResponseSchema,ListOpenInterestResponseSchema,ListMarketPositionsResponseSchema,ListPositionsResponseSchema,ListClosedPositionsResponseSchema,ListComboPositionsResponseSchema,FetchPortfolioValueResponseSchema,TradedSchema}from'@polymarket/bindings/data';export{ComboPositionStatus as Yd}from'@polymarket/bindings/data';import {RelayerTransactionType,RelayerExecuteRequestSchema,RelayerTransactionState,RelayerExecuteParamsSchema,RelayerDeployedResponseSchema,GaslessTransactionSchema,RelayerExecuteResponseSchema}from'@polymarket/bindings/relayer';import {ListComboMarketsResponseSchema}from'@polymarket/bindings/rfq';export{RfqConfirmationDecision as Ne,RfqDirection as Oe,RfqErrorCode as Pe,RfqExecutionStatus as Qe,RfqRequestedSizeUnit as Re,RfqSide as Se}from'@polymarket/bindings/rfq';import {PerpsPnlIntervalSchema,PerpsWithdrawalStatusSchema,PerpsDepositStatusSchema,PerpsInstrumentIdSchema,PerpsClientOrderIdSchema,PerpsOrderIdSchema,PerpsDecimalInputSchema,PerpsTimeInForce,PerpsCommandAckSchema,PerpsInstrumentCategorySchema,PerpsInstrumentTypeSchema,PerpsKlineIntervalSchema,PerpsTradeIdSchema,PerpsPostOrderAckSchema,PerpsTpSlKind,PerpsTpSlScope,PerpsCancelOrderResultSchema,PerpsUpdateLeverageResultSchema,FetchPerpsBalancesResponseSchema,FetchPerpsPortfolioResponseSchema,FetchPerpsAccountStatsResponseSchema,FetchPerpsAccountConfigResponseSchema,FetchPerpsOpenOrdersResponseSchema,FetchPerpsOrdersResponseSchema,ListPerpsFillsResponseSchema,ListPerpsFundingPaymentsResponseSchema,ListPerpsDepositsResponseSchema,ListPerpsWithdrawalsResponseSchema,ListPerpsEquityHistoryResponseSchema,ListPerpsPnlHistoryResponseSchema,FetchPerpsInstrumentsResponseSchema,FetchPerpsTickersResponseSchema,FetchPerpsStatisticsResponseSchema,PerpsBookSchema,FetchPerpsCandlesResponseSchema,FetchPerpsFundingHistoryResponseSchema,FetchPerpsTradesResponseSchema,FetchPerpsFeesResponseSchema,PerpsDeleteProxyResponseSchema,PerpsWithdrawResponseSchema,PerpsCreateProxyResponseSchema,PerpsCredentialsResponseSchema}from'@polymarket/bindings/perps';import {encode}from'@msgpack/msgpack';import {PerpsSessionUpdateEventSchema}from'@polymarket/bindings/subscriptions';import {pushable}from'it-pushable';import Cy from'it-merge';function l(e,r){let t=r.safeParse(e);if(t.success)return t.data;throw a.fromZodError(t.error)}var A=z.number().int().positive(),$t=z.object({offset:z.number().int().min(0),pageSize:A});function x(e,r,t=[]){function o(){return {async firstPage(){return {items:t,hasMore:false}},from(){return o()},async*[Symbol.asyncIterator](){}}}function n(s=r){return {firstPage(){return unwrap(e(s))},from(a){return a===void 0?o():n(a)},async*[Symbol.asyncIterator](){let a=s;for(;;){let y=await unwrap(e(a));if(yield y,!y.hasMore)return;a=y.nextCursor;}}}}return n()}function F(e){return toPaginationCursor(btoa(JSON.stringify($t.parse(e))))}function U(e,r){if(e===void 0)return {offset:0,pageSize:r};try{return $t.parse(JSON.parse(atob(e)))}catch(t){throw new a("Invalid pagination cursor",{cause:t})}}function f(e){return function(t){return ResultAsync.fromPromise(t.json(),()=>new b(`Received non-JSON response from ${t.url}`)).andThen(o=>qa(t.url,e,o))}}function Yt(e){return ResultAsync.fromPromise(e.blob(),()=>new b(`Received unreadable binary response from ${e.url}`))}function qa(e,r,t){let o=r.safeParse(t);return o.success?ok(o.data):err(b.fromZodError(o.error,{endpoint:e}))}var Zt=class{#e;constructor({url:r}){this.#e=r;}async ethCall(r){let t=await this.#n({jsonrpc:"2.0",id:1,method:"eth_call",params:[{to:r.to,data:r.data},"latest"]});if("error"in t)throw new d(`JSON-RPC eth_call failed: ${t.error.message}`,{cause:t.error,status:200});if(typeof t.result!="string")throw new b("Expected JSON-RPC eth_call result to be a hex string");if(!to(t.result))throw new b("Expected JSON-RPC eth_call result to be a hex string");return t.result}async ethCallBatch(r){return r.length===0?[]:this.#r(r)}async#r(r){if(r.length===1)return [await this.ethCall(r[0])];try{return await this.#t(r)}catch(t){if(!(t instanceof d)||t.status<500)throw t;let o=Math.ceil(r.length/2),[n,s]=await Promise.all([this.#r(r.slice(0,o)),this.#r(r.slice(o))]);return [...n,...s]}}async#t(r){let t=await this.#o(r.map((n,s)=>({jsonrpc:"2.0",id:s+1,method:"eth_call",params:[{to:n.to,data:n.data},"latest"]}))),o=new Map;for(let n of t){if("error"in n&&n.id===null)throw new d(`JSON-RPC eth_call failed: ${n.error.message}`,{cause:n.error,status:200});n.id!==null&&o.set(n.id,n);}return r.map((n,s)=>{let a=s+1,y=o.get(a);if(y===void 0)throw new b("Expected JSON-RPC batch response for every request");if("error"in y)throw new d(`JSON-RPC eth_call failed: ${y.error.message}`,{cause:y.error,status:200});return va(y.result)})}async#n(r){let t;try{t=await Jt.post(this.#e,{json:r,throwHttpErrors:!1});}catch(n){throw c.fromError(n)}if(!t.ok)throw new d(`JSON-RPC request to ${this.#e} failed with status ${t.status}`,{status:t.status});let o;try{o=await t.json();}catch(n){throw new b("Expected JSON-RPC response body to be JSON",{cause:n})}if(!Qt(o))throw new b("Unexpected JSON-RPC response shape");return o}async#o(r){let t;try{t=await Jt.post(this.#e,{json:r,throwHttpErrors:!1});}catch(n){throw c.fromError(n)}if(!t.ok)throw new d(`JSON-RPC request to ${this.#e} failed with status ${t.status}`,{status:t.status});let o;try{o=await t.json();}catch(n){throw new b("Expected JSON-RPC response body to be JSON",{cause:n})}if(!Array.isArray(o)||!o.every(n=>Qt(n)))throw new b("Unexpected JSON-RPC response shape");return o}};function Xt(e){if(!(e instanceof d)||!eo(e.cause))return false;let r=[e.cause.message,Aa(e.cause.data)].join(" ").toLowerCase();return (e.cause.code===3||e.cause.code===-32e3||e.cause.code===-32003||e.cause.code===-32015||e.cause.code===-32603)&&(r.includes("execution reverted")||r.includes("revert")||r.includes("invalid opcode"))}function Qt(e){return !ro(e)||e.jsonrpc!=="2.0"?false:"error"in e?eo(e.error):"result"in e}function eo(e){return ro(e)&&typeof e.code=="number"&&typeof e.message=="string"}function ro(e){return typeof e=="object"&&e!==null}function to(e){return /^0x[a-fA-F0-9]*$/.test(e)}function va(e){if(typeof e!="string"||!to(e))throw new b("Expected JSON-RPC eth_call result to be a hex string");return e}function Aa(e){if(e===void 0)return "";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return ""}}function aP(e,r,t){return {signer:r,wallet:t,walletType:Ya(e,r,t)}}function pe(e){switch(e){case WalletType.EOA:return SignatureType.EOA;case WalletType.POLY_PROXY:return SignatureType.POLY_PROXY;case WalletType.GNOSIS_SAFE:return SignatureType.POLY_GNOSIS_SAFE;case WalletType.DEPOSIT_WALLET:return SignatureType.POLY_1271}}function oo(e){let r=pe(e.walletType);return {maker:e.wallet,signatureType:r,signer:r===SignatureType.POLY_1271?e.wallet:e.signer}}var wa="3d3d606380380380913d393d73%s5af4602a57600080fd5b602d8060366000396000f3363d3d373d3d3d363d73%s5af43d82803e903d91602b57fd5bf352e831dd00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000";function La(e){let r=wa.replace("%s",e.proxyFactory.slice(2).toLowerCase()).replace("%s",e.proxyImplementation.slice(2).toLowerCase());return expectHexString(Hash.keccak256(`0x${r}`))}function Ma(e,r){return expectEvmAddress(ContractAddress.fromCreate2({bytecodeHash:La(r),from:r.proxyFactory,salt:Hash.keccak256(AbiParameters.encodePacked(["address"],[e]))}))}function Fa(e,r){return expectEvmAddress(ContractAddress.fromCreate2({bytecodeHash:r.safeInitCodeHash,from:r.safeFactory,salt:Hash.keccak256(AbiParameters.encode([{name:"address",type:"address"}],[e]))}))}var Ba="0xcc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3",Ua="0x5155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076",Da=0x61003d3d8160233d3973n;function no(e,r){let t=expectHexString(`0x${e.slice(2).padStart(64,"0")}`),o=AbiParameters.encode([{type:"address"},{type:"bytes32"}],[r.depositWalletFactory,t]);return expectEvmAddress(ContractAddress.fromCreate2({bytecodeHash:Na(r.depositWalletImplementation,o),from:r.depositWalletFactory,salt:Hash.keccak256(o)}))}var za="0xb3582b35133d50545afa5036515af43d6000803e604d573d6000fd5b3d6000f3",ja="0x1b60e01b36527fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6c",Wa="0x60195155f3363d3d373d3d363d602036600436635c60da",Ha=0x6100523d8160233d3973n,_a="0x49493a4d";function so(e,r){let t=expectHexString(`0x${e.slice(2).padStart(64,"0")}`),o=AbiParameters.encode([{type:"address"},{type:"bytes32"}],[r.depositWalletFactory,t]);return expectEvmAddress(ContractAddress.fromCreate2({bytecodeHash:Ga(r.depositWalletBeacon,o),from:r.depositWalletFactory,salt:Hash.keccak256(o)}))}function Na(e,r){let t=BigInt((r.length-2)/2),o=Da+(t<<56n);return expectHexString(Hash.keccak256(Bytes.concat(Bytes.fromNumber(o,{size:10}),Bytes.fromHex(e),Bytes.fromHex("0x6009"),Bytes.fromHex(Ua),Bytes.fromHex(Ba),Bytes.fromHex(r)),{as:"Hex"}))}function Ga(e,r){let t=BigInt((r.length-2)/2),o=Ha+(t<<56n);return expectHexString(Hash.keccak256(Bytes.concat(Bytes.fromNumber(o,{size:10}),Bytes.fromHex(e),Bytes.fromHex(Wa),Bytes.fromHex(ja),Bytes.fromHex(za),Bytes.fromHex(r)),{as:"Hex"}))}async function Ka(e,r){try{let t=await e.ethCall({to:r,data:_a});return Va(t)}catch(t){if(Xt(t))return ZERO_ADDRESS;throw t}}async function $a(e,r){let t=await Ka(e,r);return !isSameEvmAddress(t,ZERO_ADDRESS)}async function ao(e,r,t){return await $a(e,t.depositWalletFactory)?so(r,t):no(r,t)}function Va(e){return e.length<66?ZERO_ADDRESS:expectEvmAddress(`0x${e.slice(-40)}`)}function Ya(e,r,t){if(isSameEvmAddress(t,r))return WalletType.EOA;let o=e.walletDerivation;if(isSameEvmAddress(t,so(r,o)))return WalletType.DEPOSIT_WALLET;if(isSameEvmAddress(t,no(r,o)))return WalletType.DEPOSIT_WALLET;if(isSameEvmAddress(t,Fa(r,o)))return WalletType.GNOSIS_SAFE;if(isSameEvmAddress(t,Ma(r,o)))return WalletType.POLY_PROXY;never(`Wallet ${t} does not match the signer ${r} or any supported deterministic wallet address.`);}function g(e,r){if(Ja(r))return Za(e,r.exceptions);let t=new URLSearchParams;for(let[o,n]of Object.entries(r)){let s=e[o];if(s!==void 0){if(io(s)){for(let a of s)t.append(n,we(a));continue}t.append(n,we(s));}}return t}function h(e={}){return {format:"snake_case",exceptions:e}}function W(e){let r=new URLSearchParams;for(let[t,o]of Object.entries(e))if(o!==void 0){if(Array.isArray(o)){r.append(t,o.map(we).join(","));continue}r.append(t,we(o));}return r}function Ja(e){return "format"in e}function Za(e,r){let t=new URLSearchParams;for(let[o,n]of Object.entries(e)){if(n===void 0)continue;let s=r[o]??Qa(o);if(io(n)){for(let a of n)t.append(s,we(a));continue}t.append(s,we(n));}return t}function io(e){return Array.isArray(e)}function Qa(e){return e.replace(/[A-Z]/g,r=>`_${r.toLowerCase()}`)}function we(e){return String(e)}var EP=k(e,d,j,c,b);async function hP(e){return (await unwrap(e.secureClob.get("/auth/ban-status/closed-only").andThen(f(ClosedOnlyModeSchema)))).closedOnly}var ui=z.object({tokenId:z.string().optional(),cursor:PaginationCursorSchema.optional(),id:z.string().optional(),market:z.string().optional()}).default({}),SP=k(e,d,j,c,b,a);function TP(e,r){let{cursor:t,...o}=l(r,ui);return x(n=>e.secureClob.get("/data/orders",{params:g({...o,nextCursor:n},h({tokenId:"asset_id"}))}).andThen(f(OpenOrdersPageSchema)).map(s=>({items:s.data,hasMore:s.nextCursor!==END_CURSOR,nextCursor:s.nextCursor===END_CURSOR?void 0:toPaginationCursor(s.nextCursor),totalCount:s.count})),t)}var mi=z.object({orderId:z.string()}),xP=k(e,d,j,c,b,a);async function CP(e,r){let t=l(r,mi);return unwrap(e.secureClob.get(`/data/order/${t.orderId}`).andThen(f(OpenOrderSchema)))}var li={after:z.string().optional(),tokenId:z.string().optional(),before:z.string().optional(),cursor:PaginationCursorSchema.optional(),id:z.string().optional(),makerAddress:z.string().optional(),market:z.string().optional()},fi=z.object(li).default({}),kP=k(e,d,j,c,b,a);function bP(e,r){let{cursor:t,...o}=l(r,fi);return x(n=>e.secureClob.get("/data/trades",{params:g({...o,nextCursor:n},h({tokenId:"asset_id"}))}).andThen(f(ClobTradesPageSchema)).map(s=>({items:s.data,hasMore:s.nextCursor!==END_CURSOR,nextCursor:s.nextCursor===END_CURSOR?void 0:toPaginationCursor(s.nextCursor),totalCount:s.count})),t)}var IP=k(e,d,j,c,b),yi=z.object({ids:z.array(z.string()).min(1)});async function qP(e){let r=pe(e.account.walletType);return unwrap(e.secureClob.get("/notifications",{params:g({signatureType:r},h())}).andThen(f(NotificationsResponseSchema)))}var vP=k(e,d,j,c,b,a);async function AP(e,r){let t=l(r,yi),o=pe(e.account.walletType),n=g({ids:t.ids.join(","),signatureType:o},h());await unwrap(e.secureClob.del("/notifications",{params:n}));}var Pi=z.object({assetType:AssetTypeSchema,tokenId:z.string().optional()}),OP=k(e,d,j,c,b,a);async function Nr(e,r){let t=l(r,Pi),o=pe(e.account.walletType);return unwrap(e.secureClob.get("/balance-allowance",{params:g({...t,signatureType:o},h())}).andThen(f(BalanceAllowanceResponseSchema)))}var gi=z.object({assetType:AssetTypeSchema,tokenId:z.string().optional()}),wP=k(e,d,j,c,b,a);async function co(e,r){let t=l(r,gi),o=pe(e.account.walletType),n=g({...t,signatureType:o},h());return await unwrap(e.secureClob.get("/balance-allowance/update",{params:n})),Nr(e,t)}var Ri=z.object({orderId:z.string()}),LP=k(e,d,j,c,b,a);async function MP(e,r){let t=l(r,Ri);return (await unwrap(e.secureClob.get("/order-scoring",{params:g(t,h())}).andThen(f(OrderScoringResponseSchema)))).scoring}var Ei=z.object({orderIds:z.array(z.string())}),FP=k(e,d,j,c,b,a);async function BP(e,r){let o=l(r,Ei).orderIds;return unwrap(e.secureClob.post("/orders-scoring",{json:o}).andThen(f(OrdersScoringResponseSchema)))}var uo=z.object({cursor:PaginationCursorSchema.optional(),date:z.string()}),UP=k(e,d,j,c,b,a);function DP(e,r){let{cursor:t,...o}=l(r,uo),n=pe(e.account.walletType);return x(s=>e.secureClob.get("/rewards/user",{params:g({...o,nextCursor:s,signatureType:n},h())}).andThen(f(UserEarningsPageSchema)).map(a=>({items:a.data,hasMore:a.nextCursor!==END_CURSOR,nextCursor:a.nextCursor===END_CURSOR?void 0:toPaginationCursor(a.nextCursor),totalCount:a.count})),t)}var zP=k(e,d,j,c,b,a);async function jP(e,r){let t=l(r,uo),o=pe(e.account.walletType);return unwrap(e.secureClob.get("/rewards/user/total",{params:g({...t,signatureType:o},h())}).andThen(f(TotalUserEarningsResponseSchema)))}var hi=z.object({cursor:PaginationCursorSchema.optional(),date:z.string(),noCompetition:z.boolean().optional(),orderBy:z.string().optional(),pageSize:A.max(500).default(100),position:z.string().optional()}),WP=k(e,d,j,c,b,a);function HP(e,r){let{cursor:t,...o}=l(r,hi),n=pe(e.account.walletType);return x(s=>e.secureClob.get("/rewards/user/markets",{params:g({...o,nextCursor:s,signatureType:n},h())}).andThen(f(UserRewardsEarningsPageSchema)).map(a=>({items:a.data,hasMore:a.nextCursor!==END_CURSOR,nextCursor:a.nextCursor===END_CURSOR?void 0:toPaginationCursor(a.nextCursor),totalCount:a.count})),t)}var _P=k(e,d,j,c,b);async function NP(e){let r=pe(e.account.walletType);return unwrap(e.secureClob.get("/rewards/user/percentages",{params:g({signatureType:r},h())}).andThen(f(RewardsPercentagesSchema)))}var Ci=z.enum(["TIMESTAMP","TOKENS","CASH"]),ki=z.enum(["ASC","DESC"]),bi=z.enum(["CASH","TOKENS"]),Ii=z.object({cursor:PaginationCursorSchema.optional(),pageSize:A.default(20),takerOnly:z.boolean().optional(),filterType:bi.optional(),filterAmount:z.number().optional(),market:z.array(z.string()).optional(),eventId:z.array(z.number().int()).optional(),user:z.string().optional(),side:SideSchema.optional()}).refine(e=>!(e.market&&e.eventId),{message:"Provide market or eventId, not both",path:["eventId"]}).refine(e=>e.filterType===void 0==(e.filterAmount===void 0),{message:"Provide filterType and filterAmount together",path:["filterAmount"]}),qi=z.object({cursor:PaginationCursorSchema.optional(),pageSize:A.default(20),user:z.string(),market:z.array(z.string()).optional(),eventId:z.array(z.number().int()).optional(),type:z.array(ActivityTypeSchema).optional(),start:z.number().int().optional(),end:z.number().int().optional(),sortBy:Ci.optional(),sortDirection:ki.optional(),side:SideSchema.optional()}).refine(e=>!(e.market&&e.eventId),{message:"Provide market or eventId, not both",path:["eventId"]}),eg=k(e,d,c,b,a);function rg(e,r={}){let{cursor:t,pageSize:o,...n}=l(r,Ii);return x(s=>{let a=U(s,o);return e.data.get("/trades",{params:W({...n,limit:a.pageSize+1,offset:a.offset})}).andThen(f(ListTradesResponseSchema)).map(y=>{let P=y.length>a.pageSize;return {items:y.slice(0,a.pageSize),hasMore:P,nextCursor:P?F({offset:a.offset+a.pageSize,pageSize:a.pageSize}):void 0}})},t)}var tg=k(e,d,c,b,a);function og(e,r){let{cursor:t,pageSize:o,...n}=l(r,qi);return x(s=>{let a=U(s,o);return e.data.get("/activity",{params:W({...n,limit:a.pageSize+1,offset:a.offset})}).andThen(f(ListActivityResponseSchema)).map(y=>{let P=y.length>a.pageSize;return {items:y.slice(0,a.pageSize),hasMore:P,nextCursor:P?F({offset:a.offset+a.pageSize,pageSize:a.pageSize}):void 0}})},t)}var Ai=64,Oi=/^0x[0-9a-fA-F]{62}$/,wi=/^0x[0-9a-fA-F]{64}$/,Gr="0x0000000000000000000000000000000000000000000000000000000000000000",Li=AbiFunction.from("function approve(address spender, uint256 amount)"),yo=AbiFunction.from("function allowance(address owner, address spender) view returns (uint256)"),Mi=AbiFunction.from("function transfer(address recipient, uint256 amount)"),Fi=AbiFunction.from("function deposit(address token, uint256 amount, address to)"),Bi=AbiFunction.from("function setApprovalForAll(address operator, bool approved)"),Po=AbiFunction.from("function isApprovedForAll(address account, address operator) view returns (bool)"),go=AbiFunction.from("function balanceOf(address account, uint256 id) view returns (uint256)"),Ro=AbiFunction.from("function balanceOfBatch(address[] accounts, uint256[] ids) view returns (uint256[])"),Ui=AbiFunction.from("function splitPosition(address collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint256[] partition, uint256 amount)"),Di=AbiFunction.from("function mergePositions(address collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint256[] partition, uint256 amount)"),zi=AbiFunction.from("function redeemPositions(address collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint256[] indexSets)"),ji=AbiFunction.from("function split(bytes31 conditionId, uint256 amount)"),Wi=AbiFunction.from("function merge(bytes31 conditionId, uint256 amount)"),Hi=AbiFunction.from("function redeem(bytes31 conditionId, uint256 outcomeIndex, uint256 amount)"),_i=AbiFunction.from("function prepareCondition(uint256[] legs) returns (bytes31)"),Ni=AbiFunction.from("function multiSend(bytes)"),Gi=AbiFunction.from("function proxy((uint8 typeCode, address to, uint256 value, bytes data)[] calls) returns (bytes[])"),Eo=[1n,2n],Ki=[1n,2n],Y=(1n<<256n)-1n,pg=k(a);function mr(e,r,t){if(t<0n)throw new a("Approval amount must be non-negative");if(t>Y)throw new a("Approval amount exceeds uint256 range");return {data:$i(r,t),to:e}}function ho(e,r,t){return {data:AbiFunction.encodeData(yo,[r,t]),to:e}}function So(e){return AbiFunction.decodeResult(yo,e)}function lr(e,r,t){return {data:Vi(r,t),to:e}}function To(e,r,t){return {data:AbiFunction.encodeData(Po,[r,t]),to:e}}function xo(e){return AbiFunction.decodeResult(Po,e)}function Co(e,r,t){return {data:AbiFunction.encodeData(go,[r,Pe(BigInt(t),"Position ID")]),to:e}}function ko(e){return AbiFunction.decodeResult(go,e)}function Kr(e,r,t){return {data:AbiFunction.encodeData(Ro,[t.map(()=>r),t.map(o=>Pe(BigInt(o),"id"))]),to:e}}function $r(e){return AbiFunction.decodeResult(Ro,e)}var cg=k(a);function Vr(e,r,t){if(t<0n)throw new a("Transfer amount must be non-negative");if(t>Y)throw new a("Transfer amount exceeds uint256 range");return {data:Yi(r,t),to:e}}var dg=k(a);function bo(e,r,t,o){if(t<=0n)throw new a("Perps deposit amount must be positive");return {data:AbiFunction.encodeData(Fi,[r,Pe(t,"Perps deposit amount"),o]),to:e}}var ug=k(a),mg=k(a);function Io(e,r,t,o){return {data:Ji(r,t,o),to:e}}var lg=k(a);function qo(e,r,t,o){return {data:Zi(r,t,o),to:e}}function vo(e,r,t){return {data:Qi(r,t),to:e}}var fg=k(a);function Ao(e,r,t){return {data:AbiFunction.encodeData(ji,[Jr(r),Pe(t,"Split amount")]),to:e}}var yg=k(a);function Oo(e,r,t){return {data:AbiFunction.encodeData(Wi,[Jr(r),Pe(t,"Merge amount")]),to:e}}var Pg=k(a);function wo(e,r,t,o){return {data:AbiFunction.encodeData(Hi,[Jr(r),BigInt(Xi(t)),Pe(o,"Redeem amount")]),to:e}}var gg=k(a);function Yr(e,r){return {data:AbiFunction.encodeData(_i,[r.map(t=>Pe(t,"Leg position ID"))]),to:e}}function $i(e,r){return invariant(r>=0n,"Approval amount must be non-negative"),AbiFunction.encodeData(Li,[e,r])}function Vi(e,r){return AbiFunction.encodeData(Bi,[e,r])}function Yi(e,r){return AbiFunction.encodeData(Mi,[e,r])}function Ji(e,r,t){return AbiFunction.encodeData(Ui,[e,Gr,r,Eo,Pe(t,"Split amount")])}function Zi(e,r,t){return AbiFunction.encodeData(Di,[e,Gr,r,Eo,Pe(t,"Merge amount")])}function Qi(e,r){return AbiFunction.encodeData(zi,[e,Gr,r,Ki])}function Pe(e,r){if(e<0n)throw new a(`${r} must be non-negative`);if(e>Y)throw new a(`${r} exceeds uint256 range`);return e}function Jr(e){if(Oi.test(e))return e.toLowerCase();if(wi.test(e)){let r=e.toLowerCase();if(r.endsWith("00")||r.endsWith("01"))return r.slice(0,Ai)}throw new a("Protocol v2 condition ID must be bytes31, or bytes32 with a binary outcome byte")}function Xi(e){if(e!==0&&e!==1)throw new a("Protocol v2 outcome index must be 0 or 1");return e}function Lo(e){return AbiFunction.encodeData(Gi,[e.map(r=>({typeCode:1,to:r.to,value:r.value??0n,data:r.data}))])}function Mo(e){let r=e.map(t=>ep(t));return AbiFunction.encodeData(Ni,[r.length===0?"0x":AbiParameters.encodePacked(Array.from({length:r.length},()=>"bytes"),r)])}function ep(e){let r=e.value??0n;return AbiParameters.encodePacked(["uint8","address","uint256","uint256","bytes"],[0,e.to,r,BigInt((e.data.length-2)/2),e.data])}var Sg=k(e,d,f$1,g$1,c,b,a);function _(e,r="Expected a TransactionHandle"){return invariant(typeof e=="object"&&e!==null&&"transactionHash"in e&&"transactionId"in e&&"wait"in e&&typeof e.wait=="function",r),e}k(h$1,j);k(h$1,j);function bg(e){return async function(t){let o=await t.next();for(;!o.done;)try{switch(o.value.kind){case "requestAddress":o=await t.next(await e.getAddress());break;case "signAuthMessage":o=await t.next(await e.signTypedData(o.value.payload));break}}catch(n){o=await t.throw(n);}return o.value}}function H(e){return async function(t){let o=await t.next();for(;!o.done;)try{switch(o.value.kind){case "requestAddress":o=await t.next(await e.getAddress());break;case "signGaslessTypedData":case "signOrder":o=await t.next(await e.signTypedData(o.value.payload));break;case "signGaslessMessage":o=await t.next(await e.signMessage(o.value.payload));break;case "sendErc20ApprovalTransaction":case "sendErc1155ApprovalForAllTransaction":case "sendErc20TransferTransaction":case "sendPerpsDepositTransaction":case "sendMergePositionsTransaction":case "sendRedeemPositionsTransaction":case "sendSplitPositionTransaction":o=await t.next(await e.sendTransaction(o.value.request));break}}catch(n){o=await t.throw(n);}return o.value}}function Fo(){return {kind:"requestAddress"}}function N(e,r){return {chainId:e,...r}}var lp=[{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],fp=[{name:"to",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"},{name:"operation",type:"uint8"},{name:"safeTxGas",type:"uint256"},{name:"baseGas",type:"uint256"},{name:"gasPrice",type:"uint256"},{name:"gasToken",type:"address"},{name:"refundReceiver",type:"address"},{name:"nonce",type:"uint256"}],yp="DepositWallet",Pp="1",gp=600,Rp=[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],Ep=[{name:"wallet",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"calls",type:"Call[]"}],hp=z.object({address:z.string(),type:z.enum(RelayerTransactionType)}),Wg=k(e,d,c,b,a);async function et(e,r){let t=l(r,hp);return unwrap(e.relayer.get("/v1/account/transactions/params",{params:g(t,{address:"address",type:"type"})}).andThen(f(RelayerExecuteParamsSchema)))}var Sp=z.object({transactionId:TransactionIdSchema}),Tp=z.object({wallet:EvmAddressSchema,type:z.enum(WalletType)}),Hg=k(e,d,c,b,a);async function _g(e,r){let t=await xp(e,r);return t.type===WalletType.EOA?false:unwrap(e.relayer.get("/deployed",{params:g({address:t.wallet,type:t.type===WalletType.DEPOSIT_WALLET?RelayerTransactionType.WALLET:void 0},{address:"address",type:"type"})}).andThen(f(RelayerDeployedResponseSchema)).map(({deployed:o})=>o))}async function xp(e,r){if(r!==void 0)return l(r,Tp);if(!e.isSecureClient())throw new a("Gasless readiness inference requires a secure client. Pass a wallet and type when using a public client.");return e.account.walletType!==WalletType.EOA?{wallet:e.account.wallet,type:e.account.walletType}:{wallet:await ao(e.rpc,e.account.signer,e.environment.walletDerivation),type:WalletType.DEPOSIT_WALLET}}var G=z.string().max(500),Bo=10,Ng=k(e,d,c,b,a);async function Gg(e){return invariant(e.supportsGasless,"Deposit Wallet deployment requires a Relayer API Key or Builder API Key in the client configuration."),Pr(e,{from:e.account.signer,metadata:"Deploy Deposit Wallet",to:e.environment.walletDerivation.depositWalletFactory,type:RelayerTransactionType.WALLET_CREATE})}async function Cp(e,r){let t=l(r,Sp);return unwrap(e.relayer.get(`/v1/account/transactions/${t.transactionId}`).andThen(f(GaslessTransactionSchema)))}var kp=z.object({data:z.custom(isHexString),to:EvmAddressSchema,value:z.bigint().optional()}),bp=z.object({calls:z.array(kp).min(1).transform(e=>expectNonEmptyArray(e)),metadata:G}),Kg=k(e,d,c,b,a);async function J(e,r){let t=l(r,bp);return invariant(e.supportsGasless,"Gasless transactions require a Relayer API Key or Builder API Key in the client configuration."),invariant(e.account.walletType===WalletType.GNOSIS_SAFE||e.account.walletType===WalletType.POLY_PROXY||e.account.walletType===WalletType.DEPOSIT_WALLET,"Gasless transaction preparation supports Deposit Wallet, Safe-backed, and proxy-backed accounts"),async function*(){let o=expectEvmAddress(yield Fo());invariant(o===e.account.signer,"Wallet client address does not match the authenticated signer");for(let n=0;n<=Bo;n+=1)try{switch(e.account.walletType){case WalletType.POLY_PROXY:return yield*Ip(e,t);case WalletType.DEPOSIT_WALLET:return yield*qp(e,t);case WalletType.GNOSIS_SAFE:return yield*vp(e,t)}invariant(!1,"Unsupported wallet type for gasless transaction");}catch(s){if(!Ap(s)||n===Bo)throw s;await delay(e.environment.relayerPollFrequencyMs);}invariant(false,"Expected gasless transaction retry loop to return");}.call(null)}async function*Ip(e,r){let t=await et(e,{address:e.account.signer,type:RelayerTransactionType.PROXY}),o=e.environment.walletDerivation.proxyFactory,n=Lo(r.calls),s="0",a="0",y="10000000",P=e.environment.contracts.relayHub,L=ZERO_ADDRESS,q=Up(e.account.signer,o,n,s,a,y,t.nonce,P,L),$=expectEvmSignature(yield zo(q));return Pr(e,{data:n,from:e.account.signer,metadata:r.metadata,nonce:t.nonce,proxyWallet:e.account.wallet,signature:$,signatureParams:{gasLimit:y,gasPrice:a,relay:L,relayHub:P,relayerFee:s},to:o,type:RelayerTransactionType.PROXY})}async function*qp(e,r){let t=await et(e,{address:e.account.signer,type:RelayerTransactionType.WALLET}),o=r.calls.map(Op),n=`${Math.floor(Date.now()/1e3)+gp}`,s=expectEvmSignature(yield Bp(wp({calls:o,chainId:e.environment.chainId,deadline:n,nonce:t.nonce,wallet:e.account.wallet}))),a={depositWalletParams:{calls:o,deadline:n,depositWallet:e.account.wallet},from:e.account.signer,metadata:r.metadata,nonce:t.nonce,signature:s,to:e.environment.walletDerivation.depositWalletFactory,type:RelayerTransactionType.WALLET};return Pr(e,a)}async function*vp(e,r){let t=await et(e,{address:e.account.signer,type:RelayerTransactionType.SAFE}),o=Lp(r.calls,e.environment.contracts.safeMultisend),n=Fp({chainId:e.environment.chainId,data:o.data,nonce:t.nonce,operation:o.operation,safeAddress:e.account.wallet,to:o.to,value:o.value}),s=expectEvmSignature(yield zo(expectHexString(TypedData.getSignPayload(n))));return Pr(e,{data:o.data,from:e.account.signer,metadata:r.metadata,nonce:t.nonce,proxyWallet:e.account.wallet,signature:Dp(s),signatureParams:Mp(o.operation),to:o.to,type:RelayerTransactionType.SAFE,value:o.value>0n?`${o.value}`:void 0})}async function Pr(e,r){let t=l(r,RelayerExecuteRequestSchema),o=await unwrap(e.relayer.post("/submit",{json:t}).andThen(f(RelayerExecuteResponseSchema)));return new Zr(e,o)}function Ap(e$1){if(e$1 instanceof e)return true;if(!(e$1 instanceof d)||e$1.status!==400)return false;if(/wallet busy/i.test(e$1.message)&&/active action/i.test(e$1.message)||/wallet has in-flight action/i.test(e$1.message))return true;let r=/batch nonce\s+(\d+)\s+does not match on-chain nonce\s+(\d+)/i.exec(e$1.message);if(r===null)return false;let t=r[1],o=r[2];return t===void 0||o===void 0?false:BigInt(t)<BigInt(o)}function Op(e){return {data:e.data,target:e.to,value:`${e.value??0n}`}}function wp(e){return {domain:{chainId:e.chainId,name:yp,verifyingContract:e.wallet,version:Pp},message:{calls:e.calls.map(r=>({data:r.data,target:r.target,value:BigInt(r.value)})),deadline:BigInt(e.deadline),nonce:BigInt(e.nonce),wallet:e.wallet},primaryType:"Batch",types:{Batch:Ep,Call:Rp}}}function Lp(e,r){if(e.length===1){let[t]=e;return {data:t.data,operation:0,to:t.to,value:t.value??0n}}return {data:Mo(e),operation:1,to:r,value:0n}}function Mp(e){return {baseGas:"0",gasPrice:"0",gasToken:ZERO_ADDRESS,operation:`${e}`,refundReceiver:ZERO_ADDRESS,safeTxnGas:"0"}}function Fp(e){return {domain:{chainId:e.chainId,verifyingContract:e.safeAddress},message:{baseGas:0n,data:e.data,gasPrice:0n,gasToken:ZERO_ADDRESS,nonce:BigInt(e.nonce),operation:e.operation,refundReceiver:ZERO_ADDRESS,safeTxGas:0n,to:e.to,value:e.value},primaryType:"SafeTx",types:{EIP712Domain:lp,SafeTx:fp}}}function zo(e){return {kind:"signGaslessMessage",payload:e}}function Bp(e){return {kind:"signGaslessTypedData",payload:e}}function Up(e,r,t,o,n,s,a,y,P){return expectHexString(Hash.keccak256(Bytes.concat(Bytes.fromString("rlx:"),Bytes.fromHex(e),Bytes.fromHex(r),Bytes.fromHex(t),Bytes.fromNumber(BigInt(o),{size:32}),Bytes.fromNumber(BigInt(n),{size:32}),Bytes.fromNumber(BigInt(s),{size:32}),Bytes.fromNumber(BigInt(a),{size:32}),Bytes.fromHex(y),Bytes.fromHex(P)),{as:"Hex"}))}function Dp(e){let r=e.slice(2),t=Number.parseInt(r.slice(128,130),16),o=t===0||t===1?t+31:t===27||t===28?t+4:t;return expectHexString(`0x${r.slice(0,128)}${o.toString(16).padStart(2,"0")}`)}var $g=k(e,d,c,b,a,f$1,g$1),Zr=class{#e;transactionHash;transactionId;constructor(r,t){this.#e=r,this.transactionHash=t.transactionHash,this.transactionId=t.transactionId;}async wait(){let r=0;for(;r<this.#e.environment.relayerMaxPolls;){let t=await Cp(this.#e,{transactionId:this.transactionId});if(t.state===RelayerTransactionState.STATE_MINED||t.state===RelayerTransactionState.STATE_CONFIRMED){let o=t.transactionHash??this.transactionHash;if(o===null)throw new b("Expected submitted transaction to have a transaction hash once settled");return {transactionHash:o,transactionId:t.transactionId}}if(t.state===RelayerTransactionState.STATE_FAILED||t.state===RelayerTransactionState.STATE_INVALID)throw new g$1(t.errorMsg??`Transaction ${t.transactionId} reached terminal state ${t.state}`);r+=1,await delay(this.#e.environment.relayerPollFrequencyMs);}throw new f$1(`Timed out waiting for transaction ${this.transactionId} to settle`)}};var zp=z.object({amount:z.union([z.bigint(),z.literal("max")]),metadata:G.optional(),spenderAddress:EvmAddressSchema,tokenAddress:EvmAddressSchema}),nR=k(a);async function jp(e,r){let t=l(r,zp),o=t.amount==="max"?Y:t.amount;return async function*(){return e.account.walletType===WalletType.EOA?_(yield Ho(N(e.environment.chainId,mr(t.tokenAddress,t.spenderAddress,o)))):yield*await J(e,{calls:[mr(t.tokenAddress,t.spenderAddress,o)],metadata:t.metadata??`Approve ${t.amount} of ${t.tokenAddress} to ${t.spenderAddress}`})}.call(null)}var sR=k(h$1,e,d,j,c,b,a);function jo(e,r){return jp(e,r).then(H(e.signer))}var Wp=z.object({approved:z.boolean().default(true),metadata:G.optional(),operatorAddress:EvmAddressSchema,tokenAddress:EvmAddressSchema}),aR=k(a);async function Hp(e,r){let t=l(r,Wp);return async function*(){return e.account.walletType===WalletType.EOA?_(yield _o(N(e.environment.chainId,lr(t.tokenAddress,t.operatorAddress,t.approved)))):yield*await J(e,{calls:[lr(t.tokenAddress,t.operatorAddress,t.approved)],metadata:t.metadata??`${t.approved?"Approve":"Revoke"} ${t.operatorAddress} on ${t.tokenAddress}`})}.call(null)}var iR=k(h$1,e,d,j,c,b,a);function Wo(e,r){return Hp(e,r).then(H(e.signer))}var pR=k(d,c,b,a);async function _p(e){let r=await Gp(e),t=r.erc20.map(n=>mr(n.tokenAddress,n.spenderAddress,n.amount)),o=r.erc1155.map(n=>lr(n.tokenAddress,n.operatorAddress,true));return async function*(){if(t.length===0&&o.length===0)return;if(e.account.walletType===WalletType.EOA){for(let s of t)await _(yield Ho(N(e.environment.chainId,s))).wait();for(let s of o)await _(yield _o(N(e.environment.chainId,s))).wait();return}await(yield*await J(e,{calls:[...t,...o],metadata:"Trading setup approvals"})).wait();}.call(null)}var cR=k(h$1,e,d,j,f$1,g$1,c,b,a);function dR(e){return _p(e).then(H(e.signer)).then(Np)}function Np(){return {transactionHash:null,transactionId:null,wait:async()=>{}}}async function Gp(e){let r=Kp(e),t=[...r.erc20.map(a=>ho(a.tokenAddress,e.account.wallet,a.spenderAddress)),...r.erc1155.map(a=>To(a.tokenAddress,e.account.wallet,a.operatorAddress))],o=await e.rpc.ethCallBatch(t),n=o.slice(0,r.erc20.length),s=o.slice(r.erc20.length);return {erc20:r.erc20.filter((a,y)=>So(n[y])<a.amount),erc1155:r.erc1155.filter((a,y)=>!xo(s[y]))}}function Kp(e){let{contracts:r}=e.environment;return {erc20:[{amount:Y,spenderAddress:r.standardExchange,tokenAddress:r.collateralToken},{amount:Y,spenderAddress:r.negRiskExchange,tokenAddress:r.collateralToken},{amount:Y,spenderAddress:r.negRiskAdapter,tokenAddress:r.collateralToken},{amount:Y,spenderAddress:r.collateralAdapter,tokenAddress:r.collateralToken},{amount:Y,spenderAddress:r.negRiskCollateralAdapter,tokenAddress:r.collateralToken},{amount:Y,spenderAddress:r.protocolV2Router,tokenAddress:r.collateralToken},{amount:Y,spenderAddress:r.exchangeV3,tokenAddress:r.collateralToken},{amount:Y,spenderAddress:r.perpsDepositContract,tokenAddress:r.collateralToken}],erc1155:[{operatorAddress:r.standardExchange,tokenAddress:r.conditionalTokens},{operatorAddress:r.negRiskExchange,tokenAddress:r.conditionalTokens},{operatorAddress:r.negRiskAdapter,tokenAddress:r.conditionalTokens},{operatorAddress:r.collateralAdapter,tokenAddress:r.conditionalTokens},{operatorAddress:r.negRiskCollateralAdapter,tokenAddress:r.conditionalTokens},{operatorAddress:r.autoRedeemOperator,tokenAddress:r.conditionalTokens},{operatorAddress:r.protocolV2Router,tokenAddress:r.positionManager},{operatorAddress:r.exchangeV3,tokenAddress:r.positionManager},{operatorAddress:r.autoRedeemOperator,tokenAddress:r.positionManager}]}}function Ho(e){return {kind:"sendErc20ApprovalTransaction",request:e}}function _o(e){return {kind:"sendErc1155ApprovalForAllTransaction",request:e}}var gR=k(e,d,c,b);async function Jp(e,r){return unwrap(e.clob.post("/auth/api-key",{headers:Ko(r)}).andThen(f(ApiKeyCredsSchema)))}var RR=k(e,d,c,b);async function Zp(e,r){return unwrap(e.clob.get("/auth/derive-api-key",{headers:Ko(r)}).andThen(f(ApiKeyCredsSchema)))}var ER=k(e,d,c,b);async function hR(e,r){try{return await Jp(e,r)}catch(t){if(!(t instanceof d)||t.status!==400)throw t}return Zp(e,r)}var SR=k(e,d,j,c,b);async function TR(e){return (await unwrap(e.secureClob.get("/auth/api-keys").andThen(f(ApiKeysResponseSchema)))).apiKeys}var xR=k(e,d,j,c,b);async function CR(e){await unwrap(e.secureClob.del("/auth/api-key").andThen(f(z.literal("OK"))));}var kR=k(e,d,j,c,b);async function bR(e){return unwrap(e.secureClob.post("/auth/builder-api-key").andThen(f(BuilderApiKeyCredsSchema)))}var IR=k(e,d,j,c,b);async function qR(e){return unwrap(e.secureClob.get("/auth/builder-api-key").andThen(f(BuilderApiKeysResponseSchema)))}var vR=k(e,d,j,c,b);async function AR(e){await unwrap(e.clob.del("/auth/builder-api-key").andThen(f(z.literal("OK"))));}function Ko(e){return {POLY_ADDRESS:e.address,POLY_NONCE:`${e.nonce}`,POLY_SIGNATURE:e.signature,POLY_TIMESTAMP:`${e.timestamp}`}}var tc=z.object({after:z.string().optional(),before:z.string().optional(),builderCode:BuilderCodeSchema,cursor:PaginationCursorSchema.optional(),id:z.string().optional(),market:z.string().optional(),tokenId:z.string().optional()}),jR=k(e,d,c,b,a);function WR(e,r){let{cursor:t,...o}=l(r,tc);return x(n=>e.clob.get("/builder/trades",{params:g({...o,nextCursor:n},h({builderCode:"builder_code",tokenId:"asset_id"}))}).andThen(f(PaginatedBuilderTradesSchema)).map(s=>({items:s.data,hasMore:s.nextCursor!==END_CURSOR,nextCursor:s.nextCursor===END_CURSOR?void 0:toPaginationCursor(s.nextCursor),totalCount:s.count})),t)}var Cc=z.object({tokenId:z.string()}),QR=k(e,d,c,b,a);async function XR(e,r){let t=l(r,Cc);return (await unwrap(e.clob.get("/midpoint",{params:g(t,h())}).andThen(f(MidpointSchema)))).mid}var kc=z.array(z.object({tokenId:z.string()})).min(1),eE=k(e,d,c,b,a);async function rE(e,r){let t=l(r,kc);return unwrap(e.clob.post("midpoints",{json:Er(t)}).andThen(f(MidpointsSchema)))}var bc=z.object({tokenId:z.string()}),tE=k(e,d,c,b,a);async function Be(e,r){let t=l(r,bc);return (await unwrap(e.clob.get("/tick-size",{params:g(t,h())}).andThen(f(FetchTickSizeResponseSchema)))).minimumTickSize}var Ic=z.object({tokenId:z.string()}),oE=k(e,d,c,b,a);async function Ue(e,r){let t=l(r,Ic);return (await unwrap(e.clob.get("/neg-risk",{params:g(t,h())}).andThen(f(FetchNegRiskResponseSchema)))).negRisk}var qc=z.object({tokenId:TokenIdSchema}),nE=k(e,d,c,b,a);async function Qo(e,r){let t=l(r,qc);return unwrap(e.clob.get(`/markets-by-token/${t.tokenId}`).andThen(f(ResolveConditionByTokenResponseSchema)))}var vc=z.object({conditionId:CtfConditionIdSchema}),sE=k(e,d,c,b,a);async function Xo(e,r){let t=l(r,vc);return unwrap(e.clob.get(`/clob-markets/${t.conditionId}`).andThen(f(FetchMarketInfoResponseSchema)))}var Ac=z.object({builderCode:BuilderCodeSchema}),aE=k(e,d,c,b,a);async function en(e,r){let t=l(r,Ac);return unwrap(e.clob.get(`/fees/builder-fees/${t.builderCode}`).andThen(f(FetchBuilderFeeRatesResponseSchema)).mapErr(o=>o instanceof d&&o.status===404?new a(`Unknown builder code: ${t.builderCode}`,{cause:o}):o))}var Oc=z.object({tokenId:z.string(),side:OrderSideSchema}),iE=k(e,d,c,b,a);async function pE(e,r){let t=l(r,Oc);return (await unwrap(e.clob.get("/price",{params:g(t,h())}).andThen(f(PriceSchema)))).price}var wc=z.array(z.object({tokenId:z.string(),side:OrderSideSchema})).min(1),cE=k(e,d,c,b,a);async function dE(e,r){let t=l(r,wc);return unwrap(e.clob.post("prices",{json:Hc(t)}).andThen(f(PricesSchema)))}var Lc=z.object({tokenId:z.string()}),uE=k(e,d,c,b,a);async function rn(e,r){let t=l(r,Lc);return unwrap(e.clob.get("/book",{params:g(t,h())}).andThen(f(FetchOrderBookResponseSchema)))}var Mc=z.array(z.object({tokenId:z.string()})).min(1),mE=k(e,d,c,b,a);async function lE(e,r){let t=l(r,Mc);return unwrap(e.clob.post("books",{json:Er(t)}).andThen(f(OrderBooksSchema)))}var Fc=z.object({tokenId:z.string()}),fE=k(e,d,c,b,a);async function yE(e,r){let t=l(r,Fc);return (await unwrap(e.clob.get("/spread",{params:g(t,h())}).andThen(f(SpreadSchema)))).spread}var Bc=z.array(z.object({tokenId:z.string()})).min(1),PE=k(e,d,c,b,a);async function gE(e,r){let t=l(r,Bc);return unwrap(e.clob.post("spreads",{json:Er(t)}).andThen(f(SpreadsSchema)))}var Uc=z.object({tokenId:z.string()}),RE=k(e,d,c,b,a);async function EE(e,r){let t=l(r,Uc);return unwrap(e.clob.get("/last-trade-price",{params:g(t,h())}).andThen(f(LastTradePriceSchema)))}var Dc=z.array(z.object({tokenId:z.string()})).min(1),hE=k(e,d,c,b,a);async function SE(e,r){let t=l(r,Dc);return unwrap(e.clob.post("last-trades-prices",{json:Er(t)}).andThen(f(LastTradePricesSchema)))}var zc=z.object({tokenId:z.string(),startTs:z.number().int().optional(),endTs:z.number().int().optional(),fidelity:z.number().int().positive().optional(),interval:PriceHistoryIntervalSchema.optional()}),TE=k(e,d,c,b,a);async function xE(e,r){let t=l(r,zc);return (await unwrap(e.clob.get("/prices-history",{params:g(t,{tokenId:"market",startTs:"startTs",endTs:"endTs",fidelity:"fidelity",interval:"interval"})}).andThen(f(PriceHistorySchema)))).history}var jc=z.object({cursor:PaginationCursorSchema.optional(),sponsored:z.boolean().optional()}).default({}),CE=k(e,d,c,b,a);function kE(e,r={}){let{cursor:t,...o}=l(r,jc);return x(n=>e.clob.get("/rewards/markets/current",{params:g({...o,nextCursor:n},h())}).andThen(f(PaginatedCurrentRewardsSchema)).map(s=>({items:s.data,hasMore:s.nextCursor!==END_CURSOR,nextCursor:s.nextCursor===END_CURSOR?void 0:toPaginationCursor(s.nextCursor),totalCount:s.count})),t)}var Wc=z.object({conditionId:CtfConditionIdSchema,cursor:PaginationCursorSchema.optional(),sponsored:z.boolean().optional()}),bE=k(e,d,c,b,a);function IE(e,r){let{cursor:t,...o}=l(r,Wc);return x(n=>e.clob.get(`rewards/markets/${o.conditionId}`,{params:g({nextCursor:n,sponsored:o.sponsored},h())}).andThen(f(PaginatedMarketRewardsSchema)).map(s=>({items:s.data,hasMore:s.nextCursor!==END_CURSOR,nextCursor:s.nextCursor===END_CURSOR?void 0:toPaginationCursor(s.nextCursor),totalCount:s.count})),t)}function Er(e){return e.map(({tokenId:r})=>({token_id:r}))}function Hc(e){return e.map(({tokenId:r,side:t})=>({token_id:r,side:t}))}var Vc=z.object({ascending:z.boolean().optional(),cursor:PaginationCursorSchema.optional(),pageSize:A.default(20),getPositions:z.boolean().optional(),holdersOnly:z.boolean().optional(),order:z.string().optional(),parentEntityId:z.union([EventIdSchema,SeriesIdSchema]),parentEntityType:CommentParentEntityTypeSchema}),Yc=z.object({getPositions:z.boolean().optional(),id:CommentIdSchema}),Jc=z.object({address:z.string(),ascending:z.boolean().optional(),cursor:PaginationCursorSchema.optional(),order:z.string().optional(),pageSize:A.default(20)}),DE=k(e,d,c,b,a);function zE(e,r){let{cursor:t,pageSize:o,...n}=l(r,Vc);return x(s=>{let a=U(s,o);return e.gamma.get("/comments",{params:g({ascending:n.ascending,getPositions:n.getPositions,holdersOnly:n.holdersOnly,limit:a.pageSize+1,offset:a.offset,order:n.order,parentEntityId:n.parentEntityId,parentEntityType:n.parentEntityType},h())}).andThen(f(ListCommentsResponseSchema)).map(y=>{let P=y.length>a.pageSize;return {items:y.slice(0,a.pageSize),hasMore:P,nextCursor:P?F({offset:a.offset+a.pageSize,pageSize:a.pageSize}):void 0}})},t)}var jE=k(e,d,c,b,a);async function WE(e,r){let t=l(r,Yc);return unwrap(e.gamma.get(`comments/${t.id}`,{params:g({getPositions:t.getPositions},h())}).andThen(f(ListCommentsResponseSchema)))}var HE=k(e,d,c,b,a);function _E(e,r){let{address:t,cursor:o,pageSize:n,...s}=l(r,Jc);return x(a=>{let y=U(a,n);return e.gamma.get(`comments/user_address/${t}`,{params:g({ascending:s.ascending,limit:y.pageSize+1,offset:y.offset,order:s.order},h())}).andThen(f(ListCommentsResponseSchema)).map(P=>{let L=P.length>y.pageSize;return {items:P.slice(0,y.pageSize),hasMore:L,nextCursor:L?F({offset:y.offset+y.pageSize,pageSize:y.pageSize}):void 0}})},o)}function hr(e,r){let t;try{t=new URL(e);}catch(y){throw new a("Expected a valid Polymarket URL.",{cause:y})}if(t.protocol!=="https:"||t.hostname!=="polymarket.com"&&t.hostname!=="www.polymarket.com")throw new a("Expected a valid Polymarket URL.");let[o,n,...s]=t.pathname.split("/").filter(Boolean),a$1=s[0];if(r==="market"&&o==="event"&&n!==void 0&&s.length<=1)return a$1??n;if(o!==r||n===void 0||s.length>0)throw new a(`Expected a Polymarket ${r} URL.`);return n}var td=z.object({ascending:z.boolean().optional(),closed:z.boolean().default(false),cursor:PaginationCursorSchema.optional(),pageSize:A.optional(),cyom:z.boolean().optional(),endDateMax:IsoDateTimeStringSchema.optional(),endDateMin:IsoDateTimeStringSchema.optional(),ended:z.boolean().optional(),eventDate:IsoCalendarDateStringSchema.optional(),eventWeek:z.number().int().optional(),excludeTagIds:z.array(z.number().int()).optional(),featured:z.boolean().optional(),featuredOrder:z.boolean().optional(),gameIds:z.array(z.number().int()).optional(),ids:z.array(z.number().int()).optional(),includeBestLines:z.boolean().optional(),includeChat:z.boolean().optional(),includeChildren:z.boolean().optional(),includeTemplate:z.boolean().optional(),liquidityMax:z.number().optional(),liquidityMin:z.number().optional(),live:z.boolean().optional(),locale:z.string().optional(),order:z.string().optional(),parentEventId:z.number().int().optional(),partnerSlug:z.string().optional(),recurrence:z.enum(["daily","weekly","monthly"]).optional(),relatedTags:z.boolean().optional(),seriesIds:z.array(z.number().int()).optional(),slug:z.array(z.string()).optional(),startDateMax:IsoDateTimeStringSchema.optional(),startDateMin:IsoDateTimeStringSchema.optional(),startTimeMax:IsoDateTimeStringSchema.optional(),startTimeMin:IsoDateTimeStringSchema.optional(),tagIds:z.array(z.number().int()).optional(),tagMatch:z.enum(["any","all"]).optional(),tagSlug:z.string().optional(),titleSearch:z.string().optional(),volumeMax:z.number().optional(),volumeMin:z.number().optional()}),od=z.union([z.object({id:z.string(),includeBestLines:z.boolean().optional(),includeChat:z.boolean().optional(),includeTemplate:z.boolean().optional(),locale:z.string().optional()}),z.object({slug:z.string(),includeBestLines:z.boolean().optional(),includeChat:z.boolean().optional(),includeTemplate:z.boolean().optional(),locale:z.string().optional()}),z.object({url:z.string(),includeBestLines:z.boolean().optional(),includeChat:z.boolean().optional(),includeTemplate:z.boolean().optional(),locale:z.string().optional()})]),nd=z.object({id:z.string()}),sd=z.object({id:z.string()}),nh=k(e,d,c,b,a);function sh(e,r={}){let t=l(r,td);return x(o=>e.gamma.get("/events/keyset",{params:ad({...t,cursor:o??t.cursor})}).andThen(f(ListEventsKeysetResponseSchema)).map(n=>({items:n.items,hasMore:n.nextCursor!==void 0,nextCursor:n.nextCursor})),t.cursor)}var ah=k(e,d,c,b,a);async function ih(e,r){let t=l(r,od);if("id"in t)return unwrap(e.gamma.get(`events/${t.id}`,{params:id(t)}).andThen(f(EventSchema)));let o="url"in t?hr(t.url,"event"):t.slug;return unwrap(e.gamma.get(`events/slug/${o}`,{params:pd(t)}).andThen(f(EventSchema)))}var ph=k(e,d,c,b,a);async function ch(e,r){let t=l(r,nd);return unwrap(e.gamma.get(`events/${t.id}/tags`).andThen(f(FetchEventTagsResponseSchema)))}var dh=k(e,d,c,b,a);async function uh(e,r){let t=l(r,sd);return unwrap(e.data.get("/live-volume",{params:W(t)}).andThen(f(FetchEventLiveVolumeResponseSchema)))}function ad(e){return g(e,h({cursor:"after_cursor",excludeTagIds:"exclude_tag_id",gameIds:"game_id",ids:"id",pageSize:"limit",seriesIds:"series_id",tagIds:"tag_id"}))}function id(e){return g({includeBestLines:e.includeBestLines,includeChat:e.includeChat,includeTemplate:e.includeTemplate,locale:e.locale},h())}function pd(e){return g({includeBestLines:e.includeBestLines,includeChat:e.includeChat,includeTemplate:e.includeTemplate,locale:e.locale},h())}var yd=z.object({cursor:PaginationCursorSchema.optional(),pageSize:A.default(20),timePeriod:TimePeriodSchema.optional()}),Pd=z.object({timePeriod:TimePeriodSchema.optional()}),gd=z.object({category:LeaderboardCategorySchema.optional(),cursor:PaginationCursorSchema.optional(),pageSize:A.default(20),timePeriod:TimePeriodSchema.optional(),orderBy:LeaderboardOrderBySchema.optional(),user:z.string().optional(),userName:z.string().optional()}),Th=k(e,d,c,b,a);function xh(e,r={}){let{cursor:t,pageSize:o,...n}=l(r,yd);return x(s=>{let a=U(s,o);return e.data.get("/v1/builders/leaderboard",{params:W({...n,limit:a.pageSize+1,offset:a.offset})}).andThen(f(ListBuilderLeaderboardResponseSchema)).map(y=>{let P=y.length>a.pageSize;return {items:y.slice(0,a.pageSize),hasMore:P,nextCursor:P?F({offset:a.offset+a.pageSize,pageSize:a.pageSize}):void 0}})},t)}var Ch=k(e,d,c,b,a);async function kh(e,r={}){let t=l(r,Pd);return unwrap(e.data.get("/v1/builders/volume",{params:W(t)}).andThen(f(ListBuilderVolumeResponseSchema)))}var bh=k(e,d,c,b,a);function Ih(e,r={}){let{cursor:t,pageSize:o,...n}=l(r,gd);return x(s=>{let a=U(s,o);return e.data.get("/v1/leaderboard",{params:W({...n,limit:a.pageSize+1,offset:a.offset})}).andThen(f(ListTraderLeaderboardResponseSchema)).map(y=>{let P=y.length>a.pageSize;return {items:y.slice(0,a.pageSize),hasMore:P,nextCursor:P?F({offset:a.offset+a.pageSize,pageSize:a.pageSize}):void 0}})},t)}var kd=z.object({ascending:z.boolean().optional(),closed:z.boolean().optional(),clobTokenIds:z.array(z.string()).optional(),cursor:PaginationCursorSchema.optional(),pageSize:A.optional(),conditionIds:z.array(CtfConditionIdSchema).optional(),cyom:z.boolean().optional(),decimalized:z.boolean().optional(),endDateMax:IsoDateTimeStringSchema.optional(),endDateMin:IsoDateTimeStringSchema.optional(),gameId:z.string().optional(),ids:z.array(z.number().int()).optional(),includeTag:z.boolean().optional(),liquidityNumMax:z.number().optional(),liquidityNumMin:z.number().optional(),locale:z.string().optional(),marketMakerAddresses:z.array(z.string()).optional(),order:z.string().optional(),positionIds:z.array(PositionIdSchema).optional(),questionIds:z.array(z.string()).optional(),relatedTags:z.boolean().optional(),rfqEnabled:z.boolean().optional(),rewardsMinSize:z.number().optional(),slug:z.array(z.string()).optional(),sportsMarketTypes:z.array(z.string()).optional(),startDateMax:IsoDateTimeStringSchema.optional(),startDateMin:IsoDateTimeStringSchema.optional(),tagId:z.number().int().optional(),tagMatch:z.enum(["any","all"]).optional(),umaResolutionStatus:z.string().optional(),volumeNumMax:z.number().optional(),volumeNumMin:z.number().optional()}),bd=z.object({id:z.string(),includeTag:z.boolean().optional(),locale:z.string().optional()}),Id=z.object({slug:z.string(),includeTag:z.boolean().optional(),locale:z.string().optional()}),qd=z.object({url:z.string(),includeTag:z.boolean().optional(),locale:z.string().optional()}),vd=z.union([bd,Id,qd]),Ad=z.object({id:z.string()}),Od=z.object({limit:z.number().int().optional(),market:z.array(z.string()),minBalance:z.number().int().optional()}),wd=z.object({market:z.array(z.string()).optional()}),Ld=z.enum(["OPEN","CLOSED","ALL"]),Md=z.enum(["TOKENS","CASH_PNL","REALIZED_PNL","TOTAL_PNL"]),Fd=z.enum(["ASC","DESC"]),Bd=z.object({cursor:PaginationCursorSchema.optional(),market:z.string(),pageSize:A.default(20),user:z.string().optional(),status:Ld.optional(),sortBy:Md.optional(),sortDirection:Fd.optional()}),Wh=k(e,d,c,b,a);function cn(e,r={}){let t=l(r,kd);return x(o=>e.gamma.get("/markets/keyset",{params:Dd({...t,cursor:o??t.cursor})}).andThen(f(ListMarketsKeysetResponseSchema)).map(n=>({items:n.items,hasMore:n.nextCursor!==void 0,nextCursor:n.nextCursor})),t.cursor)}var Ud=z.object({cursor:PaginationCursorSchema.optional(),pageSize:A.max(100).optional(),exclude:z.array(CtfConditionIdSchema).optional()}),Hh=k(e,d,c,b,a);function _h(e,r={}){let t=l(r,Ud);return x(o=>e.rfq.get("/v1/rfq/combo-markets",{params:zd({...t,cursor:o??t.cursor})}).andThen(f(ListComboMarketsResponseSchema)).map(n=>({items:n.markets,hasMore:n.nextCursor!==void 0,nextCursor:n.nextCursor})),t.cursor)}var Nh=k(e,d,c,b,a);async function Gh(e,r){let t=l(r,vd);return "id"in t?jd(e,t):"url"in t?sn(e,{includeTag:t.includeTag,locale:t.locale,slug:hr(t.url,"market")}):sn(e,t)}var Kh=k(e,d,c,b,a);async function $h(e,r){let t=l(r,Ad);return unwrap(e.gamma.get(`markets/${t.id}/tags`).andThen(f(FetchMarketTagsResponseSchema)))}var Vh=k(e,d,c,b,a);async function Yh(e,r){let t=l(r,Od);return unwrap(e.data.get("/holders",{params:W(t)}).andThen(f(ListMarketHoldersResponseSchema)))}var Jh=k(e,d,c,b,a);async function Zh(e,r={}){let t=l(r,wd);return unwrap(e.data.get("/oi",{params:W(t)}).andThen(f(ListOpenInterestResponseSchema)))}var Qh=k(e,d,c,b,a);function Xh(e,r){let{cursor:t,pageSize:o,...n}=l(r,Bd);return x(s=>{let a=U(s,o);return e.data.get("/v1/market-positions",{params:W({...n,limit:a.pageSize+1,offset:a.offset})}).andThen(f(ListMarketPositionsResponseSchema)).map(y=>{let P=y.length>a.pageSize;return {items:y.slice(0,a.pageSize),hasMore:P,nextCursor:P?F({offset:a.offset+a.pageSize,pageSize:a.pageSize}):void 0}})},t)}function Dd(e){return g(e,h({cursor:"after_cursor",ids:"id",marketMakerAddresses:"market_maker_address",pageSize:"limit"}))}function zd(e){return g({cursor:e.cursor,exclude:e.exclude?.join(","),pageSize:e.pageSize},{cursor:"cursor",exclude:"exclude",pageSize:"limit"})}async function sn(e,r){return unwrap(e.gamma.get(`markets/slug/${r.slug}`,{params:g({includeTag:r.includeTag,locale:r.locale},h())}).andThen(f(MarketSchema)))}async function jd(e,r){return unwrap(e.gamma.get(`markets/${r.id}`,{params:g({includeTag:r.includeTag,locale:r.locale},h())}).andThen(f(MarketSchema)))}var _d=z.object({orderId:z.string()}),Nd=z.object({orderIds:z.array(z.string()).min(1).max(3e3)}),Gd=z.object({tokenId:z.string().optional(),market:z.string().optional()}).refine(e=>e.market!==void 0||e.tokenId!==void 0,{message:"At least one of market or tokenId is required.",path:["market"]}),iS=k(d,e,j,c,b,a);async function pS(e,r){let t=l(r,_d);return xr(e,"/order",{orderID:t.orderId})}var cS=k(d,e,j,c,b,a);async function dS(e,r){let t=l(r,Nd);return xr(e,"/orders",t.orderIds)}var uS=k(d,e,j,c,b);async function mS(e){return xr(e,"/cancel-all")}var lS=k(d,e,j,c,b,a);async function fS(e,r){let t=l(r,Gd);return xr(e,"/cancel-market-orders",{asset_id:t.tokenId,market:t.market})}async function xr(e,r,t){return unwrap(e.secureClob.del(r,{json:t}).andThen(f(CancelOrdersResponseSchema)))}var un=z.object({tokenId:z.string(),orderType:z.union([z.literal(OrderType.FAK),z.literal(OrderType.FOK)]).default(OrderType.FOK)}),$d=z.discriminatedUnion("side",[un.extend({side:z.literal(OrderSide.BUY),amount:PositiveDecimalNumberSchema}),un.extend({side:z.literal(OrderSide.SELL),shares:PositiveDecimalNumberSchema})]),TS=k(i,e,d,c,b,a);async function xS(e,r){let t=l(r,$d),o=await Be(e,{tokenId:t.tokenId}),n=t.side===OrderSide.BUY?t.amount:t.shares;return st(e,{amount:n,orderType:t.orderType,side:t.side,tickSize:o,tokenId:t.tokenId})}async function st(e,r){let t=await rn(e,{tokenId:r.tokenId}),o=r.side===OrderSide.BUY?Yd(t.asks,r.amount,r.orderType):Jd(t.bids,r.amount,r.orderType);return invariant(Vd(o,r.tickSize),`Resolved market price fell outside the valid range for tick size ${r.tickSize}.`),o}function Vd(e,r){return e>=r&&e<=1-r}function Yd(e,r,t){if(e.length===0)throw new i("No resting liquidity.");let o=0;for(let s=e.length-1;s>=0;s-=1){let a=e[s];if(a!==void 0&&(o+=Number.parseFloat(a.size)*Number.parseFloat(a.price),o>=r))return Number.parseFloat(a.price)}if(t===OrderType.FOK)throw new i("Insufficient liquidity for full fill.");let n=e[0];return Number.parseFloat(n.price)}function Jd(e,r,t){if(e.length===0)throw new i("No resting liquidity.");let o=0;for(let s=e.length-1;s>=0;s-=1){let a=e[s];if(a!==void 0&&(o+=Number.parseFloat(a.size),o>=r))return Number.parseFloat(a.price)}if(t===OrderType.FOK)throw new i("Insufficient liquidity for full fill.");let n=e[0];return Number.parseFloat(n.price)}var eu=z.array(z.custom()).min(1).max(15),wS=k(e,d,j,c,b),LS=k(e,d,j,c,b,a);function kr(e){return async function(t){let o=yn(e,t);return unwrap(e.secureClob.post("/order",{json:o}).andThen(f(OrderResponseSchema)))}}function MS(e){return async function(t){let n=l(t,eu).map(s=>yn(e,s));return unwrap(e.secureClob.post("/orders",{json:n}).andThen(f(OrderResponsesSchema)))}}function yn(e,r){return invariant(r.postOnly!==true||r.orderType===OrderType.GTC||r.orderType===OrderType.GTD,"Post-only orders are only supported for GTC and GTD order types."),{deferExec:false,order:{builder:r.builder,expiration:`${r.expiration}`,maker:r.maker,makerAmount:r.makerAmount,metadata:r.metadata,salt:Number.parseInt(r.salt,10),side:r.side,signature:r.signature,signatureType:r.signatureType,signer:r.signer,takerAmount:r.takerAmount,timestamp:r.timestamp,tokenId:r.tokenId},orderType:r.orderType,owner:e.credentials.key,...r.postOnly===true?{postOnly:true}:{}}}function ze(e){switch(e){case .1:return {amount:3,price:1,size:2};case .01:return {amount:4,price:2,size:2};case .005:return {amount:5,price:3,size:2};case .0025:return {amount:6,price:4,size:2};case .001:return {amount:5,price:3,size:2};case 1e-4:return {amount:6,price:4,size:2}}invariant(false,`Unsupported tick size: ${e}`);}function je(e,r){return r?e.environment.contracts.negRiskExchange:e.environment.contracts.standardExchange}function de(e){return BigInt(Math.round(e*10**6))}function ue(e,r){return Z(e)<=r?e:Math.floor(e*10**r)/10**r}function Ce(e,r){return Z(e)<=r?e:Math.ceil(e*10**r)/10**r}function at(e,r){return Z(e)<=r?e:Math.round(e*10**r)/10**r}function Z(e){if(typeof e=="number"&&Number.isInteger(e))return 0;let[r="",t]=e.toString().toLowerCase().split("e"),[,o=""]=r.split("."),n=o.length;if(t===void 0)return n;let s=Number.parseInt(t,10);return Math.max(0,n-s)}var au=180,Rn=z.strictObject({tokenId:TokenIdSchema,price:PositiveDecimalNumberSchema,size:PositiveDecimalNumberSchema,side:OrderSideSchema,builderCode:BuilderCodeSchema.optional(),postOnly:z.boolean().default(false),expiration:z.number().int().nonnegative().optional()}).superRefine((e,r)=>{if(e.expiration!==void 0){let t=Math.floor(Date.now()/1e3)+au;e.expiration<t&&r.addIssue({code:"custom",message:"Expiration must be at least 3 minutes in the future.",path:["expiration"]});}});async function En(e,r){let t=await iu(e,{price:r.price,tokenId:r.tokenId}),o=pu({price:t.price,side:r.side,size:r.size,tickSize:t.tickSize});return {builderCode:r.builderCode,chainId:e.environment.chainId,exchangeAddress:t.exchangeAddress,expiration:r.expiration??0,funderAddress:t.funderAddress,offeredAmount:o.offeredAmount,orderType:r.expiration===void 0?OrderType.GTC:OrderType.GTD,side:r.side,signer:t.signerAddress,requestedAmount:o.requestedAmount,tokenId:r.tokenId}}async function iu(e,r){let t=e.account,o=await Be(e,{tokenId:r.tokenId}),n=await Ue(e,{tokenId:r.tokenId});return {exchangeAddress:je(e,n),funderAddress:t.wallet,negRisk:n,price:cu(r.price,o),signerAddress:t.signer,tickSize:o}}function pu(e){let r=ze(e.tickSize),t=at(e.price,r.price);if(e.side===OrderSide.BUY){let s=ue(e.size,r.size),a=s*t;return Z(a)>r.amount&&(a=Ce(a,r.amount+4),Z(a)>r.amount&&(a=ue(a,r.amount))),{offeredAmount:de(a),requestedAmount:de(s)}}let o=ue(e.size,r.size),n=o*t;return Z(n)>r.amount&&(n=Ce(n,r.amount+4),Z(n)>r.amount&&(n=ue(n,r.amount))),{offeredAmount:de(o),requestedAmount:de(n)}}function cu(e,r){let t=ze(r);if(e<r||e>1-r)throw new a(`Price must be between ${r} and ${1-r} for tick size ${r}.`);if(Z(e)>t.price)throw new a(`Price must conform to tick size ${r} with at most ${t.price} decimal places.`);return at(e,t.price)}var hn=z.object({tokenId:TokenIdSchema,builderCode:BuilderCodeSchema.optional(),orderType:z.union([z.literal(OrderType.FAK),z.literal(OrderType.FOK)]).default(OrderType.FAK)}),Tn=z.discriminatedUnion("side",[hn.extend({side:z.literal(OrderSide.BUY),amount:PositiveDecimalNumberSchema,maxSpend:PositiveDecimalNumberSchema.optional(),maxPrice:PositiveDecimalNumberSchema.optional()}),hn.extend({side:z.literal(OrderSide.SELL),shares:PositiveDecimalNumberSchema,minPrice:PositiveDecimalNumberSchema.optional()})]);async function xn(e,r){let t=await mu(e,r),o=yu({amount:t.resolvedAmount,price:t.price,protectPrice:fu(r),side:r.side,tickSize:t.tickSize});return {builderCode:r.builderCode,chainId:e.environment.chainId,exchangeAddress:t.exchangeAddress,expiration:0,funderAddress:t.funderAddress,offeredAmount:o.offeredAmount,orderType:r.orderType,side:r.side,signer:t.signerAddress,requestedAmount:o.requestedAmount,tokenId:r.tokenId}}async function mu(e,r){let t=e.account,o=await Be(e,{tokenId:r.tokenId}),n=r.side===OrderSide.BUY?r.amount:r.shares,s=await lu(e,r,n,o),a=await Ue(e,{tokenId:r.tokenId}),y=await Pu(e,{amount:n,builderCode:r.builderCode,maxSpend:r.side===OrderSide.BUY?r.maxSpend:void 0,price:s,side:r.side,tokenId:r.tokenId});return {exchangeAddress:je(e,a),funderAddress:t.wallet,negRisk:a,price:s,resolvedAmount:y,signerAddress:t.signer,tickSize:o}}async function lu(e,r,t,o){return r.side===OrderSide.BUY&&r.maxPrice!==void 0?Sn(r.maxPrice,o,"maxPrice"):r.side===OrderSide.SELL&&r.minPrice!==void 0?Sn(r.minPrice,o,"minPrice"):st(e,{amount:t,orderType:r.orderType,side:r.side,tickSize:o,tokenId:r.tokenId})}function Sn(e,r,t){let o=ze(r);if(e<r||e>1-r)throw new a(`${t} must be between ${r} and ${1-r} for tick size ${r}.`);if(Z(e)>o.price)throw new a(`${t} must conform to tick size ${r} with at most ${o.price} decimal places.`);return e}function fu(e){return e.side===OrderSide.BUY&&e.maxPrice!==void 0||e.side===OrderSide.SELL&&e.minPrice!==void 0}function yu(e){let r=ze(e.tickSize),t=ue(e.price,r.price),o=ue(e.amount,r.size);if(e.side===OrderSide.BUY){let s=o/t;return Z(s)>r.amount&&(s=Ce(s,r.amount+4),Z(s)>r.amount&&(s=e.protectPrice?Ce(s,r.amount):ue(s,r.amount))),{offeredAmount:de(o),requestedAmount:de(s)}}let n=o*t;return Z(n)>r.amount&&(n=Ce(n,r.amount+4),Z(n)>r.amount&&(n=e.protectPrice?Ce(n,r.amount):ue(n,r.amount))),{offeredAmount:de(o),requestedAmount:de(n)}}async function Pu(e,r){if(r.side!==OrderSide.BUY||r.maxSpend===void 0)return r.amount;let[t,o]=await Promise.all([gu(e,r.tokenId),Ru(e,r.builderCode)]);return Eu({amount:r.amount,builderTakerFeeRate:o,platformFeeExponent:t.exponent,platformFeeRate:t.rate,maxSpend:r.maxSpend,price:r.price})}async function gu(e,r){let t=await Qo(e,{tokenId:r});return (await Xo(e,{conditionId:t})).feeInfo}async function Ru(e,r){return r===void 0?0:(await en(e,{builderCode:r})).taker}function Eu(e){let r=e.platformFeeRate*(e.price*(1-e.price))**e.platformFeeExponent,t=e.amount/e.price*r,o=e.amount+t+e.amount*e.builderTakerFeeRate;return e.maxSpend<=o?e.maxSpend/(1+r/e.price+e.builderTakerFeeRate):e.amount}var Cn="0x0000000000000000000000000000000000000000000000000000000000000000";function ct(e,r){let t=oo(r);return {builder:e.builderCode??Cn,chainId:e.chainId,exchangeAddress:e.exchangeAddress,expiration:e.expiration,maker:t.maker,makerAmount:e.offeredAmount.toString(),metadata:Cn,orderType:e.orderType,salt:hu().toString(),side:e.side,signatureType:t.signatureType,signer:t.signer,takerAmount:e.requestedAmount.toString(),timestamp:Date.now().toString(),tokenId:e.tokenId}}function dt(e,r){let{chainId:t,exchangeAddress:o,...n}=e;return {...n,signature:r}}function hu(){let e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),BigInt(`0x${Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}`)&(1n<<53n)-1n}var In="Polymarket CTF Exchange",xu="DepositWallet",Cu="1",ut="0x0000000000000000000000000000000000000000000000000000000000000000",mt="Order(uint256 salt,address maker,address signer,uint256 tokenId,uint256 makerAmount,uint256 takerAmount,uint8 side,uint8 signatureType,uint256 timestamp,bytes32 metadata,bytes32 builder)",ku=Hash.keccak256(Bytes.fromString(mt),{as:"Hex"}),bu=Hash.keccak256(Bytes.fromString("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),{as:"Hex"}),Iu=Hash.keccak256(Bytes.fromString(In),{as:"Hex"}),qu=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],qn=[{name:"salt",type:"uint256"},{name:"maker",type:"address"},{name:"signer",type:"address"},{name:"tokenId",type:"uint256"},{name:"makerAmount",type:"uint256"},{name:"takerAmount",type:"uint256"},{name:"side",type:"uint8"},{name:"signatureType",type:"uint8"},{name:"timestamp",type:"uint256"},{name:"metadata",type:"bytes32"},{name:"builder",type:"bytes32"}],vu=[{name:"contents",type:"Order"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"}];function vn(e){let r=Au(e.domain,e.order);return e.order.signatureType!==SignatureType.POLY_1271?r:{domain:wn(e.domain),message:{chainId:e.domain.chainId,contents:r.message,name:xu,salt:ut,verifyingContract:e.order.signer,version:Cu},primaryType:"TypedDataSign",types:{Order:qn,TypedDataSign:vu}}}function An(e){if(e.order.signatureType!==SignatureType.POLY_1271)return e.signature;let r=Bytes.toHex(Bytes.fromString(mt)),t=mt.length.toString(16).padStart(4,"0");return expectErc1271Signature(`0x${e.signature.slice(2)}${Ou(e.domain).slice(2)}${wu(e.order).slice(2)}${r.slice(2)}${t}`)}function On(e){return {builder:e.builder??ut,maker:e.maker,makerAmount:BigInt(e.makerAmount),metadata:e.metadata??ut,salt:BigInt(e.salt),side:Mu(e.side),signatureType:e.signatureType,signer:e.signer,takerAmount:BigInt(e.takerAmount),timestamp:BigInt(e.timestamp),tokenId:BigInt(e.tokenId)}}function Au(e,r){return {domain:wn(e),message:On(r),primaryType:"Order",types:{EIP712Domain:qu,Order:qn}}}function wn(e){return {chainId:e.chainId,name:In,verifyingContract:e.exchange,version:e.protocolVersion}}function Ou(e){return expectHexString(Hash.keccak256(AbiParameters.encode([{type:"bytes32"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"address"}],[bu,Iu,Lu(e.protocolVersion),BigInt(e.chainId),e.exchange]),{as:"Hex"}))}function wu(e){let r=On(e);return expectHexString(Hash.keccak256(AbiParameters.encode([{type:"bytes32"},{type:"uint256"},{type:"address"},{type:"address"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint8"},{type:"uint8"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"}],[ku,r.salt,r.maker,r.signer,r.tokenId,r.makerAmount,r.takerAmount,r.side,r.signatureType,r.timestamp,r.metadata,r.builder]),{as:"Hex"}))}function Lu(e){return expectHexString(Hash.keccak256(Bytes.fromString(e),{as:"Hex"}))}function Mu(e){return e===0||e===1?e:e===OrderSide.BUY?0:1}function ft(e){return vn({domain:Ln(e),order:e})}function yt(e,r){return An({domain:Ln(e),order:e,signature:r})}function Ln(e){return {chainId:e.chainId,exchange:e.exchangeAddress,protocolVersion:"2"}}function Pt(e){return {kind:"signOrder",payload:e}}var Fu=k(i,e,d,j,c,b,a);async function gt(e,r){let t=l(r,Tn);return async function*(){let o=await xn(e,t),n=ct(o,e.account),s=expectEvmSignature(yield Pt(ft(n)));return dt(n,yt(n,s))}.call(null)}var Bu=k(e,d,j,c,b,a);async function Rt(e,r){let t=l(r,Rn);return async function*(){let o=await En(e,t),n=ct(o,e.account),s=expectEvmSignature(yield Pt(ft(n))),a=dt(n,yt(n,s));return t.postOnly===true?{...a,postOnly:true}:a}.call(null)}var hT=Fu;async function ST(e,r){return Fn(e,gt(e,r))}var TT=Bu;async function xT(e,r){return Fn(e,Rt(e,r))}async function Fn(e,r){let t=await r;return async function*(){let o=yield*t;return kr(e)(o)}.call(null)}async function Dn(e,r){let t=r.side===OrderSide.BUY?AssetType.COLLATERAL:AssetType.CONDITIONAL,{allowances:o}=await Nr(e,r.side===OrderSide.BUY?{assetType:t}:{assetType:t,tokenId:r.tokenId});return Du(o,r.spenderAddress)}function Du(e,r){return Object.entries(e).find(([o])=>isSameEvmAddress(o,r))?.[1]??0n}var WT=k(h$1,i,e,d,j,c,b,a);function zu(e,r){return gt(e,r).then(H(e.signer))}var HT=k(h$1,i,e,d,j,f$1,g$1,c,b,a);function _T(e,r){return zu(e,r).then(t=>jn(e,t))}var NT=k(h$1,e,d,j,c,b,a);function ju(e,r){return Rt(e,r).then(H(e.signer))}var GT=k(h$1,e,d,j,f$1,g$1,c,b,a);function KT(e,r){return ju(e,r).then(t=>jn(e,t))}async function jn(e,r){let t=kr(e);try{return await t(r)}catch(o){if(!Hu(o))throw o;let n=await Wu(e,r,t);if(n===void 0)throw o;return n}}async function Wu(e,r,t){return await _u(e,r)?t(r):void 0}function Hu(e){return e instanceof d&&e.status===400&&e.message.includes("allowance is not enough")}async function _u(e,r){let t=await Ue(e,{tokenId:r.tokenId}),o=je(e,t),n=BigInt(r.makerAmount);return await Dn(e,{spenderAddress:o,side:r.side,tokenId:r.tokenId})>=n?false:(await(r.side===OrderSide.BUY?await jo(e,{amount:"max",spenderAddress:o,tokenAddress:e.environment.contracts.collateralToken}):await Wo(e,{operatorAddress:o,tokenAddress:e.environment.contracts.conditionalTokens})).wait(),await co(e,{assetType:r.side===OrderSide.BUY?AssetType.COLLATERAL:AssetType.CONDITIONAL,tokenId:r.side===OrderSide.SELL?r.tokenId:void 0}),true)}function Wn(e){let r=TypedData.getSignPayload(ht(e));return expectEvmSignature(Signature.toHex(Secp256k1.sign({payload:r,privateKey:e.privateKey})))}function ht(e){return {domain:{chainId:e.chainId,name:"Polymarket",version:"1"},message:{data:Hash.keccak256(encode(Hn(e.op)),{as:"Hex"}),salt:BigInt(e.salt),ts:BigInt(e.timestamp)},primaryType:"Op",types:{Op:[{name:"data",type:"bytes32"},{name:"salt",type:"uint64"},{name:"ts",type:"uint64"}]}}}function Hn(e){return Array.isArray(e)?e.filter(r=>r!==void 0).map(Hn):e}var br=class{#e;#r;#t;constructor({root:r,headers:t,resolveHeaders:o}){this.#e=Jt.create({prefixUrl:r,throwHttpErrors:false}),this.#r=t,this.#t=o;}get(r,t={}){return this.#o("GET",r,t)}post(r,t={}){return this.#o("POST",r,t)}patch(r,t={}){return this.#o("PATCH",r,t)}del(r,t={}){return this.#o("DELETE",r,t)}#n(r){return r.startsWith("/")?r.slice(1):r}#o(r,t,o){return this.#a(this.#c(r,t,o))}async#c(r,t,o){let n=this.#i(r,t,o),s=await this.#t?.(n),a=this.#p(this.#r,n.headers,s);return n.body!==void 0&&!a.has("content-type")&&a.set("content-type","application/json"),this.#e(this.#n(t),{body:n.body,headers:a,method:r,searchParams:n.params})}#i(r,t,o){return {body:"json"in o?this.#s(o.json):void 0,headers:o.headers,json:"json"in o?o.json:void 0,method:r,params:"params"in o?o.params:void 0,path:t}}#s(r){if(r!==void 0)return JSON.stringify(r)}#p(...r){let t=new Headers;for(let o of r)if(o!==void 0)for(let[n,s]of new Headers(o).entries())t.set(n,s);return t}#a(r){return ResultAsync.fromPromise(r.then(async t=>{if(t.ok)return t;if(t.status===429)throw new e(`Request to ${t.url} was rate limited`);let o=await this.#d(t);throw new d(o,{status:t.status})}),t=>t instanceof e||t instanceof d?t:c.fromError(t))}async#d(r){let t=r.headers.get("content-type")?.toLowerCase();if(t?.includes("application/json")){let{error:n}=await r.clone().json().catch(()=>({}));if(n)return `${String(n)} (${r.url})`}if(t?.includes("text/plain")){let n=await r.clone().text().then(s=>s.trim(),()=>"");if(n)return `${n} (${r.url})`}return r.headers.get("server")?.toLowerCase()?.includes("cloudflare")?`Request to ${r.url} was blocked by Cloudflare with status ${r.status}`:t?.includes("text/html")||t?.includes("application/xhtml+xml")?`Request to ${r.url} failed with status ${r.status} and an unexpected HTML response body`:`Request to ${r.url} failed with status ${r.status} and unreadable response body`}};var Qu=1e4,Xu=3e4,em=5e3,rm=10*6e4,tm=3e4,om=25e3,nm=65e3,_n=class{#e=0;#r;start(r){this.stop(),this.#e=Date.now(),this.#r=setNonBlockingInterval(()=>{r("PING");},Qu);}handleMessage(r){return r!=="PONG"?false:(this.#e=Date.now(),true)}isStale(r){return r-this.#e>Xu}stop(){this.#r!==void 0&&(clearInterval(this.#r),this.#r=void 0);}},Nn=class{#e=0;#r;start(r){this.stop(),this.#e=Date.now(),this.#r=setNonBlockingInterval(()=>{r("PING");},em);}handleMessage(){return this.#e=Date.now(),false}isStale(r){return r-this.#e>rm}stop(){this.#r!==void 0&&(clearInterval(this.#r),this.#r=void 0);}},Gn=class{#e=0;#r;start(r){this.#e=Date.now(),this.#r=r;}stop(){this.#r=void 0;}handleMessage(r){return r!=="ping"?false:(this.#e=Date.now(),this.#r?.("pong"),true)}isStale(r){return r-this.#e>tm}},Ir=class{#e=0;#r;start(r){this.stop(),this.#e=Date.now(),this.#r=setNonBlockingInterval(()=>{r(JSON.stringify({id:0,req:"post",op:{type:"ping"}}));},om);}handleMessage(){return this.#e=Date.now(),false}isStale(r){return r-this.#e>nm}stop(){this.#r!==void 0&&(clearInterval(this.#r),this.#r=void 0);}};var im=5e3,pm=250,cm=3e4,qr=class{#e;#r=0;schedule(r){if(this.#e!==void 0||!r.shouldReconnect())return;let t=um(this.#r,{baseMs:pm,maxMs:cm});this.#r+=1,this.#e=setNonBlockingTimeout(()=>{this.#e=void 0,this.#t(r);},t);}stop(){this.#e!==void 0&&(clearTimeout(this.#e),this.#e=void 0);}resetBackoff(){this.#r=0,this.stop();}async#t(r){if(r.shouldReconnect())try{await r.reconnect();}catch{this.schedule(r);}}},vr=class{#e;#r;#t;#n;constructor(r={}){this.#e=r.heartbeat;}connect(r){if(this.#r?.readyState===WebSocket.OPEN)return Promise.resolve({reusedOpenSocket:true});if(this.#s(),this.#t!==void 0)return this.#t;let o=this.#c(r).then(()=>({reusedOpenSocket:false})).catch(n=>{throw this.#t===o&&(this.#t=void 0),n});return this.#t=o,o}send(r){return this.#o(JSON.stringify(r))}#o(r){return this.#r?.readyState!==WebSocket.OPEN?false:(this.#r.send(r),true)}async close(){let r=await this.#d();this.#a(),!(r===void 0||r.readyState===WebSocket.CLOSED)&&await new Promise(t=>{r.addEventListener("close",()=>t(),{once:true}),r.readyState!==WebSocket.CLOSING&&r.close();});}async#c(r){let t=await r.prepare?.();return new Promise((o,n)=>{let s=dm(r.url,r.headers),a=()=>{s.removeEventListener("error",y),this.#i(s),this.#p(),r.onOpen(t),o(s);},y=P=>{s.removeEventListener("open",a),n(new c(`WebSocket connection failed: ${r.url}`,{cause:P}));};s.addEventListener("open",a,{once:true}),s.addEventListener("error",y,{once:true}),s.addEventListener("message",P=>{if(this.#r!==s)return;let L=String(P.data);if(this.#e?.handleMessage(L))return;let q;try{q=JSON.parse(L);}catch{return}r.onMessage(q);}),s.addEventListener("close",()=>{this.#r===s&&(this.#s(),r.onClose());}),s.addEventListener("error",()=>r.onError());})}#i(r){this.#r=r,this.#t=void 0;}#s(){this.#a(),this.#r=void 0;}#p(){this.#a();let r=this.#e;r!==void 0&&(r.start(t=>this.#o(t)),this.#n=setNonBlockingInterval(()=>{if(!r.isStale(Date.now()))return;let t=this.#r;t?.readyState===WebSocket.OPEN&&t.close();},im));}#a(){this.#n!==void 0&&(clearInterval(this.#n),this.#n=void 0),this.#e?.stop();}async#d(){let r=this.#r,t=this.#t;return this.#r=void 0,this.#t=void 0,r!==void 0?r:t?.then(()=>this.#r,()=>{})}};function dm(e,r){if(r===void 0)return new WebSocket(e);try{let t=Reflect.construct(WebSocket,[e,{headers:r}]);if(t instanceof WebSocket)return t}catch(t){throw new c("WebSocket headers require a header-capable WebSocket implementation.",{cause:t})}throw new c("WebSocket headers require a header-capable WebSocket implementation.")}function um(e,r){let t=Math.min(r.baseMs*2**e,r.maxMs);return Math.random()*t}var or=1440*60*1e3,Yn=90*or,le=z.number().int().nonnegative(),Ar=z.object({start:le.optional(),end:le.optional()}),Jn=z.object({interval:PerpsPnlIntervalSchema,start:le,end:le.optional()}),Im=z.enum(["perpsFills","perpsFundingPayments","perpsDeposits","perpsWithdrawals"]),qm=z.enum(["perpsEquityHistory","perpsPnlHistory"]),Or=z.object({kind:Im,startTimestamp:le,endTimestamp:le,instrumentId:PerpsInstrumentIdSchema.optional(),depositStatus:PerpsDepositStatusSchema.optional(),withdrawalStatus:PerpsWithdrawalStatusSchema.optional(),hash:TxHashSchema.optional(),seenKeys:z.array(z.string())}),Zn=z.object({kind:qm,startTimestamp:le,endTimestamp:le,interval:PerpsPnlIntervalSchema});async function Qn(e){return await unwrap(e.get("/v1/account/balances").andThen(f(FetchPerpsBalancesResponseSchema)))}async function Xn(e){return await unwrap(e.get("/v1/account/portfolio").andThen(f(FetchPerpsPortfolioResponseSchema)))}async function es(e){return await unwrap(e.get("/v1/account/stats").andThen(f(FetchPerpsAccountStatsResponseSchema)))}var vm=z.object({instrumentId:PerpsInstrumentIdSchema.optional()}).default({});async function rs(e,r){let t=l(r,vm);return await unwrap(e.get("/v1/account/config",{params:Re(t)}).andThen(f(FetchPerpsAccountConfigResponseSchema)))}var Am=z.object({instrumentId:PerpsInstrumentIdSchema.optional()}).default({});async function ts(e,r){let t=l(r,Am);return await unwrap(e.get("/v1/account/open-orders",{params:Re(t)}).andThen(f(FetchPerpsOpenOrdersResponseSchema)))}var Om=z.object({orderId:PerpsOrderIdSchema.optional(),clientOrderId:PerpsClientOrderIdSchema.optional(),instrumentId:PerpsInstrumentIdSchema.optional(),start:le.optional(),end:le.optional()}).default({}).transform(({end:e,start:r,...t})=>({...t,endTimestamp:e,startTimestamp:r}));async function os(e,r){let t=l(r,Om);return await unwrap(e.get("/v1/account/orders",{params:Re(t)}).andThen(f(FetchPerpsOrdersResponseSchema)))}var wm=z.union([Ar.extend({cursor:PaginationCursorSchema.optional()}).transform(({cursor:e,...r})=>({cursor:e,params:wr(r,or)})),z.object({cursor:PaginationCursorSchema}).transform(({cursor:e})=>({cursor:e,params:void 0}))]);function ns(e,r={}){let{cursor:t,params:o}=l(r,wm);return x(n=>{let s;n===void 0?(invariant(o!==void 0,"Expected initial Perps fills params."),s={kind:"perpsFills",seenKeys:[],...o}):s=Ne(n,Or);let{kind:a,seenKeys:y,...P}=s,L=new Set(s.seenKeys);return e.get("/v1/account/fills",{params:Re(P)}).andThen(f(ListPerpsFillsResponseSchema)).map(q=>{let $=q.data.filter(M=>!L.has(String(M.tradeId)));return Lr({getKey:M=>String(M.tradeId),getTimestamp:M=>M.timestamp,items:$,responseData:q.data,responseMore:q.more,state:s})})},t)}var Lm=z.union([Ar.extend({cursor:PaginationCursorSchema.optional(),instrumentId:PerpsInstrumentIdSchema.optional()}).transform(({cursor:e,...r})=>({cursor:e,params:wr(r,or)})),z.object({cursor:PaginationCursorSchema}).transform(({cursor:e})=>({cursor:e,params:void 0}))]);function ss(e,r={}){let{cursor:t,params:o}=l(r,Lm);return x(n=>{let s;n===void 0?(invariant(o!==void 0,"Expected initial Perps funding payment params."),s={kind:"perpsFundingPayments",seenKeys:[],...o}):s=Ne(n,Or);let{kind:a,seenKeys:y,...P}=s,L=new Set(s.seenKeys);return e.get("/v1/account/funding",{params:Re(P)}).andThen(f(ListPerpsFundingPaymentsResponseSchema)).map(q=>{let $=q.data.filter(M=>!L.has(`${M.instrumentId}:${M.timestamp}:${M.funding}`));return Lr({getKey:M=>`${M.instrumentId}:${M.timestamp}:${M.funding}`,getTimestamp:M=>M.timestamp,items:$,responseData:q.data,responseMore:q.more,state:s})})},t)}var Mm=z.union([Ar.extend({cursor:PaginationCursorSchema.optional(),depositStatus:PerpsDepositStatusSchema.optional(),hash:TxHashSchema.optional()}).transform(({cursor:e,...r})=>({cursor:e,params:wr(r,Yn)})),z.object({cursor:PaginationCursorSchema}).transform(({cursor:e})=>({cursor:e,params:void 0}))]);function as(e,r={}){let{cursor:t,params:o}=l(r,Mm);return x(n=>{let s;n===void 0?(invariant(o!==void 0,"Expected initial Perps deposit params."),s={kind:"perpsDeposits",seenKeys:[],...o}):s=Ne(n,Or);let{kind:a,seenKeys:y,...P}=s,L=new Set(s.seenKeys);return e.get("/v1/account/deposits",{params:Re(P)}).andThen(f(ListPerpsDepositsResponseSchema)).map(q=>{let $=q.data.filter(M=>!L.has(M.hash));return Lr({getKey:M=>M.hash,getTimestamp:Dm,items:$,responseData:q.data,responseMore:q.more,state:s})})},t)}var Fm=z.union([Ar.extend({cursor:PaginationCursorSchema.optional(),withdrawalStatus:PerpsWithdrawalStatusSchema.optional(),hash:TxHashSchema.optional()}).transform(({cursor:e,...r})=>({cursor:e,params:wr(r,Yn)})),z.object({cursor:PaginationCursorSchema}).transform(({cursor:e})=>({cursor:e,params:void 0}))]);function is(e,r={}){let{cursor:t,params:o}=l(r,Fm);return x(n=>{let s;n===void 0?(invariant(o!==void 0,"Expected initial Perps withdrawal params."),s={kind:"perpsWithdrawals",seenKeys:[],...o}):s=Ne(n,Or);let{kind:a,seenKeys:y,...P}=s,L=new Set(s.seenKeys);return e.get("/v1/account/withdrawals",{params:Re(P)}).andThen(f(ListPerpsWithdrawalsResponseSchema)).map(q=>{let $=q.data.filter(M=>!L.has(String(M.withdrawalId)));return Lr({getKey:M=>String(M.withdrawalId),getTimestamp:zm,items:$,responseData:q.data,responseMore:q.more,state:s})})},t)}var Bm=z.union([Jn.extend({cursor:PaginationCursorSchema.optional()}).transform(({cursor:e,...r})=>({cursor:e,params:ds(r)})),z.object({cursor:PaginationCursorSchema}).transform(({cursor:e})=>({cursor:e,params:void 0}))]);function ps(e,r){let{cursor:t,params:o}=l(r,Bm);return x(n=>{let s;n===void 0?(invariant(o!==void 0,"Expected initial Perps equity history params."),s={kind:"perpsEquityHistory",...o}):s=Ne(n,Zn);let{kind:a,...y}=s;return e.get("/v1/account/equity",{params:Re(y)}).andThen(f(ListPerpsEquityHistoryResponseSchema)).map(P=>{let L=P.data.at(-1),q=P.more&&L!==void 0&&L.timestamp<s.endTimestamp;return {items:P.data,hasMore:q,nextCursor:q?xt({...s,startTimestamp:L.timestamp+us(s.interval)}):void 0}})},t)}var Um=z.union([Jn.extend({cursor:PaginationCursorSchema.optional()}).transform(({cursor:e,...r})=>({cursor:e,params:ds(r)})),z.object({cursor:PaginationCursorSchema}).transform(({cursor:e})=>({cursor:e,params:void 0}))]);function cs(e,r){let{cursor:t,params:o}=l(r,Um);return x(n=>{let s;n===void 0?(invariant(o!==void 0,"Expected initial Perps PnL history params."),s={kind:"perpsPnlHistory",...o}):s=Ne(n,Zn);let{kind:a,...y}=s;return e.get("/v1/account/pnl",{params:Re(y)}).andThen(f(ListPerpsPnlHistoryResponseSchema)).map(P=>{let L=P.data.at(-1),q=P.more&&L!==void 0&&L.timestamp<s.endTimestamp;return {items:P.data,hasMore:q,nextCursor:q?xt({...s,startTimestamp:L.timestamp+us(s.interval)}):void 0}})},t)}function wr(e,r){let t=Date.now(),{end:o,start:n,...s}=e;return {...s,endTimestamp:o??t,startTimestamp:n??t-r}}function ds(e){return {endTimestamp:e.end??Date.now(),interval:e.interval,startTimestamp:e.start}}function Ne(e,r){try{return r.parse(JSON.parse(atob(e)))}catch(t){throw new c("Invalid Perps account pagination cursor",{cause:t})}}function xt(e){return toPaginationCursor(btoa(JSON.stringify(e)))}function Re(e){return g(e,h())}function Dm(e){return e.confirmedTimestamp??e.createdTimestamp}function zm(e){return e.confirmedTimestamp??e.createdTimestamp}function Lr(e){let r=e.responseData.at(-1),t=e.items.at(-1),o=(t===void 0?void 0:e.getTimestamp(t))??(r===void 0?void 0:e.getTimestamp(r)),n=e.responseMore&&o!==void 0&&o>e.state.startTimestamp;if(!n)return {items:e.items,hasMore:n};let s=t===void 0?o-1:o,a=new Set(e.state.endTimestamp===s?e.state.seenKeys:[]);for(let y of e.items)e.getTimestamp(y)===s&&a.add(e.getKey(y));return {items:e.items,hasMore:n,nextCursor:xt({...e.state,endTimestamp:s,seenKeys:Array.from(a)})}}function us(e){switch(e){case "1h":return 3600*1e3;case "4h":return 14400*1e3;case "1d":return or;case "1w":return 7*or}invariant(false,`Unsupported Perps account history interval: ${String(e)}`);}var It=z.object({instrumentId:PerpsInstrumentIdSchema,side:OrderSideSchema,quantity:PerpsDecimalInputSchema,clientOrderId:PerpsClientOrderIdSchema.optional()}),Nm=It.extend({price:PerpsDecimalInputSchema,timeInForce:z.literal(PerpsTimeInForce.GTC),postOnly:z.boolean().default(false)}),Gm=It.extend({price:PerpsDecimalInputSchema.optional(),timeInForce:z.literal(PerpsTimeInForce.IOC),postOnly:z.never().optional()}),Km=It.extend({price:PerpsDecimalInputSchema.optional(),timeInForce:z.literal(PerpsTimeInForce.FOK),postOnly:z.never().optional()}),gs=z.discriminatedUnion("timeInForce",[Nm,Gm,Km]),Mr=z.object({triggerPrice:PerpsDecimalInputSchema,limitPrice:PerpsDecimalInputSchema.optional()}),Fr=z.object({triggerPrice:PerpsDecimalInputSchema}),$m=z.union([z.object({takeProfit:Mr,stopLoss:Mr.optional()}),z.object({takeProfit:Mr.optional(),stopLoss:Mr})]),Vm=z.object({orders:z.array(gs).min(1),expiresAt:z.number().int().positive().optional()});async function qt(e,r){let t=l(r,Vm);return await e.sendSignedWsCommand({op:["createOrders",t.orders.map(Cs)],responseSchema:z.array(PerpsPostOrderAckSchema),timeoutMessage:"Perps post order acknowledgement timed out.",expiresAt:t.expiresAt})}var Ym=z.intersection(gs,z.intersection($m,z.object({expiresAt:z.number().int().positive().optional()})));function Rs(e){return e.takeProfit!==void 0||e.stopLoss!==void 0}async function Es(e,r){let t=l(r,Ym),o=[Cs(t)],n=t.side===OrderSide.SELL;return t.takeProfit!==void 0&&o.push(Dr({buy:n,instrumentId:t.instrumentId,kind:PerpsTpSlKind.TakeProfit,quantity:toDecimalString(t.quantity),trigger:t.takeProfit})),t.stopLoss!==void 0&&o.push(Dr({buy:n,instrumentId:t.instrumentId,kind:PerpsTpSlKind.StopLoss,quantity:toDecimalString(t.quantity),trigger:t.stopLoss})),await ks(e,{expiresAt:t.expiresAt,group:PerpsTpSlScope.Order,orders:o})}var Jm=z.union([z.object({takeProfit:Fr,stopLoss:Fr.optional()}),z.object({takeProfit:Fr.optional(),stopLoss:Fr})]),Zm=z.intersection(Jm,z.object({instrumentId:PerpsInstrumentIdSchema,expiresAt:z.number().int().positive().optional()})),Qm=z.intersection(Zm,z.object({buy:z.boolean()}));async function hs(e,r){let t=l(r,Qm),o=[];return t.takeProfit!==void 0&&o.push(Dr({buy:t.buy,instrumentId:t.instrumentId,kind:PerpsTpSlKind.TakeProfit,quantity:"0",trigger:t.takeProfit})),t.stopLoss!==void 0&&o.push(Dr({buy:t.buy,instrumentId:t.instrumentId,kind:PerpsTpSlKind.StopLoss,quantity:"0",trigger:t.stopLoss})),await ks(e,{expiresAt:t.expiresAt,group:PerpsTpSlScope.Position,orders:o})}var Xm=z.union([z.object({orderId:PerpsOrderIdSchema,clientOrderId:z.undefined().optional(),expiresAt:z.number().int().positive().optional()}),z.object({clientOrderId:PerpsClientOrderIdSchema,orderId:z.undefined().optional(),expiresAt:z.number().int().positive().optional()})]);async function Ss(e,r){let t=l(r,Xm),[o]=t.orderId!==void 0?await Ur(e,{orderIds:[t.orderId],expiresAt:t.expiresAt}):await Ur(e,{clientOrderIds:[t.clientOrderId],expiresAt:t.expiresAt});return expectPresent(o,"Expected Perps cancel order result.")}var el=z.union([z.object({orderIds:z.array(PerpsOrderIdSchema).min(1),clientOrderIds:z.undefined().optional(),expiresAt:z.number().int().positive().optional()}),z.object({clientOrderIds:z.array(PerpsClientOrderIdSchema).min(1),orderIds:z.undefined().optional(),expiresAt:z.number().int().positive().optional()})]);async function Ur(e,r){let t=l(r,el);return t.orderIds!==void 0?await e.sendSignedWsCommand({op:["cancelOrders",t.orderIds],responseSchema:z.array(PerpsCancelOrderResultSchema),timeoutMessage:"Perps cancel order response timed out.",expiresAt:t.expiresAt}):await e.sendSignedWsCommand({op:["cancelOrdersCOID",t.clientOrderIds],responseSchema:z.array(PerpsCancelOrderResultSchema),timeoutMessage:"Perps cancel order response timed out.",expiresAt:t.expiresAt})}var rl=z.object({instrumentId:PerpsInstrumentIdSchema,leverage:z.number().int().positive(),crossMargin:z.boolean()}),Ts=k(d,j,c,a);async function xs(e,r){let t=l(r,rl);return await e.sendSignedWsCommand({op:["updateLeverage",[t.instrumentId,t.leverage,t.crossMargin]],responseSchema:PerpsUpdateLeverageResultSchema,timeoutMessage:"Perps update leverage response timed out."})}function Cs(e){return [e.instrumentId,e.side===OrderSide.BUY,e.price===void 0?void 0:toDecimalString(e.price),toDecimalString(e.quantity),e.timeInForce,e.postOnly??false,void 0,e.clientOrderId,void 0]}function Dr(e){return [e.instrumentId,e.buy,e.trigger.limitPrice===void 0?void 0:toDecimalString(e.trigger.limitPrice),e.quantity,void 0,false,true,void 0,[e.trigger.limitPrice===void 0?true:void 0,toDecimalString(e.trigger.triggerPrice),e.kind]]}async function ks(e,r){return await e.sendSignedWsCommand({op:["createOrders",r.orders,r.group],responseSchema:z.array(PerpsPostOrderAckSchema),timeoutMessage:"Perps place TP/SL order acknowledgement timed out.",expiresAt:r.expiresAt})}function bs(e){let[r,t,o]=e;switch(r){case "createOrders":return nl({args:t.map(tl),type:r},o);case "cancelOrders":case "cancelOrdersCOID":return {type:r,args:t};case "updateLeverage":{let[n,s,a]=t;return {type:r,args:{cross:a,iid:n,lev:s}}}default:invariant(false,`Unsupported Perps command: ${String(r)}`);}}function tl(e){let r={iid:e[0],buy:e[1],po:e[5],qty:e[3]};return e[4]!==void 0&&(r.tif=e[4]),e[6]&&(r.ro=e[6]),e[2]!==void 0&&(r.p=e[2]),e[7]!==void 0&&(r.c=e[7]),e[8]!==void 0&&(r.tr=ol(e[8])),r}function ol(e){let r={tpsl:e[2],trp:e[1]};return e[0]!==void 0&&(r.market=e[0]),r}function nl(e,r){return r!==void 0&&(e.grp=r),e}var pl=3e4,vs=3e4,As=1e3,cl=["balances","portfolio","orders","fills","funding","deposits","withdrawals","tpsl"],dl=z.object({id:z.number().int().positive().optional(),data:z.unknown().optional()}).passthrough(),Os=z.union([PerpsCommandAckSchema,z.array(PerpsCommandAckSchema)]).transform(e=>Array.isArray(e)?e.find(r=>r.status==="err")??e[0]:e),ws=class{credentials;#e;#r;#t;#n;#o;#c=new vr({heartbeat:new Ir});#i=pushable({objectMode:true});#s=new Map;#p=new Set;#a=new qr;#d=new Map;#l=1;#m;constructor(r){this.#e=new br({headers:r.headers,resolveHeaders:async()=>this.#k(),root:r.restUrl}),this.#r=r.chainId,this.credentials=r.credentials,this.#t=r.headers,this.#n=r.onClose,this.#o=r.wsUrl;}get closed(){return this.#m!==void 0}async connect(){await this.#P(false);}async close(){this.#m===void 0&&(this.#m=this.#q()),await this.#m;}[Symbol.asyncIterator](){return this.#i[Symbol.asyncIterator]()}async fetchBalances(){return await Qn(this.#e)}async fetchPortfolio(){return await Xn(this.#e)}async fetchStats(){return await es(this.#e)}async fetchAccountConfig(r){return await rs(this.#e,r)}async fetchOpenOrders(r){return await ts(this.#e,r)}async fetchOrders(r){return await os(this.#e,r)}listFills(r={}){return ns(this.#e,r)}listFundingPayments(r={}){return ss(this.#e,r)}listDeposits(r={}){return as(this.#e,r)}listWithdrawals(r={}){return is(this.#e,r)}listEquityHistory(r){return ps(this.#e,r)}listPnlHistory(r){return cs(this.#e,r)}async placeOrder(r){if(Rs(r))return await this.#S(r);let[t]=await qt(this.#u(),{orders:[r],expiresAt:r.expiresAt}).then(expectNonEmptyArray);if(t.status==="err")throw new d(t.error,{status:200});return {order:(await this.#E(n=>n.type==="order"&&n.payload.id===t.orderId,As)).payload}}async postOrders(r){return await qt(this.#u(),r)}async#S(r){let t=await Es(this.#u(),r).then(expectNonEmptyArray);for(let P of t)if(P.status==="err")throw new d(P.error,{status:200});let[o]=t,n=sr(o),s=await this.#E(P=>P.type==="order"&&P.payload.id===n.orderId,As),a=1,y={};return r.takeProfit!==void 0&&(y.takeProfit=sr(expectPresent(t[a++],"Expected Perps take-profit acknowledgement."))),r.stopLoss!==void 0&&(y.stopLoss=sr(expectPresent(t[a],"Expected Perps stop-loss acknowledgement."))),{order:s.payload,tpSl:y}}async placePositionTpSl(r){let t=await hs(this.#u(),{...r,buy:await this.#T(r.instrumentId)}).then(expectNonEmptyArray);for(let s of t)if(s.status==="err")throw new d(s.error,{status:200});let o=0,n={};return r.takeProfit!==void 0&&(n.takeProfit=sr(expectPresent(t[o++],"Expected Perps take-profit acknowledgement."))),r.stopLoss!==void 0&&(n.stopLoss=sr(expectPresent(t[o],"Expected Perps stop-loss acknowledgement."))),{tpSl:n}}async#T(r){let o=(await this.fetchPortfolio()).positions.find(s=>s.instrumentId===r),n=o===void 0?0:ll(o.size);if(n===0)throw new a(`No open Perps position for instrument ${r}.`);return n<0}async cancelOrder(r){return await Ss(this.#u(),r)}async cancelOrders(r){return await Ur(this.#u(),r)}async updateLeverage(r){return await xs(this.#u(),r)}async#P(r){await this.#c.connect({onClose:()=>this.#O(),onError:()=>{},onMessage:t=>this.#v(t),onOpen:()=>{},headers:this.#t,url:this.#o}),await this.#x(),await this.#C(),this.#a.resetBackoff(),r&&(this.#d.clear(),this.#i.push({reason:"reconnect",type:"resync"}));}async#x(){await this.#f({id:this.#l++,op:{args:{proxy:this.credentials.proxy,secret:this.credentials.secret},type:"auth"},req:"post"},Os,pl,"Perps session authentication timed out.");}async#C(){await this.#f({id:this.#l++,req:"sub",chs:cl},Os,vs,"Perps session subscription timed out.");}#k(){return {"POLYMARKET-PROXY":this.credentials.proxy,"POLYMARKET-SECRET":this.credentials.secret}}#u(){return {sendSignedWsCommand:r=>this.#b(r)}}async#b(r){let t=bs(r.op),o=this.#I(r.op,r.expiresAt);return await this.#f({...o,id:this.#l++,op:t,req:"post"},r.responseSchema,vs,r.timeoutMessage)}#I(r,t){let o=fl(),n=Date.now(),s;try{s=Wn({chainId:this.#r,op:r,privateKey:this.credentials.privateKey,salt:o,timestamp:n});}catch(y){throw j.fromError(y,"Could not sign the Perps session command")}let a={salt:o,sig:s,ts:n};return t!==void 0&&(a.exp=t),a}async#f(r,t,o,n){let s=ul(t);this.#s.set(r.id,s);let a=setNonBlockingTimeout(()=>{s.reject(new c(n));},o);try{if(!this.#c.send(r))throw new c("Perps session transport is not open.");return await s.promise}finally{clearTimeout(a),this.#s.delete(r.id);}}async#q(){this.#a.stop(),this.#g(new c("Perps session closed.")),this.#h(new c("Perps session closed.")),this.#i.end(),await this.#c.close(),this.#n(this);}#v(r){if(this.#A(r))return;let t=PerpsSessionUpdateEventSchema.safeParse(r);if(!t.success)return;let o=t.data;this.#w(o),this.#R(o);}#A(r){let t=dl.safeParse(r);if(!t.success||t.data.id===void 0)return false;let o=this.#s.get(t.data.id);if(o===void 0)return true;let n=o.schema.safeParse(t.data.data);if(!n.success){let s=Ls(t.data.data??t.data);return s!==void 0?o.reject(new d(s.error,{status:200})):o.reject(new c("Perps session unexpected response.")),true}return ml(n.data)?o.reject(new d(n.data.error,{status:200})):o.resolve(n.data),true}#O(){this.#g(new c("Perps session connection closed.")),this.#h(new c("Perps session connection closed.")),this.#m===void 0&&this.#a.schedule({reconnect:()=>this.#P(true),shouldReconnect:()=>this.#m===void 0});}#g(r){for(let t of this.#s.values())t.reject(r);this.#s.clear();}#w(r){let t=this.#d.get(r.channel);this.#d.set(r.channel,r.sequence),!(t===void 0||r.sequence===t+1)&&this.#R({channel:r.channel,previousSequence:t,reason:"sequence_gap",sequence:r.sequence,type:"resync"});}#R(r){this.#M(r),this.#i.push(r);}#E(r,t){return this.#L(r,t).then(o=>o)}#L(r,t){let o,n=new Promise((s,a)=>{o={predicate:r,reject:a,resolve:s,timeout:setNonBlockingTimeout(()=>{this.#y(o),a(new f$1("Perps event wait timed out."));},t)};});return this.#p.add(o),n}#M(r){for(let t of Array.from(this.#p))t.predicate(r)&&(this.#y(t),t.resolve(r));}#y(r){this.#p.delete(r)&&clearTimeout(r.timeout);}#h(r){for(let t of Array.from(this.#p))this.#y(t),t.reject(r);}};function ul(e){let r,t;return {promise:new Promise((n,s)=>{r=n,t=s;}),reject:t,resolve:r,schema:e}}function ml(e){return Ls(e)!==void 0}function Ls(e){if(Array.isArray(e)||typeof e!="object"||e===null)return;let r=e;if(r.status==="err")return {error:typeof r.error=="string"?r.error:"Perps command failed."}}function sr(e){if(e.status==="err")throw new d(e.error,{status:200});return {orderId:e.orderId}}function ll(e){let r=e.trim(),t=r.replace(/^[+-]/,"").replace(".","");return /^0*$/.test(t)?0:r.startsWith("-")?-1:1}function fl(){let[e]=globalThis.crypto.getRandomValues(new Uint32Array(1));return invariant(e!==void 0,"Expected crypto.getRandomValues to return a salt."),e}var Ae=k(e,d,c,b,a),fe=z.number().int().nonnegative(),Bs=1440*60*1e3,Fl=z.object({instrumentId:PerpsInstrumentIdSchema.optional(),instrumentType:PerpsInstrumentTypeSchema.optional(),category:PerpsInstrumentCategorySchema.optional()}).default({}),eC=Ae;async function rC(e,r){let t=l(r,Fl);return unwrap(e.perps.get("/v1/info/instruments",{params:g(t,h())}).andThen(f(FetchPerpsInstrumentsResponseSchema)))}var Bl=z.object({instrumentId:PerpsInstrumentIdSchema}),tC=Ae;async function oC(e,r){let t=l(r,Bl),[o]=await Dl(e,t);if(o===void 0)throw new b(`Perps ticker ${t.instrumentId} was not returned by the API`);return o}var Ul=z.object({instrumentId:PerpsInstrumentIdSchema.optional()}).default({}),nC=Ae;async function Dl(e,r){let t=l(r,Ul),o=g(t,h()),[n,s]=await Promise.all([unwrap(e.perps.get("/v1/info/tickers",{params:o}).andThen(f(FetchPerpsTickersResponseSchema))),unwrap(e.perps.get("/v1/info/statistics",{params:o}).andThen(f(FetchPerpsStatisticsResponseSchema)))]),a=new Map(s.map(y=>[y.instrumentId,y]));return n.map(y=>{let P=a.get(y.instrumentId);return {...y,openPrice:P?.openPrice,volume24h:P?.volume}})}var zl=z.union([z.literal(10),z.literal(100),z.literal(500),z.literal(1e3)]),jl=z.object({instrumentId:PerpsInstrumentIdSchema,depth:zl.default(100)}),sC=Ae;async function aC(e,r){let t=l(r,jl);return unwrap(e.perps.get("/v1/info/book",{params:g(t,h())}).andThen(f(PerpsBookSchema)))}var Wl=z.object({instrumentId:PerpsInstrumentIdSchema,interval:PerpsKlineIntervalSchema,start:fe.optional(),end:fe.optional()}),Hl=z.union([Wl.extend({cursor:PaginationCursorSchema.optional()}).transform(({cursor:e,...r})=>({cursor:e,params:Vl(r)})),z.object({cursor:PaginationCursorSchema}).transform(({cursor:e})=>({cursor:e,params:void 0}))]),iC=Ae;function pC(e,r){let{cursor:t,params:o}=l(r,Hl);return x(n=>{let s=n===void 0?Yl(o):Ql(n);return e.perps.get("/v1/info/klines",{params:g({endTimestamp:s.endTimestamp,instrumentId:s.instrumentId,interval:s.interval,startTimestamp:s.startTimestamp},h())}).andThen(f(FetchPerpsCandlesResponseSchema)).map(a=>{let y=a.data.at(-1),P=a.more&&y!==void 0;return {items:a.data,hasMore:P,nextCursor:P?Lt({...s,startTimestamp:y.timestamp+rf(s.interval)}):void 0}})},t)}var Us=z.object({instrumentId:PerpsInstrumentIdSchema,start:fe.optional(),end:fe.optional()}),_l=z.union([Us.extend({cursor:PaginationCursorSchema.optional()}).transform(({cursor:e,...r})=>({cursor:e,params:Ds(r)})),z.object({cursor:PaginationCursorSchema}).transform(({cursor:e})=>({cursor:e,params:void 0}))]),cC=Ae;function dC(e,r){let{cursor:t,params:o}=l(r,_l);return x(n=>{let s=n===void 0?Jl(o):Xl(n);return e.perps.get("/v1/info/funding",{params:g({endTimestamp:s.endTimestamp,instrumentId:s.instrumentId,startTimestamp:s.startTimestamp},h())}).andThen(f(FetchPerpsFundingHistoryResponseSchema)).map(a=>{let y=a.data.at(-1),P=a.more&&y!==void 0&&y.timestamp>s.startTimestamp;return {items:a.data,hasMore:P,nextCursor:P?Lt({...s,endTimestamp:y.timestamp-1}):void 0}})},t)}var Nl=z.union([Us.extend({cursor:PaginationCursorSchema.optional()}).transform(({cursor:e,...r})=>({cursor:e,params:Ds(r)})),z.object({cursor:PaginationCursorSchema}).transform(({cursor:e})=>({cursor:e,params:void 0}))]),uC=Ae;function mC(e,r){let{cursor:t,params:o}=l(r,Nl);return x(n=>{let s=n===void 0?Zl(o):ef(n),a=new Set(s.seenTradeIds);return e.perps.get("/v1/info/trades",{params:g({endTimestamp:s.endTimestamp,instrumentId:s.instrumentId,startTimestamp:s.startTimestamp},h())}).andThen(f(FetchPerpsTradesResponseSchema)).map(y=>{let P=y.data.filter(Ca=>!a.has(Ca.tradeId)),L=y.data.at(-1),q=P.at(-1),$=q?.timestamp??L?.timestamp,M=y.more&&$!==void 0&&$>s.startTimestamp;return {items:P,hasMore:M,nextCursor:M?Lt({...s,endTimestamp:q===void 0?$-1:$,seenTradeIds:q===void 0?[]:tf(s,P,q)}):void 0}})},t)}var lC=k(e,d,c,b);async function fC(e){return (await unwrap(e.perps.get("/v1/info/fees").andThen(f(FetchPerpsFeesResponseSchema)))).feeSchedule}var Gl=z.object({kind:z.literal("perpsCandles"),instrumentId:PerpsInstrumentIdSchema,interval:PerpsKlineIntervalSchema,startTimestamp:fe,endTimestamp:fe}),Kl=z.object({kind:z.literal("perpsFundingHistory"),instrumentId:PerpsInstrumentIdSchema,startTimestamp:fe,endTimestamp:fe}),$l=z.object({kind:z.literal("perpsTrades"),instrumentId:PerpsInstrumentIdSchema,startTimestamp:fe,endTimestamp:fe,seenTradeIds:z.array(PerpsTradeIdSchema)});function Vl(e){let r=Date.now();return {endTimestamp:e.end??r,instrumentId:e.instrumentId,interval:e.interval,startTimestamp:e.start??r-Bs}}function Ds(e){let r=Date.now();return {endTimestamp:e.end??r,instrumentId:e.instrumentId,startTimestamp:e.start??r-Bs}}function Yl(e){return invariant(e!==void 0,"Expected initial Perps candles params."),{kind:"perpsCandles",...e}}function Jl(e){return invariant(e!==void 0,"Expected initial Perps funding params."),{kind:"perpsFundingHistory",...e}}function Zl(e){return invariant(e!==void 0,"Expected initial Perps trades params."),{kind:"perpsTrades",seenTradeIds:[],...e}}function Ql(e){return wt(e,Gl)}function Xl(e){return wt(e,Kl)}function ef(e){return wt(e,$l)}function wt(e,r){try{return r.parse(JSON.parse(atob(e)))}catch(t){throw new a("Invalid Perps pagination cursor",{cause:t})}}function Lt(e){return toPaginationCursor(btoa(JSON.stringify(e)))}function rf(e){switch(e){case "1s":return 1e3;case "1m":return 60*1e3;case "5m":return 300*1e3;case "15m":return 900*1e3;case "1h":return 3600*1e3;case "4h":return 14400*1e3;case "1d":return 1440*60*1e3;case "1w":return 10080*60*1e3}invariant(false,`Unsupported Perps kline interval: ${String(e)}`);}function tf(e,r,t){let o=new Set(e.endTimestamp===t.timestamp?e.seenTradeIds:[]);for(let n of r)n.timestamp===t.timestamp&&o.add(n.tradeId);return Array.from(o)}var of=z.custom(e=>isPrivateKey(e),"Expected a hex-encoded 32-byte private key."),nf=z.object({proxy:z.string().transform(e=>expectEvmAddress(e)),privateKey:of,secret:z.string().min(1),expiresAt:z.number().int().positive()}),sf=10080*60*1e3,af=z.strictObject({expiresIn:z.number().int().positive().default(sf),label:z.string().min(1).optional()}),pf=z.strictObject({credentials:nf}),cf=z.union([af,pf]),df=z.object({proxy:z.string().transform(e=>expectEvmAddress(e))}),zs=z.bigint().positive().max(Y),uf=z.object({amount:zs,metadata:G.optional()}),mf=z.object({amount:zs}),yC=k(e,d,j,c,b,a),PC=k(e,d,j,c,b,a),gC=k(a),RC=k(h$1,e,d,j,c,b,a),EC=k(e,d,j,c,b,a);async function hC(e,r={}){let t=l(r,cf),o="credentials"in t?await yf(e,t.credentials):await ff(e,t);return e.webSockets.perpsSession.connect(o)}async function SC(e,r){let t=l(r,df),o={type:"deleteProxy",args:{proxy:t.proxy}},n=["deleteProxy",[t.proxy]],s=Mt(),a=Date.now(),y=await gf(e,{salt:s,signedOp:n,timestamp:a}),P=await unwrap(e.perps.del("/v1/account/proxy",{json:{op:o,salt:s,sig:y,ts:a}}).andThen(f(PerpsDeleteProxyResponseSchema)));if(P.status==="err")throw new d(P.error??"Perps credentials revocation was rejected.",{status:200})}async function lf(e,r){let t=l(r,uf),{contracts:o}=e.environment,n=bo(o.perpsDepositContract,o.collateralToken,t.amount,e.account.signer);return async function*(){return e.account.walletType===WalletType.EOA?_(yield Cf(N(e.environment.chainId,n))):yield*await J(e,{calls:[n],metadata:t.metadata??`Deposit ${t.amount} of ${o.collateralToken} to Perps`})}.call(null)}function TC(e,r){return lf(e,r).then(H(e.signer))}async function xC(e,r){let t=l(r,mf),o=Math.floor(Date.now()/1e3),n=Mt(),s={type:"withdraw",args:{account:e.account.signer,token:e.environment.contracts.collateralToken,amount:t.amount.toString(),to:e.account.wallet}},a=await Rf(e,{amount:t.amount,salt:n,timestamp:o}),y=await unwrap(e.perps.post("/v1/account/withdraw",{json:{op:s,salt:n,sig:a,ts:o}}).andThen(f(PerpsWithdrawResponseSchema)));if(y.status==="err")throw new d(y.error??"Perps withdrawal was rejected.",{status:200});if(y.withdrawalId===void 0)throw new b("Perps withdrawal response did not include a withdrawal ID.");return y.withdrawalId}async function ff(e,r){let t=Sf(),o=Ws(t),n=e.account.signer,s=Date.now()+r.expiresIn,a=Date.now(),y=Mt(),P={args:{expiry:s,owner:n,proxy:o},type:"createProxy"},L=await Pf(e,{expiresAt:s,proxy:o,salt:y,timestamp:a}),q={op:P,salt:y,sig:L,ts:a};r.label!==void 0&&(q.label=r.label);let $=await unwrap(e.perps.post("/v1/account/proxy",{json:q}).andThen(f(PerpsCreateProxyResponseSchema))),M={expiresAt:s,privateKey:t,proxy:o,secret:$.secret};return js(e,M)}async function yf(e,r){return Tf(r),js(e,r)}async function js(e,r){let t=await unwrap(e.perps.get("/v1/account/credentials",{headers:xf(r)}).andThen(f(PerpsCredentialsResponseSchema)));if(!isSameEvmAddress(t.address,e.account.signer))throw new b("Perps credentials belong to a different signer account.");let o=t.keys.find(n=>isSameEvmAddress(n.proxy,r.proxy));if(o===void 0)throw new b("Perps credentials were not returned by the API.");if(o.expiresAt<=Date.now())throw new b("Perps credentials are expired.");return {...r,expiresAt:o.expiresAt}}async function Pf(e,r){try{return await e.signer.signTypedData(hf({chainId:e.environment.chainId,...r}))}catch(t){throw j.fromError(t,"Could not sign the Perps proxy credentials request")}}async function gf(e,r){try{return await e.signer.signTypedData(ht({chainId:e.environment.chainId,op:r.signedOp,salt:r.salt,timestamp:r.timestamp}))}catch(t){throw j.fromError(t,"Could not sign the Perps operation request")}}async function Rf(e,r){try{return await e.signer.signTypedData(Ef({account:e.account.signer,chainId:e.environment.chainId,contract:e.environment.contracts.perpsDepositContract,token:e.environment.contracts.collateralToken,to:e.account.wallet,...r}))}catch(t){throw j.fromError(t,"Could not sign the Perps withdrawal request")}}function Ef(e){return {domain:{chainId:e.chainId,name:"Polymarket",verifyingContract:e.contract,version:"1"},message:{account:e.account,amount:e.amount,fee:0n,salt:e.salt,token:e.token,to:e.to,ts:e.timestamp},primaryType:"Withdraw",types:{Withdraw:[{name:"account",type:"address"},{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"fee",type:"uint256"},{name:"to",type:"address"},{name:"salt",type:"uint64"},{name:"ts",type:"uint64"}]}}}function hf(e){return {domain:{chainId:e.chainId,name:"Polymarket",version:"1"},message:{addr:e.proxy,exp:e.expiresAt,salt:e.salt,ts:e.timestamp},primaryType:"CreateProxy",types:{CreateProxy:[{name:"addr",type:"address"},{name:"exp",type:"uint64"},{name:"salt",type:"uint64"},{name:"ts",type:"uint64"}]}}}function Sf(){return expectPrivateKey(Secp256k1.randomPrivateKey(),"Generated invalid Perps proxy key.")}function Ws(e){return expectEvmAddress(Address.fromPublicKey(Secp256k1.getPublicKey({privateKey:e})))}function Tf(e){let r=Ws(e.privateKey);if(!isSameEvmAddress(r,e.proxy))throw new a("Perps credentials private key does not match the proxy address.")}function xf(e){return {"POLYMARKET-PROXY":e.proxy,"POLYMARKET-SECRET":e.secret}}function Cf(e){return {kind:"sendPerpsDepositTransaction",request:e}}function Mt(){let[e]=crypto.getRandomValues(new Uint32Array(1));return invariant(e!==void 0,"Expected crypto.getRandomValues to return a salt."),e}var Lf=z.enum(["CURRENT","INITIAL","TOKENS","CASHPNL","PERCENTPNL","TITLE","RESOLVING","PRICE","AVGPRICE"]),Hs=z.enum(["ASC","DESC"]),Mf=z.enum(["REALIZEDPNL","TITLE","PRICE","AVGPRICE","TIMESTAMP"]),Ff=z.object({cursor:PaginationCursorSchema.optional(),user:z.string(),market:z.array(z.string()).optional(),eventId:z.array(z.number().int()).optional(),sizeThreshold:z.number().optional(),redeemable:z.boolean().optional(),mergeable:z.boolean().optional(),pageSize:A.default(20),sortBy:Lf.optional(),sortDirection:Hs.optional(),title:z.string().max(100).optional()}).refine(e=>!(e.market&&e.eventId),{message:"Provide market or eventId, not both",path:["eventId"]}),Bf=z.object({cursor:PaginationCursorSchema.optional(),user:z.string(),market:z.array(z.string()).optional(),title:z.string().max(100).optional(),eventId:z.array(z.number().int()).optional(),pageSize:A.default(20),sortBy:Mf.optional(),sortDirection:Hs.optional()}).refine(e=>!(e.market&&e.eventId),{message:"Provide market or eventId, not both",path:["eventId"]}),Uf=z.object({cursor:PaginationCursorSchema.optional(),user:z.string(),pageSize:A.default(20),status:ComboPositionStatusSchema.optional(),conditionId:ComboConditionIdSchema.optional(),positionId:PositionIdSchema.optional()}),Df=z.object({user:z.string(),market:z.array(z.string()).optional()}),zf=z.object({user:z.string()}),jf=z.object({user:z.string()}),FC=k(e,d,c,b,a);function BC(e,r){let{cursor:t,pageSize:o,...n}=l(r,Ff);return x(s=>{let a=U(s,o);return e.data.get("/positions",{params:W({...n,limit:a.pageSize+1,offset:a.offset})}).andThen(f(ListPositionsResponseSchema)).map(y=>{let P=y.length>a.pageSize;return {items:y.slice(0,a.pageSize),hasMore:P,nextCursor:P?F({offset:a.offset+a.pageSize,pageSize:a.pageSize}):void 0}})},t)}var UC=k(e,d,c,b,a),DC=k(e,d,c,b,a);function zC(e,r){let{cursor:t,pageSize:o,...n}=l(r,Bf);return x(s=>{let a=U(s,o);return e.data.get("/closed-positions",{params:W({...n,limit:a.pageSize+1,offset:a.offset})}).andThen(f(ListClosedPositionsResponseSchema)).map(y=>{let P=y.length>a.pageSize;return {items:y.slice(0,a.pageSize),hasMore:P,nextCursor:P?F({offset:a.offset+a.pageSize,pageSize:a.pageSize}):void 0}})},t)}function jC(e,r){let{cursor:t,pageSize:o,...n}=l(r,Uf);return x(s=>{let a=U(s,o);return e.data.get("/v1/positions/combos",{params:g({...n,limit:a.pageSize+1,offset:a.offset},h({conditionId:"combo_condition_id",positionId:"combo_position_id"}))}).andThen(f(ListComboPositionsResponseSchema)).map(y=>{let P=y.combos.length>a.pageSize;return {items:y.combos.slice(0,a.pageSize),hasMore:P,nextCursor:P?F({offset:a.offset+a.pageSize,pageSize:a.pageSize}):void 0}})},t)}var WC=k(e,d,c,b,a);async function HC(e,r){let t=l(r,Df);return unwrap(e.data.get("/value",{params:W(t)}).andThen(f(FetchPortfolioValueResponseSchema)))}var _C=k(e,d,c,b,a);async function NC(e,r){let t=l(r,zf);return unwrap(e.data.get("/traded",{params:W(t)}).andThen(f(TradedSchema)))}var GC=k(e,d,c,b,a);async function KC(e,r){let t=l(r,jf);return unwrap(e.data.get("/v1/accounting/snapshot",{params:W(t)}).andThen(Yt))}var $s=32,Vs=3n,Gs=50,Hf=(1n<<256n)-1n;function Ut(e){let r=AbiParameters.encode([{name:"legs",type:"uint256[]"}],[e]),t=Hash.keccak256(AbiParameters.encode([{name:"moduleId",type:"uint256"},{name:"data",type:"bytes"}],[Vs,r])),o=toComboConditionId(`0x03${t.slice(34)}0000000000000000000000000000`);return {conditionId:o,positionIds:[toPositionId(BigInt(`${o}00`).toString()),toPositionId(BigInt(`${o}01`).toString())]}}function Ys(e){if(e.length===0||e.length>Gs)throw new a(`Combo legs must include 1 to ${Gs} position IDs`);let r=e.map(t=>{let o=Zs(t),n=o.toString(16).padStart($s*2,"0"),s=Number.parseInt(n.slice(0,2),16),a$1=Number.parseInt(n.slice(-2),16);if(s!==1&&s!==2||a$1>1)throw new a("Combo legs must be binary or neg-risk YES/NO position IDs");return {value:o,conditionId:n.slice(0,-2)}});r.sort((t,o)=>t.value<o.value?-1:t.value>o.value?1:0);for(let t=1;t<r.length;t+=1){let o=r[t-1],n=r[t];if(o===void 0||n===void 0)throw new a("Invalid combo leg set");if(o.value===n.value)throw new a("Combo legs must not contain duplicate position IDs");if(o.conditionId===n.conditionId)throw new a("Combo legs must not contain both outcomes for the same condition")}return r.map(t=>t.value)}function Js(e){let t=Zs(e).toString(16).padStart($s*2,"0"),o=BigInt(`0x${t.slice(0,2)}`),n=Number.parseInt(t.slice(-2),16);if(o!==Vs)throw new a("Combo position ID must use the combinatorial module");if(n!==0&&n!==1)throw new a("Combo position ID must be a YES/NO position ID");return {conditionId:toComboConditionId(`0x${t.slice(0,-2)}`),outcomeIndex:n}}function Zs(e){let r=e.trim(),t;if(r.length===0)throw new a("Position ID must be a uint256 value");try{t=BigInt(r);}catch{throw new a("Position ID must be a uint256 value")}if(t<0n||t>Hf)throw new a("Position ID must be a uint256 value");return t}var Xs=z.object({amount:z.bigint().min(0n),conditionId:CtfConditionIdSchema,metadata:G.optional()}),Nf=z.object({amount:z.bigint().positive(),legs:z.array(PositionIdSchema).min(1).max(50),metadata:G.optional()}),ea=z.array(PositionIdSchema).min(1).max(50).transform(Ys),Gf=z.object({amount:z.bigint().positive(),legs:ea,metadata:G.optional()}),Kf=z.union([Xs.extend({legs:z.never().optional()}),Nf.extend({conditionId:z.never().optional()})]),ra=k(e,d,c,b,a),mk=ra,lk=ra,ta=k(e,d,c,b,a),fk=ta,yk=ta,oa=k(e,d,c,b,a),Pk=oa,gk=oa;async function na(e,r){let t=l(r,Xs),o=await Wt(e,{conditionId:t.conditionId}),n=Io(o.adapterAddress,e.environment.contracts.collateralToken,o.conditionId,t.amount);return async function*(){return e.account.walletType===WalletType.EOA?_(yield Dt(N(e.environment.chainId,n))):yield*await J(e,{calls:[n],metadata:t.metadata??`Split ${t.amount} positions for market ${o.marketId} (condition ${o.conditionId})`})}.call(null)}async function sa(e,r){let t=l(r,Gf),o=Yr(e.environment.contracts.combinatorialModule,t.legs),n=Ut(t.legs),s=Ao(e.environment.contracts.protocolV2Router,n.conditionId,t.amount);return async function*(){return e.account.walletType===WalletType.EOA?(await _(yield Dt(N(e.environment.chainId,o))).wait(),_(yield Dt(N(e.environment.chainId,s)))):yield*await J(e,{calls:[o,s],metadata:t.metadata??`Split ${t.amount} combo positions for condition ${n.conditionId}`})}.call(null)}async function $f(e,r){let t=l(r,Kf);return t.legs!==void 0?sa(e,t):na(e,t)}var aa=k(h$1,e,d,j,f$1,g$1,c,b,a),Rk=aa,Ek=aa;function hk(e,r){return na(e,r).then(H(e.signer))}function Sk(e,r){return sa(e,r).then(H(e.signer))}function Tk(e,r){return $f(e,r).then(H(e.signer))}var ia=z.object({amount:z.union([z.bigint().positive(),z.literal("max")]),conditionId:CtfConditionIdSchema,metadata:G.optional()}),Vf=z.object({amount:z.union([z.bigint().positive(),z.literal("max")]),legs:z.array(PositionIdSchema).min(1).max(50),metadata:G.optional()}),Yf=z.object({amount:z.union([z.bigint().positive(),z.literal("max")]),legs:ea,metadata:G.optional()}),Jf=z.union([ia.extend({legs:z.never().optional()}),Vf.extend({conditionId:z.never().optional()})]);async function pa(e,r){let t=l(r,ia),o=await Wt(e,{conditionId:t.conditionId}),n=$r(await e.rpc.ethCall(Kr(o.positionErc1155Address,e.account.wallet,o.tokenIds))),s=ya(o.conditionId,n,t.amount),a=qo(o.adapterAddress,e.environment.contracts.collateralToken,o.conditionId,s);return async function*(){return e.account.walletType===WalletType.EOA?_(yield zt(N(e.environment.chainId,a))):yield*await J(e,{calls:[a],metadata:t.metadata??`Merge ${s} positions for market ${o.marketId} (condition ${o.conditionId})`})}.call(null)}async function ca(e,r){let t=l(r,Yf),o=Yr(e.environment.contracts.combinatorialModule,t.legs),n=Ut(t.legs),s=$r(await e.rpc.ethCall(Kr(e.environment.contracts.positionManager,e.account.wallet,n.positionIds))),a=ya(n.conditionId,s,t.amount),y=Oo(e.environment.contracts.protocolV2Router,n.conditionId,a);return async function*(){return e.account.walletType===WalletType.EOA?(await _(yield zt(N(e.environment.chainId,o))).wait(),_(yield zt(N(e.environment.chainId,y)))):yield*await J(e,{calls:[o,y],metadata:t.metadata??`Merge ${a} combo positions for condition ${n.conditionId}`})}.call(null)}async function Zf(e,r){let t=l(r,Jf);return t.legs!==void 0?ca(e,t):pa(e,t)}var da=k(h$1,e,d,j,f$1,g$1,c,b,a),xk=da,Ck=da;function kk(e,r){return pa(e,r).then(H(e.signer))}function bk(e,r){return ca(e,r).then(H(e.signer))}function Ik(e,r){return Zf(e,r).then(H(e.signer))}var ua=z.object({conditionId:CtfConditionIdSchema,marketId:z.never().optional(),amount:z.never().optional(),positionId:z.never().optional(),metadata:G.optional()}),ma=z.object({conditionId:z.never().optional(),marketId:MarketIdSchema,amount:z.never().optional(),positionId:z.never().optional(),metadata:G.optional()}),Qf=z.union([ua,ma]),la=z.object({positionId:PositionIdSchema,conditionId:z.never().optional(),marketId:z.never().optional(),metadata:G.optional()}),Xf=z.union([ua,ma,la]);async function ey(e,r){let t=l(r,Qf),o=await Wt(e,t.conditionId!==void 0?{conditionId:t.conditionId}:{marketId:t.marketId}),n=vo(o.adapterAddress,e.environment.contracts.collateralToken,o.conditionId);return async function*(){return e.account.walletType===WalletType.EOA?_(yield fa(N(e.environment.chainId,n))):yield*await J(e,{calls:[n],metadata:t.metadata??`Redeem positions for market ${o.marketId} (condition ${o.conditionId})`})}.call(null)}async function ry(e,r){let t=l(r,la),o=Js(t.positionId),n=ko(await e.rpc.ethCall(Co(e.environment.contracts.positionManager,e.account.wallet,t.positionId)));if(n===0n)throw new a("Combo position has no balance to redeem");let s=wo(e.environment.contracts.protocolV2Router,o.conditionId,o.outcomeIndex,n);return async function*(){return e.account.walletType===WalletType.EOA?_(yield fa(N(e.environment.chainId,s))):yield*await J(e,{calls:[s],metadata:t.metadata??`Redeem combo position ${t.positionId}`})}.call(null)}async function ty(e,r){let t=l(r,Xf);return t.positionId!==void 0?ry(e,t):ey(e,t)}var qk=k(h$1,e,d,j,c,b,a);function vk(e,r){return ty(e,r).then(H(e.signer))}function Dt(e){return {kind:"sendSplitPositionTransaction",request:e}}function zt(e){return {kind:"sendMergePositionsTransaction",request:e}}function fa(e){return {kind:"sendRedeemPositionsTransaction",request:e}}async function Wt(e,r){let t=r.conditionId!==void 0?`condition ${r.conditionId}`:`market ${r.marketId}`,o=await cn(e,r.conditionId!==void 0?{conditionIds:[r.conditionId],pageSize:1}:{ids:[oy(r.marketId)],pageSize:1}).firstPage(),[n]=o.items;if(n===void 0)throw new a(`No market found for ${t}`);let s=ny(n,t);return {...s,adapterAddress:s.negRisk?e.environment.contracts.negRiskCollateralAdapter:e.environment.contracts.collateralAdapter,positionErc1155Address:s.negRisk?e.environment.contracts.negRiskAdapter:e.environment.contracts.conditionalTokens}}function oy(e){let r=Number(e);if(!Number.isInteger(r))throw new a(`Market ID must be an integer, received ${e}`);return r}function ny(e,r){if(!isPresent(e.conditionId))throw new b(`Missing condition ID for ${r}`);if(!isPresent(e.state.negRisk))throw new b(`Missing negative-risk flag for ${r}`);let t=e.outcomes.yes.tokenId,o=e.outcomes.no.tokenId;if(!isPresent(t)||!isPresent(o))throw new b(`Missing market token IDs for ${r}`);return {marketId:e.id,conditionId:e.conditionId,negRisk:e.state.negRisk,tokenIds:[t,o]}}function ya(e,r,t){let o=sy(r);if(o===0n)throw new a(`You have no complementary positions to merge for condition ${e}`);if(t==="max")return o;if(t>o)throw new a(`Requested merge amount ${t} exceeds the maximum mergeable amount ${o} for condition ${e}`);return t}function sy(e){if(e.length!==2)throw new b("Expected two position balances");let[r,t]=e;return invariant(r!==void 0,"Expected YES position balance"),invariant(t!==void 0,"Expected NO position balance"),r<t?r:t}var dy=z.object({address:z.string()}),Dk=k(e,d,c,b,a);async function zk(e,r){let t=l(r,dy);return unwrap(e.gamma.get("/public-profile",{params:g(t,h())}).andThen(f(PublicProfileSchema)).orElse(o=>o instanceof d&&o.status===404?ok(null):err(o)))}var Ht=class extends PolymarketError{name="RfqQuoteRejectedError";code;errorId;rfqId;constructor(r,t){super(r,t),this.code=t.code,this.errorId=t.errorId,this.rfqId=t.rfqId;}},_k=k(Ht,j,f$1,c,a),_t=class extends PolymarketError{name="RfqCancelQuoteRejectedError";code;errorId;rfqId;quoteId;constructor(r,t){super(r,t),this.code=t.code,this.errorId=t.errorId,this.rfqId=t.rfqId,this.quoteId=t.quoteId;}},Nk=k(_t,f$1,c),Nt=class extends PolymarketError{name="RfqConfirmationRejectedError";code;errorId;rfqId;quoteId;constructor(r,t){super(r,t),this.code=t.code,this.errorId=t.errorId,this.rfqId=t.rfqId,this.quoteId=t.quoteId;}},Gk=k(Nt,f$1,c),Kk=k(c);async function $k(e){return e.webSockets.rfqQuoter.connect()}var ga=(y=>(y.Volume="volume",y.Volume24Hr="volume_24hr",y.Liquidity="liquidity",y.Competitive="competitive",y.ClosedTime="closed_time",y.StartDate="start_date",y.EndDate="end_date",y))(ga||{}),ly=z.object({q:z.string().trim().min(1),ascending:z.boolean().optional(),cache:z.boolean().optional(),cursor:PaginationCursorSchema.optional(),eventsStatus:z.string().min(1).optional(),eventsTag:z.array(z.string()).optional(),excludeTagIds:z.array(z.number().int()).optional(),keepClosedMarkets:z.number().int().optional(),optimized:z.boolean().optional(),pageSize:A.default(10),presets:z.array(z.string()).optional(),recurrence:z.enum(["daily","weekly","monthly"]).optional(),searchProfiles:z.boolean().optional(),searchTags:z.boolean().optional(),sort:z.enum(ga).optional()}),db=k(e,d,c,b,a);function ub(e,r){let{cursor:t,pageSize:o,...n}=l(r,ly);return x(s=>{let a=U(s,o);return e.gamma.get("/public-search",{params:g({...n,limitPerType:a.pageSize,page:a.offset},h({excludeTagIds:"exclude_tag_id"}))}).andThen(f(PublicSearchResponseSchema)).map(y=>({items:fy(y),hasMore:y.pagination?.hasMore??false,totalCount:y.pagination?.totalResults??void 0,nextCursor:y.pagination?.hasMore?F({offset:a.offset+1,pageSize:a.pageSize}):void 0}))},t??F({offset:1,pageSize:o}),{events:[],profiles:[],tags:[]})}function fy(e){return {events:e.events??[],profiles:e.profiles??[],tags:e.tags??[]}}var Ey=z.object({ascending:z.boolean().optional(),closed:z.boolean().optional(),cursor:PaginationCursorSchema.optional(),excludeEvents:z.boolean().optional(),locale:z.string().optional(),order:z.string().optional(),pageSize:A.default(20),recurrence:z.enum(["daily","weekly","monthly"]).optional(),slug:z.array(z.string()).optional()}),hy=z.object({id:z.string(),locale:z.string().optional()}),Tb=k(e,d,c,b,a);function xb(e,r={}){let{cursor:t,pageSize:o,...n}=l(r,Ey);return x(s=>{let a=U(s,o);return e.gamma.get("/series",{params:g({...n,limit:a.pageSize+1,offset:a.offset},h())}).andThen(f(ListSeriesResponseSchema)).map(y=>{let P=y.length>a.pageSize;return {items:y.slice(0,a.pageSize),hasMore:P,nextCursor:P?F({offset:a.offset+a.pageSize,pageSize:a.pageSize}):void 0}})},t)}var Cb=k(e,d,c,b,a);async function kb(e,r){let t=l(r,hy);return unwrap(e.gamma.get(`series/${t.id}`,{params:g({locale:t.locale},h())}).andThen(f(SeriesSchema)))}var Ob=k(e,d,c,b);async function wb(e){return unwrap(e.gamma.get("/sports").andThen(f(ListSportsMetadataResponseSchema)))}var Lb=k(e,d,c,b);async function Mb(e){return unwrap(e.gamma.get("/sports/market-types").andThen(f(SportsMarketTypesResponseSchema)))}async function Db(e,r){let t=await Promise.all(r.map(o=>ky(e,o)));return by(t)}function ky(e,r){switch(r.topic){case "market":return e.webSockets.clobMarket.subscribe(r);case "sports":return e.webSockets.sports.subscribe(r);case "comments":case "prices.crypto.binance":case "prices.crypto.chainlink":case "prices.equity.pyth":return e.webSockets.rtds.subscribe(r);case "perps.trades":case "perps.bbo":case "perps.book":case "perps.candles":case "perps.tickers":case "perps.statistics":return e.webSockets.perpsSubscriptions.subscribe(r);case "user":return invariant(e.isSecureClient(),"A 'user' subscription requires a secure client instance."),e.webSockets.clobUser.subscribe(r)}}function by(e){let r;async function t(){r===void 0&&(r=Promise.all(e.map(n=>n.close())).then(()=>{})),await r;}let o=Cy(...e);return {close:t,[Symbol.asyncIterator](){return o[Symbol.asyncIterator]()}}}var vy=z.object({ascending:z.boolean().optional(),cursor:PaginationCursorSchema.optional(),includeTemplate:z.boolean().optional(),isCarousel:z.boolean().optional(),locale:z.string().optional(),order:z.string().optional(),pageSize:A.default(20)}),Ay=z.union([z.object({id:z.string(),includeTemplate:z.boolean().optional(),locale:z.string().optional()}),z.object({slug:z.string(),locale:z.string().optional()})]),Oy=z.object({id:z.string(),omitEmpty:z.boolean().optional(),status:z.enum(["active","closed","all"]).optional()}),wy=z.object({slug:z.string()}),Ly=z.object({id:z.string(),locale:z.string().optional(),omitEmpty:z.boolean().optional(),status:z.enum(["active","closed","all"]).optional()}),My=z.object({locale:z.string().optional(),slug:z.string(),omitEmpty:z.boolean().optional(),status:z.enum(["active","closed","all"]).optional()}),Yb=k(e,d,c,b,a);function Jb(e,r={}){let{cursor:t,pageSize:o,...n}=l(r,vy);return x(s=>{let a=U(s,o);return e.gamma.get("/tags",{params:g({...n,limit:a.pageSize+1,offset:a.offset},h())}).andThen(f(ListTagsResponseSchema)).map(y=>{let P=y.length>a.pageSize;return {items:y.slice(0,a.pageSize),hasMore:P,nextCursor:P?F({offset:a.offset+a.pageSize,pageSize:a.pageSize}):void 0}})},t)}var Zb=k(e,d,c,b,a);async function Qb(e,r){let t=l(r,Ay);return "id"in t?unwrap(e.gamma.get(`tags/${t.id}`,{params:g({includeTemplate:t.includeTemplate,locale:t.locale},h())}).andThen(f(TagSchema))):unwrap(e.gamma.get(`tags/slug/${t.slug}`,{params:g({locale:t.locale},h())}).andThen(f(TagSchema)))}var Xb=k(e,d,c,b,a);async function eI(e,r){if("id"in r){let o=l(r,Oy);return unwrap(e.gamma.get(`tags/${o.id}/related-tags`,{params:g({omitEmpty:o.omitEmpty,status:o.status},h())}).andThen(f(ListRelatedTagsResponseSchema)))}let t=l(r,wy);return unwrap(e.gamma.get(`tags/slug/${t.slug}/related-tags`).andThen(f(ListRelatedTagsResponseSchema)))}var rI=k(e,d,c,b,a);async function tI(e,r){if("id"in r){let o=l(r,Ly);return unwrap(e.gamma.get(`tags/${o.id}/related-tags/tags`,{params:g({locale:o.locale,omitEmpty:o.omitEmpty,status:o.status},h())}).andThen(f(ListRelatedTagResourcesResponseSchema)))}let t=l(r,My);return unwrap(e.gamma.get(`tags/slug/${t.slug}/related-tags/tags`,{params:g({locale:t.locale,omitEmpty:t.omitEmpty,status:t.status},h())}).andThen(f(ListRelatedTagResourcesResponseSchema)))}var Uy=z.object({abbreviation:z.array(z.string()).optional(),ascending:z.boolean().optional(),cursor:PaginationCursorSchema.optional(),league:z.array(z.string()).optional(),name:z.array(z.string()).optional(),order:z.string().optional(),pageSize:A.default(20),providerId:z.array(z.number().int()).optional()}),mI=k(e,d,c,b,a);function lI(e,r={}){let{cursor:t,pageSize:o,...n}=l(r,Uy);return x(s=>{let a=U(s,o);return e.gamma.get("/teams",{params:g({...n,limit:a.pageSize+1,offset:a.offset},h({providerId:"provider_id"}))}).andThen(f(ListTeamsResponseSchema)).map(y=>{let P=y.length>a.pageSize;return {items:y.slice(0,a.pageSize),hasMore:P,nextCursor:P?F({offset:a.offset+a.pageSize,pageSize:a.pageSize}):void 0}})},t)}var zy=z.object({amount:z.bigint(),metadata:G.optional(),recipientAddress:EvmAddressSchema,tokenAddress:EvmAddressSchema}),CI=k(a);async function jy(e,r){let t=l(r,zy);return async function*(){return e.account.walletType===WalletType.EOA?_(yield Wy(N(e.environment.chainId,Vr(t.tokenAddress,t.recipientAddress,t.amount)))):yield*await J(e,{calls:[Vr(t.tokenAddress,t.recipientAddress,t.amount)],metadata:t.metadata??`Transfer ${t.amount} of ${t.tokenAddress} to ${t.recipientAddress}`})}.call(null)}var kI=k(h$1,e,d,j,c,b,a);function bI(e,r){return jy(e,r).then(H(e.signer))}function Wy(e){return {kind:"sendErc20TransferTransaction",request:e}}export{co as $,kR as $a,ph as $b,NT as $c,lk as $d,wb as $e,Pg as A,Gg as Aa,rn as Ab,dS as Ac,lC as Ad,ty as Ae,wo as B,Cp as Ba,mE as Bb,uS as Bc,fC as Bd,qk as Be,gg as C,Kg as Ca,lE as Cb,mS as Cc,yC as Cd,vk as Ce,Yr as D,J as Da,fE as Db,lS as Dc,PC as Dd,Dk as De,Lo as E,$g as Ea,yE as Eb,fS as Ec,gC as Ed,zk as Ee,Mo as F,nR as Fa,PE as Fb,TS as Fc,RC as Fd,Ht as Fe,l as G,jp as Ga,gE as Gb,xS as Gc,EC as Gd,_k as Ge,Zt as H,sR as Ha,RE as Hb,st as Hc,hC as Hd,_t as He,aP as I,jo as Ia,EE as Ib,wS as Ic,SC as Id,Nk as Ie,oo as J,aR as Ja,hE as Jb,LS as Jc,lf as Jd,Nt as Je,no as K,Hp as Ka,SE as Kb,kr as Kc,TC as Kd,Gk as Ke,so as L,iR as La,TE as Lb,MS as Lc,xC as Ld,Kk as Le,EP as M,Wo as Ma,xE as Mb,vn as Mc,FC as Md,$k as Me,hP as N,pR as Na,CE as Nb,An as Nc,BC as Nd,SP as O,_p as Oa,kE as Ob,Pt as Oc,UC as Od,TP as P,cR as Pa,bE as Pb,Fu as Pc,DC as Pd,xP as Q,dR as Qa,IE as Qb,gt as Qc,zC as Qd,CP as R,gR as Ra,DE as Rb,Bu as Rc,jC as Rd,kP as S,Jp as Sa,zE as Sb,Rt as Sc,WC as Sd,bP as T,RR as Ta,jE as Tb,hT as Tc,HC as Td,ga as Te,IP as U,Zp as Ua,WE as Ub,ST as Uc,_C as Ud,db as Ue,qP as V,ER as Va,HE as Vb,TT as Vc,NC as Vd,ub as Ve,vP as W,hR as Wa,_E as Wb,xT as Wc,GC as Wd,Tb as We,AP as X,SR as Xa,nh as Xb,WT as Xc,KC as Xd,xb as Xe,OP as Y,TR as Ya,sh as Yb,zu as Yc,Cb as Ye,Nr as Z,xR as Za,ah as Zb,HT as Zc,ra as Zd,kb as Ze,wP as _,CR as _a,ih as _b,_T as _c,mk as _d,Ob as _e,Y as a,LP as aa,bR as ab,ch as ac,ju as ad,ta as ae,Lb as af,pg as b,MP as ba,IR as bb,dh as bc,GT as bd,fk as be,Mb as bf,mr as c,FP as ca,qR as cb,uh as cc,KT as cd,yk as ce,Db as cf,ho as d,BP as da,vR as db,Th as dc,br as dd,oa as de,Yb as df,So as e,UP as ea,AR as eb,xh as ec,_n as ed,Pk as ee,Jb as ef,lr as f,DP as fa,jR as fb,Ch as fc,Nn as fd,gk as fe,Zb as ff,To as g,zP as ga,WR as gb,kh as gc,Gn as gd,na as ge,Qb as gf,xo as h,jP as ha,QR as hb,bh as hc,Ir as hd,sa as he,Xb as hf,Co as i,WP as ia,XR as ib,Ih as ic,qr as id,$f as ie,eI as if,ko as j,HP as ja,eE as jb,Wh as jc,vr as jd,aa as je,rI as jf,Kr as k,_P as ka,rE as kb,cn as kc,Ts as kd,Rk as ke,tI as kf,$r as l,NP as la,tE as lb,Hh as lc,ws as ld,Ek as le,mI as lf,cg as m,eg as ma,Be as mb,_h as mc,eC as md,hk as me,lI as mf,Vr as n,rg as na,oE as nb,Nh as nc,rC as nd,Sk as ne,CI as nf,dg as o,tg as oa,Ue as ob,Gh as oc,tC as od,Tk as oe,jy as of,bo as p,og as pa,nE as pb,Kh as pc,oC as pd,pa as pe,kI as pf,ug as q,Sg as qa,Qo as qb,$h as qc,nC as qd,ca as qe,bI as qf,mg as r,_ as ra,sE as rb,Vh as rc,Dl as rd,Zf as re,Io as s,bg as sa,Xo as sb,Yh as sc,sC as sd,da as se,lg as t,Fo as ta,aE as tb,Jh as tc,aC as td,xk as te,qo as u,Wg as ua,en as ub,Zh as uc,iC as ud,Ck as ue,vo as v,et as va,iE as vb,Qh as vc,pC as vd,kk as ve,fg as w,Hg as wa,pE as wb,Xh as wc,cC as wd,bk as we,Ao as x,_g as xa,cE as xb,iS as xc,dC as xd,Ik as xe,yg as y,G as ya,dE as yb,pS as yc,uC as yd,ey as ye,Oo as z,Ng as za,uE as zb,cS as zc,mC as zd,ry as ze};//# sourceMappingURL=chunk-AYGGMWA6.js.map
2
+ //# sourceMappingURL=chunk-AYGGMWA6.js.map