@agg-build/sdk 4.5.0 → 4.7.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 +172 -4
- package/dist/index.d.ts +172 -4
- package/dist/index.js +112 -14
- package/dist/index.mjs +109 -14
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1226,11 +1226,11 @@ interface TSchema extends TKind, SchemaOptions {
|
|
|
1226
1226
|
* Always carry a human-readable `message` alongside; the code is additive and
|
|
1227
1227
|
* may be absent on rejections that pre-date this addition.
|
|
1228
1228
|
*/
|
|
1229
|
-
declare const QuoteErrorCodeTB: TUnion<[TLiteral<"quote_not_found">, TLiteral<"quote_expired">, TLiteral<"quote_already_executed">, TLiteral<"quote_cancelled">, TLiteral<"quote_user_mismatch">, TLiteral<"quote_app_blocked">, TLiteral<"quote_unfillable">, TLiteral<"quote_min_order_size">, TLiteral<"quote_stale_status">, TLiteral<"quote_stale_price">, TLiteral<"quote_insufficient_balance">, TLiteral<"quote_market_inactive">, TLiteral<"venue_not_executable">, TLiteral<"outcome_ambiguous">]>;
|
|
1229
|
+
declare const QuoteErrorCodeTB: TUnion<[TLiteral<"quote_not_found">, TLiteral<"quote_expired">, TLiteral<"quote_already_executed">, TLiteral<"quote_cancelled">, TLiteral<"quote_user_mismatch">, TLiteral<"quote_app_blocked">, TLiteral<"quote_unfillable">, TLiteral<"quote_min_order_size">, TLiteral<"quote_stale_status">, TLiteral<"quote_stale_price">, TLiteral<"quote_insufficient_balance">, TLiteral<"quote_market_inactive">, TLiteral<"quote_self_custody_unsupported_venue">, TLiteral<"quote_self_custody_app_fee">, TLiteral<"quote_self_custody_redeem_unsupported">, TLiteral<"venue_not_executable">, TLiteral<"outcome_ambiguous">]>;
|
|
1230
1230
|
type QuoteErrorCode = Static<typeof QuoteErrorCodeTB>;
|
|
1231
1231
|
declare const QuoteErrorTB: TObject<{
|
|
1232
1232
|
message: TString;
|
|
1233
|
-
code: TOptional<TUnion<[TLiteral<"quote_not_found">, TLiteral<"quote_expired">, TLiteral<"quote_already_executed">, TLiteral<"quote_cancelled">, TLiteral<"quote_user_mismatch">, TLiteral<"quote_app_blocked">, TLiteral<"quote_unfillable">, TLiteral<"quote_min_order_size">, TLiteral<"quote_stale_status">, TLiteral<"quote_stale_price">, TLiteral<"quote_insufficient_balance">, TLiteral<"quote_market_inactive">, TLiteral<"venue_not_executable">, TLiteral<"outcome_ambiguous">]>>;
|
|
1233
|
+
code: TOptional<TUnion<[TLiteral<"quote_not_found">, TLiteral<"quote_expired">, TLiteral<"quote_already_executed">, TLiteral<"quote_cancelled">, TLiteral<"quote_user_mismatch">, TLiteral<"quote_app_blocked">, TLiteral<"quote_unfillable">, TLiteral<"quote_min_order_size">, TLiteral<"quote_stale_status">, TLiteral<"quote_stale_price">, TLiteral<"quote_insufficient_balance">, TLiteral<"quote_market_inactive">, TLiteral<"quote_self_custody_unsupported_venue">, TLiteral<"quote_self_custody_app_fee">, TLiteral<"quote_self_custody_redeem_unsupported">, TLiteral<"venue_not_executable">, TLiteral<"outcome_ambiguous">]>>;
|
|
1234
1234
|
}>;
|
|
1235
1235
|
type QuoteError = Static<typeof QuoteErrorTB>;
|
|
1236
1236
|
|
|
@@ -2164,6 +2164,82 @@ interface PersistedAuthSnapshot {
|
|
|
2164
2164
|
}
|
|
2165
2165
|
/** Auth lifecycle status for UI state machines. */
|
|
2166
2166
|
type AuthStatus = "unknown" | "authenticated" | "unauthenticated";
|
|
2167
|
+
type SignatureRequestType = "eip712" | "personal_sign"
|
|
2168
|
+
/** EVM transaction — bridge legs and approvals. secp256k1. */
|
|
2169
|
+
| "transaction"
|
|
2170
|
+
/** Solana transaction — bridge legs on SVM. ed25519, NOT secp256k1. */
|
|
2171
|
+
| "solana_transaction" | "hl_l1_action"
|
|
2172
|
+
/**
|
|
2173
|
+
* EIP-7702 authorization over `{ contractAddress, chainId, nonce }`.
|
|
2174
|
+
*
|
|
2175
|
+
* A signature over a RAW digest — `keccak(0x05 ‖ rlp([chainId, delegate,
|
|
2176
|
+
* nonce]))` — not EIP-191 and not EIP-712. Many wallets do not expose this,
|
|
2177
|
+
* and that is expected: reject it and the server falls back to asking the
|
|
2178
|
+
* user to broadcast a plain approve instead.
|
|
2179
|
+
*/
|
|
2180
|
+
| "eip7702_authorization";
|
|
2181
|
+
/** One payload the client must sign before a fill can proceed. */
|
|
2182
|
+
interface SignatureRequest {
|
|
2183
|
+
/** Echo this back with the signature. */
|
|
2184
|
+
stepId: string;
|
|
2185
|
+
/** Payload shape. Discriminates how to sign — not which venue. */
|
|
2186
|
+
type: SignatureRequestType;
|
|
2187
|
+
venue: string;
|
|
2188
|
+
/** The address that must produce this signature. Sign with this key, not another. */
|
|
2189
|
+
signerAddress: string;
|
|
2190
|
+
/** Absent for non-EVM payloads (e.g. Hyperliquid L1 actions). */
|
|
2191
|
+
chainId?: number;
|
|
2192
|
+
/** Sign verbatim. */
|
|
2193
|
+
payload: unknown;
|
|
2194
|
+
expiresAt: string;
|
|
2195
|
+
}
|
|
2196
|
+
/**
|
|
2197
|
+
* Supplied by the partner. Receives a payload, returns a signature. The SDK
|
|
2198
|
+
* never sees the key.
|
|
2199
|
+
*
|
|
2200
|
+
* Return a 0x-prefixed hex string for anything the wallet SIGNS:
|
|
2201
|
+
*
|
|
2202
|
+
* - `eip712` — `signTypedData` over `payload`.
|
|
2203
|
+
* - `personal_sign` — `personal_sign` over `payload`.
|
|
2204
|
+
* - `hl_l1_action` — Hyperliquid L1 action, EIP-712 in phantom-agent form.
|
|
2205
|
+
* - `eip7702_authorization` — an EIP-7702 authorization over
|
|
2206
|
+
* `{ contractAddress, chainId, nonce }`. This is a signature over a RAW
|
|
2207
|
+
* digest, not EIP-191 and not EIP-712, and many wallets do not expose it.
|
|
2208
|
+
* **Throwing here does not help**: there is no reject verb, so a thrown
|
|
2209
|
+
* signer is indistinguishable from a slow user — the request simply expires
|
|
2210
|
+
* and the fill dies. If your wallet cannot produce this signature, declare
|
|
2211
|
+
* `approveMode: "user_broadcast"` on the fill instead and the approve is
|
|
2212
|
+
* requested as a `transaction` the user sends themselves. Handling this
|
|
2213
|
+
* request is what makes funding gasless.
|
|
2214
|
+
*
|
|
2215
|
+
* Return `{ txHash }` for anything the wallet BROADCASTS:
|
|
2216
|
+
*
|
|
2217
|
+
* - `transaction` — send it, then return the hash **immediately, without
|
|
2218
|
+
* awaiting the receipt**. The server watches for the mined receipt itself
|
|
2219
|
+
* and will not resume until it matches the request byte-for-byte.
|
|
2220
|
+
*/
|
|
2221
|
+
type SignerFn = (req: SignatureRequest) => Promise<string | {
|
|
2222
|
+
txHash: string;
|
|
2223
|
+
}>;
|
|
2224
|
+
/**
|
|
2225
|
+
* How long `fillSelfCustody` will keep waiting before giving up.
|
|
2226
|
+
*
|
|
2227
|
+
* Covers a first-time user: sign the wallet-setup batch, wait for it on-chain,
|
|
2228
|
+
* then sign the order. Generous because the wait is a relayer transaction
|
|
2229
|
+
* confirming, not a human deciding.
|
|
2230
|
+
*/
|
|
2231
|
+
declare const SELF_CUSTODY_FILL_TIMEOUT_MS: number;
|
|
2232
|
+
/** Gap between re-reads while an on-chain step is in flight. */
|
|
2233
|
+
declare const SELF_CUSTODY_POLL_INTERVAL_MS = 2000;
|
|
2234
|
+
/**
|
|
2235
|
+
* States a run never leaves. Everything else means "still working".
|
|
2236
|
+
*
|
|
2237
|
+
* Typed against `ExecutionOverallState` so a typo'd or renamed literal (e.g.
|
|
2238
|
+
* `cancelled` drifting to `canceled`) is a compile error instead of a state
|
|
2239
|
+
* that silently stops being treated as terminal. Mirrors
|
|
2240
|
+
* `ExecutionOverallStateTB` in the contract; keep the two in step.
|
|
2241
|
+
*/
|
|
2242
|
+
declare const TERMINAL_EXECUTION_STATES: ReadonlySet<ExecutionOverallState>;
|
|
2167
2243
|
type SportsGameStatus = "scheduled" | "live" | "paused" | "finished" | "cancelled" | "postponed" | "unknown";
|
|
2168
2244
|
interface SportsLiveParticipant {
|
|
2169
2245
|
position: "first" | "second";
|
|
@@ -2213,6 +2289,17 @@ interface AggClientOptions {
|
|
|
2213
2289
|
* When authDelivery is "cookie-refresh", refresh tokens survive via HttpOnly cookies
|
|
2214
2290
|
* and the SDK attempts a silent refresh on cold start. Defaults to true. */
|
|
2215
2291
|
persistSession?: boolean;
|
|
2292
|
+
/**
|
|
2293
|
+
* Supplies signatures for self-custodial fills. Required whenever
|
|
2294
|
+
* `fillSelfCustody()` is called with `signingAddress` — the SDK never
|
|
2295
|
+
* holds a key itself, so without this option a fill that needs a
|
|
2296
|
+
* client-side signature cannot proceed. The signature requests never
|
|
2297
|
+
* come back on `POST /execution/fill` itself: `fillSelfCustody()` polls
|
|
2298
|
+
* `GET /execution/status` for them (`pendingSignatures`), signs each one
|
|
2299
|
+
* with this function, and posts the result to
|
|
2300
|
+
* `POST /execution/fill/:quoteId/signatures`.
|
|
2301
|
+
*/
|
|
2302
|
+
signer?: SignerFn;
|
|
2216
2303
|
}
|
|
2217
2304
|
interface SiweMessageParams {
|
|
2218
2305
|
domain: string;
|
|
@@ -2791,6 +2878,25 @@ interface ExecuteManagedParams {
|
|
|
2791
2878
|
sellShares?: number;
|
|
2792
2879
|
allowedVenues?: Venue[];
|
|
2793
2880
|
};
|
|
2881
|
+
/**
|
|
2882
|
+
* Self-custody: the wallet that will sign this fill. Must be a wallet
|
|
2883
|
+
* already linked to this account. Omit for managed custody (the default).
|
|
2884
|
+
*/
|
|
2885
|
+
signingAddress?: string;
|
|
2886
|
+
/**
|
|
2887
|
+
* Self-custody only: which approve shape a cross-chain fill uses when the
|
|
2888
|
+
* bridge needs an ERC20 approve. Omit (the default) for "sponsored" — we pay
|
|
2889
|
+
* the gas, but the wallet must sign a one-time EIP-7702 authorization over a
|
|
2890
|
+
* RAW DIGEST, which many wallets cannot produce. Send "user_broadcast" when
|
|
2891
|
+
* yours cannot: the user sends the approve and pays their own gas. Only your
|
|
2892
|
+
* client can know which applies — it is a property of the wallet software,
|
|
2893
|
+
* not of the address or the chain.
|
|
2894
|
+
*
|
|
2895
|
+
* Worth surfacing in your UI: "user_broadcast" never establishes the
|
|
2896
|
+
* delegation, so it charges gas on EVERY bridge. "sponsored" costs one
|
|
2897
|
+
* signature once per chain, then is free.
|
|
2898
|
+
*/
|
|
2899
|
+
approveMode?: "sponsored" | "user_broadcast";
|
|
2794
2900
|
}
|
|
2795
2901
|
interface ExecuteManagedResponse {
|
|
2796
2902
|
quoteId: string;
|
|
@@ -2798,6 +2904,17 @@ interface ExecuteManagedResponse {
|
|
|
2798
2904
|
status: "pending";
|
|
2799
2905
|
redeemId?: string;
|
|
2800
2906
|
message?: string;
|
|
2907
|
+
/**
|
|
2908
|
+
* What this fill is waiting to be signed, if anything. On the immediate
|
|
2909
|
+
* `POST /execution/fill` response this is always absent or empty — even
|
|
2910
|
+
* for a self-custody fill, the DAG parks asynchronously, after this
|
|
2911
|
+
* response has already been sent. Real entries only ever come back from
|
|
2912
|
+
* polling `GET /execution/status` or from the next
|
|
2913
|
+
* `POST /execution/fill/:quoteId/signatures` response (this same shape,
|
|
2914
|
+
* reused). Drive the whole round trip through `fillSelfCustody()` rather
|
|
2915
|
+
* than reading this field on the fill response by hand.
|
|
2916
|
+
*/
|
|
2917
|
+
pendingSignatures?: SignatureRequest[];
|
|
2801
2918
|
}
|
|
2802
2919
|
type LimitOrderTimeInForce = "GTC" | "GTD" | "FOK" | "FAK" | "IOC" | "ALO";
|
|
2803
2920
|
interface PlaceLimitOrderParams {
|
|
@@ -3162,6 +3279,14 @@ interface ExecutionStatusResponse {
|
|
|
3162
3279
|
dagProgress: ExecutionDagProgress | null;
|
|
3163
3280
|
steps: ExecutionStatusStep[];
|
|
3164
3281
|
orders: ExecutionStatusOrder[];
|
|
3282
|
+
/**
|
|
3283
|
+
* What this run is waiting to be signed, mirroring the fill response's
|
|
3284
|
+
* field of the same name. This is the polling route `fillSelfCustody` reads
|
|
3285
|
+
* while an on-chain step is in flight — a caller polling this route for
|
|
3286
|
+
* progress learns about newly-parked steps here too, not just from the
|
|
3287
|
+
* signatures endpoint.
|
|
3288
|
+
*/
|
|
3289
|
+
pendingSignatures?: SignatureRequest[];
|
|
3165
3290
|
}
|
|
3166
3291
|
type ExecutionPositionsQuery = GetPositionsQuery & {
|
|
3167
3292
|
mode?: ExecutionMode;
|
|
@@ -4038,6 +4163,8 @@ declare class AggClient {
|
|
|
4038
4163
|
private authOptions?;
|
|
4039
4164
|
/** In-flight refresh promise — serializes concurrent 401 retries so only one refresh runs. */
|
|
4040
4165
|
private pendingRefresh;
|
|
4166
|
+
/** Partner-supplied signature callback for self-custodial fills. The SDK never sees a key. */
|
|
4167
|
+
private readonly signer?;
|
|
4041
4168
|
constructor(options: AggClientOptions);
|
|
4042
4169
|
private resolvePaperTradingAppId;
|
|
4043
4170
|
private paperTradingAccountsPath;
|
|
@@ -4171,7 +4298,13 @@ declare class AggClient {
|
|
|
4171
4298
|
* rollup (total cost, share-weighted avg price, to-win).
|
|
4172
4299
|
*/
|
|
4173
4300
|
getExecutionOrders(params?: ExecutionOrdersQuery): Promise<PaginatedResponse<ExecutionOrderItem>>;
|
|
4174
|
-
/**
|
|
4301
|
+
/**
|
|
4302
|
+
* Get quote-scoped execution progress, DAG step state, and order leg
|
|
4303
|
+
* terminal status. Also carries `pendingSignatures` — this is the route
|
|
4304
|
+
* `fillSelfCustody` polls while an on-chain step is in flight, so a caller
|
|
4305
|
+
* already polling this for progress learns about newly-parked steps here
|
|
4306
|
+
* too, not just from the signatures endpoint.
|
|
4307
|
+
*/
|
|
4175
4308
|
getExecutionStatus(params: ExecutionStatusQuery): Promise<ExecutionStatusResponse>;
|
|
4176
4309
|
/** Unified user activity feed (trades, deposits, withdrawals, bridges, wallet ops). */
|
|
4177
4310
|
getUserActivity(params?: UserActivityQuery): Promise<PaginatedResponse<UserActivityItem>>;
|
|
@@ -4238,6 +4371,13 @@ declare class AggClient {
|
|
|
4238
4371
|
/** Get a single venue event by ID. Requires appId or admin auth. */
|
|
4239
4372
|
getVenueEventById(id: string, options?: {
|
|
4240
4373
|
signal?: AbortSignal;
|
|
4374
|
+
/**
|
|
4375
|
+
* Scope `marketCount` and the rolled-up `volume` to the whole matched
|
|
4376
|
+
* cluster (default, `true`) or to this one venue event (`false`). Pair it
|
|
4377
|
+
* with the same value on {@link getVenueMarkets} so the count matches the
|
|
4378
|
+
* market list you render.
|
|
4379
|
+
*/
|
|
4380
|
+
cluster?: boolean;
|
|
4241
4381
|
}): Promise<VenueEvent>;
|
|
4242
4382
|
/** Get normalized live score state for sports events. Requires appId or admin auth. */
|
|
4243
4383
|
getSportsLive(eventIds: string[], options?: {
|
|
@@ -4253,6 +4393,13 @@ declare class AggClient {
|
|
|
4253
4393
|
getVenueMarkets(options?: {
|
|
4254
4394
|
venue?: Venue;
|
|
4255
4395
|
venueEventId?: string;
|
|
4396
|
+
/**
|
|
4397
|
+
* Scope `venueEventId` to the whole matched cluster (default, `true`) or to
|
|
4398
|
+
* that one venue event (`false`). Under the default, naming any member of a
|
|
4399
|
+
* cluster returns every venue's markets for that real-world event with
|
|
4400
|
+
* matched siblings folded into their anchor. Ignored without `venueEventId`.
|
|
4401
|
+
*/
|
|
4402
|
+
cluster?: boolean;
|
|
4256
4403
|
search?: string;
|
|
4257
4404
|
matchStatus?: MatchStatus;
|
|
4258
4405
|
status?: MarketStatus;
|
|
@@ -4405,6 +4552,27 @@ declare class AggClient {
|
|
|
4405
4552
|
}): AggWebSocket;
|
|
4406
4553
|
/** Execute a previously quoted managed trade. Returns pending order IDs. */
|
|
4407
4554
|
executeManaged(params: ExecuteManagedParams): Promise<ExecuteManagedResponse>;
|
|
4555
|
+
/** Submit signatures for a parked fill. Returns whatever is still outstanding. */
|
|
4556
|
+
submitFillSignatures(quoteId: string, signatures: Array<{
|
|
4557
|
+
stepId: string;
|
|
4558
|
+
signature?: string;
|
|
4559
|
+
txHash?: string;
|
|
4560
|
+
}>): Promise<ExecuteManagedResponse & {
|
|
4561
|
+
accepted?: number;
|
|
4562
|
+
}>;
|
|
4563
|
+
/**
|
|
4564
|
+
* Execute a quote in self-custodial mode.
|
|
4565
|
+
*
|
|
4566
|
+
* Identical to `executeManaged` when the server can sign for the user. When
|
|
4567
|
+
* it cannot, the DAG parks on a signature request instead — but that park
|
|
4568
|
+
* always happens asynchronously, in the trade-executor process, so it can
|
|
4569
|
+
* never show up on this `POST /execution/fill` response itself. This
|
|
4570
|
+
* drives the round trip from there: poll `getExecutionStatus` while an
|
|
4571
|
+
* on-chain step is in flight, sign whatever it hands back with the
|
|
4572
|
+
* configured `signer`, post the signatures back, and repeat until the
|
|
4573
|
+
* server reports nothing outstanding and the run reaches a terminal state.
|
|
4574
|
+
*/
|
|
4575
|
+
fillSelfCustody(params: ExecuteManagedParams): Promise<ExecuteManagedResponse>;
|
|
4408
4576
|
/** Place a managed limit order. Returns the venue-backed order state. */
|
|
4409
4577
|
placeLimitOrder(params: PlaceLimitOrderParams): Promise<PlaceLimitOrderResponse>;
|
|
4410
4578
|
/**
|
|
@@ -4581,4 +4749,4 @@ declare function aggregateMidpoint(midpoints: (number | null | undefined)[]): nu
|
|
|
4581
4749
|
|
|
4582
4750
|
declare function createAggClient(options: AggClientOptions): AggClient;
|
|
4583
4751
|
|
|
4584
|
-
export { ACTIVE_VENUES, type Account, AccountProvider, AccountType, AggApiError, type AggApiErrorInit, type AggApiFieldError, type AggAuthDeliveryMode, type AggAuthProviderType, type AggAuthStartBody, type AggAuthStartResult, type AggAuthVerifyBody, AggClient, type AggClientAuthOptions, type AggClientSessionInput, type AggLinkAccountBody, type AggLinkAccountConfirmResult, type AggLinkAccountResult, type AggLinkAccountWalletConfirmBody, 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 BalanceRefillAttempt, type BalanceRefillAttemptStatus, type BalanceRefillPolicy, type BalanceRefillPolicyStatus, type BatchMidpointsResponse, type BatchOrderbooksResponse, type BookQuality, 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 CreateBalanceRefillPolicyParams, type CreatePaperTradingAccountParams, type CryptoReferencePriceError, type CryptoReferencePriceExternalMarketInput, type CryptoReferencePriceMarketInput, type CryptoReferencePriceResult, type CryptoReferencePriceSource, type CryptoReferencePriceTarget, type CryptoReferencePricesResponse, DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW, DEFAULT_BALANCE_REFILL_MAX_FEE_RAW, 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 ExecutionDagProgress, type ExecutionDisplayGroupStatus, type ExecutionDisplayStepKind, type ExecutionMode, type ExecutionOrderItem, type ExecutionOrdersQuery, type ExecutionOverallState, type ExecutionPositionGroup, type ExecutionPositionsQuery, type ExecutionStatusOrder, type ExecutionStatusQuery, type ExecutionStatusResponse, type ExecutionStatusStep, type GetBalanceQuery, type GetBalanceResponse, type GetCryptoReferencePricesOptions, type GetHoldingsQuery, type GetHoldingsResponse, type GetOrdersParams, type GetOrdersQuery, type GetPositionsParams, type GetPositionsQuery, type HelloResponse, IMAGE_SIZES, INACTIVE_VENUES, ImageSize, LIMIT_PRICE_RAW_SCALE, type LimitOrderTimeInForce, type LimitPriceSide, type LimitPriceTickAdjustment, type ListRecurringCryptoMarketsOptions, type ManagedBalancesParams, type MarkSource, type MarketPriceHistory, MarketStatus, MatchStatus, MatchType, type MatchedMidpoint, type MatchedMidpointOutcome, type MatchedOrderbookMarket, type MatchedVenueMarketOutcomeRef, type MidpointItem, type MidpointRow, type NewsFeedArticleFeedItem, type NewsFeedArticleFeedResponse, type NewsFeedArticleWithSummary, type NewsFeedLinkedMarket, type NewsFeedListResponse, type NewsFeedMarketFeedArticle, type NewsFeedMarketFeedItem, type NewsFeedMarketFeedResponse, type NewsFeedMarketNewsParams, type NewsFeedMarketNewsResponse, type NewsFeedMarketNewsResult, type NewsFeedPageOptions, type NewsFeedStatusResponse, type NonceResponse, type OrderListItem, type OrderListQuery, OrderStatus, OrderType, 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 PaperTradingAccount, type PaperTradingAccountsPage, type PaperTradingAppOptions, type PaperTradingBalanceAdjustment, type PaperTradingBalanceResponse, type PaperTradingLiquidityStatus, type PaperTradingListParams, type PaperTradingMarkSource, type PaperTradingOrder, type PaperTradingOrdersPage, type PaperTradingPortfolio, type PaperTradingPosition, type PaperTradingPositionsPage, type PersistedAuthSnapshot, type PlaceLimitOrderParams, type PlaceLimitOrderResponse, type PlacePaperTradingOrderParams, type PositionGroup, type PositionRedeemStatus, type PricePoint, type PriceSource, type PricesHistoryResponse, type QuoteError, type QuoteErrorCode, RECURRENCE_CADENCES, type RampQuote, type RampQuoteRequest, type RampSessionRequest, type RampWidgetSession, type RecurrenceCadence, type RecurrenceFilter, type RecurringCryptoComparisonPoint, type RecurringCryptoComparisonPriceSource, type RecurringCryptoDuration, type RecurringCryptoDurationInput, type RecurringCryptoMarketMetrics, type RecurringCryptoMarketsResponse, type RecurringCryptoOrderbookDepthLevel, type RecurringCryptoOrderbookDepthSide, type RecurringCryptoOutcome, type RecurringCryptoOutcomeOrderbookDepth, type RecurringCryptoPriceComparison, type RecurringCryptoReferencePrice, type RecurringCryptoResolution, type RecurringCryptoSourceConfidence, type RecurringCryptoVenueMarket, type RecurringCryptoWindowComparisons, type RecurringCryptoWindowMarket, type RedeemLegResult, type RedeemLegStatus, type RedeemRequest, type RedeemResponse, type RequestedOrderbookMarket, type ResetPaperTradingAccountParams, type ResolveCorrelatedMarketsParams, type ResolveCorrelatedMarketsResponse, type ResolvedCorrelatedMarketsResponse, type RpcTokenResponse, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, type ServerWallet, type SetPaperTradingBalanceParams, type SettlementDiff, type SettlementDifference, type SettlementSource, type SetupDepositAddressStep, type SetupVenueKeyStep, type SimpleOrderbookLevel, type SmartRouteAllocation, type SmartRouteBridgeStep, type SmartRouteFeeBreakdown, type SmartRouteFill, type SmartRouteParams, type SmartRouteResponse, type SmartRouteSettlementLeg, type SmartRouteSettlementPlan, type SmartRouteSetupCostLine, type SmartRouteSide, type SmartRouteStatus, type SmartRouteVenueFill, type SplitsByAmountResult, type SportsGameStatus, type SportsLiveParticipant, type SportsLiveResponse, type SportsLiveState, type SyncBalancesResponse, TimeInForce, type TradeExecutorOrder, type TradeExecutorOrderListResponse, TradeSide$1 as TradeSide, type TradeSplit, type TradeStep, TurnstileChallengeError, type UnifiedBalanceResponse, type UpdateBalanceRefillPolicyParams, 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, VENUE_CHAIN_IDS, type ValidateBalanceOnClientStep, type ValidateManagedParams, type ValidateManagedRequest, type ValidateManagedResponse, type ValidateTradeRequest, type ValidateTradeResponse, Venue, type VenueEvent, type VenueEventListItem, type VenueEventWithMarkets, type VenueGeoPolicyEntry, type VenueGeoPolicyResponse, type VenueKeyStatus, 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 WithdrawPreviewParams, type WithdrawPreviewResponse, type WithdrawTokenSymbol, type WithdrawalExpected, type WithdrawalLeg, type WithdrawalLegStatus, type WithdrawalLegType, type WithdrawalLifecycleStatus, type WithdrawalQuoteParams, type WithdrawalQuoteResponse, 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, adjustLimitPriceRawToTick, aggregateMidpoint, applyOrderbookDelta, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getBalanceRefillMaximumRaw, getEffectiveDisabledVenues, getWalletAddressFromUserProfile, hasShape, isAggApiError, isBalanceRefillWithinDailyCap, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, isVenueActive, isVenueDataVisible, isVenueInactive, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, parse, parseEmail, parseEmailStrict, safeParse, snapshotToOrderbook, sortVenues };
|
|
4752
|
+
export { ACTIVE_VENUES, type Account, AccountProvider, AccountType, AggApiError, type AggApiErrorInit, type AggApiFieldError, type AggAuthDeliveryMode, type AggAuthProviderType, type AggAuthStartBody, type AggAuthStartResult, type AggAuthVerifyBody, AggClient, type AggClientAuthOptions, type AggClientOptions, type AggClientSessionInput, type AggLinkAccountBody, type AggLinkAccountConfirmResult, type AggLinkAccountResult, type AggLinkAccountWalletConfirmBody, 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 BalanceRefillAttempt, type BalanceRefillAttemptStatus, type BalanceRefillPolicy, type BalanceRefillPolicyStatus, type BatchMidpointsResponse, type BatchOrderbooksResponse, type BookQuality, 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 CreateBalanceRefillPolicyParams, type CreatePaperTradingAccountParams, type CryptoReferencePriceError, type CryptoReferencePriceExternalMarketInput, type CryptoReferencePriceMarketInput, type CryptoReferencePriceResult, type CryptoReferencePriceSource, type CryptoReferencePriceTarget, type CryptoReferencePricesResponse, DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW, DEFAULT_BALANCE_REFILL_MAX_FEE_RAW, 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 ExecutionDagProgress, type ExecutionDisplayGroupStatus, type ExecutionDisplayStepKind, type ExecutionMode, type ExecutionOrderItem, type ExecutionOrdersQuery, type ExecutionOverallState, type ExecutionPositionGroup, type ExecutionPositionsQuery, type ExecutionStatusOrder, type ExecutionStatusQuery, type ExecutionStatusResponse, type ExecutionStatusStep, type GetBalanceQuery, type GetBalanceResponse, type GetCryptoReferencePricesOptions, type GetHoldingsQuery, type GetHoldingsResponse, type GetOrdersParams, type GetOrdersQuery, type GetPositionsParams, type GetPositionsQuery, type HelloResponse, IMAGE_SIZES, INACTIVE_VENUES, ImageSize, LIMIT_PRICE_RAW_SCALE, type LimitOrderTimeInForce, type LimitPriceSide, type LimitPriceTickAdjustment, type ListRecurringCryptoMarketsOptions, type ManagedBalancesParams, type MarkSource, type MarketPriceHistory, MarketStatus, MatchStatus, MatchType, type MatchedMidpoint, type MatchedMidpointOutcome, type MatchedOrderbookMarket, type MatchedVenueMarketOutcomeRef, type MidpointItem, type MidpointRow, type NewsFeedArticleFeedItem, type NewsFeedArticleFeedResponse, type NewsFeedArticleWithSummary, type NewsFeedLinkedMarket, type NewsFeedListResponse, type NewsFeedMarketFeedArticle, type NewsFeedMarketFeedItem, type NewsFeedMarketFeedResponse, type NewsFeedMarketNewsParams, type NewsFeedMarketNewsResponse, type NewsFeedMarketNewsResult, type NewsFeedPageOptions, type NewsFeedStatusResponse, type NonceResponse, type OrderListItem, type OrderListQuery, OrderStatus, OrderType, 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 PaperTradingAccount, type PaperTradingAccountsPage, type PaperTradingAppOptions, type PaperTradingBalanceAdjustment, type PaperTradingBalanceResponse, type PaperTradingLiquidityStatus, type PaperTradingListParams, type PaperTradingMarkSource, type PaperTradingOrder, type PaperTradingOrdersPage, type PaperTradingPortfolio, type PaperTradingPosition, type PaperTradingPositionsPage, type PersistedAuthSnapshot, type PlaceLimitOrderParams, type PlaceLimitOrderResponse, type PlacePaperTradingOrderParams, type PositionGroup, type PositionRedeemStatus, type PricePoint, type PriceSource, type PricesHistoryResponse, type QuoteError, type QuoteErrorCode, RECURRENCE_CADENCES, type RampQuote, type RampQuoteRequest, type RampSessionRequest, type RampWidgetSession, type RecurrenceCadence, type RecurrenceFilter, type RecurringCryptoComparisonPoint, type RecurringCryptoComparisonPriceSource, type RecurringCryptoDuration, type RecurringCryptoDurationInput, type RecurringCryptoMarketMetrics, type RecurringCryptoMarketsResponse, type RecurringCryptoOrderbookDepthLevel, type RecurringCryptoOrderbookDepthSide, type RecurringCryptoOutcome, type RecurringCryptoOutcomeOrderbookDepth, type RecurringCryptoPriceComparison, type RecurringCryptoReferencePrice, type RecurringCryptoResolution, type RecurringCryptoSourceConfidence, type RecurringCryptoVenueMarket, type RecurringCryptoWindowComparisons, type RecurringCryptoWindowMarket, type RedeemLegResult, type RedeemLegStatus, type RedeemRequest, type RedeemResponse, type RequestedOrderbookMarket, type ResetPaperTradingAccountParams, type ResolveCorrelatedMarketsParams, type ResolveCorrelatedMarketsResponse, type ResolvedCorrelatedMarketsResponse, type RpcTokenResponse, SELF_CUSTODY_FILL_TIMEOUT_MS, SELF_CUSTODY_POLL_INTERVAL_MS, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, type ServerWallet, type SetPaperTradingBalanceParams, type SettlementDiff, type SettlementDifference, type SettlementSource, type SetupDepositAddressStep, type SetupVenueKeyStep, type SignatureRequest, type SignatureRequestType, type SignerFn, type SimpleOrderbookLevel, type SmartRouteAllocation, type SmartRouteBridgeStep, type SmartRouteFeeBreakdown, type SmartRouteFill, type SmartRouteParams, type SmartRouteResponse, type SmartRouteSettlementLeg, type SmartRouteSettlementPlan, type SmartRouteSetupCostLine, type SmartRouteSide, type SmartRouteStatus, type SmartRouteVenueFill, type SplitsByAmountResult, type SportsGameStatus, type SportsLiveParticipant, type SportsLiveResponse, type SportsLiveState, type SyncBalancesResponse, TERMINAL_EXECUTION_STATES, TimeInForce, type TradeExecutorOrder, type TradeExecutorOrderListResponse, TradeSide$1 as TradeSide, type TradeSplit, type TradeStep, TurnstileChallengeError, type UnifiedBalanceResponse, type UpdateBalanceRefillPolicyParams, 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, VENUE_CHAIN_IDS, type ValidateBalanceOnClientStep, type ValidateManagedParams, type ValidateManagedRequest, type ValidateManagedResponse, type ValidateTradeRequest, type ValidateTradeResponse, Venue, type VenueEvent, type VenueEventListItem, type VenueEventWithMarkets, type VenueGeoPolicyEntry, type VenueGeoPolicyResponse, type VenueKeyStatus, 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 WithdrawPreviewParams, type WithdrawPreviewResponse, type WithdrawTokenSymbol, type WithdrawalExpected, type WithdrawalLeg, type WithdrawalLegStatus, type WithdrawalLegType, type WithdrawalLifecycleStatus, type WithdrawalQuoteParams, type WithdrawalQuoteResponse, 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, adjustLimitPriceRawToTick, aggregateMidpoint, applyOrderbookDelta, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getBalanceRefillMaximumRaw, getEffectiveDisabledVenues, getWalletAddressFromUserProfile, hasShape, isAggApiError, isBalanceRefillWithinDailyCap, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, isVenueActive, isVenueDataVisible, isVenueInactive, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, parse, parseEmail, parseEmailStrict, safeParse, snapshotToOrderbook, sortVenues };
|
package/dist/index.d.ts
CHANGED
|
@@ -1226,11 +1226,11 @@ interface TSchema extends TKind, SchemaOptions {
|
|
|
1226
1226
|
* Always carry a human-readable `message` alongside; the code is additive and
|
|
1227
1227
|
* may be absent on rejections that pre-date this addition.
|
|
1228
1228
|
*/
|
|
1229
|
-
declare const QuoteErrorCodeTB: TUnion<[TLiteral<"quote_not_found">, TLiteral<"quote_expired">, TLiteral<"quote_already_executed">, TLiteral<"quote_cancelled">, TLiteral<"quote_user_mismatch">, TLiteral<"quote_app_blocked">, TLiteral<"quote_unfillable">, TLiteral<"quote_min_order_size">, TLiteral<"quote_stale_status">, TLiteral<"quote_stale_price">, TLiteral<"quote_insufficient_balance">, TLiteral<"quote_market_inactive">, TLiteral<"venue_not_executable">, TLiteral<"outcome_ambiguous">]>;
|
|
1229
|
+
declare const QuoteErrorCodeTB: TUnion<[TLiteral<"quote_not_found">, TLiteral<"quote_expired">, TLiteral<"quote_already_executed">, TLiteral<"quote_cancelled">, TLiteral<"quote_user_mismatch">, TLiteral<"quote_app_blocked">, TLiteral<"quote_unfillable">, TLiteral<"quote_min_order_size">, TLiteral<"quote_stale_status">, TLiteral<"quote_stale_price">, TLiteral<"quote_insufficient_balance">, TLiteral<"quote_market_inactive">, TLiteral<"quote_self_custody_unsupported_venue">, TLiteral<"quote_self_custody_app_fee">, TLiteral<"quote_self_custody_redeem_unsupported">, TLiteral<"venue_not_executable">, TLiteral<"outcome_ambiguous">]>;
|
|
1230
1230
|
type QuoteErrorCode = Static<typeof QuoteErrorCodeTB>;
|
|
1231
1231
|
declare const QuoteErrorTB: TObject<{
|
|
1232
1232
|
message: TString;
|
|
1233
|
-
code: TOptional<TUnion<[TLiteral<"quote_not_found">, TLiteral<"quote_expired">, TLiteral<"quote_already_executed">, TLiteral<"quote_cancelled">, TLiteral<"quote_user_mismatch">, TLiteral<"quote_app_blocked">, TLiteral<"quote_unfillable">, TLiteral<"quote_min_order_size">, TLiteral<"quote_stale_status">, TLiteral<"quote_stale_price">, TLiteral<"quote_insufficient_balance">, TLiteral<"quote_market_inactive">, TLiteral<"venue_not_executable">, TLiteral<"outcome_ambiguous">]>>;
|
|
1233
|
+
code: TOptional<TUnion<[TLiteral<"quote_not_found">, TLiteral<"quote_expired">, TLiteral<"quote_already_executed">, TLiteral<"quote_cancelled">, TLiteral<"quote_user_mismatch">, TLiteral<"quote_app_blocked">, TLiteral<"quote_unfillable">, TLiteral<"quote_min_order_size">, TLiteral<"quote_stale_status">, TLiteral<"quote_stale_price">, TLiteral<"quote_insufficient_balance">, TLiteral<"quote_market_inactive">, TLiteral<"quote_self_custody_unsupported_venue">, TLiteral<"quote_self_custody_app_fee">, TLiteral<"quote_self_custody_redeem_unsupported">, TLiteral<"venue_not_executable">, TLiteral<"outcome_ambiguous">]>>;
|
|
1234
1234
|
}>;
|
|
1235
1235
|
type QuoteError = Static<typeof QuoteErrorTB>;
|
|
1236
1236
|
|
|
@@ -2164,6 +2164,82 @@ interface PersistedAuthSnapshot {
|
|
|
2164
2164
|
}
|
|
2165
2165
|
/** Auth lifecycle status for UI state machines. */
|
|
2166
2166
|
type AuthStatus = "unknown" | "authenticated" | "unauthenticated";
|
|
2167
|
+
type SignatureRequestType = "eip712" | "personal_sign"
|
|
2168
|
+
/** EVM transaction — bridge legs and approvals. secp256k1. */
|
|
2169
|
+
| "transaction"
|
|
2170
|
+
/** Solana transaction — bridge legs on SVM. ed25519, NOT secp256k1. */
|
|
2171
|
+
| "solana_transaction" | "hl_l1_action"
|
|
2172
|
+
/**
|
|
2173
|
+
* EIP-7702 authorization over `{ contractAddress, chainId, nonce }`.
|
|
2174
|
+
*
|
|
2175
|
+
* A signature over a RAW digest — `keccak(0x05 ‖ rlp([chainId, delegate,
|
|
2176
|
+
* nonce]))` — not EIP-191 and not EIP-712. Many wallets do not expose this,
|
|
2177
|
+
* and that is expected: reject it and the server falls back to asking the
|
|
2178
|
+
* user to broadcast a plain approve instead.
|
|
2179
|
+
*/
|
|
2180
|
+
| "eip7702_authorization";
|
|
2181
|
+
/** One payload the client must sign before a fill can proceed. */
|
|
2182
|
+
interface SignatureRequest {
|
|
2183
|
+
/** Echo this back with the signature. */
|
|
2184
|
+
stepId: string;
|
|
2185
|
+
/** Payload shape. Discriminates how to sign — not which venue. */
|
|
2186
|
+
type: SignatureRequestType;
|
|
2187
|
+
venue: string;
|
|
2188
|
+
/** The address that must produce this signature. Sign with this key, not another. */
|
|
2189
|
+
signerAddress: string;
|
|
2190
|
+
/** Absent for non-EVM payloads (e.g. Hyperliquid L1 actions). */
|
|
2191
|
+
chainId?: number;
|
|
2192
|
+
/** Sign verbatim. */
|
|
2193
|
+
payload: unknown;
|
|
2194
|
+
expiresAt: string;
|
|
2195
|
+
}
|
|
2196
|
+
/**
|
|
2197
|
+
* Supplied by the partner. Receives a payload, returns a signature. The SDK
|
|
2198
|
+
* never sees the key.
|
|
2199
|
+
*
|
|
2200
|
+
* Return a 0x-prefixed hex string for anything the wallet SIGNS:
|
|
2201
|
+
*
|
|
2202
|
+
* - `eip712` — `signTypedData` over `payload`.
|
|
2203
|
+
* - `personal_sign` — `personal_sign` over `payload`.
|
|
2204
|
+
* - `hl_l1_action` — Hyperliquid L1 action, EIP-712 in phantom-agent form.
|
|
2205
|
+
* - `eip7702_authorization` — an EIP-7702 authorization over
|
|
2206
|
+
* `{ contractAddress, chainId, nonce }`. This is a signature over a RAW
|
|
2207
|
+
* digest, not EIP-191 and not EIP-712, and many wallets do not expose it.
|
|
2208
|
+
* **Throwing here does not help**: there is no reject verb, so a thrown
|
|
2209
|
+
* signer is indistinguishable from a slow user — the request simply expires
|
|
2210
|
+
* and the fill dies. If your wallet cannot produce this signature, declare
|
|
2211
|
+
* `approveMode: "user_broadcast"` on the fill instead and the approve is
|
|
2212
|
+
* requested as a `transaction` the user sends themselves. Handling this
|
|
2213
|
+
* request is what makes funding gasless.
|
|
2214
|
+
*
|
|
2215
|
+
* Return `{ txHash }` for anything the wallet BROADCASTS:
|
|
2216
|
+
*
|
|
2217
|
+
* - `transaction` — send it, then return the hash **immediately, without
|
|
2218
|
+
* awaiting the receipt**. The server watches for the mined receipt itself
|
|
2219
|
+
* and will not resume until it matches the request byte-for-byte.
|
|
2220
|
+
*/
|
|
2221
|
+
type SignerFn = (req: SignatureRequest) => Promise<string | {
|
|
2222
|
+
txHash: string;
|
|
2223
|
+
}>;
|
|
2224
|
+
/**
|
|
2225
|
+
* How long `fillSelfCustody` will keep waiting before giving up.
|
|
2226
|
+
*
|
|
2227
|
+
* Covers a first-time user: sign the wallet-setup batch, wait for it on-chain,
|
|
2228
|
+
* then sign the order. Generous because the wait is a relayer transaction
|
|
2229
|
+
* confirming, not a human deciding.
|
|
2230
|
+
*/
|
|
2231
|
+
declare const SELF_CUSTODY_FILL_TIMEOUT_MS: number;
|
|
2232
|
+
/** Gap between re-reads while an on-chain step is in flight. */
|
|
2233
|
+
declare const SELF_CUSTODY_POLL_INTERVAL_MS = 2000;
|
|
2234
|
+
/**
|
|
2235
|
+
* States a run never leaves. Everything else means "still working".
|
|
2236
|
+
*
|
|
2237
|
+
* Typed against `ExecutionOverallState` so a typo'd or renamed literal (e.g.
|
|
2238
|
+
* `cancelled` drifting to `canceled`) is a compile error instead of a state
|
|
2239
|
+
* that silently stops being treated as terminal. Mirrors
|
|
2240
|
+
* `ExecutionOverallStateTB` in the contract; keep the two in step.
|
|
2241
|
+
*/
|
|
2242
|
+
declare const TERMINAL_EXECUTION_STATES: ReadonlySet<ExecutionOverallState>;
|
|
2167
2243
|
type SportsGameStatus = "scheduled" | "live" | "paused" | "finished" | "cancelled" | "postponed" | "unknown";
|
|
2168
2244
|
interface SportsLiveParticipant {
|
|
2169
2245
|
position: "first" | "second";
|
|
@@ -2213,6 +2289,17 @@ interface AggClientOptions {
|
|
|
2213
2289
|
* When authDelivery is "cookie-refresh", refresh tokens survive via HttpOnly cookies
|
|
2214
2290
|
* and the SDK attempts a silent refresh on cold start. Defaults to true. */
|
|
2215
2291
|
persistSession?: boolean;
|
|
2292
|
+
/**
|
|
2293
|
+
* Supplies signatures for self-custodial fills. Required whenever
|
|
2294
|
+
* `fillSelfCustody()` is called with `signingAddress` — the SDK never
|
|
2295
|
+
* holds a key itself, so without this option a fill that needs a
|
|
2296
|
+
* client-side signature cannot proceed. The signature requests never
|
|
2297
|
+
* come back on `POST /execution/fill` itself: `fillSelfCustody()` polls
|
|
2298
|
+
* `GET /execution/status` for them (`pendingSignatures`), signs each one
|
|
2299
|
+
* with this function, and posts the result to
|
|
2300
|
+
* `POST /execution/fill/:quoteId/signatures`.
|
|
2301
|
+
*/
|
|
2302
|
+
signer?: SignerFn;
|
|
2216
2303
|
}
|
|
2217
2304
|
interface SiweMessageParams {
|
|
2218
2305
|
domain: string;
|
|
@@ -2791,6 +2878,25 @@ interface ExecuteManagedParams {
|
|
|
2791
2878
|
sellShares?: number;
|
|
2792
2879
|
allowedVenues?: Venue[];
|
|
2793
2880
|
};
|
|
2881
|
+
/**
|
|
2882
|
+
* Self-custody: the wallet that will sign this fill. Must be a wallet
|
|
2883
|
+
* already linked to this account. Omit for managed custody (the default).
|
|
2884
|
+
*/
|
|
2885
|
+
signingAddress?: string;
|
|
2886
|
+
/**
|
|
2887
|
+
* Self-custody only: which approve shape a cross-chain fill uses when the
|
|
2888
|
+
* bridge needs an ERC20 approve. Omit (the default) for "sponsored" — we pay
|
|
2889
|
+
* the gas, but the wallet must sign a one-time EIP-7702 authorization over a
|
|
2890
|
+
* RAW DIGEST, which many wallets cannot produce. Send "user_broadcast" when
|
|
2891
|
+
* yours cannot: the user sends the approve and pays their own gas. Only your
|
|
2892
|
+
* client can know which applies — it is a property of the wallet software,
|
|
2893
|
+
* not of the address or the chain.
|
|
2894
|
+
*
|
|
2895
|
+
* Worth surfacing in your UI: "user_broadcast" never establishes the
|
|
2896
|
+
* delegation, so it charges gas on EVERY bridge. "sponsored" costs one
|
|
2897
|
+
* signature once per chain, then is free.
|
|
2898
|
+
*/
|
|
2899
|
+
approveMode?: "sponsored" | "user_broadcast";
|
|
2794
2900
|
}
|
|
2795
2901
|
interface ExecuteManagedResponse {
|
|
2796
2902
|
quoteId: string;
|
|
@@ -2798,6 +2904,17 @@ interface ExecuteManagedResponse {
|
|
|
2798
2904
|
status: "pending";
|
|
2799
2905
|
redeemId?: string;
|
|
2800
2906
|
message?: string;
|
|
2907
|
+
/**
|
|
2908
|
+
* What this fill is waiting to be signed, if anything. On the immediate
|
|
2909
|
+
* `POST /execution/fill` response this is always absent or empty — even
|
|
2910
|
+
* for a self-custody fill, the DAG parks asynchronously, after this
|
|
2911
|
+
* response has already been sent. Real entries only ever come back from
|
|
2912
|
+
* polling `GET /execution/status` or from the next
|
|
2913
|
+
* `POST /execution/fill/:quoteId/signatures` response (this same shape,
|
|
2914
|
+
* reused). Drive the whole round trip through `fillSelfCustody()` rather
|
|
2915
|
+
* than reading this field on the fill response by hand.
|
|
2916
|
+
*/
|
|
2917
|
+
pendingSignatures?: SignatureRequest[];
|
|
2801
2918
|
}
|
|
2802
2919
|
type LimitOrderTimeInForce = "GTC" | "GTD" | "FOK" | "FAK" | "IOC" | "ALO";
|
|
2803
2920
|
interface PlaceLimitOrderParams {
|
|
@@ -3162,6 +3279,14 @@ interface ExecutionStatusResponse {
|
|
|
3162
3279
|
dagProgress: ExecutionDagProgress | null;
|
|
3163
3280
|
steps: ExecutionStatusStep[];
|
|
3164
3281
|
orders: ExecutionStatusOrder[];
|
|
3282
|
+
/**
|
|
3283
|
+
* What this run is waiting to be signed, mirroring the fill response's
|
|
3284
|
+
* field of the same name. This is the polling route `fillSelfCustody` reads
|
|
3285
|
+
* while an on-chain step is in flight — a caller polling this route for
|
|
3286
|
+
* progress learns about newly-parked steps here too, not just from the
|
|
3287
|
+
* signatures endpoint.
|
|
3288
|
+
*/
|
|
3289
|
+
pendingSignatures?: SignatureRequest[];
|
|
3165
3290
|
}
|
|
3166
3291
|
type ExecutionPositionsQuery = GetPositionsQuery & {
|
|
3167
3292
|
mode?: ExecutionMode;
|
|
@@ -4038,6 +4163,8 @@ declare class AggClient {
|
|
|
4038
4163
|
private authOptions?;
|
|
4039
4164
|
/** In-flight refresh promise — serializes concurrent 401 retries so only one refresh runs. */
|
|
4040
4165
|
private pendingRefresh;
|
|
4166
|
+
/** Partner-supplied signature callback for self-custodial fills. The SDK never sees a key. */
|
|
4167
|
+
private readonly signer?;
|
|
4041
4168
|
constructor(options: AggClientOptions);
|
|
4042
4169
|
private resolvePaperTradingAppId;
|
|
4043
4170
|
private paperTradingAccountsPath;
|
|
@@ -4171,7 +4298,13 @@ declare class AggClient {
|
|
|
4171
4298
|
* rollup (total cost, share-weighted avg price, to-win).
|
|
4172
4299
|
*/
|
|
4173
4300
|
getExecutionOrders(params?: ExecutionOrdersQuery): Promise<PaginatedResponse<ExecutionOrderItem>>;
|
|
4174
|
-
/**
|
|
4301
|
+
/**
|
|
4302
|
+
* Get quote-scoped execution progress, DAG step state, and order leg
|
|
4303
|
+
* terminal status. Also carries `pendingSignatures` — this is the route
|
|
4304
|
+
* `fillSelfCustody` polls while an on-chain step is in flight, so a caller
|
|
4305
|
+
* already polling this for progress learns about newly-parked steps here
|
|
4306
|
+
* too, not just from the signatures endpoint.
|
|
4307
|
+
*/
|
|
4175
4308
|
getExecutionStatus(params: ExecutionStatusQuery): Promise<ExecutionStatusResponse>;
|
|
4176
4309
|
/** Unified user activity feed (trades, deposits, withdrawals, bridges, wallet ops). */
|
|
4177
4310
|
getUserActivity(params?: UserActivityQuery): Promise<PaginatedResponse<UserActivityItem>>;
|
|
@@ -4238,6 +4371,13 @@ declare class AggClient {
|
|
|
4238
4371
|
/** Get a single venue event by ID. Requires appId or admin auth. */
|
|
4239
4372
|
getVenueEventById(id: string, options?: {
|
|
4240
4373
|
signal?: AbortSignal;
|
|
4374
|
+
/**
|
|
4375
|
+
* Scope `marketCount` and the rolled-up `volume` to the whole matched
|
|
4376
|
+
* cluster (default, `true`) or to this one venue event (`false`). Pair it
|
|
4377
|
+
* with the same value on {@link getVenueMarkets} so the count matches the
|
|
4378
|
+
* market list you render.
|
|
4379
|
+
*/
|
|
4380
|
+
cluster?: boolean;
|
|
4241
4381
|
}): Promise<VenueEvent>;
|
|
4242
4382
|
/** Get normalized live score state for sports events. Requires appId or admin auth. */
|
|
4243
4383
|
getSportsLive(eventIds: string[], options?: {
|
|
@@ -4253,6 +4393,13 @@ declare class AggClient {
|
|
|
4253
4393
|
getVenueMarkets(options?: {
|
|
4254
4394
|
venue?: Venue;
|
|
4255
4395
|
venueEventId?: string;
|
|
4396
|
+
/**
|
|
4397
|
+
* Scope `venueEventId` to the whole matched cluster (default, `true`) or to
|
|
4398
|
+
* that one venue event (`false`). Under the default, naming any member of a
|
|
4399
|
+
* cluster returns every venue's markets for that real-world event with
|
|
4400
|
+
* matched siblings folded into their anchor. Ignored without `venueEventId`.
|
|
4401
|
+
*/
|
|
4402
|
+
cluster?: boolean;
|
|
4256
4403
|
search?: string;
|
|
4257
4404
|
matchStatus?: MatchStatus;
|
|
4258
4405
|
status?: MarketStatus;
|
|
@@ -4405,6 +4552,27 @@ declare class AggClient {
|
|
|
4405
4552
|
}): AggWebSocket;
|
|
4406
4553
|
/** Execute a previously quoted managed trade. Returns pending order IDs. */
|
|
4407
4554
|
executeManaged(params: ExecuteManagedParams): Promise<ExecuteManagedResponse>;
|
|
4555
|
+
/** Submit signatures for a parked fill. Returns whatever is still outstanding. */
|
|
4556
|
+
submitFillSignatures(quoteId: string, signatures: Array<{
|
|
4557
|
+
stepId: string;
|
|
4558
|
+
signature?: string;
|
|
4559
|
+
txHash?: string;
|
|
4560
|
+
}>): Promise<ExecuteManagedResponse & {
|
|
4561
|
+
accepted?: number;
|
|
4562
|
+
}>;
|
|
4563
|
+
/**
|
|
4564
|
+
* Execute a quote in self-custodial mode.
|
|
4565
|
+
*
|
|
4566
|
+
* Identical to `executeManaged` when the server can sign for the user. When
|
|
4567
|
+
* it cannot, the DAG parks on a signature request instead — but that park
|
|
4568
|
+
* always happens asynchronously, in the trade-executor process, so it can
|
|
4569
|
+
* never show up on this `POST /execution/fill` response itself. This
|
|
4570
|
+
* drives the round trip from there: poll `getExecutionStatus` while an
|
|
4571
|
+
* on-chain step is in flight, sign whatever it hands back with the
|
|
4572
|
+
* configured `signer`, post the signatures back, and repeat until the
|
|
4573
|
+
* server reports nothing outstanding and the run reaches a terminal state.
|
|
4574
|
+
*/
|
|
4575
|
+
fillSelfCustody(params: ExecuteManagedParams): Promise<ExecuteManagedResponse>;
|
|
4408
4576
|
/** Place a managed limit order. Returns the venue-backed order state. */
|
|
4409
4577
|
placeLimitOrder(params: PlaceLimitOrderParams): Promise<PlaceLimitOrderResponse>;
|
|
4410
4578
|
/**
|
|
@@ -4581,4 +4749,4 @@ declare function aggregateMidpoint(midpoints: (number | null | undefined)[]): nu
|
|
|
4581
4749
|
|
|
4582
4750
|
declare function createAggClient(options: AggClientOptions): AggClient;
|
|
4583
4751
|
|
|
4584
|
-
export { ACTIVE_VENUES, type Account, AccountProvider, AccountType, AggApiError, type AggApiErrorInit, type AggApiFieldError, type AggAuthDeliveryMode, type AggAuthProviderType, type AggAuthStartBody, type AggAuthStartResult, type AggAuthVerifyBody, AggClient, type AggClientAuthOptions, type AggClientSessionInput, type AggLinkAccountBody, type AggLinkAccountConfirmResult, type AggLinkAccountResult, type AggLinkAccountWalletConfirmBody, 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 BalanceRefillAttempt, type BalanceRefillAttemptStatus, type BalanceRefillPolicy, type BalanceRefillPolicyStatus, type BatchMidpointsResponse, type BatchOrderbooksResponse, type BookQuality, 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 CreateBalanceRefillPolicyParams, type CreatePaperTradingAccountParams, type CryptoReferencePriceError, type CryptoReferencePriceExternalMarketInput, type CryptoReferencePriceMarketInput, type CryptoReferencePriceResult, type CryptoReferencePriceSource, type CryptoReferencePriceTarget, type CryptoReferencePricesResponse, DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW, DEFAULT_BALANCE_REFILL_MAX_FEE_RAW, 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 ExecutionDagProgress, type ExecutionDisplayGroupStatus, type ExecutionDisplayStepKind, type ExecutionMode, type ExecutionOrderItem, type ExecutionOrdersQuery, type ExecutionOverallState, type ExecutionPositionGroup, type ExecutionPositionsQuery, type ExecutionStatusOrder, type ExecutionStatusQuery, type ExecutionStatusResponse, type ExecutionStatusStep, type GetBalanceQuery, type GetBalanceResponse, type GetCryptoReferencePricesOptions, type GetHoldingsQuery, type GetHoldingsResponse, type GetOrdersParams, type GetOrdersQuery, type GetPositionsParams, type GetPositionsQuery, type HelloResponse, IMAGE_SIZES, INACTIVE_VENUES, ImageSize, LIMIT_PRICE_RAW_SCALE, type LimitOrderTimeInForce, type LimitPriceSide, type LimitPriceTickAdjustment, type ListRecurringCryptoMarketsOptions, type ManagedBalancesParams, type MarkSource, type MarketPriceHistory, MarketStatus, MatchStatus, MatchType, type MatchedMidpoint, type MatchedMidpointOutcome, type MatchedOrderbookMarket, type MatchedVenueMarketOutcomeRef, type MidpointItem, type MidpointRow, type NewsFeedArticleFeedItem, type NewsFeedArticleFeedResponse, type NewsFeedArticleWithSummary, type NewsFeedLinkedMarket, type NewsFeedListResponse, type NewsFeedMarketFeedArticle, type NewsFeedMarketFeedItem, type NewsFeedMarketFeedResponse, type NewsFeedMarketNewsParams, type NewsFeedMarketNewsResponse, type NewsFeedMarketNewsResult, type NewsFeedPageOptions, type NewsFeedStatusResponse, type NonceResponse, type OrderListItem, type OrderListQuery, OrderStatus, OrderType, 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 PaperTradingAccount, type PaperTradingAccountsPage, type PaperTradingAppOptions, type PaperTradingBalanceAdjustment, type PaperTradingBalanceResponse, type PaperTradingLiquidityStatus, type PaperTradingListParams, type PaperTradingMarkSource, type PaperTradingOrder, type PaperTradingOrdersPage, type PaperTradingPortfolio, type PaperTradingPosition, type PaperTradingPositionsPage, type PersistedAuthSnapshot, type PlaceLimitOrderParams, type PlaceLimitOrderResponse, type PlacePaperTradingOrderParams, type PositionGroup, type PositionRedeemStatus, type PricePoint, type PriceSource, type PricesHistoryResponse, type QuoteError, type QuoteErrorCode, RECURRENCE_CADENCES, type RampQuote, type RampQuoteRequest, type RampSessionRequest, type RampWidgetSession, type RecurrenceCadence, type RecurrenceFilter, type RecurringCryptoComparisonPoint, type RecurringCryptoComparisonPriceSource, type RecurringCryptoDuration, type RecurringCryptoDurationInput, type RecurringCryptoMarketMetrics, type RecurringCryptoMarketsResponse, type RecurringCryptoOrderbookDepthLevel, type RecurringCryptoOrderbookDepthSide, type RecurringCryptoOutcome, type RecurringCryptoOutcomeOrderbookDepth, type RecurringCryptoPriceComparison, type RecurringCryptoReferencePrice, type RecurringCryptoResolution, type RecurringCryptoSourceConfidence, type RecurringCryptoVenueMarket, type RecurringCryptoWindowComparisons, type RecurringCryptoWindowMarket, type RedeemLegResult, type RedeemLegStatus, type RedeemRequest, type RedeemResponse, type RequestedOrderbookMarket, type ResetPaperTradingAccountParams, type ResolveCorrelatedMarketsParams, type ResolveCorrelatedMarketsResponse, type ResolvedCorrelatedMarketsResponse, type RpcTokenResponse, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, type ServerWallet, type SetPaperTradingBalanceParams, type SettlementDiff, type SettlementDifference, type SettlementSource, type SetupDepositAddressStep, type SetupVenueKeyStep, type SimpleOrderbookLevel, type SmartRouteAllocation, type SmartRouteBridgeStep, type SmartRouteFeeBreakdown, type SmartRouteFill, type SmartRouteParams, type SmartRouteResponse, type SmartRouteSettlementLeg, type SmartRouteSettlementPlan, type SmartRouteSetupCostLine, type SmartRouteSide, type SmartRouteStatus, type SmartRouteVenueFill, type SplitsByAmountResult, type SportsGameStatus, type SportsLiveParticipant, type SportsLiveResponse, type SportsLiveState, type SyncBalancesResponse, TimeInForce, type TradeExecutorOrder, type TradeExecutorOrderListResponse, TradeSide$1 as TradeSide, type TradeSplit, type TradeStep, TurnstileChallengeError, type UnifiedBalanceResponse, type UpdateBalanceRefillPolicyParams, 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, VENUE_CHAIN_IDS, type ValidateBalanceOnClientStep, type ValidateManagedParams, type ValidateManagedRequest, type ValidateManagedResponse, type ValidateTradeRequest, type ValidateTradeResponse, Venue, type VenueEvent, type VenueEventListItem, type VenueEventWithMarkets, type VenueGeoPolicyEntry, type VenueGeoPolicyResponse, type VenueKeyStatus, 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 WithdrawPreviewParams, type WithdrawPreviewResponse, type WithdrawTokenSymbol, type WithdrawalExpected, type WithdrawalLeg, type WithdrawalLegStatus, type WithdrawalLegType, type WithdrawalLifecycleStatus, type WithdrawalQuoteParams, type WithdrawalQuoteResponse, 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, adjustLimitPriceRawToTick, aggregateMidpoint, applyOrderbookDelta, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getBalanceRefillMaximumRaw, getEffectiveDisabledVenues, getWalletAddressFromUserProfile, hasShape, isAggApiError, isBalanceRefillWithinDailyCap, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, isVenueActive, isVenueDataVisible, isVenueInactive, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, parse, parseEmail, parseEmailStrict, safeParse, snapshotToOrderbook, sortVenues };
|
|
4752
|
+
export { ACTIVE_VENUES, type Account, AccountProvider, AccountType, AggApiError, type AggApiErrorInit, type AggApiFieldError, type AggAuthDeliveryMode, type AggAuthProviderType, type AggAuthStartBody, type AggAuthStartResult, type AggAuthVerifyBody, AggClient, type AggClientAuthOptions, type AggClientOptions, type AggClientSessionInput, type AggLinkAccountBody, type AggLinkAccountConfirmResult, type AggLinkAccountResult, type AggLinkAccountWalletConfirmBody, 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 BalanceRefillAttempt, type BalanceRefillAttemptStatus, type BalanceRefillPolicy, type BalanceRefillPolicyStatus, type BatchMidpointsResponse, type BatchOrderbooksResponse, type BookQuality, 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 CreateBalanceRefillPolicyParams, type CreatePaperTradingAccountParams, type CryptoReferencePriceError, type CryptoReferencePriceExternalMarketInput, type CryptoReferencePriceMarketInput, type CryptoReferencePriceResult, type CryptoReferencePriceSource, type CryptoReferencePriceTarget, type CryptoReferencePricesResponse, DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW, DEFAULT_BALANCE_REFILL_MAX_FEE_RAW, 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 ExecutionDagProgress, type ExecutionDisplayGroupStatus, type ExecutionDisplayStepKind, type ExecutionMode, type ExecutionOrderItem, type ExecutionOrdersQuery, type ExecutionOverallState, type ExecutionPositionGroup, type ExecutionPositionsQuery, type ExecutionStatusOrder, type ExecutionStatusQuery, type ExecutionStatusResponse, type ExecutionStatusStep, type GetBalanceQuery, type GetBalanceResponse, type GetCryptoReferencePricesOptions, type GetHoldingsQuery, type GetHoldingsResponse, type GetOrdersParams, type GetOrdersQuery, type GetPositionsParams, type GetPositionsQuery, type HelloResponse, IMAGE_SIZES, INACTIVE_VENUES, ImageSize, LIMIT_PRICE_RAW_SCALE, type LimitOrderTimeInForce, type LimitPriceSide, type LimitPriceTickAdjustment, type ListRecurringCryptoMarketsOptions, type ManagedBalancesParams, type MarkSource, type MarketPriceHistory, MarketStatus, MatchStatus, MatchType, type MatchedMidpoint, type MatchedMidpointOutcome, type MatchedOrderbookMarket, type MatchedVenueMarketOutcomeRef, type MidpointItem, type MidpointRow, type NewsFeedArticleFeedItem, type NewsFeedArticleFeedResponse, type NewsFeedArticleWithSummary, type NewsFeedLinkedMarket, type NewsFeedListResponse, type NewsFeedMarketFeedArticle, type NewsFeedMarketFeedItem, type NewsFeedMarketFeedResponse, type NewsFeedMarketNewsParams, type NewsFeedMarketNewsResponse, type NewsFeedMarketNewsResult, type NewsFeedPageOptions, type NewsFeedStatusResponse, type NonceResponse, type OrderListItem, type OrderListQuery, OrderStatus, OrderType, 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 PaperTradingAccount, type PaperTradingAccountsPage, type PaperTradingAppOptions, type PaperTradingBalanceAdjustment, type PaperTradingBalanceResponse, type PaperTradingLiquidityStatus, type PaperTradingListParams, type PaperTradingMarkSource, type PaperTradingOrder, type PaperTradingOrdersPage, type PaperTradingPortfolio, type PaperTradingPosition, type PaperTradingPositionsPage, type PersistedAuthSnapshot, type PlaceLimitOrderParams, type PlaceLimitOrderResponse, type PlacePaperTradingOrderParams, type PositionGroup, type PositionRedeemStatus, type PricePoint, type PriceSource, type PricesHistoryResponse, type QuoteError, type QuoteErrorCode, RECURRENCE_CADENCES, type RampQuote, type RampQuoteRequest, type RampSessionRequest, type RampWidgetSession, type RecurrenceCadence, type RecurrenceFilter, type RecurringCryptoComparisonPoint, type RecurringCryptoComparisonPriceSource, type RecurringCryptoDuration, type RecurringCryptoDurationInput, type RecurringCryptoMarketMetrics, type RecurringCryptoMarketsResponse, type RecurringCryptoOrderbookDepthLevel, type RecurringCryptoOrderbookDepthSide, type RecurringCryptoOutcome, type RecurringCryptoOutcomeOrderbookDepth, type RecurringCryptoPriceComparison, type RecurringCryptoReferencePrice, type RecurringCryptoResolution, type RecurringCryptoSourceConfidence, type RecurringCryptoVenueMarket, type RecurringCryptoWindowComparisons, type RecurringCryptoWindowMarket, type RedeemLegResult, type RedeemLegStatus, type RedeemRequest, type RedeemResponse, type RequestedOrderbookMarket, type ResetPaperTradingAccountParams, type ResolveCorrelatedMarketsParams, type ResolveCorrelatedMarketsResponse, type ResolvedCorrelatedMarketsResponse, type RpcTokenResponse, SELF_CUSTODY_FILL_TIMEOUT_MS, SELF_CUSTODY_POLL_INTERVAL_MS, type SafeParseFailure, type SafeParseResult, type SafeParseSuccess, type ServerWallet, type SetPaperTradingBalanceParams, type SettlementDiff, type SettlementDifference, type SettlementSource, type SetupDepositAddressStep, type SetupVenueKeyStep, type SignatureRequest, type SignatureRequestType, type SignerFn, type SimpleOrderbookLevel, type SmartRouteAllocation, type SmartRouteBridgeStep, type SmartRouteFeeBreakdown, type SmartRouteFill, type SmartRouteParams, type SmartRouteResponse, type SmartRouteSettlementLeg, type SmartRouteSettlementPlan, type SmartRouteSetupCostLine, type SmartRouteSide, type SmartRouteStatus, type SmartRouteVenueFill, type SplitsByAmountResult, type SportsGameStatus, type SportsLiveParticipant, type SportsLiveResponse, type SportsLiveState, type SyncBalancesResponse, TERMINAL_EXECUTION_STATES, TimeInForce, type TradeExecutorOrder, type TradeExecutorOrderListResponse, TradeSide$1 as TradeSide, type TradeSplit, type TradeStep, TurnstileChallengeError, type UnifiedBalanceResponse, type UpdateBalanceRefillPolicyParams, 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, VENUE_CHAIN_IDS, type ValidateBalanceOnClientStep, type ValidateManagedParams, type ValidateManagedRequest, type ValidateManagedResponse, type ValidateTradeRequest, type ValidateTradeResponse, Venue, type VenueEvent, type VenueEventListItem, type VenueEventWithMarkets, type VenueGeoPolicyEntry, type VenueGeoPolicyResponse, type VenueKeyStatus, 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 WithdrawPreviewParams, type WithdrawPreviewResponse, type WithdrawTokenSymbol, type WithdrawalExpected, type WithdrawalLeg, type WithdrawalLegStatus, type WithdrawalLegType, type WithdrawalLifecycleStatus, type WithdrawalQuoteParams, type WithdrawalQuoteResponse, 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, adjustLimitPriceRawToTick, aggregateMidpoint, applyOrderbookDelta, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getBalanceRefillMaximumRaw, getEffectiveDisabledVenues, getWalletAddressFromUserProfile, hasShape, isAggApiError, isBalanceRefillWithinDailyCap, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, isVenueActive, isVenueDataVisible, isVenueInactive, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, parse, parseEmail, parseEmailStrict, safeParse, snapshotToOrderbook, sortVenues };
|
package/dist/index.js
CHANGED
|
@@ -90,6 +90,9 @@ __export(index_exports, {
|
|
|
90
90
|
OrderStatus: () => OrderStatus,
|
|
91
91
|
OrderType: () => OrderType,
|
|
92
92
|
RECURRENCE_CADENCES: () => RECURRENCE_CADENCES,
|
|
93
|
+
SELF_CUSTODY_FILL_TIMEOUT_MS: () => SELF_CUSTODY_FILL_TIMEOUT_MS,
|
|
94
|
+
SELF_CUSTODY_POLL_INTERVAL_MS: () => SELF_CUSTODY_POLL_INTERVAL_MS,
|
|
95
|
+
TERMINAL_EXECUTION_STATES: () => TERMINAL_EXECUTION_STATES,
|
|
93
96
|
TimeInForce: () => TimeInForce,
|
|
94
97
|
TradeSide: () => TradeSide,
|
|
95
98
|
TurnstileChallengeError: () => TurnstileChallengeError,
|
|
@@ -818,6 +821,21 @@ function isAggApiError(value) {
|
|
|
818
821
|
return value instanceof AggApiError;
|
|
819
822
|
}
|
|
820
823
|
|
|
824
|
+
// src/types.ts
|
|
825
|
+
var SELF_CUSTODY_FILL_TIMEOUT_MS = 5 * 6e4;
|
|
826
|
+
var SELF_CUSTODY_POLL_INTERVAL_MS = 2e3;
|
|
827
|
+
var TERMINAL_EXECUTION_STATES = /* @__PURE__ */ new Set(["filled", "partially_filled", "failed", "cancelled", "expired"]);
|
|
828
|
+
var RECURRENCE_CADENCES = [
|
|
829
|
+
"PT5M",
|
|
830
|
+
"PT10M",
|
|
831
|
+
"PT15M",
|
|
832
|
+
"PT1H",
|
|
833
|
+
"P1D",
|
|
834
|
+
"P1W",
|
|
835
|
+
"P1M",
|
|
836
|
+
"P1Y"
|
|
837
|
+
];
|
|
838
|
+
|
|
821
839
|
// src/orderbook-utils.ts
|
|
822
840
|
var PRICE_KEY_SCALE = 1e9;
|
|
823
841
|
function crc32(str) {
|
|
@@ -1838,6 +1856,7 @@ var AggClient = class {
|
|
|
1838
1856
|
this.appId = options.appId;
|
|
1839
1857
|
this.adminKey = options.adminKey;
|
|
1840
1858
|
this.apiKey = options.apiKey;
|
|
1859
|
+
this.signer = options.signer;
|
|
1841
1860
|
this.baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
1842
1861
|
this.wsUrl = options.wsUrl;
|
|
1843
1862
|
this.authOptions = options.auth;
|
|
@@ -2481,7 +2500,13 @@ Issued At: ${issuedAt}`;
|
|
|
2481
2500
|
});
|
|
2482
2501
|
});
|
|
2483
2502
|
}
|
|
2484
|
-
/**
|
|
2503
|
+
/**
|
|
2504
|
+
* Get quote-scoped execution progress, DAG step state, and order leg
|
|
2505
|
+
* terminal status. Also carries `pendingSignatures` — this is the route
|
|
2506
|
+
* `fillSelfCustody` polls while an on-chain step is in flight, so a caller
|
|
2507
|
+
* already polling this for progress learns about newly-parked steps here
|
|
2508
|
+
* too, not just from the signatures endpoint.
|
|
2509
|
+
*/
|
|
2485
2510
|
getExecutionStatus(params) {
|
|
2486
2511
|
return __async(this, null, function* () {
|
|
2487
2512
|
const query = { quoteId: params.quoteId };
|
|
@@ -2694,7 +2719,7 @@ Issued At: ${issuedAt}`;
|
|
|
2694
2719
|
// Opt into the lean response (no embedded `venueMarkets`) — markets are
|
|
2695
2720
|
// fetched separately via GET /venue-markets. Empty `expand` (no `markets`
|
|
2696
2721
|
// token) tells the API to omit the deprecated embedded array.
|
|
2697
|
-
query: { expand: "" },
|
|
2722
|
+
query: __spreadValues({ expand: "" }, (options == null ? void 0 : options.cluster) === false ? { cluster: "false" } : {}),
|
|
2698
2723
|
signal: options == null ? void 0 : options.signal
|
|
2699
2724
|
});
|
|
2700
2725
|
});
|
|
@@ -2822,6 +2847,7 @@ Issued At: ${issuedAt}`;
|
|
|
2822
2847
|
const query = {};
|
|
2823
2848
|
if (options == null ? void 0 : options.venue) query.venue = options.venue;
|
|
2824
2849
|
if (options == null ? void 0 : options.venueEventId) query.venueEventId = options.venueEventId;
|
|
2850
|
+
if ((options == null ? void 0 : options.cluster) === false) query.cluster = "false";
|
|
2825
2851
|
if ((_a = options == null ? void 0 : options.search) == null ? void 0 : _a.trim()) query.search = options.search.trim();
|
|
2826
2852
|
if (options == null ? void 0 : options.matchStatus) query.matchStatus = options.matchStatus;
|
|
2827
2853
|
if (options == null ? void 0 : options.status) query.status = options.status;
|
|
@@ -3151,6 +3177,87 @@ Issued At: ${issuedAt}`;
|
|
|
3151
3177
|
});
|
|
3152
3178
|
});
|
|
3153
3179
|
}
|
|
3180
|
+
/** Submit signatures for a parked fill. Returns whatever is still outstanding. */
|
|
3181
|
+
submitFillSignatures(quoteId, signatures) {
|
|
3182
|
+
return __async(this, null, function* () {
|
|
3183
|
+
return this.request(`/execution/fill/${encodeURIComponent(quoteId)}/signatures`, {
|
|
3184
|
+
method: "POST",
|
|
3185
|
+
body: JSON.stringify({ signatures })
|
|
3186
|
+
});
|
|
3187
|
+
});
|
|
3188
|
+
}
|
|
3189
|
+
/**
|
|
3190
|
+
* Execute a quote in self-custodial mode.
|
|
3191
|
+
*
|
|
3192
|
+
* Identical to `executeManaged` when the server can sign for the user. When
|
|
3193
|
+
* it cannot, the DAG parks on a signature request instead — but that park
|
|
3194
|
+
* always happens asynchronously, in the trade-executor process, so it can
|
|
3195
|
+
* never show up on this `POST /execution/fill` response itself. This
|
|
3196
|
+
* drives the round trip from there: poll `getExecutionStatus` while an
|
|
3197
|
+
* on-chain step is in flight, sign whatever it hands back with the
|
|
3198
|
+
* configured `signer`, post the signatures back, and repeat until the
|
|
3199
|
+
* server reports nothing outstanding and the run reaches a terminal state.
|
|
3200
|
+
*/
|
|
3201
|
+
fillSelfCustody(params) {
|
|
3202
|
+
return __async(this, null, function* () {
|
|
3203
|
+
var _a, _b, _c;
|
|
3204
|
+
if (this.signer && !params.signingAddress) {
|
|
3205
|
+
throw new Error(
|
|
3206
|
+
"fillSelfCustody requires `signingAddress` \u2014 the wallet that will sign this fill."
|
|
3207
|
+
);
|
|
3208
|
+
}
|
|
3209
|
+
if (params.signingAddress && !this.signer) {
|
|
3210
|
+
throw new Error(
|
|
3211
|
+
"This fill requires client-side signatures, but no `signer` was passed to createAggClient(). Provide one to trade in self-custodial mode."
|
|
3212
|
+
);
|
|
3213
|
+
}
|
|
3214
|
+
const first = yield this.executeManaged(params);
|
|
3215
|
+
if (!this.signer && !params.signingAddress) return first;
|
|
3216
|
+
const signer = this.signer;
|
|
3217
|
+
const quoteId = first.quoteId;
|
|
3218
|
+
let pending = (_a = first.pendingSignatures) != null ? _a : [];
|
|
3219
|
+
let lastKey = "";
|
|
3220
|
+
const deadline = Date.now() + SELF_CUSTODY_FILL_TIMEOUT_MS;
|
|
3221
|
+
for (; ; ) {
|
|
3222
|
+
if (Date.now() > deadline) {
|
|
3223
|
+
throw new Error(`Fill for quote ${quoteId} did not finish within the timeout.`);
|
|
3224
|
+
}
|
|
3225
|
+
if (pending.length === 0) {
|
|
3226
|
+
yield new Promise((r) => setTimeout(r, SELF_CUSTODY_POLL_INTERVAL_MS));
|
|
3227
|
+
const polled = yield this.getExecutionStatus({ quoteId });
|
|
3228
|
+
if (TERMINAL_EXECUTION_STATES.has(polled.overallState)) {
|
|
3229
|
+
if (polled.overallState !== "filled" && polled.overallState !== "partially_filled") {
|
|
3230
|
+
throw new Error(`Fill for quote ${quoteId} ended as ${polled.overallState}.`);
|
|
3231
|
+
}
|
|
3232
|
+
return __spreadProps(__spreadValues({}, first), { pendingSignatures: [] });
|
|
3233
|
+
}
|
|
3234
|
+
pending = (_b = polled.pendingSignatures) != null ? _b : [];
|
|
3235
|
+
continue;
|
|
3236
|
+
}
|
|
3237
|
+
const key = pending.map((p) => p.stepId).sort().join(",");
|
|
3238
|
+
if (key === lastKey) {
|
|
3239
|
+
throw new Error(
|
|
3240
|
+
`Fill for quote ${quoteId} did not advance \u2014 still awaiting steps [${key}] after signing them.`
|
|
3241
|
+
);
|
|
3242
|
+
}
|
|
3243
|
+
lastKey = key;
|
|
3244
|
+
const signatures = [];
|
|
3245
|
+
for (const req of pending) {
|
|
3246
|
+
if (Date.now() > new Date(req.expiresAt).getTime()) {
|
|
3247
|
+
throw new Error(
|
|
3248
|
+
`Signature request ${req.stepId} for quote ${quoteId} expired at ${req.expiresAt}; the fill must be re-quoted.`
|
|
3249
|
+
);
|
|
3250
|
+
}
|
|
3251
|
+
const signed = yield signer(req);
|
|
3252
|
+
signatures.push(
|
|
3253
|
+
typeof signed === "string" ? { stepId: req.stepId, signature: signed } : { stepId: req.stepId, txHash: signed.txHash }
|
|
3254
|
+
);
|
|
3255
|
+
}
|
|
3256
|
+
const next = yield this.submitFillSignatures(quoteId, signatures);
|
|
3257
|
+
pending = (_c = next.pendingSignatures) != null ? _c : [];
|
|
3258
|
+
}
|
|
3259
|
+
});
|
|
3260
|
+
}
|
|
3154
3261
|
/** Place a managed limit order. Returns the venue-backed order state. */
|
|
3155
3262
|
placeLimitOrder(params) {
|
|
3156
3263
|
return __async(this, null, function* () {
|
|
@@ -3339,18 +3446,6 @@ Issued At: ${issuedAt}`;
|
|
|
3339
3446
|
// src/best-split.ts
|
|
3340
3447
|
var computeBestSplitsByAmount2 = computeBestSplitsByAmount;
|
|
3341
3448
|
|
|
3342
|
-
// src/types.ts
|
|
3343
|
-
var RECURRENCE_CADENCES = [
|
|
3344
|
-
"PT5M",
|
|
3345
|
-
"PT10M",
|
|
3346
|
-
"PT15M",
|
|
3347
|
-
"PT1H",
|
|
3348
|
-
"P1D",
|
|
3349
|
-
"P1W",
|
|
3350
|
-
"P1M",
|
|
3351
|
-
"P1Y"
|
|
3352
|
-
];
|
|
3353
|
-
|
|
3354
3449
|
// src/candle-builder.ts
|
|
3355
3450
|
var INTERVAL_SECS = {
|
|
3356
3451
|
"1m": 60,
|
|
@@ -3562,6 +3657,9 @@ function createAggClient(options) {
|
|
|
3562
3657
|
OrderStatus,
|
|
3563
3658
|
OrderType,
|
|
3564
3659
|
RECURRENCE_CADENCES,
|
|
3660
|
+
SELF_CUSTODY_FILL_TIMEOUT_MS,
|
|
3661
|
+
SELF_CUSTODY_POLL_INTERVAL_MS,
|
|
3662
|
+
TERMINAL_EXECUTION_STATES,
|
|
3565
3663
|
TimeInForce,
|
|
3566
3664
|
TradeSide,
|
|
3567
3665
|
TurnstileChallengeError,
|
package/dist/index.mjs
CHANGED
|
@@ -690,6 +690,21 @@ function isAggApiError(value) {
|
|
|
690
690
|
return value instanceof AggApiError;
|
|
691
691
|
}
|
|
692
692
|
|
|
693
|
+
// src/types.ts
|
|
694
|
+
var SELF_CUSTODY_FILL_TIMEOUT_MS = 5 * 6e4;
|
|
695
|
+
var SELF_CUSTODY_POLL_INTERVAL_MS = 2e3;
|
|
696
|
+
var TERMINAL_EXECUTION_STATES = /* @__PURE__ */ new Set(["filled", "partially_filled", "failed", "cancelled", "expired"]);
|
|
697
|
+
var RECURRENCE_CADENCES = [
|
|
698
|
+
"PT5M",
|
|
699
|
+
"PT10M",
|
|
700
|
+
"PT15M",
|
|
701
|
+
"PT1H",
|
|
702
|
+
"P1D",
|
|
703
|
+
"P1W",
|
|
704
|
+
"P1M",
|
|
705
|
+
"P1Y"
|
|
706
|
+
];
|
|
707
|
+
|
|
693
708
|
// src/orderbook-utils.ts
|
|
694
709
|
var PRICE_KEY_SCALE = 1e9;
|
|
695
710
|
function crc32(str) {
|
|
@@ -1710,6 +1725,7 @@ var AggClient = class {
|
|
|
1710
1725
|
this.appId = options.appId;
|
|
1711
1726
|
this.adminKey = options.adminKey;
|
|
1712
1727
|
this.apiKey = options.apiKey;
|
|
1728
|
+
this.signer = options.signer;
|
|
1713
1729
|
this.baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
1714
1730
|
this.wsUrl = options.wsUrl;
|
|
1715
1731
|
this.authOptions = options.auth;
|
|
@@ -2353,7 +2369,13 @@ Issued At: ${issuedAt}`;
|
|
|
2353
2369
|
});
|
|
2354
2370
|
});
|
|
2355
2371
|
}
|
|
2356
|
-
/**
|
|
2372
|
+
/**
|
|
2373
|
+
* Get quote-scoped execution progress, DAG step state, and order leg
|
|
2374
|
+
* terminal status. Also carries `pendingSignatures` — this is the route
|
|
2375
|
+
* `fillSelfCustody` polls while an on-chain step is in flight, so a caller
|
|
2376
|
+
* already polling this for progress learns about newly-parked steps here
|
|
2377
|
+
* too, not just from the signatures endpoint.
|
|
2378
|
+
*/
|
|
2357
2379
|
getExecutionStatus(params) {
|
|
2358
2380
|
return __async(this, null, function* () {
|
|
2359
2381
|
const query = { quoteId: params.quoteId };
|
|
@@ -2566,7 +2588,7 @@ Issued At: ${issuedAt}`;
|
|
|
2566
2588
|
// Opt into the lean response (no embedded `venueMarkets`) — markets are
|
|
2567
2589
|
// fetched separately via GET /venue-markets. Empty `expand` (no `markets`
|
|
2568
2590
|
// token) tells the API to omit the deprecated embedded array.
|
|
2569
|
-
query: { expand: "" },
|
|
2591
|
+
query: __spreadValues({ expand: "" }, (options == null ? void 0 : options.cluster) === false ? { cluster: "false" } : {}),
|
|
2570
2592
|
signal: options == null ? void 0 : options.signal
|
|
2571
2593
|
});
|
|
2572
2594
|
});
|
|
@@ -2694,6 +2716,7 @@ Issued At: ${issuedAt}`;
|
|
|
2694
2716
|
const query = {};
|
|
2695
2717
|
if (options == null ? void 0 : options.venue) query.venue = options.venue;
|
|
2696
2718
|
if (options == null ? void 0 : options.venueEventId) query.venueEventId = options.venueEventId;
|
|
2719
|
+
if ((options == null ? void 0 : options.cluster) === false) query.cluster = "false";
|
|
2697
2720
|
if ((_a = options == null ? void 0 : options.search) == null ? void 0 : _a.trim()) query.search = options.search.trim();
|
|
2698
2721
|
if (options == null ? void 0 : options.matchStatus) query.matchStatus = options.matchStatus;
|
|
2699
2722
|
if (options == null ? void 0 : options.status) query.status = options.status;
|
|
@@ -3023,6 +3046,87 @@ Issued At: ${issuedAt}`;
|
|
|
3023
3046
|
});
|
|
3024
3047
|
});
|
|
3025
3048
|
}
|
|
3049
|
+
/** Submit signatures for a parked fill. Returns whatever is still outstanding. */
|
|
3050
|
+
submitFillSignatures(quoteId, signatures) {
|
|
3051
|
+
return __async(this, null, function* () {
|
|
3052
|
+
return this.request(`/execution/fill/${encodeURIComponent(quoteId)}/signatures`, {
|
|
3053
|
+
method: "POST",
|
|
3054
|
+
body: JSON.stringify({ signatures })
|
|
3055
|
+
});
|
|
3056
|
+
});
|
|
3057
|
+
}
|
|
3058
|
+
/**
|
|
3059
|
+
* Execute a quote in self-custodial mode.
|
|
3060
|
+
*
|
|
3061
|
+
* Identical to `executeManaged` when the server can sign for the user. When
|
|
3062
|
+
* it cannot, the DAG parks on a signature request instead — but that park
|
|
3063
|
+
* always happens asynchronously, in the trade-executor process, so it can
|
|
3064
|
+
* never show up on this `POST /execution/fill` response itself. This
|
|
3065
|
+
* drives the round trip from there: poll `getExecutionStatus` while an
|
|
3066
|
+
* on-chain step is in flight, sign whatever it hands back with the
|
|
3067
|
+
* configured `signer`, post the signatures back, and repeat until the
|
|
3068
|
+
* server reports nothing outstanding and the run reaches a terminal state.
|
|
3069
|
+
*/
|
|
3070
|
+
fillSelfCustody(params) {
|
|
3071
|
+
return __async(this, null, function* () {
|
|
3072
|
+
var _a, _b, _c;
|
|
3073
|
+
if (this.signer && !params.signingAddress) {
|
|
3074
|
+
throw new Error(
|
|
3075
|
+
"fillSelfCustody requires `signingAddress` \u2014 the wallet that will sign this fill."
|
|
3076
|
+
);
|
|
3077
|
+
}
|
|
3078
|
+
if (params.signingAddress && !this.signer) {
|
|
3079
|
+
throw new Error(
|
|
3080
|
+
"This fill requires client-side signatures, but no `signer` was passed to createAggClient(). Provide one to trade in self-custodial mode."
|
|
3081
|
+
);
|
|
3082
|
+
}
|
|
3083
|
+
const first = yield this.executeManaged(params);
|
|
3084
|
+
if (!this.signer && !params.signingAddress) return first;
|
|
3085
|
+
const signer = this.signer;
|
|
3086
|
+
const quoteId = first.quoteId;
|
|
3087
|
+
let pending = (_a = first.pendingSignatures) != null ? _a : [];
|
|
3088
|
+
let lastKey = "";
|
|
3089
|
+
const deadline = Date.now() + SELF_CUSTODY_FILL_TIMEOUT_MS;
|
|
3090
|
+
for (; ; ) {
|
|
3091
|
+
if (Date.now() > deadline) {
|
|
3092
|
+
throw new Error(`Fill for quote ${quoteId} did not finish within the timeout.`);
|
|
3093
|
+
}
|
|
3094
|
+
if (pending.length === 0) {
|
|
3095
|
+
yield new Promise((r) => setTimeout(r, SELF_CUSTODY_POLL_INTERVAL_MS));
|
|
3096
|
+
const polled = yield this.getExecutionStatus({ quoteId });
|
|
3097
|
+
if (TERMINAL_EXECUTION_STATES.has(polled.overallState)) {
|
|
3098
|
+
if (polled.overallState !== "filled" && polled.overallState !== "partially_filled") {
|
|
3099
|
+
throw new Error(`Fill for quote ${quoteId} ended as ${polled.overallState}.`);
|
|
3100
|
+
}
|
|
3101
|
+
return __spreadProps(__spreadValues({}, first), { pendingSignatures: [] });
|
|
3102
|
+
}
|
|
3103
|
+
pending = (_b = polled.pendingSignatures) != null ? _b : [];
|
|
3104
|
+
continue;
|
|
3105
|
+
}
|
|
3106
|
+
const key = pending.map((p) => p.stepId).sort().join(",");
|
|
3107
|
+
if (key === lastKey) {
|
|
3108
|
+
throw new Error(
|
|
3109
|
+
`Fill for quote ${quoteId} did not advance \u2014 still awaiting steps [${key}] after signing them.`
|
|
3110
|
+
);
|
|
3111
|
+
}
|
|
3112
|
+
lastKey = key;
|
|
3113
|
+
const signatures = [];
|
|
3114
|
+
for (const req of pending) {
|
|
3115
|
+
if (Date.now() > new Date(req.expiresAt).getTime()) {
|
|
3116
|
+
throw new Error(
|
|
3117
|
+
`Signature request ${req.stepId} for quote ${quoteId} expired at ${req.expiresAt}; the fill must be re-quoted.`
|
|
3118
|
+
);
|
|
3119
|
+
}
|
|
3120
|
+
const signed = yield signer(req);
|
|
3121
|
+
signatures.push(
|
|
3122
|
+
typeof signed === "string" ? { stepId: req.stepId, signature: signed } : { stepId: req.stepId, txHash: signed.txHash }
|
|
3123
|
+
);
|
|
3124
|
+
}
|
|
3125
|
+
const next = yield this.submitFillSignatures(quoteId, signatures);
|
|
3126
|
+
pending = (_c = next.pendingSignatures) != null ? _c : [];
|
|
3127
|
+
}
|
|
3128
|
+
});
|
|
3129
|
+
}
|
|
3026
3130
|
/** Place a managed limit order. Returns the venue-backed order state. */
|
|
3027
3131
|
placeLimitOrder(params) {
|
|
3028
3132
|
return __async(this, null, function* () {
|
|
@@ -3211,18 +3315,6 @@ Issued At: ${issuedAt}`;
|
|
|
3211
3315
|
// src/best-split.ts
|
|
3212
3316
|
var computeBestSplitsByAmount2 = computeBestSplitsByAmount;
|
|
3213
3317
|
|
|
3214
|
-
// src/types.ts
|
|
3215
|
-
var RECURRENCE_CADENCES = [
|
|
3216
|
-
"PT5M",
|
|
3217
|
-
"PT10M",
|
|
3218
|
-
"PT15M",
|
|
3219
|
-
"PT1H",
|
|
3220
|
-
"P1D",
|
|
3221
|
-
"P1W",
|
|
3222
|
-
"P1M",
|
|
3223
|
-
"P1Y"
|
|
3224
|
-
];
|
|
3225
|
-
|
|
3226
3318
|
// src/candle-builder.ts
|
|
3227
3319
|
var INTERVAL_SECS = {
|
|
3228
3320
|
"1m": 60,
|
|
@@ -3433,6 +3525,9 @@ export {
|
|
|
3433
3525
|
OrderStatus,
|
|
3434
3526
|
OrderType,
|
|
3435
3527
|
RECURRENCE_CADENCES,
|
|
3528
|
+
SELF_CUSTODY_FILL_TIMEOUT_MS,
|
|
3529
|
+
SELF_CUSTODY_POLL_INTERVAL_MS,
|
|
3530
|
+
TERMINAL_EXECUTION_STATES,
|
|
3436
3531
|
TimeInForce,
|
|
3437
3532
|
TradeSide,
|
|
3438
3533
|
TurnstileChallengeError,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agg-build/sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.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",
|