@agg-build/sdk 1.2.13 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +87 -11
- package/dist/index.d.ts +87 -11
- package/dist/index.js +141 -4
- package/dist/index.mjs +141 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -626,6 +626,7 @@ type VenueEvent = {
|
|
|
626
626
|
category: {
|
|
627
627
|
id: string;
|
|
628
628
|
name: string;
|
|
629
|
+
displayName: string | null;
|
|
629
630
|
parentId: string | null;
|
|
630
631
|
eventCount: number;
|
|
631
632
|
};
|
|
@@ -829,6 +830,7 @@ type ComputeSplitsResponse = {
|
|
|
829
830
|
type Category = {
|
|
830
831
|
id: string;
|
|
831
832
|
name: string;
|
|
833
|
+
displayName: string | null;
|
|
832
834
|
parentId: string | null;
|
|
833
835
|
eventCount: number;
|
|
834
836
|
};
|
|
@@ -865,6 +867,7 @@ type ValidateManagedRequest = {
|
|
|
865
867
|
amount: number;
|
|
866
868
|
};
|
|
867
869
|
type WithdrawTokenSymbol$1 = "USDC" | "USDC.e" | "USDT";
|
|
870
|
+
type WithdrawalSourceTokenSymbol$1 = WithdrawTokenSymbol$1 | "pUSD";
|
|
868
871
|
type WithdrawManagedRequest = {
|
|
869
872
|
/** Positive integer string in the token's native decimals (e.g. "100000" = 0.1 USDC). */
|
|
870
873
|
amountRaw: string;
|
|
@@ -878,7 +881,7 @@ type WithdrawalSourceStatus$1 = "pending" | "submitted" | "confirmed" | "failed"
|
|
|
878
881
|
type WithdrawalSourceItem = {
|
|
879
882
|
sourceId: string;
|
|
880
883
|
chainId: number;
|
|
881
|
-
tokenSymbol:
|
|
884
|
+
tokenSymbol: WithdrawalSourceTokenSymbol$1;
|
|
882
885
|
/** On-chain token address on `chainId`. */
|
|
883
886
|
tokenAddress: string;
|
|
884
887
|
/**
|
|
@@ -1414,7 +1417,28 @@ interface WsWithdrawalLifecycleEvent {
|
|
|
1414
1417
|
/** @unit milliseconds (raw from server — NOT converted like other WS types) */
|
|
1415
1418
|
timestamp: number;
|
|
1416
1419
|
}
|
|
1417
|
-
|
|
1420
|
+
interface WsArbMarketUpdate {
|
|
1421
|
+
type: "arb_market_update";
|
|
1422
|
+
marketId: string;
|
|
1423
|
+
venueEventId: string | null;
|
|
1424
|
+
arbReturn: number;
|
|
1425
|
+
ts: number;
|
|
1426
|
+
}
|
|
1427
|
+
interface WsArbFeedEntry {
|
|
1428
|
+
marketId: string;
|
|
1429
|
+
venueEventId: string | null;
|
|
1430
|
+
arbReturn: number;
|
|
1431
|
+
ts: number;
|
|
1432
|
+
}
|
|
1433
|
+
interface WsArbFeedBatch {
|
|
1434
|
+
type: "arb_feed_batch";
|
|
1435
|
+
feed: "arb";
|
|
1436
|
+
entries: WsArbFeedEntry[];
|
|
1437
|
+
flushTs: number;
|
|
1438
|
+
chunk: number;
|
|
1439
|
+
chunkCount: number;
|
|
1440
|
+
}
|
|
1441
|
+
type WsServerMessage = WsOrderbookSnapshot | WsOrderbookDelta | WsTrade | WsSubscribed | WsUnsubscribed | WsConnected | WsAuthenticated | WsHeartbeat | WsMarketResolved | WsError | WsOrderSubmitted | WsBalanceUpdate | WsOrderEvent | WsRedeemEvent | WsWithdrawalLifecycleEvent | WsArbMarketUpdate | WsArbFeedBatch;
|
|
1418
1442
|
type WsClientMessage = {
|
|
1419
1443
|
action: "subscribe";
|
|
1420
1444
|
channel: "orderbook" | "trades";
|
|
@@ -1427,6 +1451,20 @@ type WsClientMessage = {
|
|
|
1427
1451
|
action: "resnapshot";
|
|
1428
1452
|
channel: "orderbook";
|
|
1429
1453
|
outcomeIds: string[];
|
|
1454
|
+
} | {
|
|
1455
|
+
action: "subscribe";
|
|
1456
|
+
channel: "arb";
|
|
1457
|
+
marketIds: string[];
|
|
1458
|
+
} | {
|
|
1459
|
+
action: "unsubscribe";
|
|
1460
|
+
channel: "arb";
|
|
1461
|
+
marketIds: string[];
|
|
1462
|
+
} | {
|
|
1463
|
+
action: "subscribe";
|
|
1464
|
+
channel: "arb-feed";
|
|
1465
|
+
} | {
|
|
1466
|
+
action: "unsubscribe";
|
|
1467
|
+
channel: "arb-feed";
|
|
1430
1468
|
} | {
|
|
1431
1469
|
action: "authenticate";
|
|
1432
1470
|
token: string;
|
|
@@ -1534,6 +1572,8 @@ interface AggWebSocketCallbacks {
|
|
|
1534
1572
|
onOrderEvent?: (msg: WsOrderEvent) => void;
|
|
1535
1573
|
onRedeemEvent?: (msg: WsRedeemEvent) => void;
|
|
1536
1574
|
onWithdrawalLifecycle?: (msg: WsWithdrawalLifecycleEvent) => void;
|
|
1575
|
+
onArbMarket?: (msg: WsArbMarketUpdate) => void;
|
|
1576
|
+
onArbFeed?: (batch: WsArbFeedBatch) => void;
|
|
1537
1577
|
onDiagnostics?: DiagnosticCallback;
|
|
1538
1578
|
onConnectionStateChange?: (connected: boolean) => void;
|
|
1539
1579
|
}
|
|
@@ -1561,7 +1601,13 @@ declare class AggWebSocket {
|
|
|
1561
1601
|
private readonly pendingFlushUnsubs;
|
|
1562
1602
|
private readonly pendingFlushTradeSubs;
|
|
1563
1603
|
private readonly pendingFlushTradeUnsubs;
|
|
1604
|
+
private readonly pendingFlushArbSubs;
|
|
1605
|
+
private readonly pendingFlushArbUnsubs;
|
|
1564
1606
|
private flushScheduled;
|
|
1607
|
+
private readonly arbSubs;
|
|
1608
|
+
private readonly arbFeedCbs;
|
|
1609
|
+
/** Latest arb market update per marketId (last-value-wins, loss-tolerant). */
|
|
1610
|
+
private readonly latestArb;
|
|
1565
1611
|
private readonly books;
|
|
1566
1612
|
/** Markets currently resyncing (awaiting snapshot after seq gap / checksum mismatch). */
|
|
1567
1613
|
private readonly resyncing;
|
|
@@ -1580,6 +1626,20 @@ declare class AggWebSocket {
|
|
|
1580
1626
|
getBook(outcomeId: string): OrderbookState | null;
|
|
1581
1627
|
/** Whether an outcome is currently resyncing (waiting for fresh snapshot). */
|
|
1582
1628
|
isResyncing(outcomeId: string): boolean;
|
|
1629
|
+
/** Get the latest arb update for a market (or null if none received yet). */
|
|
1630
|
+
getArb(marketId: string): WsArbMarketUpdate | null;
|
|
1631
|
+
/**
|
|
1632
|
+
* Subscribe to per-market arb updates for a given marketId.
|
|
1633
|
+
* Ref-counted: multiple callers for the same marketId share one server subscription.
|
|
1634
|
+
* Returns an unsubscribe function.
|
|
1635
|
+
*/
|
|
1636
|
+
subscribeArb(marketId: string, cb: (m: WsArbMarketUpdate) => void): () => void;
|
|
1637
|
+
/**
|
|
1638
|
+
* Subscribe to the global arb-feed batches.
|
|
1639
|
+
* Only one server subscription is maintained regardless of how many callers.
|
|
1640
|
+
* Returns an unsubscribe function.
|
|
1641
|
+
*/
|
|
1642
|
+
subscribeArbFeed(cb: (b: WsArbFeedBatch) => void): () => void;
|
|
1583
1643
|
/**
|
|
1584
1644
|
* Subscribe to a feed by outcome ID.
|
|
1585
1645
|
* @param outcomeId The venueMarketOutcomeId to subscribe to.
|
|
@@ -1638,6 +1698,7 @@ declare class AggWebSocket {
|
|
|
1638
1698
|
private send;
|
|
1639
1699
|
private activeOrderbookMarkets;
|
|
1640
1700
|
private activeTradeMarkets;
|
|
1701
|
+
private activeArbMarkets;
|
|
1641
1702
|
private emitDiagnostic;
|
|
1642
1703
|
private summarizeTopLevels;
|
|
1643
1704
|
private debugOrderbook;
|
|
@@ -2082,13 +2143,15 @@ interface QuoteManagedResponse {
|
|
|
2082
2143
|
}
|
|
2083
2144
|
interface ExecuteManagedParams {
|
|
2084
2145
|
quoteId: string;
|
|
2146
|
+
/** Trading mode. Defaults to live. */
|
|
2147
|
+
mode?: ExecutionMode;
|
|
2085
2148
|
/**
|
|
2086
2149
|
* Optional intent fallback. When the supplied `quoteId` has expired in the
|
|
2087
2150
|
* cache (e.g. user clicked Buy after a tab was inactive), the server
|
|
2088
|
-
* resolves the latest
|
|
2089
|
-
*
|
|
2090
|
-
*
|
|
2091
|
-
* different intent and won't match.
|
|
2151
|
+
* resolves the latest quote for this intent and refreshes/executes against
|
|
2152
|
+
* that instead of returning 400 `quote_not_found`. Same intent = same buttons
|
|
2153
|
+
* the user pressed in the UI; a different `maxSpend`, mode, or venue scope is
|
|
2154
|
+
* a different intent and won't match.
|
|
2092
2155
|
*/
|
|
2093
2156
|
fallbackToLatest?: {
|
|
2094
2157
|
outcomeId: string;
|
|
@@ -2116,6 +2179,7 @@ interface ValidateManagedResponse {
|
|
|
2116
2179
|
bridgeAmountRaw?: string;
|
|
2117
2180
|
}
|
|
2118
2181
|
type WithdrawTokenSymbol = "USDC" | "USDC.e" | "USDT";
|
|
2182
|
+
type WithdrawalSourceTokenSymbol = WithdrawTokenSymbol | "pUSD";
|
|
2119
2183
|
interface WithdrawManagedParams {
|
|
2120
2184
|
/** Positive integer string in the token's native decimals (e.g. "100000" = 0.1 USDC). */
|
|
2121
2185
|
amountRaw: string;
|
|
@@ -2143,7 +2207,7 @@ interface WithdrawalLeg {
|
|
|
2143
2207
|
interface WithdrawManagedSourceItem {
|
|
2144
2208
|
sourceId: string;
|
|
2145
2209
|
chainId: number;
|
|
2146
|
-
tokenSymbol:
|
|
2210
|
+
tokenSymbol: WithdrawalSourceTokenSymbol;
|
|
2147
2211
|
/** On-chain token address on `chainId`. */
|
|
2148
2212
|
tokenAddress: string;
|
|
2149
2213
|
/**
|
|
@@ -2219,6 +2283,7 @@ interface GetPositionsParams {
|
|
|
2219
2283
|
cursor?: string;
|
|
2220
2284
|
limit?: number;
|
|
2221
2285
|
status?: "active" | "closed";
|
|
2286
|
+
mode?: ExecutionMode;
|
|
2222
2287
|
}
|
|
2223
2288
|
interface GetOrdersParams {
|
|
2224
2289
|
status?: string;
|
|
@@ -2246,10 +2311,17 @@ interface OrderbookQuoteResponse {
|
|
|
2246
2311
|
slippage: number | null;
|
|
2247
2312
|
fills: OrderbookQuoteFill[];
|
|
2248
2313
|
}
|
|
2249
|
-
type ExecutionOrdersQuery = GetOrdersQuery
|
|
2314
|
+
type ExecutionOrdersQuery = GetOrdersQuery & {
|
|
2315
|
+
mode?: ExecutionMode;
|
|
2316
|
+
};
|
|
2250
2317
|
type ExecutionOrderItem = OrderListItem;
|
|
2251
|
-
type ExecutionPositionsQuery = GetPositionsQuery
|
|
2318
|
+
type ExecutionPositionsQuery = GetPositionsQuery & {
|
|
2319
|
+
mode?: ExecutionMode;
|
|
2320
|
+
};
|
|
2252
2321
|
type ExecutionPositionGroup = PositionGroup;
|
|
2322
|
+
type ManagedBalancesParams = {
|
|
2323
|
+
mode?: ExecutionMode;
|
|
2324
|
+
};
|
|
2253
2325
|
type UserActivityType = "trade" | "withdrawal" | "bridge" | "deposit" | "user_op" | "redeem";
|
|
2254
2326
|
interface UserActivityBase {
|
|
2255
2327
|
id: string;
|
|
@@ -2453,6 +2525,8 @@ interface VenueSoloQuote {
|
|
|
2453
2525
|
type SmartRouteSide = "yes" | "no";
|
|
2454
2526
|
/** Trade direction for order routing. "buy" (default) reads asks, "sell" reads bids. */
|
|
2455
2527
|
type TradeSide = "buy" | "sell";
|
|
2528
|
+
/** Trading mode for normal execution endpoints. Defaults to live. */
|
|
2529
|
+
type ExecutionMode = "live" | "paper";
|
|
2456
2530
|
/** Request params for GET /orderbook/:venueMarketOutcomeId/route. */
|
|
2457
2531
|
interface SmartRouteParams {
|
|
2458
2532
|
venueMarketOutcomeId?: string;
|
|
@@ -2464,6 +2538,8 @@ interface SmartRouteParams {
|
|
|
2464
2538
|
side?: SmartRouteSide;
|
|
2465
2539
|
/** Trade direction: "buy" (default) or "sell". */
|
|
2466
2540
|
tradeSide?: TradeSide;
|
|
2541
|
+
/** Trading mode. Defaults to live. */
|
|
2542
|
+
mode?: ExecutionMode;
|
|
2467
2543
|
maxSpend?: number;
|
|
2468
2544
|
/** Sell only: target number of contracts to sell. Required for sell unless maxSpend is given. */
|
|
2469
2545
|
sellShares?: number;
|
|
@@ -2891,7 +2967,7 @@ declare class AggClient {
|
|
|
2891
2967
|
/** List execution positions for the authenticated user (cursor pagination). */
|
|
2892
2968
|
getExecutionPositions(params?: ExecutionPositionsQuery): Promise<PaginatedResponse<ExecutionPositionGroup>>;
|
|
2893
2969
|
/** Get managed wallet balances, including per-chain cash balances and per-venue position balances. */
|
|
2894
|
-
getManagedBalances(): Promise<UnifiedBalanceResponse>;
|
|
2970
|
+
getManagedBalances(params?: ManagedBalancesParams): Promise<UnifiedBalanceResponse>;
|
|
2895
2971
|
/** Cancel a pending managed execution by order id. */
|
|
2896
2972
|
cancelManagedOrder(orderId: string, options?: {
|
|
2897
2973
|
signal?: AbortSignal;
|
|
@@ -3141,4 +3217,4 @@ declare function aggregateMidpoint(midpoints: (number | null | undefined)[]): nu
|
|
|
3141
3217
|
|
|
3142
3218
|
declare function createAggClient(options: AggClientOptions): AggClient;
|
|
3143
3219
|
|
|
3144
|
-
export { type Account, AccountProvider, AccountType, type AggAuthDeliveryMode, type AggAuthProviderType, type AggAuthStartBody, type AggAuthStartResult, type AggAuthVerifyBody, AggClient, type AggClientAuthOptions, type AggClientSessionInput, type AggLinkAccountBody, type AggLinkAccountConfirmResult, type AggLinkAccountResult, type AggSessionUser, AggWebSocket, type AggWebSocketCallbacks, type AggWebSocketOptions, type AggregatedOrderbookLevel, type AggregatedOrderbookResponse, type App, type AppClientConfigResponse, type AttributedOrderbook, type AttributedOrderbookLevel, type AuthCodeResponse, type AuthStatus, type AuthTokenResponse, type AuthUser, type BatchMidpointsResponse, type BatchOrderbooksResponse, type BuildVenueUrlOpts, CONFIRMED_MATCH_STATUSES, type CancelManagedExecutionResponse, type Candle, CandleBuilder, type CandleInterval, type Category, Chain, type ChartBarsResponse, type ChartCandle, type ChartResolution, type ChartVenueCandles, type ComputeSplitsRequest, type ComputeSplitsResponse, type ComputeSplitsSelection, type CorrelatedMarketCascadeItem, type CorrelatedMarketCascadeResponse, type CorrelatedMarketQueryResult, type CorrelatedMarketSide, type CorrelatedMarketSignal, type CorrelatedMarketSignalBatch, type CorrelatedMarketSignalDirection, type CorrelatedMarketsStatus, type CreateApp, type DepositAddressesPendingResponse, type DepositAddressesReadyResponse, type DepositAddressesResponse, type DepositAddressesSupportedChain, type DepositAddressesToken, type DepositStep, type DiagnosticCallback, type DiagnosticEvent, type ExecuteManagedParams, type ExecuteManagedRequest, type ExecuteManagedResponse, type ExecuteTradeRequest, type ExecuteTradeResponse, type ExecutionOrderItem, type ExecutionOrdersQuery, type ExecutionPositionGroup, type ExecutionPositionsQuery, type GetBalanceQuery, type GetBalanceResponse, type GetHoldingsQuery, type GetHoldingsResponse, type GetOrdersParams, type GetOrdersQuery, type GetPositionsParams, type GetPositionsQuery, type HelloResponse, IMAGE_SIZES, ImageSize, type MarkSource, type MarketPriceHistory, MarketStatus, MatchStatus, MatchType, type MatchedMidpoint, type MatchedMidpointOutcome, type MatchedOrderbookMarket, type MatchedVenueMarketOutcomeRef, type MatchingReport, type MidpointItem, type MidpointRow, type NonceResponse, type OrderListItem, type OrderListQuery, OrderStatus, type Orderbook, type OrderbookBatchItemError, type OrderbookBatchItemErrorCode, type OrderbookBatchItemStatus, type OrderbookHistoryPoint, type OrderbookHistoryResponse, type OrderbookLevel, type OrderbookQuoteFill, type OrderbookQuoteParams, type OrderbookQuoteResponse, type OrderbookServiceUnavailableError, type OrderbookState, type OrderbooksOnlyError, type OutcomeMidpoint, type OutcomeMidpointRow, type OutcomeOrderbookResponse, type PaginatedResponse, type PersistedAuthSnapshot, type PositionGroup, type PositionRedeemStatus, type PricePoint, type PriceSource, type PricesHistoryResponse, type QuoteManagedParams, type QuoteManagedRequest, type QuoteManagedResponse, type QuoteManagedSplit, type QuoteManagedStep, type QuoteSplit, type QuoteStep, type RampQuote, type RampQuoteRequest, type RampSessionRequest, type RampWidgetSession, type RedeemLegResult, type RedeemLegStatus, type RedeemRequest, type RedeemResponse, type RequestedOrderbookMarket, type ResolveCorrelatedMarketsParams, type ResolveCorrelatedMarketsResponse, type ResolvedCorrelatedMarketsResponse, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, type ServerWallet, type SettlementSource, type SetupDepositAddressStep, type SetupVenueKeyStep, type SimpleOrderbookLevel, type SmartRouteAllocation, type SmartRouteBridgeStep, type SmartRouteFeeBreakdown, type SmartRouteFill, type SmartRouteParams, type SmartRouteResponse, type SmartRouteSetupCostLine, type SmartRouteSide, type SmartRouteStatus, type SmartRouteVenueFill, type SplitsByAmountResult, type SyncBalancesResponse, type TradeExecutorOrder, type TradeExecutorOrderListResponse, TradeSide$1 as TradeSide, type TradeSplit, type TradeStep, TurnstileChallengeError, type UnifiedBalanceResponse, type UpdateUserBody, type UpsertVenueKey, type UserActivityBridge, type UserActivityDeposit, type UserActivityItem, type UserActivityQuery, type UserActivityRedeem, type UserActivityRedeemLeg, type UserActivityTrade, type UserActivityType, type UserActivityUserOp, type UserActivityWithdrawal, type UserHolding, type UserProfile, VENUES, type ValidateBalanceOnClientStep, type ValidateManagedParams, type ValidateManagedRequest, type ValidateManagedResponse, type ValidateTradeRequest, type ValidateTradeResponse, Venue, type VenueEvent, type VenueEventListItem, type VenueEventWithMarkets, type VenueKeySummary, type VenueMarket, type VenueMarketClusterNode, type VenueMarketListItem, type VenueMarketOutcome, type VenueMarketRef, type VenueOrderbookEntry, type VenueOrderbookLevel, type VenuePositionBalance, type VenuePriceInfo, type VenueSoloQuote, type VerifyBody, type VerifyResponse, type WalletChainBalance, type WalletTokenBalance, type WithdrawManagedParams, type WithdrawManagedRequest, type WithdrawManagedResponse, type WithdrawManagedSourceItem, type WithdrawTokenSymbol, type WithdrawalExpected, type WithdrawalLeg, type WithdrawalLegStatus, type WithdrawalLegType, type WithdrawalLifecycleStatus, type WithdrawalSource, type WithdrawalSourceItem, type WithdrawalSourceStatus, type WsAttributedLevel, type WsAuthenticated, type WsBalanceUpdate, type WsCandleInterval, type WsClientMessage, type WsConnected, type WsError, type WsHeartbeat, type WsMarkSource, type WsMarketResolved, type WsOrderEvent, type WsOrderEventType, type WsOrderSubmitted, type WsOrderbookDelta, type WsOrderbookSnapshot, type WsRedeemEvent, type WsServerMessage, type WsSubscribed, type WsTrade, type WsUnsubscribed, type WsVenueBook, type WsVenueInfo, type WsVenueLevel, type WsWithdrawalLegStatus, type WsWithdrawalLifecycleEvent, type WsWithdrawalLifecycleLeg, type WsWithdrawalLifecycleStatus, aggregateMidpoint, applyOrderbookDelta, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getWalletAddressFromUserProfile, hasShape, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, parse, parseEmail, parseEmailStrict, safeParse, snapshotToOrderbook, sortVenues };
|
|
3220
|
+
export { type Account, AccountProvider, AccountType, type AggAuthDeliveryMode, type AggAuthProviderType, type AggAuthStartBody, type AggAuthStartResult, type AggAuthVerifyBody, AggClient, type AggClientAuthOptions, type AggClientSessionInput, type AggLinkAccountBody, type AggLinkAccountConfirmResult, type AggLinkAccountResult, type AggSessionUser, AggWebSocket, type AggWebSocketCallbacks, type AggWebSocketOptions, type AggregatedOrderbookLevel, type AggregatedOrderbookResponse, type App, type AppClientConfigResponse, type AttributedOrderbook, type AttributedOrderbookLevel, type AuthCodeResponse, type AuthStatus, type AuthTokenResponse, type AuthUser, type BatchMidpointsResponse, type BatchOrderbooksResponse, type BuildVenueUrlOpts, CONFIRMED_MATCH_STATUSES, type CancelManagedExecutionResponse, type Candle, CandleBuilder, type CandleInterval, type Category, Chain, type ChartBarsResponse, type ChartCandle, type ChartResolution, type ChartVenueCandles, type ComputeSplitsRequest, type ComputeSplitsResponse, type ComputeSplitsSelection, type CorrelatedMarketCascadeItem, type CorrelatedMarketCascadeResponse, type CorrelatedMarketQueryResult, type CorrelatedMarketSide, type CorrelatedMarketSignal, type CorrelatedMarketSignalBatch, type CorrelatedMarketSignalDirection, type CorrelatedMarketsStatus, type CreateApp, type DepositAddressesPendingResponse, type DepositAddressesReadyResponse, type DepositAddressesResponse, type DepositAddressesSupportedChain, type DepositAddressesToken, type DepositStep, type DiagnosticCallback, type DiagnosticEvent, type ExecuteManagedParams, type ExecuteManagedRequest, type ExecuteManagedResponse, type ExecuteTradeRequest, type ExecuteTradeResponse, type ExecutionMode, type ExecutionOrderItem, type ExecutionOrdersQuery, type ExecutionPositionGroup, type ExecutionPositionsQuery, type GetBalanceQuery, type GetBalanceResponse, type GetHoldingsQuery, type GetHoldingsResponse, type GetOrdersParams, type GetOrdersQuery, type GetPositionsParams, type GetPositionsQuery, type HelloResponse, IMAGE_SIZES, ImageSize, type ManagedBalancesParams, type MarkSource, type MarketPriceHistory, MarketStatus, MatchStatus, MatchType, type MatchedMidpoint, type MatchedMidpointOutcome, type MatchedOrderbookMarket, type MatchedVenueMarketOutcomeRef, type MatchingReport, type MidpointItem, type MidpointRow, type NonceResponse, type OrderListItem, type OrderListQuery, OrderStatus, type Orderbook, type OrderbookBatchItemError, type OrderbookBatchItemErrorCode, type OrderbookBatchItemStatus, type OrderbookHistoryPoint, type OrderbookHistoryResponse, type OrderbookLevel, type OrderbookQuoteFill, type OrderbookQuoteParams, type OrderbookQuoteResponse, type OrderbookServiceUnavailableError, type OrderbookState, type OrderbooksOnlyError, type OutcomeMidpoint, type OutcomeMidpointRow, type OutcomeOrderbookResponse, type PaginatedResponse, type PersistedAuthSnapshot, type PositionGroup, type PositionRedeemStatus, type PricePoint, type PriceSource, type PricesHistoryResponse, type QuoteManagedParams, type QuoteManagedRequest, type QuoteManagedResponse, type QuoteManagedSplit, type QuoteManagedStep, type QuoteSplit, type QuoteStep, type RampQuote, type RampQuoteRequest, type RampSessionRequest, type RampWidgetSession, type RedeemLegResult, type RedeemLegStatus, type RedeemRequest, type RedeemResponse, type RequestedOrderbookMarket, type ResolveCorrelatedMarketsParams, type ResolveCorrelatedMarketsResponse, type ResolvedCorrelatedMarketsResponse, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, type ServerWallet, type SettlementSource, type SetupDepositAddressStep, type SetupVenueKeyStep, type SimpleOrderbookLevel, type SmartRouteAllocation, type SmartRouteBridgeStep, type SmartRouteFeeBreakdown, type SmartRouteFill, type SmartRouteParams, type SmartRouteResponse, type SmartRouteSetupCostLine, type SmartRouteSide, type SmartRouteStatus, type SmartRouteVenueFill, type SplitsByAmountResult, type SyncBalancesResponse, type TradeExecutorOrder, type TradeExecutorOrderListResponse, TradeSide$1 as TradeSide, type TradeSplit, type TradeStep, TurnstileChallengeError, type UnifiedBalanceResponse, type UpdateUserBody, type UpsertVenueKey, type UserActivityBridge, type UserActivityDeposit, type UserActivityItem, type UserActivityQuery, type UserActivityRedeem, type UserActivityRedeemLeg, type UserActivityTrade, type UserActivityType, type UserActivityUserOp, type UserActivityWithdrawal, type UserHolding, type UserProfile, VENUES, type ValidateBalanceOnClientStep, type ValidateManagedParams, type ValidateManagedRequest, type ValidateManagedResponse, type ValidateTradeRequest, type ValidateTradeResponse, Venue, type VenueEvent, type VenueEventListItem, type VenueEventWithMarkets, type VenueKeySummary, type VenueMarket, type VenueMarketClusterNode, type VenueMarketListItem, type VenueMarketOutcome, type VenueMarketRef, type VenueOrderbookEntry, type VenueOrderbookLevel, type VenuePositionBalance, type VenuePriceInfo, type VenueSoloQuote, type VerifyBody, type VerifyResponse, type WalletChainBalance, type WalletTokenBalance, type WithdrawManagedParams, type WithdrawManagedRequest, type WithdrawManagedResponse, type WithdrawManagedSourceItem, type WithdrawTokenSymbol, type WithdrawalExpected, type WithdrawalLeg, type WithdrawalLegStatus, type WithdrawalLegType, type WithdrawalLifecycleStatus, type WithdrawalSource, type WithdrawalSourceItem, type WithdrawalSourceStatus, type WithdrawalSourceTokenSymbol, type WsArbFeedBatch, type WsArbFeedEntry, type WsArbMarketUpdate, type WsAttributedLevel, type WsAuthenticated, type WsBalanceUpdate, type WsCandleInterval, type WsClientMessage, type WsConnected, type WsError, type WsHeartbeat, type WsMarkSource, type WsMarketResolved, type WsOrderEvent, type WsOrderEventType, type WsOrderSubmitted, type WsOrderbookDelta, type WsOrderbookSnapshot, type WsRedeemEvent, type WsServerMessage, type WsSubscribed, type WsTrade, type WsUnsubscribed, type WsVenueBook, type WsVenueInfo, type WsVenueLevel, type WsWithdrawalLegStatus, type WsWithdrawalLifecycleEvent, type WsWithdrawalLifecycleLeg, type WsWithdrawalLifecycleStatus, aggregateMidpoint, applyOrderbookDelta, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getWalletAddressFromUserProfile, hasShape, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, parse, parseEmail, parseEmailStrict, safeParse, snapshotToOrderbook, sortVenues };
|
package/dist/index.d.ts
CHANGED
|
@@ -626,6 +626,7 @@ type VenueEvent = {
|
|
|
626
626
|
category: {
|
|
627
627
|
id: string;
|
|
628
628
|
name: string;
|
|
629
|
+
displayName: string | null;
|
|
629
630
|
parentId: string | null;
|
|
630
631
|
eventCount: number;
|
|
631
632
|
};
|
|
@@ -829,6 +830,7 @@ type ComputeSplitsResponse = {
|
|
|
829
830
|
type Category = {
|
|
830
831
|
id: string;
|
|
831
832
|
name: string;
|
|
833
|
+
displayName: string | null;
|
|
832
834
|
parentId: string | null;
|
|
833
835
|
eventCount: number;
|
|
834
836
|
};
|
|
@@ -865,6 +867,7 @@ type ValidateManagedRequest = {
|
|
|
865
867
|
amount: number;
|
|
866
868
|
};
|
|
867
869
|
type WithdrawTokenSymbol$1 = "USDC" | "USDC.e" | "USDT";
|
|
870
|
+
type WithdrawalSourceTokenSymbol$1 = WithdrawTokenSymbol$1 | "pUSD";
|
|
868
871
|
type WithdrawManagedRequest = {
|
|
869
872
|
/** Positive integer string in the token's native decimals (e.g. "100000" = 0.1 USDC). */
|
|
870
873
|
amountRaw: string;
|
|
@@ -878,7 +881,7 @@ type WithdrawalSourceStatus$1 = "pending" | "submitted" | "confirmed" | "failed"
|
|
|
878
881
|
type WithdrawalSourceItem = {
|
|
879
882
|
sourceId: string;
|
|
880
883
|
chainId: number;
|
|
881
|
-
tokenSymbol:
|
|
884
|
+
tokenSymbol: WithdrawalSourceTokenSymbol$1;
|
|
882
885
|
/** On-chain token address on `chainId`. */
|
|
883
886
|
tokenAddress: string;
|
|
884
887
|
/**
|
|
@@ -1414,7 +1417,28 @@ interface WsWithdrawalLifecycleEvent {
|
|
|
1414
1417
|
/** @unit milliseconds (raw from server — NOT converted like other WS types) */
|
|
1415
1418
|
timestamp: number;
|
|
1416
1419
|
}
|
|
1417
|
-
|
|
1420
|
+
interface WsArbMarketUpdate {
|
|
1421
|
+
type: "arb_market_update";
|
|
1422
|
+
marketId: string;
|
|
1423
|
+
venueEventId: string | null;
|
|
1424
|
+
arbReturn: number;
|
|
1425
|
+
ts: number;
|
|
1426
|
+
}
|
|
1427
|
+
interface WsArbFeedEntry {
|
|
1428
|
+
marketId: string;
|
|
1429
|
+
venueEventId: string | null;
|
|
1430
|
+
arbReturn: number;
|
|
1431
|
+
ts: number;
|
|
1432
|
+
}
|
|
1433
|
+
interface WsArbFeedBatch {
|
|
1434
|
+
type: "arb_feed_batch";
|
|
1435
|
+
feed: "arb";
|
|
1436
|
+
entries: WsArbFeedEntry[];
|
|
1437
|
+
flushTs: number;
|
|
1438
|
+
chunk: number;
|
|
1439
|
+
chunkCount: number;
|
|
1440
|
+
}
|
|
1441
|
+
type WsServerMessage = WsOrderbookSnapshot | WsOrderbookDelta | WsTrade | WsSubscribed | WsUnsubscribed | WsConnected | WsAuthenticated | WsHeartbeat | WsMarketResolved | WsError | WsOrderSubmitted | WsBalanceUpdate | WsOrderEvent | WsRedeemEvent | WsWithdrawalLifecycleEvent | WsArbMarketUpdate | WsArbFeedBatch;
|
|
1418
1442
|
type WsClientMessage = {
|
|
1419
1443
|
action: "subscribe";
|
|
1420
1444
|
channel: "orderbook" | "trades";
|
|
@@ -1427,6 +1451,20 @@ type WsClientMessage = {
|
|
|
1427
1451
|
action: "resnapshot";
|
|
1428
1452
|
channel: "orderbook";
|
|
1429
1453
|
outcomeIds: string[];
|
|
1454
|
+
} | {
|
|
1455
|
+
action: "subscribe";
|
|
1456
|
+
channel: "arb";
|
|
1457
|
+
marketIds: string[];
|
|
1458
|
+
} | {
|
|
1459
|
+
action: "unsubscribe";
|
|
1460
|
+
channel: "arb";
|
|
1461
|
+
marketIds: string[];
|
|
1462
|
+
} | {
|
|
1463
|
+
action: "subscribe";
|
|
1464
|
+
channel: "arb-feed";
|
|
1465
|
+
} | {
|
|
1466
|
+
action: "unsubscribe";
|
|
1467
|
+
channel: "arb-feed";
|
|
1430
1468
|
} | {
|
|
1431
1469
|
action: "authenticate";
|
|
1432
1470
|
token: string;
|
|
@@ -1534,6 +1572,8 @@ interface AggWebSocketCallbacks {
|
|
|
1534
1572
|
onOrderEvent?: (msg: WsOrderEvent) => void;
|
|
1535
1573
|
onRedeemEvent?: (msg: WsRedeemEvent) => void;
|
|
1536
1574
|
onWithdrawalLifecycle?: (msg: WsWithdrawalLifecycleEvent) => void;
|
|
1575
|
+
onArbMarket?: (msg: WsArbMarketUpdate) => void;
|
|
1576
|
+
onArbFeed?: (batch: WsArbFeedBatch) => void;
|
|
1537
1577
|
onDiagnostics?: DiagnosticCallback;
|
|
1538
1578
|
onConnectionStateChange?: (connected: boolean) => void;
|
|
1539
1579
|
}
|
|
@@ -1561,7 +1601,13 @@ declare class AggWebSocket {
|
|
|
1561
1601
|
private readonly pendingFlushUnsubs;
|
|
1562
1602
|
private readonly pendingFlushTradeSubs;
|
|
1563
1603
|
private readonly pendingFlushTradeUnsubs;
|
|
1604
|
+
private readonly pendingFlushArbSubs;
|
|
1605
|
+
private readonly pendingFlushArbUnsubs;
|
|
1564
1606
|
private flushScheduled;
|
|
1607
|
+
private readonly arbSubs;
|
|
1608
|
+
private readonly arbFeedCbs;
|
|
1609
|
+
/** Latest arb market update per marketId (last-value-wins, loss-tolerant). */
|
|
1610
|
+
private readonly latestArb;
|
|
1565
1611
|
private readonly books;
|
|
1566
1612
|
/** Markets currently resyncing (awaiting snapshot after seq gap / checksum mismatch). */
|
|
1567
1613
|
private readonly resyncing;
|
|
@@ -1580,6 +1626,20 @@ declare class AggWebSocket {
|
|
|
1580
1626
|
getBook(outcomeId: string): OrderbookState | null;
|
|
1581
1627
|
/** Whether an outcome is currently resyncing (waiting for fresh snapshot). */
|
|
1582
1628
|
isResyncing(outcomeId: string): boolean;
|
|
1629
|
+
/** Get the latest arb update for a market (or null if none received yet). */
|
|
1630
|
+
getArb(marketId: string): WsArbMarketUpdate | null;
|
|
1631
|
+
/**
|
|
1632
|
+
* Subscribe to per-market arb updates for a given marketId.
|
|
1633
|
+
* Ref-counted: multiple callers for the same marketId share one server subscription.
|
|
1634
|
+
* Returns an unsubscribe function.
|
|
1635
|
+
*/
|
|
1636
|
+
subscribeArb(marketId: string, cb: (m: WsArbMarketUpdate) => void): () => void;
|
|
1637
|
+
/**
|
|
1638
|
+
* Subscribe to the global arb-feed batches.
|
|
1639
|
+
* Only one server subscription is maintained regardless of how many callers.
|
|
1640
|
+
* Returns an unsubscribe function.
|
|
1641
|
+
*/
|
|
1642
|
+
subscribeArbFeed(cb: (b: WsArbFeedBatch) => void): () => void;
|
|
1583
1643
|
/**
|
|
1584
1644
|
* Subscribe to a feed by outcome ID.
|
|
1585
1645
|
* @param outcomeId The venueMarketOutcomeId to subscribe to.
|
|
@@ -1638,6 +1698,7 @@ declare class AggWebSocket {
|
|
|
1638
1698
|
private send;
|
|
1639
1699
|
private activeOrderbookMarkets;
|
|
1640
1700
|
private activeTradeMarkets;
|
|
1701
|
+
private activeArbMarkets;
|
|
1641
1702
|
private emitDiagnostic;
|
|
1642
1703
|
private summarizeTopLevels;
|
|
1643
1704
|
private debugOrderbook;
|
|
@@ -2082,13 +2143,15 @@ interface QuoteManagedResponse {
|
|
|
2082
2143
|
}
|
|
2083
2144
|
interface ExecuteManagedParams {
|
|
2084
2145
|
quoteId: string;
|
|
2146
|
+
/** Trading mode. Defaults to live. */
|
|
2147
|
+
mode?: ExecutionMode;
|
|
2085
2148
|
/**
|
|
2086
2149
|
* Optional intent fallback. When the supplied `quoteId` has expired in the
|
|
2087
2150
|
* cache (e.g. user clicked Buy after a tab was inactive), the server
|
|
2088
|
-
* resolves the latest
|
|
2089
|
-
*
|
|
2090
|
-
*
|
|
2091
|
-
* different intent and won't match.
|
|
2151
|
+
* resolves the latest quote for this intent and refreshes/executes against
|
|
2152
|
+
* that instead of returning 400 `quote_not_found`. Same intent = same buttons
|
|
2153
|
+
* the user pressed in the UI; a different `maxSpend`, mode, or venue scope is
|
|
2154
|
+
* a different intent and won't match.
|
|
2092
2155
|
*/
|
|
2093
2156
|
fallbackToLatest?: {
|
|
2094
2157
|
outcomeId: string;
|
|
@@ -2116,6 +2179,7 @@ interface ValidateManagedResponse {
|
|
|
2116
2179
|
bridgeAmountRaw?: string;
|
|
2117
2180
|
}
|
|
2118
2181
|
type WithdrawTokenSymbol = "USDC" | "USDC.e" | "USDT";
|
|
2182
|
+
type WithdrawalSourceTokenSymbol = WithdrawTokenSymbol | "pUSD";
|
|
2119
2183
|
interface WithdrawManagedParams {
|
|
2120
2184
|
/** Positive integer string in the token's native decimals (e.g. "100000" = 0.1 USDC). */
|
|
2121
2185
|
amountRaw: string;
|
|
@@ -2143,7 +2207,7 @@ interface WithdrawalLeg {
|
|
|
2143
2207
|
interface WithdrawManagedSourceItem {
|
|
2144
2208
|
sourceId: string;
|
|
2145
2209
|
chainId: number;
|
|
2146
|
-
tokenSymbol:
|
|
2210
|
+
tokenSymbol: WithdrawalSourceTokenSymbol;
|
|
2147
2211
|
/** On-chain token address on `chainId`. */
|
|
2148
2212
|
tokenAddress: string;
|
|
2149
2213
|
/**
|
|
@@ -2219,6 +2283,7 @@ interface GetPositionsParams {
|
|
|
2219
2283
|
cursor?: string;
|
|
2220
2284
|
limit?: number;
|
|
2221
2285
|
status?: "active" | "closed";
|
|
2286
|
+
mode?: ExecutionMode;
|
|
2222
2287
|
}
|
|
2223
2288
|
interface GetOrdersParams {
|
|
2224
2289
|
status?: string;
|
|
@@ -2246,10 +2311,17 @@ interface OrderbookQuoteResponse {
|
|
|
2246
2311
|
slippage: number | null;
|
|
2247
2312
|
fills: OrderbookQuoteFill[];
|
|
2248
2313
|
}
|
|
2249
|
-
type ExecutionOrdersQuery = GetOrdersQuery
|
|
2314
|
+
type ExecutionOrdersQuery = GetOrdersQuery & {
|
|
2315
|
+
mode?: ExecutionMode;
|
|
2316
|
+
};
|
|
2250
2317
|
type ExecutionOrderItem = OrderListItem;
|
|
2251
|
-
type ExecutionPositionsQuery = GetPositionsQuery
|
|
2318
|
+
type ExecutionPositionsQuery = GetPositionsQuery & {
|
|
2319
|
+
mode?: ExecutionMode;
|
|
2320
|
+
};
|
|
2252
2321
|
type ExecutionPositionGroup = PositionGroup;
|
|
2322
|
+
type ManagedBalancesParams = {
|
|
2323
|
+
mode?: ExecutionMode;
|
|
2324
|
+
};
|
|
2253
2325
|
type UserActivityType = "trade" | "withdrawal" | "bridge" | "deposit" | "user_op" | "redeem";
|
|
2254
2326
|
interface UserActivityBase {
|
|
2255
2327
|
id: string;
|
|
@@ -2453,6 +2525,8 @@ interface VenueSoloQuote {
|
|
|
2453
2525
|
type SmartRouteSide = "yes" | "no";
|
|
2454
2526
|
/** Trade direction for order routing. "buy" (default) reads asks, "sell" reads bids. */
|
|
2455
2527
|
type TradeSide = "buy" | "sell";
|
|
2528
|
+
/** Trading mode for normal execution endpoints. Defaults to live. */
|
|
2529
|
+
type ExecutionMode = "live" | "paper";
|
|
2456
2530
|
/** Request params for GET /orderbook/:venueMarketOutcomeId/route. */
|
|
2457
2531
|
interface SmartRouteParams {
|
|
2458
2532
|
venueMarketOutcomeId?: string;
|
|
@@ -2464,6 +2538,8 @@ interface SmartRouteParams {
|
|
|
2464
2538
|
side?: SmartRouteSide;
|
|
2465
2539
|
/** Trade direction: "buy" (default) or "sell". */
|
|
2466
2540
|
tradeSide?: TradeSide;
|
|
2541
|
+
/** Trading mode. Defaults to live. */
|
|
2542
|
+
mode?: ExecutionMode;
|
|
2467
2543
|
maxSpend?: number;
|
|
2468
2544
|
/** Sell only: target number of contracts to sell. Required for sell unless maxSpend is given. */
|
|
2469
2545
|
sellShares?: number;
|
|
@@ -2891,7 +2967,7 @@ declare class AggClient {
|
|
|
2891
2967
|
/** List execution positions for the authenticated user (cursor pagination). */
|
|
2892
2968
|
getExecutionPositions(params?: ExecutionPositionsQuery): Promise<PaginatedResponse<ExecutionPositionGroup>>;
|
|
2893
2969
|
/** Get managed wallet balances, including per-chain cash balances and per-venue position balances. */
|
|
2894
|
-
getManagedBalances(): Promise<UnifiedBalanceResponse>;
|
|
2970
|
+
getManagedBalances(params?: ManagedBalancesParams): Promise<UnifiedBalanceResponse>;
|
|
2895
2971
|
/** Cancel a pending managed execution by order id. */
|
|
2896
2972
|
cancelManagedOrder(orderId: string, options?: {
|
|
2897
2973
|
signal?: AbortSignal;
|
|
@@ -3141,4 +3217,4 @@ declare function aggregateMidpoint(midpoints: (number | null | undefined)[]): nu
|
|
|
3141
3217
|
|
|
3142
3218
|
declare function createAggClient(options: AggClientOptions): AggClient;
|
|
3143
3219
|
|
|
3144
|
-
export { type Account, AccountProvider, AccountType, type AggAuthDeliveryMode, type AggAuthProviderType, type AggAuthStartBody, type AggAuthStartResult, type AggAuthVerifyBody, AggClient, type AggClientAuthOptions, type AggClientSessionInput, type AggLinkAccountBody, type AggLinkAccountConfirmResult, type AggLinkAccountResult, type AggSessionUser, AggWebSocket, type AggWebSocketCallbacks, type AggWebSocketOptions, type AggregatedOrderbookLevel, type AggregatedOrderbookResponse, type App, type AppClientConfigResponse, type AttributedOrderbook, type AttributedOrderbookLevel, type AuthCodeResponse, type AuthStatus, type AuthTokenResponse, type AuthUser, type BatchMidpointsResponse, type BatchOrderbooksResponse, type BuildVenueUrlOpts, CONFIRMED_MATCH_STATUSES, type CancelManagedExecutionResponse, type Candle, CandleBuilder, type CandleInterval, type Category, Chain, type ChartBarsResponse, type ChartCandle, type ChartResolution, type ChartVenueCandles, type ComputeSplitsRequest, type ComputeSplitsResponse, type ComputeSplitsSelection, type CorrelatedMarketCascadeItem, type CorrelatedMarketCascadeResponse, type CorrelatedMarketQueryResult, type CorrelatedMarketSide, type CorrelatedMarketSignal, type CorrelatedMarketSignalBatch, type CorrelatedMarketSignalDirection, type CorrelatedMarketsStatus, type CreateApp, type DepositAddressesPendingResponse, type DepositAddressesReadyResponse, type DepositAddressesResponse, type DepositAddressesSupportedChain, type DepositAddressesToken, type DepositStep, type DiagnosticCallback, type DiagnosticEvent, type ExecuteManagedParams, type ExecuteManagedRequest, type ExecuteManagedResponse, type ExecuteTradeRequest, type ExecuteTradeResponse, type ExecutionOrderItem, type ExecutionOrdersQuery, type ExecutionPositionGroup, type ExecutionPositionsQuery, type GetBalanceQuery, type GetBalanceResponse, type GetHoldingsQuery, type GetHoldingsResponse, type GetOrdersParams, type GetOrdersQuery, type GetPositionsParams, type GetPositionsQuery, type HelloResponse, IMAGE_SIZES, ImageSize, type MarkSource, type MarketPriceHistory, MarketStatus, MatchStatus, MatchType, type MatchedMidpoint, type MatchedMidpointOutcome, type MatchedOrderbookMarket, type MatchedVenueMarketOutcomeRef, type MatchingReport, type MidpointItem, type MidpointRow, type NonceResponse, type OrderListItem, type OrderListQuery, OrderStatus, type Orderbook, type OrderbookBatchItemError, type OrderbookBatchItemErrorCode, type OrderbookBatchItemStatus, type OrderbookHistoryPoint, type OrderbookHistoryResponse, type OrderbookLevel, type OrderbookQuoteFill, type OrderbookQuoteParams, type OrderbookQuoteResponse, type OrderbookServiceUnavailableError, type OrderbookState, type OrderbooksOnlyError, type OutcomeMidpoint, type OutcomeMidpointRow, type OutcomeOrderbookResponse, type PaginatedResponse, type PersistedAuthSnapshot, type PositionGroup, type PositionRedeemStatus, type PricePoint, type PriceSource, type PricesHistoryResponse, type QuoteManagedParams, type QuoteManagedRequest, type QuoteManagedResponse, type QuoteManagedSplit, type QuoteManagedStep, type QuoteSplit, type QuoteStep, type RampQuote, type RampQuoteRequest, type RampSessionRequest, type RampWidgetSession, type RedeemLegResult, type RedeemLegStatus, type RedeemRequest, type RedeemResponse, type RequestedOrderbookMarket, type ResolveCorrelatedMarketsParams, type ResolveCorrelatedMarketsResponse, type ResolvedCorrelatedMarketsResponse, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, type ServerWallet, type SettlementSource, type SetupDepositAddressStep, type SetupVenueKeyStep, type SimpleOrderbookLevel, type SmartRouteAllocation, type SmartRouteBridgeStep, type SmartRouteFeeBreakdown, type SmartRouteFill, type SmartRouteParams, type SmartRouteResponse, type SmartRouteSetupCostLine, type SmartRouteSide, type SmartRouteStatus, type SmartRouteVenueFill, type SplitsByAmountResult, type SyncBalancesResponse, type TradeExecutorOrder, type TradeExecutorOrderListResponse, TradeSide$1 as TradeSide, type TradeSplit, type TradeStep, TurnstileChallengeError, type UnifiedBalanceResponse, type UpdateUserBody, type UpsertVenueKey, type UserActivityBridge, type UserActivityDeposit, type UserActivityItem, type UserActivityQuery, type UserActivityRedeem, type UserActivityRedeemLeg, type UserActivityTrade, type UserActivityType, type UserActivityUserOp, type UserActivityWithdrawal, type UserHolding, type UserProfile, VENUES, type ValidateBalanceOnClientStep, type ValidateManagedParams, type ValidateManagedRequest, type ValidateManagedResponse, type ValidateTradeRequest, type ValidateTradeResponse, Venue, type VenueEvent, type VenueEventListItem, type VenueEventWithMarkets, type VenueKeySummary, type VenueMarket, type VenueMarketClusterNode, type VenueMarketListItem, type VenueMarketOutcome, type VenueMarketRef, type VenueOrderbookEntry, type VenueOrderbookLevel, type VenuePositionBalance, type VenuePriceInfo, type VenueSoloQuote, type VerifyBody, type VerifyResponse, type WalletChainBalance, type WalletTokenBalance, type WithdrawManagedParams, type WithdrawManagedRequest, type WithdrawManagedResponse, type WithdrawManagedSourceItem, type WithdrawTokenSymbol, type WithdrawalExpected, type WithdrawalLeg, type WithdrawalLegStatus, type WithdrawalLegType, type WithdrawalLifecycleStatus, type WithdrawalSource, type WithdrawalSourceItem, type WithdrawalSourceStatus, type WsAttributedLevel, type WsAuthenticated, type WsBalanceUpdate, type WsCandleInterval, type WsClientMessage, type WsConnected, type WsError, type WsHeartbeat, type WsMarkSource, type WsMarketResolved, type WsOrderEvent, type WsOrderEventType, type WsOrderSubmitted, type WsOrderbookDelta, type WsOrderbookSnapshot, type WsRedeemEvent, type WsServerMessage, type WsSubscribed, type WsTrade, type WsUnsubscribed, type WsVenueBook, type WsVenueInfo, type WsVenueLevel, type WsWithdrawalLegStatus, type WsWithdrawalLifecycleEvent, type WsWithdrawalLifecycleLeg, type WsWithdrawalLifecycleStatus, aggregateMidpoint, applyOrderbookDelta, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getWalletAddressFromUserProfile, hasShape, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, parse, parseEmail, parseEmailStrict, safeParse, snapshotToOrderbook, sortVenues };
|
|
3220
|
+
export { type Account, AccountProvider, AccountType, type AggAuthDeliveryMode, type AggAuthProviderType, type AggAuthStartBody, type AggAuthStartResult, type AggAuthVerifyBody, AggClient, type AggClientAuthOptions, type AggClientSessionInput, type AggLinkAccountBody, type AggLinkAccountConfirmResult, type AggLinkAccountResult, type AggSessionUser, AggWebSocket, type AggWebSocketCallbacks, type AggWebSocketOptions, type AggregatedOrderbookLevel, type AggregatedOrderbookResponse, type App, type AppClientConfigResponse, type AttributedOrderbook, type AttributedOrderbookLevel, type AuthCodeResponse, type AuthStatus, type AuthTokenResponse, type AuthUser, type BatchMidpointsResponse, type BatchOrderbooksResponse, type BuildVenueUrlOpts, CONFIRMED_MATCH_STATUSES, type CancelManagedExecutionResponse, type Candle, CandleBuilder, type CandleInterval, type Category, Chain, type ChartBarsResponse, type ChartCandle, type ChartResolution, type ChartVenueCandles, type ComputeSplitsRequest, type ComputeSplitsResponse, type ComputeSplitsSelection, type CorrelatedMarketCascadeItem, type CorrelatedMarketCascadeResponse, type CorrelatedMarketQueryResult, type CorrelatedMarketSide, type CorrelatedMarketSignal, type CorrelatedMarketSignalBatch, type CorrelatedMarketSignalDirection, type CorrelatedMarketsStatus, type CreateApp, type DepositAddressesPendingResponse, type DepositAddressesReadyResponse, type DepositAddressesResponse, type DepositAddressesSupportedChain, type DepositAddressesToken, type DepositStep, type DiagnosticCallback, type DiagnosticEvent, type ExecuteManagedParams, type ExecuteManagedRequest, type ExecuteManagedResponse, type ExecuteTradeRequest, type ExecuteTradeResponse, type ExecutionMode, type ExecutionOrderItem, type ExecutionOrdersQuery, type ExecutionPositionGroup, type ExecutionPositionsQuery, type GetBalanceQuery, type GetBalanceResponse, type GetHoldingsQuery, type GetHoldingsResponse, type GetOrdersParams, type GetOrdersQuery, type GetPositionsParams, type GetPositionsQuery, type HelloResponse, IMAGE_SIZES, ImageSize, type ManagedBalancesParams, type MarkSource, type MarketPriceHistory, MarketStatus, MatchStatus, MatchType, type MatchedMidpoint, type MatchedMidpointOutcome, type MatchedOrderbookMarket, type MatchedVenueMarketOutcomeRef, type MatchingReport, type MidpointItem, type MidpointRow, type NonceResponse, type OrderListItem, type OrderListQuery, OrderStatus, type Orderbook, type OrderbookBatchItemError, type OrderbookBatchItemErrorCode, type OrderbookBatchItemStatus, type OrderbookHistoryPoint, type OrderbookHistoryResponse, type OrderbookLevel, type OrderbookQuoteFill, type OrderbookQuoteParams, type OrderbookQuoteResponse, type OrderbookServiceUnavailableError, type OrderbookState, type OrderbooksOnlyError, type OutcomeMidpoint, type OutcomeMidpointRow, type OutcomeOrderbookResponse, type PaginatedResponse, type PersistedAuthSnapshot, type PositionGroup, type PositionRedeemStatus, type PricePoint, type PriceSource, type PricesHistoryResponse, type QuoteManagedParams, type QuoteManagedRequest, type QuoteManagedResponse, type QuoteManagedSplit, type QuoteManagedStep, type QuoteSplit, type QuoteStep, type RampQuote, type RampQuoteRequest, type RampSessionRequest, type RampWidgetSession, type RedeemLegResult, type RedeemLegStatus, type RedeemRequest, type RedeemResponse, type RequestedOrderbookMarket, type ResolveCorrelatedMarketsParams, type ResolveCorrelatedMarketsResponse, type ResolvedCorrelatedMarketsResponse, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, type ServerWallet, type SettlementSource, type SetupDepositAddressStep, type SetupVenueKeyStep, type SimpleOrderbookLevel, type SmartRouteAllocation, type SmartRouteBridgeStep, type SmartRouteFeeBreakdown, type SmartRouteFill, type SmartRouteParams, type SmartRouteResponse, type SmartRouteSetupCostLine, type SmartRouteSide, type SmartRouteStatus, type SmartRouteVenueFill, type SplitsByAmountResult, type SyncBalancesResponse, type TradeExecutorOrder, type TradeExecutorOrderListResponse, TradeSide$1 as TradeSide, type TradeSplit, type TradeStep, TurnstileChallengeError, type UnifiedBalanceResponse, type UpdateUserBody, type UpsertVenueKey, type UserActivityBridge, type UserActivityDeposit, type UserActivityItem, type UserActivityQuery, type UserActivityRedeem, type UserActivityRedeemLeg, type UserActivityTrade, type UserActivityType, type UserActivityUserOp, type UserActivityWithdrawal, type UserHolding, type UserProfile, VENUES, type ValidateBalanceOnClientStep, type ValidateManagedParams, type ValidateManagedRequest, type ValidateManagedResponse, type ValidateTradeRequest, type ValidateTradeResponse, Venue, type VenueEvent, type VenueEventListItem, type VenueEventWithMarkets, type VenueKeySummary, type VenueMarket, type VenueMarketClusterNode, type VenueMarketListItem, type VenueMarketOutcome, type VenueMarketRef, type VenueOrderbookEntry, type VenueOrderbookLevel, type VenuePositionBalance, type VenuePriceInfo, type VenueSoloQuote, type VerifyBody, type VerifyResponse, type WalletChainBalance, type WalletTokenBalance, type WithdrawManagedParams, type WithdrawManagedRequest, type WithdrawManagedResponse, type WithdrawManagedSourceItem, type WithdrawTokenSymbol, type WithdrawalExpected, type WithdrawalLeg, type WithdrawalLegStatus, type WithdrawalLegType, type WithdrawalLifecycleStatus, type WithdrawalSource, type WithdrawalSourceItem, type WithdrawalSourceStatus, type WithdrawalSourceTokenSymbol, type WsArbFeedBatch, type WsArbFeedEntry, type WsArbMarketUpdate, type WsAttributedLevel, type WsAuthenticated, type WsBalanceUpdate, type WsCandleInterval, type WsClientMessage, type WsConnected, type WsError, type WsHeartbeat, type WsMarkSource, type WsMarketResolved, type WsOrderEvent, type WsOrderEventType, type WsOrderSubmitted, type WsOrderbookDelta, type WsOrderbookSnapshot, type WsRedeemEvent, type WsServerMessage, type WsSubscribed, type WsTrade, type WsUnsubscribed, type WsVenueBook, type WsVenueInfo, type WsVenueLevel, type WsWithdrawalLegStatus, type WsWithdrawalLifecycleEvent, type WsWithdrawalLifecycleLeg, type WsWithdrawalLifecycleStatus, aggregateMidpoint, applyOrderbookDelta, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getWalletAddressFromUserProfile, hasShape, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, parse, parseEmail, parseEmailStrict, safeParse, snapshotToOrderbook, sortVenues };
|
package/dist/index.js
CHANGED
|
@@ -826,7 +826,14 @@ var AggWebSocket = class {
|
|
|
826
826
|
this.pendingFlushUnsubs = /* @__PURE__ */ new Set();
|
|
827
827
|
this.pendingFlushTradeSubs = /* @__PURE__ */ new Set();
|
|
828
828
|
this.pendingFlushTradeUnsubs = /* @__PURE__ */ new Set();
|
|
829
|
+
this.pendingFlushArbSubs = /* @__PURE__ */ new Set();
|
|
830
|
+
this.pendingFlushArbUnsubs = /* @__PURE__ */ new Set();
|
|
829
831
|
this.flushScheduled = false;
|
|
832
|
+
// ── Arb subscriptions ──
|
|
833
|
+
this.arbSubs = /* @__PURE__ */ new Map();
|
|
834
|
+
this.arbFeedCbs = /* @__PURE__ */ new Set();
|
|
835
|
+
/** Latest arb market update per marketId (last-value-wins, loss-tolerant). */
|
|
836
|
+
this.latestArb = /* @__PURE__ */ new Map();
|
|
830
837
|
// ── Orderbook state per market ──
|
|
831
838
|
this.books = /* @__PURE__ */ new Map();
|
|
832
839
|
/** Markets currently resyncing (awaiting snapshot after seq gap / checksum mismatch). */
|
|
@@ -858,6 +865,69 @@ var AggWebSocket = class {
|
|
|
858
865
|
isResyncing(outcomeId) {
|
|
859
866
|
return this.resyncing.has(outcomeId);
|
|
860
867
|
}
|
|
868
|
+
/** Get the latest arb update for a market (or null if none received yet). */
|
|
869
|
+
getArb(marketId) {
|
|
870
|
+
var _a;
|
|
871
|
+
return (_a = this.latestArb.get(marketId)) != null ? _a : null;
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Subscribe to per-market arb updates for a given marketId.
|
|
875
|
+
* Ref-counted: multiple callers for the same marketId share one server subscription.
|
|
876
|
+
* Returns an unsubscribe function.
|
|
877
|
+
*/
|
|
878
|
+
subscribeArb(marketId, cb) {
|
|
879
|
+
let entry = this.arbSubs.get(marketId);
|
|
880
|
+
if (!entry) {
|
|
881
|
+
entry = { refCount: 0, cbs: /* @__PURE__ */ new Set() };
|
|
882
|
+
this.arbSubs.set(marketId, entry);
|
|
883
|
+
this.ensureConnected();
|
|
884
|
+
if (this._connected) {
|
|
885
|
+
this.pendingFlushArbUnsubs.delete(marketId);
|
|
886
|
+
this.pendingFlushArbSubs.add(marketId);
|
|
887
|
+
this.scheduleFlush();
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
entry.cbs.add(cb);
|
|
891
|
+
entry.refCount++;
|
|
892
|
+
return () => {
|
|
893
|
+
const e = this.arbSubs.get(marketId);
|
|
894
|
+
if (!e) return;
|
|
895
|
+
e.cbs.delete(cb);
|
|
896
|
+
e.refCount--;
|
|
897
|
+
if (e.refCount <= 0) {
|
|
898
|
+
this.arbSubs.delete(marketId);
|
|
899
|
+
if (this._connected) {
|
|
900
|
+
if (this.pendingFlushArbSubs.has(marketId)) {
|
|
901
|
+
this.pendingFlushArbSubs.delete(marketId);
|
|
902
|
+
} else {
|
|
903
|
+
this.pendingFlushArbUnsubs.add(marketId);
|
|
904
|
+
this.scheduleFlush();
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Subscribe to the global arb-feed batches.
|
|
912
|
+
* Only one server subscription is maintained regardless of how many callers.
|
|
913
|
+
* Returns an unsubscribe function.
|
|
914
|
+
*/
|
|
915
|
+
subscribeArbFeed(cb) {
|
|
916
|
+
const wasEmpty = this.arbFeedCbs.size === 0;
|
|
917
|
+
this.arbFeedCbs.add(cb);
|
|
918
|
+
if (wasEmpty) {
|
|
919
|
+
this.ensureConnected();
|
|
920
|
+
if (this._connected) {
|
|
921
|
+
this.send({ action: "subscribe", channel: "arb-feed" });
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
return () => {
|
|
925
|
+
this.arbFeedCbs.delete(cb);
|
|
926
|
+
if (this.arbFeedCbs.size === 0 && this._connected) {
|
|
927
|
+
this.send({ action: "unsubscribe", channel: "arb-feed" });
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
}
|
|
861
931
|
/**
|
|
862
932
|
* Subscribe to a feed by outcome ID.
|
|
863
933
|
* @param outcomeId The venueMarketOutcomeId to subscribe to.
|
|
@@ -995,6 +1065,11 @@ var AggWebSocket = class {
|
|
|
995
1065
|
this.pendingFlushUnsubs.clear();
|
|
996
1066
|
this.pendingFlushTradeSubs.clear();
|
|
997
1067
|
this.pendingFlushTradeUnsubs.clear();
|
|
1068
|
+
this.arbSubs.clear();
|
|
1069
|
+
this.arbFeedCbs.clear();
|
|
1070
|
+
this.latestArb.clear();
|
|
1071
|
+
this.pendingFlushArbSubs.clear();
|
|
1072
|
+
this.pendingFlushArbUnsubs.clear();
|
|
998
1073
|
this.flushScheduled = false;
|
|
999
1074
|
}
|
|
1000
1075
|
/** Update callbacks (e.g., after React re-render). */
|
|
@@ -1040,7 +1115,7 @@ var AggWebSocket = class {
|
|
|
1040
1115
|
if (wasConnected) {
|
|
1041
1116
|
(_b = (_a = this.callbacks).onConnectionStateChange) == null ? void 0 : _b.call(_a, false);
|
|
1042
1117
|
}
|
|
1043
|
-
if (!this.destroyed && this.subs.size > 0) {
|
|
1118
|
+
if (!this.destroyed && (this.subs.size > 0 || this.arbSubs.size > 0 || this.arbFeedCbs.size > 0)) {
|
|
1044
1119
|
this.scheduleReconnect();
|
|
1045
1120
|
}
|
|
1046
1121
|
};
|
|
@@ -1085,7 +1160,7 @@ var AggWebSocket = class {
|
|
|
1085
1160
|
}
|
|
1086
1161
|
// ── Message handling ──
|
|
1087
1162
|
handleMessage(raw) {
|
|
1088
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1163
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1089
1164
|
const type = raw.type;
|
|
1090
1165
|
switch (type) {
|
|
1091
1166
|
case "orderbook_snapshot":
|
|
@@ -1133,6 +1208,22 @@ var AggWebSocket = class {
|
|
|
1133
1208
|
case "withdrawal_lifecycle":
|
|
1134
1209
|
(_l = (_k = this.callbacks).onWithdrawalLifecycle) == null ? void 0 : _l.call(_k, raw);
|
|
1135
1210
|
break;
|
|
1211
|
+
case "arb_market_update": {
|
|
1212
|
+
const arbMsg = raw;
|
|
1213
|
+
this.latestArb.set(arbMsg.marketId, arbMsg);
|
|
1214
|
+
const arbEntry = this.arbSubs.get(arbMsg.marketId);
|
|
1215
|
+
if (arbEntry) {
|
|
1216
|
+
for (const cb of arbEntry.cbs) cb(arbMsg);
|
|
1217
|
+
}
|
|
1218
|
+
(_n = (_m = this.callbacks).onArbMarket) == null ? void 0 : _n.call(_m, arbMsg);
|
|
1219
|
+
break;
|
|
1220
|
+
}
|
|
1221
|
+
case "arb_feed_batch": {
|
|
1222
|
+
const feedMsg = raw;
|
|
1223
|
+
for (const cb of this.arbFeedCbs) cb(feedMsg);
|
|
1224
|
+
(_p = (_o = this.callbacks).onArbFeed) == null ? void 0 : _p.call(_o, feedMsg);
|
|
1225
|
+
break;
|
|
1226
|
+
}
|
|
1136
1227
|
}
|
|
1137
1228
|
}
|
|
1138
1229
|
/**
|
|
@@ -1169,6 +1260,17 @@ var AggWebSocket = class {
|
|
|
1169
1260
|
this.send({ action: "resnapshot", channel: "orderbook", outcomeIds: resnapshotIds });
|
|
1170
1261
|
}
|
|
1171
1262
|
this.pendingResnapshots.clear();
|
|
1263
|
+
const arbSet = new Set(this.activeArbMarkets());
|
|
1264
|
+
this.pendingFlushArbSubs.forEach((id) => arbSet.add(id));
|
|
1265
|
+
const arbIds = Array.from(arbSet);
|
|
1266
|
+
if (arbIds.length > 0) {
|
|
1267
|
+
this.send({ action: "subscribe", channel: "arb", marketIds: arbIds });
|
|
1268
|
+
}
|
|
1269
|
+
this.pendingFlushArbSubs.clear();
|
|
1270
|
+
this.pendingFlushArbUnsubs.clear();
|
|
1271
|
+
if (this.arbFeedCbs.size > 0) {
|
|
1272
|
+
this.send({ action: "subscribe", channel: "arb-feed" });
|
|
1273
|
+
}
|
|
1172
1274
|
}
|
|
1173
1275
|
handleSnapshot(raw) {
|
|
1174
1276
|
var _a, _b;
|
|
@@ -1340,6 +1442,8 @@ var AggWebSocket = class {
|
|
|
1340
1442
|
this.pendingFlushUnsubs.clear();
|
|
1341
1443
|
this.pendingFlushTradeSubs.clear();
|
|
1342
1444
|
this.pendingFlushTradeUnsubs.clear();
|
|
1445
|
+
this.pendingFlushArbSubs.clear();
|
|
1446
|
+
this.pendingFlushArbUnsubs.clear();
|
|
1343
1447
|
return;
|
|
1344
1448
|
}
|
|
1345
1449
|
this.flushPending();
|
|
@@ -1386,6 +1490,28 @@ var AggWebSocket = class {
|
|
|
1386
1490
|
});
|
|
1387
1491
|
this.pendingFlushTradeUnsubs.clear();
|
|
1388
1492
|
}
|
|
1493
|
+
for (const id of [...this.pendingFlushArbSubs]) {
|
|
1494
|
+
if (this.pendingFlushArbUnsubs.has(id)) {
|
|
1495
|
+
this.pendingFlushArbSubs.delete(id);
|
|
1496
|
+
this.pendingFlushArbUnsubs.delete(id);
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
if (this.pendingFlushArbSubs.size > 0) {
|
|
1500
|
+
this.send({
|
|
1501
|
+
action: "subscribe",
|
|
1502
|
+
channel: "arb",
|
|
1503
|
+
marketIds: Array.from(this.pendingFlushArbSubs)
|
|
1504
|
+
});
|
|
1505
|
+
this.pendingFlushArbSubs.clear();
|
|
1506
|
+
}
|
|
1507
|
+
if (this.pendingFlushArbUnsubs.size > 0) {
|
|
1508
|
+
this.send({
|
|
1509
|
+
action: "unsubscribe",
|
|
1510
|
+
channel: "arb",
|
|
1511
|
+
marketIds: Array.from(this.pendingFlushArbUnsubs)
|
|
1512
|
+
});
|
|
1513
|
+
this.pendingFlushArbUnsubs.clear();
|
|
1514
|
+
}
|
|
1389
1515
|
}
|
|
1390
1516
|
sendSubscribe(outcomeIds) {
|
|
1391
1517
|
this.send({ action: "subscribe", channel: "orderbook", outcomeIds });
|
|
@@ -1410,6 +1536,9 @@ var AggWebSocket = class {
|
|
|
1410
1536
|
});
|
|
1411
1537
|
return markets;
|
|
1412
1538
|
}
|
|
1539
|
+
activeArbMarkets() {
|
|
1540
|
+
return Array.from(this.arbSubs.keys());
|
|
1541
|
+
}
|
|
1413
1542
|
emitDiagnostic(event) {
|
|
1414
1543
|
var _a, _b;
|
|
1415
1544
|
(_b = (_a = this.callbacks).onDiagnostics) == null ? void 0 : _b.call(_a, event);
|
|
@@ -2091,6 +2220,7 @@ Issued At: ${issuedAt}`;
|
|
|
2091
2220
|
if (params.orderId) query.orderId = params.orderId;
|
|
2092
2221
|
if (params.quoteId) query.quoteId = params.quoteId;
|
|
2093
2222
|
if (params.status) query.status = params.status;
|
|
2223
|
+
if (params.mode) query.mode = params.mode;
|
|
2094
2224
|
if (params.cursor) query.cursor = params.cursor;
|
|
2095
2225
|
if (params.limit != null) query.limit = String(params.limit);
|
|
2096
2226
|
return this.request("/execution/orders", {
|
|
@@ -2117,6 +2247,7 @@ Issued At: ${issuedAt}`;
|
|
|
2117
2247
|
if (params.cursor) query.cursor = params.cursor;
|
|
2118
2248
|
if (params.limit != null) query.limit = String(params.limit);
|
|
2119
2249
|
if (params.status) query.status = params.status;
|
|
2250
|
+
if (params.mode) query.mode = params.mode;
|
|
2120
2251
|
return this.request("/execution/positions", {
|
|
2121
2252
|
query: Object.keys(query).length ? query : void 0
|
|
2122
2253
|
});
|
|
@@ -2124,8 +2255,12 @@ Issued At: ${issuedAt}`;
|
|
|
2124
2255
|
}
|
|
2125
2256
|
/** Get managed wallet balances, including per-chain cash balances and per-venue position balances. */
|
|
2126
2257
|
getManagedBalances() {
|
|
2127
|
-
return __async(this,
|
|
2128
|
-
|
|
2258
|
+
return __async(this, arguments, function* (params = {}) {
|
|
2259
|
+
const query = {};
|
|
2260
|
+
if (params.mode) query.mode = params.mode;
|
|
2261
|
+
return this.request("/execution/balances", {
|
|
2262
|
+
query: Object.keys(query).length ? query : void 0
|
|
2263
|
+
});
|
|
2129
2264
|
});
|
|
2130
2265
|
}
|
|
2131
2266
|
/** Cancel a pending managed execution by order id. */
|
|
@@ -2373,6 +2508,7 @@ Issued At: ${issuedAt}`;
|
|
|
2373
2508
|
if (params.compareVenues) query.compareVenues = "true";
|
|
2374
2509
|
if ((_c = params.allowedVenues) == null ? void 0 : _c.length) query.allowedVenues = params.allowedVenues.map(String);
|
|
2375
2510
|
if (params.tradeSide) query.side = params.tradeSide;
|
|
2511
|
+
if (params.mode) query.mode = params.mode;
|
|
2376
2512
|
if (params.deepEstimate) query.deepEstimate = "true";
|
|
2377
2513
|
const response = yield this.request(
|
|
2378
2514
|
`/orderbook/${encodeURIComponent(venueMarketOutcomeId)}/route`,
|
|
@@ -2474,6 +2610,7 @@ Issued At: ${issuedAt}`;
|
|
|
2474
2610
|
if (params == null ? void 0 : params.cursor) query.cursor = params.cursor;
|
|
2475
2611
|
if ((params == null ? void 0 : params.limit) != null) query.limit = String(params.limit);
|
|
2476
2612
|
if (params == null ? void 0 : params.status) query.status = params.status;
|
|
2613
|
+
if (params == null ? void 0 : params.mode) query.mode = params.mode;
|
|
2477
2614
|
return this.request("/execution/positions", {
|
|
2478
2615
|
query: Object.keys(query).length > 0 ? query : void 0
|
|
2479
2616
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -727,7 +727,14 @@ var AggWebSocket = class {
|
|
|
727
727
|
this.pendingFlushUnsubs = /* @__PURE__ */ new Set();
|
|
728
728
|
this.pendingFlushTradeSubs = /* @__PURE__ */ new Set();
|
|
729
729
|
this.pendingFlushTradeUnsubs = /* @__PURE__ */ new Set();
|
|
730
|
+
this.pendingFlushArbSubs = /* @__PURE__ */ new Set();
|
|
731
|
+
this.pendingFlushArbUnsubs = /* @__PURE__ */ new Set();
|
|
730
732
|
this.flushScheduled = false;
|
|
733
|
+
// ── Arb subscriptions ──
|
|
734
|
+
this.arbSubs = /* @__PURE__ */ new Map();
|
|
735
|
+
this.arbFeedCbs = /* @__PURE__ */ new Set();
|
|
736
|
+
/** Latest arb market update per marketId (last-value-wins, loss-tolerant). */
|
|
737
|
+
this.latestArb = /* @__PURE__ */ new Map();
|
|
731
738
|
// ── Orderbook state per market ──
|
|
732
739
|
this.books = /* @__PURE__ */ new Map();
|
|
733
740
|
/** Markets currently resyncing (awaiting snapshot after seq gap / checksum mismatch). */
|
|
@@ -759,6 +766,69 @@ var AggWebSocket = class {
|
|
|
759
766
|
isResyncing(outcomeId) {
|
|
760
767
|
return this.resyncing.has(outcomeId);
|
|
761
768
|
}
|
|
769
|
+
/** Get the latest arb update for a market (or null if none received yet). */
|
|
770
|
+
getArb(marketId) {
|
|
771
|
+
var _a;
|
|
772
|
+
return (_a = this.latestArb.get(marketId)) != null ? _a : null;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Subscribe to per-market arb updates for a given marketId.
|
|
776
|
+
* Ref-counted: multiple callers for the same marketId share one server subscription.
|
|
777
|
+
* Returns an unsubscribe function.
|
|
778
|
+
*/
|
|
779
|
+
subscribeArb(marketId, cb) {
|
|
780
|
+
let entry = this.arbSubs.get(marketId);
|
|
781
|
+
if (!entry) {
|
|
782
|
+
entry = { refCount: 0, cbs: /* @__PURE__ */ new Set() };
|
|
783
|
+
this.arbSubs.set(marketId, entry);
|
|
784
|
+
this.ensureConnected();
|
|
785
|
+
if (this._connected) {
|
|
786
|
+
this.pendingFlushArbUnsubs.delete(marketId);
|
|
787
|
+
this.pendingFlushArbSubs.add(marketId);
|
|
788
|
+
this.scheduleFlush();
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
entry.cbs.add(cb);
|
|
792
|
+
entry.refCount++;
|
|
793
|
+
return () => {
|
|
794
|
+
const e = this.arbSubs.get(marketId);
|
|
795
|
+
if (!e) return;
|
|
796
|
+
e.cbs.delete(cb);
|
|
797
|
+
e.refCount--;
|
|
798
|
+
if (e.refCount <= 0) {
|
|
799
|
+
this.arbSubs.delete(marketId);
|
|
800
|
+
if (this._connected) {
|
|
801
|
+
if (this.pendingFlushArbSubs.has(marketId)) {
|
|
802
|
+
this.pendingFlushArbSubs.delete(marketId);
|
|
803
|
+
} else {
|
|
804
|
+
this.pendingFlushArbUnsubs.add(marketId);
|
|
805
|
+
this.scheduleFlush();
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Subscribe to the global arb-feed batches.
|
|
813
|
+
* Only one server subscription is maintained regardless of how many callers.
|
|
814
|
+
* Returns an unsubscribe function.
|
|
815
|
+
*/
|
|
816
|
+
subscribeArbFeed(cb) {
|
|
817
|
+
const wasEmpty = this.arbFeedCbs.size === 0;
|
|
818
|
+
this.arbFeedCbs.add(cb);
|
|
819
|
+
if (wasEmpty) {
|
|
820
|
+
this.ensureConnected();
|
|
821
|
+
if (this._connected) {
|
|
822
|
+
this.send({ action: "subscribe", channel: "arb-feed" });
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
return () => {
|
|
826
|
+
this.arbFeedCbs.delete(cb);
|
|
827
|
+
if (this.arbFeedCbs.size === 0 && this._connected) {
|
|
828
|
+
this.send({ action: "unsubscribe", channel: "arb-feed" });
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
}
|
|
762
832
|
/**
|
|
763
833
|
* Subscribe to a feed by outcome ID.
|
|
764
834
|
* @param outcomeId The venueMarketOutcomeId to subscribe to.
|
|
@@ -896,6 +966,11 @@ var AggWebSocket = class {
|
|
|
896
966
|
this.pendingFlushUnsubs.clear();
|
|
897
967
|
this.pendingFlushTradeSubs.clear();
|
|
898
968
|
this.pendingFlushTradeUnsubs.clear();
|
|
969
|
+
this.arbSubs.clear();
|
|
970
|
+
this.arbFeedCbs.clear();
|
|
971
|
+
this.latestArb.clear();
|
|
972
|
+
this.pendingFlushArbSubs.clear();
|
|
973
|
+
this.pendingFlushArbUnsubs.clear();
|
|
899
974
|
this.flushScheduled = false;
|
|
900
975
|
}
|
|
901
976
|
/** Update callbacks (e.g., after React re-render). */
|
|
@@ -941,7 +1016,7 @@ var AggWebSocket = class {
|
|
|
941
1016
|
if (wasConnected) {
|
|
942
1017
|
(_b = (_a = this.callbacks).onConnectionStateChange) == null ? void 0 : _b.call(_a, false);
|
|
943
1018
|
}
|
|
944
|
-
if (!this.destroyed && this.subs.size > 0) {
|
|
1019
|
+
if (!this.destroyed && (this.subs.size > 0 || this.arbSubs.size > 0 || this.arbFeedCbs.size > 0)) {
|
|
945
1020
|
this.scheduleReconnect();
|
|
946
1021
|
}
|
|
947
1022
|
};
|
|
@@ -986,7 +1061,7 @@ var AggWebSocket = class {
|
|
|
986
1061
|
}
|
|
987
1062
|
// ── Message handling ──
|
|
988
1063
|
handleMessage(raw) {
|
|
989
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1064
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
990
1065
|
const type = raw.type;
|
|
991
1066
|
switch (type) {
|
|
992
1067
|
case "orderbook_snapshot":
|
|
@@ -1034,6 +1109,22 @@ var AggWebSocket = class {
|
|
|
1034
1109
|
case "withdrawal_lifecycle":
|
|
1035
1110
|
(_l = (_k = this.callbacks).onWithdrawalLifecycle) == null ? void 0 : _l.call(_k, raw);
|
|
1036
1111
|
break;
|
|
1112
|
+
case "arb_market_update": {
|
|
1113
|
+
const arbMsg = raw;
|
|
1114
|
+
this.latestArb.set(arbMsg.marketId, arbMsg);
|
|
1115
|
+
const arbEntry = this.arbSubs.get(arbMsg.marketId);
|
|
1116
|
+
if (arbEntry) {
|
|
1117
|
+
for (const cb of arbEntry.cbs) cb(arbMsg);
|
|
1118
|
+
}
|
|
1119
|
+
(_n = (_m = this.callbacks).onArbMarket) == null ? void 0 : _n.call(_m, arbMsg);
|
|
1120
|
+
break;
|
|
1121
|
+
}
|
|
1122
|
+
case "arb_feed_batch": {
|
|
1123
|
+
const feedMsg = raw;
|
|
1124
|
+
for (const cb of this.arbFeedCbs) cb(feedMsg);
|
|
1125
|
+
(_p = (_o = this.callbacks).onArbFeed) == null ? void 0 : _p.call(_o, feedMsg);
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1037
1128
|
}
|
|
1038
1129
|
}
|
|
1039
1130
|
/**
|
|
@@ -1070,6 +1161,17 @@ var AggWebSocket = class {
|
|
|
1070
1161
|
this.send({ action: "resnapshot", channel: "orderbook", outcomeIds: resnapshotIds });
|
|
1071
1162
|
}
|
|
1072
1163
|
this.pendingResnapshots.clear();
|
|
1164
|
+
const arbSet = new Set(this.activeArbMarkets());
|
|
1165
|
+
this.pendingFlushArbSubs.forEach((id) => arbSet.add(id));
|
|
1166
|
+
const arbIds = Array.from(arbSet);
|
|
1167
|
+
if (arbIds.length > 0) {
|
|
1168
|
+
this.send({ action: "subscribe", channel: "arb", marketIds: arbIds });
|
|
1169
|
+
}
|
|
1170
|
+
this.pendingFlushArbSubs.clear();
|
|
1171
|
+
this.pendingFlushArbUnsubs.clear();
|
|
1172
|
+
if (this.arbFeedCbs.size > 0) {
|
|
1173
|
+
this.send({ action: "subscribe", channel: "arb-feed" });
|
|
1174
|
+
}
|
|
1073
1175
|
}
|
|
1074
1176
|
handleSnapshot(raw) {
|
|
1075
1177
|
var _a, _b;
|
|
@@ -1241,6 +1343,8 @@ var AggWebSocket = class {
|
|
|
1241
1343
|
this.pendingFlushUnsubs.clear();
|
|
1242
1344
|
this.pendingFlushTradeSubs.clear();
|
|
1243
1345
|
this.pendingFlushTradeUnsubs.clear();
|
|
1346
|
+
this.pendingFlushArbSubs.clear();
|
|
1347
|
+
this.pendingFlushArbUnsubs.clear();
|
|
1244
1348
|
return;
|
|
1245
1349
|
}
|
|
1246
1350
|
this.flushPending();
|
|
@@ -1287,6 +1391,28 @@ var AggWebSocket = class {
|
|
|
1287
1391
|
});
|
|
1288
1392
|
this.pendingFlushTradeUnsubs.clear();
|
|
1289
1393
|
}
|
|
1394
|
+
for (const id of [...this.pendingFlushArbSubs]) {
|
|
1395
|
+
if (this.pendingFlushArbUnsubs.has(id)) {
|
|
1396
|
+
this.pendingFlushArbSubs.delete(id);
|
|
1397
|
+
this.pendingFlushArbUnsubs.delete(id);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
if (this.pendingFlushArbSubs.size > 0) {
|
|
1401
|
+
this.send({
|
|
1402
|
+
action: "subscribe",
|
|
1403
|
+
channel: "arb",
|
|
1404
|
+
marketIds: Array.from(this.pendingFlushArbSubs)
|
|
1405
|
+
});
|
|
1406
|
+
this.pendingFlushArbSubs.clear();
|
|
1407
|
+
}
|
|
1408
|
+
if (this.pendingFlushArbUnsubs.size > 0) {
|
|
1409
|
+
this.send({
|
|
1410
|
+
action: "unsubscribe",
|
|
1411
|
+
channel: "arb",
|
|
1412
|
+
marketIds: Array.from(this.pendingFlushArbUnsubs)
|
|
1413
|
+
});
|
|
1414
|
+
this.pendingFlushArbUnsubs.clear();
|
|
1415
|
+
}
|
|
1290
1416
|
}
|
|
1291
1417
|
sendSubscribe(outcomeIds) {
|
|
1292
1418
|
this.send({ action: "subscribe", channel: "orderbook", outcomeIds });
|
|
@@ -1311,6 +1437,9 @@ var AggWebSocket = class {
|
|
|
1311
1437
|
});
|
|
1312
1438
|
return markets;
|
|
1313
1439
|
}
|
|
1440
|
+
activeArbMarkets() {
|
|
1441
|
+
return Array.from(this.arbSubs.keys());
|
|
1442
|
+
}
|
|
1314
1443
|
emitDiagnostic(event) {
|
|
1315
1444
|
var _a, _b;
|
|
1316
1445
|
(_b = (_a = this.callbacks).onDiagnostics) == null ? void 0 : _b.call(_a, event);
|
|
@@ -1992,6 +2121,7 @@ Issued At: ${issuedAt}`;
|
|
|
1992
2121
|
if (params.orderId) query.orderId = params.orderId;
|
|
1993
2122
|
if (params.quoteId) query.quoteId = params.quoteId;
|
|
1994
2123
|
if (params.status) query.status = params.status;
|
|
2124
|
+
if (params.mode) query.mode = params.mode;
|
|
1995
2125
|
if (params.cursor) query.cursor = params.cursor;
|
|
1996
2126
|
if (params.limit != null) query.limit = String(params.limit);
|
|
1997
2127
|
return this.request("/execution/orders", {
|
|
@@ -2018,6 +2148,7 @@ Issued At: ${issuedAt}`;
|
|
|
2018
2148
|
if (params.cursor) query.cursor = params.cursor;
|
|
2019
2149
|
if (params.limit != null) query.limit = String(params.limit);
|
|
2020
2150
|
if (params.status) query.status = params.status;
|
|
2151
|
+
if (params.mode) query.mode = params.mode;
|
|
2021
2152
|
return this.request("/execution/positions", {
|
|
2022
2153
|
query: Object.keys(query).length ? query : void 0
|
|
2023
2154
|
});
|
|
@@ -2025,8 +2156,12 @@ Issued At: ${issuedAt}`;
|
|
|
2025
2156
|
}
|
|
2026
2157
|
/** Get managed wallet balances, including per-chain cash balances and per-venue position balances. */
|
|
2027
2158
|
getManagedBalances() {
|
|
2028
|
-
return __async(this,
|
|
2029
|
-
|
|
2159
|
+
return __async(this, arguments, function* (params = {}) {
|
|
2160
|
+
const query = {};
|
|
2161
|
+
if (params.mode) query.mode = params.mode;
|
|
2162
|
+
return this.request("/execution/balances", {
|
|
2163
|
+
query: Object.keys(query).length ? query : void 0
|
|
2164
|
+
});
|
|
2030
2165
|
});
|
|
2031
2166
|
}
|
|
2032
2167
|
/** Cancel a pending managed execution by order id. */
|
|
@@ -2274,6 +2409,7 @@ Issued At: ${issuedAt}`;
|
|
|
2274
2409
|
if (params.compareVenues) query.compareVenues = "true";
|
|
2275
2410
|
if ((_c = params.allowedVenues) == null ? void 0 : _c.length) query.allowedVenues = params.allowedVenues.map(String);
|
|
2276
2411
|
if (params.tradeSide) query.side = params.tradeSide;
|
|
2412
|
+
if (params.mode) query.mode = params.mode;
|
|
2277
2413
|
if (params.deepEstimate) query.deepEstimate = "true";
|
|
2278
2414
|
const response = yield this.request(
|
|
2279
2415
|
`/orderbook/${encodeURIComponent(venueMarketOutcomeId)}/route`,
|
|
@@ -2375,6 +2511,7 @@ Issued At: ${issuedAt}`;
|
|
|
2375
2511
|
if (params == null ? void 0 : params.cursor) query.cursor = params.cursor;
|
|
2376
2512
|
if ((params == null ? void 0 : params.limit) != null) query.limit = String(params.limit);
|
|
2377
2513
|
if (params == null ? void 0 : params.status) query.status = params.status;
|
|
2514
|
+
if (params == null ? void 0 : params.mode) query.mode = params.mode;
|
|
2378
2515
|
return this.request("/execution/positions", {
|
|
2379
2516
|
query: Object.keys(query).length > 0 ? query : void 0
|
|
2380
2517
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agg-build/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Vanilla TypeScript client for the AGG prediction market aggregator (auth, markets, orderbooks, charts, trading, managed execution, WebSockets). Works in browsers, Node.js, and React Native.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|