@cexyio/cexy 0.1.0-dev.4 → 0.1.0-dev.6

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.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 */
@@ -60,9 +54,17 @@ declare class RateLimiter {
60
54
  get state(): RateLimiterState;
61
55
  /** Waits until a request may be sent, then takes a token. */
62
56
  acquire(signal?: AbortSignal): Promise<void>;
57
+ /**
58
+ * How long `acquire()` would wait right now, in ms (0 when a request may go at once). Lets a
59
+ * caller with a time budget, such as the cancelAll untilDone loop, count the limiter's wait.
60
+ */
61
+ pendingWaitMs(): number;
63
62
  /** Adapts to the server's rate-limit headers. Never raises the configured limit. */
64
63
  update(headers: Headers): void;
65
- /** Blocks all requests for `ms` (used for 429 Retry-After). */
64
+ /**
65
+ * Blocks all requests for `ms` (used for 429 Retry-After and `X-RateLimit-Reset`). Server
66
+ * hints are untrusted: non-finite values are ignored and the block is capped at 120 s.
67
+ */
66
68
  blockFor(ms: number): void;
67
69
  }
68
70
 
@@ -135,10 +137,10 @@ interface RequestOptions {
135
137
  /** Overrides the client's `maxRetries`. */
136
138
  maxRetries?: number;
137
139
  /**
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`).
140
+ * Pool join/exit only: the `Idempotency-Key` to send (generated automatically when absent,
141
+ * and reused on every retry). The server honours it there; set it yourself to make a retry
142
+ * across process restarts safe. No other request sends the header: orders and cancels do
143
+ * not honour it, and their safety comes from `client_order_id` (see `placeOrder`).
142
144
  */
143
145
  idempotencyKey?: string;
144
146
  }
