@cexyio/cexy 0.1.0-dev.3 → 0.1.0-dev.5

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.cts CHANGED
@@ -36,12 +36,6 @@ declare class ApiKeyAuthenticator implements Authenticator {
36
36
  toJSON(): Record<string, string>;
37
37
  }
38
38
 
39
- /**
40
- * Client-side token bucket. `CexyClient` defaults to 100 requests/minute without credentials
41
- * and 300/minute with an API key (the server allows about 120/min per IP and 600/min per
42
- * key; this keeps a margin). It adapts to `X-RateLimit-Limit`, `X-RateLimit-Remaining` and
43
- * `X-RateLimit-Reset` when the server sends them, and to 429 `Retry-After`.
44
- */
45
39
  interface RateLimiterOptions {
46
40
  requestsPerMinute: number;
47
41
  /** @internal for tests */
@@ -62,7 +56,10 @@ declare class RateLimiter {
62
56
  acquire(signal?: AbortSignal): Promise<void>;
63
57
  /** Adapts to the server's rate-limit headers. Never raises the configured limit. */
64
58
  update(headers: Headers): void;
65
- /** Blocks all requests for `ms` (used for 429 Retry-After). */
59
+ /**
60
+ * Blocks all requests for `ms` (used for 429 Retry-After and `X-RateLimit-Reset`). Server
61
+ * hints are untrusted: non-finite values are ignored and the block is capped at 120 s.
62
+ */
66
63
  blockFor(ms: number): void;
67
64
  }
68
65
 
@@ -135,10 +132,10 @@ interface RequestOptions {
135
132
  /** Overrides the client's `maxRetries`. */
136
133
  maxRetries?: number;
137
134
  /**
138
- * Mutations only: the `Idempotency-Key` to send. Generated automatically when absent.
139
- * The server honours it on pool join/exit; set it yourself to make a retry across process
140
- * restarts safe there. Orders and cancels do NOT honour it: their safety comes from
141
- * `client_order_id` (see `placeOrder`).
135
+ * Pool join/exit only: the `Idempotency-Key` to send (generated automatically when absent,
136
+ * and reused on every retry). The server honours it there; set it yourself to make a retry
137
+ * across process restarts safe. No other request sends the header: orders and cancels do
138
+ * not honour it, and their safety comes from `client_order_id` (see `placeOrder`).
142
139
  */
143
140
  idempotencyKey?: string;
144
141
  }
@@ -163,6 +160,8 @@ interface TransportConfig {
163
160
  userAgent: string | null;
164
161
  sleep: (ms: number, signal?: AbortSignal) => Promise<void>;
165
162
  random: () => number;
163
+ /** Milliseconds clock (default `Date.now`); injectable for tests. */
164
+ now?: () => number;
166
165
  onRetry?: ((info: RetryInfo) => void) | undefined;
167
166
  }
168
167
  interface CallSpec {
@@ -182,14 +181,17 @@ declare class Transport {
182
181
  readonly config: TransportConfig;
183
182
  constructor(config: TransportConfig);
184
183
  /**
185
- * Sends a request with the standard retry policy: GETs retry on retryable errors and
186
- * network failures. Mutations carry an `Idempotency-Key` reused on every attempt; the server
187
- * honours it on pool join/exit, which makes their retries safe. The other mutations routed
188
- * here (cancel-all) are naturally repeatable. `placeOrder` and `cancelOrder` use
184
+ * Sends a request with the standard retry policy: retryable errors and network failures are
185
+ * retried. Pool join/exit carry an `Idempotency-Key` reused on every attempt (the server
186
+ * honours it there, which makes their retries safe); the other mutations routed here
187
+ * (cancel-all) are naturally repeatable and send no key. `placeOrder` and `cancelOrder` use
189
188
  * `attempt()` with their own policies.
190
189
  */
191
190
  request(spec: CallSpec, opts?: RequestOptions): Promise<RawResponse>;
192
- /** Waits before retry number `attempt + 1`, honouring server hints. */
191
+ /**
192
+ * Waits before retry number `attempt + 1`, honouring server hints. A server hint longer than
193
+ * `MAX_SERVER_WAIT_MS` is not waited: `err` is thrown at once (it still carries the hint).
194
+ */
193
195
  backoff(op: OperationId, info: OperationInfo, attempt: number, err: unknown, idempotencyKey: string | undefined, signal?: AbortSignal): Promise<void>;
194
196
  /** Full-jitter exponential backoff, or the server's hint plus a little jitter. */
195
197
  retryDelay(attempt: number, err: unknown): number;
@@ -730,7 +732,11 @@ interface paths {
730
732
  put?: never;
731
733
  /**
732
734
  * Cancels every open order, optionally within one market.
733
- * @description Best-effort: a failure on one order does not stop the rest, and both outcomes are reported. A panic-button endpoint that stops at the first problem is worse than useless.
735
+ * @description Best-effort: a failure on one order does not stop the rest, and every outcome is reported. A panic-button endpoint that stops at the first problem is worse than useless.
736
+ *
737
+ * An order still being placed when the call starts (status `pending`, for as long as its own placement request runs) is waited for, up to 500 ms per call in total: cancelled if it opens, reported in `already_closed` if it fills or is refused, and in `failed` with code `INVALID_STATE` if it is still being placed at the deadline. Orders placed after the call starts are not part of it. At most 500 orders per call; `has_more` says there are others.
738
+ *
739
+ * Limited to 30 calls a minute per account, on top of the general request limit.
734
740
  */
735
741
  post: operations["cancel_all"];
736
742
  delete?: never;
@@ -1037,12 +1043,31 @@ interface components {
1037
1043
  /** @description Limit the cancellation to one market. Omitted or `null`, every market's open orders are cancelled. */
1038
1044
  symbol?: string | null;
1039
1045
  };
1040
- /** @description What a bulk cancellation achieved. */
1046
+ /**
1047
+ * @description What a bulk cancellation achieved.
1048
+ *
1049
+ * Every order the call handled is in exactly one of `cancelled`, `already_closed` and `failed`.
1050
+ */
1041
1051
  CancelAllResponse: {
1052
+ /** @description Orders that closed on their own (filled, rejected, cancelled elsewhere) before this call reached them. Nothing was done to them, and they are not failures. */
1053
+ already_closed: string[];
1042
1054
  /** @description Orders cancelled. */
1043
1055
  cancelled: string[];
1044
- /** @description Orders that could not be cancelled. Each failure is logged server-side. */
1056
+ /** @description Orders that could not be cancelled in this call. Check `failures` for why, then refresh or call again. */
1045
1057
  failed: string[];
1058
+ /** @description Why each order in `failed` could not be cancelled. */
1059
+ failures: components["schemas"]["CancelFailureResponse"][];
1060
+ /** @description More open orders exist than one call handles (500). Call again. */
1061
+ has_more: boolean;
1062
+ };
1063
+ /** @description Why one order could not be cancelled. */
1064
+ CancelFailureResponse: {
1065
+ /** @description The error code of the attempt, as in any error response: e.g. `INVALID_STATE` for an order still being placed when the wait ran out, or `MARKET_UNAVAILABLE`. */
1066
+ code: string;
1067
+ /** @description Its message. */
1068
+ message: string;
1069
+ /** @description The order. */
1070
+ order_id: string;
1046
1071
  };
1047
1072
  /**
1048
1073
  * @description Candle/kline intervals for market data.
@@ -2877,6 +2902,24 @@ interface operations {
2877
2902
  };
2878
2903
  };
2879
2904
  };
2905
+ /** @description No such market */
2906
+ 404: {
2907
+ headers: {
2908
+ [name: string]: unknown;
2909
+ };
2910
+ content: {
2911
+ "application/json": components["schemas"]["ErrorResponse"];
2912
+ };
2913
+ };
2914
+ /** @description Over 30 calls a minute for this account; `details.retry_after_seconds` says when to retry */
2915
+ 429: {
2916
+ headers: {
2917
+ [name: string]: unknown;
2918
+ };
2919
+ content: {
2920
+ "application/json": components["schemas"]["ErrorResponse"];
2921
+ };
2922
+ };
2880
2923
  };
2881
2924
  };
2882
2925
  order_history: {
@@ -3181,6 +3224,26 @@ type AssetNetwork = S["AssetNetworkResponse"];
3181
3224
  type Balance = S["BalanceResponse"];
3182
3225
  type CancelAllRequest = S["CancelAllRequest"];
3183
3226
  type CancelAllResult = S["CancelAllResponse"];
3227
+ /** Why one order could not be cancelled (`CancelAllResult.failures`). */
3228
+ type CancelFailure = S["CancelFailureResponse"];
3229
+ /** Why a `cancelAll({ ..., untilDone: true })` loop ended. */
3230
+ type CancelAllStopReason = "done" | "max_rounds" | "time_budget";
3231
+ /**
3232
+ * Merged result of a `cancelAll({ ..., untilDone: true })` loop. Every order is in exactly one
3233
+ * of `cancelled`, `already_closed` and `failed`, in its latest state; `has_more` is the last
3234
+ * round's.
3235
+ */
3236
+ interface CancelAllUntilDoneResult extends CancelAllResult {
3237
+ /** Number of cancel-all calls made. */
3238
+ rounds: number;
3239
+ /** `done`: nothing left to retry; otherwise the loop's limit that ended it. */
3240
+ stopped: CancelAllStopReason;
3241
+ /**
3242
+ * The error code of the last round when that round failed with a retryable error (e.g.
3243
+ * `RATE_LIMITED`, `SERVICE_UNAVAILABLE`, `CONNECTION_ERROR`); absent when it succeeded.
3244
+ */
3245
+ last_error_code?: string;
3246
+ }
3184
3247
  type Candle = S["CandleResponse"];
3185
3248
  type CandleInterval = S["CandleInterval"];
3186
3249
  type DepositAddress = S["DepositAddressResponse"];
@@ -3344,6 +3407,14 @@ interface PlaceOrderResult extends PlaceOrderResponse {
3344
3407
  */
3345
3408
  interface CancelAllParams {
3346
3409
  symbol: string | null;
3410
+ /**
3411
+ * Repeat the call until nothing is left to retry (see `cancelAll`). Default false: one call.
3412
+ */
3413
+ untilDone?: boolean;
3414
+ /** With `untilDone`: at most this many calls. Default 20. */
3415
+ maxRounds?: number;
3416
+ /** With `untilDone`: stop before a wait would take the loop to this many ms. Default 120000. */
3417
+ timeBudgetMs?: number;
3347
3418
  }
3348
3419
  declare class TradingResource extends Resource {
3349
3420
  #private;
@@ -3361,7 +3432,7 @@ declare class TradingResource extends Resource {
3361
3432
  *
3362
3433
  * Retry safety rests on `client_order_id` (generated as a UUID when absent): it is unique
3363
3434
  * per account and the server refuses a repeat before any funds move. The server does NOT
3364
- * honour `Idempotency-Key` on orders (the header is sent but gives no protection). After an
3435
+ * honour `Idempotency-Key` on orders, so none is sent. After an
3365
3436
  * ambiguous failure (network error, timeout or 5xx) the SDK first looks the order up by
3366
3437
  * `client_order_id` and returns it if it exists (`recovered: true`); only if it does not
3367
3438
  * exist does it send the order again, with the same `client_order_id`, so a late-arriving
@@ -3380,12 +3451,35 @@ declare class TradingResource extends Resource {
3380
3451
  * Cancels every open order in one market: `cancelAll({ symbol: "BTC/USDT" })`.
3381
3452
  * To cancel across ALL markets, pass `symbol: null` explicitly: `cancelAll({ symbol: null })`.
3382
3453
  * Omitting `symbol` is an error, so an account-wide cancel never happens by accident
3383
- * (the server itself treats `{}` as every market).
3454
+ * (the server itself treats `{}` as every market). An unknown symbol throws `NotFoundError`.
3455
+ *
3456
+ * One call handles at most 500 orders. Every order it handled is in exactly one list:
3457
+ * `cancelled`; `already_closed` (it filled, was refused or was cancelled elsewhere first:
3458
+ * not an error); or `failed`, with the reason in `failures` (`INVALID_STATE` for an order
3459
+ * still being placed when the server's 500 ms wait ran out). `has_more` says more orders
3460
+ * remain: call again.
3384
3461
  *
3385
- * The server limits cancel-all to 30 calls per minute per account. It is naturally
3386
- * repeatable, so it is retried after network errors; a retry reports only what that retry
3387
- * cancelled.
3462
+ * With `untilDone: true` the SDK does that for you. It repeats while `has_more` is true or a
3463
+ * failure is `INVALID_STATE` / `SERVICE_UNAVAILABLE`. After a call that made no progress it
3464
+ * waits 1, 2, 4, 8 and then 15 s, starting over after any progress. It stops after
3465
+ * `maxRounds` calls or before a wait would pass `timeBudgetMs`, and returns the merged
3466
+ * result with `rounds` and `stopped`. Other failure codes are returned, never retried.
3467
+ * In this mode every round is exactly one HTTP request (the loop owns the retries, so it
3468
+ * never sends more than `maxRounds` requests): a 429 round waits the server's Retry-After
3469
+ * (without advancing the backoff), another retryable error (5xx, network) takes the next
3470
+ * backoff step, and a wait that would pass the budget ends the loop with
3471
+ * `stopped: "time_budget"` and `last_error_code`. A non-retryable error (e.g. a key without
3472
+ * the trade scope) throws `CancelAllInterruptedError`, which carries the error and the
3473
+ * partial result.
3474
+ *
3475
+ * The server allows 30 cancel-all calls per minute per account. A single call (without
3476
+ * `untilDone`) follows the normal retry policy: a 429 is retried after its Retry-After (up to
3477
+ * 120 s; a longer one fails at once) and network errors are retried, since the call is
3478
+ * naturally repeatable; a retry reports only what that retry did. No Idempotency-Key is sent.
3388
3479
  */
3480
+ cancelAll(params: CancelAllParams & {
3481
+ untilDone: true;
3482
+ }, opts?: RequestOptions): Promise<CancelAllUntilDoneResult>;
3389
3483
  cancelAll(params: CancelAllParams, opts?: RequestOptions): Promise<CancelAllResult>;
3390
3484
  }
3391
3485
 
@@ -3431,6 +3525,16 @@ declare class OrderStateUnknownError extends CexyError {
3431
3525
  readonly clientOrderId: string;
3432
3526
  constructor(clientOrderId: string, cause: unknown);
3433
3527
  }
3528
+ /**
3529
+ * A `cancelAll({ ..., untilDone: true })` loop hit an error it does not retry (for example
3530
+ * `ForbiddenError` for a key without the trade scope). `error` is that error; `partial` is what
3531
+ * the earlier rounds did, in the same shape as the loop's normal result.
3532
+ */
3533
+ declare class CancelAllInterruptedError extends CexyError {
3534
+ readonly error: unknown;
3535
+ readonly partial: CancelAllUntilDoneResult;
3536
+ constructor(error: unknown, partial: CancelAllUntilDoneResult);
3537
+ }
3434
3538
  interface CexyApiErrorInit {
3435
3539
  status: number;
3436
3540
  code: ErrorCode;
@@ -3484,8 +3588,23 @@ declare class RateLimitError extends CexyApiError {
3484
3588
  /** 5xx */
3485
3589
  declare class ServerError extends CexyApiError {
3486
3590
  }
3487
- /** True for codes listed in errors.yaml. */
3591
+ /**
3592
+ * Codes the SDK itself sets on a `CexyApiError`; the API never sends them, so they are not in
3593
+ * errors.yaml and `isKnownErrorCode()` returns false for them.
3594
+ * - `UNEXPECTED_REDIRECT`: the server answered with a 3xx. The SDK never follows redirects (the
3595
+ * credentials would go to the redirect target); not retryable.
3596
+ */
3597
+ declare const CLIENT_ERROR_CODES: {
3598
+ readonly UNEXPECTED_REDIRECT: "UNEXPECTED_REDIRECT";
3599
+ };
3600
+ /** True for codes listed in errors.yaml (server codes; see `CLIENT_ERROR_CODES` for the SDK's own). */
3488
3601
  declare function isKnownErrorCode(code: string): code is KnownErrorCode;
3602
+ /**
3603
+ * The longest wait the SDK accepts from a server hint (`Retry-After`, `retry_after_seconds`,
3604
+ * `X-RateLimit-Reset`): 120 s. A longer hint is never waited; the call fails at once instead
3605
+ * (see `Transport.backoff`), and the client-side rate limiter caps its block at this value.
3606
+ */
3607
+ declare const MAX_SERVER_WAIT_MS = 120000;
3489
3608
  /**
3490
3609
  * Builds the right error subclass for an HTTP error response.
3491
3610
  * - A known code maps by HTTP status (401 -> AuthenticationError, 403 -> ForbiddenError, ...).
@@ -3844,7 +3963,12 @@ interface CexyClientOptions {
3844
3963
  timeoutMs?: number;
3845
3964
  /** Retries after the first attempt for retryable failures. Default 3. */
3846
3965
  maxRetries?: number;
3847
- /** A `fetch` implementation. Default: the global `fetch` (Node 22+, browsers). */
3966
+ /**
3967
+ * A `fetch` implementation. Default: the global `fetch` (Node 22+, browsers).
3968
+ * It must honour `redirect: "manual"` (the SDK never follows redirects). A fetch that follows
3969
+ * them anyway has already sent the credentials to the redirect target by the time the SDK sees
3970
+ * `response.redirected` and throws `UNEXPECTED_REDIRECT`.
3971
+ */
3848
3972
  fetch?: FetchLike;
3849
3973
  /**
3850
3974
  * Client-side rate limit in requests per minute, or `false` to disable. Default 100/min
@@ -3866,6 +3990,8 @@ interface CexyClientOptions {
3866
3990
  sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
3867
3991
  /** @internal Deterministic jitter in tests. */
3868
3992
  random?: () => number;
3993
+ /** @internal Replace the clock in tests (milliseconds). */
3994
+ now?: () => number;
3869
3995
  }
3870
3996
  /**
3871
3997
  * CEXY.io REST client.
@@ -3925,11 +4051,11 @@ declare function isAmount(value: unknown): value is Amount;
3925
4051
  declare function assertAmountFields(body: Record<string, unknown>, fields: readonly string[], context: string): void;
3926
4052
 
3927
4053
  /** SDK version, kept in sync with package.json (a test enforces this). */
3928
- declare const VERSION = "0.1.0-dev.3";
4054
+ declare const VERSION = "0.1.0-dev.5";
3929
4055
  /** Default User-Agent product token. */
3930
- declare const USER_AGENT = "cexy-typescript/0.1.0-dev.3";
4056
+ declare const USER_AGENT = "cexy-typescript/0.1.0-dev.5";
3931
4057
 
3932
4058
  /** True for loopback hosts, the only ones where plain-text transport may be allowed. */
3933
4059
  declare function isLocalHost(hostname: string): boolean;
3934
4060
 
3935
- export { AccountResource, type Amount, type ApiKey, ApiKeyAuthenticator, type ApiScope, type Asset, type AssetNetwork, AssetsResource, type AuthRequest, type AuthResult, type AuthenticatedFrame, AuthenticationError, type Authenticator, type Balance, type BalanceUpdatedEvent, type BookLevel, type CancelAllParams, type CancelAllRequest, type CancelAllResult, type Candle, type CandleInterval, CexyApiError, type CexyApiErrorInit, CexyClient, type CexyClientOptions, CexyConfigError, CexyConnectionError, CexyError, CexyTimeoutError, CexyWebSocket, CexyWebSocketError, type CexyWebSocketEvents, type CexyWebSocketOptions, type CloseInfo, ConflictError, type CursorParams, DEFAULT_BASE_URL, DEFAULT_RPM_ANONYMOUS, DEFAULT_RPM_WITH_KEY, DEFAULT_WS_URL, type Deposit, type DepositAddress, type DepositEvent, type DepositStatus, type ErrorBody, type ErrorCode, type ErrorFrame, type EventMap, type ExchangeConfig, type ExitPoolRequest, type ExitPoolResult, ExportsResource, type FeeSchedule, FeesResource, type FetchLike, type Fill, ForbiddenError, InvalidAmountError, type IterateOptions, type JoinPoolRequest, type JoinPoolResult, JurisdictionBlockedError, KNOWN_EVENT_TYPES, type KnownErrorCode, type LedgerEntry, type LedgerEntryKind, type LiquidityRole, type Listener, LiveOrderBook, type LiveOrderBookEvents, type LiveOrderBookOptions, type MaintenanceState, type Market, type MarketStatus, type MarketStatusEvent, MarketsResource, type Network, NetworksResource, NotFoundError, type Notification, type NotificationKind, OPERATIONS, type OperationAuth, type OperationId, type OperationInfo, type OperationScope, type Order, type OrderBook, type OrderBookUpdateData, type OrderBookUpdateEvent, type OrderEvent, type OrderSide, OrderStateUnknownError, type OrderStatus, type OrderType, PRIVATE_CHANNELS, type Page, type PlaceOrderRequest, type PlaceOrderResponse, type PlaceOrderResult, type PongFrame, type Pool, type PoolStatus, PoolsResource, type PublicTrade, type QueryOf, RateLimitError, RateLimiter, type RateLimiterOptions, type RateLimiterState, type ReconnectOptions, type RequestOptions, type ResyncReason, type RetryInfo, SUPPORTED_PROTOCOL_VERSION, ServerError, type ServerTime, type SessionRevokedData, type SessionRevokedEvent, type SnapshotSource, type SortDirection, type SubAccount, type SubscribeResult, type SubscribedFrame, type TickerUpdateEvent, type TimeInForce, type TradeNewEvent, TradingResource, type TriggerDirection, TypedEmitter, USER_AGENT, UnprocessableError, type UnsubscribedFrame, VERSION, ValidationError, WS_BOOK_DEPTH, WalletResource, type WebSocketConstructor, type WebSocketLike, type WelcomeFrame, type Withdrawal, type WithdrawalAddress, type WithdrawalStatus, type WithdrawalUpdatedEvent, type WsEvent, type WsLogger, assertAmountFields, type components, errorFromResponse, isAmount, isKnownErrorCode, isLocalHost, isRetryable, type operations, paginate, type paths };
4061
+ export { AccountResource, type Amount, type ApiKey, ApiKeyAuthenticator, type ApiScope, type Asset, type AssetNetwork, AssetsResource, type AuthRequest, type AuthResult, type AuthenticatedFrame, AuthenticationError, type Authenticator, type Balance, type BalanceUpdatedEvent, type BookLevel, CLIENT_ERROR_CODES, CancelAllInterruptedError, type CancelAllParams, type CancelAllRequest, type CancelAllResult, type CancelAllStopReason, type CancelAllUntilDoneResult, type CancelFailure, type Candle, type CandleInterval, CexyApiError, type CexyApiErrorInit, CexyClient, type CexyClientOptions, CexyConfigError, CexyConnectionError, CexyError, CexyTimeoutError, CexyWebSocket, CexyWebSocketError, type CexyWebSocketEvents, type CexyWebSocketOptions, type CloseInfo, ConflictError, type CursorParams, DEFAULT_BASE_URL, DEFAULT_RPM_ANONYMOUS, DEFAULT_RPM_WITH_KEY, DEFAULT_WS_URL, type Deposit, type DepositAddress, type DepositEvent, type DepositStatus, type ErrorBody, type ErrorCode, type ErrorFrame, type EventMap, type ExchangeConfig, type ExitPoolRequest, type ExitPoolResult, ExportsResource, type FeeSchedule, FeesResource, type FetchLike, type Fill, ForbiddenError, InvalidAmountError, type IterateOptions, type JoinPoolRequest, type JoinPoolResult, JurisdictionBlockedError, KNOWN_EVENT_TYPES, type KnownErrorCode, type LedgerEntry, type LedgerEntryKind, type LiquidityRole, type Listener, LiveOrderBook, type LiveOrderBookEvents, type LiveOrderBookOptions, MAX_SERVER_WAIT_MS, type MaintenanceState, type Market, type MarketStatus, type MarketStatusEvent, MarketsResource, type Network, NetworksResource, NotFoundError, type Notification, type NotificationKind, OPERATIONS, type OperationAuth, type OperationId, type OperationInfo, type OperationScope, type Order, type OrderBook, type OrderBookUpdateData, type OrderBookUpdateEvent, type OrderEvent, type OrderSide, OrderStateUnknownError, type OrderStatus, type OrderType, PRIVATE_CHANNELS, type Page, type PlaceOrderRequest, type PlaceOrderResponse, type PlaceOrderResult, type PongFrame, type Pool, type PoolStatus, PoolsResource, type PublicTrade, type QueryOf, RateLimitError, RateLimiter, type RateLimiterOptions, type RateLimiterState, type ReconnectOptions, type RequestOptions, type ResyncReason, type RetryInfo, SUPPORTED_PROTOCOL_VERSION, ServerError, type ServerTime, type SessionRevokedData, type SessionRevokedEvent, type SnapshotSource, type SortDirection, type SubAccount, type SubscribeResult, type SubscribedFrame, type TickerUpdateEvent, type TimeInForce, type TradeNewEvent, TradingResource, type TriggerDirection, TypedEmitter, USER_AGENT, UnprocessableError, type UnsubscribedFrame, VERSION, ValidationError, WS_BOOK_DEPTH, WalletResource, type WebSocketConstructor, type WebSocketLike, type WelcomeFrame, type Withdrawal, type WithdrawalAddress, type WithdrawalStatus, type WithdrawalUpdatedEvent, type WsEvent, type WsLogger, assertAmountFields, type components, errorFromResponse, isAmount, isKnownErrorCode, isLocalHost, isRetryable, type operations, paginate, type paths };
package/dist/index.d.ts CHANGED
@@ -36,12 +36,6 @@ declare class ApiKeyAuthenticator implements Authenticator {
36
36
  toJSON(): Record<string, string>;
37
37
  }
38
38
 
39
- /**
40
- * Client-side token bucket. `CexyClient` defaults to 100 requests/minute without credentials
41
- * and 300/minute with an API key (the server allows about 120/min per IP and 600/min per
42
- * key; this keeps a margin). It adapts to `X-RateLimit-Limit`, `X-RateLimit-Remaining` and
43
- * `X-RateLimit-Reset` when the server sends them, and to 429 `Retry-After`.
44
- */
45
39
  interface RateLimiterOptions {
46
40
  requestsPerMinute: number;
47
41
  /** @internal for tests */
@@ -62,7 +56,10 @@ declare class RateLimiter {
62
56
  acquire(signal?: AbortSignal): Promise<void>;
63
57
  /** Adapts to the server's rate-limit headers. Never raises the configured limit. */
64
58
  update(headers: Headers): void;
65
- /** Blocks all requests for `ms` (used for 429 Retry-After). */
59
+ /**
60
+ * Blocks all requests for `ms` (used for 429 Retry-After and `X-RateLimit-Reset`). Server
61
+ * hints are untrusted: non-finite values are ignored and the block is capped at 120 s.
62
+ */
66
63
  blockFor(ms: number): void;
67
64
  }
68
65
 
@@ -135,10 +132,10 @@ interface RequestOptions {
135
132
  /** Overrides the client's `maxRetries`. */
136
133
  maxRetries?: number;
137
134
  /**
138
- * Mutations only: the `Idempotency-Key` to send. Generated automatically when absent.
139
- * The server honours it on pool join/exit; set it yourself to make a retry across process
140
- * restarts safe there. Orders and cancels do NOT honour it: their safety comes from
141
- * `client_order_id` (see `placeOrder`).
135
+ * Pool join/exit only: the `Idempotency-Key` to send (generated automatically when absent,
136
+ * and reused on every retry). The server honours it there; set it yourself to make a retry
137
+ * across process restarts safe. No other request sends the header: orders and cancels do
138
+ * not honour it, and their safety comes from `client_order_id` (see `placeOrder`).
142
139
  */
143
140
  idempotencyKey?: string;
144
141
  }
@@ -163,6 +160,8 @@ interface TransportConfig {
163
160
  userAgent: string | null;
164
161
  sleep: (ms: number, signal?: AbortSignal) => Promise<void>;
165
162
  random: () => number;
163
+ /** Milliseconds clock (default `Date.now`); injectable for tests. */
164
+ now?: () => number;
166
165
  onRetry?: ((info: RetryInfo) => void) | undefined;
167
166
  }
168
167
  interface CallSpec {
@@ -182,14 +181,17 @@ declare class Transport {
182
181
  readonly config: TransportConfig;
183
182
  constructor(config: TransportConfig);
184
183
  /**
185
- * Sends a request with the standard retry policy: GETs retry on retryable errors and
186
- * network failures. Mutations carry an `Idempotency-Key` reused on every attempt; the server
187
- * honours it on pool join/exit, which makes their retries safe. The other mutations routed
188
- * here (cancel-all) are naturally repeatable. `placeOrder` and `cancelOrder` use
184
+ * Sends a request with the standard retry policy: retryable errors and network failures are
185
+ * retried. Pool join/exit carry an `Idempotency-Key` reused on every attempt (the server
186
+ * honours it there, which makes their retries safe); the other mutations routed here
187
+ * (cancel-all) are naturally repeatable and send no key. `placeOrder` and `cancelOrder` use
189
188
  * `attempt()` with their own policies.
190
189
  */
191
190
  request(spec: CallSpec, opts?: RequestOptions): Promise<RawResponse>;
192
- /** Waits before retry number `attempt + 1`, honouring server hints. */
191
+ /**
192
+ * Waits before retry number `attempt + 1`, honouring server hints. A server hint longer than
193
+ * `MAX_SERVER_WAIT_MS` is not waited: `err` is thrown at once (it still carries the hint).
194
+ */
193
195
  backoff(op: OperationId, info: OperationInfo, attempt: number, err: unknown, idempotencyKey: string | undefined, signal?: AbortSignal): Promise<void>;
194
196
  /** Full-jitter exponential backoff, or the server's hint plus a little jitter. */
195
197
  retryDelay(attempt: number, err: unknown): number;
@@ -730,7 +732,11 @@ interface paths {
730
732
  put?: never;
731
733
  /**
732
734
  * Cancels every open order, optionally within one market.
733
- * @description Best-effort: a failure on one order does not stop the rest, and both outcomes are reported. A panic-button endpoint that stops at the first problem is worse than useless.
735
+ * @description Best-effort: a failure on one order does not stop the rest, and every outcome is reported. A panic-button endpoint that stops at the first problem is worse than useless.
736
+ *
737
+ * An order still being placed when the call starts (status `pending`, for as long as its own placement request runs) is waited for, up to 500 ms per call in total: cancelled if it opens, reported in `already_closed` if it fills or is refused, and in `failed` with code `INVALID_STATE` if it is still being placed at the deadline. Orders placed after the call starts are not part of it. At most 500 orders per call; `has_more` says there are others.
738
+ *
739
+ * Limited to 30 calls a minute per account, on top of the general request limit.
734
740
  */
735
741
  post: operations["cancel_all"];
736
742
  delete?: never;
@@ -1037,12 +1043,31 @@ interface components {
1037
1043
  /** @description Limit the cancellation to one market. Omitted or `null`, every market's open orders are cancelled. */
1038
1044
  symbol?: string | null;
1039
1045
  };
1040
- /** @description What a bulk cancellation achieved. */
1046
+ /**
1047
+ * @description What a bulk cancellation achieved.
1048
+ *
1049
+ * Every order the call handled is in exactly one of `cancelled`, `already_closed` and `failed`.
1050
+ */
1041
1051
  CancelAllResponse: {
1052
+ /** @description Orders that closed on their own (filled, rejected, cancelled elsewhere) before this call reached them. Nothing was done to them, and they are not failures. */
1053
+ already_closed: string[];
1042
1054
  /** @description Orders cancelled. */
1043
1055
  cancelled: string[];
1044
- /** @description Orders that could not be cancelled. Each failure is logged server-side. */
1056
+ /** @description Orders that could not be cancelled in this call. Check `failures` for why, then refresh or call again. */
1045
1057
  failed: string[];
1058
+ /** @description Why each order in `failed` could not be cancelled. */
1059
+ failures: components["schemas"]["CancelFailureResponse"][];
1060
+ /** @description More open orders exist than one call handles (500). Call again. */
1061
+ has_more: boolean;
1062
+ };
1063
+ /** @description Why one order could not be cancelled. */
1064
+ CancelFailureResponse: {
1065
+ /** @description The error code of the attempt, as in any error response: e.g. `INVALID_STATE` for an order still being placed when the wait ran out, or `MARKET_UNAVAILABLE`. */
1066
+ code: string;
1067
+ /** @description Its message. */
1068
+ message: string;
1069
+ /** @description The order. */
1070
+ order_id: string;
1046
1071
  };
1047
1072
  /**
1048
1073
  * @description Candle/kline intervals for market data.
@@ -2877,6 +2902,24 @@ interface operations {
2877
2902
  };
2878
2903
  };
2879
2904
  };
2905
+ /** @description No such market */
2906
+ 404: {
2907
+ headers: {
2908
+ [name: string]: unknown;
2909
+ };
2910
+ content: {
2911
+ "application/json": components["schemas"]["ErrorResponse"];
2912
+ };
2913
+ };
2914
+ /** @description Over 30 calls a minute for this account; `details.retry_after_seconds` says when to retry */
2915
+ 429: {
2916
+ headers: {
2917
+ [name: string]: unknown;
2918
+ };
2919
+ content: {
2920
+ "application/json": components["schemas"]["ErrorResponse"];
2921
+ };
2922
+ };
2880
2923
  };
2881
2924
  };
2882
2925
  order_history: {
@@ -3181,6 +3224,26 @@ type AssetNetwork = S["AssetNetworkResponse"];
3181
3224
  type Balance = S["BalanceResponse"];
3182
3225
  type CancelAllRequest = S["CancelAllRequest"];
3183
3226
  type CancelAllResult = S["CancelAllResponse"];
3227
+ /** Why one order could not be cancelled (`CancelAllResult.failures`). */
3228
+ type CancelFailure = S["CancelFailureResponse"];
3229
+ /** Why a `cancelAll({ ..., untilDone: true })` loop ended. */
3230
+ type CancelAllStopReason = "done" | "max_rounds" | "time_budget";
3231
+ /**
3232
+ * Merged result of a `cancelAll({ ..., untilDone: true })` loop. Every order is in exactly one
3233
+ * of `cancelled`, `already_closed` and `failed`, in its latest state; `has_more` is the last
3234
+ * round's.
3235
+ */
3236
+ interface CancelAllUntilDoneResult extends CancelAllResult {
3237
+ /** Number of cancel-all calls made. */
3238
+ rounds: number;
3239
+ /** `done`: nothing left to retry; otherwise the loop's limit that ended it. */
3240
+ stopped: CancelAllStopReason;
3241
+ /**
3242
+ * The error code of the last round when that round failed with a retryable error (e.g.
3243
+ * `RATE_LIMITED`, `SERVICE_UNAVAILABLE`, `CONNECTION_ERROR`); absent when it succeeded.
3244
+ */
3245
+ last_error_code?: string;
3246
+ }
3184
3247
  type Candle = S["CandleResponse"];
3185
3248
  type CandleInterval = S["CandleInterval"];
3186
3249
  type DepositAddress = S["DepositAddressResponse"];
@@ -3344,6 +3407,14 @@ interface PlaceOrderResult extends PlaceOrderResponse {
3344
3407
  */
3345
3408
  interface CancelAllParams {
3346
3409
  symbol: string | null;
3410
+ /**
3411
+ * Repeat the call until nothing is left to retry (see `cancelAll`). Default false: one call.
3412
+ */
3413
+ untilDone?: boolean;
3414
+ /** With `untilDone`: at most this many calls. Default 20. */
3415
+ maxRounds?: number;
3416
+ /** With `untilDone`: stop before a wait would take the loop to this many ms. Default 120000. */
3417
+ timeBudgetMs?: number;
3347
3418
  }
3348
3419
  declare class TradingResource extends Resource {
3349
3420
  #private;
@@ -3361,7 +3432,7 @@ declare class TradingResource extends Resource {
3361
3432
  *
3362
3433
  * Retry safety rests on `client_order_id` (generated as a UUID when absent): it is unique
3363
3434
  * per account and the server refuses a repeat before any funds move. The server does NOT
3364
- * honour `Idempotency-Key` on orders (the header is sent but gives no protection). After an
3435
+ * honour `Idempotency-Key` on orders, so none is sent. After an
3365
3436
  * ambiguous failure (network error, timeout or 5xx) the SDK first looks the order up by
3366
3437
  * `client_order_id` and returns it if it exists (`recovered: true`); only if it does not
3367
3438
  * exist does it send the order again, with the same `client_order_id`, so a late-arriving
@@ -3380,12 +3451,35 @@ declare class TradingResource extends Resource {
3380
3451
  * Cancels every open order in one market: `cancelAll({ symbol: "BTC/USDT" })`.
3381
3452
  * To cancel across ALL markets, pass `symbol: null` explicitly: `cancelAll({ symbol: null })`.
3382
3453
  * Omitting `symbol` is an error, so an account-wide cancel never happens by accident
3383
- * (the server itself treats `{}` as every market).
3454
+ * (the server itself treats `{}` as every market). An unknown symbol throws `NotFoundError`.
3455
+ *
3456
+ * One call handles at most 500 orders. Every order it handled is in exactly one list:
3457
+ * `cancelled`; `already_closed` (it filled, was refused or was cancelled elsewhere first:
3458
+ * not an error); or `failed`, with the reason in `failures` (`INVALID_STATE` for an order
3459
+ * still being placed when the server's 500 ms wait ran out). `has_more` says more orders
3460
+ * remain: call again.
3384
3461
  *
3385
- * The server limits cancel-all to 30 calls per minute per account. It is naturally
3386
- * repeatable, so it is retried after network errors; a retry reports only what that retry
3387
- * cancelled.
3462
+ * With `untilDone: true` the SDK does that for you. It repeats while `has_more` is true or a
3463
+ * failure is `INVALID_STATE` / `SERVICE_UNAVAILABLE`. After a call that made no progress it
3464
+ * waits 1, 2, 4, 8 and then 15 s, starting over after any progress. It stops after
3465
+ * `maxRounds` calls or before a wait would pass `timeBudgetMs`, and returns the merged
3466
+ * result with `rounds` and `stopped`. Other failure codes are returned, never retried.
3467
+ * In this mode every round is exactly one HTTP request (the loop owns the retries, so it
3468
+ * never sends more than `maxRounds` requests): a 429 round waits the server's Retry-After
3469
+ * (without advancing the backoff), another retryable error (5xx, network) takes the next
3470
+ * backoff step, and a wait that would pass the budget ends the loop with
3471
+ * `stopped: "time_budget"` and `last_error_code`. A non-retryable error (e.g. a key without
3472
+ * the trade scope) throws `CancelAllInterruptedError`, which carries the error and the
3473
+ * partial result.
3474
+ *
3475
+ * The server allows 30 cancel-all calls per minute per account. A single call (without
3476
+ * `untilDone`) follows the normal retry policy: a 429 is retried after its Retry-After (up to
3477
+ * 120 s; a longer one fails at once) and network errors are retried, since the call is
3478
+ * naturally repeatable; a retry reports only what that retry did. No Idempotency-Key is sent.
3388
3479
  */
3480
+ cancelAll(params: CancelAllParams & {
3481
+ untilDone: true;
3482
+ }, opts?: RequestOptions): Promise<CancelAllUntilDoneResult>;
3389
3483
  cancelAll(params: CancelAllParams, opts?: RequestOptions): Promise<CancelAllResult>;
3390
3484
  }
3391
3485
 
@@ -3431,6 +3525,16 @@ declare class OrderStateUnknownError extends CexyError {
3431
3525
  readonly clientOrderId: string;
3432
3526
  constructor(clientOrderId: string, cause: unknown);
3433
3527
  }
3528
+ /**
3529
+ * A `cancelAll({ ..., untilDone: true })` loop hit an error it does not retry (for example
3530
+ * `ForbiddenError` for a key without the trade scope). `error` is that error; `partial` is what
3531
+ * the earlier rounds did, in the same shape as the loop's normal result.
3532
+ */
3533
+ declare class CancelAllInterruptedError extends CexyError {
3534
+ readonly error: unknown;
3535
+ readonly partial: CancelAllUntilDoneResult;
3536
+ constructor(error: unknown, partial: CancelAllUntilDoneResult);
3537
+ }
3434
3538
  interface CexyApiErrorInit {
3435
3539
  status: number;
3436
3540
  code: ErrorCode;
@@ -3484,8 +3588,23 @@ declare class RateLimitError extends CexyApiError {
3484
3588
  /** 5xx */
3485
3589
  declare class ServerError extends CexyApiError {
3486
3590
  }
3487
- /** True for codes listed in errors.yaml. */
3591
+ /**
3592
+ * Codes the SDK itself sets on a `CexyApiError`; the API never sends them, so they are not in
3593
+ * errors.yaml and `isKnownErrorCode()` returns false for them.
3594
+ * - `UNEXPECTED_REDIRECT`: the server answered with a 3xx. The SDK never follows redirects (the
3595
+ * credentials would go to the redirect target); not retryable.
3596
+ */
3597
+ declare const CLIENT_ERROR_CODES: {
3598
+ readonly UNEXPECTED_REDIRECT: "UNEXPECTED_REDIRECT";
3599
+ };
3600
+ /** True for codes listed in errors.yaml (server codes; see `CLIENT_ERROR_CODES` for the SDK's own). */
3488
3601
  declare function isKnownErrorCode(code: string): code is KnownErrorCode;
3602
+ /**
3603
+ * The longest wait the SDK accepts from a server hint (`Retry-After`, `retry_after_seconds`,
3604
+ * `X-RateLimit-Reset`): 120 s. A longer hint is never waited; the call fails at once instead
3605
+ * (see `Transport.backoff`), and the client-side rate limiter caps its block at this value.
3606
+ */
3607
+ declare const MAX_SERVER_WAIT_MS = 120000;
3489
3608
  /**
3490
3609
  * Builds the right error subclass for an HTTP error response.
3491
3610
  * - A known code maps by HTTP status (401 -> AuthenticationError, 403 -> ForbiddenError, ...).
@@ -3844,7 +3963,12 @@ interface CexyClientOptions {
3844
3963
  timeoutMs?: number;
3845
3964
  /** Retries after the first attempt for retryable failures. Default 3. */
3846
3965
  maxRetries?: number;
3847
- /** A `fetch` implementation. Default: the global `fetch` (Node 22+, browsers). */
3966
+ /**
3967
+ * A `fetch` implementation. Default: the global `fetch` (Node 22+, browsers).
3968
+ * It must honour `redirect: "manual"` (the SDK never follows redirects). A fetch that follows
3969
+ * them anyway has already sent the credentials to the redirect target by the time the SDK sees
3970
+ * `response.redirected` and throws `UNEXPECTED_REDIRECT`.
3971
+ */
3848
3972
  fetch?: FetchLike;
3849
3973
  /**
3850
3974
  * Client-side rate limit in requests per minute, or `false` to disable. Default 100/min
@@ -3866,6 +3990,8 @@ interface CexyClientOptions {
3866
3990
  sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
3867
3991
  /** @internal Deterministic jitter in tests. */
3868
3992
  random?: () => number;
3993
+ /** @internal Replace the clock in tests (milliseconds). */
3994
+ now?: () => number;
3869
3995
  }
3870
3996
  /**
3871
3997
  * CEXY.io REST client.
@@ -3925,11 +4051,11 @@ declare function isAmount(value: unknown): value is Amount;
3925
4051
  declare function assertAmountFields(body: Record<string, unknown>, fields: readonly string[], context: string): void;
3926
4052
 
3927
4053
  /** SDK version, kept in sync with package.json (a test enforces this). */
3928
- declare const VERSION = "0.1.0-dev.3";
4054
+ declare const VERSION = "0.1.0-dev.5";
3929
4055
  /** Default User-Agent product token. */
3930
- declare const USER_AGENT = "cexy-typescript/0.1.0-dev.3";
4056
+ declare const USER_AGENT = "cexy-typescript/0.1.0-dev.5";
3931
4057
 
3932
4058
  /** True for loopback hosts, the only ones where plain-text transport may be allowed. */
3933
4059
  declare function isLocalHost(hostname: string): boolean;
3934
4060
 
3935
- export { AccountResource, type Amount, type ApiKey, ApiKeyAuthenticator, type ApiScope, type Asset, type AssetNetwork, AssetsResource, type AuthRequest, type AuthResult, type AuthenticatedFrame, AuthenticationError, type Authenticator, type Balance, type BalanceUpdatedEvent, type BookLevel, type CancelAllParams, type CancelAllRequest, type CancelAllResult, type Candle, type CandleInterval, CexyApiError, type CexyApiErrorInit, CexyClient, type CexyClientOptions, CexyConfigError, CexyConnectionError, CexyError, CexyTimeoutError, CexyWebSocket, CexyWebSocketError, type CexyWebSocketEvents, type CexyWebSocketOptions, type CloseInfo, ConflictError, type CursorParams, DEFAULT_BASE_URL, DEFAULT_RPM_ANONYMOUS, DEFAULT_RPM_WITH_KEY, DEFAULT_WS_URL, type Deposit, type DepositAddress, type DepositEvent, type DepositStatus, type ErrorBody, type ErrorCode, type ErrorFrame, type EventMap, type ExchangeConfig, type ExitPoolRequest, type ExitPoolResult, ExportsResource, type FeeSchedule, FeesResource, type FetchLike, type Fill, ForbiddenError, InvalidAmountError, type IterateOptions, type JoinPoolRequest, type JoinPoolResult, JurisdictionBlockedError, KNOWN_EVENT_TYPES, type KnownErrorCode, type LedgerEntry, type LedgerEntryKind, type LiquidityRole, type Listener, LiveOrderBook, type LiveOrderBookEvents, type LiveOrderBookOptions, type MaintenanceState, type Market, type MarketStatus, type MarketStatusEvent, MarketsResource, type Network, NetworksResource, NotFoundError, type Notification, type NotificationKind, OPERATIONS, type OperationAuth, type OperationId, type OperationInfo, type OperationScope, type Order, type OrderBook, type OrderBookUpdateData, type OrderBookUpdateEvent, type OrderEvent, type OrderSide, OrderStateUnknownError, type OrderStatus, type OrderType, PRIVATE_CHANNELS, type Page, type PlaceOrderRequest, type PlaceOrderResponse, type PlaceOrderResult, type PongFrame, type Pool, type PoolStatus, PoolsResource, type PublicTrade, type QueryOf, RateLimitError, RateLimiter, type RateLimiterOptions, type RateLimiterState, type ReconnectOptions, type RequestOptions, type ResyncReason, type RetryInfo, SUPPORTED_PROTOCOL_VERSION, ServerError, type ServerTime, type SessionRevokedData, type SessionRevokedEvent, type SnapshotSource, type SortDirection, type SubAccount, type SubscribeResult, type SubscribedFrame, type TickerUpdateEvent, type TimeInForce, type TradeNewEvent, TradingResource, type TriggerDirection, TypedEmitter, USER_AGENT, UnprocessableError, type UnsubscribedFrame, VERSION, ValidationError, WS_BOOK_DEPTH, WalletResource, type WebSocketConstructor, type WebSocketLike, type WelcomeFrame, type Withdrawal, type WithdrawalAddress, type WithdrawalStatus, type WithdrawalUpdatedEvent, type WsEvent, type WsLogger, assertAmountFields, type components, errorFromResponse, isAmount, isKnownErrorCode, isLocalHost, isRetryable, type operations, paginate, type paths };
4061
+ export { AccountResource, type Amount, type ApiKey, ApiKeyAuthenticator, type ApiScope, type Asset, type AssetNetwork, AssetsResource, type AuthRequest, type AuthResult, type AuthenticatedFrame, AuthenticationError, type Authenticator, type Balance, type BalanceUpdatedEvent, type BookLevel, CLIENT_ERROR_CODES, CancelAllInterruptedError, type CancelAllParams, type CancelAllRequest, type CancelAllResult, type CancelAllStopReason, type CancelAllUntilDoneResult, type CancelFailure, type Candle, type CandleInterval, CexyApiError, type CexyApiErrorInit, CexyClient, type CexyClientOptions, CexyConfigError, CexyConnectionError, CexyError, CexyTimeoutError, CexyWebSocket, CexyWebSocketError, type CexyWebSocketEvents, type CexyWebSocketOptions, type CloseInfo, ConflictError, type CursorParams, DEFAULT_BASE_URL, DEFAULT_RPM_ANONYMOUS, DEFAULT_RPM_WITH_KEY, DEFAULT_WS_URL, type Deposit, type DepositAddress, type DepositEvent, type DepositStatus, type ErrorBody, type ErrorCode, type ErrorFrame, type EventMap, type ExchangeConfig, type ExitPoolRequest, type ExitPoolResult, ExportsResource, type FeeSchedule, FeesResource, type FetchLike, type Fill, ForbiddenError, InvalidAmountError, type IterateOptions, type JoinPoolRequest, type JoinPoolResult, JurisdictionBlockedError, KNOWN_EVENT_TYPES, type KnownErrorCode, type LedgerEntry, type LedgerEntryKind, type LiquidityRole, type Listener, LiveOrderBook, type LiveOrderBookEvents, type LiveOrderBookOptions, MAX_SERVER_WAIT_MS, type MaintenanceState, type Market, type MarketStatus, type MarketStatusEvent, MarketsResource, type Network, NetworksResource, NotFoundError, type Notification, type NotificationKind, OPERATIONS, type OperationAuth, type OperationId, type OperationInfo, type OperationScope, type Order, type OrderBook, type OrderBookUpdateData, type OrderBookUpdateEvent, type OrderEvent, type OrderSide, OrderStateUnknownError, type OrderStatus, type OrderType, PRIVATE_CHANNELS, type Page, type PlaceOrderRequest, type PlaceOrderResponse, type PlaceOrderResult, type PongFrame, type Pool, type PoolStatus, PoolsResource, type PublicTrade, type QueryOf, RateLimitError, RateLimiter, type RateLimiterOptions, type RateLimiterState, type ReconnectOptions, type RequestOptions, type ResyncReason, type RetryInfo, SUPPORTED_PROTOCOL_VERSION, ServerError, type ServerTime, type SessionRevokedData, type SessionRevokedEvent, type SnapshotSource, type SortDirection, type SubAccount, type SubscribeResult, type SubscribedFrame, type TickerUpdateEvent, type TimeInForce, type TradeNewEvent, TradingResource, type TriggerDirection, TypedEmitter, USER_AGENT, UnprocessableError, type UnsubscribedFrame, VERSION, ValidationError, WS_BOOK_DEPTH, WalletResource, type WebSocketConstructor, type WebSocketLike, type WelcomeFrame, type Withdrawal, type WithdrawalAddress, type WithdrawalStatus, type WithdrawalUpdatedEvent, type WsEvent, type WsLogger, assertAmountFields, type components, errorFromResponse, isAmount, isKnownErrorCode, isLocalHost, isRetryable, type operations, paginate, type paths };