@@ -184,14 +186,17 @@ declare class Transport {
184
186
  readonly config: TransportConfig;
185
187
  constructor(config: TransportConfig);
186
188
  /**
187
- * Sends a request with the standard retry policy: GETs retry on retryable errors and
188
- * network failures. Mutations carry an `Idempotency-Key` reused on every attempt; the server
189
- * honours it on pool join/exit, which makes their retries safe. The other mutations routed
190
- * here (cancel-all) are naturally repeatable. `placeOrder` and `cancelOrder` use
189
+ * Sends a request with the standard retry policy: retryable errors and network failures are
190
+ * retried. Pool join/exit carry an `Idempotency-Key` reused on every attempt (the server
191
+ * honours it there, which makes their retries safe); the other mutations routed here
192
+ * (cancel-all) are naturally repeatable and send no key. `placeOrder` and `cancelOrder` use
191
193
  * `attempt()` with their own policies.
192
194
  */
193
195
  request(spec: CallSpec, opts?: RequestOptions): Promise<RawResponse>;
194
- /** Waits before retry number `attempt + 1`, honouring server hints. */
196
+ /**
197
+ * Waits before retry number `attempt + 1`, honouring server hints. A server hint longer than
198
+ * `MAX_SERVER_WAIT_MS` is not waited: `err` is thrown at once (it still carries the hint).
199
+ */
195
200
  backoff(op: OperationId, info: OperationInfo, attempt: number, err: unknown, idempotencyKey: string | undefined, signal?: AbortSignal): Promise<void>;
196
201
  /** Full-jitter exponential backoff, or the server's hint plus a little jitter. */
197
202
  retryDelay(attempt: number, err: unknown): number;
@@ -731,8 +736,10 @@ interface paths {
731
736
  get?: never;
732
737
  put?: never;
733
738
  /**
734
- * Cancels every open order, optionally within one market.
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.
739
+ * Cancels every open order, and every stop order that has not triggered, optionally within
740
+ * @description one market.
741
+ *
742
+ * 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. A stop waiting for its trigger (`pending_trigger`) is cancelled too and its reservation released, so nothing fires into the market after the call.
736
743
  *
737
744
  * 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
745
  *
@@ -1117,6 +1124,11 @@ interface components {
1117
1124
  /** @description Network code. */
1118
1125
  network: string;
1119
1126
  };
1127
+ /**
1128
+ * @description Unique identifier of a deposit.
1129
+ * @example 507f1f77bcf86cd799439011
1130
+ */
1131
+ DepositId: string;
1120
1132
  /** @description A deposit. */
1121
1133
  DepositResponse: {
1122
1134
  /** @description Address that received it. */
@@ -1198,7 +1210,7 @@ interface components {
1198
1210
  * Serialized as `SCREAMING_SNAKE_CASE`. Adding a variant is backwards-compatible; renaming or removing one is a breaking API change.
1199
1211
  * @enum {string}
1200
1212
  */
1201
- ErrorCode: "VALIDATION_FAILED" | "MALFORMED_REQUEST" | "INVALID_CURSOR" | "PRECISION_EXCEEDED" | "BELOW_MINIMUM" | "ABOVE_MAXIMUM" | "INVALID_ADDRESS" | "MEMO_REQUIRED" | "UNAUTHENTICATED" | "INVALID_CREDENTIALS" | "TOKEN_EXPIRED" | "SESSION_REVOKED" | "TWO_FACTOR_REQUIRED" | "TWO_FACTOR_INVALID" | "FRESH_TWO_FACTOR_REQUIRED" | "FORBIDDEN" | "API_KEY_NOT_ALLOWED" | "FUTURES_RESTRICTED" | "ACCOUNT_FROZEN" | "ACCOUNT_ON_HOLD" | "EMAIL_NOT_VERIFIED" | "REGION_BLOCKED" | "JURISDICTION_BLOCKED" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "ALREADY_EXISTS" | "INVALID_STATE" | "IDEMPOTENCY_KEY_CONFLICT" | "WINDOW_OPEN" | "EVIDENCE_CONTRADICTS" | "AMOUNT_MISMATCH" | "CONCURRENT_MODIFICATION" | "INSUFFICIENT_FUNDS" | "INSUFFICIENT_FEE_FUNDS" | "MARKET_UNAVAILABLE" | "DEPOSIT_DISABLED" | "WITHDRAWAL_DISABLED" | "SELF_TRADE_BLOCKED" | "LIMIT_EXCEEDED" | "RATE_LIMITED" | "INTERNAL" | "SERVICE_UNAVAILABLE" | "UNDER_MAINTENANCE" | "ENGINE_OVERLOADED";
1213
+ ErrorCode: "VALIDATION_FAILED" | "MALFORMED_REQUEST" | "INVALID_CURSOR" | "PRECISION_EXCEEDED" | "BELOW_MINIMUM" | "ABOVE_MAXIMUM" | "INVALID_ADDRESS" | "MEMO_REQUIRED" | "UNAUTHENTICATED" | "INVALID_CREDENTIALS" | "TOKEN_EXPIRED" | "SESSION_REVOKED" | "TWO_FACTOR_REQUIRED" | "TWO_FACTOR_INVALID" | "FRESH_TWO_FACTOR_REQUIRED" | "FORBIDDEN" | "API_KEY_NOT_ALLOWED" | "FUTURES_RESTRICTED" | "ACCOUNT_FROZEN" | "ACCOUNT_ON_HOLD" | "EMAIL_NOT_VERIFIED" | "REGION_BLOCKED" | "JURISDICTION_BLOCKED" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "ALREADY_EXISTS" | "INVALID_STATE" | "IDEMPOTENCY_KEY_CONFLICT" | "WINDOW_OPEN" | "EVIDENCE_CONTRADICTS" | "AMOUNT_MISMATCH" | "CONCURRENT_MODIFICATION" | "INSUFFICIENT_FUNDS" | "INSUFFICIENT_FEE_FUNDS" | "MARKET_UNAVAILABLE" | "DEPOSIT_DISABLED" | "WITHDRAWAL_DISABLED" | "SELF_TRADE_BLOCKED" | "LIMIT_EXCEEDED" | "PRICE_UNAVAILABLE" | "RATE_LIMITED" | "INTERNAL" | "SERVICE_UNAVAILABLE" | "UNDER_MAINTENANCE" | "ENGINE_OVERLOADED";
1202
1214
  /** @description The top-level error envelope. */
1203
1215
  ErrorResponse: {
1204
1216
  error: components["schemas"]["ErrorBody"];
@@ -1309,14 +1321,15 @@ interface components {
1309
1321
  /** @description Trade id. */
1310
1322
  trade_id: string;
1311
1323
  };
1324
+ /**
1325
+ * @description Unique identifier of a futures collateral transfer.
1326
+ * @example 507f1f77bcf86cd799439011
1327
+ */
1328
+ FuturesTransferId: string;
1312
1329
  /** @description Adds liquidity to a pool. */
1313
1330
  JoinPoolRequest: {
1314
1331
  base_amount: components["schemas"]["Amount"];
1315
- /**
1316
- * @description How far, in percent, the offered ratio may sit from the pool's own before the request is refused rather than repriced. Defaults to 1%.
1317
- * @example 1
1318
- */
1319
- max_ratio_deviation_percent?: string | null;
1332
+ max_ratio_deviation_percent?: components["schemas"]["Amount"] | null;
1320
1333
  quote_amount: components["schemas"]["Amount"];
1321
1334
  };
1322
1335
  /** @description What a join produced. */
@@ -1330,7 +1343,7 @@ interface components {
1330
1343
  * @description What a ledger entry records.
1331
1344
  * @enum {string}
1332
1345
  */
1333
- LedgerEntryKind: "deposit" | "deposit_reversal" | "withdrawal_debit" | "withdrawal_fee" | "withdrawal_fee_reserve" | "withdrawal_release" | "withdrawal_fee_release" | "order_reserve" | "withdrawal_reserve" | "order_release" | "trade_debit" | "trade_credit" | "trade_fee" | "transfer_out" | "transfer_in" | "adjustment_credit" | "adjustment_debit" | "rebate" | "pool_join" | "pool_exit" | "futures_transfer_reserve" | "futures_transfer_release" | "futures_collateral_sent" | "futures_collateral_returned" | "trade_fee_revenue" | "withdrawal_fee_revenue" | "futures_transfer_fee_revenue" | "futures_hyperliquid_cost" | "futures_transfer_discrepancy" | "exchange_capital";
1346
+ LedgerEntryKind: "deposit" | "deposit_reversal" | "withdrawal_debit" | "withdrawal_fee" | "withdrawal_fee_reserve" | "withdrawal_release" | "withdrawal_fee_release" | "order_reserve" | "withdrawal_reserve" | "order_release" | "trade_debit" | "trade_credit" | "trade_fee" | "transfer_out" | "transfer_in" | "transfer_in_held" | "transfer_release" | "transfer_reversal" | "adjustment_credit" | "adjustment_debit" | "rebate" | "pool_join" | "pool_exit" | "futures_transfer_reserve" | "futures_transfer_release" | "futures_collateral_sent" | "futures_collateral_returned" | "trade_fee_revenue" | "withdrawal_fee_revenue" | "withdrawal_refund" | "withdrawal_fee_revenue_reversal" | "futures_transfer_fee_revenue" | "futures_hyperliquid_cost" | "futures_transfer_discrepancy" | "exchange_capital";
1334
1347
  /** @description One entry from the account's ledger. */
1335
1348
  LedgerEntryResponse: {
1336
1349
  /** @description Asset symbol. */
@@ -1347,14 +1360,55 @@ interface components {
1347
1360
  kind: components["schemas"]["LedgerEntryKind"];
1348
1361
  locked_delta: components["schemas"]["Amount"];
1349
1362
  pending_delta: components["schemas"]["Amount"];
1350
- /** @description What caused the entry. */
1351
- reference: unknown;
1363
+ reference: components["schemas"]["LedgerReference"];
1352
1364
  /**
1353
1365
  * Format: int64
1354
1366
  * @description Position in this account's history for this asset.
1355
1367
  */
1356
1368
  sequence: number;
1357
1369
  };
1370
+ /** @description What caused a ledger entry: one kind of cause per variant, told apart by `type`. */
1371
+ LedgerReference: {
1372
+ deposit_id: components["schemas"]["DepositId"];
1373
+ /** @enum {string} */
1374
+ type: "deposit";
1375
+ } | {
1376
+ /** @enum {string} */
1377
+ type: "withdrawal";
1378
+ withdrawal_id: components["schemas"]["WithdrawalId"];
1379
+ } | {
1380
+ order_id: components["schemas"]["OrderId"];
1381
+ /** @enum {string} */
1382
+ type: "order";
1383
+ } | {
1384
+ order_id: components["schemas"]["OrderId"];
1385
+ trade_id: components["schemas"]["TradeId"];
1386
+ /** @enum {string} */
1387
+ type: "trade";
1388
+ } | {
1389
+ counterparty_user_id: components["schemas"]["UserId"];
1390
+ /** @description Shared reference linking both halves. */
1391
+ transfer_ref: string;
1392
+ /** @enum {string} */
1393
+ type: "transfer";
1394
+ } | {
1395
+ operator_user_id: components["schemas"]["UserId"];
1396
+ /** @enum {string} */
1397
+ type: "adjustment";
1398
+ } | {
1399
+ pool_id: components["schemas"]["PoolId"];
1400
+ /** @enum {string} */
1401
+ type: "pool";
1402
+ } | {
1403
+ futures_transfer_id: components["schemas"]["FuturesTransferId"];
1404
+ /** @enum {string} */
1405
+ type: "futures_transfer";
1406
+ } | {
1407
+ /** @description Short machine-readable cause. */
1408
+ cause: string;
1409
+ /** @enum {string} */
1410
+ type: "system";
1411
+ };
1358
1412
  /**
1359
1413
  * @description Whether a fill added liquidity (maker) or removed it (taker).
1360
1414
  * @enum {string}
@@ -1514,6 +1568,11 @@ interface components {
1514
1568
  */
1515
1569
  timestamp: string;
1516
1570
  };
1571
+ /**
1572
+ * @description Unique identifier of an order.
1573
+ * @example 507f1f77bcf86cd799439011
1574
+ */
1575
+ OrderId: string;
1517
1576
  /** @description An order. */
1518
1577
  OrderResponse: {
1519
1578
  average_price?: components["schemas"]["Amount"] | null;
@@ -1616,6 +1675,11 @@ interface components {
1616
1675
  fills: components["schemas"]["FillResponse"][];
1617
1676
  order: components["schemas"]["OrderResponse"];
1618
1677
  };
1678
+ /**
1679
+ * @description Unique identifier of a liquidity pool.
1680
+ * @example 507f1f77bcf86cd799439011
1681
+ */
1682
+ PoolId: string;
1619
1683
  /**
1620
1684
  * @description A pool as a client sees it.
1621
1685
  *
@@ -1717,6 +1781,11 @@ interface components {
1717
1781
  * @enum {string}
1718
1782
  */
1719
1783
  TimeInForce: "gtc" | "ioc" | "fok" | "post_only";
1784
+ /**
1785
+ * @description Unique identifier of a trade.
1786
+ * @example 507f1f77bcf86cd799439011
1787
+ */
1788
+ TradeId: string;
1720
1789
  /**
1721
1790
  * @description Which way the price must move for a stop to fire.
1722
1791
  *
@@ -1724,6 +1793,11 @@ interface components {
1724
1793
  * @enum {string}
1725
1794
  */
1726
1795
  TriggerDirection: "above" | "below";
1796
+ /**
1797
+ * @description Unique identifier of a user account.
1798
+ * @example 507f1f77bcf86cd799439011
1799
+ */
1800
+ UserId: string;
1727
1801
  /** @description A saved withdrawal address. */
1728
1802
  WithdrawalAddressResponse: {
1729
1803
  /** @description The address. */
@@ -1762,6 +1836,11 @@ interface components {
1762
1836
  reason?: string | null;
1763
1837
  status: components["schemas"]["WithdrawalStatus"];
1764
1838
  };
1839
+ /**
1840
+ * @description Unique identifier of a withdrawal.
1841
+ * @example 507f1f77bcf86cd799439011
1842
+ */
1843
+ WithdrawalId: string;
1765
1844
  /** @description A withdrawal. */
1766
1845
  WithdrawalResponse: {
1767
1846
  /** @description Destination. */
@@ -1818,7 +1897,7 @@ interface components {
1818
1897
  * against the chain.
1819
1898
  * @enum {string}
1820
1899
  */
1821
- WithdrawalStatus: "requested" | "pending_approval" | "approved" | "processing" | "broadcast" | "completed" | "rejected" | "cancelled" | "failed" | "broadcast_unknown";
1900
+ WithdrawalStatus: "requested" | "pending_approval" | "approved" | "processing" | "broadcast" | "completed" | "rejected" | "cancelled" | "failed" | "broadcast_unknown" | "reverted";
1822
1901
  };
1823
1902
  responses: never;
1824
1903
  parameters: never;
@@ -3238,6 +3317,11 @@ interface CancelAllUntilDoneResult extends CancelAllResult {
3238
3317
  rounds: number;
3239
3318
  /** `done`: nothing left to retry; otherwise the loop's limit that ended it. */
3240
3319
  stopped: CancelAllStopReason;
3320
+ /**
3321
+ * The error code of the last round when that round failed with a retryable error (e.g.
3322
+ * `RATE_LIMITED`, `SERVICE_UNAVAILABLE`, `CONNECTION_ERROR`); absent when it succeeded.
3323
+ */
3324
+ last_error_code?: string;
3241
3325
  }
3242
3326
  type Candle = S["CandleResponse"];
3243
3327
  type CandleInterval = S["CandleInterval"];
@@ -3251,7 +3335,31 @@ type FeeSchedule = S["FeeScheduleResponse"];
3251
3335
  type Fill = S["FillResponse"];
3252
3336
  type JoinPoolRequest = S["JoinPoolRequest"];
3253
3337
  type JoinPoolResult = S["JoinPoolResponse"];
3254
- type LedgerEntry = S["LedgerEntryResponse"];
3338
+ /** A ledger entry. `reference` also accepts cause types this SDK version does not know yet. */
3339
+ type LedgerEntry = Omit<S["LedgerEntryResponse"], "reference"> & {
3340
+ reference: LedgerReference;
3341
+ };
3342
+ /** What caused a ledger entry, as documented: one variant per `type`. */
3343
+ type KnownLedgerReference = S["LedgerReference"];
3344
+ /** The documented `LedgerReference` types. */
3345
+ type LedgerReferenceType = KnownLedgerReference["type"];
3346
+ /**
3347
+ * A cause type this SDK version does not know yet (the server may add new ones). The object is
3348
+ * kept as sent. Use `isLedgerReference()` to narrow to a documented variant.
3349
+ */
3350
+ interface UnknownLedgerReference {
3351
+ type: string;
3352
+ [field: string]: unknown;
3353
+ }
3354
+ /** `LedgerEntry.reference`: a documented variant or an unknown one; never throws on new types. */
3355
+ type LedgerReference = KnownLedgerReference | UnknownLedgerReference;
3356
+ type DepositId = S["DepositId"];
3357
+ type FuturesTransferId = S["FuturesTransferId"];
3358
+ type OrderId = S["OrderId"];
3359
+ type PoolId = S["PoolId"];
3360
+ type TradeId = S["TradeId"];
3361
+ type UserId = S["UserId"];
3362
+ type WithdrawalId = S["WithdrawalId"];
3255
3363
  type LedgerEntryKind = S["LedgerEntryKind"];
3256
3364
  type LiquidityRole = S["LiquidityRole"];
3257
3365
  type MaintenanceState = S["MaintenanceState"];
@@ -3427,7 +3535,7 @@ declare class TradingResource extends Resource {
3427
3535
  *
3428
3536
  * Retry safety rests on `client_order_id` (generated as a UUID when absent): it is unique
3429
3537
  * per account and the server refuses a repeat before any funds move. The server does NOT
3430
- * honour `Idempotency-Key` on orders (the header is sent but gives no protection). After an
3538
+ * honour `Idempotency-Key` on orders, so none is sent. After an
3431
3539
  * ambiguous failure (network error, timeout or 5xx) the SDK first looks the order up by
3432
3540
  * `client_order_id` and returns it if it exists (`recovered: true`); only if it does not
3433
3541
  * exist does it send the order again, with the same `client_order_id`, so a late-arriving
@@ -3444,6 +3552,8 @@ declare class TradingResource extends Resource {
3444
3552
  cancelOrder(orderId: string, opts?: RequestOptions): Promise<Order>;
3445
3553
  /**
3446
3554
  * Cancels every open order in one market: `cancelAll({ symbol: "BTC/USDT" })`.
3555
+ * This includes stop orders that have not triggered yet (status `pending_trigger`): they are
3556
+ * cancelled and their reservations released, so nothing fires into the market afterwards.
3447
3557
  * To cancel across ALL markets, pass `symbol: null` explicitly: `cancelAll({ symbol: null })`.
3448
3558
  * Omitting `symbol` is an error, so an account-wide cancel never happens by accident
3449
3559
  * (the server itself treats `{}` as every market). An unknown symbol throws `NotFoundError`.
@@ -3459,10 +3569,18 @@ declare class TradingResource extends Resource {
3459
3569
  * waits 1, 2, 4, 8 and then 15 s, starting over after any progress. It stops after
3460
3570
  * `maxRounds` calls or before a wait would pass `timeBudgetMs`, and returns the merged
3461
3571
  * result with `rounds` and `stopped`. Other failure codes are returned, never retried.
3572
+ * In this mode every round is exactly one HTTP request (the loop owns the retries, so it
3573
+ * never sends more than `maxRounds` requests): a 429 round waits the server's Retry-After
3574
+ * (without advancing the backoff), another retryable error (5xx, network) takes the next
3575
+ * backoff step, and a wait that would pass the budget ends the loop with
3576
+ * `stopped: "time_budget"` and `last_error_code`. A non-retryable error (e.g. a key without
3577
+ * the trade scope) throws `CancelAllInterruptedError`, which carries the error and the
3578
+ * partial result.
3462
3579
  *
3463
- * The server allows 30 cancel-all calls per minute per account (a 429 is retried after its
3464
- * Retry-After). The call is naturally repeatable and needs no Idempotency-Key, so it is
3465
- * retried after network errors; a retry reports only what that retry did.
3580
+ * The server allows 30 cancel-all calls per minute per account. A single call (without
3581
+ * `untilDone`) follows the normal retry policy: a 429 is retried after its Retry-After (up to
3582
+ * 120 s; a longer one fails at once) and network errors are retried, since the call is
3583
+ * naturally repeatable; a retry reports only what that retry did. No Idempotency-Key is sent.
3466
3584
  */
3467
3585
  cancelAll(params: CancelAllParams & {
3468
3586
  untilDone: true;
@@ -3512,6 +3630,16 @@ declare class OrderStateUnknownError extends CexyError {
3512
3630
  readonly clientOrderId: string;
3513
3631
  constructor(clientOrderId: string, cause: unknown);
3514
3632
  }
3633
+ /**
3634
+ * A `cancelAll({ ..., untilDone: true })` loop hit an error it does not retry (for example
3635
+ * `ForbiddenError` for a key without the trade scope). `error` is that error; `partial` is what
3636
+ * the earlier rounds did, in the same shape as the loop's normal result.
3637
+ */
3638
+ declare class CancelAllInterruptedError extends CexyError {
3639
+ readonly error: unknown;
3640
+ readonly partial: CancelAllUntilDoneResult;
3641
+ constructor(error: unknown, partial: CancelAllUntilDoneResult);
3642
+ }
3515
3643
  interface CexyApiErrorInit {
3516
3644
  status: number;
3517
3645
  code: ErrorCode;
@@ -3576,6 +3704,12 @@ declare const CLIENT_ERROR_CODES: {
3576
3704
  };
3577
3705
  /** True for codes listed in errors.yaml (server codes; see `CLIENT_ERROR_CODES` for the SDK's own). */
3578
3706
  declare function isKnownErrorCode(code: string): code is KnownErrorCode;
3707
+ /**
3708
+ * The longest wait the SDK accepts from a server hint (`Retry-After`, `retry_after_seconds`,
3709
+ * `X-RateLimit-Reset`): 120 s. A longer hint is never waited; the call fails at once instead
3710
+ * (see `Transport.backoff`), and the client-side rate limiter caps its block at this value.
3711
+ */
3712
+ declare const MAX_SERVER_WAIT_MS = 120000;
3579
3713
  /**
3580
3714
  * Builds the right error subclass for an HTTP error response.
3581
3715
  * - A known code maps by HTTP status (401 -> AuthenticationError, 403 -> ForbiddenError, ...).
@@ -4021,12 +4155,23 @@ declare function isAmount(value: unknown): value is Amount;
4021
4155
  */
4022
4156
  declare function assertAmountFields(body: Record<string, unknown>, fields: readonly string[], context: string): void;
4023
4157
 
4158
+ /**
4159
+ * Narrows a ledger entry's `reference`:
4160
+ * - `isLedgerReference(ref)`: true for any documented variant;
4161
+ * - `isLedgerReference(ref, "trade")`: true only for that variant, typed accordingly.
4162
+ * Unknown (newer) types return false and keep their raw fields.
4163
+ */
4164
+ declare function isLedgerReference(ref: LedgerReference): ref is KnownLedgerReference;
4165
+ declare function isLedgerReference<T extends LedgerReferenceType>(ref: LedgerReference, type: T): ref is Extract<KnownLedgerReference, {
4166
+ type: T;
4167
+ }>;
4168
+
4024
4169
  /** SDK version, kept in sync with package.json (a test enforces this). */
4025
- declare const VERSION = "0.1.0-dev.4";
4170
+ declare const VERSION = "0.1.0-dev.6";
4026
4171
  /** Default User-Agent product token. */
4027
- declare const USER_AGENT = "cexy-typescript/0.1.0-dev.4";
4172
+ declare const USER_AGENT = "cexy-typescript/0.1.0-dev.6";
4028
4173
 
4029
4174
  /** True for loopback hosts, the only ones where plain-text transport may be allowed. */
4030
4175
  declare function isLocalHost(hostname: string): boolean;
4031
4176
 
4032
- 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, 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, 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 };
4177
+ 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 DepositId, 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, type FuturesTransferId, InvalidAmountError, type IterateOptions, type JoinPoolRequest, type JoinPoolResult, JurisdictionBlockedError, KNOWN_EVENT_TYPES, type KnownErrorCode, type KnownLedgerReference, type LedgerEntry, type LedgerEntryKind, type LedgerReference, type LedgerReferenceType, 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 OrderId, type OrderSide, OrderStateUnknownError, type OrderStatus, type OrderType, PRIVATE_CHANNELS, type Page, type PlaceOrderRequest, type PlaceOrderResponse, type PlaceOrderResult, type PongFrame, type Pool, type PoolId, 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 TradeId, type TradeNewEvent, TradingResource, type TriggerDirection, TypedEmitter, USER_AGENT, type UnknownLedgerReference, UnprocessableError, type UnsubscribedFrame, type UserId, VERSION, ValidationError, WS_BOOK_DEPTH, WalletResource, type WebSocketConstructor, type WebSocketLike, type WelcomeFrame, type Withdrawal, type WithdrawalAddress, type WithdrawalId, type WithdrawalStatus, type WithdrawalUpdatedEvent, type WsEvent, type WsLogger, assertAmountFields, type components, errorFromResponse, isAmount, isKnownErrorCode, isLedgerReference, isLocalHost, isRetryable, type operations, paginate, type paths };