From 685bffc655da66ab498dc51f436263063b23a4b4 Mon Sep 17 00:00:00 2001 From: Jerko J <83344666+JJ-Cro@users.noreply.github.com> Date: Tue, 6 Oct 2026 14:18:10 +0200 Subject: [PATCH 1/7] feat(v4.7.10): add auto savings, tax export, option base coins, and delay liquidation Sync the 2026-09-22 to 2026-09-30 V5 changelog: Flexible Saving auto savings, batch tax report export, instrument tags, Token Splash tradeToken, option base coins, institutional delay liquidation status, and removal of the Netherlands API domain. Co-authored-by: Cursor --- README.md | 5 +- docs/BYBIT_SDK_QUICKSTART_GUIDE.md | 3 +- docs/endpointFunctionList.md | 835 +- examples/Rest/rest-v5-custom-url.ts | 3 +- .../V5/Earn/get-auto-savings-settings.js | 20 + .../V5/Earn/set-auto-savings-settings.js | 22 + .../get-delay-liquidation-status.js | 18 + .../apidoc/V5/Market/get-option-base-coins.js | 18 + .../apidoc/V5/Tax/create-tax-batch-export.js | 28 + .../apidoc/V5/Tax/get-tax-batch-export.js | 20 + llms.txt | 23580 ++++++++-------- package-lock.json | 4 +- package.json | 2 +- src/rest-client-v5.ts | 76 + src/types/request/index.ts | 1 + src/types/request/v5-earn.ts | 12 + src/types/request/v5-market.ts | 8 + src/types/request/v5-tax.ts | 32 + src/types/response/index.ts | 1 + src/types/response/v5-crypto-loan.ts | 8 + src/types/response/v5-earn.ts | 12 + src/types/response/v5-market.ts | 19 + src/types/response/v5-spot-x.ts | 2 + src/types/response/v5-tax.ts | 16 + src/util/requestUtils.ts | 27 +- 25 files changed, 12754 insertions(+), 12018 deletions(-) create mode 100644 examples/apidoc/V5/Earn/get-auto-savings-settings.js create mode 100644 examples/apidoc/V5/Earn/set-auto-savings-settings.js create mode 100644 examples/apidoc/V5/Institutional-Loan/get-delay-liquidation-status.js create mode 100644 examples/apidoc/V5/Market/get-option-base-coins.js create mode 100644 examples/apidoc/V5/Tax/create-tax-batch-export.js create mode 100644 examples/apidoc/V5/Tax/get-tax-batch-export.js create mode 100644 src/types/request/v5-tax.ts create mode 100644 src/types/response/v5-tax.ts diff --git a/README.md b/README.md index 1c7a3b5a..6c99ad92 100644 --- a/README.md +++ b/README.md @@ -238,7 +238,7 @@ const restClientOptions = { /** * Optionally override API domain used: - * apiRegion: 'default' | 'bytick' | 'NL' | 'TK' | 'KZ' | 'HK' | 'GE' | 'UAE' | 'EU' | 'ID' | 'JP', + * apiRegion: 'default' | 'bytick' | 'TK' | 'KZ' | 'HK' | 'GE' | 'UAE' | 'EU' | 'ID' | 'JP', **/ // apiRegion: 'bytick', @@ -599,7 +599,6 @@ The following values are currently supported in this option: - `apiRegion: undefined`: if missing or undefined, this SDK will default to the Bybit Global domain `api.bybit.com`. - `apiRegion: "default"`: the Bybit Global domain (same behaviour as above). - `apiRegion: "bytick"`: the alternative Bybit Global domain `api.bytick.com`. -- `apiRegion: "NL"`: the dedicated Bybit Netherlands domain `api.bybit.nl`. - `apiRegion: "TK"`: the dedicated Bybit Turkey domain `api.bybit.tr`. - `apiRegion: "KZ"`: the dedicated Bybit Kazakhstan domain `api.bybit.kz`. - `apiRegion: "HK"`: the dedicated Bybit Hong Kong domain `api.spark-fintech.com`. The SDK also adds `x-refer-site-id: HKG`. Testnet uses `api-testnet.spark-fintech.com`. @@ -620,7 +619,7 @@ For WebSocket clients, the same option selects these mainnet stream domains: | `ID` | `stream.bybit.id` | | `JP` | `stream.manepa.jp` | -For `default`, `bytick`, `NL`, `UAE`, and `EU`, WebSocket connections continue to use the global stream because Bybit does not list a dedicated V5 trading stream for those values. This means `apiRegion: 'EU'` selects `api.bybit.eu` for REST and keeps `stream.bybit.com` for WebSocket. Testnet WebSocket connections use `stream-testnet.bybit.com`. For Hong Kong mainnet WebSocket connections, the SDK also adds `x-refer-site-id: HKG` automatically. +For `default`, `bytick`, `UAE`, and `EU`, WebSocket connections continue to use the global stream because Bybit does not list a dedicated V5 trading stream for those values. This means `apiRegion: 'EU'` selects `api.bybit.eu` for REST and keeps `stream.bybit.com` for WebSocket. Testnet WebSocket connections use `stream-testnet.bybit.com`. For Hong Kong mainnet WebSocket connections, the SDK also adds `x-refer-site-id: HKG` automatically. ```typescript const ws = new WebsocketClient({ apiRegion: 'TK' }); diff --git a/docs/BYBIT_SDK_QUICKSTART_GUIDE.md b/docs/BYBIT_SDK_QUICKSTART_GUIDE.md index 68617fd2..7a6bf079 100644 --- a/docs/BYBIT_SDK_QUICKSTART_GUIDE.md +++ b/docs/BYBIT_SDK_QUICKSTART_GUIDE.md @@ -1242,7 +1242,6 @@ Supported API region values in this SDK: - `default` - `bytick` -- `NL` - `TK` - `KZ` - `HK` @@ -1263,7 +1262,7 @@ On WebSocket clients, these mainnet routes are selected automatically: - `ID`: `stream.bybit.id` - `JP`: `stream.manepa.jp` -For `default`, `bytick`, `NL`, `UAE`, and `EU`, WebSocket connections continue to use the global stream because Bybit does not list a dedicated V5 trading stream for those values. This means `apiRegion: 'EU'` selects `api.bybit.eu` for REST API requests and keeps `stream.bybit.com` for WebSocket. Testnet WebSocket connections use `stream-testnet.bybit.com`. +For `default`, `bytick`, `UAE`, and `EU`, WebSocket connections continue to use the global stream because Bybit does not list a dedicated V5 trading stream for those values. This means `apiRegion: 'EU'` selects `api.bybit.eu` for REST API requests and keeps `stream.bybit.com` for WebSocket. Testnet WebSocket connections use `stream-testnet.bybit.com`. New API regions will be supported as they become available. If you're looking for a region not yet supported, please get in touch. diff --git a/docs/endpointFunctionList.md b/docs/endpointFunctionList.md index c4f4fd10..9e4ffd0e 100644 --- a/docs/endpointFunctionList.md +++ b/docs/endpointFunctionList.md @@ -49,421 +49,426 @@ This table includes all endpoints from the official Exchange API docs and corres | Function | AUTH | HTTP Method | Endpoint | | -------- | :------: | :------: | -------- | -| [getSystemStatus()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L711) | :closed_lock_with_key: | GET | `/v5/system/status` | -| [getServerTime()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L728) | | GET | `/v5/market/time` | -| [requestDemoTradingFunds()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L740) | :closed_lock_with_key: | POST | `/v5/account/demo-apply-money` | -| [createDemoAccount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L753) | :closed_lock_with_key: | POST | `/v5/user/create-demo-member` | -| [getSpreadInstrumentsInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L766) | | GET | `/v5/spread/instrument` | -| [getSpreadOrderbook()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L778) | | GET | `/v5/spread/orderbook` | -| [getSpreadTickers()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L788) | | GET | `/v5/spread/tickers` | -| [getSpreadRecentTrades()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L799) | | GET | `/v5/spread/recent-trade` | -| [getSpreadMaxQty()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L811) | :closed_lock_with_key: | GET | `/v5/spread/max-qty` | -| [submitSpreadOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L820) | :closed_lock_with_key: | POST | `/v5/spread/order/create` | -| [amendSpreadOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L833) | :closed_lock_with_key: | POST | `/v5/spread/order/amend` | -| [cancelSpreadOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L845) | :closed_lock_with_key: | POST | `/v5/spread/order/cancel` | -| [cancelAllSpreadOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L863) | :closed_lock_with_key: | POST | `/v5/spread/order/cancel-all` | -| [getSpreadOpenOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L882) | :closed_lock_with_key: | GET | `/v5/spread/order/realtime` | -| [getSpreadOrderHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L899) | :closed_lock_with_key: | GET | `/v5/spread/order/history` | -| [getSpreadTradeHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L915) | :closed_lock_with_key: | GET | `/v5/spread/execution/list` | -| [getKline()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L935) | | GET | `/v5/market/kline` | -| [getMarkPriceKline()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L952) | | GET | `/v5/market/mark-price-kline` | -| [getIndexPriceKline()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L967) | | GET | `/v5/market/index-price-kline` | -| [getPremiumIndexPriceKline()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L982) | | GET | `/v5/market/premium-index-price-kline` | -| [getInstrumentsInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L998) | | GET | `/v5/market/instruments-info` | -| [getOrderbook()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1009) | | GET | `/v5/market/orderbook` | -| [getFullDepthOrderbook()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1015) | | GET | `/v5/market/full_orderbook` | -| [getRPIOrderbook()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1029) | | GET | `/v5/market/rpi_orderbook` | -| [getTickers()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1035) | | GET | `/v5/market/tickers` | -| [getFundingRateHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1073) | | GET | `/v5/market/funding/history` | -| [getPublicTradingHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1088) | | GET | `/v5/market/recent-trade` | -| [getOpenInterest()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1101) | | GET | `/v5/market/open-interest` | -| [getHistoricalVolatility()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1111) | | GET | `/v5/market/historical-volatility` | -| [getInsurance()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1122) | | GET | `/v5/market/insurance` | -| [getRiskLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1133) | | GET | `/v5/market/risk-limit` | -| [getOptionDeliveryPrice()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1148) | | GET | `/v5/market/delivery-price` | -| [getDeliveryPrice()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1161) | | GET | `/v5/market/delivery-price` | -| [getNewDeliveryPrice()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1177) | | GET | `/v5/market/new-delivery-price` | -| [getLongShortRatio()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1193) | | GET | `/v5/market/account-ratio` | -| [getIndexPriceComponents()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1203) | | GET | `/v5/market/index-price-components` | -| [getOrderPriceLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1209) | | GET | `/v5/market/price-limit` | -| [getADLAlert()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1223) | | GET | `/v5/market/adlAlert` | -| [getFeeGroupStructure()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1236) | | GET | `/v5/market/fee-group-info` | -| [submitOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1248) | :closed_lock_with_key: | POST | `/v5/order/create` | -| [amendOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1254) | :closed_lock_with_key: | POST | `/v5/order/amend` | -| [cancelOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1260) | :closed_lock_with_key: | POST | `/v5/order/cancel` | -| [getActiveOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1269) | :closed_lock_with_key: | GET | `/v5/order/realtime` | -| [cancelAllOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1275) | :closed_lock_with_key: | POST | `/v5/order/cancel-all` | -| [getHistoricOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1288) | :closed_lock_with_key: | GET | `/v5/order/history` | -| [getExecutionList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1300) | :closed_lock_with_key: | GET | `/v5/execution/list` | -| [batchSubmitOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1318) | :closed_lock_with_key: | POST | `/v5/order/create-batch` | -| [batchAmendOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1343) | :closed_lock_with_key: | POST | `/v5/order/amend-batch` | -| [batchCancelOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1368) | :closed_lock_with_key: | POST | `/v5/order/cancel-batch` | -| [getSpotBorrowCheck()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1390) | :closed_lock_with_key: | GET | `/v5/order/spot-borrow-check` | -| [setDisconnectCancelAllWindow()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1411) | :closed_lock_with_key: | POST | `/v5/order/disconnected-cancel-all` | -| [setDisconnectCancelAllWindowV2()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1429) | :closed_lock_with_key: | POST | `/v5/order/disconnected-cancel-all` | -| [preCheckOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1444) | :closed_lock_with_key: | POST | `/v5/order/pre-check` | -| [createStrategyOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1461) | :closed_lock_with_key: | POST | `/v5/strategy/create` | -| [getStrategyList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1472) | :closed_lock_with_key: | GET | `/v5/strategy/list` | -| [getStrategyOrderList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1483) | :closed_lock_with_key: | GET | `/v5/strategy/order-list` | -| [stopStrategy()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1494) | :closed_lock_with_key: | POST | `/v5/strategy/stop` | -| [getPositionInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1519) | :closed_lock_with_key: | GET | `/v5/position/list` | -| [getFuturesLeverage()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1531) | :closed_lock_with_key: | GET | `/v5/position/symbol-info` | -| [setLeverage()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1546) | :closed_lock_with_key: | POST | `/v5/position/set-leverage` | -| [switchIsolatedMargin()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1559) | :closed_lock_with_key: | POST | `/v5/position/switch-isolated` | -| [setTPSLMode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1573) | :closed_lock_with_key: | POST | `/v5/position/set-tpsl-mode` | -| [switchPositionMode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1588) | :closed_lock_with_key: | POST | `/v5/position/switch-mode` | -| [setRiskLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1602) | :closed_lock_with_key: | POST | `/v5/position/set-risk-limit` | -| [setTradingStop()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1617) | :closed_lock_with_key: | POST | `/v5/position/trading-stop` | -| [setAutoAddMargin()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1628) | :closed_lock_with_key: | POST | `/v5/position/set-auto-add-margin` | -| [addOrReduceMargin()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1640) | :closed_lock_with_key: | POST | `/v5/position/add-margin` | -| [getClosedPnL()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1652) | :closed_lock_with_key: | GET | `/v5/position/closed-pnl` | -| [getClosedOptionsPositions()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1666) | :closed_lock_with_key: | GET | `/v5/position/get-closed-positions` | -| [movePosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1691) | :closed_lock_with_key: | POST | `/v5/position/move-positions` | -| [getMovePositionHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1702) | :closed_lock_with_key: | GET | `/v5/position/move-history` | -| [confirmNewRiskLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1721) | :closed_lock_with_key: | POST | `/v5/position/confirm-pending-mmr` | -| [getPreUpgradeOrderHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1741) | :closed_lock_with_key: | GET | `/v5/pre-upgrade/order/history` | -| [getPreUpgradeTradeHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1756) | :closed_lock_with_key: | GET | `/v5/pre-upgrade/execution/list` | -| [getPreUpgradeClosedPnl()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1767) | :closed_lock_with_key: | GET | `/v5/pre-upgrade/position/closed-pnl` | -| [getPreUpgradeTransactions()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1781) | :closed_lock_with_key: | GET | `/v5/pre-upgrade/account/transaction-log` | -| [getPreUpgradeOptionDeliveryRecord()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1798) | :closed_lock_with_key: | GET | `/v5/pre-upgrade/asset/delivery-record` | -| [getPreUpgradeUSDCSessionSettlements()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1812) | :closed_lock_with_key: | GET | `/v5/pre-upgrade/asset/settlement-record` | -| [getWalletBalance()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1833) | :closed_lock_with_key: | GET | `/v5/account/wallet-balance` | -| [getTransferableAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1844) | :closed_lock_with_key: | GET | `/v5/account/withdrawal` | -| [getAccountInstrumentsInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1861) | :closed_lock_with_key: | GET | `/v5/account/instruments-info` | -| [upgradeToUnifiedAccount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1872) | :closed_lock_with_key: | POST | `/v5/account/upgrade-to-uta` | -| [getBorrowHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1883) | :closed_lock_with_key: | GET | `/v5/account/borrow-history` | -| [repayLiability()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1904) | :closed_lock_with_key: | POST | `/v5/account/quick-repayment` | -| [manualRepay()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1929) | :closed_lock_with_key: | POST | `/v5/account/repay` | -| [setCollateralCoin()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1938) | :closed_lock_with_key: | POST | `/v5/account/set-collateral-switch` | -| [batchSetCollateralCoin()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1944) | :closed_lock_with_key: | POST | `/v5/account/set-collateral-switch-batch` | -| [getCollateralInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1954) | :closed_lock_with_key: | GET | `/v5/account/collateral-info` | -| [getCoinGreeks()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1963) | :closed_lock_with_key: | GET | `/v5/asset/coin-greeks` | -| [getFeeRate()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1976) | :closed_lock_with_key: | GET | `/v5/account/fee-rate` | -| [getAccountInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1985) | :closed_lock_with_key: | GET | `/v5/account/info` | -| [getDCPInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1998) | :closed_lock_with_key: | GET | `/v5/account/query-dcp-info` | -| [getTransactionLog()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2005) | :closed_lock_with_key: | GET | `/v5/account/transaction-log` | -| [getClassicTransactionLogs()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2016) | :closed_lock_with_key: | GET | `/v5/account/contract-transaction-log` | -| [getSMPGroup()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2027) | :closed_lock_with_key: | GET | `/v5/account/smp-group` | -| [setMarginMode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2040) | :closed_lock_with_key: | POST | `/v5/account/set-margin-mode` | -| [setSpotHedging()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2057) | :closed_lock_with_key: | POST | `/v5/account/set-hedging-mode` | -| [setLimitPriceAction()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2070) | :closed_lock_with_key: | POST | `/v5/account/set-limit-px-action` | -| [getLimitPriceAction()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2081) | :closed_lock_with_key: | GET | `/v5/account/user-setting-config` | -| [setDeltaNeutralMode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2089) | :closed_lock_with_key: | POST | `/v5/account/set-delta-mode` | -| [setMMP()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2098) | :closed_lock_with_key: | POST | `/v5/account/mmp-modify` | -| [resetMMP()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2105) | :closed_lock_with_key: | POST | `/v5/account/mmp-reset` | -| [getMMPState()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2112) | :closed_lock_with_key: | GET | `/v5/account/mmp-state` | -| [getOptionAssetInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2122) | :closed_lock_with_key: | GET | `/v5/account/option-asset-info` | -| [getPayInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2132) | :closed_lock_with_key: | GET | `/v5/account/pay-info` | -| [getTradeInfoForAnalysis()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2142) | :closed_lock_with_key: | GET | `/v5/account/trade-info-for-analysis` | -| [getAssetOverview()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2162) | :closed_lock_with_key: | GET | `/v5/asset/asset-overview` | -| [getPortfolioMarginInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2172) | :closed_lock_with_key: | GET | `/v5/asset/portfolio-margin` | -| [getTotalMembersAssets()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2182) | :closed_lock_with_key: | GET | `/v5/asset/total-members-assets` | -| [getFundingAccountTransactionHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2194) | :closed_lock_with_key: | GET | `/v5/asset/fundinghistory` | -| [getDeliveryRecord()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2210) | :closed_lock_with_key: | GET | `/v5/asset/delivery-record` | -| [getSettlementRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2221) | :closed_lock_with_key: | GET | `/v5/asset/settlement-record` | -| [getCoinExchangeRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2234) | :closed_lock_with_key: | GET | `/v5/asset/exchange/order-record` | -| [getCoinInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2249) | :closed_lock_with_key: | GET | `/v5/asset/coin/query-info` | -| [getSubUID()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2263) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-sub-member-list` | -| [getAssetInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2278) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-asset-info` | -| [getAllCoinsBalance()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2289) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-account-coins-balance` | -| [getCoinBalance()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2303) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-account-coin-balance` | -| [getWithdrawableAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2317) | :closed_lock_with_key: | GET | `/v5/asset/withdraw/withdrawable-amount` | -| [getTransferableCoinList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2326) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-transfer-coin-list` | -| [createInternalTransfer()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2342) | :closed_lock_with_key: | POST | `/v5/asset/transfer/inter-transfer` | -| [getInternalTransferRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2361) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-inter-transfer-list` | -| [enableUniversalTransferForSubUIDs()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2381) | :closed_lock_with_key: | POST | `/v5/asset/transfer/save-transfer-sub-member` | -| [createUniversalTransfer()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2392) | :closed_lock_with_key: | POST | `/v5/asset/transfer/universal-transfer` | -| [getUniversalTransferRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2404) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-universal-transfer-list` | -| [getAllowedDepositCoinInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2417) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-allowed-list` | -| [setDepositAccount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2432) | :closed_lock_with_key: | POST | `/v5/asset/deposit/deposit-to-account` | -| [getDepositRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2448) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-record` | -| [getSubAccountDepositRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2463) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-sub-member-record` | -| [getInternalDepositRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2479) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-internal-record` | -| [getMasterDepositAddress()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2491) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-address` | -| [getSubDepositAddress()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2509) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-sub-member-address` | -| [querySubMemberAddress()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2534) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-sub-member-address` | -| [getWithdrawalRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2554) | :closed_lock_with_key: | GET | `/v5/asset/withdraw/query-record` | -| [getWithdrawalAddressList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2566) | :closed_lock_with_key: | GET | `/v5/asset/withdraw/query-address` | -| [getExchangeEntities()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2580) | :closed_lock_with_key: | GET | `/v5/asset/withdraw/vasp/list` | -| [submitDepositOriginatorInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2590) | :closed_lock_with_key: | POST | `/v5/asset/travel-rule/deposit/submit` | -| [submitWithdrawal()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2605) | :closed_lock_with_key: | POST | `/v5/asset/withdraw/create` | -| [cancelWithdrawal()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2616) | :closed_lock_with_key: | POST | `/v5/asset/withdraw/cancel` | -| [getConvertCoins()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2625) | :closed_lock_with_key: | GET | `/v5/asset/exchange/query-coin-list` | -| [requestConvertQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2636) | :closed_lock_with_key: | POST | `/v5/asset/exchange/quote-apply` | -| [confirmConvertQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2645) | :closed_lock_with_key: | POST | `/v5/asset/exchange/convert-execute` | -| [getConvertStatus()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2657) | :closed_lock_with_key: | GET | `/v5/asset/exchange/convert-result-query` | -| [getConvertHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2676) | :closed_lock_with_key: | GET | `/v5/asset/exchange/query-convert-history` | -| [getSmallBalanceList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2693) | :closed_lock_with_key: | GET | `/v5/asset/covert/small-balance-list` | -| [getFiatTradingPairList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2707) | :closed_lock_with_key: | GET | `/v5/fiat/query-coin-list` | -| [createSubMember()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2725) | :closed_lock_with_key: | POST | `/v5/user/create-sub-member` | -| [createSubUIDAPIKey()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2737) | :closed_lock_with_key: | POST | `/v5/user/create-sub-api` | -| [getSubUIDList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2746) | :closed_lock_with_key: | GET | `/v5/user/query-sub-members` | -| [getSubUIDListUnlimited()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2755) | :closed_lock_with_key: | GET | `/v5/user/submembers` | -| [setSubUIDFrozenState()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2773) | :closed_lock_with_key: | POST | `/v5/user/frozen-sub-member` | -| [getQueryApiKey()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2788) | :closed_lock_with_key: | GET | `/v5/user/query-api` | -| [getSubAccountAllApiKeys()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2795) | :closed_lock_with_key: | GET | `/v5/user/sub-apikeys` | -| [getUIDWalletType()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2804) | :closed_lock_with_key: | GET | `/v5/user/get-member-type` | -| [updateMasterApiKey()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2823) | :closed_lock_with_key: | POST | `/v5/user/update-api` | -| [updateSubApiKey()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2837) | :closed_lock_with_key: | POST | `/v5/user/update-sub-api` | -| [deleteSubMember()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2850) | :closed_lock_with_key: | POST | `/v5/user/del-submember` | -| [deleteMasterApiKey()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2865) | :closed_lock_with_key: | POST | `/v5/user/delete-api` | -| [deleteSubApiKey()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2879) | :closed_lock_with_key: | POST | `/v5/user/delete-sub-api` | -| [getAffiliateUserList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2899) | :closed_lock_with_key: | GET | `/v5/affiliate/aff-user-list` | -| [getAffiliateSubAffiliateList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2917) | :closed_lock_with_key: | GET | `/v5/affiliate/affiliate-sub-list` | -| [getAffiliateUserInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2933) | :closed_lock_with_key: | GET | `/v5/user/aff-customer-info` | -| [getFriendReferrals()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2945) | :closed_lock_with_key: | GET | `/v5/user/invitation/referrals` | -| [getReferralCode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2954) | :closed_lock_with_key: | GET | `/v5/user/invitation/code` | -| [signAgreement()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2970) | :closed_lock_with_key: | POST | `/v5/user/agreement` | -| [getAlphaTradeQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2987) | :closed_lock_with_key: | POST | `/v5/alpha/trade/quote` | -| [executeAlphaTradePurchase()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2998) | :closed_lock_with_key: | POST | `/v5/alpha/trade/purchase` | -| [executeAlphaTradeRedeem()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3009) | :closed_lock_with_key: | POST | `/v5/alpha/trade/redeem` | -| [getAlphaPayTokenList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3019) | :closed_lock_with_key: | POST | `/v5/alpha/trade/pay-token-list` | -| [getAlphaTradeOrderList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3029) | :closed_lock_with_key: | POST | `/v5/alpha/trade/order-list` | -| [getAlphaBizTokenList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3039) | :closed_lock_with_key: | POST | `/v5/alpha/trade/biz-token-list` | -| [getAlphaBizTokenPriceList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3049) | :closed_lock_with_key: | POST | `/v5/alpha/trade/biz-token-price-list` | -| [getAlphaBizTokenDetails()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3059) | :closed_lock_with_key: | POST | `/v5/alpha/trade/biz-token-details` | -| [getAlphaAssetList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3069) | :closed_lock_with_key: | POST | `/v5/alpha/trade/asset-list` | -| [getAlphaAssetDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3077) | :closed_lock_with_key: | POST | `/v5/alpha/trade/asset-detail` | -| [getAlphaPredictionEngineStatus()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3093) | :closed_lock_with_key: | GET | `/v5/alpha/prediction/engine-status` | -| [getAlphaPredictionPayTokenList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3103) | :closed_lock_with_key: | GET | `/v5/alpha/prediction/pay-token-list` | -| [getAlphaPredictionEventDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3113) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/event-detail` | -| [getAlphaPredictionOrderEstimate()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3123) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/order-estimate` | -| [executeAlphaPredictionBuy()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3133) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/buy` | -| [executeAlphaPredictionSell()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3143) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/sell` | -| [getAlphaPredictionOrderList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3153) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/order-list` | -| [getAlphaPredictionOrderBook()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3163) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/order-book` | -| [getAlphaPredictionTokenPrice()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3173) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/token-price` | -| [getAlphaPredictionPriceHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3183) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/price-history` | -| [getAlphaPredictionPositionList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3193) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/position-list` | -| [getAlphaPredictionPositionHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3203) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/position-history` | -| [getAlphaPredictionPortfolioSummary()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3213) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/portfolio-summary` | -| [getAlphaPredictionSideMarketList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3223) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/side-market-list` | -| [getAlphaPredictionSportsMatchList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3233) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/sports/match-list` | -| [getAlphaPredictionSportsTimelineStages()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3243) | :closed_lock_with_key: | GET | `/v5/alpha/prediction/sports/timeline-stages` | -| [getAlphaPredictionSportsGroupStageDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3256) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/sports/group-stage-detail` | -| [getAlphaLPPoolList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3275) | :closed_lock_with_key: | POST | `/v5/alpha/lp/pool-list` | -| [getAlphaLPPoolInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3285) | :closed_lock_with_key: | POST | `/v5/alpha/lp/pool-info` | -| [executeAlphaLPStake()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3295) | :closed_lock_with_key: | POST | `/v5/alpha/lp/stake` | -| [executeAlphaLPRedeem()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3305) | :closed_lock_with_key: | POST | `/v5/alpha/lp/redeem` | -| [getAlphaLPOrderList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3315) | :closed_lock_with_key: | POST | `/v5/alpha/lp/order-list` | -| [getAlphaLPPayTokenList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3325) | :closed_lock_with_key: | POST | `/v5/alpha/lp/pay-token-list` | -| [getAlphaLPPayTokenPrice()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3335) | :closed_lock_with_key: | POST | `/v5/alpha/lp/pay-token-price` | -| [getAlphaLPPositionList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3345) | :closed_lock_with_key: | POST | `/v5/alpha/lp/position-list` | -| [getVIPMarginData()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3365) | | GET | `/v5/spot-margin-trade/data` | -| [getHistoricalInterestRate()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3376) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/interest-rate-history` | -| [getSpotMarginCurrencyData()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3401) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/currency-data` | -| [toggleSpotMarginTrade()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3413) | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/switch-mode` | -| [setSpotMarginLeverage()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3424) | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/set-leverage` | -| [setSpotMarginLeverageV2()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3432) | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/set-leverage` | -| [getSpotMarginState()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3443) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/state` | -| [manualBorrow()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3450) | :closed_lock_with_key: | POST | `/v5/account/borrow` | -| [getMaxBorrowableAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3459) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/max-borrowable` | -| [getPositionTiers()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3468) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/position-tiers` | -| [getCoinState()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3479) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/coinstate` | -| [getAvailableAmountToRepay()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3490) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/repayment-available-amount` | -| [manualRepayWithoutConversion()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3509) | :closed_lock_with_key: | POST | `/v5/account/no-convert-repay` | -| [getAutoRepayMode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3522) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/get-auto-repay-mode` | -| [setAutoRepayMode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3538) | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/set-auto-repay-mode` | -| [getSpotMarginLiability()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3550) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/liability` | -| [submitFixedRateBorrow()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3559) | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/fixedborrow` | -| [getFixedRateBorrowOrderInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3568) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/fixedborrow-order-info` | -| [getFixedRateBorrowContractInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3585) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/fixedborrow-contract-info` | -| [getFixedRateBorrowOrderQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3602) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/fixedborrow-order-quote` | -| [renewFixedRateBorrow()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3614) | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/fixedborrow-renew` | -| [getFlexibleAvailableInventory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3620) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/flexible-available-inventory` | -| [getFixedRateAvailableInventory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3629) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/fixed-available-inventory` | -| [getSpotMarginCoinInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3647) | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/pledge-token` | -| [getSpotMarginBorrowableCoinInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3664) | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/borrow-token` | -| [getSpotMarginInterestAndQuota()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3681) | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/loan-info` | -| [getSpotMarginLoanAccountInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3699) | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/account` | -| [spotMarginBorrow()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3723) | :closed_lock_with_key: | POST | `/v5/spot-cross-margin-trade/loan` | -| [spotMarginRepay()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3734) | :closed_lock_with_key: | POST | `/v5/spot-cross-margin-trade/repay` | -| [getSpotMarginBorrowOrderDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3749) | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/orders` | -| [getSpotMarginRepaymentOrderDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3778) | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/repay-history` | -| [toggleSpotCrossMarginTrade()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3807) | :closed_lock_with_key: | POST | `/v5/spot-cross-margin-trade/switch` | -| [getCollateralCoins()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3827) | | GET | `/v5/crypto-loan/collateral-data` | -| [getBorrowableCoins()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3844) | | GET | `/v5/crypto-loan/loanable-data` | -| [getAccountBorrowCollateralLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3862) | :closed_lock_with_key: | GET | `/v5/crypto-loan/borrowable-collateralisable-number` | -| [borrowCryptoLoan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3882) | :closed_lock_with_key: | POST | `/v5/crypto-loan/borrow` | -| [repayCryptoLoan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3903) | :closed_lock_with_key: | POST | `/v5/crypto-loan/repay` | -| [getUnpaidLoanOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3919) | :closed_lock_with_key: | GET | `/v5/crypto-loan/ongoing-orders` | -| [getRepaymentHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3940) | :closed_lock_with_key: | GET | `/v5/crypto-loan/repayment-history` | -| [getCompletedLoanOrderHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3960) | :closed_lock_with_key: | GET | `/v5/crypto-loan/borrow-history` | -| [getMaxAllowedReductionCollateralAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3979) | :closed_lock_with_key: | GET | `/v5/crypto-loan/max-collateral-amount` | -| [adjustCollateralAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3998) | :closed_lock_with_key: | POST | `/v5/crypto-loan/adjust-ltv` | -| [getLoanLTVAdjustmentHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4022) | :closed_lock_with_key: | GET | `/v5/crypto-loan/adjustment-history` | -| [getLoanBorrowableCoins()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4043) | | GET | `/v5/crypto-loan-common/loanable-data` | -| [getLoanCollateralCoins()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4055) | | GET | `/v5/crypto-loan-common/collateral-data` | -| [getMaxCollateralAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4065) | :closed_lock_with_key: | GET | `/v5/crypto-loan-common/max-collateral-amount` | -| [getMaxLoanAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4084) | :closed_lock_with_key: | POST | `/v5/crypto-loan-common/max-loan` | -| [updateCollateralAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4094) | :closed_lock_with_key: | POST | `/v5/crypto-loan-common/adjust-ltv` | -| [getCollateralAdjustmentHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4105) | :closed_lock_with_key: | GET | `/v5/crypto-loan-common/adjustment-history` | -| [getCryptoLoanPosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4120) | :closed_lock_with_key: | GET | `/v5/crypto-loan-common/position` | -| [borrowFlexible()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4137) | :closed_lock_with_key: | POST | `/v5/crypto-loan-flexible/borrow` | -| [repayFlexible()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4148) | :closed_lock_with_key: | POST | `/v5/crypto-loan-flexible/repay` | -| [repayCollateralFlexible()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4158) | :closed_lock_with_key: | POST | `/v5/crypto-loan-flexible/repay-collateral` | -| [getOngoingFlexibleLoans()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4172) | :closed_lock_with_key: | GET | `/v5/crypto-loan-flexible/ongoing-coin` | -| [getBorrowHistoryFlexible()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4184) | :closed_lock_with_key: | GET | `/v5/crypto-loan-flexible/borrow-history` | -| [getRepaymentHistoryFlexible()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4197) | :closed_lock_with_key: | GET | `/v5/crypto-loan-flexible/repayment-history` | -| [getFlexibleLoanAvailableInventory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4211) | :closed_lock_with_key: | GET | `/v5/crypto-loan-flexible/available-inventory` | -| [getSupplyOrderQuoteFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4231) | | GET | `/v5/crypto-loan-fixed/supply-order-quote` | -| [getBorrowOrderQuoteFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4244) | | GET | `/v5/crypto-loan-fixed/borrow-order-quote` | -| [createBorrowOrderFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4257) | :closed_lock_with_key: | POST | `/v5/crypto-loan-fixed/borrow` | -| [createSupplyOrderFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4270) | :closed_lock_with_key: | POST | `/v5/crypto-loan-fixed/supply` | -| [cancelBorrowOrderFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4280) | :closed_lock_with_key: | POST | `/v5/crypto-loan-fixed/borrow-order-cancel` | -| [cancelSupplyOrderFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4294) | :closed_lock_with_key: | POST | `/v5/crypto-loan-fixed/supply-order-cancel` | -| [getBorrowContractInfoFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4307) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/borrow-contract-info` | -| [getSupplyContractInfoFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4325) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/supply-contract-info` | -| [getBorrowOrderInfoFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4343) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/borrow-order-info` | -| [getSupplyOrderInfoFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4356) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/supply-order-info` | -| [repayFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4370) | :closed_lock_with_key: | POST | `/v5/crypto-loan-fixed/fully-repay` | -| [repayCollateralFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4381) | :closed_lock_with_key: | POST | `/v5/crypto-loan-flexible/repay-collateral` | -| [getRepaymentHistoryFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4394) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/repayment-history` | -| [renewBorrowOrderFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4411) | :closed_lock_with_key: | POST | `/v5/crypto-loan-fixed/renew` | -| [getRenewOrderInfoFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4424) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/renew-info` | -| [getFixedLoanAvailableInventory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4433) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/available-inventory` | -| [getInstitutionalLendingProductInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4448) | | GET | `/v5/ins-loan/product-infos` | -| [getInstitutionalLendingCoinDeltaAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4460) | :closed_lock_with_key: | GET | `/v5/ins-loan/coin-delta-amount` | -| [getInstitutionalLendingMarginCoinInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4470) | | GET | `/v5/ins-loan/ensure-tokens` | -| [getInstitutionalLendingMarginCoinInfoWithConversionRate()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4479) | | GET | `/v5/ins-loan/ensure-tokens-convert` | -| [getInstitutionalLendingLoanOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4488) | :closed_lock_with_key: | GET | `/v5/ins-loan/loan-order` | -| [getInstitutionalLendingRepayOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4500) | :closed_lock_with_key: | GET | `/v5/ins-loan/repaid-history` | -| [getInstitutionalLendingLTV()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4512) | :closed_lock_with_key: | GET | `/v5/ins-loan/ltv` | -| [getInstitutionalLendingLTVWithLadderConversionRate()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4521) | :closed_lock_with_key: | GET | `/v5/ins-loan/ltv-convert` | -| [bindOrUnbindUID()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4536) | :closed_lock_with_key: | POST | `/v5/ins-loan/association-uid` | -| [repayInstitutionalLoan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4556) | :closed_lock_with_key: | POST | `/v5/ins-loan/repay-loan` | -| [getExchangeBrokerEarnings()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4577) | :closed_lock_with_key: | GET | `/v5/broker/earnings-info` | -| [getExchangeBrokerAccountInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4590) | :closed_lock_with_key: | GET | `/v5/broker/account-info` | -| [getBrokerSubAccountDeposits()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4606) | :closed_lock_with_key: | GET | `/v5/broker/asset/query-sub-member-deposit-record` | -| [getBrokerVoucherSpec()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4621) | :closed_lock_with_key: | POST | `/v5/broker/award/info` | -| [issueBrokerVoucher()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4633) | :closed_lock_with_key: | POST | `/v5/broker/award/distribute-award` | -| [getBrokerIssuedVoucher()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4645) | :closed_lock_with_key: | POST | `/v5/broker/award/distribution-record` | -| [setBrokerRateLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4662) | :closed_lock_with_key: | POST | `/v5/broker/apilimit/set` | -| [getBrokerRateLimitCap()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4681) | :closed_lock_with_key: | GET | `/v5/broker/apilimit/query-cap` | -| [getAllBrokerRateLimits()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4699) | :closed_lock_with_key: | GET | `/v5/broker/apilimit/query-all` | -| [getEarnProduct()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4719) | | GET | `/v5/earn/product` | -| [getEarnCouponList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4731) | :closed_lock_with_key: | GET | `/v5/earn/coupons` | -| [getRWAProductList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4741) | | GET | `/v5/earn/rwa/product` | -| [placeRWAOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4751) | :closed_lock_with_key: | POST | `/v5/earn/rwa/place-order` | -| [getRWAPositionList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4760) | :closed_lock_with_key: | GET | `/v5/earn/rwa/position` | -| [getRWAOrderList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4769) | :closed_lock_with_key: | GET | `/v5/earn/rwa/order` | -| [getRWANavChart()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4779) | | GET | `/v5/earn/rwa/nav-chart` | -| [getHoldToEarnAirdropProducts()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4790) | | GET | `/v5/earn/hold-to-earn/product` | -| [getAdvanceEarnProduct()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4801) | | GET | `/v5/earn/advance/product` | -| [getLiquidityMiningProduct()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4812) | | GET | `/v5/earn/liquidity-mining/product` | -| [reinvestLiquidityMining()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4825) | :closed_lock_with_key: | POST | `/v5/earn/liquidity-mining/reinvest` | -| [getFixedTermEarnProduct()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4836) | | GET | `/v5/earn/fixed-term/product` | -| [getAdvanceEarnProductExtraInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4848) | | GET | `/v5/earn/advance/product-extra-info` | -| [submitAdvanceEarnPlaceOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4859) | :closed_lock_with_key: | POST | `/v5/earn/advance/place-order` | -| [getAdvanceEarnPosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4870) | :closed_lock_with_key: | GET | `/v5/earn/advance/position` | -| [getAdvanceEarnOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4881) | :closed_lock_with_key: | GET | `/v5/earn/advance/order` | -| [submitFixedTermEarnOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4892) | :closed_lock_with_key: | POST | `/v5/earn/fixed-term/place-order` | -| [redeemFixedTermEarn()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4903) | :closed_lock_with_key: | POST | `/v5/earn/fixed-term/redeem` | -| [getFixedTermEarnPosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4914) | :closed_lock_with_key: | GET | `/v5/earn/fixed-term/position` | -| [getFixedTermEarnOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4925) | :closed_lock_with_key: | GET | `/v5/earn/fixed-term/order` | -| [setFixedTermEarnAutoInvest()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4936) | :closed_lock_with_key: | POST | `/v5/earn/fixed-term/position/auto-invest` | -| [submitStakeRedeem()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4952) | :closed_lock_with_key: | POST | `/v5/earn/place-order` | -| [getEarnOrderHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4971) | :closed_lock_with_key: | GET | `/v5/earn/order` | -| [getEarnPosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4989) | :closed_lock_with_key: | GET | `/v5/earn/position` | -| [modifyEarnPosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5002) | :closed_lock_with_key: | POST | `/v5/earn/position/modify` | -| [getEarnYieldHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5015) | :closed_lock_with_key: | GET | `/v5/earn/yield` | -| [getHoldToEarnAirdropYieldHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5029) | :closed_lock_with_key: | GET | `/v5/earn/hold-to-earn/yield-history` | -| [getEarnHourlyYieldHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5040) | :closed_lock_with_key: | GET | `/v5/earn/hourly-yield` | -| [getEarnAprHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5054) | | GET | `/v5/earn/apr-history` | -| [getEarnTokenProduct()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5064) | | GET | `/v5/earn/token/product` | -| [submitEarnTokenOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5073) | :closed_lock_with_key: | POST | `/v5/earn/token/place-order` | -| [getEarnTokenOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5082) | :closed_lock_with_key: | GET | `/v5/earn/token/order` | -| [getEarnTokenPosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5094) | :closed_lock_with_key: | GET | `/v5/earn/token/position` | -| [getEarnTokenDailyYield()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5103) | :closed_lock_with_key: | GET | `/v5/earn/token/yield` | -| [getEarnTokenHourlyYield()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5115) | :closed_lock_with_key: | GET | `/v5/earn/token/hourly-yield` | -| [getEarnTokenHistoryApr()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5127) | | GET | `/v5/earn/token/history-apr` | -| [getPwmInvestmentPlanList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5142) | :closed_lock_with_key: | GET | `/v5/earn/pwm/investment-plan/list` | -| [getPwmInvestmentPlanDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5151) | :closed_lock_with_key: | GET | `/v5/earn/pwm/investment-plan/detail` | -| [getPwmPendingInvestmentPlanDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5160) | :closed_lock_with_key: | GET | `/v5/earn/pwm/investment-plan/new-plan` | -| [claimPwmWithdrawableFunds()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5169) | :closed_lock_with_key: | POST | `/v5/earn/pwm/investment-plan/claim` | -| [getPwmInvestmentPlanAssetTrend()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5178) | :closed_lock_with_key: | GET | `/v5/earn/pwm/investment-plan/asset-trend` | -| [getPwmFundHistoricalNav()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5187) | :closed_lock_with_key: | GET | `/v5/earn/pwm/investment-plan/fund-nav` | -| [subscribePwmInvestmentPlan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5196) | :closed_lock_with_key: | POST | `/v5/earn/pwm/investment-plan/subscribe` | -| [investMorePwmInvestmentPlan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5205) | :closed_lock_with_key: | POST | `/v5/earn/pwm/investment-plan/invest-more` | -| [redeemPwmInvestmentPlan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5214) | :closed_lock_with_key: | POST | `/v5/earn/pwm/investment-plan/redeem` | -| [getPwmInvestmentPlanOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5223) | :closed_lock_with_key: | GET | `/v5/earn/pwm/investment-plan/order` | -| [getPwmSubscribableProductInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5232) | | GET | `/v5/earn/pwm/customize-plan/product` | -| [createPwmCustomizeInvestmentPlan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5241) | :closed_lock_with_key: | POST | `/v5/earn/pwm/customize-plan/create` | -| [getPwmAllFunds()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5256) | :closed_lock_with_key: | GET | `/v5/earn/pwm/asset-manager/all-funds` | -| [settlePwmFundProfit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5265) | :closed_lock_with_key: | POST | `/v5/earn/pwm/asset-manager/settle-profit` | -| [createPwmFund()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5274) | :closed_lock_with_key: | POST | `/v5/earn/pwm/asset-manager/create-fund` | -| [createPwmAssetManagerInvestmentPlan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5283) | :closed_lock_with_key: | POST | `/v5/earn/pwm/asset-manager/create-investment-plan` | -| [getPwmAssetManagerInvestmentPlans()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5297) | :closed_lock_with_key: | GET | `/v5/earn/pwm/asset-manager/get-investment-plan` | -| [managePwmAssetManagerInvestmentPlan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5309) | :closed_lock_with_key: | POST | `/v5/earn/pwm/asset-manager/manage-investment-plan` | -| [getPwmAllFundOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5323) | :closed_lock_with_key: | GET | `/v5/earn/pwm/asset-manager/all-order` | -| [managePwmFundOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5332) | :closed_lock_with_key: | POST | `/v5/earn/pwm/asset-manager/manage-order` | -| [createPwmFundSubAccount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5341) | :closed_lock_with_key: | POST | `/v5/earn/pwm/asset-manager/create-sub-account` | -| [pwmFundTransfer()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5353) | :closed_lock_with_key: | POST | `/v5/earn/pwm/fund-transfer` | -| [getPwmFundTransferRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5362) | :closed_lock_with_key: | GET | `/v5/earn/pwm/query-fund-transfer-result` | -| [queryCardAssetRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5377) | :closed_lock_with_key: | POST | `/v5/card/transaction/query-asset-records` | -| [queryCardPointsBalance()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5386) | :closed_lock_with_key: | POST | `/v5/card/reward/points/balance` | -| [queryCardPointsRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5393) | :closed_lock_with_key: | POST | `/v5/card/reward/points/records` | -| [queryCardPointsTier()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5402) | :closed_lock_with_key: | POST | `/v5/card/reward/points/tier` | -| [queryCardMallItemList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5409) | :closed_lock_with_key: | POST | `/v5/card/reward/mall/item/list` | -| [queryCardPointCashbackDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5418) | :closed_lock_with_key: | POST | `/v5/card/reward/point/cashback/detail` | -| [createRFQ()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5434) | :closed_lock_with_key: | POST | `/v5/rfq/create-rfq` | -| [getRFQConfig()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5445) | :closed_lock_with_key: | GET | `/v5/rfq/config` | -| [cancelRFQ()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5454) | :closed_lock_with_key: | POST | `/v5/rfq/cancel-rfq` | -| [cancelAllRFQ()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5464) | :closed_lock_with_key: | POST | `/v5/rfq/cancel-all-rfq` | -| [createRFQQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5473) | :closed_lock_with_key: | POST | `/v5/rfq/create-quote` | -| [executeRFQQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5484) | :closed_lock_with_key: | POST | `/v5/rfq/execute-quote` | -| [cancelRFQQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5495) | :closed_lock_with_key: | POST | `/v5/rfq/cancel-quote` | -| [cancelAllRFQQuotes()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5505) | :closed_lock_with_key: | POST | `/v5/rfq/cancel-all-quotes` | -| [getRFQRealtimeInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5519) | :closed_lock_with_key: | GET | `/v5/rfq/rfq-realtime` | -| [getRFQHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5531) | :closed_lock_with_key: | GET | `/v5/rfq/rfq-list` | -| [getRFQRealtimeQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5545) | :closed_lock_with_key: | GET | `/v5/rfq/quote-realtime` | -| [getRFQHistoryQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5560) | :closed_lock_with_key: | GET | `/v5/rfq/quote-list` | -| [getRFQTrades()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5573) | :closed_lock_with_key: | GET | `/v5/rfq/trade-list` | -| [getRFQPublicTrades()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5586) | :closed_lock_with_key: | GET | `/v5/rfq/public-trades` | -| [acceptNonLPQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5602) | :closed_lock_with_key: | POST | `/v5/rfq/accept-other-quote` | -| [getRFQDetails()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5608) | :closed_lock_with_key: | GET | `/v5/rfq/rfq-detail-list` | -| [getP2PAccountCoinsBalance()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5633) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-account-coins-balance` | -| [getP2POnlineAds()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5650) | :closed_lock_with_key: | POST | `/v5/p2p/item/online` | -| [createP2PAd()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5659) | :closed_lock_with_key: | POST | `/v5/p2p/item/create` | -| [cancelP2PAd()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5668) | :closed_lock_with_key: | POST | `/v5/p2p/item/cancel` | -| [updateP2PAd()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5682) | :closed_lock_with_key: | POST | `/v5/p2p/item/update` | -| [getP2PPersonalAds()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5692) | :closed_lock_with_key: | POST | `/v5/p2p/item/personal/list` | -| [getP2PAdDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5701) | :closed_lock_with_key: | POST | `/v5/p2p/item/info` | -| [getP2POrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5716) | :closed_lock_with_key: | POST | `/v5/p2p/order/simplifyList` | -| [getP2POrderDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5726) | :closed_lock_with_key: | POST | `/v5/p2p/order/info` | -| [getP2PPendingOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5735) | :closed_lock_with_key: | POST | `/v5/p2p/order/pending/simplifyList` | -| [markP2POrderAsPaid()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5744) | :closed_lock_with_key: | POST | `/v5/p2p/order/pay` | -| [releaseP2POrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5753) | :closed_lock_with_key: | POST | `/v5/p2p/order/finish` | -| [sendP2POrderMessage()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5762) | :closed_lock_with_key: | POST | `/v5/p2p/order/message/send` | -| [getP2PChatSessions()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5777) | :closed_lock_with_key: | POST | `/v5/p2p/chat/session/list_v1` | -| [getP2PChatSessionId()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5787) | :closed_lock_with_key: | POST | `/v5/p2p/chat/session/getSessionId` | -| [uploadP2PChatFile()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5805) | :closed_lock_with_key: | POST | `/v5/p2p/oss/upload_file` | -| [sendP2PChatMessage()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5823) | :closed_lock_with_key: | POST | `/v5/p2p/chat/message/send_v1` | -| [getP2PChatMessages()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5835) | :closed_lock_with_key: | POST | `/v5/p2p/chat/message/listpage_v1` | -| [getP2POrderMessages()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5844) | :closed_lock_with_key: | POST | `/v5/p2p/order/message/listpage` | -| [getP2PUserInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5858) | :closed_lock_with_key: | POST | `/v5/p2p/user/personal/info` | -| [getP2PCounterpartyUserInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5865) | :closed_lock_with_key: | POST | `/v5/p2p/user/order/personal/info` | -| [getP2PUserPayments()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5874) | :closed_lock_with_key: | POST | `/v5/p2p/user/payment/list` | -| [setApiRateLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5894) | :closed_lock_with_key: | POST | `/v5/apilimit/set` | -| [queryApiRateLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5923) | :closed_lock_with_key: | GET | `/v5/apilimit/query` | -| [getRateLimitCap()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5942) | :closed_lock_with_key: | GET | `/v5/apilimit/query-cap` | -| [getAllRateLimits()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5961) | :closed_lock_with_key: | GET | `/v5/apilimit/query-all` | -| [getLaunchpoolProjectList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5984) | | GET | `/v5/spot-x/launchpool/project/list` | -| [getLaunchpoolUserActivityLog()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5990) | :closed_lock_with_key: | POST | `/v5/spot-x/launchpool/user/activity-log` | -| [getLaunchpoolCurrentStaking()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5996) | :closed_lock_with_key: | GET | `/v5/spot-x/launchpool/user/current-staking` | -| [getLaunchpoolUserHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6002) | :closed_lock_with_key: | POST | `/v5/spot-x/launchpool/user/history` | -| [getPuzzleProjectList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6008) | | GET | `/v5/spot-x/puzzle/project/list` | -| [getTokenSplashProjectList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6014) | | GET | `/v5/spot-x/token-splash/project/list` | -| [getTokenSplashUserActivityParams()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6020) | :closed_lock_with_key: | GET | `/v5/spot-x/token-splash/user/activity-params` | -| [getEventInstrumentsInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6043) | | GET | `/v5/event/instruments-info` | -| [getEventOrderbook()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6054) | | GET | `/v5/event/orderbook` | -| [getEventOrderHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6065) | :closed_lock_with_key: | GET | `/v5/event/order-list` | -| [getEventActiveOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6076) | :closed_lock_with_key: | GET | `/v5/event/order-realtime` | -| [getEventPositionInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6087) | :closed_lock_with_key: | GET | `/v5/event/positions` | -| [getEventTradeHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6098) | :closed_lock_with_key: | GET | `/v5/event/trades` | -| [getEventSettlementRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6109) | :closed_lock_with_key: | GET | `/v5/event/settlements` | -| [submitEventQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6120) | :closed_lock_with_key: | POST | `/v5/event/quotes` | -| [cancelEventQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6131) | :closed_lock_with_key: | POST | `/v5/event/cancel` | +| [getSystemStatus()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L721) | :closed_lock_with_key: | GET | `/v5/system/status` | +| [getServerTime()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L738) | | GET | `/v5/market/time` | +| [requestDemoTradingFunds()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L750) | :closed_lock_with_key: | POST | `/v5/account/demo-apply-money` | +| [createDemoAccount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L763) | :closed_lock_with_key: | POST | `/v5/user/create-demo-member` | +| [getSpreadInstrumentsInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L776) | | GET | `/v5/spread/instrument` | +| [getSpreadOrderbook()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L788) | | GET | `/v5/spread/orderbook` | +| [getSpreadTickers()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L798) | | GET | `/v5/spread/tickers` | +| [getSpreadRecentTrades()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L809) | | GET | `/v5/spread/recent-trade` | +| [getSpreadMaxQty()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L821) | :closed_lock_with_key: | GET | `/v5/spread/max-qty` | +| [submitSpreadOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L830) | :closed_lock_with_key: | POST | `/v5/spread/order/create` | +| [amendSpreadOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L843) | :closed_lock_with_key: | POST | `/v5/spread/order/amend` | +| [cancelSpreadOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L855) | :closed_lock_with_key: | POST | `/v5/spread/order/cancel` | +| [cancelAllSpreadOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L873) | :closed_lock_with_key: | POST | `/v5/spread/order/cancel-all` | +| [getSpreadOpenOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L892) | :closed_lock_with_key: | GET | `/v5/spread/order/realtime` | +| [getSpreadOrderHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L909) | :closed_lock_with_key: | GET | `/v5/spread/order/history` | +| [getSpreadTradeHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L925) | :closed_lock_with_key: | GET | `/v5/spread/execution/list` | +| [getKline()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L945) | | GET | `/v5/market/kline` | +| [getMarkPriceKline()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L962) | | GET | `/v5/market/mark-price-kline` | +| [getIndexPriceKline()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L977) | | GET | `/v5/market/index-price-kline` | +| [getPremiumIndexPriceKline()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L992) | | GET | `/v5/market/premium-index-price-kline` | +| [getInstrumentsInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1008) | | GET | `/v5/market/instruments-info` | +| [getOrderbook()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1019) | | GET | `/v5/market/orderbook` | +| [getFullDepthOrderbook()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1025) | | GET | `/v5/market/full_orderbook` | +| [getRPIOrderbook()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1039) | | GET | `/v5/market/rpi_orderbook` | +| [getTickers()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1045) | | GET | `/v5/market/tickers` | +| [getFundingRateHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1083) | | GET | `/v5/market/funding/history` | +| [getPublicTradingHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1098) | | GET | `/v5/market/recent-trade` | +| [getOpenInterest()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1111) | | GET | `/v5/market/open-interest` | +| [getHistoricalVolatility()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1121) | | GET | `/v5/market/historical-volatility` | +| [getInsurance()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1132) | | GET | `/v5/market/insurance` | +| [getRiskLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1143) | | GET | `/v5/market/risk-limit` | +| [getOptionDeliveryPrice()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1158) | | GET | `/v5/market/delivery-price` | +| [getDeliveryPrice()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1171) | | GET | `/v5/market/delivery-price` | +| [getNewDeliveryPrice()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1187) | | GET | `/v5/market/new-delivery-price` | +| [getLongShortRatio()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1203) | | GET | `/v5/market/account-ratio` | +| [getIndexPriceComponents()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1213) | | GET | `/v5/market/index-price-components` | +| [getOrderPriceLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1219) | | GET | `/v5/market/price-limit` | +| [getADLAlert()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1233) | | GET | `/v5/market/adlAlert` | +| [getFeeGroupStructure()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1246) | | GET | `/v5/market/fee-group-info` | +| [getOptionBaseCoins()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1255) | | GET | `/v5/market/option-base-coins` | +| [submitOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1267) | :closed_lock_with_key: | POST | `/v5/order/create` | +| [amendOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1273) | :closed_lock_with_key: | POST | `/v5/order/amend` | +| [cancelOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1279) | :closed_lock_with_key: | POST | `/v5/order/cancel` | +| [getActiveOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1288) | :closed_lock_with_key: | GET | `/v5/order/realtime` | +| [cancelAllOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1294) | :closed_lock_with_key: | POST | `/v5/order/cancel-all` | +| [getHistoricOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1307) | :closed_lock_with_key: | GET | `/v5/order/history` | +| [getExecutionList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1319) | :closed_lock_with_key: | GET | `/v5/execution/list` | +| [batchSubmitOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1337) | :closed_lock_with_key: | POST | `/v5/order/create-batch` | +| [batchAmendOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1362) | :closed_lock_with_key: | POST | `/v5/order/amend-batch` | +| [batchCancelOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1387) | :closed_lock_with_key: | POST | `/v5/order/cancel-batch` | +| [getSpotBorrowCheck()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1409) | :closed_lock_with_key: | GET | `/v5/order/spot-borrow-check` | +| [setDisconnectCancelAllWindow()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1430) | :closed_lock_with_key: | POST | `/v5/order/disconnected-cancel-all` | +| [setDisconnectCancelAllWindowV2()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1448) | :closed_lock_with_key: | POST | `/v5/order/disconnected-cancel-all` | +| [preCheckOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1463) | :closed_lock_with_key: | POST | `/v5/order/pre-check` | +| [createStrategyOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1480) | :closed_lock_with_key: | POST | `/v5/strategy/create` | +| [getStrategyList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1491) | :closed_lock_with_key: | GET | `/v5/strategy/list` | +| [getStrategyOrderList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1502) | :closed_lock_with_key: | GET | `/v5/strategy/order-list` | +| [stopStrategy()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1513) | :closed_lock_with_key: | POST | `/v5/strategy/stop` | +| [getPositionInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1538) | :closed_lock_with_key: | GET | `/v5/position/list` | +| [getFuturesLeverage()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1550) | :closed_lock_with_key: | GET | `/v5/position/symbol-info` | +| [setLeverage()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1565) | :closed_lock_with_key: | POST | `/v5/position/set-leverage` | +| [switchIsolatedMargin()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1578) | :closed_lock_with_key: | POST | `/v5/position/switch-isolated` | +| [setTPSLMode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1592) | :closed_lock_with_key: | POST | `/v5/position/set-tpsl-mode` | +| [switchPositionMode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1607) | :closed_lock_with_key: | POST | `/v5/position/switch-mode` | +| [setRiskLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1621) | :closed_lock_with_key: | POST | `/v5/position/set-risk-limit` | +| [setTradingStop()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1636) | :closed_lock_with_key: | POST | `/v5/position/trading-stop` | +| [setAutoAddMargin()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1647) | :closed_lock_with_key: | POST | `/v5/position/set-auto-add-margin` | +| [addOrReduceMargin()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1659) | :closed_lock_with_key: | POST | `/v5/position/add-margin` | +| [getClosedPnL()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1671) | :closed_lock_with_key: | GET | `/v5/position/closed-pnl` | +| [getClosedOptionsPositions()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1685) | :closed_lock_with_key: | GET | `/v5/position/get-closed-positions` | +| [movePosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1710) | :closed_lock_with_key: | POST | `/v5/position/move-positions` | +| [getMovePositionHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1721) | :closed_lock_with_key: | GET | `/v5/position/move-history` | +| [confirmNewRiskLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1740) | :closed_lock_with_key: | POST | `/v5/position/confirm-pending-mmr` | +| [getPreUpgradeOrderHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1760) | :closed_lock_with_key: | GET | `/v5/pre-upgrade/order/history` | +| [getPreUpgradeTradeHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1775) | :closed_lock_with_key: | GET | `/v5/pre-upgrade/execution/list` | +| [getPreUpgradeClosedPnl()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1786) | :closed_lock_with_key: | GET | `/v5/pre-upgrade/position/closed-pnl` | +| [getPreUpgradeTransactions()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1800) | :closed_lock_with_key: | GET | `/v5/pre-upgrade/account/transaction-log` | +| [getPreUpgradeOptionDeliveryRecord()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1817) | :closed_lock_with_key: | GET | `/v5/pre-upgrade/asset/delivery-record` | +| [getPreUpgradeUSDCSessionSettlements()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1831) | :closed_lock_with_key: | GET | `/v5/pre-upgrade/asset/settlement-record` | +| [getWalletBalance()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1852) | :closed_lock_with_key: | GET | `/v5/account/wallet-balance` | +| [getTransferableAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1863) | :closed_lock_with_key: | GET | `/v5/account/withdrawal` | +| [getAccountInstrumentsInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1880) | :closed_lock_with_key: | GET | `/v5/account/instruments-info` | +| [upgradeToUnifiedAccount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1891) | :closed_lock_with_key: | POST | `/v5/account/upgrade-to-uta` | +| [getBorrowHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1902) | :closed_lock_with_key: | GET | `/v5/account/borrow-history` | +| [repayLiability()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1923) | :closed_lock_with_key: | POST | `/v5/account/quick-repayment` | +| [manualRepay()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1948) | :closed_lock_with_key: | POST | `/v5/account/repay` | +| [setCollateralCoin()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1957) | :closed_lock_with_key: | POST | `/v5/account/set-collateral-switch` | +| [batchSetCollateralCoin()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1963) | :closed_lock_with_key: | POST | `/v5/account/set-collateral-switch-batch` | +| [getCollateralInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1973) | :closed_lock_with_key: | GET | `/v5/account/collateral-info` | +| [getCoinGreeks()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1982) | :closed_lock_with_key: | GET | `/v5/asset/coin-greeks` | +| [getFeeRate()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L1995) | :closed_lock_with_key: | GET | `/v5/account/fee-rate` | +| [getAccountInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2004) | :closed_lock_with_key: | GET | `/v5/account/info` | +| [getDCPInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2017) | :closed_lock_with_key: | GET | `/v5/account/query-dcp-info` | +| [getTransactionLog()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2024) | :closed_lock_with_key: | GET | `/v5/account/transaction-log` | +| [getClassicTransactionLogs()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2035) | :closed_lock_with_key: | GET | `/v5/account/contract-transaction-log` | +| [getSMPGroup()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2046) | :closed_lock_with_key: | GET | `/v5/account/smp-group` | +| [setMarginMode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2059) | :closed_lock_with_key: | POST | `/v5/account/set-margin-mode` | +| [setSpotHedging()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2076) | :closed_lock_with_key: | POST | `/v5/account/set-hedging-mode` | +| [setLimitPriceAction()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2089) | :closed_lock_with_key: | POST | `/v5/account/set-limit-px-action` | +| [getLimitPriceAction()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2100) | :closed_lock_with_key: | GET | `/v5/account/user-setting-config` | +| [setDeltaNeutralMode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2108) | :closed_lock_with_key: | POST | `/v5/account/set-delta-mode` | +| [setMMP()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2117) | :closed_lock_with_key: | POST | `/v5/account/mmp-modify` | +| [resetMMP()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2124) | :closed_lock_with_key: | POST | `/v5/account/mmp-reset` | +| [getMMPState()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2131) | :closed_lock_with_key: | GET | `/v5/account/mmp-state` | +| [getOptionAssetInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2141) | :closed_lock_with_key: | GET | `/v5/account/option-asset-info` | +| [getPayInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2151) | :closed_lock_with_key: | GET | `/v5/account/pay-info` | +| [getTradeInfoForAnalysis()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2161) | :closed_lock_with_key: | GET | `/v5/account/trade-info-for-analysis` | +| [getAssetOverview()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2181) | :closed_lock_with_key: | GET | `/v5/asset/asset-overview` | +| [getPortfolioMarginInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2191) | :closed_lock_with_key: | GET | `/v5/asset/portfolio-margin` | +| [getTotalMembersAssets()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2201) | :closed_lock_with_key: | GET | `/v5/asset/total-members-assets` | +| [getFundingAccountTransactionHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2213) | :closed_lock_with_key: | GET | `/v5/asset/fundinghistory` | +| [getDeliveryRecord()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2229) | :closed_lock_with_key: | GET | `/v5/asset/delivery-record` | +| [getSettlementRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2240) | :closed_lock_with_key: | GET | `/v5/asset/settlement-record` | +| [getCoinExchangeRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2253) | :closed_lock_with_key: | GET | `/v5/asset/exchange/order-record` | +| [getCoinInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2268) | :closed_lock_with_key: | GET | `/v5/asset/coin/query-info` | +| [getSubUID()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2282) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-sub-member-list` | +| [getAssetInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2297) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-asset-info` | +| [getAllCoinsBalance()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2308) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-account-coins-balance` | +| [getCoinBalance()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2322) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-account-coin-balance` | +| [getWithdrawableAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2336) | :closed_lock_with_key: | GET | `/v5/asset/withdraw/withdrawable-amount` | +| [getTransferableCoinList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2345) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-transfer-coin-list` | +| [createInternalTransfer()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2361) | :closed_lock_with_key: | POST | `/v5/asset/transfer/inter-transfer` | +| [getInternalTransferRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2380) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-inter-transfer-list` | +| [enableUniversalTransferForSubUIDs()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2400) | :closed_lock_with_key: | POST | `/v5/asset/transfer/save-transfer-sub-member` | +| [createUniversalTransfer()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2411) | :closed_lock_with_key: | POST | `/v5/asset/transfer/universal-transfer` | +| [getUniversalTransferRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2423) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-universal-transfer-list` | +| [getAllowedDepositCoinInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2436) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-allowed-list` | +| [setDepositAccount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2451) | :closed_lock_with_key: | POST | `/v5/asset/deposit/deposit-to-account` | +| [getDepositRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2467) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-record` | +| [getSubAccountDepositRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2482) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-sub-member-record` | +| [getInternalDepositRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2498) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-internal-record` | +| [getMasterDepositAddress()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2510) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-address` | +| [getSubDepositAddress()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2528) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-sub-member-address` | +| [querySubMemberAddress()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2553) | :closed_lock_with_key: | GET | `/v5/asset/deposit/query-sub-member-address` | +| [getWithdrawalRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2573) | :closed_lock_with_key: | GET | `/v5/asset/withdraw/query-record` | +| [getWithdrawalAddressList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2585) | :closed_lock_with_key: | GET | `/v5/asset/withdraw/query-address` | +| [getExchangeEntities()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2599) | :closed_lock_with_key: | GET | `/v5/asset/withdraw/vasp/list` | +| [submitDepositOriginatorInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2609) | :closed_lock_with_key: | POST | `/v5/asset/travel-rule/deposit/submit` | +| [submitWithdrawal()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2624) | :closed_lock_with_key: | POST | `/v5/asset/withdraw/create` | +| [cancelWithdrawal()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2635) | :closed_lock_with_key: | POST | `/v5/asset/withdraw/cancel` | +| [getConvertCoins()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2644) | :closed_lock_with_key: | GET | `/v5/asset/exchange/query-coin-list` | +| [requestConvertQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2655) | :closed_lock_with_key: | POST | `/v5/asset/exchange/quote-apply` | +| [confirmConvertQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2664) | :closed_lock_with_key: | POST | `/v5/asset/exchange/convert-execute` | +| [getConvertStatus()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2676) | :closed_lock_with_key: | GET | `/v5/asset/exchange/convert-result-query` | +| [getConvertHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2695) | :closed_lock_with_key: | GET | `/v5/asset/exchange/query-convert-history` | +| [getSmallBalanceList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2712) | :closed_lock_with_key: | GET | `/v5/asset/covert/small-balance-list` | +| [getFiatTradingPairList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2726) | :closed_lock_with_key: | GET | `/v5/fiat/query-coin-list` | +| [createSubMember()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2744) | :closed_lock_with_key: | POST | `/v5/user/create-sub-member` | +| [createSubUIDAPIKey()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2756) | :closed_lock_with_key: | POST | `/v5/user/create-sub-api` | +| [getSubUIDList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2765) | :closed_lock_with_key: | GET | `/v5/user/query-sub-members` | +| [getSubUIDListUnlimited()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2774) | :closed_lock_with_key: | GET | `/v5/user/submembers` | +| [setSubUIDFrozenState()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2792) | :closed_lock_with_key: | POST | `/v5/user/frozen-sub-member` | +| [getQueryApiKey()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2807) | :closed_lock_with_key: | GET | `/v5/user/query-api` | +| [getSubAccountAllApiKeys()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2814) | :closed_lock_with_key: | GET | `/v5/user/sub-apikeys` | +| [getUIDWalletType()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2823) | :closed_lock_with_key: | GET | `/v5/user/get-member-type` | +| [updateMasterApiKey()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2842) | :closed_lock_with_key: | POST | `/v5/user/update-api` | +| [updateSubApiKey()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2856) | :closed_lock_with_key: | POST | `/v5/user/update-sub-api` | +| [deleteSubMember()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2869) | :closed_lock_with_key: | POST | `/v5/user/del-submember` | +| [deleteMasterApiKey()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2884) | :closed_lock_with_key: | POST | `/v5/user/delete-api` | +| [deleteSubApiKey()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2898) | :closed_lock_with_key: | POST | `/v5/user/delete-sub-api` | +| [createTaxBatchExport()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2913) | :closed_lock_with_key: | POST | `/v5/fht/compliance/tax/private/batch_create` | +| [getTaxBatchExport()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2925) | :closed_lock_with_key: | GET | `/v5/fht/compliance/tax/private/batch_query` | +| [getAffiliateUserList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2948) | :closed_lock_with_key: | GET | `/v5/affiliate/aff-user-list` | +| [getAffiliateSubAffiliateList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2966) | :closed_lock_with_key: | GET | `/v5/affiliate/affiliate-sub-list` | +| [getAffiliateUserInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2982) | :closed_lock_with_key: | GET | `/v5/user/aff-customer-info` | +| [getFriendReferrals()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L2994) | :closed_lock_with_key: | GET | `/v5/user/invitation/referrals` | +| [getReferralCode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3003) | :closed_lock_with_key: | GET | `/v5/user/invitation/code` | +| [signAgreement()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3019) | :closed_lock_with_key: | POST | `/v5/user/agreement` | +| [getAlphaTradeQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3036) | :closed_lock_with_key: | POST | `/v5/alpha/trade/quote` | +| [executeAlphaTradePurchase()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3047) | :closed_lock_with_key: | POST | `/v5/alpha/trade/purchase` | +| [executeAlphaTradeRedeem()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3058) | :closed_lock_with_key: | POST | `/v5/alpha/trade/redeem` | +| [getAlphaPayTokenList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3068) | :closed_lock_with_key: | POST | `/v5/alpha/trade/pay-token-list` | +| [getAlphaTradeOrderList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3078) | :closed_lock_with_key: | POST | `/v5/alpha/trade/order-list` | +| [getAlphaBizTokenList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3088) | :closed_lock_with_key: | POST | `/v5/alpha/trade/biz-token-list` | +| [getAlphaBizTokenPriceList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3098) | :closed_lock_with_key: | POST | `/v5/alpha/trade/biz-token-price-list` | +| [getAlphaBizTokenDetails()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3108) | :closed_lock_with_key: | POST | `/v5/alpha/trade/biz-token-details` | +| [getAlphaAssetList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3118) | :closed_lock_with_key: | POST | `/v5/alpha/trade/asset-list` | +| [getAlphaAssetDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3126) | :closed_lock_with_key: | POST | `/v5/alpha/trade/asset-detail` | +| [getAlphaPredictionEngineStatus()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3142) | :closed_lock_with_key: | GET | `/v5/alpha/prediction/engine-status` | +| [getAlphaPredictionPayTokenList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3152) | :closed_lock_with_key: | GET | `/v5/alpha/prediction/pay-token-list` | +| [getAlphaPredictionEventDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3162) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/event-detail` | +| [getAlphaPredictionOrderEstimate()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3172) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/order-estimate` | +| [executeAlphaPredictionBuy()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3182) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/buy` | +| [executeAlphaPredictionSell()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3192) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/sell` | +| [getAlphaPredictionOrderList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3202) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/order-list` | +| [getAlphaPredictionOrderBook()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3212) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/order-book` | +| [getAlphaPredictionTokenPrice()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3222) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/token-price` | +| [getAlphaPredictionPriceHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3232) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/price-history` | +| [getAlphaPredictionPositionList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3242) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/position-list` | +| [getAlphaPredictionPositionHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3252) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/position-history` | +| [getAlphaPredictionPortfolioSummary()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3262) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/portfolio-summary` | +| [getAlphaPredictionSideMarketList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3272) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/side-market-list` | +| [getAlphaPredictionSportsMatchList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3282) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/sports/match-list` | +| [getAlphaPredictionSportsTimelineStages()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3292) | :closed_lock_with_key: | GET | `/v5/alpha/prediction/sports/timeline-stages` | +| [getAlphaPredictionSportsGroupStageDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3305) | :closed_lock_with_key: | POST | `/v5/alpha/prediction/sports/group-stage-detail` | +| [getAlphaLPPoolList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3324) | :closed_lock_with_key: | POST | `/v5/alpha/lp/pool-list` | +| [getAlphaLPPoolInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3334) | :closed_lock_with_key: | POST | `/v5/alpha/lp/pool-info` | +| [executeAlphaLPStake()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3344) | :closed_lock_with_key: | POST | `/v5/alpha/lp/stake` | +| [executeAlphaLPRedeem()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3354) | :closed_lock_with_key: | POST | `/v5/alpha/lp/redeem` | +| [getAlphaLPOrderList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3364) | :closed_lock_with_key: | POST | `/v5/alpha/lp/order-list` | +| [getAlphaLPPayTokenList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3374) | :closed_lock_with_key: | POST | `/v5/alpha/lp/pay-token-list` | +| [getAlphaLPPayTokenPrice()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3384) | :closed_lock_with_key: | POST | `/v5/alpha/lp/pay-token-price` | +| [getAlphaLPPositionList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3394) | :closed_lock_with_key: | POST | `/v5/alpha/lp/position-list` | +| [getVIPMarginData()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3414) | | GET | `/v5/spot-margin-trade/data` | +| [getHistoricalInterestRate()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3425) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/interest-rate-history` | +| [getSpotMarginCurrencyData()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3450) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/currency-data` | +| [toggleSpotMarginTrade()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3462) | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/switch-mode` | +| [setSpotMarginLeverage()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3473) | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/set-leverage` | +| [setSpotMarginLeverageV2()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3481) | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/set-leverage` | +| [getSpotMarginState()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3492) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/state` | +| [manualBorrow()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3499) | :closed_lock_with_key: | POST | `/v5/account/borrow` | +| [getMaxBorrowableAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3508) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/max-borrowable` | +| [getPositionTiers()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3517) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/position-tiers` | +| [getCoinState()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3528) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/coinstate` | +| [getAvailableAmountToRepay()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3539) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/repayment-available-amount` | +| [manualRepayWithoutConversion()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3558) | :closed_lock_with_key: | POST | `/v5/account/no-convert-repay` | +| [getAutoRepayMode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3571) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/get-auto-repay-mode` | +| [setAutoRepayMode()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3587) | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/set-auto-repay-mode` | +| [getSpotMarginLiability()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3599) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/liability` | +| [submitFixedRateBorrow()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3608) | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/fixedborrow` | +| [getFixedRateBorrowOrderInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3617) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/fixedborrow-order-info` | +| [getFixedRateBorrowContractInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3634) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/fixedborrow-contract-info` | +| [getFixedRateBorrowOrderQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3651) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/fixedborrow-order-quote` | +| [renewFixedRateBorrow()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3663) | :closed_lock_with_key: | POST | `/v5/spot-margin-trade/fixedborrow-renew` | +| [getFlexibleAvailableInventory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3669) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/flexible-available-inventory` | +| [getFixedRateAvailableInventory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3678) | :closed_lock_with_key: | GET | `/v5/spot-margin-trade/fixed-available-inventory` | +| [getSpotMarginCoinInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3696) | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/pledge-token` | +| [getSpotMarginBorrowableCoinInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3713) | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/borrow-token` | +| [getSpotMarginInterestAndQuota()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3730) | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/loan-info` | +| [getSpotMarginLoanAccountInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3748) | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/account` | +| [spotMarginBorrow()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3772) | :closed_lock_with_key: | POST | `/v5/spot-cross-margin-trade/loan` | +| [spotMarginRepay()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3783) | :closed_lock_with_key: | POST | `/v5/spot-cross-margin-trade/repay` | +| [getSpotMarginBorrowOrderDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3798) | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/orders` | +| [getSpotMarginRepaymentOrderDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3827) | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/repay-history` | +| [toggleSpotCrossMarginTrade()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3856) | :closed_lock_with_key: | POST | `/v5/spot-cross-margin-trade/switch` | +| [getCollateralCoins()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3876) | | GET | `/v5/crypto-loan/collateral-data` | +| [getBorrowableCoins()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3893) | | GET | `/v5/crypto-loan/loanable-data` | +| [getAccountBorrowCollateralLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3911) | :closed_lock_with_key: | GET | `/v5/crypto-loan/borrowable-collateralisable-number` | +| [borrowCryptoLoan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3931) | :closed_lock_with_key: | POST | `/v5/crypto-loan/borrow` | +| [repayCryptoLoan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3952) | :closed_lock_with_key: | POST | `/v5/crypto-loan/repay` | +| [getUnpaidLoanOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3968) | :closed_lock_with_key: | GET | `/v5/crypto-loan/ongoing-orders` | +| [getRepaymentHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L3989) | :closed_lock_with_key: | GET | `/v5/crypto-loan/repayment-history` | +| [getCompletedLoanOrderHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4009) | :closed_lock_with_key: | GET | `/v5/crypto-loan/borrow-history` | +| [getMaxAllowedReductionCollateralAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4028) | :closed_lock_with_key: | GET | `/v5/crypto-loan/max-collateral-amount` | +| [adjustCollateralAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4047) | :closed_lock_with_key: | POST | `/v5/crypto-loan/adjust-ltv` | +| [getLoanLTVAdjustmentHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4071) | :closed_lock_with_key: | GET | `/v5/crypto-loan/adjustment-history` | +| [getLoanBorrowableCoins()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4092) | | GET | `/v5/crypto-loan-common/loanable-data` | +| [getLoanCollateralCoins()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4104) | | GET | `/v5/crypto-loan-common/collateral-data` | +| [getMaxCollateralAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4114) | :closed_lock_with_key: | GET | `/v5/crypto-loan-common/max-collateral-amount` | +| [getMaxLoanAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4133) | :closed_lock_with_key: | POST | `/v5/crypto-loan-common/max-loan` | +| [updateCollateralAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4143) | :closed_lock_with_key: | POST | `/v5/crypto-loan-common/adjust-ltv` | +| [getCollateralAdjustmentHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4154) | :closed_lock_with_key: | GET | `/v5/crypto-loan-common/adjustment-history` | +| [getCryptoLoanPosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4169) | :closed_lock_with_key: | GET | `/v5/crypto-loan-common/position` | +| [borrowFlexible()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4186) | :closed_lock_with_key: | POST | `/v5/crypto-loan-flexible/borrow` | +| [repayFlexible()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4197) | :closed_lock_with_key: | POST | `/v5/crypto-loan-flexible/repay` | +| [repayCollateralFlexible()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4207) | :closed_lock_with_key: | POST | `/v5/crypto-loan-flexible/repay-collateral` | +| [getOngoingFlexibleLoans()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4221) | :closed_lock_with_key: | GET | `/v5/crypto-loan-flexible/ongoing-coin` | +| [getBorrowHistoryFlexible()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4233) | :closed_lock_with_key: | GET | `/v5/crypto-loan-flexible/borrow-history` | +| [getRepaymentHistoryFlexible()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4246) | :closed_lock_with_key: | GET | `/v5/crypto-loan-flexible/repayment-history` | +| [getFlexibleLoanAvailableInventory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4260) | :closed_lock_with_key: | GET | `/v5/crypto-loan-flexible/available-inventory` | +| [getSupplyOrderQuoteFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4280) | | GET | `/v5/crypto-loan-fixed/supply-order-quote` | +| [getBorrowOrderQuoteFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4293) | | GET | `/v5/crypto-loan-fixed/borrow-order-quote` | +| [createBorrowOrderFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4306) | :closed_lock_with_key: | POST | `/v5/crypto-loan-fixed/borrow` | +| [createSupplyOrderFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4319) | :closed_lock_with_key: | POST | `/v5/crypto-loan-fixed/supply` | +| [cancelBorrowOrderFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4329) | :closed_lock_with_key: | POST | `/v5/crypto-loan-fixed/borrow-order-cancel` | +| [cancelSupplyOrderFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4343) | :closed_lock_with_key: | POST | `/v5/crypto-loan-fixed/supply-order-cancel` | +| [getBorrowContractInfoFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4356) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/borrow-contract-info` | +| [getSupplyContractInfoFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4374) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/supply-contract-info` | +| [getBorrowOrderInfoFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4392) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/borrow-order-info` | +| [getSupplyOrderInfoFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4405) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/supply-order-info` | +| [repayFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4419) | :closed_lock_with_key: | POST | `/v5/crypto-loan-fixed/fully-repay` | +| [repayCollateralFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4430) | :closed_lock_with_key: | POST | `/v5/crypto-loan-flexible/repay-collateral` | +| [getRepaymentHistoryFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4443) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/repayment-history` | +| [renewBorrowOrderFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4460) | :closed_lock_with_key: | POST | `/v5/crypto-loan-fixed/renew` | +| [getRenewOrderInfoFixed()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4473) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/renew-info` | +| [getFixedLoanAvailableInventory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4482) | :closed_lock_with_key: | GET | `/v5/crypto-loan-fixed/available-inventory` | +| [getInstitutionalLendingProductInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4497) | | GET | `/v5/ins-loan/product-infos` | +| [getInstitutionalLendingCoinDeltaAmount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4509) | :closed_lock_with_key: | GET | `/v5/ins-loan/coin-delta-amount` | +| [getInstitutionalLendingDelayLiquidationStatus()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4518) | :closed_lock_with_key: | GET | `/v5/ins-loan/delay-liq-status` | +| [getInstitutionalLendingMarginCoinInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4528) | | GET | `/v5/ins-loan/ensure-tokens` | +| [getInstitutionalLendingMarginCoinInfoWithConversionRate()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4537) | | GET | `/v5/ins-loan/ensure-tokens-convert` | +| [getInstitutionalLendingLoanOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4546) | :closed_lock_with_key: | GET | `/v5/ins-loan/loan-order` | +| [getInstitutionalLendingRepayOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4558) | :closed_lock_with_key: | GET | `/v5/ins-loan/repaid-history` | +| [getInstitutionalLendingLTV()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4570) | :closed_lock_with_key: | GET | `/v5/ins-loan/ltv` | +| [getInstitutionalLendingLTVWithLadderConversionRate()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4579) | :closed_lock_with_key: | GET | `/v5/ins-loan/ltv-convert` | +| [bindOrUnbindUID()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4594) | :closed_lock_with_key: | POST | `/v5/ins-loan/association-uid` | +| [repayInstitutionalLoan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4614) | :closed_lock_with_key: | POST | `/v5/ins-loan/repay-loan` | +| [getExchangeBrokerEarnings()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4635) | :closed_lock_with_key: | GET | `/v5/broker/earnings-info` | +| [getExchangeBrokerAccountInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4648) | :closed_lock_with_key: | GET | `/v5/broker/account-info` | +| [getBrokerSubAccountDeposits()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4664) | :closed_lock_with_key: | GET | `/v5/broker/asset/query-sub-member-deposit-record` | +| [getBrokerVoucherSpec()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4679) | :closed_lock_with_key: | POST | `/v5/broker/award/info` | +| [issueBrokerVoucher()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4691) | :closed_lock_with_key: | POST | `/v5/broker/award/distribute-award` | +| [getBrokerIssuedVoucher()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4703) | :closed_lock_with_key: | POST | `/v5/broker/award/distribution-record` | +| [setBrokerRateLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4720) | :closed_lock_with_key: | POST | `/v5/broker/apilimit/set` | +| [getBrokerRateLimitCap()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4739) | :closed_lock_with_key: | GET | `/v5/broker/apilimit/query-cap` | +| [getAllBrokerRateLimits()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4757) | :closed_lock_with_key: | GET | `/v5/broker/apilimit/query-all` | +| [getEarnProduct()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4777) | | GET | `/v5/earn/product` | +| [getFlexibleSavingAutoSavings()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4788) | :closed_lock_with_key: | GET | `/v5/earn/flexible-saving/auto-savings` | +| [setFlexibleSavingAutoSavings()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4797) | :closed_lock_with_key: | POST | `/v5/earn/flexible-saving/auto-savings` | +| [getEarnCouponList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4807) | :closed_lock_with_key: | GET | `/v5/earn/coupons` | +| [getRWAProductList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4817) | | GET | `/v5/earn/rwa/product` | +| [placeRWAOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4827) | :closed_lock_with_key: | POST | `/v5/earn/rwa/place-order` | +| [getRWAPositionList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4836) | :closed_lock_with_key: | GET | `/v5/earn/rwa/position` | +| [getRWAOrderList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4845) | :closed_lock_with_key: | GET | `/v5/earn/rwa/order` | +| [getRWANavChart()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4855) | | GET | `/v5/earn/rwa/nav-chart` | +| [getHoldToEarnAirdropProducts()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4866) | | GET | `/v5/earn/hold-to-earn/product` | +| [getAdvanceEarnProduct()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4877) | | GET | `/v5/earn/advance/product` | +| [getLiquidityMiningProduct()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4888) | | GET | `/v5/earn/liquidity-mining/product` | +| [reinvestLiquidityMining()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4901) | :closed_lock_with_key: | POST | `/v5/earn/liquidity-mining/reinvest` | +| [getFixedTermEarnProduct()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4912) | | GET | `/v5/earn/fixed-term/product` | +| [getAdvanceEarnProductExtraInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4924) | | GET | `/v5/earn/advance/product-extra-info` | +| [submitAdvanceEarnPlaceOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4935) | :closed_lock_with_key: | POST | `/v5/earn/advance/place-order` | +| [getAdvanceEarnPosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4946) | :closed_lock_with_key: | GET | `/v5/earn/advance/position` | +| [getAdvanceEarnOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4957) | :closed_lock_with_key: | GET | `/v5/earn/advance/order` | +| [submitFixedTermEarnOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4968) | :closed_lock_with_key: | POST | `/v5/earn/fixed-term/place-order` | +| [redeemFixedTermEarn()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4979) | :closed_lock_with_key: | POST | `/v5/earn/fixed-term/redeem` | +| [getFixedTermEarnPosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L4990) | :closed_lock_with_key: | GET | `/v5/earn/fixed-term/position` | +| [getFixedTermEarnOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5001) | :closed_lock_with_key: | GET | `/v5/earn/fixed-term/order` | +| [setFixedTermEarnAutoInvest()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5012) | :closed_lock_with_key: | POST | `/v5/earn/fixed-term/position/auto-invest` | +| [submitStakeRedeem()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5028) | :closed_lock_with_key: | POST | `/v5/earn/place-order` | +| [getEarnOrderHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5047) | :closed_lock_with_key: | GET | `/v5/earn/order` | +| [getEarnPosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5065) | :closed_lock_with_key: | GET | `/v5/earn/position` | +| [modifyEarnPosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5078) | :closed_lock_with_key: | POST | `/v5/earn/position/modify` | +| [getEarnYieldHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5091) | :closed_lock_with_key: | GET | `/v5/earn/yield` | +| [getHoldToEarnAirdropYieldHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5105) | :closed_lock_with_key: | GET | `/v5/earn/hold-to-earn/yield-history` | +| [getEarnHourlyYieldHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5116) | :closed_lock_with_key: | GET | `/v5/earn/hourly-yield` | +| [getEarnAprHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5130) | | GET | `/v5/earn/apr-history` | +| [getEarnTokenProduct()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5140) | | GET | `/v5/earn/token/product` | +| [submitEarnTokenOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5149) | :closed_lock_with_key: | POST | `/v5/earn/token/place-order` | +| [getEarnTokenOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5158) | :closed_lock_with_key: | GET | `/v5/earn/token/order` | +| [getEarnTokenPosition()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5170) | :closed_lock_with_key: | GET | `/v5/earn/token/position` | +| [getEarnTokenDailyYield()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5179) | :closed_lock_with_key: | GET | `/v5/earn/token/yield` | +| [getEarnTokenHourlyYield()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5191) | :closed_lock_with_key: | GET | `/v5/earn/token/hourly-yield` | +| [getEarnTokenHistoryApr()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5203) | | GET | `/v5/earn/token/history-apr` | +| [getPwmInvestmentPlanList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5218) | :closed_lock_with_key: | GET | `/v5/earn/pwm/investment-plan/list` | +| [getPwmInvestmentPlanDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5227) | :closed_lock_with_key: | GET | `/v5/earn/pwm/investment-plan/detail` | +| [getPwmPendingInvestmentPlanDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5236) | :closed_lock_with_key: | GET | `/v5/earn/pwm/investment-plan/new-plan` | +| [claimPwmWithdrawableFunds()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5245) | :closed_lock_with_key: | POST | `/v5/earn/pwm/investment-plan/claim` | +| [getPwmInvestmentPlanAssetTrend()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5254) | :closed_lock_with_key: | GET | `/v5/earn/pwm/investment-plan/asset-trend` | +| [getPwmFundHistoricalNav()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5263) | :closed_lock_with_key: | GET | `/v5/earn/pwm/investment-plan/fund-nav` | +| [subscribePwmInvestmentPlan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5272) | :closed_lock_with_key: | POST | `/v5/earn/pwm/investment-plan/subscribe` | +| [investMorePwmInvestmentPlan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5281) | :closed_lock_with_key: | POST | `/v5/earn/pwm/investment-plan/invest-more` | +| [redeemPwmInvestmentPlan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5290) | :closed_lock_with_key: | POST | `/v5/earn/pwm/investment-plan/redeem` | +| [getPwmInvestmentPlanOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5299) | :closed_lock_with_key: | GET | `/v5/earn/pwm/investment-plan/order` | +| [getPwmSubscribableProductInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5308) | | GET | `/v5/earn/pwm/customize-plan/product` | +| [createPwmCustomizeInvestmentPlan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5317) | :closed_lock_with_key: | POST | `/v5/earn/pwm/customize-plan/create` | +| [getPwmAllFunds()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5332) | :closed_lock_with_key: | GET | `/v5/earn/pwm/asset-manager/all-funds` | +| [settlePwmFundProfit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5341) | :closed_lock_with_key: | POST | `/v5/earn/pwm/asset-manager/settle-profit` | +| [createPwmFund()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5350) | :closed_lock_with_key: | POST | `/v5/earn/pwm/asset-manager/create-fund` | +| [createPwmAssetManagerInvestmentPlan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5359) | :closed_lock_with_key: | POST | `/v5/earn/pwm/asset-manager/create-investment-plan` | +| [getPwmAssetManagerInvestmentPlans()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5373) | :closed_lock_with_key: | GET | `/v5/earn/pwm/asset-manager/get-investment-plan` | +| [managePwmAssetManagerInvestmentPlan()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5385) | :closed_lock_with_key: | POST | `/v5/earn/pwm/asset-manager/manage-investment-plan` | +| [getPwmAllFundOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5399) | :closed_lock_with_key: | GET | `/v5/earn/pwm/asset-manager/all-order` | +| [managePwmFundOrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5408) | :closed_lock_with_key: | POST | `/v5/earn/pwm/asset-manager/manage-order` | +| [createPwmFundSubAccount()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5417) | :closed_lock_with_key: | POST | `/v5/earn/pwm/asset-manager/create-sub-account` | +| [pwmFundTransfer()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5429) | :closed_lock_with_key: | POST | `/v5/earn/pwm/fund-transfer` | +| [getPwmFundTransferRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5438) | :closed_lock_with_key: | GET | `/v5/earn/pwm/query-fund-transfer-result` | +| [queryCardAssetRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5453) | :closed_lock_with_key: | POST | `/v5/card/transaction/query-asset-records` | +| [queryCardPointsBalance()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5462) | :closed_lock_with_key: | POST | `/v5/card/reward/points/balance` | +| [queryCardPointsRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5469) | :closed_lock_with_key: | POST | `/v5/card/reward/points/records` | +| [queryCardPointsTier()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5478) | :closed_lock_with_key: | POST | `/v5/card/reward/points/tier` | +| [queryCardMallItemList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5485) | :closed_lock_with_key: | POST | `/v5/card/reward/mall/item/list` | +| [queryCardPointCashbackDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5494) | :closed_lock_with_key: | POST | `/v5/card/reward/point/cashback/detail` | +| [createRFQ()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5510) | :closed_lock_with_key: | POST | `/v5/rfq/create-rfq` | +| [getRFQConfig()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5521) | :closed_lock_with_key: | GET | `/v5/rfq/config` | +| [cancelRFQ()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5530) | :closed_lock_with_key: | POST | `/v5/rfq/cancel-rfq` | +| [cancelAllRFQ()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5540) | :closed_lock_with_key: | POST | `/v5/rfq/cancel-all-rfq` | +| [createRFQQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5549) | :closed_lock_with_key: | POST | `/v5/rfq/create-quote` | +| [executeRFQQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5560) | :closed_lock_with_key: | POST | `/v5/rfq/execute-quote` | +| [cancelRFQQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5571) | :closed_lock_with_key: | POST | `/v5/rfq/cancel-quote` | +| [cancelAllRFQQuotes()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5581) | :closed_lock_with_key: | POST | `/v5/rfq/cancel-all-quotes` | +| [getRFQRealtimeInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5595) | :closed_lock_with_key: | GET | `/v5/rfq/rfq-realtime` | +| [getRFQHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5607) | :closed_lock_with_key: | GET | `/v5/rfq/rfq-list` | +| [getRFQRealtimeQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5621) | :closed_lock_with_key: | GET | `/v5/rfq/quote-realtime` | +| [getRFQHistoryQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5636) | :closed_lock_with_key: | GET | `/v5/rfq/quote-list` | +| [getRFQTrades()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5649) | :closed_lock_with_key: | GET | `/v5/rfq/trade-list` | +| [getRFQPublicTrades()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5662) | :closed_lock_with_key: | GET | `/v5/rfq/public-trades` | +| [acceptNonLPQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5678) | :closed_lock_with_key: | POST | `/v5/rfq/accept-other-quote` | +| [getRFQDetails()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5684) | :closed_lock_with_key: | GET | `/v5/rfq/rfq-detail-list` | +| [getP2PAccountCoinsBalance()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5709) | :closed_lock_with_key: | GET | `/v5/asset/transfer/query-account-coins-balance` | +| [getP2POnlineAds()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5726) | :closed_lock_with_key: | POST | `/v5/p2p/item/online` | +| [createP2PAd()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5735) | :closed_lock_with_key: | POST | `/v5/p2p/item/create` | +| [cancelP2PAd()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5744) | :closed_lock_with_key: | POST | `/v5/p2p/item/cancel` | +| [updateP2PAd()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5758) | :closed_lock_with_key: | POST | `/v5/p2p/item/update` | +| [getP2PPersonalAds()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5768) | :closed_lock_with_key: | POST | `/v5/p2p/item/personal/list` | +| [getP2PAdDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5777) | :closed_lock_with_key: | POST | `/v5/p2p/item/info` | +| [getP2POrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5792) | :closed_lock_with_key: | POST | `/v5/p2p/order/simplifyList` | +| [getP2POrderDetail()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5802) | :closed_lock_with_key: | POST | `/v5/p2p/order/info` | +| [getP2PPendingOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5811) | :closed_lock_with_key: | POST | `/v5/p2p/order/pending/simplifyList` | +| [markP2POrderAsPaid()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5820) | :closed_lock_with_key: | POST | `/v5/p2p/order/pay` | +| [releaseP2POrder()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5829) | :closed_lock_with_key: | POST | `/v5/p2p/order/finish` | +| [sendP2POrderMessage()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5838) | :closed_lock_with_key: | POST | `/v5/p2p/order/message/send` | +| [getP2PChatSessions()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5853) | :closed_lock_with_key: | POST | `/v5/p2p/chat/session/list_v1` | +| [getP2PChatSessionId()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5863) | :closed_lock_with_key: | POST | `/v5/p2p/chat/session/getSessionId` | +| [sendP2PChatMessage()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5899) | :closed_lock_with_key: | POST | `/v5/p2p/chat/message/send_v1` | +| [getP2PChatMessages()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5911) | :closed_lock_with_key: | POST | `/v5/p2p/chat/message/listpage_v1` | +| [getP2POrderMessages()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5920) | :closed_lock_with_key: | POST | `/v5/p2p/order/message/listpage` | +| [getP2PUserInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5934) | :closed_lock_with_key: | POST | `/v5/p2p/user/personal/info` | +| [getP2PCounterpartyUserInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5941) | :closed_lock_with_key: | POST | `/v5/p2p/user/order/personal/info` | +| [getP2PUserPayments()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5950) | :closed_lock_with_key: | POST | `/v5/p2p/user/payment/list` | +| [setApiRateLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5970) | :closed_lock_with_key: | POST | `/v5/apilimit/set` | +| [queryApiRateLimit()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L5999) | :closed_lock_with_key: | GET | `/v5/apilimit/query` | +| [getRateLimitCap()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6018) | :closed_lock_with_key: | GET | `/v5/apilimit/query-cap` | +| [getAllRateLimits()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6037) | :closed_lock_with_key: | GET | `/v5/apilimit/query-all` | +| [getLaunchpoolProjectList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6060) | | GET | `/v5/spot-x/launchpool/project/list` | +| [getLaunchpoolUserActivityLog()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6066) | :closed_lock_with_key: | POST | `/v5/spot-x/launchpool/user/activity-log` | +| [getLaunchpoolCurrentStaking()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6072) | :closed_lock_with_key: | GET | `/v5/spot-x/launchpool/user/current-staking` | +| [getLaunchpoolUserHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6078) | :closed_lock_with_key: | POST | `/v5/spot-x/launchpool/user/history` | +| [getPuzzleProjectList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6084) | | GET | `/v5/spot-x/puzzle/project/list` | +| [getTokenSplashProjectList()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6090) | | GET | `/v5/spot-x/token-splash/project/list` | +| [getTokenSplashUserActivityParams()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6096) | :closed_lock_with_key: | GET | `/v5/spot-x/token-splash/user/activity-params` | +| [getEventInstrumentsInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6119) | | GET | `/v5/event/instruments-info` | +| [getEventOrderbook()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6130) | | GET | `/v5/event/orderbook` | +| [getEventOrderHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6141) | :closed_lock_with_key: | GET | `/v5/event/order-list` | +| [getEventActiveOrders()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6152) | :closed_lock_with_key: | GET | `/v5/event/order-realtime` | +| [getEventPositionInfo()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6163) | :closed_lock_with_key: | GET | `/v5/event/positions` | +| [getEventTradeHistory()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6174) | :closed_lock_with_key: | GET | `/v5/event/trades` | +| [getEventSettlementRecords()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6185) | :closed_lock_with_key: | GET | `/v5/event/settlements` | +| [submitEventQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6196) | :closed_lock_with_key: | POST | `/v5/event/quotes` | +| [cancelEventQuote()](https://github.com/sieblyio/bybit-api/blob/master/src/rest-client-v5.ts#L6207) | :closed_lock_with_key: | POST | `/v5/event/cancel` | # websocket-api-client.ts diff --git a/examples/Rest/rest-v5-custom-url.ts b/examples/Rest/rest-v5-custom-url.ts index 3fc974be..13d6d98b 100644 --- a/examples/Rest/rest-v5-custom-url.ts +++ b/examples/Rest/rest-v5-custom-url.ts @@ -35,8 +35,7 @@ const client = new RestClientV5({ // apiRegion: 'bytick', // // - // NL: routes to api.bybit.nl (for Netherlands users) - // apiRegion: 'NL', + // NL: Bybit removed api.bybit.nl from Integration Guidance on 2026-09-22. apiRegion no longer includes NL. // // // TK: routes to api.bybit.tr (for Turkey users) diff --git a/examples/apidoc/V5/Earn/get-auto-savings-settings.js b/examples/apidoc/V5/Earn/get-auto-savings-settings.js new file mode 100644 index 00000000..d366d7f5 --- /dev/null +++ b/examples/apidoc/V5/Earn/get-auto-savings-settings.js @@ -0,0 +1,20 @@ +import { RestClientV5 } from 'bybit-api'; +// or, if require is preferred: +// const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getFlexibleSavingAutoSavings({ + coins: ['BTC', 'ETH'], + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Earn/set-auto-savings-settings.js b/examples/apidoc/V5/Earn/set-auto-savings-settings.js new file mode 100644 index 00000000..3f05d5b7 --- /dev/null +++ b/examples/apidoc/V5/Earn/set-auto-savings-settings.js @@ -0,0 +1,22 @@ +import { RestClientV5 } from 'bybit-api'; +// or, if require is preferred: +// const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .setFlexibleSavingAutoSavings({ + coin: 'BTC', + isSelected: true, + purchaseImmediately: false, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Institutional-Loan/get-delay-liquidation-status.js b/examples/apidoc/V5/Institutional-Loan/get-delay-liquidation-status.js new file mode 100644 index 00000000..8c3e8f73 --- /dev/null +++ b/examples/apidoc/V5/Institutional-Loan/get-delay-liquidation-status.js @@ -0,0 +1,18 @@ +import { RestClientV5 } from 'bybit-api'; +// or, if require is preferred: +// const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getInstitutionalLendingDelayLiquidationStatus() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-option-base-coins.js b/examples/apidoc/V5/Market/get-option-base-coins.js new file mode 100644 index 00000000..3c458c9d --- /dev/null +++ b/examples/apidoc/V5/Market/get-option-base-coins.js @@ -0,0 +1,18 @@ +import { RestClientV5 } from 'bybit-api'; +// or, if require is preferred: +// const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getOptionBaseCoins({ + underlyingType: '0,2', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Tax/create-tax-batch-export.js b/examples/apidoc/V5/Tax/create-tax-batch-export.js new file mode 100644 index 00000000..d64ee907 --- /dev/null +++ b/examples/apidoc/V5/Tax/create-tax-batch-export.js @@ -0,0 +1,28 @@ +import { RestClientV5 } from 'bybit-api'; +// or, if require is preferred: +// const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .createTaxBatchExport({ + startTime: 1756684800, + endTime: 1788220800, + items: [ + { type: 'TRADE', number: '1' }, + { type: 'EARN', number: '1' }, + { type: 'DEPOSIT&WITHDRAWAL', number: '1' }, + ], + sourceInstitution: 'INST_A', + exportFileType: 'csv', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Tax/get-tax-batch-export.js b/examples/apidoc/V5/Tax/get-tax-batch-export.js new file mode 100644 index 00000000..21954085 --- /dev/null +++ b/examples/apidoc/V5/Tax/get-tax-batch-export.js @@ -0,0 +1,20 @@ +import { RestClientV5 } from 'bybit-api'; +// or, if require is preferred: +// const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getTaxBatchExport({ + batchId: 'b5f4a3e2-1c8d-4f96-9a03-2e7b8c6d4f10', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/llms.txt b/llms.txt index 8fee3175..7b9395ce 100644 --- a/llms.txt +++ b/llms.txt @@ -118,6 +118,7 @@ src/ v5-spot-x.ts v5-spreadtrading.ts v5-strategy.ts + v5-tax.ts v5-trade.ts v5-user.ts response/ @@ -153,6 +154,7 @@ src/ v5-spot-x.ts v5-spreadtrading.ts v5-strategy.ts + v5-tax.ts v5-trade.ts v5-user.ts websockets/ @@ -193,6 +195,76 @@ tsconfig.test.json Files ================================================================ +================ +File: examples/Auth/fasterHmacSign.ts +================ +import { createHmac } from 'crypto'; +⋮---- +import { DefaultLogger, RestClientV5, WebsocketClient } from '../../src/index'; +⋮---- +// or +// import { createHmac } from 'crypto'; +// import { DefaultLogger, RestClientV5, WebsocketClient } from 'bybit-api'; +⋮---- +/** + * Injecting a custom signMessage function. + * + * As of version 4.0.0 of the bybit-api Node.js/TypeScript/JavaScript + * SDK for Bybit, the SDK uses the Web Crypto API for signing requests. + * While it is compatible with Node and Browser environments, it is + * slightly slower than using Node's native crypto module (only + * available in backend Node environments). + * + * For latency sensitive users, you can inject the previous node crypto sign + * method (or your own even faster-implementation), if this change affects you. + * + * This example demonstrates how to inject a custom sign function, to achieve + * the same peformance as seen before the Web Crypto API was introduced. + * + * For context on standard usage, the "signMessage" function is used: + * - During every single API call + * - After opening a new private WebSocket connection + * + */ +⋮---- +/** + * Set this to true to enable demo trading: + */ +⋮---- +/** + * Overkill in almost every case, but if you need any optimisation available, + * you can inject a faster sign mechanism such as node's native createHmac: + */ +⋮---- +// Optional, uncomment the "trace" override to log a lot more info about what the WS client is doing +⋮---- +// trace: (...params) => console.log('trace', ...params), +⋮---- +/** + * Set this to true to enable demo trading for the private account data WS + * Topics: order,execution,position,wallet,greeks + */ +⋮---- +/** + * Overkill in almost every case, but if you need any optimisation available, + * you can inject a faster sign mechanism such as node's native createHmac: + */ +⋮---- +function setWsClientEventListeners( + websocketClient: WebsocketClient, + accountRef: string, +): Promise +⋮---- +// console.log('raw message received ', JSON.stringify(data, null, 2)); +⋮---- +// Simple promise to ensure we're subscribed before trying anything else +⋮---- +// Start trading +⋮---- +/** Simple examples for private REST API calls with bybit's V5 REST APIs */ +⋮---- +// Trade USDT linear perps + ================ File: examples/deprecated/README.md ================ @@ -203,5830 +275,4216 @@ The examples in this folder use old/deprecated/obsolete APIs. They should all ha As of December 2023, use the V5 APIs & WebSockets. ================ -File: examples/README.md -================ -# Examples - -These samples can be executed using `ts-node`: -``` -ts-node ./examples/rest-spot-public.ts -``` - -================ -File: src/types/request/account-asset.ts +File: examples/Rest/demo-trading.ts ================ -export type TransferAccountType = - | 'CONTRACT' - | 'SPOT' - | 'INVESTMENT' - | 'OPTION' - | 'UNIFIED'; -⋮---- -export type TransferType = 'IN' | 'OUT'; +import { DefaultLogger, RestClientV5, WebsocketClient } from '../../src/index'; ⋮---- -export type TransferStatus = 'SUCCESS' | 'PENDING' | 'FAILED'; +// or +// import { RestClientV5 } from 'bybit-api'; ⋮---- -export type PageDirection = 'Prev' | 'Next'; +/** + * + * + * This example demonstrates how to use Bybit's demo trading functionality, both for REST and WS. + * + * Refer to the API docs for more information: https://bybit-exchange.github.io/docs/v5/demo + * + * + */ ⋮---- -export interface InternalTransferRequest { - transfer_id: string; - coin: string; - amount: string; - from_account_type: TransferAccountType; - to_account_type: TransferAccountType; -} +/** + * Set this to true to enable demo trading: + */ ⋮---- -export interface InternalTransferRequestV3 { - transferId: string; - coin: string; - amount: string; - fromAccountType: string; - toAccountType: string; -} +// Optional, uncomment the "trace" override to log a lot more info about what the WS client is doing ⋮---- -export interface QueryInternalTransfersRequestV3 { - transferId?: string; - coin: string; - status?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; -} +// trace: (...params) => console.log('trace', ...params), ⋮---- -export interface SubAccountTransferRequest { - transfer_id: string; - coin: string; - amount: string; - sub_user_id: string; - type: TransferType; -} +/** + * Set this to true to enable demo trading for the private account data WS + * Topics: order,execution,position,wallet,greeks + */ ⋮---- -export interface SubAccountTransferRequestV3 { - transferId?: string; - coin?: string; - status?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; -} +function setWsClientEventListeners( + websocketClient: WebsocketClient, + accountRef: string, +): Promise ⋮---- -export interface TransferQueryRequest { - transfer_id?: string; - coin?: string; - status?: TransferStatus; - start_time?: number; - end_time?: number; - direction?: PageDirection; - limit?: number; - cursor?: string; -} +// console.log('raw message received ', JSON.stringify(data, null, 2)); ⋮---- -export interface EnableUniversalTransferRequest { - /** A comma-separated list of subaccount UIDs, for example "123,45,14,26,46" */ - transferable_sub_ids?: string; -} +// Simple promise to ensure we're subscribed before trying anything else ⋮---- -/** A comma-separated list of subaccount UIDs, for example "123,45,14,26,46" */ +// Start trading ⋮---- -export interface UniversalTransferRequest { - transfer_id: string; - coin: string; - amount: string; - from_member_id: string; - to_member_id: string; - from_account_type: TransferAccountType; - to_account_type: TransferAccountType; -} -export interface SupportedDepositListRequest { - coin?: string; - chain?: string; - page_index?: number; - page_size?: number; -} +/** Simple examples for private REST API calls with bybit's V5 REST APIs */ ⋮---- -export interface DepositRecordsRequest { - start_time?: number; - end_time?: number; - coin?: string; - cursor?: string; - direction?: PageDirection; - limit?: number; -} +// Trade USDT linear perps + +================ +File: examples/Rest/rest-v5-all.ts +================ +import { RestClientV5 } from '../../src/index'; ⋮---- -export interface WithdrawalRecordsRequest { - withdraw_id?: number; - start_time?: number; - end_time?: number; - coin?: string; - cursor?: string; - direction?: PageDirection; - limit?: number; -} +// or +// import { RestClientV5 } from 'bybit-api'; ⋮---- -export interface AccountAssetInformationRequest { - /** Account type. Default value: ACCOUNT_TYPE_SPOT */ - account_type?: string; - coin?: string; -} +/** + * If you don't plan on making any private api calls, + * you can instance the REST client without any parameters: + * + * const client = new RestClientV5(); + */ + +================ +File: examples/Rest/rest-v5-next-cursor.ts +================ +import { RestClientV5, UniversalTransferRecordV5 } from '../../src/index'; ⋮---- -/** Account type. Default value: ACCOUNT_TYPE_SPOT */ +// or +// import { RestClientV5 } from 'bybit-api'; ⋮---- -export interface WithdrawalRequest { - address: string; - amount: string; - coin: string; - chain: string; - tag?: string; -} +async function getAllUniversalTransfers() ⋮---- -export interface UniversalTransferRequestV3 { - transferId: string; - coin: string; - amount: string; - fromMemberId: string; - toMemberId: string; - fromAccountType: TransferAccountType; - toAccountType: TransferAccountType; -} +limit: 50, // Maximum page size per request +cursor: nextCursor || undefined, // Only send cursor if we have one ⋮---- -export interface UniversalTransferListRequestV3 { - transferId?: string; - coin: string; - status?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; -} -⋮---- -export interface TransferCoinListRequestV3 { - fromAccountType: TransferAccountType; - toAccountType: TransferAccountType; -} -⋮---- -export interface SingleAccountCoinBalanceRequestV3 { - memberId?: string; - accountType: TransferAccountType; - coin: string; - withBonus?: '0' | '1'; -} +// Optional: Add a small delay to avoid rate limits + +================ +File: examples/Rest/rest-v5-p2p.ts +================ +import fs from 'fs'; +import path from 'path'; ⋮---- -export interface AccountCoinBalancesRequestV3 { - memberId?: string; - accountType: TransferAccountType; - coin?: string; - withBonus?: '0' | '1'; -} +import { RestClientV5 } from '../../src'; ⋮---- -export interface AssetInfoRequestV3 { - accountType?: TransferAccountType; - coin?: string; -} +// ENDPOINT: /v5/p2p/oss/upload_file +// METHOD: POST +// PUBLIC: NO +// NOTE: Node.js only (Buffer required) ⋮---- -export interface SupportedDepositListRequestV3 { - coin?: string; - chain?: string; - cursor?: string; - limit?: number; -} +async function uploadP2PChatFile() ⋮---- -export interface DepositRecordQueryRequestV3 { - startTime?: number; - endTime?: number; - coin?: string; - cursor?: string; - limit?: number; -} +// You must read the file yourself and pass the Buffer + filename ⋮---- -export interface SubDepositRecordQueryRequestV3 { - subMemberId: number; - startTime?: number; - endTime?: number; - coin?: string; - cursor?: string; - limit?: number; -} +/** + * + * + * + * + * + * + */ ⋮---- -export interface WithdrawRecordQueryRequestV3 { - withdrawID?: number; - startTime?: number; - endTime?: number; - coin?: string; - withdrawType?: string; - cursor?: string; - limit?: number; -} +// Test basic P2P API connectivity ⋮---- -export interface WithdrawCreateRequestV3 { - coin: string; - chain: string; - address: string; - tag?: string; - amount: string; - timestamp: number; - forceChain?: 0 | 1; -} +// Example 1: Upload from file path ⋮---- -export interface QueryDepositAddressRequestV3 { - coin?: string; - chainType?: string; -} +fileName: path.basename(filePath), // Extract filename from path ⋮---- -export interface QuerySubAccountDepositAddressRequestV3 { - coin?: string; - chainType?: string; - subMemberId: string; -} +// Example 2: Upload with custom filename +// You control the filename sent to Bybit ⋮---- -export interface CreateSubMemberRequestV3 { - username: string; - memberType: 1 | 6; - switch?: 0 | 1; - note?: string; -} +fileName: 'custom-name.png', // Use any filename you want ⋮---- -export interface CreateSubAPIKeyRequestV3 { - subuid: string; - note?: string; - readOnly: 0 | 1; - ips?: string[]; - permissions: { - ContractTrade?: string[]; - Spot?: string[]; - Wallet?: string[]; - Options?: string[]; - Derivatives?: string[]; - Exchange?: string[]; - }; -} +// Example 3: Upload different file ⋮---- -export interface ModifyAPIKeyRequestV3 { - readOnly: number; - ips?: string[]; - permissions: { - ContractTrade?: string[]; - Spot?: string[]; - Wallet?: string[]; - Options?: string[]; - Derivatives?: string[]; - CopyTrading?: string[]; - BlockTrade?: string[]; - Exchange?: string[]; - NFT?: string[]; - }; -} +// Supported file types (determined by filename extension): +// - Images: jpg, jpeg, png +// - Documents: pdf +// - Videos: mp4 ================ -File: src/types/request/contract.ts +File: examples/Rest/rest-v5-private.ts ================ -import { OrderSide } from '../shared'; -import { UMOrderType } from './unified-margin'; -import { USDCOrderFilter, USDCTimeInForce } from './usdc-shared'; -⋮---- -export interface ContractOrderRequest { - symbol: string; - side: OrderSide; - orderType: UMOrderType; - qty: string; - timeInForce: USDCTimeInForce; - price?: string; - triggerDirection?: '1' | '2'; - triggerPrice?: string; - triggerBy?: string; - positionIdx?: '0' | '1' | '2'; - orderLinkId?: string; - takeProfit?: string; - stopLoss?: string; - tpTriggerBy?: string; - slTriggerBy?: string; - reduceOnly?: boolean; - closeOnTrigger?: boolean; - tpslMode?: 'Partial' | 'Full'; - tpOrderType?: UMOrderType; - slOrderType?: UMOrderType; -} -⋮---- -export interface ContractHistoricOrdersRequest { - orderId?: string; - orderLinkId?: string; - symbol: string; - orderStatus?: string; - orderFilter?: USDCOrderFilter; - limit?: number; - cursor?: string; -} +import { RestClientV5 } from '../../src/index'; ⋮---- -export interface ContractCancelOrderRequest { - symbol: string; - orderId?: string; - orderLinkId?: string; -} +// or +// import { RestClientV5 } from 'bybit-api'; ⋮---- -export interface ContractModifyOrderRequest { - symbol: string; - orderId?: string; - orderLinkId?: string; - price?: string; - qty?: string; - triggerPrice?: string; - takeProfit?: string; - stopLoss?: string; - tpTriggerBy?: string; - slTriggerBy?: string; - triggerBy?: string; - tpLimitPrice?: string; - slLimitPrice?: string; -} +/** Simple examples for private REST API calls with bybit's V5 REST APIs */ ⋮---- -export interface ContractActiveOrdersRequest { - symbol?: string; - orderId?: string; - orderLinkId?: string; - settleCoin?: string; - orderFilter?: USDCOrderFilter; - limit?: number; -} +// Trade USDT linear perps + +================ +File: examples/Rest/rest-v5-proxies.ts +================ +import { RestClientV5 } from '../../src/index'; ⋮---- -export interface ContractPositionsRequest { - symbol?: string; - settleCoin?: string; - dataFilter?: string; -} +// or +// import { RestClientV5 } from 'bybit-api'; ⋮---- -export interface ContractSetAutoAddMarginRequest { - symbol: string; - side: 'Buy' | 'Sell'; - autoAddMargin: 1 | 0; - positionIdx?: 0 | 1 | 2; -} +// Sometimes using a proxy introduces recv timestamp errors (due to the extra latency) +// If that happens, you can try increasing the recv window (which is 5000ms by default) +// recv_window: 10000, ⋮---- -export interface ContractSetMarginSwitchRequest { - symbol: string; - tradeMode: 0 | 1; - buyLeverage: string; - sellLeverage: string; -} +/** + * Axios has a native way of supporting http/https proxies. It works for most proxy services but not all. + * If you have issues making any proxied requests this way, take a look at the rest-v5-proxies2.ts example using the https-proxy-agent. + */ ⋮---- -export interface ContractSetPositionModeRequest { - symbol?: string; - coin?: string; - mode: 0 | 3; -} +protocol: 'http', // or 'https' ⋮---- -export interface ContractSetTPSLRequest { - symbol: string; - takeProfit?: string; - stopLoss?: string; - tpslMode?: 'Full' | 'Partial'; - tpSize?: string; - slSize?: string; - tpTriggerBy?: string; - slTriggerBy?: string; - trailingStop?: string; - activePrice?: string; - tpLimitPrice?: string; - slLimitPrice?: string; - tpOrderType?: UMOrderType; - slOrderType?: UMOrderType; - /** 0-one-way, 1-buy side, 2-sell side */ - positionIdx?: 0 | 1 | 2; -} +// const orders = await client.batchSubmitOrders('linear', [ +// { +// symbol: 'ETHUSDT', +// orderType: 'Limit', +// side: 'Buy', +// qty: '1', +// orderIv: '6', +// timeInForce: 'GTC', +// orderLinkId: 'option-test-001', +// mmp: false, +// reduceOnly: false, +// }, +// { +// symbol: 'ETHUSDT', +// orderType: 'Limit', +// side: 'Sell', +// qty: '2', +// price: '700', +// timeInForce: 'GTC', +// orderLinkId: 'option-test-001', +// mmp: false, +// reduceOnly: false, +// }, +// ]); ⋮---- -/** 0-one-way, 1-buy side, 2-sell side */ +// console.log('orders: ', JSON.stringify(orders, null, 2)); + +================ +File: examples/Rest/rest-v5-proxies2.ts +================ +import { HttpsProxyAgent } from 'https-proxy-agent'; ⋮---- -export interface ContractUserExecutionHistoryRequest { - symbol: string; - orderId?: string; - startTime?: number; - endTime?: number; - execType?: 'Trade' | 'AdlTrade' | 'Funding' | 'BustTrade'; - limit?: number; - cursor?: string; -} +import { RestClientV5 } from '../../src/index'; ⋮---- -export interface ContractClosedPNLRequest { - symbol: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; -} +// or +// import { RestClientV5 } from 'bybit-api'; ⋮---- -export interface ContractWalletFundRecordRequest { - startTime?: string; - endTime?: string; - coin?: string; - walletFundType?: string; - limit?: string; - cursor?: string; -} +/** + * Some proxy services don't work with the proxy configuration that axios supports. + * + * For these, you can try using HttpsProxyAgent or SocksProxyAgent (depending on your proxy type, HTTP or SOCKS). + * + * The following example uses the HttpsProxyAgent (via the npm module https-proxy-agent). + */ +⋮---- +// Sometimes using a proxy introduces recv timestamp errors (due to the extra latency) +// If that happens, you can try increasing the recv window (which is 5000ms by default) +// recv_window: 10000, ================ -File: src/types/request/copy-trading.ts +File: examples/Rest/rest-v5-public.ts ================ -import { OrderSide } from '../shared'; -import { USDCOrderType } from './usdc-shared'; +import { RestClientV5 } from '../../src/index'; ⋮---- -export interface CopyTradingOrderRequest { - side: OrderSide; - symbol: string; - orderType: USDCOrderType; - price: string; - qty: string; - takeProfit?: string; - stopLoss?: string; - tpTriggerBy?: string; - slTriggerBy?: string; - orderLinkId?: string; -} +// or +// import { RestClientV5 } from 'bybit-api'; ⋮---- -export interface CopyTradingTradingStopRequest { - symbol: string; - parentOrderId: string; - takeProfit?: string; - stopLoss?: string; - tpTriggerBy?: string; - slTriggerBy?: string; - parentOrderLinkId?: string; -} +/** + * If you don't plan on making any private api calls, + * you can instance the REST client without any parameters + */ ⋮---- -export interface CopyTradingOrderListRequest { - symbol?: string; - orderId?: string; - orderLinkId?: string; - copyTradeOrderType?: string; -} +// const klineResult = await client.getKline({ +// category: 'linear', +// interval: '15', +// symbol: 'BTCUSDT', +// }); +// console.log('klineResult: ', klineResult); ⋮---- -export interface CopyTradingCancelOrderRequest { - symbol: string; - orderId?: string; - orderLinkId?: string; -} +// const markPriceKlineResult = await client.getMarkPriceKline({ +// category: 'linear', +// interval: '15', +// symbol: 'BTCUSDT', +// }); +// console.log('markPriceKlineResult: ', markPriceKlineResult); ⋮---- -export interface CopyTradingCloseOrderRequest { - symbol: string; - orderLinkId?: string; - parentOrderId?: string; - parentOrderLinkId?: string; -} +// const indexPriceKline = await client.getIndexPriceKline({ +// category: 'linear', +// interval: '15', +// symbol: 'BTCUSDT', +// }); +// console.log('indexPriceKline: ', indexPriceKline); ⋮---- -export interface CopyTradingTransferRequest { - transferId: string; - coin: string; - amount: string; - fromAccountType: string; - toAccountType: string; -} +// const openInterest = await client.getOpenInterest({ +// category: 'linear', +// symbol: 'BTCUSDT', +// intervalTime: '5min', +// }); +⋮---- +// console.log( +// JSON.stringify( +// tickers.result.list.map((ticker) => ticker.symbol), +// null, +// 2, +// ), +// ); +⋮---- +// openInterest.result.list.forEach((row) => { +// console.log('int: ', { +// timestamp: row.timestamp, +// value: row.openInterest, +// }); +// }); +// console.log('openInterest: ', openInterest.result.list); ================ -File: src/types/request/inverse.ts +File: examples/Websocket/Public/ws-public-allLiquidations.ts ================ -export interface InverseOrderRequest { - side: string; - symbol: string; - order_type: string; - qty: number; - price?: number; - time_in_force: string; - take_profit?: number; - stop_loss?: number; - reduce_only?: boolean; - tp_trigger_by?: 'LastPrice' | 'MarkPrice' | 'IndexPrice'; - sl_trigger_by?: 'LastPrice' | 'MarkPrice' | 'IndexPrice'; - close_on_trigger?: boolean; - order_link_id?: string; -} +import { + isWsAllLiquidationEvent, + RestClientV5, + WebsocketClient, +} from '../../../src'; ⋮---- -export interface InverseActiveOrdersRequest { - symbol: string; - order_status?: string; - direction?: string; - limit?: number; - cursor?: string; -} +// or +// import { +// RestClientV5, +// WebsocketClient, +// isWsAllLiquidationEvent, +// } from 'bybit-api'; ⋮---- -export interface InverseCancelOrderRequest { - symbol: string; - order_id?: string; - order_link_id?: string; -} +function onAllLiquidationEvent(event: unknown) ⋮---- -export interface InverseReplaceOrderRequest { - order_id?: string; - order_link_id?: string; - symbol: string; - p_r_qty?: number; - p_r_price?: string; - take_profit?: number; - stop_loss?: number; - tp_trigger_by?: string; - sl_trigger_by?: string; -} +/** + * + * If you want to receive data for all available symbols, this websocket topic + * requires you to subscribe to each symbol individually. + * + * This can be easily automated by fetching a list of symbols via the REST client, + * generating a list of topics (one per symbol), before simply passing an + * array of topics to the websocket client per product group (linear & inverse perps). + * + */ +async function start() ⋮---- -export interface InverseGetOrderRequest { - order_id?: string; - order_link_id?: string; - symbol: string; -} +// Make an array of topics ready for submission ⋮---- -export interface InverseConditionalOrderRequest { - side: string; - symbol: string; - order_type: string; - qty: string; - price?: string; - base_price: string; - stop_px: string; - time_in_force: string; - trigger_by?: string; - close_on_trigger?: boolean; - order_link_id?: string; -} +// subscribe to all linear symbols ⋮---- -export interface InverseActiveConditionalOrderRequest { - symbol: string; - stop_order_status?: string; - direction?: string; - limit?: number; - cursor?: string; -} +// subscribe to all inverse symbols + +================ +File: examples/Websocket/Public/ws-public-v5.ts +================ +import { DefaultLogger, WebsocketClient, WS_KEY_MAP } from '../../../src'; ⋮---- -export interface InverseCancelConditionalOrderRequest { - symbol: string; - stop_order_id?: string; - order_link_id?: string; -} +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from 'bybit-api'; ⋮---- -export interface InverseReplaceConditionalOrderRequest { - stop_order_id?: string; - order_link_id?: string; - symbol: string; - p_r_qty?: number; - p_r_price?: string; - p_r_trigger_price?: string; -} +/** + * Prepare an instance of the WebSocket client. This client handles all aspects of connectivity for you: + * - Connections are opened when you subscribe to topics + * - If key & secret are provided, authentication is handled automatically + * - If you subscribe to topics from different v5 products (e.g. spot and linear perps), + * subscription events are automatically routed to the different ws endpoints on bybit's side + * - Heartbeats/ping/pong/reconnects are all handled automatically. + * If a connection drops, the client will clean it up, respawn a fresh connection and resubscribe for you. + */ ⋮---- -export interface InverseChangePositionMarginRequest { - symbol: string; - margin: string; -} +/** + * For public V5 topics, use the subscribeV5 method and include the API category this topic is for. + * Category is required, since each category has a different websocket endpoint. + */ ⋮---- -export interface InverseSetTradingStopRequest { - symbol: string; - take_profit?: number; - stop_loss?: number; - trailing_stop?: number; - tp_trigger_by?: string; - sl_trigger_by?: string; - new_trailing_active?: number; -} +// Linear v5 +// -> Just one topic per call +// wsClient.subscribeV5('orderbook.50.BTCUSDT', 'linear'); ⋮---- -export interface InverseSetLeverageRequest { - symbol: string; - leverage: number; - leverage_only?: boolean; -} +// -> Or multiple topics in one call +// wsClient.subscribeV5( +// ['orderbook.50.BTCUSDT', 'orderbook.50.ETHUSDT'], +// 'linear' +// ); ⋮---- -export interface InverseGetTradeRecordsRequest { - order_id?: string; - symbol: string; - start_time?: number; - page?: number; - limit?: number; - order?: string; -} +// Inverse v5 +// wsClient.subscribeV5('orderbook.50.BTCUSD', 'inverse'); ⋮---- -export interface InverseGetClosedPnlRequest { - symbol: string; - start_time?: number; - end_time?: number; - exec_type?: string; - page?: number; - limit?: number; -} +// Spot v5 +// wsClient.subscribeV5('orderbook.50.BTCUSDT', 'spot'); ⋮---- -export interface InverseSetSlTpPositionModeRequest { - symbol: string; - tp_sl_mode: 'Full' | 'Partial'; -} +// Option v5 +// wsClient.subscribeV5('publicTrade.BTC', 'option'); ⋮---- -export interface InverseSetMarginTypeRequest { - symbol: string; - is_isolated: boolean; - buy_leverage: number; - sell_leverage: number; -} +// Use the subscribeV5() call for most subscribe calls with v5 websockets +⋮---- +// Alternatively, you can also use objects in the wsClient.subscribe() call +// wsClient.subscribe({ +// topic: 'orderook.50.BTCUSDT', +// category: 'spot', +// }); +⋮---- +/** + * For private V5 topics, just call the same subscribeV5() method on the ws client or use the original subscribe() method. + * + * Note: for private endpoints the "category" field is ignored since there is only one private endpoint + * (compared to one public one per category) + */ +⋮---- +// wsClient.subscribeV5('position', 'linear'); +// wsClient.subscribeV5('execution', 'linear'); +// wsClient.subscribeV5(['order', 'wallet', 'greek'], 'linear'); +⋮---- +// To unsubscribe from topics (after a 5 second delay, in this example): +⋮---- +// Topics are tracked per websocket type +// Get a list of subscribed topics (e.g. for public v3 spot topics) (after a 5 second delay) ================ -File: src/types/request/linear.ts +File: examples/Websocket/WS-API/ws-api-client.ts ================ -import { - LinearPositionIdx, - linearPositionModeEnum, - positionTpSlModeEnum, -} from '../../constants/enum'; -import { OrderSide } from '../shared'; -⋮---- -export interface LinearGetOrdersRequest { - order_id?: string; - order_link_id?: string; - symbol: string; - order?: string; - page?: number; - limit?: number; - order_status?: string; -} +import { DefaultLogger, WebsocketAPIClient } from '../../../src'; ⋮---- -export interface LinearCancelOrderRequest { - symbol: string; - order_id?: string; - order_link_id?: string; -} +// or +// import { DefaultLogger, WebsocketAPIClient } from 'bybit-api'; +// const { DefaultLogger, WebsocketAPIClient } = require('bybit-api'); ⋮---- -export interface LinearReplaceOrderRequest { - order_id?: string; - order_link_id?: string; - symbol: string; - p_r_qty?: number; - p_r_price?: number; - take_profit?: number; - stop_loss?: number; - tp_trigger_by?: string; - sl_trigger_by?: string; -} +// function attachEventHandlers( +// wsClient: TWSClient, +// ): void { +// wsClient.on('update', (data) => { +// console.log('raw message received ', JSON.stringify(data)); +// }); +// wsClient.on('open', (data) => { +// console.log('ws connected', data.wsKey); +// }); +// wsClient.on('reconnect', ({ wsKey }) => { +// console.log('ws automatically reconnecting.... ', wsKey); +// }); +// wsClient.on('reconnected', (data) => { +// console.log('ws has reconnected ', data?.wsKey); +// }); +// wsClient.on('authenticated', (data) => { +// console.log('ws has authenticated ', data?.wsKey); +// }); +// } ⋮---- -export interface LinearGetOrderRequest { - order_id?: string; - order_link_id?: string; - symbol: string; -} +async function main() ⋮---- -export type LinearOrderType = 'Limit' | 'Market'; +// Optional ⋮---- -export type LinearTimeInForce = - | 'GoodTillCancel' - | 'ImmediateOrCancel' - | 'FillOrKill' - | 'PostOnly'; +// For a more detailed view of the WebsocketClient, enable the `trace` level by uncommenting the below line: +// trace: (...params) => console.log('trace', ...params), ⋮---- -export interface NewLinearOrder { - side: OrderSide; - symbol: string; - order_type: LinearOrderType; - qty: number; - price?: number; - time_in_force: LinearTimeInForce; - take_profit?: number; - stop_loss?: number; - tp_trigger_by?: string; - sl_trigger_by?: string; - reduce_only: boolean; - close_on_trigger: boolean; - order_link_id?: string; - position_idx?: LinearPositionIdx; -} +// testnet: true, // Whether to use the testnet environment: https://testnet.bybit.com/app/user/api-management ⋮---- -export interface LinearConditionalOrderRequest { - side: string; - symbol: string; - order_type: string; - qty: number; - price?: number; - base_price: number; - stop_px: number; - time_in_force: string; - trigger_by?: string; - close_on_trigger?: boolean; - order_link_id?: string; - reduce_only: boolean; - take_profit?: number; - stop_loss?: number; - tp_trigger_by?: string; - sl_trigger_by?: string; -} +// Whether to use the livenet demo trading environment +// Note: As of Jan 2025, demo trading only supports consuming events, it does +// NOT support the WS API. +// demoTrading: false, ⋮---- -export interface LinearGetConditionalOrderRequest { - stop_order_id?: string; - order_link_id?: string; - symbol: string; - stop_order_status?: string; - order?: string; - page?: number; - limit?: number; -} +// If you want your own event handlers instead of the default ones with logs, +// disable this setting and see the `attachEventHandlers` example below: +// attachEventListeners: false ⋮---- -export interface LinearCancelConditionalOrderRequest { - symbol: string; - stop_order_id?: string; - order_link_id?: string; -} +logger, // Optional: inject a custom logger ⋮---- -export interface LinearReplaceConditionalOrderRequest { - stop_order_id?: string; - order_link_id?: string; - symbol: string; - p_r_qty?: number; - p_r_price?: number; - p_r_trigger_price?: number; - take_profit?: number; - stop_loss?: number; - tp_trigger_by?: string; - sl_trigger_by?: string; -} +// Optional, see above "attachEventListeners". Attach basic event handlers, so nothing is left unhandled +// attachEventHandlers(wsClient.getWSClient()); ⋮---- -export interface LinearQueryConditionalOrderRequest { - symbol: string; - stop_order_id?: string; - order_link_id?: string; -} +// Optional, if you see RECV Window errors, you can use this to manage time issues. +// ! However, make sure you sync your system clock first! +// https://github.com/tiagosiebler/awesome-crypto-examples/wiki/Timestamp-for-this-request-is-outside-of-the-recvWindow +// wsClient.setTimeOffsetMs(-5000); ⋮---- -export interface LinearSetAutoAddMarginRequest { - symbol: string; - side: string; - auto_add_margin: boolean; -} +// Optional: prepare the WebSocket API connection in advance. +// This happens automatically but you can do this early before making any API calls, to prevent delays from a cold start. +// await wsClient.getWSClient().connectWSAPI(); + +================ +File: examples/Websocket/WS-API/ws-api-raw-events.ts +================ +import { DefaultLogger, WebsocketClient, WS_KEY_MAP } from '../../../src'; ⋮---- -export interface LinearSetMarginSwitchRequest { - symbol: string; - is_isolated: boolean; - buy_leverage: number; - sell_leverage: number; -} +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from 'bybit-api'; ⋮---- -export interface LinearSetPositionModeRequest { - symbol: string; - mode: (typeof linearPositionModeEnum)[keyof typeof linearPositionModeEnum]; -} +// For a more detailed view of the WebsocketClient, enable the `trace` level by uncommenting the below line: +// trace: (...params) => console.log('trace', ...params), ⋮---- -export interface LinearSetPositionTpSlModeRequest { - symbol: string; - tp_sl_mode: (typeof positionTpSlModeEnum)[keyof typeof positionTpSlModeEnum]; -} +// testnet: true, // Whether to use the testnet environment: https://testnet.bybit.com/app/user/api-management +// demoTrading: false, // note: As of Jan 2025, demo trading does NOT support the WS API ⋮---- -export interface LinearSetAddReduceMarginRequest { - symbol: string; - side: string; - margin: number; -} +logger, // Optional: inject a custom logger ⋮---- -export interface LinearSetUserLeverageRequest { - symbol: string; - buy_leverage: number; - sell_leverage: number; -} +/** + * General event handlers for monitoring the WebsocketClient + */ ⋮---- -export interface LinearSetTradingStopRequest { - symbol: string; - side: string; - take_profit?: number; - stop_loss?: number; - trailing_stop?: number; - tp_trigger_by?: string; - sl_trigger_by?: string; - sl_size?: number; - tp_size?: number; - position_idx?: 0 | 1 | 2; -} +async function main() ⋮---- -export interface LinearGetTradeRecordsRequest { - symbol: string; - start_time?: number; - end_time?: number; - exec_type?: string; - page?: number; - limit?: number; -} +/** + * + * This SDK's WebSocket API integration is event-driven at its core. You can treat the sentWSAPIRquest(...) method as + * a fire-and-forget method, to submit commands (create/amend/cancel order) via a WebSocket Connection. + * + * Replies to commands will show in the `response` event from the WebsocketClient's EventEmitter. Exceptions, however, + * will show in the `error` event from the WebsocketClient's EventEmitter. + * + * - Fire-and-forget a command. + * - Handle command results in the `response` event handler asynchronously as desired. + * - Handle any exceptions in a catch block. + * + * This is a more "raw" workflow in how WebSockets behave. For a more convenient & REST-like approach, using the + * promise-driven interface is recommended. See the `ws-api-raw-promises.ts` and `ws-api-client.ts` examples for a + * demonstration you can compare. + * + * Note: even without using promises, you should still tie on a .catch handler to each sendWSAPIRequest call, to prevent + * any unnecessary "unhandled promise rejection" exceptions. + * + */ ⋮---- -export interface LinearGetHistoryTradeRecordsRequest { - symbol: string; - start_time?: number; - end_time?: number; - exec_type?: string; - page?: number; - limit?: number; - page_token?: string; -} +// To make it easier to watch, wait a few seconds before sending the amend order ⋮---- -export interface LinearGetClosedPnlRequest { - symbol: string; - start_time?: number; - end_time?: number; - exec_type?: string; - page?: number; - limit?: number; -} +// Then wait a few more before sending the cancel order ⋮---- -export interface LinearSetRiskLimitRequest { - symbol: string; - side: string; - risk_id: number; -} +// Exceptions including rejected commands will show here (as well as the catch handler used below) +⋮---- +// Replies to commands will show here +⋮---- +/** + * + * If you haven't connected yet, the WebsocketClient will automatically connect and authenticate you as soon as you send + * your first command. That connection will then be reused for every command you send, unless the connection drops - then + * it will automatically be replaced with a healthy connection. + * + * This "not connected yet" scenario can add an initial delay to your first command. If you want to prepare a connection + * in advance, you can ask the WebsocketClient to prepare it before you start submitting commands. This is optional. + * + * Repeated note: even without using promises, you should still tie on a .catch handler to each sendWSAPIRequest call, to prevent + * any unnecessary "unhandled promise rejection" exceptions. + * + */ +⋮---- +// Optional, see above. Can be used to prepare a connection before sending commands +⋮---- +// Fire and forget the create.order command +// Even without using promises, you should still "catch" exceptions (although no need to await anything you send) +⋮---- +// +⋮---- +// Fire and forget the order.amend command +// For simplicity, the orderId is hardcoded here (and will probably not work) +⋮---- +// +⋮---- +// Fire and forget the order.cancel command +// For simplicity, the orderId is hardcoded here (and will probably not work) +⋮---- +// Start executing the example workflow ================ -File: src/types/request/unified-margin.ts +File: examples/Websocket/WS-API/ws-api-raw-promises.ts ================ -import { KlineIntervalV3, OrderSide } from '../shared'; -import { USDCOrderFilter, USDCTimeInForce } from './usdc-shared'; +import { DefaultLogger, WebsocketClient, WS_KEY_MAP } from '../../../src'; ⋮---- -export type UMCategory = 'linear' | 'inverse' | 'option'; -export type UMOrderType = 'Limit' | 'Market'; -export type UMDirection = 'prev' | 'next'; +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from 'bybit-api'; ⋮---- -export interface UMCandlesRequest { - category: UMCategory; - symbol: string; - interval: KlineIntervalV3; - start: number; - end: number; - limit?: number; -} +// For a more detailed view of the WebsocketClient, enable the `trace` level by uncommenting the below line: +// trace: (...params) => console.log('trace', ...params), ⋮---- -export interface UMInstrumentInfoRequest { - category: UMCategory; - symbol?: string; - baseCoin?: string; - limit?: string; - cursor?: string; -} +// testnet: true, // Whether to use the testnet environment: https://testnet.bybit.com/app/user/api-management +// demoTrading: false, // note: As of Jan 2025, demo trading does NOT support the WS API ⋮---- -export interface UMFundingRateHistoryRequest { - category: UMCategory; - symbol: string; - startTime?: number; - endTime?: number; - limit?: number; -} +logger, // Optional: inject a custom logger ⋮---- -export interface UMOptionDeliveryPriceRequest { - category: UMCategory; - symbol?: string; - baseCoin?: string; - direction?: UMDirection; - limit?: string; - cursor?: string; -} +/** + * General event handlers for monitoring the WebsocketClient + */ ⋮---- -export interface UMPublicTradesRequest { - category: UMCategory; - symbol: string; - baseCoin?: string; - optionType?: 'Call' | 'Put'; - limit?: string; -} +async function main() ⋮---- -export interface UMOpenInterestRequest { - category: UMCategory; - symbol: string; - interval: '5min' | '15min' | '30min' | '1h' | '4h' | '1d'; - startTime?: number; - endTime?: number; - limit?: number; -} +/** + * + * This SDK's WebSocket API integration can connect WS API responses to the request that caused them. Each call + * to the `sendWSAPIRequest(...)` method returns a promise. + * + * This promise will resolve when the matching response is detected, and reject if an exception for that request + * is detected. This allows using Bybit's Websocket API in the same way that a REST API normally works. + * + * Send a command and immediately await the result. Handle any exceptions in a catch block. + * + * TypeScript users can benefit from smart type flowing for increased type safety & convenience: + * - Request parameters are fully typed, depending on the operation in the second parameter to the call. E.g. + * the `order.create` operation will automatically require the params to match the `OrderParamsV5` interface. + * + * - Response parameters are fully typed, depending on the operation in the second parameter. E.g the `order.create` + * operation will automatically map the returned value to `WSAPIResponse`. + * + */ ⋮---- -export interface UMOrderRequest { - category: UMCategory; - symbol: string; - side: OrderSide; - positionIdx?: '0' | '1' | '2'; - orderType: UMOrderType; - qty: string; - price?: string; - basePrice?: string; - triggerPrice?: string; - triggerBy?: string; - iv?: string; - timeInForce: USDCTimeInForce; - orderLinkId?: string; - takeProfit?: number; - stopLoss?: number; - tpTriggerBy?: string; - slTriggerBy?: string; - reduceOnly?: boolean; - closeOnTrigger?: boolean; - mmp?: boolean; -} +// To make it easier to watch, wait a few seconds before sending the amend order ⋮---- -export interface UMModifyOrderRequest { - category: UMCategory; - symbol: string; - orderId?: string; - orderLinkId?: string; - iv?: string; - triggerPrice?: string; - qty?: string; - price?: string; - takeProfit?: number; - stopLoss?: number; - tpTriggerBy?: string; - slTriggerBy?: string; - triggerBy?: string; -} +// Then wait a few more before sending the cancel order ⋮---- -export interface UMCancelOrderRequest { - category: UMCategory; - symbol: string; - orderId?: string; - orderLinkId?: string; - orderFilter?: USDCOrderFilter; -} +/** + * + * If you haven't connected yet, the WebsocketClient will automatically connect and authenticate you as soon as you send + * your first command. That connection will then be reused for every command you send, unless the connection drops - then + * it will automatically be replaced with a healthy connection. + * + * This "not connected yet" scenario can add an initial delay to your first command. If you want to prepare a connection + * in advance, you can ask the WebsocketClient to prepare it before you start submitting commands. This is optional. + * + */ ⋮---- -export interface UMActiveOrdersRequest { - category: UMCategory; - symbol?: string; - baseCoin?: string; - orderId?: string; - orderLinkId?: string; - orderFilter?: USDCOrderFilter; - direction?: UMDirection; - limit?: number; - cursor?: string; -} +// Optional, see above. Can be used to prepare a connection before sending commands ⋮---- -export interface UMHistoricOrdersRequest { - category: UMCategory; - symbol?: string; - baseCoin?: string; - orderId?: string; - orderLinkId?: string; - orderStatus?: string; - orderFilter?: USDCOrderFilter; - direction?: UMDirection; - limit?: number; - cursor?: string; -} +/** + * Create a new order + */ ⋮---- -export interface UMBatchOrder { - symbol: string; - side: OrderSide; - positionIdx?: '0'; - orderType: UMOrderType; - qty: string; - price?: string; - iv?: string; - timeInForce: USDCTimeInForce; - orderLinkId?: string; - reduceOnly?: boolean; - closeOnTrigger?: boolean; - mmp?: boolean; -} +// The type for `wsAPISubmitOrderResult` is automatically resolved to `WSAPIResponse` ⋮---- -export interface UMBatchOrderReplace { - symbol: string; - orderId?: string; - orderLinkId?: string; - iv?: string; - qty?: string; - price?: string; -} +// Save the orderId for the next call ⋮---- -export interface UMBatchOrderCancel { - symbol: string; - orderId?: string; - orderLinkId?: string; -} +// The type for `wsAPIAmendOrderResult` is automatically resolved to `WSAPIResponse` ⋮---- -export interface UMCancelAllOrdersRequest { - category: UMCategory; - baseCoin?: string; - settleCoin?: string; - symbol?: string; - orderFilter?: USDCOrderFilter; -} +// Save the orderId for the next call ⋮---- -export interface UMPositionsRequest { - category: UMCategory; - symbol?: string; - baseCoin?: string; - direction?: UMDirection; - limit?: number; - cursor?: string; -} +// The type for `wsAPICancelOrderResult` is automatically resolved to `WSAPIResponse` ⋮---- -export interface UMSetTPSLRequest { - category: UMCategory; - symbol: string; - takeProfit?: string; - stopLoss?: string; - trailingStop?: string; - tpTriggerBy?: string; - slTriggerBy?: string; - activePrice?: string; - slSize?: string; - tpSize?: string; - positionIdx?: '0'; -} +// Start executing the example workflow + +================ +File: examples/README.md +================ +# Examples + +These samples can be executed using `ts-node`: +``` +ts-node ./examples/rest-spot-public.ts +``` + +================ +File: src/types/request/account-asset.ts +================ +export type TransferAccountType = + | 'CONTRACT' + | 'SPOT' + | 'INVESTMENT' + | 'OPTION' + | 'UNIFIED'; ⋮---- -export interface UM7DayTradingHistoryRequest { - category: UMCategory; - symbol: string; - baseCoin?: string; - orderId?: string; - orderLinkId?: string; - startTime?: number; - endTime?: number; - direction?: UMDirection; - limit?: number; - cursor?: string; - execType?: string; -} +export type TransferType = 'IN' | 'OUT'; ⋮---- -export interface UMOptionsSettlementHistoryRequest { - category: UMCategory; - symbol?: string; - expDate?: string; - direction?: UMDirection; - limit?: number; - cursor?: string; +export type TransferStatus = 'SUCCESS' | 'PENDING' | 'FAILED'; +⋮---- +export type PageDirection = 'Prev' | 'Next'; +⋮---- +export interface InternalTransferRequest { + transfer_id: string; + coin: string; + amount: string; + from_account_type: TransferAccountType; + to_account_type: TransferAccountType; } ⋮---- -export interface UMPerpSettlementHistoryRequest { - category: UMCategory; - symbol?: string; - direction?: UMDirection; - limit?: number; - cursor?: string; +export interface InternalTransferRequestV3 { + transferId: string; + coin: string; + amount: string; + fromAccountType: string; + toAccountType: string; } ⋮---- -export interface UMTransactionLogRequest { - category: UMCategory; - currency: string; - baseCoin?: string; - type?: string; +export interface QueryInternalTransfersRequestV3 { + transferId?: string; + coin: string; + status?: string; startTime?: number; endTime?: number; - direction?: UMDirection; limit?: number; cursor?: string; } ⋮---- -export interface UMExchangeCoinsRequest { - fromCoin?: string; - toCoin?: string; +export interface SubAccountTransferRequest { + transfer_id: string; + coin: string; + amount: string; + sub_user_id: string; + type: TransferType; } ⋮---- -export interface UMBorrowHistoryRequest { - currency: string; +export interface SubAccountTransferRequestV3 { + transferId?: string; + coin?: string; + status?: string; startTime?: number; endTime?: number; - direction?: UMDirection; limit?: number; cursor?: string; } - -================ -File: src/types/request/usdc-options.ts -================ -import { OrderSide } from '../shared'; -import { USDCAPICategory, USDCOrderType, USDCTimeInForce } from './usdc-shared'; -⋮---- -export interface USDCOptionsContractInfoRequest { - symbol?: string; - status?: 'WAITING_ONLINE' | 'ONLINE' | 'DELIVERING' | 'OFFLINE'; - baseCoin?: string; - direction?: string; - limit?: string; - cursor?: string; -} ⋮---- -export interface USDCOptionsDeliveryPriceRequest { - symbol?: string; - baseCoin?: string; - direction?: string; - limit?: string; +export interface TransferQueryRequest { + transfer_id?: string; + coin?: string; + status?: TransferStatus; + start_time?: number; + end_time?: number; + direction?: PageDirection; + limit?: number; cursor?: string; } ⋮---- -export interface USDCOptionsRecentTradesRequest { - category: USDCAPICategory; - symbol?: string; - baseCoin?: string; - optionType?: 'Call' | 'Put'; - limit?: string; +export interface EnableUniversalTransferRequest { + /** A comma-separated list of subaccount UIDs, for example "123,45,14,26,46" */ + transferable_sub_ids?: string; } ⋮---- -export interface USDCOptionsHistoricalVolatilityRequest { - baseCoin?: string; - period?: string; - startTime?: string; - endTime?: string; -} +/** A comma-separated list of subaccount UIDs, for example "123,45,14,26,46" */ ⋮---- -export interface USDCOptionsOrderRequest { - symbol: string; - orderType: USDCOrderType; - side: OrderSide; - orderPrice?: string; - orderQty: string; - iv?: string; - timeInForce?: USDCTimeInForce; - orderLinkId?: string; - reduceOnly?: boolean; +export interface UniversalTransferRequest { + transfer_id: string; + coin: string; + amount: string; + from_member_id: string; + to_member_id: string; + from_account_type: TransferAccountType; + to_account_type: TransferAccountType; +} +export interface SupportedDepositListRequest { + coin?: string; + chain?: string; + page_index?: number; + page_size?: number; } ⋮---- -export interface USDCOptionsModifyOrderRequest { - symbol: string; - orderId?: string; - orderLinkId?: string; - orderPrice?: string; - orderQty?: string; - iv?: string; +export interface DepositRecordsRequest { + start_time?: number; + end_time?: number; + coin?: string; + cursor?: string; + direction?: PageDirection; + limit?: number; } ⋮---- -export interface USDCOptionsCancelOrderRequest { - symbol: string; - orderId?: string; - orderLinkId?: string; +export interface WithdrawalRecordsRequest { + withdraw_id?: number; + start_time?: number; + end_time?: number; + coin?: string; + cursor?: string; + direction?: PageDirection; + limit?: number; } ⋮---- -export interface USDCOptionsCancelAllOrdersRequest { - symbol?: string; - baseCoin?: string; +export interface AccountAssetInformationRequest { + /** Account type. Default value: ACCOUNT_TYPE_SPOT */ + account_type?: string; + coin?: string; } ⋮---- -export interface USDCOptionsActiveOrdersRealtimeRequest { - orderId?: string; - orderLinkId?: string; - symbol?: string; - baseCoin?: string; - direction?: string; - limit?: number; - cursor?: string; +/** Account type. Default value: ACCOUNT_TYPE_SPOT */ +⋮---- +export interface WithdrawalRequest { + address: string; + amount: string; + coin: string; + chain: string; + tag?: string; } ⋮---- -export interface USDCOptionsActiveOrdersRequest { - category: 'OPTION'; - symbol?: string; - baseCoin?: string; - orderId?: string; - orderLinkId?: string; - direction?: string; - limit?: number; - cursor?: string; +export interface UniversalTransferRequestV3 { + transferId: string; + coin: string; + amount: string; + fromMemberId: string; + toMemberId: string; + fromAccountType: TransferAccountType; + toAccountType: TransferAccountType; } ⋮---- -export interface USDCOptionsHistoricOrdersRequest { - category: 'OPTION'; - symbol?: string; - baseCoin?: string; - orderId?: string; - orderLinkId?: string; - orderStatus?: string; - direction?: string; +export interface UniversalTransferListRequestV3 { + transferId?: string; + coin: string; + status?: string; + startTime?: number; + endTime?: number; limit?: number; cursor?: string; } ⋮---- -export interface USDCOptionsOrderExecutionRequest { - category: 'OPTION'; - symbol?: string; - baseCoin?: string; - orderId?: string; - orderLinkId?: string; - startTime?: string; - direction?: string; - limit?: number; - cursor?: string; +export interface TransferCoinListRequestV3 { + fromAccountType: TransferAccountType; + toAccountType: TransferAccountType; } ⋮---- -export interface USDCOptionsDeliveryHistoryRequest { - symbol: string; - expDate?: string; - direction?: string; - limit?: string; - cursor?: string; +export interface SingleAccountCoinBalanceRequestV3 { + memberId?: string; + accountType: TransferAccountType; + coin: string; + withBonus?: '0' | '1'; } ⋮---- -export interface USDCOptionsPositionsInfoExpiryRequest { - expDate?: string; - direction?: string; - limit?: string; - cursor?: string; +export interface AccountCoinBalancesRequestV3 { + memberId?: string; + accountType: TransferAccountType; + coin?: string; + withBonus?: '0' | '1'; } ⋮---- -export interface USDCOptionsModifyMMPRequest { - currency: string; - windowMs: number; - frozenPeriodMs: number; - qtyLimit: string; - deltaLimit: string; +export interface AssetInfoRequestV3 { + accountType?: TransferAccountType; + coin?: string; } - -================ -File: src/types/request/usdc-perp.ts -================ -import { OrderSide } from '../shared'; -import { - USDCAPICategory, - USDCOrderFilter, - USDCOrderType, - USDCTimeInForce, -} from './usdc-shared'; ⋮---- -export interface USDCOpenInterestRequest { - symbol: string; - period: string; +export interface SupportedDepositListRequestV3 { + coin?: string; + chain?: string; + cursor?: string; limit?: number; } ⋮---- -export interface USDCLast500TradesRequest { - category: USDCAPICategory; - symbol?: string; - baseCoin?: string; - limit?: string; +export interface DepositRecordQueryRequestV3 { + startTime?: number; + endTime?: number; + coin?: string; + cursor?: string; + limit?: number; } ⋮---- -export interface USDCSymbolDirectionLimit { - symbol?: string; - direction?: string; - limit?: string; +export interface SubDepositRecordQueryRequestV3 { + subMemberId: number; + startTime?: number; + endTime?: number; + coin?: string; + cursor?: string; + limit?: number; } ⋮---- -export interface USDCSymbolDirectionLimitCursor { - symbol?: string; - direction?: string; - limit?: string; +export interface WithdrawRecordQueryRequestV3 { + withdrawID?: number; + startTime?: number; + endTime?: number; + coin?: string; + withdrawType?: string; cursor?: string; + limit?: number; } ⋮---- -export interface USDCPerpOrderRequest { - symbol: string; - orderType: USDCOrderType; - orderFilter: USDCOrderFilter; - side: OrderSide; - orderPrice?: string; - orderQty: string; - timeInForce?: USDCTimeInForce; - orderLinkId?: string; - reduceOnly?: boolean; - closeOnTrigger?: boolean; - takeProfit?: string; - stopLoss?: string; - tptriggerby?: string; - slTriggerBy?: string; - basePrice?: string; - triggerPrice?: string; - triggerBy?: string; - mmp?: boolean; +export interface WithdrawCreateRequestV3 { + coin: string; + chain: string; + address: string; + tag?: string; + amount: string; + timestamp: number; + forceChain?: 0 | 1; } ⋮---- -export interface USDCPerpModifyOrderRequest { - symbol: string; - orderFilter: USDCOrderFilter; - orderId?: string; - orderLinkId?: string; - orderPrice?: string; - orderQty?: string; - takeProfit?: string; - stopLoss?: string; - tptriggerby?: string; - slTriggerBy?: string; - triggerPrice?: string; +export interface QueryDepositAddressRequestV3 { + coin?: string; + chainType?: string; } ⋮---- -export interface USDCPerpCancelOrderRequest { - symbol: string; - orderFilter: USDCOrderFilter; - orderId?: string; - orderLinkId?: string; +export interface QuerySubAccountDepositAddressRequestV3 { + coin?: string; + chainType?: string; + subMemberId: string; } ⋮---- -export interface USDCPerpActiveOrdersRequest { - category: 'PERPETUAL'; - symbol?: string; - baseCoin?: string; - orderId?: string; - orderLinkId?: string; - orderFilter?: USDCOrderFilter; - direction?: string; - limit?: number; - cursor?: string; +export interface CreateSubMemberRequestV3 { + username: string; + memberType: 1 | 6; + switch?: 0 | 1; + note?: string; } ⋮---- -export interface USDCPerpHistoricOrdersRequest { - category: 'PERPETUAL'; - symbol?: string; - baseCoin?: string; - orderId?: string; - orderLinkId?: string; - orderStatus?: string; - orderFilter?: USDCOrderFilter; - direction?: string; - limit?: number; - cursor?: string; +export interface CreateSubAPIKeyRequestV3 { + subuid: string; + note?: string; + readOnly: 0 | 1; + ips?: string[]; + permissions: { + ContractTrade?: string[]; + Spot?: string[]; + Wallet?: string[]; + Options?: string[]; + Derivatives?: string[]; + Exchange?: string[]; + }; +} +⋮---- +export interface ModifyAPIKeyRequestV3 { + readOnly: number; + ips?: string[]; + permissions: { + ContractTrade?: string[]; + Spot?: string[]; + Wallet?: string[]; + Options?: string[]; + Derivatives?: string[]; + CopyTrading?: string[]; + BlockTrade?: string[]; + Exchange?: string[]; + NFT?: string[]; + }; } ================ -File: src/types/request/usdc-shared.ts +File: src/types/request/contract.ts ================ -export type USDCAPICategory = 'PERPETUAL' | 'OPTION'; -⋮---- -export type USDCOrderType = 'Limit' | 'Market'; -⋮---- -export type USDCTimeInForce = - | 'GoodTillCancel' - | 'ImmediateOrCancel' - | 'FillOrKill' - | 'PostOnly'; -⋮---- -export type USDCOrderFilter = 'Order' | 'StopOrder'; +import { OrderSide } from '../shared'; +import { UMOrderType } from './unified-margin'; +import { USDCOrderFilter, USDCTimeInForce } from './usdc-shared'; ⋮---- -export interface USDCKlineRequest { +export interface ContractOrderRequest { symbol: string; - period: string; - startTime: number; - limit?: string; -} -⋮---- -export interface USDCTransactionLogRequest { - type: string; - baseCoin?: string; - startTime?: string; - endTime?: string; - direction?: string; - limit?: string; - cursor?: string; - category?: USDCAPICategory; + side: OrderSide; + orderType: UMOrderType; + qty: string; + timeInForce: USDCTimeInForce; + price?: string; + triggerDirection?: '1' | '2'; + triggerPrice?: string; + triggerBy?: string; + positionIdx?: '0' | '1' | '2'; + orderLinkId?: string; + takeProfit?: string; + stopLoss?: string; + tpTriggerBy?: string; + slTriggerBy?: string; + reduceOnly?: boolean; + closeOnTrigger?: boolean; + tpslMode?: 'Partial' | 'Full'; + tpOrderType?: UMOrderType; + slOrderType?: UMOrderType; } ⋮---- -export interface USDCPositionsRequest { - category: USDCAPICategory; - symbol?: string; - baseCoin?: string; - expDate?: string; - direction?: string; - limit?: string; - cursor?: string; -} - -================ -File: src/types/request/v5-event.ts -================ -export interface GetEventInstrumentsInfoParamsV5 { - symbol?: string; - status?: 'PreLaunch' | 'Trading' | 'Delivering' | 'Closed'; +export interface ContractHistoricOrdersRequest { + orderId?: string; + orderLinkId?: string; + symbol: string; + orderStatus?: string; + orderFilter?: USDCOrderFilter; limit?: number; cursor?: string; } ⋮---- -export interface GetEventOrderbookParamsV5 { +export interface ContractCancelOrderRequest { symbol: string; + orderId?: string; + orderLinkId?: string; } ⋮---- -export interface GetEventOrderHistoryParamsV5 { - symbol?: string; +export interface ContractModifyOrderRequest { + symbol: string; orderId?: string; orderLinkId?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; + price?: string; + qty?: string; + triggerPrice?: string; + takeProfit?: string; + stopLoss?: string; + tpTriggerBy?: string; + slTriggerBy?: string; + triggerBy?: string; + tpLimitPrice?: string; + slLimitPrice?: string; } ⋮---- -export interface GetEventActiveOrdersParamsV5 { +export interface ContractActiveOrdersRequest { symbol?: string; orderId?: string; orderLinkId?: string; + settleCoin?: string; + orderFilter?: USDCOrderFilter; limit?: number; - cursor?: string; } ⋮---- -export interface GetEventPositionInfoParamsV5 { +export interface ContractPositionsRequest { symbol?: string; - baseCoin?: string; settleCoin?: string; - limit?: number; - cursor?: string; + dataFilter?: string; } ⋮---- -export interface GetEventTradeHistoryParamsV5 { +export interface ContractSetAutoAddMarginRequest { + symbol: string; + side: 'Buy' | 'Sell'; + autoAddMargin: 1 | 0; + positionIdx?: 0 | 1 | 2; +} +⋮---- +export interface ContractSetMarginSwitchRequest { + symbol: string; + tradeMode: 0 | 1; + buyLeverage: string; + sellLeverage: string; +} +⋮---- +export interface ContractSetPositionModeRequest { + symbol?: string; + coin?: string; + mode: 0 | 3; +} +⋮---- +export interface ContractSetTPSLRequest { + symbol: string; + takeProfit?: string; + stopLoss?: string; + tpslMode?: 'Full' | 'Partial'; + tpSize?: string; + slSize?: string; + tpTriggerBy?: string; + slTriggerBy?: string; + trailingStop?: string; + activePrice?: string; + tpLimitPrice?: string; + slLimitPrice?: string; + tpOrderType?: UMOrderType; + slOrderType?: UMOrderType; + /** 0-one-way, 1-buy side, 2-sell side */ + positionIdx?: 0 | 1 | 2; +} +⋮---- +/** 0-one-way, 1-buy side, 2-sell side */ +⋮---- +export interface ContractUserExecutionHistoryRequest { symbol: string; orderId?: string; - orderLinkId?: string; startTime?: number; endTime?: number; + execType?: 'Trade' | 'AdlTrade' | 'Funding' | 'BustTrade'; limit?: number; cursor?: string; } ⋮---- -export interface GetEventSettlementRecordsParamsV5 { +export interface ContractClosedPNLRequest { symbol: string; - orderId?: string; startTime?: number; endTime?: number; limit?: number; cursor?: string; } ⋮---- -export interface SubmitEventQuoteParamsV5 { - symbol: string; - orderLinkId: string; - grossPayoutRatio: string; - amount: string; -} -⋮---- -export interface CancelEventQuoteParamsV5 { - orderLinkId?: string; - orderId?: string; +export interface ContractWalletFundRecordRequest { + startTime?: string; + endTime?: string; + coin?: string; + walletFundType?: string; + limit?: string; + cursor?: string; } ================ -File: src/types/request/v5-p2p-trading.ts +File: src/types/request/copy-trading.ts ================ -export interface GetP2PAccountCoinsBalanceParamsV5 { - memberId?: string; - accountType: string; - coin?: string; - withBonus?: 0 | 1; +import { OrderSide } from '../shared'; +import { USDCOrderType } from './usdc-shared'; +⋮---- +export interface CopyTradingOrderRequest { + side: OrderSide; + symbol: string; + orderType: USDCOrderType; + price: string; + qty: string; + takeProfit?: string; + stopLoss?: string; + tpTriggerBy?: string; + slTriggerBy?: string; + orderLinkId?: string; } ⋮---- -export interface GetP2POnlineAdsParamsV5 { - tokenId: string; - currencyId: string; - side: '0' | '1'; // 0: buy; 1: sell - page?: string; - size?: string; +export interface CopyTradingTradingStopRequest { + symbol: string; + parentOrderId: string; + takeProfit?: string; + stopLoss?: string; + tpTriggerBy?: string; + slTriggerBy?: string; + parentOrderLinkId?: string; } ⋮---- -side: '0' | '1'; // 0: buy; 1: sell -⋮---- -export interface P2PTradingPreferenceSetV5 { - hasUnPostAd?: 0 | 1; - isKyc?: 0 | 1; - isEmail?: 0 | 1; - isMobile?: 0 | 1; - hasRegisterTime?: 0 | 1; - registerTimeThreshold?: number; - orderFinishNumberDay30?: number; - completeRateDay30?: string; - nationalLimit?: string; - hasOrderFinishNumberDay30?: 0 | 1; - hasCompleteRateDay30?: 0 | 1; - hasNationalLimit?: 0 | 1; +export interface CopyTradingOrderListRequest { + symbol?: string; + orderId?: string; + orderLinkId?: string; + copyTradeOrderType?: string; } ⋮---- -export interface CreateP2PAdParamsV5 { - tokenId: string; - currencyId: string; - side: '0' | '1'; // 0: buy; 1: sell - priceType: '0' | '1'; // 0: fixed rate; 1: floating rate - premium: string; - price: string; - minAmount: string; - maxAmount: string; - remark: string; - tradingPreferenceSet: P2PTradingPreferenceSetV5; - paymentIds: string[]; - quantity: string; - paymentPeriod: string; - itemType: 'ORIGIN' | 'BULK'; +export interface CopyTradingCancelOrderRequest { + symbol: string; + orderId?: string; + orderLinkId?: string; } ⋮---- -side: '0' | '1'; // 0: buy; 1: sell -priceType: '0' | '1'; // 0: fixed rate; 1: floating rate -⋮---- -export interface UpdateP2PAdParamsV5 { - id: string; - priceType: '0' | '1'; // 0: fixed rate; 1: floating rate - premium: string; - price: string; - minAmount: string; - maxAmount: string; - remark: string; - tradingPreferenceSet: P2PTradingPreferenceSetV5; - paymentIds: string[]; - actionType: 'MODIFY' | 'ACTIVE'; // MODIFY: modify adv; ACTIVE: reonline adv - quantity: string; - paymentPeriod: string; - itemType?: 'ORIGIN' | 'BULK'; - subsidyAd?: boolean; - securityRiskToken?: string; +export interface CopyTradingCloseOrderRequest { + symbol: string; + orderLinkId?: string; + parentOrderId?: string; + parentOrderLinkId?: string; } ⋮---- -priceType: '0' | '1'; // 0: fixed rate; 1: floating rate +export interface CopyTradingTransferRequest { + transferId: string; + coin: string; + amount: string; + fromAccountType: string; + toAccountType: string; +} + +================ +File: src/types/request/inverse.ts +================ +export interface InverseOrderRequest { + side: string; + symbol: string; + order_type: string; + qty: number; + price?: number; + time_in_force: string; + take_profit?: number; + stop_loss?: number; + reduce_only?: boolean; + tp_trigger_by?: 'LastPrice' | 'MarkPrice' | 'IndexPrice'; + sl_trigger_by?: 'LastPrice' | 'MarkPrice' | 'IndexPrice'; + close_on_trigger?: boolean; + order_link_id?: string; +} ⋮---- -actionType: 'MODIFY' | 'ACTIVE'; // MODIFY: modify adv; ACTIVE: reonline adv +export interface InverseActiveOrdersRequest { + symbol: string; + order_status?: string; + direction?: string; + limit?: number; + cursor?: string; +} ⋮---- -export interface GetP2PPersonalAdsParamsV5 { - itemId?: string; - status?: '1' | '2'; // 1: Sold Out; 2: Available - side?: '0' | '1'; // 0: buy; 1: sell - tokenId?: string; - page?: string; - size?: string; - currencyId?: string; +export interface InverseCancelOrderRequest { + symbol: string; + order_id?: string; + order_link_id?: string; } ⋮---- -status?: '1' | '2'; // 1: Sold Out; 2: Available -side?: '0' | '1'; // 0: buy; 1: sell +export interface InverseReplaceOrderRequest { + order_id?: string; + order_link_id?: string; + symbol: string; + p_r_qty?: number; + p_r_price?: string; + take_profit?: number; + stop_loss?: number; + tp_trigger_by?: string; + sl_trigger_by?: string; +} ⋮---- -export interface GetP2POrdersParamsV5 { - status?: number; - beginTime?: string; - endTime?: string; - tokenId?: string; - side?: number[]; - page: number; - size: number; +export interface InverseGetOrderRequest { + order_id?: string; + order_link_id?: string; + symbol: string; } ⋮---- -export interface GetP2PPendingOrdersParamsV5 { - status?: number; - beginTime?: string; - endTime?: string; - tokenId?: string; - side?: number[]; - page: number; - size: number; +export interface InverseConditionalOrderRequest { + side: string; + symbol: string; + order_type: string; + qty: string; + price?: string; + base_price: string; + stop_px: string; + time_in_force: string; + trigger_by?: string; + close_on_trigger?: boolean; + order_link_id?: string; } ⋮---- -export interface MarkP2POrderAsPaidParamsV5 { - orderId: string; - paymentType: string; - paymentId: string; +export interface InverseActiveConditionalOrderRequest { + symbol: string; + stop_order_status?: string; + direction?: string; + limit?: number; + cursor?: string; } ⋮---- -export interface SendP2POrderMessageParamsV5 { - message: string; - contentType: string; - orderId: string; - msgUuid?: string; - fileName?: string; +export interface InverseCancelConditionalOrderRequest { + symbol: string; + stop_order_id?: string; + order_link_id?: string; } ⋮---- -export interface GetP2POrderMessagesParamsV5 { - orderId: string; - currentPage?: string; - size: string; +export interface InverseReplaceConditionalOrderRequest { + stop_order_id?: string; + order_link_id?: string; + symbol: string; + p_r_qty?: number; + p_r_price?: string; + p_r_trigger_price?: string; } ⋮---- -export interface GetP2PCounterpartyUserInfoParamsV5 { - originalUid: string; - orderId: string; +export interface InverseChangePositionMarginRequest { + symbol: string; + margin: string; } - -================ -File: src/types/request/v5-pre-upgrade.ts -================ -import { ExecTypeV5 } from '../shared-v5'; ⋮---- -export interface GetPreUpgradeOrderHistoryParamsV5 { - category: 'linear' | 'inverse'; - symbol?: string; - baseCoin?: string; - orderId?: string; - orderLinkId?: string; - orderFilter?: 'Order' | 'StopOrder'; - orderStatus?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; +export interface InverseSetTradingStopRequest { + symbol: string; + take_profit?: number; + stop_loss?: number; + trailing_stop?: number; + tp_trigger_by?: string; + sl_trigger_by?: string; + new_trailing_active?: number; } ⋮---- -export interface GetPreUpgradeTradeHistoryParamsV5 { - category: 'linear' | 'inverse'; - symbol?: string; - orderId?: string; - orderLinkId?: string; - baseCoin?: string; - startTime?: number; - endTime?: number; - execType?: ExecTypeV5; - limit?: number; - cursor?: string; +export interface InverseSetLeverageRequest { + symbol: string; + leverage: number; + leverage_only?: boolean; } ⋮---- -export interface GetPreUpgradeClosedPnlParamsV5 { - category: 'linear' | 'inverse'; +export interface InverseGetTradeRecordsRequest { + order_id?: string; symbol: string; - startTime?: number; - endTime?: number; + start_time?: number; + page?: number; limit?: number; - cursor?: string; + order?: string; } ⋮---- -export interface GetPreUpgradeTransactionLogParamsV5 { - category: 'linear' | 'option'; - baseCoin?: string; - type?: string; - startTime?: number; - endTime?: number; +export interface InverseGetClosedPnlRequest { + symbol: string; + start_time?: number; + end_time?: number; + exec_type?: string; + page?: number; limit?: number; - cursor?: string; } ⋮---- -export interface GetPreUpgradeOptionDeliveryRecordParamsV5 { - category: 'option'; - symbol?: string; - expDate?: string; - limit?: number; - cursor?: string; +export interface InverseSetSlTpPositionModeRequest { + symbol: string; + tp_sl_mode: 'Full' | 'Partial'; } ⋮---- -export interface GetPreUpgradeUSDCSessionParamsV5 { - category: 'linear'; - symbol?: string; - limit?: number; - cursor?: string; +export interface InverseSetMarginTypeRequest { + symbol: string; + is_isolated: boolean; + buy_leverage: number; + sell_leverage: number; } ================ -File: src/types/response/account-asset.ts +File: src/types/request/linear.ts ================ -export interface UniversalTransferCreateResponse { - transferId: string; +import { + LinearPositionIdx, + linearPositionModeEnum, + positionTpSlModeEnum, +} from '../../constants/enum'; +import { OrderSide } from '../shared'; +⋮---- +export interface LinearGetOrdersRequest { + order_id?: string; + order_link_id?: string; + symbol: string; + order?: string; + page?: number; + limit?: number; + order_status?: string; } ⋮---- -export interface UniversalTransferListResponseV3 { - list: { - transferId: string; - coin: string; - amount: string; - timestamp: string; - status: string; - fromAccountType: string; - toAccountType: string; - fromMemberId: string; - toMemberId: string; - }[]; - nextPageCursor: string; +export interface LinearCancelOrderRequest { + symbol: string; + order_id?: string; + order_link_id?: string; } ⋮---- -export interface QueryInternalTransferSResponseV3 { - list: { - transferId: string; - coin: string; - amount: string; - fromAccountType: string; - toAccountType: string; - timestamp: string; - status: string; - }[]; - nextPageCursor: string; +export interface LinearReplaceOrderRequest { + order_id?: string; + order_link_id?: string; + symbol: string; + p_r_qty?: number; + p_r_price?: number; + take_profit?: number; + stop_loss?: number; + tp_trigger_by?: string; + sl_trigger_by?: string; } ⋮---- -export interface SubAccountTransferResponseV3 { - list: { - transferId: string; - coin: string; - amount: string; - memberId: number; - subMemberId: number; - timestamp: string; - status: string; - type: 'IN' | 'OUT'; - }[]; - nextPageCursor: string; +export interface LinearGetOrderRequest { + order_id?: string; + order_link_id?: string; + symbol: string; } ⋮---- -export interface AccountCoinBalanceResponseV3 { - accountType: string; - bizType: number; - accountId: string; - memberId: string; - balance: { - coin: string; - walletBalance: string; - transferBalance: string; - bonus: string; - }; +export type LinearOrderType = 'Limit' | 'Market'; +⋮---- +export type LinearTimeInForce = + | 'GoodTillCancel' + | 'ImmediateOrCancel' + | 'FillOrKill' + | 'PostOnly'; +⋮---- +export interface NewLinearOrder { + side: OrderSide; + symbol: string; + order_type: LinearOrderType; + qty: number; + price?: number; + time_in_force: LinearTimeInForce; + take_profit?: number; + stop_loss?: number; + tp_trigger_by?: string; + sl_trigger_by?: string; + reduce_only: boolean; + close_on_trigger: boolean; + order_link_id?: string; + position_idx?: LinearPositionIdx; } ⋮---- -export interface AccountCoinBalancesResponseV3 { - accountType: string; - memberId: string; - balance: { - coin: string; - walletBalance: string; - transferBalance: string; - bonus: string; - }[]; +export interface LinearConditionalOrderRequest { + side: string; + symbol: string; + order_type: string; + qty: number; + price?: number; + base_price: number; + stop_px: number; + time_in_force: string; + trigger_by?: string; + close_on_trigger?: boolean; + order_link_id?: string; + reduce_only: boolean; + take_profit?: number; + stop_loss?: number; + tp_trigger_by?: string; + sl_trigger_by?: string; } ⋮---- -export interface AssetInfoResponseV3 { - spot: { - status: 'ACCOUNT_STATUS_NORMAL' | 'ACCOUNT_STATUS_UNSPECIFIED'; - assets: { - coin: string; - frozen: string; - free: string; - withdraw: string; - }[]; - }; +export interface LinearGetConditionalOrderRequest { + stop_order_id?: string; + order_link_id?: string; + symbol: string; + stop_order_status?: string; + order?: string; + page?: number; + limit?: number; } ⋮---- -interface SupportedDepositV3 { - coin: string; - chain: string; - coinShowName: string; - chainType: string; - blockConfirmNumber: number; - minDepositAmount: string; +export interface LinearCancelConditionalOrderRequest { + symbol: string; + stop_order_id?: string; + order_link_id?: string; } ⋮---- -export interface SupportedDepositListResponseV3 { - configList: SupportedDepositV3[]; - nextPageCursor: string; +export interface LinearReplaceConditionalOrderRequest { + stop_order_id?: string; + order_link_id?: string; + symbol: string; + p_r_qty?: number; + p_r_price?: number; + p_r_trigger_price?: number; + take_profit?: number; + stop_loss?: number; + tp_trigger_by?: string; + sl_trigger_by?: string; } ⋮---- -interface DepositRecordV3 { - coin: string; - chain: string; - amount: string; - txID: string; - status: number; - toAddress: string; - tag: string; - depositFee: string; - successAt: string; - confirmations: string; - txIndex: string; - blockHash: string; +export interface LinearQueryConditionalOrderRequest { + symbol: string; + stop_order_id?: string; + order_link_id?: string; } ⋮---- -export interface DepositRecordQueryResponseV3 { - rows: DepositRecordV3[]; - nextPageCursor: string; +export interface LinearSetAutoAddMarginRequest { + symbol: string; + side: string; + auto_add_margin: boolean; } ⋮---- -export interface WithdrawRecordsQueryResponseV3 { - rows: { - coin: string; - chain: string; - amount: string; - txID: string; - status: number; - toAddress: string; - tag: string; - withdrawFee: string; - createTime: string; - updateTime: string; - withdrawId: string; - withdrawType: number; - }[]; - nextPageCursor: string; +export interface LinearSetMarginSwitchRequest { + symbol: string; + is_isolated: boolean; + buy_leverage: number; + sell_leverage: number; } ⋮---- -export interface CoinInfoV3 { - name: string; - coin: string; - remainAmount: string; - chains: { - chainType: string; - confirmation: string; - withdrawFee: string; - depositMin: string; - withdrawMin: string; - chain: string; - chainDeposit: string; - chainWithdraw: string; - minAccuracy: string; - }[]; -} -⋮---- -export interface CoinInfoQueryResponseV3 { - rows: CoinInfoV3[]; +export interface LinearSetPositionModeRequest { + symbol: string; + mode: (typeof linearPositionModeEnum)[keyof typeof linearPositionModeEnum]; } ⋮---- -export interface DepositAddressChainV3 { - chainType: string; - addressDeposit: string; - tagDeposit: string; - chain: string; +export interface LinearSetPositionTpSlModeRequest { + symbol: string; + tp_sl_mode: (typeof positionTpSlModeEnum)[keyof typeof positionTpSlModeEnum]; } ⋮---- -export interface DepositAddressResponseV3 { - coin: string; - chains: DepositAddressChainV3[]; +export interface LinearSetAddReduceMarginRequest { + symbol: string; + side: string; + margin: number; } ⋮---- -export interface CreateSubMemberResponseV3 { - uid: number; - username: string; - memberType: 1 | 6; - switch: 0 | 1; - note: string; +export interface LinearSetUserLeverageRequest { + symbol: string; + buy_leverage: number; + sell_leverage: number; } ⋮---- -export interface CreateSubAPIKeyResponseV3 { - id: string; - note: string; - apiKey: string; - readOnly: string; - secret: string; - permissions: { - ContractTrade: string[]; - Spot: string[]; - Wallet: string[]; - Options: string[]; - Derivatives: string[]; - CopyTrading: string[]; - BlockTrade: string[]; - Exchange: string[]; - NFT: string[]; - }; +export interface LinearSetTradingStopRequest { + symbol: string; + side: string; + take_profit?: number; + stop_loss?: number; + trailing_stop?: number; + tp_trigger_by?: string; + sl_trigger_by?: string; + sl_size?: number; + tp_size?: number; + position_idx?: 0 | 1 | 2; } ⋮---- -export interface SubMemberV3 { - uid: string; - username: string; - memberType: 1 | 6; - status: 1 | 2 | 4; - remark: string; +export interface LinearGetTradeRecordsRequest { + symbol: string; + start_time?: number; + end_time?: number; + exec_type?: string; + page?: number; + limit?: number; } ⋮---- -export interface SubMemberResponseV3 { - subMembers: SubMemberV3[]; +export interface LinearGetHistoryTradeRecordsRequest { + symbol: string; + start_time?: number; + end_time?: number; + exec_type?: string; + page?: number; + limit?: number; + page_token?: string; } ⋮---- -export interface APIKeyInfoV3 { - id: string; - note: string; - apiKey: string; - readOnly: string; - secret: string; - permissions: { - ContractTrade: string[]; - Spot: string[]; - Wallet: string[]; - Options: string[]; - Derivatives: string[]; - CopyTrading: string[]; - BlockTrade: string[]; - Exchange: string[]; - NFT: string[]; - }; - ips: string[]; - type: number; - deadlineDay: number; - expiredAt: string; - createdAt: string; - unified: number; - uta: number; - userID: number; - inviterID: number; - vipLevel: string; - mktMakerLevel: string; - affiliateID: number; -} - -================ -File: src/types/response/shared.ts -================ -export interface SymbolWalletBalance { - equity: number; - available_balance: number; - used_margin: number; - order_margin: number; - position_margin: number; - occ_closing_fee: number; - occ_funding_fee: number; - wallet_balance: number; - realised_pnl: number; - unrealised_pnl: number; - cum_realised_pnl: number; - given_cash: number; - service_cash: number; +export interface LinearGetClosedPnlRequest { + symbol: string; + start_time?: number; + end_time?: number; + exec_type?: string; + page?: number; + limit?: number; } ⋮---- -export interface WalletBalances { - [symbol: string]: SymbolWalletBalance | undefined; +export interface LinearSetRiskLimitRequest { + symbol: string; + side: string; + risk_id: number; } ================ -File: src/types/response/spot.ts +File: src/types/request/unified-margin.ts ================ -export interface SpotBalance { - coin: string; - coinId: string; - coinName: string; - total: string; - free: string; - locked: string; -} +import { KlineIntervalV3, OrderSide } from '../shared'; +import { USDCOrderFilter, USDCTimeInForce } from './usdc-shared'; ⋮---- -export interface SpotBalances { - balances: SpotBalance[]; -} +export type UMCategory = 'linear' | 'inverse' | 'option'; +export type UMOrderType = 'Limit' | 'Market'; +export type UMDirection = 'prev' | 'next'; ⋮---- -export interface SpotLastPrice { +export interface UMCandlesRequest { + category: UMCategory; symbol: string; - price: string; + interval: KlineIntervalV3; + start: number; + end: number; + limit?: number; } - -================ -File: src/types/response/unified-margin.ts -================ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export interface UMPaginatedResult { - nextPageCursor: string; - category: string; - list: List[]; +⋮---- +export interface UMInstrumentInfoRequest { + category: UMCategory; + symbol?: string; + baseCoin?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface UMLeverageFilter { - minLeverage: string; - maxLeverage: string; - leverageStep: string; +export interface UMFundingRateHistoryRequest { + category: UMCategory; + symbol: string; + startTime?: number; + endTime?: number; + limit?: number; } ⋮---- -export interface UMPriceFilter { - minPrice: string; - maxPrice: string; - tickSize: string; +export interface UMOptionDeliveryPriceRequest { + category: UMCategory; + symbol?: string; + baseCoin?: string; + direction?: UMDirection; + limit?: string; + cursor?: string; } ⋮---- -export interface UMLotSizeFilter { - maxTradingQty: string; - minTradingQty: string; - qtyStep: string; +export interface UMPublicTradesRequest { + category: UMCategory; + symbol: string; + baseCoin?: string; + optionType?: 'Call' | 'Put'; + limit?: string; } ⋮---- -export interface UMInstrumentInfo { +export interface UMOpenInterestRequest { + category: UMCategory; symbol: string; - contractType: string; - status: string; - baseCoin: string; - quoteCoin: string; - launchTime: string; - deliveryTime: string; - deliveryFeeRate: string; - priceScale: string; - leverageFilter: UMLeverageFilter; - priceFilter: UMPriceFilter; - lotSizeFilter: UMLotSizeFilter; + interval: '5min' | '15min' | '30min' | '1h' | '4h' | '1d'; + startTime?: number; + endTime?: number; + limit?: number; } ⋮---- -export interface UMHistoricOrder { +export interface UMOrderRequest { + category: UMCategory; symbol: string; - orderType: string; - orderLinkId: string; - orderId: string; - stopOrderType: string; - orderStatus: string; - takeProfit: string; - cumExecValue: string; - blockTradeId: string; - rejectReason: string; - price: string; - createdTime: number; - tpTriggerBy: string; - timeInForce: string; - basePrice: string; - leavesValue: string; - updatedTime: number; - side: string; - triggerPrice: string; - cumExecFee: string; - slTriggerBy: string; - leavesQty: string; - closeOnTrigger: boolean; - cumExecQty: string; - reduceOnly: boolean; + side: OrderSide; + positionIdx?: '0' | '1' | '2'; + orderType: UMOrderType; qty: string; - stopLoss: string; - triggerBy: string; - orderIM: string; + price?: string; + basePrice?: string; + triggerPrice?: string; + triggerBy?: string; + iv?: string; + timeInForce: USDCTimeInForce; + orderLinkId?: string; + takeProfit?: number; + stopLoss?: number; + tpTriggerBy?: string; + slTriggerBy?: string; + reduceOnly?: boolean; + closeOnTrigger?: boolean; + mmp?: boolean; } - -================ -File: src/types/response/usdt-perp.ts -================ -export interface PerpPosition { - user_id: number; +⋮---- +export interface UMModifyOrderRequest { + category: UMCategory; symbol: string; - side: string; - size: number; - position_value: number; - entry_price: number; - liq_price: number; - bust_price: number; - leverage: number; - auto_add_margin: number; - is_isolated: boolean; - position_margin: number; - occ_closing_fee: number; - realised_pnl: number; - cum_realised_pnl: number; - free_qty: number; - tp_sl_mode: string; - unrealised_pnl: number; - deleverage_indicator: number; - risk_id: number; - stop_loss: number; - take_profit: number; - trailing_stop: number; - position_idx: number; - mode: string; + orderId?: string; + orderLinkId?: string; + iv?: string; + triggerPrice?: string; + qty?: string; + price?: string; + takeProfit?: number; + stopLoss?: number; + tpTriggerBy?: string; + slTriggerBy?: string; + triggerBy?: string; } ⋮---- -export interface PerpPositionRoot { - data: PerpPosition; - is_valid: boolean; +export interface UMCancelOrderRequest { + category: UMCategory; + symbol: string; + orderId?: string; + orderLinkId?: string; + orderFilter?: USDCOrderFilter; } ⋮---- -export interface LinearOrder { - order_id: string; - user_id: number; - symbol: string; - side: string; - order_type: string; - price: number; - qty: number; - time_in_force: string; - order_status: string; - last_exec_price: number; - cum_exec_qty: number; - cum_exec_value: number; - cum_exec_fee: number; - reduce_only: boolean; - close_on_trigger: boolean; - order_link_id: string; - created_time: string; - updated_time: string; - take_profit: number; - stop_loss: number; - tp_trigger_by: string; - sl_trigger_by: string; - position_idx: number; +export interface UMActiveOrdersRequest { + category: UMCategory; + symbol?: string; + baseCoin?: string; + orderId?: string; + orderLinkId?: string; + orderFilter?: USDCOrderFilter; + direction?: UMDirection; + limit?: number; + cursor?: string; } - -================ -File: src/types/response/v5-event.ts -================ -export type EventContractTypeV5 = 'Up_Down' | 'UpDown' | 'Target' | 'Range'; -export type EventContractDirectionV5 = - | 'UP' - | 'DOWN' - | 'ABOVE' - | 'BELOW' - | 'RANGE_IN' - | 'RANGE_OUT'; ⋮---- -export interface EventInstrumentFeeRateRuleV5 { - minSecToDelivery: number; - maxSecToDelivery: number; - baseMarkup: string; +export interface UMHistoricOrdersRequest { + category: UMCategory; + symbol?: string; + baseCoin?: string; + orderId?: string; + orderLinkId?: string; + orderStatus?: string; + orderFilter?: USDCOrderFilter; + direction?: UMDirection; + limit?: number; + cursor?: string; } ⋮---- -export interface EventInstrumentQuotationLimitV5 { - minSecToDelivery: number; - maxSecToDelivery: number; - quoteMaxAmountPerUser: string; - quoteMinAmountPerUser: string; - quoteMinAmount: string; +export interface UMBatchOrder { + symbol: string; + side: OrderSide; + positionIdx?: '0'; + orderType: UMOrderType; + qty: string; + price?: string; + iv?: string; + timeInForce: USDCTimeInForce; + orderLinkId?: string; + reduceOnly?: boolean; + closeOnTrigger?: boolean; + mmp?: boolean; } ⋮---- -export interface EventInstrumentLotSizeFilterV5 { - minOrderAmount: string; - maxOrderAmount: string; - orderAmountTickSize: string; - quoteMaxValidMs: number; - quoteMinIntervalPerUserMs: number; +export interface UMBatchOrderReplace { + symbol: string; + orderId?: string; + orderLinkId?: string; + iv?: string; + qty?: string; + price?: string; } ⋮---- -export interface EventInstrumentInfoV5 { +export interface UMBatchOrderCancel { symbol: string; - symbolId: number; - baseCoin: string; - quoteCoin: string; - settleCoin: string; - eventContractType: EventContractTypeV5 | string; - durationWindow: string | number; - rvThreshold: string; - rebate: string; - takerFeeRate: string; - makerFeeRate: string; - launchTime: string; - deliveryTime: string; - status: string; - targetPrice: string; - lowerBound: string; - upperBound: string; - callOptionSymbolId: number; - putOptionSymbolId: number; - feeRateRule: EventInstrumentFeeRateRuleV5[]; - lotSizeFilter: EventInstrumentLotSizeFilterV5; - quotationLimit: EventInstrumentQuotationLimitV5[]; + orderId?: string; + orderLinkId?: string; } ⋮---- -export interface EventInstrumentInfoResultV5 { - nextPageCursor: string; - list: EventInstrumentInfoV5[]; +export interface UMCancelAllOrdersRequest { + category: UMCategory; + baseCoin?: string; + settleCoin?: string; + symbol?: string; + orderFilter?: USDCOrderFilter; } ⋮---- -/** REST Get Orderbook: each entry is [payoutRatio, orderValue] */ -export type EventOrderbookLevelV5 = [string, string]; +export interface UMPositionsRequest { + category: UMCategory; + symbol?: string; + baseCoin?: string; + direction?: UMDirection; + limit?: number; + cursor?: string; +} ⋮---- -export interface EventOrderbookV5 { - s: string; - r: EventOrderbookLevelV5[]; - ts: number; - u: number; - seq: number; - cts: number; +export interface UMSetTPSLRequest { + category: UMCategory; + symbol: string; + takeProfit?: string; + stopLoss?: string; + trailingStop?: string; + tpTriggerBy?: string; + slTriggerBy?: string; + activePrice?: string; + slSize?: string; + tpSize?: string; + positionIdx?: '0'; } ⋮---- -export interface EventOrderHistoryItemV5 { - orderId: string; - orderLinkId: string; - orderStatus: string; +export interface UM7DayTradingHistoryRequest { + category: UMCategory; symbol: string; - symbolId: string; - baseCoin: string; - quoteCoin: string; - settleCoin: string; - ecDirection: EventContractDirectionV5 | string; - ecDurationWindow: string; - ecTargetPrice: string; - ecContractType: EventContractTypeV5 | string; - ecLowerBound: string; - ecUpperBound: string; - settleTimeMs: string; - ecOrderValue: string; - ecIndexPrice: string; - orderAvgPayoutRatio: string; - cumExecValue: string; - payoutRatio: string; - tradeFee: string; - transTime: string; - createTime: string; - updateTime: string; - cumPayout: string; - cumExecFee: string; - cancelType: string; - createType: string; - rejectReason: string; - extraFees: string; + baseCoin?: string; + orderId?: string; + orderLinkId?: string; + startTime?: number; + endTime?: number; + direction?: UMDirection; + limit?: number; + cursor?: string; + execType?: string; } ⋮---- -export interface EventOrderHistoryResultV5 { - list: EventOrderHistoryItemV5[]; - cursor: string; +export interface UMOptionsSettlementHistoryRequest { + category: UMCategory; + symbol?: string; + expDate?: string; + direction?: UMDirection; + limit?: number; + cursor?: string; } ⋮---- -export interface EventActiveOrderV5 { - orderId: string; - orderLinkId: string; - symbol: string; - symbolId: string; - side: string; - orderStatus: string; - payoutRatio: string; - cumExecValue: string; - cumExecFee: string; - leavesValue: string; - ecContractType: EventContractTypeV5 | string; - ecDirection: EventContractDirectionV5 | string; - ecOrderValue: string; - ecSettleTime: string; - ecTargetPrice: string; - ecLowerBound: string; - ecUpperBound: string; - ecDurationWindow: string; - ecIndexPrice: string; - orderAvgPayoutRatio: string; - createType: string; - createdTime: string; - updatedTime: string; +export interface UMPerpSettlementHistoryRequest { + category: UMCategory; + symbol?: string; + direction?: UMDirection; + limit?: number; + cursor?: string; } ⋮---- -export interface EventActiveOrdersResultV5 { - list: EventActiveOrderV5[]; - nextPageCursor: string; +export interface UMTransactionLogRequest { + category: UMCategory; + currency: string; + baseCoin?: string; + type?: string; + startTime?: number; + endTime?: number; + direction?: UMDirection; + limit?: number; + cursor?: string; } ⋮---- -export interface EventPositionV5 { - symbol: string; - baseCoin: string; - settleCoin: string; - side: string; - ecContractType: EventContractTypeV5 | string; - ecDirection: EventContractDirectionV5 | string; - avgPayoutRatio: string; - positionValue: string; - ecSettleTime: string; - cumClosedPnl: string; - createdTime: string; - updatedTime: string; - seq: number; +export interface UMExchangeCoinsRequest { + fromCoin?: string; + toCoin?: string; } ⋮---- -export interface EventPositionInfoResultV5 { - list: EventPositionV5[]; - nextPageCursor: string; +export interface UMBorrowHistoryRequest { + currency: string; + startTime?: number; + endTime?: number; + direction?: UMDirection; + limit?: number; + cursor?: string; } + +================ +File: src/types/request/usdc-options.ts +================ +import { OrderSide } from '../shared'; +import { USDCAPICategory, USDCOrderType, USDCTimeInForce } from './usdc-shared'; ⋮---- -export interface EventTradeV5 { - orderId: string; - orderLinkId: string; - execId: string; - symbol: string; - baseCoin: string; - settleCoin: string; - side: string; - execType: string; - execPrice: string; - execValue: string; - execFee: string; - execFeeRate: string; - orderPrice: string; - feeCoin: string; - transTime: string; - timeInForce: string; - crossSeq: string; - ecPayout: string; - ecDurationWindow: string; - settleTimeMs: string; - ecOrderValue: string; - ecContractType: EventContractTypeV5 | string; - ecDirection: EventContractDirectionV5 | string; - ecTargetPrice: string; - ecLowerBound: string; - ecUpperBound: string; - extraFees: string; +export interface USDCOptionsContractInfoRequest { + symbol?: string; + status?: 'WAITING_ONLINE' | 'ONLINE' | 'DELIVERING' | 'OFFLINE'; + baseCoin?: string; + direction?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface EventTradeHistoryResultV5 { - list: EventTradeV5[]; - cursor: string; +export interface USDCOptionsDeliveryPriceRequest { + symbol?: string; + baseCoin?: string; + direction?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface EventSettlementV5 { - transId: string; +export interface USDCOptionsRecentTradesRequest { + category: USDCAPICategory; + symbol?: string; + baseCoin?: string; + optionType?: 'Call' | 'Put'; + limit?: string; +} +⋮---- +export interface USDCOptionsHistoricalVolatilityRequest { + baseCoin?: string; + period?: string; + startTime?: string; + endTime?: string; +} +⋮---- +export interface USDCOptionsOrderRequest { symbol: string; - symbolId: string; - baseCoin: string; - settleCoin: string; - side: string; - ecContractType: EventContractTypeV5 | string; - ecDirection: EventContractDirectionV5 | string; - settlePrice: string; - entryPrice: string; - grossPayoutRatio: string; - ecDurationWindow: string; - ecTargetPrice: string; - ecLowerBound: string; - ecUpperBound: string; - transTime: string; - crossSeq: string; - execFee: string; - execFeeRate: string; - payout: string; - sessionRpl: string; - orderId: string; + orderType: USDCOrderType; + side: OrderSide; + orderPrice?: string; + orderQty: string; + iv?: string; + timeInForce?: USDCTimeInForce; + orderLinkId?: string; + reduceOnly?: boolean; } ⋮---- -export interface EventSettlementRecordsResultV5 { - list: EventSettlementV5[]; - cursor: string; +export interface USDCOptionsModifyOrderRequest { + symbol: string; + orderId?: string; + orderLinkId?: string; + orderPrice?: string; + orderQty?: string; + iv?: string; } ⋮---- -export interface EventQuoteResultV5 { - orderLinkId: string; - orderId: string; +export interface USDCOptionsCancelOrderRequest { + symbol: string; + orderId?: string; + orderLinkId?: string; } - -================ -File: src/types/response/v5-p2p-trading.ts -================ -import { P2PTradingPreferenceSetV5 } from '../request/v5-p2p-trading'; ⋮---- -export interface P2PCoinBalanceV5 { - coin: string; - transferBalance: string; - walletBalance: string; - bonus: string; +export interface USDCOptionsCancelAllOrdersRequest { + symbol?: string; + baseCoin?: string; } ⋮---- -export interface P2PAccountCoinsBalanceV5 { - memberId: string; - accountType: string; - balance: P2PCoinBalanceV5[]; +export interface USDCOptionsActiveOrdersRealtimeRequest { + orderId?: string; + orderLinkId?: string; + symbol?: string; + baseCoin?: string; + direction?: string; + limit?: number; + cursor?: string; } ⋮---- -export interface P2POnlineAdV5 { - id: string; - nickName: string; - tokenId: string; - currencyId: string; - side: string; - price: string; - lastQuantity: string; - minAmount: string; - maxAmount: string; - payments: string[]; - recentOrderNum: number; - recentExecuteRate: number; - isOnline: boolean; - authTag: string[]; - paymentPeriod: number; - accountId: number; - userId: number; - priceType: number; - premium: string; - quantity: string; - frozenQuantity: string; - executedQuantity: string; - remark: string; - status: number; - createDate: string; - orderNum: string; - finishNum: string; - fee: string; - lastLogoutTime: string; - blocked: string; - makerContact: boolean; - symbolInfo: { - id: string; - exchangeId: string; - orgId: string; - tokenId: string; - currencyId: string; - status: string; - lowerLimitAlarm: number; - upperLimitAlarm: number; - itemDownRange: string; - itemUpRange: string; - currencyMinQuote: string; - currencyMaxQuote: string; - currencyLowerMaxQuote: string; - tokenMinQuote: string; - tokenMaxQuote: string; - kycCurrencyLimit: string; - itemSideLimit: string; - buyFeeRate: string; - sellFeeRate: string; - orderAutoCancelMinute: number; - orderFinishMinute: number; - tradeSide: number; - currency: { - id: string; - exchangeId: string; - orgId: string; - currencyId: string; - scale: number; - }; - token: { - id: string; - exchangeId: string; - orgId: string; - tokenId: string; - scale: number; - sequence: number; - }; - buyAd: number; - sellAd: number; - }; - tradingPreferenceSet: { - hasUnPostAd: number; - isKyc: number; - isEmail: number; - isMobile: number; - hasRegisterTime: number; - registerTimeThreshold: number; - orderFinishNumberDay30: number; - completeRateDay30: number; - nationalLimit: number; - hasOrderFinishNumberDay30: number; - hasCompleteRateDay30: number; - hasNationalLimit: number; - }; - version: number; - authStatus: number; - recommend: boolean; - recommendTag: string; - userType: string; - itemType: string; -} -⋮---- -export interface P2POnlineAdsResponseV5 { - count: number; - items: P2POnlineAdV5[]; -} -⋮---- -export interface P2PCreateAdResponseV5 { - itemId: string; - securityRiskToken: string; - riskTokenType: string; - riskVersion: string; - needSecurityRisk: boolean; -} -⋮---- -export interface P2PPaymentTermV5 { - id: string; - realName: string; - paymentType: number; - bankName: string; - branchName: string; - accountNo: string; - qrcode: string; - visible: number; - payMessage: string; - firstName: string; - lastName: string; - secondLastName: string; - clabe: string; - debitCardNumber: string; - mobile: string; - businessName: string; - concept: string; - paymentExt1: string; - paymentExt2: string; - paymentExt3: string; - paymentExt4: string; - paymentExt5: string; - paymentExt6: string; - paymentTemplateVersion: number; - paymentConfig: { - paymentType: number; - paymentName: string; - paymentDialect: string; - }; - realNameVerified: boolean; -} -⋮---- -export interface P2PAdDetailV5 { - id: string; - accountId: string; - userId: string; - nickName: string; - tokenId: string; - tokenName: string; - currencyId: string; - side: number; - priceType: number; - price: string; - premium: string; - lastQuantity: string; - quantity: string; - frozenQuantity: string; - executedQuantity: string; - minAmount: string; - maxAmount: string; - remark: string; - status: number; - createDate: string; - payments: string[]; - orderNum: number; - finishNum: number; - recentOrderNum: number; - recentExecuteRate: number; - fee: string; - isOnline: boolean; - lastLogoutTime: string; - symbolInfo: { - id: string; - exchangeId: string; - orgId: string; - tokenId: string; - currencyId: string; - status: number; - lowerLimitAlarm: number; - upperLimitAlarm: number; - itemDownRange: string; - itemUpRange: string; - currencyMinQuote: string; - currencyMaxQuote: string; - currencyLowerMaxQuote: string; - tokenMinQuote: string; - tokenMaxQuote: string; - kycCurrencyLimit: string; - itemSideLimit: number; - buyFeeRate: string; - sellFeeRate: string; - orderAutoCancelMinute: number; - orderFinishMinute: number; - tradeSide: number; - currency: { - id: string; - exchangeId: string; - orgId: string; - currencyId: string; - scale: number; - }; - token: { - id: string; - exchangeId: string; - orgId: string; - tokenId: string; - scale: number; - sequence: number; - }; - buyAd: { - paymentPeriods: number[]; - }; - sellAd: { - paymentPeriods: number[]; - }; - }; - tradingPreferenceSet: P2PTradingPreferenceSetV5; - paymentTerms: P2PPaymentTermV5[]; - version: number; - updateDate: string; - feeRate: string; - paymentPeriod: number; - itemType: string; -} -⋮---- -export interface P2PPersonalAdsResponseV5 { - count: number; - items: P2PAdDetailV5[]; - hiddenFlag: boolean; +export interface USDCOptionsActiveOrdersRequest { + category: 'OPTION'; + symbol?: string; + baseCoin?: string; + orderId?: string; + orderLinkId?: string; + direction?: string; + limit?: number; + cursor?: string; } ⋮---- -export interface P2POrderExtensionV5 { - isDelayWithdraw: boolean; - delayTime: string; - startTime: string; +export interface USDCOptionsHistoricOrdersRequest { + category: 'OPTION'; + symbol?: string; + baseCoin?: string; + orderId?: string; + orderLinkId?: string; + orderStatus?: string; + direction?: string; + limit?: number; + cursor?: string; } ⋮---- -export interface P2POrderV5 { - id: string; - side: number; - tokenId: string; - orderType: string; - amount: string; - currencyId: string; - price: string; - notifyTokenQuantity?: string; - notifyTokenId?: string; - fee: string; - targetNickName: string; - targetUserId: string; - status: number; - selfUnreadMsgCount: string; - createDate: string; - transferLastSeconds: string; - appealLastSeconds: string; - userId: string; - sellerRealName: string; - buyerRealName: string; - judgeInfo: { - autoJudgeUnlockTime: string; - dissentResult: string; - preDissent: string; - postDissent: string; - }; - unreadMsgCount: string; - extension: P2POrderExtensionV5; - bulkOrderFlag: boolean; -} -⋮---- -export interface P2POrdersResponseV5 { - count: number; - items: P2POrderV5[]; -} -⋮---- -export interface P2PPaymentConfigItemV5 { - view: boolean; - name: string; - label: string; - placeholder: string; - type: string; - maxLength: string; - required: boolean; -} -⋮---- -export interface P2PPaymentConfigV5 { - paymentType: string; - checkType: number; - sort: number; - paymentName: string; - addTips: string; - itemTips: string; - online: number; - items: P2PPaymentConfigItemV5[]; -} -⋮---- -export interface P2PPaymentTermDetailV5 { - id: string; - realName: string; - paymentType: number; - bankName: string; - branchName: string; - accountNo: string; - qrcode: string; - visible: number; - payMessage: string; - firstName: string; - lastName: string; - secondLastName: string; - clabe: string; - debitCardNumber: string; - mobile: string; - businessName: string; - concept: string; - online: string; - paymentExt1: string; - paymentExt2: string; - paymentExt3: string; - paymentExt4: string; - paymentExt5: string; - paymentExt6: string; - paymentTemplateVersion: number; - paymentConfigVo: P2PPaymentConfigV5; - ruPaymentPrompt: boolean; -} -⋮---- -export interface P2PAppraiseInfoV5 { - anonymous: string; - appraiseContent: string; - appraiseId: string; - appraiseType: string; - modifyFlag: string; - updateDate: string; -} -⋮---- -export interface P2PJudgeInfoV5 { - autoJudgeUnlockTime: string; - dissentResult: string; - preDissent: string; - postDissent: string; -} -⋮---- -export interface P2POrderDetailV5 { - id: string; - side: number; - itemId: string; - accountId: string; - userId: string; - nickName: string; - makerUserId: string; - targetAccountId: string; - targetUserId: string; - targetNickName: string; - targetFirstName: string; - targetSecondName: string; - targetUserAuthStatus: number; - targetConnectInformation: string; - payerRealName: string; - sellerRealName: string; - buyerRealName: string; - tokenId: string; - tokenName: string; - currencyId: string; - price: string; - quantity: string; - amount: string; - payCode: string; - paymentType: number; - transferDate: string; - status: number; - createDate: string; - paymentTermList: P2PPaymentTermDetailV5[]; - remark: string; - transferLastSeconds: string; - recentOrderNum: number; - recentExecuteRate: number; - appealLastSeconds: string; - appealContent: string; - appealType: number; - appealNickName: string; - canAppeal: string; - totalAppealTimes: string; - appealedTimes: string; - paymentTermResult: P2PPaymentTermDetailV5; - orderFinishMinute: number; - confirmedPayTerm: P2PPaymentTermDetailV5; - makerFee: string; - takerFee: string; - fee: string; - showContact: boolean; - tokenBalance: string; - fiatBalance: string; - unreadMsgCount: string; - updateDate: string; - extension: P2POrderExtensionV5; - selfUnreadMsgCount: string; - judgeType: string; - canReport: boolean; - canReportDisagree: boolean; - canReportType: string[]; - canReportDisagreeType: string[]; - appraiseStatus: string; - appraiseInfo: P2PAppraiseInfoV5; - canReportDisagreeTypes: string[]; - canReportTypes: string[]; - orderType: string; - middleToken: string; - beforePrice: string; - beforeQuantity: string; - beforeToken: string; - alternative: string; - appealUserId: string; - notifyTokenId: string; - notifyTokenQuantity: string; - cancelResponsible: string; - chainType: string; - chainAddress: string; - tradeHashCode: string; - estimatedGasFee: string; - gasFeeTokenId: string; - tradingFeeTokenId: string; - onChainInfo: string; - transactionId: string; - displayRefund: string; - chainWithdrawLastSeconds: string; - chainTransferLastSeconds: string; - orderSource: string; - cancelReason: string; - sellerCancelExamineRemainTime: string; - needSellerExamineCancel: boolean; - couponCurrencyAmount: string; - totalCurrencyAmount: string; - usedCoupon: boolean; - couponTokenId: string; - couponQuantity: string; - completedOrderAppealCount: number; - totalCompletedOrderAppealCount: number; - realOrderStatus: number; - appealVersion: number; - judgeInfo: P2PJudgeInfoV5; - helpType: string; - appealFlowStatus: string; - appealSubStatus: string; - bulkOrderFlag: boolean; - targetUserType: string; - targetUserDisplays: string[]; - appealProcessChangeFlag: boolean; - appealNegotiationNode: number; -} -⋮---- -export interface P2POrderMessageV5 { - id: string; - message: string; - userId: string; - msgType: number; - msgCode: number; - createDate: string; - contentType: string; - orderId: string; - msgUuid: string; - nickName: string; - fileName: string; - accountId: string; - isRead: number; - read: number; - roleType: string; - onlyForCustomer: number; -} -⋮---- -export interface P2PUserInfoV5 { - nickName: string; - defaultNickName: boolean; - isOnline: boolean; - kycLevel: string; - email: string; - mobile: string; - lastLogoutTime: string; - recentRate: string; - totalFinishCount: number; - totalFinishSellCount: number; - totalFinishBuyCount: number; - recentFinishCount: number; - averageReleaseTime: string; - averageTransferTime: string; - accountCreateDays: number; - firstTradeDays: number; - realName: string; - recentTradeAmount: string; - totalTradeAmount: string; - registerTime: string; - authStatus: number; - kycCountryCode: string; - blocked: string; - goodAppraiseRate: string; - goodAppraiseCount: number; - badAppraiseCount: number; - accountId: number; - paymentCount: number; - contactCount: number; - vipLevel: number; - userCancelCountLimit: number; - paymentRealNameUneditable: boolean; - userId: string; - realNameEn: string; -} -⋮---- -export interface P2PCounterpartyUserInfoV5 { - nickName: string; - defaultNickName: boolean; - whiteFlag: number; - contactConfig: boolean; - isOnline: boolean; - email: string; - mobile: string; - kycLevel: number; - lastLogoutTime: string; - recentRate: number; - totalFinishCount: number; - totalFinishSellCount: number; - totalFinishBuyCount: number; - recentFinishCount: number; - averageReleaseTime: string; - averageTransferTime: string; - accountCreateDays: number; - firstTradeDays: number; - realName: string; - recentTradeAmount: string; - totalTradeAmount: string; - executeNum: number; - orderNum: number; - hasUnPostAd: number; - registerTime: string; - authStatus: number; - kycCountryCode: string; - blocked: string; - goodAppraiseRate: string; - goodAppraiseCount: number; - badAppraiseCount: number; - accountId: string; - paymentCount: number; - contactCount: number; - realNameMask: string; - vipLevel: number; - vipProfit: []; - userTag: []; - userCancelCountLimit: number; - paymentRealNameUneditable: boolean; - lostRoleAffected: boolean; - userCurPrivilege: string[]; - userType: string; - userId: string; - realNameEn: string; - canSubOnline: boolean; - curPrivilegeInfo: []; - openApiSwitch: number; -} -⋮---- -export interface P2PUserPaymentV5 { - id: string; - realName: string; - paymentType: string; - bankName: string; - branchName: string; - accountNo: string; - qrcode: string; - visible: number; - payMessage: string; - firstName: string; - lastName: string; - secondLastName: string; - clabe: string; - debitCardNumber: string; - mobile: string; - businessName: string; - concept: string; - online: string; - countNo: string; - paymentExt1: string; - paymentExt2: string; - paymentExt3: string; - paymentExt4: string; - paymentExt5: string; - paymentExt6: string; - paymentTemplateVersion: number; - hasPaymentTemplateChanged: boolean; - paymentConfigVo: P2PPaymentConfigV5; - realNameVerified: boolean; - channel: string; - currencyBalance: string[]; -} - -================ -File: src/types/response/v5-preupgrade.ts -================ -export interface PreUpgradeTransaction { - symbol: string; - category: string; - side: 'Buy' | 'Sell' | 'None'; - transactionTime: string; - type: string; - qty: string; - size: string; - currency: 'USDC' | 'USDT' | 'BTC' | 'ETH'; - tradePrice: string; - funding: string; - fee: string; - cashFlow: string; - change: string; - cashBalance: string; - feeRate: string; - bonusChange: string; - tradeId: string; - orderId: string; - orderLinkId: string; - extraFees: string; -} -⋮---- -export interface PreUpgradeOptionsDelivery { - deliveryTime: number; - symbol: string; - side: 'Buy' | 'Sell'; - position: string; - deliveryPrice: string; - strike: string; - fee: string; - deliveryRpl: string; -} -⋮---- -export interface PreUpgradeUSDCSessionSettlement { - symbol: string; - side: 'Buy' | 'Sell'; - size: string; - sessionAvgPrice: string; - markPrice: string; - realisedPnl: string; - createdTime: string; -} - -================ -File: src/types/websockets/index.ts -================ - - -================ -File: src/types/websockets/ws-api.ts -================ -import { APIID, WS_KEY_MAP } from '../../util'; -import { - AmendOrderParamsV5, - BatchAmendOrderParamsV5, - BatchCancelOrderParamsV5, - BatchOrderParamsV5, - CancelOrderParamsV5, - OrderParamsV5, -} from '../request'; -import { - BatchAmendOrderResultV5, - BatchCancelOrderResultV5, - BatchCreateOrderResultV5, - BatchOrdersRetExtInfoV5, - OrderResultV5, -} from '../response'; -import { WsKey } from './ws-general'; -⋮---- -// When new WS API operations are added, make sure to also update WS_API_Operations[] below -export type WSAPIOperation = - | 'order.create' - | 'order.amend' - | 'order.cancel' - | 'order.create-batch' - | 'order.amend-batch' - | 'order.cancel-batch'; -⋮---- -export type WsOperation = - | 'subscribe' - | 'unsubscribe' - | 'auth' - | 'ping' - | 'pong'; -⋮---- -export interface WsRequestOperationBybit { - req_id: string; - op: WsOperation; - args?: (TWSTopic | string | number)[]; -} -⋮---- -export interface WSAPIRequest< - TRequestParams = undefined, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - TWSOperation extends WSAPIOperation = any, -> { - reqId: string; - op: TWSOperation; - header: { - 'X-BAPI-TIMESTAMP': string; - 'X-BAPI-RECV-WINDOW': string; - Referer: typeof APIID; - }; - args: [TRequestParams]; -} -⋮---- -// eslint-disable-next-line @typescript-eslint/no-explicit-any -⋮---- -export interface WSAPIResponse< - TResponseData extends object = object, - TOperation extends WSAPIOperation = WSAPIOperation, - TResponseExtInfo = {}, // added as optional for batch calls -> { - wsKey: WsKey; - /** Auto-generated */ - reqId: string; - retCode: 0 | number; - retMsg: 'OK' | string; - op: TOperation; - data: TResponseData; - retExtInfo: TResponseExtInfo; - header?: { - 'X-Bapi-Limit': string; - 'X-Bapi-Limit-Status': string; - 'X-Bapi-Limit-Reset-Timestamp': string; - Traceid: string; - Timenow: string; - }; - connId: string; -} -⋮---- -TResponseExtInfo = {}, // added as optional for batch calls -⋮---- -/** Auto-generated */ -⋮---- -export type Exact = { - // This part says: if there's any key that's not in T, it's an error - [K: string]: never; -} & { - [K in keyof T]: T[K]; -}; -⋮---- -// This part says: if there's any key that's not in T, it's an error -⋮---- -/** - * List of operations supported for this WsKey (connection) - */ -export interface WsAPIWsKeyTopicMap { - [WS_KEY_MAP.v5PrivateTrade]: WSAPIOperation; -} -⋮---- -/** - * Request parameters expected per operation - */ -export interface WsAPITopicRequestParamMap { - 'order.create': OrderParamsV5; - 'order.amend': AmendOrderParamsV5; - 'order.cancel': CancelOrderParamsV5; - - 'order.create-batch': { - category: 'option' | 'linear'; - request: BatchOrderParamsV5[]; - }; - 'order.amend-batch': { - category: 'option' | 'linear'; - request: BatchAmendOrderParamsV5[]; - }; - 'order.cancel-batch': { - category: 'option' | 'linear'; - request: BatchCancelOrderParamsV5[]; - }; -} -⋮---- -/** - * Response structure expected for each operation - */ -export interface WsAPIOperationResponseMap { - 'order.create': WSAPIResponse; - 'order.amend': WSAPIResponse; - 'order.cancel': WSAPIResponse; - - 'order.create-batch': WSAPIResponse< - { list: BatchCreateOrderResultV5[] }, - 'order.create-batch' - > & { - retExtInfo: BatchOrdersRetExtInfoV5; - }; - 'order.amend-batch': WSAPIResponse< - { list: BatchAmendOrderResultV5[] }, - 'order.amend-batch' - > & { - retExtInfo: BatchOrdersRetExtInfoV5; - }; - 'order.cancel-batch': WSAPIResponse< - { list: BatchCancelOrderResultV5[] }, - 'order.cancel-batch' - > & { - retExtInfo: BatchOrdersRetExtInfoV5; - }; - - ping: { - retCode: 0 | number; - retMsg: 'OK' | string; - op: 'pong'; - data: [string]; - connId: string; - }; -} - -================ -File: src/types/websockets/ws-confirmations.ts -================ -export interface WebsocketTopicSubscriptionConfirmationEvent { - op: 'subscribe'; - req_id: string; - conn_id: string; - ret_msg: string; - success: boolean; -} -⋮---- -export interface WebsocketSucceededTopicSubscriptionConfirmationEvent - extends WebsocketTopicSubscriptionConfirmationEvent { - success: true; -} -⋮---- -export interface WebsocketFailedTopicSubscriptionConfirmationEvent - extends WebsocketTopicSubscriptionConfirmationEvent { - success: false; -} - -================ -File: src/types/index.ts -================ - - -================ -File: src/types/shared.ts -================ -import { RestClientV5 } from '../rest-client-v5'; -import { SpotClientV3 } from '../spot-client-v3'; -⋮---- -export type RESTClient = SpotClientV3 | RestClientV5; -⋮---- -export type numberInString = string; -⋮---- -export type OrderSide = 'Buy' | 'Sell'; -⋮---- -export type KlineInterval = - | '1m' - | '3m' - | '5m' - | '15m' - | '30m' - | '1h' - | '2h' - | '4h' - | '6h' - | '12h' - | '1d' - | '1w' - | '1M'; -⋮---- -export type KlineIntervalV3 = - | '1' - | '3' - | '5' - | '15' - | '30' - | '60' - | '120' - | '240' - | '360' - | '720' - | 'D' - | 'W' - | 'M'; -⋮---- -export interface APIRateLimit { - /** Remaining requests to this endpoint before the next reset */ - remainingRequests: number; - /** Max requests for this endpoint per rollowing window (before next reset) */ - maxRequests: number; - /** - * Timestamp when the rate limit resets if you have exceeded your current maxRequests. - * Otherwise, this is approximately your current timestamp. - */ - resetAtTimestamp: number; -} -⋮---- -/** Remaining requests to this endpoint before the next reset */ -⋮---- -/** Max requests for this endpoint per rollowing window (before next reset) */ -⋮---- -/** - * Timestamp when the rate limit resets if you have exceeded your current maxRequests. - * Otherwise, this is approximately your current timestamp. - */ -⋮---- -export interface APIResponseV3 { - retCode: number; - retMsg: 'OK' | string; - result: TResult; - retExtInfo: TExtInfo; - /** - * These are per-UID per-endpoint rate limits, automatically parsed from response headers if available. - * - * Note: - * - this is primarily for V5 (or newer) APIs. - * - these rate limits are per-endpoint per-account, so will not appear for public API calls - */ - rateLimitApi?: APIRateLimit; -} -⋮---- -/** - * These are per-UID per-endpoint rate limits, automatically parsed from response headers if available. - * - * Note: - * - this is primarily for V5 (or newer) APIs. - * - these rate limits are per-endpoint per-account, so will not appear for public API calls - */ -⋮---- -export type APIResponseV3WithTime = APIResponseV3< - TResult, - TExtInfo -> & { time: number }; -⋮---- -export interface APIP2PResponse { - ret_code: number; - ret_msg: string; - result: { - result: TResult; - totalRows: string; - totalPages: string; - currentPage: string; - dayLimit: string; - showDayLimit: boolean; - }; - ext_code: string; - ext_info: TExtInfo; - time_now: string; -} -⋮---- -/** - * Request Parameter Types - */ -export interface SymbolParam { - symbol: string; -} -⋮---- -export interface SymbolLimitParam { - symbol: string; - limit?: TLimit; -} -⋮---- -export interface SymbolPeriodLimitParam { - symbol: string; - period: string; - limit?: TLimit; -} -⋮---- -export interface SymbolFromLimitParam { - symbol: string; - from?: number; - limit?: number; -} -⋮---- -export interface SymbolIntervalFromLimitParam { - symbol: string; - interval: string; - from: number; - limit?: number; -} -⋮---- -export interface CoinParam { - coin: string; -} -⋮---- -export interface WalletFundRecordsReq { - start_date?: string; - end_date?: string; - currency?: string; - coin?: string; - wallet_fund_type?: string; - page?: number; - limit?: number; -} -⋮---- -export interface WithdrawRecordsReq { - start_date?: string; - end_date?: string; - coin?: string; - status?: string; - page?: number; - limit?: number; -} -⋮---- -export interface AssetExchangeRecordsReq { - limit?: number; - from?: number; - direction?: string; -} -⋮---- -/** - * Response types - */ -⋮---- -export interface LeverageFilter { - min_leverage: numberInString; - max_leverage: numberInString; - leverage_step: numberInString; -} -export interface PriceFilter { - min_price: numberInString; - max_price: numberInString; - tick_size: numberInString; -} -⋮---- -export interface LotSizeFilter { - max_trading_qty: number; - min_trading_qty: number; - qty_step: number; -} -⋮---- -export interface SymbolInfo { - name: string; - alias: string; - status: 'Trading' | string; - base_currency: string; - quote_currency: string; - price_scale: number; - taker_fee: numberInString; - maker_fee: numberInString; - leverage_filter: LeverageFilter; - price_filter: PriceFilter; - lot_size_filter: LotSizeFilter; -} - -================ -File: src/index.ts -================ - - -================ -File: src/spot-client-v3.ts -================ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import { APIResponseV3, numberInString } from './types'; -import { REST_CLIENT_TYPE_ENUM } from './util'; -import BaseRestClient from './util/BaseRestClient'; -⋮---- -/** - * REST API client for newer Spot V3 APIs. - * @deprecated WARNING - * These endpoints are being switched off gradually and are expected to be completely turned off by the end of 2024. - * They may stop working at any point before then. - * Please update your code as soon as possible to use the V5 APIs instead. - */ -export class SpotClientV3 extends BaseRestClient -⋮---- -getClientType() -⋮---- -// Doesn't really matter here, since the only remaining endpoint does not require auth. -⋮---- -async fetchServerTime(): Promise -⋮---- -/** - * - * Market Data Endpoints - * - */ -⋮---- -/** - * Get merged orderbook for symbol - * - * This is the only known pre-V5 endpoint to still be online. - */ -getMergedOrderBook( - symbol: string, - scale?: number, - limit?: number, -): Promise> -⋮---- -/** - * - * API Data Endpoints - * - */ -⋮---- -getServerTime(): Promise< - -================ -File: src/websocket-api-client.ts -================ -import { - AmendOrderParamsV5, - BatchAmendOrderParamsV5, - BatchAmendOrderResultV5, - BatchCancelOrderParamsV5, - BatchCancelOrderResultV5, - BatchCreateOrderResultV5, - BatchOrderParamsV5, - BatchOrdersRetExtInfoV5, - CancelOrderParamsV5, - OrderParamsV5, - OrderResultV5, -} from './types'; -import { WSAPIResponse } from './types/websockets/ws-api'; -import { WSClientConfigurableOptions } from './types/websockets/ws-general'; -import { DefaultLogger } from './util'; -import { WS_KEY_MAP } from './util/websockets/websocket-util'; -import { WebsocketClient } from './websocket-client'; -⋮---- -/** - * Configurable options specific to only the REST-like WebsocketAPIClient - */ -export interface WSAPIClientConfigurableOptions { - /** - * Default: true - * - * Attach default event listeners, which will console log any high level - * events (opened/reconnecting/reconnected/etc). - * - * If you disable this, you should set your own event listeners - * on the embedded WS Client `wsApiClient.getWSClient().on(....)`. - */ - attachEventListeners: boolean; -} -⋮---- -/** - * Default: true - * - * Attach default event listeners, which will console log any high level - * events (opened/reconnecting/reconnected/etc). - * - * If you disable this, you should set your own event listeners - * on the embedded WS Client `wsApiClient.getWSClient().on(....)`. - */ -⋮---- -/** - * This is a minimal Websocket API wrapper around the WebsocketClient. - * - * Some methods support passing in a custom "wsKey". This is a reference to which WS connection should - * be used to transmit that message. This is only useful if you wish to use an alternative wss - * domain that is supported by the SDK. - * - * Note: To use testnet, don't set the wsKey - use `testnet: true` in - * the constructor instead. - * - * Note: You can also directly use the sendWSAPIRequest() method to make WS API calls, but some - * may find the below methods slightly more intuitive. - * - * Refer to the WS API promises example for a more detailed example on using sendWSAPIRequest() directly: - * https://github.com/tiagosiebler/bybit-api/blob/master/examples/ws-api-raw-promises.ts - */ -export class WebsocketAPIClient -⋮---- -constructor( - options?: WSClientConfigurableOptions & - Partial, - logger?: DefaultLogger, -) -⋮---- -public getWSClient(): WebsocketClient -⋮---- -public setTimeOffsetMs(newOffset: number): void -⋮---- -/* - * Bybit WebSocket API Methods - * https://bybit-exchange.github.io/docs/v5/websocket/trade/guideline - */ -⋮---- -/** - * Submit a new order - * - * @param params - * @returns - */ -submitNewOrder( - params: OrderParamsV5, -): Promise> -⋮---- -/** - * Amend an order - * - * @param params - * @returns - */ -amendOrder( - params: AmendOrderParamsV5, -): Promise> -⋮---- -/** - * Cancel an order - * - * @param params - * @returns - */ -cancelOrder( - params: CancelOrderParamsV5, -): Promise> -⋮---- -/** - * Batch submit orders - * - * @param params - * @returns - */ -batchSubmitOrders( - category: 'option' | 'linear', - orders: BatchOrderParamsV5[], - ): Promise< - WSAPIResponse< - { - list: BatchCreateOrderResultV5[]; - }, - 'order.create-batch', - BatchOrdersRetExtInfoV5 - > - > { - return this.wsClient.sendWSAPIRequest( - WS_KEY_MAP.v5PrivateTrade, - 'order.create-batch', - { - category, - request: orders, - }, - ); -⋮---- -/** - * Batch amend orders - * - * @param params - * @returns - */ -batchAmendOrder( - category: 'option' | 'linear', - orders: BatchAmendOrderParamsV5[], - ): Promise< - WSAPIResponse< - { - list: BatchAmendOrderResultV5[]; - }, - 'order.amend-batch', - BatchOrdersRetExtInfoV5 - > - > { - return this.wsClient.sendWSAPIRequest( - WS_KEY_MAP.v5PrivateTrade, - 'order.amend-batch', - { - category, - request: orders, - }, - ); -⋮---- -/** - * Batch cancel orders - * - * @param params - * @returns - */ -batchCancelOrder( - category: 'option' | 'linear', - orders: BatchCancelOrderParamsV5[], - ): Promise< - WSAPIResponse< - { - list: BatchCancelOrderResultV5[]; - }, - 'order.cancel-batch', - BatchOrdersRetExtInfoV5 - > - > { - return this.wsClient.sendWSAPIRequest( - WS_KEY_MAP.v5PrivateTrade, - 'order.cancel-batch', - { - category, - request: orders, - }, - ); -⋮---- -/** - * - * - * - * - * - * - * - * Private methods for handling some of the convenience/automation provided by the WS API Client - * - * - * - * - * - * - * - */ -⋮---- -private setupDefaultEventListeners() -⋮---- -/** - * General event handlers for monitoring the WebsocketClient - */ -⋮---- -// Blind JSON.stringify can fail on circular references -⋮---- -// JSON.stringify({ ...data, target: 'WebSocket' }), - -================ -File: .eslintrc.cjs -================ -// 'require-extensions', // only once moved to ESM +export interface USDCOptionsOrderExecutionRequest { + category: 'OPTION'; + symbol?: string; + baseCoin?: string; + orderId?: string; + orderLinkId?: string; + startTime?: string; + direction?: string; + limit?: number; + cursor?: string; +} ⋮---- -// 'plugin:require-extensions/recommended', // only once moved to ESM +export interface USDCOptionsDeliveryHistoryRequest { + symbol: string; + expDate?: string; + direction?: string; + limit?: string; + cursor?: string; +} ⋮---- -// 'no-unused-vars': ['warn'], - -================ -File: .jshintrc -================ -{ - "esversion": 8, - "asi": true, - "laxbreak": true, - "predef": [ "-Promise" ] +export interface USDCOptionsPositionsInfoExpiryRequest { + expDate?: string; + direction?: string; + limit?: string; + cursor?: string; } - -================ -File: .prettierrc -================ -{ - "tabWidth": 2, - "singleQuote": true, - "trailingComma": "all" +⋮---- +export interface USDCOptionsModifyMMPRequest { + currency: string; + windowMs: number; + frozenPeriodMs: number; + qtyLimit: string; + deltaLimit: string; } ================ -File: index.js -================ - - -================ -File: jest.config.ts +File: src/types/request/usdc-perp.ts ================ -/** - * For a detailed explanation regarding each configuration property, visit: - * https://jestjs.io/docs/configuration - */ -⋮---- -import type { Config } from 'jest'; -⋮---- -// All imported modules in your tests should be mocked automatically -// automock: false, -⋮---- -// Stop running tests after `n` failures -// bail: 0, -bail: false, // enable to stop test when an error occur, -⋮---- -// The directory where Jest should store its cached dependency information -// cacheDirectory: "/private/var/folders/kf/2k3sz4px6c9cbyzj1h_b192h0000gn/T/jest_dx", -⋮---- -// Automatically clear mock calls, instances, contexts and results before every test -⋮---- -// Indicates whether the coverage information should be collected while executing the test -⋮---- -// An array of glob patterns indicating a set of files for which coverage information should be collected -⋮---- -// The directory where Jest should output its coverage files -⋮---- -// An array of regexp pattern strings used to skip coverage collection -// coveragePathIgnorePatterns: [ -// "/node_modules/" -// ], -⋮---- -// Indicates which provider should be used to instrument code for coverage -⋮---- -// A list of reporter names that Jest uses when writing coverage reports -// coverageReporters: [ -// "json", -// "text", -// "lcov", -// "clover" -// ], -⋮---- -// An object that configures minimum threshold enforcement for coverage results -// coverageThreshold: undefined, -⋮---- -// A path to a custom dependency extractor -// dependencyExtractor: undefined, -⋮---- -// Make calling deprecated APIs throw helpful error messages -// errorOnDeprecated: false, -⋮---- -// The default configuration for fake timers -// fakeTimers: { -// "enableGlobally": false -// }, -⋮---- -// Force coverage collection from ignored files using an array of glob patterns -// forceCoverageMatch: [], -⋮---- -// A path to a module which exports an async function that is triggered once before all test suites -// globalSetup: undefined, -⋮---- -// A path to a module which exports an async function that is triggered once after all test suites -// globalTeardown: undefined, -⋮---- -// A set of global variables that need to be available in all test environments -// globals: {}, -⋮---- -// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. -// maxWorkers: "50%", -⋮---- -// An array of directory names to be searched recursively up from the requiring module's location -// moduleDirectories: [ -// "node_modules" -// ], -⋮---- -// An array of file extensions your modules use -// moduleFileExtensions: [ -// "js", -// "mjs", -// "cjs", -// "jsx", -// "ts", -// "tsx", -// "json", -// "node" -// ], -⋮---- -// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module -// moduleNameMapper: {}, -⋮---- -// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader -// modulePathIgnorePatterns: [], -⋮---- -// Activates notifications for test results -// notify: false, -⋮---- -// An enum that specifies notification mode. Requires { notify: true } -// notifyMode: "failure-change", -⋮---- -// A preset that is used as a base for Jest's configuration -// preset: undefined, -⋮---- -// Run tests from one or more projects -// projects: undefined, -⋮---- -// Use this configuration option to add custom reporters to Jest -// reporters: undefined, -⋮---- -// Automatically reset mock state before every test -// resetMocks: false, -⋮---- -// Reset the module registry before running each individual test -// resetModules: false, -⋮---- -// A path to a custom resolver -// resolver: undefined, -⋮---- -// Automatically restore mock state and implementation before every test -// restoreMocks: false, -⋮---- -// The root directory that Jest should scan for tests and modules within -// rootDir: undefined, -⋮---- -// A list of paths to directories that Jest should use to search for files in -// roots: [ -// "" -// ], -⋮---- -// Allows you to use a custom runner instead of Jest's default test runner -// runner: "jest-runner", -⋮---- -// The paths to modules that run some code to configure or set up the testing environment before each test -// setupFiles: [], -⋮---- -// A list of paths to modules that run some code to configure or set up the testing framework before each test -// setupFilesAfterEnv: [], -⋮---- -// The number of seconds after which a test is considered as slow and reported as such in the results. -// slowTestThreshold: 5, -⋮---- -// A list of paths to snapshot serializer modules Jest should use for snapshot testing -// snapshotSerializers: [], -⋮---- -// The test environment that will be used for testing -// testEnvironment: "jest-environment-node", +import { OrderSide } from '../shared'; +import { + USDCAPICategory, + USDCOrderFilter, + USDCOrderType, + USDCTimeInForce, +} from './usdc-shared'; ⋮---- -// Options that will be passed to the testEnvironment -// testEnvironmentOptions: {}, +export interface USDCOpenInterestRequest { + symbol: string; + period: string; + limit?: number; +} ⋮---- -// Adds a location field to test results -// testLocationInResults: false, +export interface USDCLast500TradesRequest { + category: USDCAPICategory; + symbol?: string; + baseCoin?: string; + limit?: string; +} ⋮---- -// The glob patterns Jest uses to detect test files +export interface USDCSymbolDirectionLimit { + symbol?: string; + direction?: string; + limit?: string; +} ⋮---- -// "**/__tests__/**/*.[jt]s?(x)", +export interface USDCSymbolDirectionLimitCursor { + symbol?: string; + direction?: string; + limit?: string; + cursor?: string; +} ⋮---- -// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped -// testPathIgnorePatterns: [ -// "/node_modules/" -// ], +export interface USDCPerpOrderRequest { + symbol: string; + orderType: USDCOrderType; + orderFilter: USDCOrderFilter; + side: OrderSide; + orderPrice?: string; + orderQty: string; + timeInForce?: USDCTimeInForce; + orderLinkId?: string; + reduceOnly?: boolean; + closeOnTrigger?: boolean; + takeProfit?: string; + stopLoss?: string; + tptriggerby?: string; + slTriggerBy?: string; + basePrice?: string; + triggerPrice?: string; + triggerBy?: string; + mmp?: boolean; +} ⋮---- -// The regexp pattern or array of patterns that Jest uses to detect test files -// testRegex: [], +export interface USDCPerpModifyOrderRequest { + symbol: string; + orderFilter: USDCOrderFilter; + orderId?: string; + orderLinkId?: string; + orderPrice?: string; + orderQty?: string; + takeProfit?: string; + stopLoss?: string; + tptriggerby?: string; + slTriggerBy?: string; + triggerPrice?: string; +} ⋮---- -// This option allows the use of a custom results processor -// testResultsProcessor: undefined, +export interface USDCPerpCancelOrderRequest { + symbol: string; + orderFilter: USDCOrderFilter; + orderId?: string; + orderLinkId?: string; +} ⋮---- -// This option allows use of a custom test runner -// testRunner: "jest-circus/runner", +export interface USDCPerpActiveOrdersRequest { + category: 'PERPETUAL'; + symbol?: string; + baseCoin?: string; + orderId?: string; + orderLinkId?: string; + orderFilter?: USDCOrderFilter; + direction?: string; + limit?: number; + cursor?: string; +} ⋮---- -// A map from regular expressions to paths to transformers -// transform: undefined, +export interface USDCPerpHistoricOrdersRequest { + category: 'PERPETUAL'; + symbol?: string; + baseCoin?: string; + orderId?: string; + orderLinkId?: string; + orderStatus?: string; + orderFilter?: USDCOrderFilter; + direction?: string; + limit?: number; + cursor?: string; +} + +================ +File: src/types/request/usdc-shared.ts +================ +export type USDCAPICategory = 'PERPETUAL' | 'OPTION'; ⋮---- -// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation -// transformIgnorePatterns: [ -// "/node_modules/", -// "\\.pnp\\.[^\\/]+$" -// ], +export type USDCOrderType = 'Limit' | 'Market'; ⋮---- -// Prevents import esm module error from v1 axios release, issue #5026 +export type USDCTimeInForce = + | 'GoodTillCancel' + | 'ImmediateOrCancel' + | 'FillOrKill' + | 'PostOnly'; ⋮---- -// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them -// unmockedModulePathPatterns: undefined, +export type USDCOrderFilter = 'Order' | 'StopOrder'; ⋮---- -// Indicates whether each individual test should be reported during the run -// verbose: undefined, -verbose: true, // report individual test +export interface USDCKlineRequest { + symbol: string; + period: string; + startTime: number; + limit?: string; +} ⋮---- -// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode -// watchPathIgnorePatterns: [], +export interface USDCTransactionLogRequest { + type: string; + baseCoin?: string; + startTime?: string; + endTime?: string; + direction?: string; + limit?: string; + cursor?: string; + category?: USDCAPICategory; +} ⋮---- -// Whether to use watchman for file crawling -// watchman: true, - -================ -File: jsconfig.json -================ -{ - "compilerOptions": { - "target": "ES6", - "module": "commonjs" - }, - "exclude": [ - "node_modules", - "**/node_modules/*", - "coverage", - "doc", - "examples/ignored/*" - ] +export interface USDCPositionsRequest { + category: USDCAPICategory; + symbol?: string; + baseCoin?: string; + expDate?: string; + direction?: string; + limit?: string; + cursor?: string; } ================ -File: LICENSE.md -================ -Copyright 2024 Tiago Siebler - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -================ -File: tsconfig.build.json +File: src/types/request/v5-pre-upgrade.ts ================ -{ - "extends": "./tsconfig.json", - "exclude": [ - "node_modules", - "test", - "dist", - "**/*spec.ts", - "**/*test.ts", - "jest.config.ts" - ] +import { ExecTypeV5 } from '../shared-v5'; +⋮---- +export interface GetPreUpgradeOrderHistoryParamsV5 { + category: 'linear' | 'inverse'; + symbol?: string; + baseCoin?: string; + orderId?: string; + orderLinkId?: string; + orderFilter?: 'Order' | 'StopOrder'; + orderStatus?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; } - -================ -File: tsconfig.examples.json -================ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "distExamples", - "allowJs": true - }, - "include": ["examples/**/*.ts", "examples/**/*.js"] +⋮---- +export interface GetPreUpgradeTradeHistoryParamsV5 { + category: 'linear' | 'inverse'; + symbol?: string; + orderId?: string; + orderLinkId?: string; + baseCoin?: string; + startTime?: number; + endTime?: number; + execType?: ExecTypeV5; + limit?: number; + cursor?: string; } - -================ -File: tsconfig.json -================ -{ - "compileOnSave": true, - "compilerOptions": { - "allowJs": true, - "target": "es6", - "module": "commonjs", - "moduleResolution": "node", - "declaration": true, - "removeComments": false, - "noEmitOnError": true, - "noImplicitAny": false, - "strictNullChecks": true, - "skipLibCheck": true, - "sourceMap": true, - "esModuleInterop": true, - "lib": ["es2017", "dom"], - "baseUrl": ".", - "outDir": "./lib" - }, - "include": ["src/**/*"], - "exclude": ["node_modules", "**/node_modules/*", "coverage", "doc"] +⋮---- +export interface GetPreUpgradeClosedPnlParamsV5 { + category: 'linear' | 'inverse'; + symbol: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; +} +⋮---- +export interface GetPreUpgradeTransactionLogParamsV5 { + category: 'linear' | 'option'; + baseCoin?: string; + type?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; +} +⋮---- +export interface GetPreUpgradeOptionDeliveryRecordParamsV5 { + category: 'option'; + symbol?: string; + expDate?: string; + limit?: number; + cursor?: string; +} +⋮---- +export interface GetPreUpgradeUSDCSessionParamsV5 { + category: 'linear'; + symbol?: string; + limit?: number; + cursor?: string; } ================ -File: tsconfig.linting.json +File: src/types/request/v5-tax.ts ================ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "target": "esnext", - "rootDir": "../", - "allowJs": true - }, - "include": [ - "src/**/*.*", - "test/**/*.*", - "examples/**/*.*", - ".eslintrc.cjs", - "jest.config.ts" - ] +export type TaxReportTypeV5 = + | 'ALL' + | 'TRADE' + | 'P&L' + | 'EARN' + | 'DEPOSIT&WITHDRAWAL' + | 'BONUS' + | 'AIRDROP' + | 'CARD'; +⋮---- +export interface TaxBatchExportItemV5 { + type: TaxReportTypeV5; + /** Subcategory number. Required but ignored when type is ALL; pass "". */ + number: string; +} +⋮---- +/** Subcategory number. Required but ignored when type is ALL; pass "". */ +⋮---- +/** POST /v5/fht/compliance/tax/private/batch_create */ +export interface CreateTaxBatchExportParamsV5 { + /** UNIX seconds. Must be within the last 18 months. */ + startTime: number; + /** UNIX seconds. Later than startTime, span at most 12 months. */ + endTime: number; + items: TaxBatchExportItemV5[]; + sourceInstitution?: string; + /** orc is the default when omitted */ + exportFileType?: 'orc' | 'csv'; } - -================ -File: tsconfig.test.json -================ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./distTest", - "allowJs": true - }, - "include": ["test/**/*.ts", "test/**/*.js"] +⋮---- +/** UNIX seconds. Must be within the last 18 months. */ +⋮---- +/** UNIX seconds. Later than startTime, span at most 12 months. */ +⋮---- +/** orc is the default when omitted */ +⋮---- +/** GET /v5/fht/compliance/tax/private/batch_query */ +export interface GetTaxBatchExportParamsV5 { + batchId: string; } ================ -File: examples/Auth/fasterHmacSign.ts +File: src/types/response/account-asset.ts ================ -import { createHmac } from 'crypto'; +export interface UniversalTransferCreateResponse { + transferId: string; +} ⋮---- -import { DefaultLogger, RestClientV5, WebsocketClient } from '../../src/index'; +export interface UniversalTransferListResponseV3 { + list: { + transferId: string; + coin: string; + amount: string; + timestamp: string; + status: string; + fromAccountType: string; + toAccountType: string; + fromMemberId: string; + toMemberId: string; + }[]; + nextPageCursor: string; +} ⋮---- -// or -// import { createHmac } from 'crypto'; -// import { DefaultLogger, RestClientV5, WebsocketClient } from 'bybit-api'; +export interface QueryInternalTransferSResponseV3 { + list: { + transferId: string; + coin: string; + amount: string; + fromAccountType: string; + toAccountType: string; + timestamp: string; + status: string; + }[]; + nextPageCursor: string; +} ⋮---- -/** - * Injecting a custom signMessage function. - * - * As of version 4.0.0 of the bybit-api Node.js/TypeScript/JavaScript - * SDK for Bybit, the SDK uses the Web Crypto API for signing requests. - * While it is compatible with Node and Browser environments, it is - * slightly slower than using Node's native crypto module (only - * available in backend Node environments). - * - * For latency sensitive users, you can inject the previous node crypto sign - * method (or your own even faster-implementation), if this change affects you. - * - * This example demonstrates how to inject a custom sign function, to achieve - * the same peformance as seen before the Web Crypto API was introduced. - * - * For context on standard usage, the "signMessage" function is used: - * - During every single API call - * - After opening a new private WebSocket connection - * - */ +export interface SubAccountTransferResponseV3 { + list: { + transferId: string; + coin: string; + amount: string; + memberId: number; + subMemberId: number; + timestamp: string; + status: string; + type: 'IN' | 'OUT'; + }[]; + nextPageCursor: string; +} ⋮---- -/** - * Set this to true to enable demo trading: - */ +export interface AccountCoinBalanceResponseV3 { + accountType: string; + bizType: number; + accountId: string; + memberId: string; + balance: { + coin: string; + walletBalance: string; + transferBalance: string; + bonus: string; + }; +} ⋮---- -/** - * Overkill in almost every case, but if you need any optimisation available, - * you can inject a faster sign mechanism such as node's native createHmac: - */ +export interface AccountCoinBalancesResponseV3 { + accountType: string; + memberId: string; + balance: { + coin: string; + walletBalance: string; + transferBalance: string; + bonus: string; + }[]; +} ⋮---- -// Optional, uncomment the "trace" override to log a lot more info about what the WS client is doing +export interface AssetInfoResponseV3 { + spot: { + status: 'ACCOUNT_STATUS_NORMAL' | 'ACCOUNT_STATUS_UNSPECIFIED'; + assets: { + coin: string; + frozen: string; + free: string; + withdraw: string; + }[]; + }; +} ⋮---- -// trace: (...params) => console.log('trace', ...params), +interface SupportedDepositV3 { + coin: string; + chain: string; + coinShowName: string; + chainType: string; + blockConfirmNumber: number; + minDepositAmount: string; +} ⋮---- -/** - * Set this to true to enable demo trading for the private account data WS - * Topics: order,execution,position,wallet,greeks - */ +export interface SupportedDepositListResponseV3 { + configList: SupportedDepositV3[]; + nextPageCursor: string; +} ⋮---- -/** - * Overkill in almost every case, but if you need any optimisation available, - * you can inject a faster sign mechanism such as node's native createHmac: - */ +interface DepositRecordV3 { + coin: string; + chain: string; + amount: string; + txID: string; + status: number; + toAddress: string; + tag: string; + depositFee: string; + successAt: string; + confirmations: string; + txIndex: string; + blockHash: string; +} ⋮---- -function setWsClientEventListeners( - websocketClient: WebsocketClient, - accountRef: string, -): Promise +export interface DepositRecordQueryResponseV3 { + rows: DepositRecordV3[]; + nextPageCursor: string; +} ⋮---- -// console.log('raw message received ', JSON.stringify(data, null, 2)); +export interface WithdrawRecordsQueryResponseV3 { + rows: { + coin: string; + chain: string; + amount: string; + txID: string; + status: number; + toAddress: string; + tag: string; + withdrawFee: string; + createTime: string; + updateTime: string; + withdrawId: string; + withdrawType: number; + }[]; + nextPageCursor: string; +} ⋮---- -// Simple promise to ensure we're subscribed before trying anything else +export interface CoinInfoV3 { + name: string; + coin: string; + remainAmount: string; + chains: { + chainType: string; + confirmation: string; + withdrawFee: string; + depositMin: string; + withdrawMin: string; + chain: string; + chainDeposit: string; + chainWithdraw: string; + minAccuracy: string; + }[]; +} ⋮---- -// Start trading +export interface CoinInfoQueryResponseV3 { + rows: CoinInfoV3[]; +} +⋮---- +export interface DepositAddressChainV3 { + chainType: string; + addressDeposit: string; + tagDeposit: string; + chain: string; +} +⋮---- +export interface DepositAddressResponseV3 { + coin: string; + chains: DepositAddressChainV3[]; +} +⋮---- +export interface CreateSubMemberResponseV3 { + uid: number; + username: string; + memberType: 1 | 6; + switch: 0 | 1; + note: string; +} +⋮---- +export interface CreateSubAPIKeyResponseV3 { + id: string; + note: string; + apiKey: string; + readOnly: string; + secret: string; + permissions: { + ContractTrade: string[]; + Spot: string[]; + Wallet: string[]; + Options: string[]; + Derivatives: string[]; + CopyTrading: string[]; + BlockTrade: string[]; + Exchange: string[]; + NFT: string[]; + }; +} +⋮---- +export interface SubMemberV3 { + uid: string; + username: string; + memberType: 1 | 6; + status: 1 | 2 | 4; + remark: string; +} ⋮---- -/** Simple examples for private REST API calls with bybit's V5 REST APIs */ +export interface SubMemberResponseV3 { + subMembers: SubMemberV3[]; +} ⋮---- -// Trade USDT linear perps +export interface APIKeyInfoV3 { + id: string; + note: string; + apiKey: string; + readOnly: string; + secret: string; + permissions: { + ContractTrade: string[]; + Spot: string[]; + Wallet: string[]; + Options: string[]; + Derivatives: string[]; + CopyTrading: string[]; + BlockTrade: string[]; + Exchange: string[]; + NFT: string[]; + }; + ips: string[]; + type: number; + deadlineDay: number; + expiredAt: string; + createdAt: string; + unified: number; + uta: number; + userID: number; + inviterID: number; + vipLevel: string; + mktMakerLevel: string; + affiliateID: number; +} ================ -File: examples/Rest/demo-trading.ts +File: src/types/response/shared.ts ================ -import { DefaultLogger, RestClientV5, WebsocketClient } from '../../src/index'; +export interface SymbolWalletBalance { + equity: number; + available_balance: number; + used_margin: number; + order_margin: number; + position_margin: number; + occ_closing_fee: number; + occ_funding_fee: number; + wallet_balance: number; + realised_pnl: number; + unrealised_pnl: number; + cum_realised_pnl: number; + given_cash: number; + service_cash: number; +} ⋮---- -// or -// import { RestClientV5 } from 'bybit-api'; +export interface WalletBalances { + [symbol: string]: SymbolWalletBalance | undefined; +} + +================ +File: src/types/response/spot.ts +================ +export interface SpotBalance { + coin: string; + coinId: string; + coinName: string; + total: string; + free: string; + locked: string; +} ⋮---- -/** - * - * - * This example demonstrates how to use Bybit's demo trading functionality, both for REST and WS. - * - * Refer to the API docs for more information: https://bybit-exchange.github.io/docs/v5/demo - * - * - */ +export interface SpotBalances { + balances: SpotBalance[]; +} ⋮---- -/** - * Set this to true to enable demo trading: - */ +export interface SpotLastPrice { + symbol: string; + price: string; +} + +================ +File: src/types/response/unified-margin.ts +================ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export interface UMPaginatedResult { + nextPageCursor: string; + category: string; + list: List[]; +} ⋮---- -// Optional, uncomment the "trace" override to log a lot more info about what the WS client is doing +export interface UMLeverageFilter { + minLeverage: string; + maxLeverage: string; + leverageStep: string; +} ⋮---- -// trace: (...params) => console.log('trace', ...params), +export interface UMPriceFilter { + minPrice: string; + maxPrice: string; + tickSize: string; +} ⋮---- -/** - * Set this to true to enable demo trading for the private account data WS - * Topics: order,execution,position,wallet,greeks - */ +export interface UMLotSizeFilter { + maxTradingQty: string; + minTradingQty: string; + qtyStep: string; +} ⋮---- -function setWsClientEventListeners( - websocketClient: WebsocketClient, - accountRef: string, -): Promise +export interface UMInstrumentInfo { + symbol: string; + contractType: string; + status: string; + baseCoin: string; + quoteCoin: string; + launchTime: string; + deliveryTime: string; + deliveryFeeRate: string; + priceScale: string; + leverageFilter: UMLeverageFilter; + priceFilter: UMPriceFilter; + lotSizeFilter: UMLotSizeFilter; +} ⋮---- -// console.log('raw message received ', JSON.stringify(data, null, 2)); +export interface UMHistoricOrder { + symbol: string; + orderType: string; + orderLinkId: string; + orderId: string; + stopOrderType: string; + orderStatus: string; + takeProfit: string; + cumExecValue: string; + blockTradeId: string; + rejectReason: string; + price: string; + createdTime: number; + tpTriggerBy: string; + timeInForce: string; + basePrice: string; + leavesValue: string; + updatedTime: number; + side: string; + triggerPrice: string; + cumExecFee: string; + slTriggerBy: string; + leavesQty: string; + closeOnTrigger: boolean; + cumExecQty: string; + reduceOnly: boolean; + qty: string; + stopLoss: string; + triggerBy: string; + orderIM: string; +} + +================ +File: src/types/response/usdt-perp.ts +================ +export interface PerpPosition { + user_id: number; + symbol: string; + side: string; + size: number; + position_value: number; + entry_price: number; + liq_price: number; + bust_price: number; + leverage: number; + auto_add_margin: number; + is_isolated: boolean; + position_margin: number; + occ_closing_fee: number; + realised_pnl: number; + cum_realised_pnl: number; + free_qty: number; + tp_sl_mode: string; + unrealised_pnl: number; + deleverage_indicator: number; + risk_id: number; + stop_loss: number; + take_profit: number; + trailing_stop: number; + position_idx: number; + mode: string; +} ⋮---- -// Simple promise to ensure we're subscribed before trying anything else +export interface PerpPositionRoot { + data: PerpPosition; + is_valid: boolean; +} ⋮---- -// Start trading +export interface LinearOrder { + order_id: string; + user_id: number; + symbol: string; + side: string; + order_type: string; + price: number; + qty: number; + time_in_force: string; + order_status: string; + last_exec_price: number; + cum_exec_qty: number; + cum_exec_value: number; + cum_exec_fee: number; + reduce_only: boolean; + close_on_trigger: boolean; + order_link_id: string; + created_time: string; + updated_time: string; + take_profit: number; + stop_loss: number; + tp_trigger_by: string; + sl_trigger_by: string; + position_idx: number; +} + +================ +File: src/types/response/v5-preupgrade.ts +================ +export interface PreUpgradeTransaction { + symbol: string; + category: string; + side: 'Buy' | 'Sell' | 'None'; + transactionTime: string; + type: string; + qty: string; + size: string; + currency: 'USDC' | 'USDT' | 'BTC' | 'ETH'; + tradePrice: string; + funding: string; + fee: string; + cashFlow: string; + change: string; + cashBalance: string; + feeRate: string; + bonusChange: string; + tradeId: string; + orderId: string; + orderLinkId: string; + extraFees: string; +} ⋮---- -/** Simple examples for private REST API calls with bybit's V5 REST APIs */ +export interface PreUpgradeOptionsDelivery { + deliveryTime: number; + symbol: string; + side: 'Buy' | 'Sell'; + position: string; + deliveryPrice: string; + strike: string; + fee: string; + deliveryRpl: string; +} ⋮---- -// Trade USDT linear perps +export interface PreUpgradeUSDCSessionSettlement { + symbol: string; + side: 'Buy' | 'Sell'; + size: string; + sessionAvgPrice: string; + markPrice: string; + realisedPnl: string; + createdTime: string; +} ================ -File: examples/Rest/rest-v5-all.ts +File: src/types/response/v5-tax.ts ================ -import { RestClientV5 } from '../../src/index'; +export interface TaxBatchExportResultV5 { + batchId: string; +} ⋮---- -// or -// import { RestClientV5 } from 'bybit-api'; +export interface TaxBatchExportTaskV5 { + type: string; + number: string; + /** 0 queued, 1 processing, 2 succeeded, -1 failed */ + status: 0 | 1 | 2 | -1; + url: string; + queryId: string; +} ⋮---- -/** - * If you don't plan on making any private api calls, - * you can instance the REST client without any parameters: - * - * const client = new RestClientV5(); - */ +/** 0 queued, 1 processing, 2 succeeded, -1 failed */ +⋮---- +export interface TaxBatchExportStatusV5 { + items: TaxBatchExportTaskV5[]; +} ================ -File: examples/Rest/rest-v5-next-cursor.ts +File: src/types/websockets/index.ts ================ -import { RestClientV5, UniversalTransferRecordV5 } from '../../src/index'; -⋮---- -// or -// import { RestClientV5 } from 'bybit-api'; -⋮---- -async function getAllUniversalTransfers() -⋮---- -limit: 50, // Maximum page size per request -cursor: nextCursor || undefined, // Only send cursor if we have one -⋮---- -// Optional: Add a small delay to avoid rate limits + ================ -File: examples/Rest/rest-v5-p2p.ts +File: src/types/websockets/ws-api.ts ================ -import fs from 'fs'; -import path from 'path'; +import { APIID, WS_KEY_MAP } from '../../util'; +import { + AmendOrderParamsV5, + BatchAmendOrderParamsV5, + BatchCancelOrderParamsV5, + BatchOrderParamsV5, + CancelOrderParamsV5, + OrderParamsV5, +} from '../request'; +import { + BatchAmendOrderResultV5, + BatchCancelOrderResultV5, + BatchCreateOrderResultV5, + BatchOrdersRetExtInfoV5, + OrderResultV5, +} from '../response'; +import { WsKey } from './ws-general'; ⋮---- -import { RestClientV5 } from '../../src'; +// When new WS API operations are added, make sure to also update WS_API_Operations[] below +export type WSAPIOperation = + | 'order.create' + | 'order.amend' + | 'order.cancel' + | 'order.create-batch' + | 'order.amend-batch' + | 'order.cancel-batch'; ⋮---- -// ENDPOINT: /v5/p2p/oss/upload_file -// METHOD: POST -// PUBLIC: NO -// NOTE: Node.js only (Buffer required) +export type WsOperation = + | 'subscribe' + | 'unsubscribe' + | 'auth' + | 'ping' + | 'pong'; ⋮---- -async function uploadP2PChatFile() +export interface WsRequestOperationBybit { + req_id: string; + op: WsOperation; + args?: (TWSTopic | string | number)[]; +} ⋮---- -// You must read the file yourself and pass the Buffer + filename +export interface WSAPIRequest< + TRequestParams = undefined, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + TWSOperation extends WSAPIOperation = any, +> { + reqId: string; + op: TWSOperation; + header: { + 'X-BAPI-TIMESTAMP': string; + 'X-BAPI-RECV-WINDOW': string; + Referer: typeof APIID; + }; + args: [TRequestParams]; +} ⋮---- -/** - * - * - * - * - * - * - */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any ⋮---- -// Test basic P2P API connectivity +export interface WSAPIResponse< + TResponseData extends object = object, + TOperation extends WSAPIOperation = WSAPIOperation, + TResponseExtInfo = {}, // added as optional for batch calls +> { + wsKey: WsKey; + /** Auto-generated */ + reqId: string; + retCode: 0 | number; + retMsg: 'OK' | string; + op: TOperation; + data: TResponseData; + retExtInfo: TResponseExtInfo; + header?: { + 'X-Bapi-Limit': string; + 'X-Bapi-Limit-Status': string; + 'X-Bapi-Limit-Reset-Timestamp': string; + Traceid: string; + Timenow: string; + }; + connId: string; +} ⋮---- -// Example 1: Upload from file path +TResponseExtInfo = {}, // added as optional for batch calls ⋮---- -fileName: path.basename(filePath), // Extract filename from path +/** Auto-generated */ ⋮---- -// Example 2: Upload with custom filename -// You control the filename sent to Bybit +export type Exact = { + // This part says: if there's any key that's not in T, it's an error + [K: string]: never; +} & { + [K in keyof T]: T[K]; +}; ⋮---- -fileName: 'custom-name.png', // Use any filename you want +// This part says: if there's any key that's not in T, it's an error ⋮---- -// Example 3: Upload different file +/** + * List of operations supported for this WsKey (connection) + */ +export interface WsAPIWsKeyTopicMap { + [WS_KEY_MAP.v5PrivateTrade]: WSAPIOperation; +} ⋮---- -// Supported file types (determined by filename extension): -// - Images: jpg, jpeg, png -// - Documents: pdf -// - Videos: mp4 +/** + * Request parameters expected per operation + */ +export interface WsAPITopicRequestParamMap { + 'order.create': OrderParamsV5; + 'order.amend': AmendOrderParamsV5; + 'order.cancel': CancelOrderParamsV5; + + 'order.create-batch': { + category: 'option' | 'linear'; + request: BatchOrderParamsV5[]; + }; + 'order.amend-batch': { + category: 'option' | 'linear'; + request: BatchAmendOrderParamsV5[]; + }; + 'order.cancel-batch': { + category: 'option' | 'linear'; + request: BatchCancelOrderParamsV5[]; + }; +} +⋮---- +/** + * Response structure expected for each operation + */ +export interface WsAPIOperationResponseMap { + 'order.create': WSAPIResponse; + 'order.amend': WSAPIResponse; + 'order.cancel': WSAPIResponse; + + 'order.create-batch': WSAPIResponse< + { list: BatchCreateOrderResultV5[] }, + 'order.create-batch' + > & { + retExtInfo: BatchOrdersRetExtInfoV5; + }; + 'order.amend-batch': WSAPIResponse< + { list: BatchAmendOrderResultV5[] }, + 'order.amend-batch' + > & { + retExtInfo: BatchOrdersRetExtInfoV5; + }; + 'order.cancel-batch': WSAPIResponse< + { list: BatchCancelOrderResultV5[] }, + 'order.cancel-batch' + > & { + retExtInfo: BatchOrdersRetExtInfoV5; + }; + + ping: { + retCode: 0 | number; + retMsg: 'OK' | string; + op: 'pong'; + data: [string]; + connId: string; + }; +} ================ -File: examples/Rest/rest-v5-private.ts +File: src/types/websockets/ws-confirmations.ts ================ -import { RestClientV5 } from '../../src/index'; -⋮---- -// or -// import { RestClientV5 } from 'bybit-api'; +export interface WebsocketTopicSubscriptionConfirmationEvent { + op: 'subscribe'; + req_id: string; + conn_id: string; + ret_msg: string; + success: boolean; +} ⋮---- -/** Simple examples for private REST API calls with bybit's V5 REST APIs */ +export interface WebsocketSucceededTopicSubscriptionConfirmationEvent + extends WebsocketTopicSubscriptionConfirmationEvent { + success: true; +} ⋮---- -// Trade USDT linear perps +export interface WebsocketFailedTopicSubscriptionConfirmationEvent + extends WebsocketTopicSubscriptionConfirmationEvent { + success: false; +} + +================ +File: src/types/index.ts +================ + ================ -File: examples/Rest/rest-v5-proxies.ts +File: src/index.ts ================ -import { RestClientV5 } from '../../src/index'; -⋮---- -// or -// import { RestClientV5 } from 'bybit-api'; -⋮---- -// Sometimes using a proxy introduces recv timestamp errors (due to the extra latency) -// If that happens, you can try increasing the recv window (which is 5000ms by default) -// recv_window: 10000, -⋮---- -/** - * Axios has a native way of supporting http/https proxies. It works for most proxy services but not all. - * If you have issues making any proxied requests this way, take a look at the rest-v5-proxies2.ts example using the https-proxy-agent. - */ -⋮---- -protocol: 'http', // or 'https' -⋮---- -// const orders = await client.batchSubmitOrders('linear', [ -// { -// symbol: 'ETHUSDT', -// orderType: 'Limit', -// side: 'Buy', -// qty: '1', -// orderIv: '6', -// timeInForce: 'GTC', -// orderLinkId: 'option-test-001', -// mmp: false, -// reduceOnly: false, -// }, -// { -// symbol: 'ETHUSDT', -// orderType: 'Limit', -// side: 'Sell', -// qty: '2', -// price: '700', -// timeInForce: 'GTC', -// orderLinkId: 'option-test-001', -// mmp: false, -// reduceOnly: false, -// }, -// ]); -⋮---- -// console.log('orders: ', JSON.stringify(orders, null, 2)); + ================ -File: examples/Rest/rest-v5-public.ts +File: src/spot-client-v3.ts ================ -import { RestClientV5 } from '../../src/index'; -⋮---- -// or -// import { RestClientV5 } from 'bybit-api'; +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { APIResponseV3, numberInString } from './types'; +import { REST_CLIENT_TYPE_ENUM } from './util'; +import BaseRestClient from './util/BaseRestClient'; ⋮---- /** - * If you don't plan on making any private api calls, - * you can instance the REST client without any parameters + * REST API client for newer Spot V3 APIs. + * @deprecated WARNING + * These endpoints are being switched off gradually and are expected to be completely turned off by the end of 2024. + * They may stop working at any point before then. + * Please update your code as soon as possible to use the V5 APIs instead. */ +export class SpotClientV3 extends BaseRestClient ⋮---- -// const klineResult = await client.getKline({ -// category: 'linear', -// interval: '15', -// symbol: 'BTCUSDT', -// }); -// console.log('klineResult: ', klineResult); +getClientType() ⋮---- -// const markPriceKlineResult = await client.getMarkPriceKline({ -// category: 'linear', -// interval: '15', -// symbol: 'BTCUSDT', -// }); -// console.log('markPriceKlineResult: ', markPriceKlineResult); +// Doesn't really matter here, since the only remaining endpoint does not require auth. ⋮---- -// const indexPriceKline = await client.getIndexPriceKline({ -// category: 'linear', -// interval: '15', -// symbol: 'BTCUSDT', -// }); -// console.log('indexPriceKline: ', indexPriceKline); +async fetchServerTime(): Promise ⋮---- -// const openInterest = await client.getOpenInterest({ -// category: 'linear', -// symbol: 'BTCUSDT', -// intervalTime: '5min', -// }); +/** + * + * Market Data Endpoints + * + */ ⋮---- -// console.log( -// JSON.stringify( -// tickers.result.list.map((ticker) => ticker.symbol), -// null, -// 2, -// ), -// ); +/** + * Get merged orderbook for symbol + * + * This is the only known pre-V5 endpoint to still be online. + */ +getMergedOrderBook( + symbol: string, + scale?: number, + limit?: number, +): Promise> ⋮---- -// openInterest.result.list.forEach((row) => { -// console.log('int: ', { -// timestamp: row.timestamp, -// value: row.openInterest, -// }); -// }); -// console.log('openInterest: ', openInterest.result.list); +/** + * + * API Data Endpoints + * + */ +⋮---- +getServerTime(): Promise< ================ -File: examples/Websocket/WS-API/ws-api-client.ts +File: src/websocket-api-client.ts ================ -import { DefaultLogger, WebsocketAPIClient } from '../../../src'; -⋮---- -// or -// import { DefaultLogger, WebsocketAPIClient } from 'bybit-api'; -// const { DefaultLogger, WebsocketAPIClient } = require('bybit-api'); -⋮---- -// function attachEventHandlers( -// wsClient: TWSClient, -// ): void { -// wsClient.on('update', (data) => { -// console.log('raw message received ', JSON.stringify(data)); -// }); -// wsClient.on('open', (data) => { -// console.log('ws connected', data.wsKey); -// }); -// wsClient.on('reconnect', ({ wsKey }) => { -// console.log('ws automatically reconnecting.... ', wsKey); -// }); -// wsClient.on('reconnected', (data) => { -// console.log('ws has reconnected ', data?.wsKey); -// }); -// wsClient.on('authenticated', (data) => { -// console.log('ws has authenticated ', data?.wsKey); -// }); -// } -⋮---- -async function main() -⋮---- -// Optional -⋮---- -// For a more detailed view of the WebsocketClient, enable the `trace` level by uncommenting the below line: -// trace: (...params) => console.log('trace', ...params), -⋮---- -// testnet: true, // Whether to use the testnet environment: https://testnet.bybit.com/app/user/api-management +import { + AmendOrderParamsV5, + BatchAmendOrderParamsV5, + BatchAmendOrderResultV5, + BatchCancelOrderParamsV5, + BatchCancelOrderResultV5, + BatchCreateOrderResultV5, + BatchOrderParamsV5, + BatchOrdersRetExtInfoV5, + CancelOrderParamsV5, + OrderParamsV5, + OrderResultV5, +} from './types'; +import { WSAPIResponse } from './types/websockets/ws-api'; +import { WSClientConfigurableOptions } from './types/websockets/ws-general'; +import { DefaultLogger } from './util'; +import { WS_KEY_MAP } from './util/websockets/websocket-util'; +import { WebsocketClient } from './websocket-client'; ⋮---- -// Whether to use the livenet demo trading environment -// Note: As of Jan 2025, demo trading only supports consuming events, it does -// NOT support the WS API. -// demoTrading: false, +/** + * Configurable options specific to only the REST-like WebsocketAPIClient + */ +export interface WSAPIClientConfigurableOptions { + /** + * Default: true + * + * Attach default event listeners, which will console log any high level + * events (opened/reconnecting/reconnected/etc). + * + * If you disable this, you should set your own event listeners + * on the embedded WS Client `wsApiClient.getWSClient().on(....)`. + */ + attachEventListeners: boolean; +} ⋮---- -// If you want your own event handlers instead of the default ones with logs, -// disable this setting and see the `attachEventHandlers` example below: -// attachEventListeners: false +/** + * Default: true + * + * Attach default event listeners, which will console log any high level + * events (opened/reconnecting/reconnected/etc). + * + * If you disable this, you should set your own event listeners + * on the embedded WS Client `wsApiClient.getWSClient().on(....)`. + */ ⋮---- -logger, // Optional: inject a custom logger +/** + * This is a minimal Websocket API wrapper around the WebsocketClient. + * + * Some methods support passing in a custom "wsKey". This is a reference to which WS connection should + * be used to transmit that message. This is only useful if you wish to use an alternative wss + * domain that is supported by the SDK. + * + * Note: To use testnet, don't set the wsKey - use `testnet: true` in + * the constructor instead. + * + * Note: You can also directly use the sendWSAPIRequest() method to make WS API calls, but some + * may find the below methods slightly more intuitive. + * + * Refer to the WS API promises example for a more detailed example on using sendWSAPIRequest() directly: + * https://github.com/tiagosiebler/bybit-api/blob/master/examples/ws-api-raw-promises.ts + */ +export class WebsocketAPIClient ⋮---- -// Optional, see above "attachEventListeners". Attach basic event handlers, so nothing is left unhandled -// attachEventHandlers(wsClient.getWSClient()); +constructor( + options?: WSClientConfigurableOptions & + Partial, + logger?: DefaultLogger, +) ⋮---- -// Optional, if you see RECV Window errors, you can use this to manage time issues. -// ! However, make sure you sync your system clock first! -// https://github.com/tiagosiebler/awesome-crypto-examples/wiki/Timestamp-for-this-request-is-outside-of-the-recvWindow -// wsClient.setTimeOffsetMs(-5000); +public getWSClient(): WebsocketClient ⋮---- -// Optional: prepare the WebSocket API connection in advance. -// This happens automatically but you can do this early before making any API calls, to prevent delays from a cold start. -// await wsClient.getWSClient().connectWSAPI(); - -================ -File: examples/Websocket/WS-API/ws-api-raw-events.ts -================ -import { DefaultLogger, WebsocketClient, WS_KEY_MAP } from '../../../src'; +public setTimeOffsetMs(newOffset: number): void ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from 'bybit-api'; +/* + * Bybit WebSocket API Methods + * https://bybit-exchange.github.io/docs/v5/websocket/trade/guideline + */ ⋮---- -// For a more detailed view of the WebsocketClient, enable the `trace` level by uncommenting the below line: -// trace: (...params) => console.log('trace', ...params), +/** + * Submit a new order + * + * @param params + * @returns + */ +submitNewOrder( + params: OrderParamsV5, +): Promise> ⋮---- -// testnet: true, // Whether to use the testnet environment: https://testnet.bybit.com/app/user/api-management -// demoTrading: false, // note: As of Jan 2025, demo trading does NOT support the WS API +/** + * Amend an order + * + * @param params + * @returns + */ +amendOrder( + params: AmendOrderParamsV5, +): Promise> ⋮---- -logger, // Optional: inject a custom logger +/** + * Cancel an order + * + * @param params + * @returns + */ +cancelOrder( + params: CancelOrderParamsV5, +): Promise> ⋮---- /** - * General event handlers for monitoring the WebsocketClient - */ + * Batch submit orders + * + * @param params + * @returns + */ +batchSubmitOrders( + category: 'option' | 'linear', + orders: BatchOrderParamsV5[], + ): Promise< + WSAPIResponse< + { + list: BatchCreateOrderResultV5[]; + }, + 'order.create-batch', + BatchOrdersRetExtInfoV5 + > + > { + return this.wsClient.sendWSAPIRequest( + WS_KEY_MAP.v5PrivateTrade, + 'order.create-batch', + { + category, + request: orders, + }, + ); ⋮---- -async function main() +/** + * Batch amend orders + * + * @param params + * @returns + */ +batchAmendOrder( + category: 'option' | 'linear', + orders: BatchAmendOrderParamsV5[], + ): Promise< + WSAPIResponse< + { + list: BatchAmendOrderResultV5[]; + }, + 'order.amend-batch', + BatchOrdersRetExtInfoV5 + > + > { + return this.wsClient.sendWSAPIRequest( + WS_KEY_MAP.v5PrivateTrade, + 'order.amend-batch', + { + category, + request: orders, + }, + ); ⋮---- /** + * Batch cancel orders * - * This SDK's WebSocket API integration is event-driven at its core. You can treat the sentWSAPIRquest(...) method as - * a fire-and-forget method, to submit commands (create/amend/cancel order) via a WebSocket Connection. + * @param params + * @returns + */ +batchCancelOrder( + category: 'option' | 'linear', + orders: BatchCancelOrderParamsV5[], + ): Promise< + WSAPIResponse< + { + list: BatchCancelOrderResultV5[]; + }, + 'order.cancel-batch', + BatchOrdersRetExtInfoV5 + > + > { + return this.wsClient.sendWSAPIRequest( + WS_KEY_MAP.v5PrivateTrade, + 'order.cancel-batch', + { + category, + request: orders, + }, + ); +⋮---- +/** * - * Replies to commands will show in the `response` event from the WebsocketClient's EventEmitter. Exceptions, however, - * will show in the `error` event from the WebsocketClient's EventEmitter. * - * - Fire-and-forget a command. - * - Handle command results in the `response` event handler asynchronously as desired. - * - Handle any exceptions in a catch block. * - * This is a more "raw" workflow in how WebSockets behave. For a more convenient & REST-like approach, using the - * promise-driven interface is recommended. See the `ws-api-raw-promises.ts` and `ws-api-client.ts` examples for a - * demonstration you can compare. * - * Note: even without using promises, you should still tie on a .catch handler to each sendWSAPIRequest call, to prevent - * any unnecessary "unhandled promise rejection" exceptions. * - */ -⋮---- -// To make it easier to watch, wait a few seconds before sending the amend order -⋮---- -// Then wait a few more before sending the cancel order -⋮---- -// Exceptions including rejected commands will show here (as well as the catch handler used below) -⋮---- -// Replies to commands will show here -⋮---- -/** * - * If you haven't connected yet, the WebsocketClient will automatically connect and authenticate you as soon as you send - * your first command. That connection will then be reused for every command you send, unless the connection drops - then - * it will automatically be replaced with a healthy connection. * - * This "not connected yet" scenario can add an initial delay to your first command. If you want to prepare a connection - * in advance, you can ask the WebsocketClient to prepare it before you start submitting commands. This is optional. + * Private methods for handling some of the convenience/automation provided by the WS API Client + * + * + * + * + * * - * Repeated note: even without using promises, you should still tie on a .catch handler to each sendWSAPIRequest call, to prevent - * any unnecessary "unhandled promise rejection" exceptions. * */ ⋮---- -// Optional, see above. Can be used to prepare a connection before sending commands -⋮---- -// Fire and forget the create.order command -// Even without using promises, you should still "catch" exceptions (although no need to await anything you send) -⋮---- -// -⋮---- -// Fire and forget the order.amend command -// For simplicity, the orderId is hardcoded here (and will probably not work) +private setupDefaultEventListeners() ⋮---- -// +/** + * General event handlers for monitoring the WebsocketClient + */ ⋮---- -// Fire and forget the order.cancel command -// For simplicity, the orderId is hardcoded here (and will probably not work) +// Blind JSON.stringify can fail on circular references ⋮---- -// Start executing the example workflow +// JSON.stringify({ ...data, target: 'WebSocket' }), ================ -File: examples/Websocket/WS-API/ws-api-raw-promises.ts +File: .eslintrc.cjs ================ -import { DefaultLogger, WebsocketClient, WS_KEY_MAP } from '../../../src'; -⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from 'bybit-api'; -⋮---- -// For a more detailed view of the WebsocketClient, enable the `trace` level by uncommenting the below line: -// trace: (...params) => console.log('trace', ...params), -⋮---- -// testnet: true, // Whether to use the testnet environment: https://testnet.bybit.com/app/user/api-management -// demoTrading: false, // note: As of Jan 2025, demo trading does NOT support the WS API +// 'require-extensions', // only once moved to ESM ⋮---- -logger, // Optional: inject a custom logger +// 'plugin:require-extensions/recommended', // only once moved to ESM ⋮---- +// 'no-unused-vars': ['warn'], + +================ +File: .jshintrc +================ +{ + "esversion": 8, + "asi": true, + "laxbreak": true, + "predef": [ "-Promise" ] +} + +================ +File: .prettierrc +================ +{ + "tabWidth": 2, + "singleQuote": true, + "trailingComma": "all" +} + +================ +File: index.js +================ + + +================ +File: jest.config.ts +================ /** - * General event handlers for monitoring the WebsocketClient + * For a detailed explanation regarding each configuration property, visit: + * https://jestjs.io/docs/configuration */ ⋮---- -async function main() -⋮---- -/** - * - * This SDK's WebSocket API integration can connect WS API responses to the request that caused them. Each call - * to the `sendWSAPIRequest(...)` method returns a promise. - * - * This promise will resolve when the matching response is detected, and reject if an exception for that request - * is detected. This allows using Bybit's Websocket API in the same way that a REST API normally works. - * - * Send a command and immediately await the result. Handle any exceptions in a catch block. - * - * TypeScript users can benefit from smart type flowing for increased type safety & convenience: - * - Request parameters are fully typed, depending on the operation in the second parameter to the call. E.g. - * the `order.create` operation will automatically require the params to match the `OrderParamsV5` interface. - * - * - Response parameters are fully typed, depending on the operation in the second parameter. E.g the `order.create` - * operation will automatically map the returned value to `WSAPIResponse`. - * - */ +import type { Config } from 'jest'; ⋮---- -// To make it easier to watch, wait a few seconds before sending the amend order +// All imported modules in your tests should be mocked automatically +// automock: false, ⋮---- -// Then wait a few more before sending the cancel order +// Stop running tests after `n` failures +// bail: 0, +bail: false, // enable to stop test when an error occur, ⋮---- -/** - * - * If you haven't connected yet, the WebsocketClient will automatically connect and authenticate you as soon as you send - * your first command. That connection will then be reused for every command you send, unless the connection drops - then - * it will automatically be replaced with a healthy connection. - * - * This "not connected yet" scenario can add an initial delay to your first command. If you want to prepare a connection - * in advance, you can ask the WebsocketClient to prepare it before you start submitting commands. This is optional. - * - */ +// The directory where Jest should store its cached dependency information +// cacheDirectory: "/private/var/folders/kf/2k3sz4px6c9cbyzj1h_b192h0000gn/T/jest_dx", ⋮---- -// Optional, see above. Can be used to prepare a connection before sending commands +// Automatically clear mock calls, instances, contexts and results before every test ⋮---- -/** - * Create a new order - */ +// Indicates whether the coverage information should be collected while executing the test ⋮---- -// The type for `wsAPISubmitOrderResult` is automatically resolved to `WSAPIResponse` +// An array of glob patterns indicating a set of files for which coverage information should be collected ⋮---- -// Save the orderId for the next call +// The directory where Jest should output its coverage files ⋮---- -// The type for `wsAPIAmendOrderResult` is automatically resolved to `WSAPIResponse` +// An array of regexp pattern strings used to skip coverage collection +// coveragePathIgnorePatterns: [ +// "/node_modules/" +// ], ⋮---- -// Save the orderId for the next call +// Indicates which provider should be used to instrument code for coverage ⋮---- -// The type for `wsAPICancelOrderResult` is automatically resolved to `WSAPIResponse` +// A list of reporter names that Jest uses when writing coverage reports +// coverageReporters: [ +// "json", +// "text", +// "lcov", +// "clover" +// ], ⋮---- -// Start executing the example workflow - -================ -File: src/constants/enum.ts -================ -/** Full take profit/stop loss mode (a single TP order and a single SL order can be placed, covering the entire position) */ +// An object that configures minimum threshold enforcement for coverage results +// coverageThreshold: undefined, ⋮---- -/** Partial take profit/stop loss mode (multiple TP and SL orders can be placed, covering portions of the position) */ +// A path to a custom dependency extractor +// dependencyExtractor: undefined, ⋮---- -/** This could mean bad request, incorrect value types or even incorrect/missing values */ +// Make calling deprecated APIs throw helpful error messages +// errorOnDeprecated: false, ⋮---- -/** API key requires specific whitelisted IPs, and this IP was not in the list */ +// The default configuration for fake timers +// fakeTimers: { +// "enableGlobally": false +// }, ⋮---- -/** Account not unified margin, update required */ +// Force coverage collection from ignored files using an array of glob patterns +// forceCoverageMatch: [], ⋮---- -/** Seen when placing an order */ +// A path to a module which exports an async function that is triggered once before all test suites +// globalSetup: undefined, ⋮---- -/** Seen if a conditional order is too large */ +// A path to a module which exports an async function that is triggered once after all test suites +// globalTeardown: undefined, ⋮---- -/** E.g. trying to change position margin while on cross */ +// A set of global variables that need to be available in all test environments +// globals: {}, ⋮---- -/** E.g. USDC Options trading, trying to access a symbol that is no longer active */ +// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. +// maxWorkers: "50%", ⋮---- -/** E.g. USDC Options trading when the account hasn't been opened for USDC Options yet */ +// An array of directory names to be searched recursively up from the requiring module's location +// moduleDirectories: [ +// "node_modules" +// ], ⋮---- -/** - * Position idx, used to identify positions in different position modes. - * Required if you are under One-Way Mode: - */ -export enum LinearPositionIdx { - OneWayMode = 0, - BuySide = 1, - SellSide = 2, -} - -================ -File: src/types/request/v5-alpha-lp.ts -================ -/** - * V5 private Alpha LP requests. - */ +// An array of file extensions your modules use +// moduleFileExtensions: [ +// "js", +// "mjs", +// "cjs", +// "jsx", +// "ts", +// "tsx", +// "json", +// "node" +// ], ⋮---- -export interface GetAlphaLPPoolListParamsV5 { - tokenSymbol?: string; -} +// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module +// moduleNameMapper: {}, ⋮---- -export interface GetAlphaLPPoolInfoParamsV5 { - poolAddress: string; -} +// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader +// modulePathIgnorePatterns: [], ⋮---- -export interface ExecuteAlphaLPStakeParamsV5 { - positionId: number; - poolAddress: string; - payTokenAmount: string; - payTokenCode: string; - rangeUpper?: string; - rangeLower?: string; - priceUpper?: string; - priceLower?: string; -} +// Activates notifications for test results +// notify: false, ⋮---- -export interface ExecuteAlphaLPRedeemParamsV5 { - positionId: number; - poolAddress: string; - dercRatio: string; - receiveTokenCode?: string; -} +// An enum that specifies notification mode. Requires { notify: true } +// notifyMode: "failure-change", ⋮---- -export interface GetAlphaLPOrderListParamsV5 { - orderType?: 0 | 1 | 2; - tokenCode?: string; - orderStatus?: number[]; - days?: number; - limit?: number; - pageIndex?: number; - poolAddress?: string; -} +// A preset that is used as a base for Jest's configuration +// preset: undefined, ⋮---- -export interface GetAlphaLPPayTokenListParamsV5 { - chainCode?: string; - tokenAddress?: string; -} +// Run tests from one or more projects +// projects: undefined, ⋮---- -export interface GetAlphaLPPayTokenPriceParamsV5 { - tokenCode: string[]; - chainCode?: string; -} - -================ -File: src/types/request/v5-alpha-prediction.ts -================ -/** - * V5 private Alpha prediction market requests. - */ +// Use this configuration option to add custom reporters to Jest +// reporters: undefined, ⋮---- -export interface GetAlphaPredictionEventDetailParamsV5 { - eventId?: string; - slug?: string; - hasMoreMarkets?: boolean; -} +// Automatically reset mock state before every test +// resetMocks: false, ⋮---- -export interface GetAlphaPredictionOrderEstimateParamsV5 { - tokenId: string; - side: 1 | 2; - eventId: string; - amount: string; - orderType: 1; - payTokenCode?: string; -} +// Reset the module registry before running each individual test +// resetModules: false, ⋮---- -export interface ExecuteAlphaPredictionBuyParamsV5 { - tokenId: string; - amount: string; - payTokenCode: string; - orderType: 1; - slippage: string; - eventId: string; -} +// A path to a custom resolver +// resolver: undefined, ⋮---- -export interface ExecuteAlphaPredictionSellParamsV5 { - tokenId: string; - size: string; - orderType: 1; - slippage: string; - eventId: string; - toTokenCode?: string; -} +// Automatically restore mock state and implementation before every test +// restoreMocks: false, ⋮---- -export interface GetAlphaPredictionOrderListParamsV5 { - status?: number; - tokenId?: string; - eventId?: string; - side?: 1 | 2; - days?: number; - limit?: number; - pageIndex?: number; -} +// The root directory that Jest should scan for tests and modules within +// rootDir: undefined, ⋮---- -export interface GetAlphaPredictionOrderBookParamsV5 { - tokenIds: string[]; -} +// A list of paths to directories that Jest should use to search for files in +// roots: [ +// "" +// ], ⋮---- -export interface GetAlphaPredictionTokenPriceParamsV5 { - tokenIds: string[]; -} +// Allows you to use a custom runner instead of Jest's default test runner +// runner: "jest-runner", ⋮---- -export interface GetAlphaPredictionPriceHistoryParamsV5 { - tokenId: string; - interval: string; -} +// The paths to modules that run some code to configure or set up the testing environment before each test +// setupFiles: [], ⋮---- -export interface GetAlphaPredictionPositionListParamsV5 { - tokenId?: string; - eventId?: string; - limit?: number; - pageIndex?: number; -} +// A list of paths to modules that run some code to configure or set up the testing framework before each test +// setupFilesAfterEnv: [], ⋮---- -export interface GetAlphaPredictionPositionHistoryParamsV5 { - tokenId?: string; - eventId?: string; - result?: number; - days?: number; - limit?: number; - pageIndex?: number; -} +// The number of seconds after which a test is considered as slow and reported as such in the results. +// slowTestThreshold: 5, ⋮---- -export interface GetAlphaPredictionPortfolioSummaryParamsV5 { - eventType?: number; -} +// A list of paths to snapshot serializer modules Jest should use for snapshot testing +// snapshotSerializers: [], ⋮---- -export interface GetAlphaPredictionSideMarketListParamsV5 { - eventId: string; - sortBy?: string; - marketType?: number; - limit?: number; - pageIndex?: number; -} +// The test environment that will be used for testing +// testEnvironment: "jest-environment-node", ⋮---- -export interface GetAlphaPredictionSportsMatchListParamsV5 { - eventType: number; - status?: number; - startTime?: number; - endTime?: number; - stageCode?: string; - limit?: number; - pageIndex?: number; -} +// Options that will be passed to the testEnvironment +// testEnvironmentOptions: {}, ⋮---- -export interface GetAlphaPredictionSportsTimelineStagesParamsV5 { - eventType: number; -} +// Adds a location field to test results +// testLocationInResults: false, ⋮---- -export interface GetAlphaPredictionSportsGroupStageDetailParamsV5 { - eventType: number; - groupName?: string; -} - -================ -File: src/types/request/v5-alpha-trade.ts -================ -/** - * V5 private Alpha / on-chain (Web3) trade requests. - */ +// The glob patterns Jest uses to detect test files ⋮---- -export interface GetAlphaTradeQuoteParamsV5 { - tradeType: 1 | 2; - fromTokenCode: string; - fromTokenAmount: string; - toTokenCode: string; - quoteMode?: 0 | 1 | 2; -} +// "**/__tests__/**/*.[jt]s?(x)", ⋮---- -export interface ExecuteAlphaTradeParamsV5 { - fromTokenCode: string; - fromTokenAmount: string; - toTokenCode: string; - slippage: string; - quoteData: string; - gas: string; - quoteMode: 0 | 1 | 2; - correctingCode: string; - tenant?: string; -} +// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped +// testPathIgnorePatterns: [ +// "/node_modules/" +// ], ⋮---- -export interface GetAlphaPayTokenListParamsV5 { - chainCode: string; - tokenAddress: string; -} +// The regexp pattern or array of patterns that Jest uses to detect test files +// testRegex: [], ⋮---- -export interface GetAlphaTradeOrderListParamsV5 { - limit: number; - pageIndex: number; - tradeType?: number; - tokenCode?: string; - orderStatus?: number[]; - days?: number; - direction?: 'prev' | 'next'; -} +// This option allows the use of a custom results processor +// testResultsProcessor: undefined, ⋮---- -export interface GetAlphaBizTokenListParamsV5 { - tokenTag?: number; -} +// This option allows use of a custom test runner +// testRunner: "jest-circus/runner", ⋮---- -export interface AlphaTokenAddressInfoV5 { - chainCode: string; - tokenAddress: string; -} +// A map from regular expressions to paths to transformers +// transform: undefined, ⋮---- -export interface GetAlphaBizTokenPriceListParamsV5 { - tokenAddressInfo: AlphaTokenAddressInfoV5[]; -} +// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation +// transformIgnorePatterns: [ +// "/node_modules/", +// "\\.pnp\\.[^\\/]+$" +// ], ⋮---- -export interface GetAlphaBizTokenDetailsParamsV5 { - chainCode: string; - tokenAddress: string; -} +// Prevents import esm module error from v1 axios release, issue #5026 ⋮---- -export interface GetAlphaAssetDetailParamsV5 { - chainCode: string; - tokenAddress: string; -} +// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them +// unmockedModulePathPatterns: undefined, +⋮---- +// Indicates whether each individual test should be reported during the run +// verbose: undefined, +verbose: true, // report individual test +⋮---- +// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode +// watchPathIgnorePatterns: [], +⋮---- +// Whether to use watchman for file crawling +// watchman: true, ================ -File: src/types/request/v5-broker.ts +File: jsconfig.json ================ -export interface GetExchangeBrokerEarningsParamsV5 { - bizType?: 'SPOT' | 'DERIVATIVES' | 'OPTIONS' | 'CONVERT' | 'FIAT_CONVERT'; - begin?: string; - end?: string; - uid?: string; - limit?: number; - cursor?: string; -} -⋮---- -export interface GetBrokerSubAccountDepositsV5 { - id?: string; - txID?: string; - subMemberId?: string; - coin?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; -} -⋮---- -export interface IssueVoucherParamsV5 { - accountId: string; - awardId: string; - specCode: string; - amount: string; - brokerId: string; +{ + "compilerOptions": { + "target": "ES6", + "module": "commonjs" + }, + "exclude": [ + "node_modules", + "**/node_modules/*", + "coverage", + "doc", + "examples/ignored/*" + ] } -⋮---- -export interface GetBrokerIssuedVoucherParamsV5 { - accountId: string; - awardId: string; - specCode: string; - withUsedAmount?: boolean; + +================ +File: LICENSE.md +================ +Copyright 2024 Tiago Siebler + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +================ +File: tsconfig.build.json +================ +{ + "extends": "./tsconfig.json", + "exclude": [ + "node_modules", + "test", + "dist", + "**/*spec.ts", + "**/*test.ts", + "jest.config.ts" + ] } -⋮---- -/** Set Rate Limit - exchange broker only. API rate limit: 1 req per second. */ -export interface SetBrokerRateLimitParamsV5 { - list: { - uids: string; - bizType: string; - rate: number; - }[]; + +================ +File: tsconfig.examples.json +================ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "distExamples", + "allowJs": true + }, + "include": ["examples/**/*.ts", "examples/**/*.js"] } -⋮---- -/** Get All Rate Limits - exchange broker only. API rate limit: 1 req per second. */ -export interface GetAllBrokerRateLimitsParamsV5 { - limit?: string; - cursor?: string; - uids?: string; + +================ +File: tsconfig.json +================ +{ + "compileOnSave": true, + "compilerOptions": { + "allowJs": true, + "target": "es6", + "module": "commonjs", + "moduleResolution": "node", + "declaration": true, + "removeComments": false, + "noEmitOnError": true, + "noImplicitAny": false, + "strictNullChecks": true, + "skipLibCheck": true, + "sourceMap": true, + "esModuleInterop": true, + "lib": ["es2017", "dom"], + "baseUrl": ".", + "outDir": "./lib" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "**/node_modules/*", "coverage", "doc"] } ================ -File: src/types/request/v5-card.ts +File: tsconfig.linting.json ================ -/** - * Bybit Card — /v5/card/* - * Authenticated; API key permission per Bybit (often card-related). - */ -⋮---- -export interface QueryCardAssetRecordsParamsV5 { - /** 0: Pending, 1: Cleared, 2: Declined */ - statusCode?: string; - /** Default 100, range [1, 500] */ - limit?: number; - /** Default 1, min 1 */ - page?: number; - /** Last 2/4 digits of card number */ - pan4?: string; - createBeginTime?: number; - createEndTime?: number; - /** Fuzzy search */ - merchName?: string; - /** Authorization / Clearing / Refund (see Bybit) */ - type?: string; - txnId?: string; - cardToken?: string; - orderNo?: string; +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "target": "esnext", + "rootDir": "../", + "allowJs": true + }, + "include": [ + "src/**/*.*", + "test/**/*.*", + "examples/**/*.*", + ".eslintrc.cjs", + "jest.config.ts" + ] } + +================ +File: tsconfig.test.json +================ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./distTest", + "allowJs": true + }, + "include": ["test/**/*.ts", "test/**/*.js"] +} + +================ +File: examples/Websocket/Private/ws-private-v5.ts +================ +/* eslint-disable @typescript-eslint/no-empty-function */ +import { DefaultLogger, WebsocketClient, WS_KEY_MAP } from '../../../src'; ⋮---- -/** 0: Pending, 1: Cleared, 2: Declined */ -⋮---- -/** Default 100, range [1, 500] */ -⋮---- -/** Default 1, min 1 */ +// or +// import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from 'bybit-api'; ⋮---- -/** Last 2/4 digits of card number */ +// Create & inject a custom logger to enable the trace logging level (empty function) ⋮---- -/** Fuzzy search */ +// trace: (...params) => console.log('trace', ...params), ⋮---- -/** Authorization / Clearing / Refund (see Bybit) */ +/** + * Prepare an instance of the WebSocket client. This client handles all aspects of connectivity for you: + * - Connections are opened when you subscribe to topics + * - If key & secret are provided, authentication is handled automatically + * - If you subscribe to topics from different v5 products (e.g. spot and linear perps), + * subscription events are automatically routed to the different ws endpoints on bybit's side + * - Heartbeats/ping/pong/reconnects are all handled automatically. + * If a connection drops, the client will clean it up, respawn a fresh connection and resubscribe for you. + */ ⋮---- -export interface QueryCardPointRecordsParamsV5 { - type?: string; - pageSize?: number; - pageNo?: number; - startTime?: number; - endTime?: number; - outOrderId?: string; - bizId?: string; - bizTxnId?: string; - /** 1: Earn, 2: Deduct */ - side?: string; -} +// testnet: false, +// demoTrading: false, // set testnet to false, if you plan on using demo trading ⋮---- -/** 1: Earn, 2: Deduct */ +// console.log('raw message received ', JSON.stringify(data, null, 2)); ⋮---- -export interface QueryCardMallItemListParamsV5 { - pageNo?: number; - pageSize?: number; - /** 1: Virtual, 2: Physical */ - itemType?: number; - /** 1: POINTS, 2: CURRENCY */ - itemBizType?: number; - /** 1: Priority, 2: Listing time, 3: Price */ - orderBy?: number; - asc?: boolean; - /** 0: Default, 1: VIP */ - source?: number; -} +// wsClient.on('exception', (data) => { +// console.error('ws exception: ', data); +// }); ⋮---- -/** 1: Virtual, 2: Physical */ +/** + * For private V5 topics, us the subscribeV5() method on the ws client or use the original subscribe() method. + * + * Note: for private endpoints the "category" field is ignored since there is only one private endpoint + * (compared to one public one per category). + * The "category" is only needed for public topics since bybit has one endpoint for public events per category. + */ ⋮---- -/** 1: POINTS, 2: CURRENCY */ +// wsClient.subscribeV5('execution.fast', 'linear'); +// wsClient.subscribeV5('execution.fast.linear', 'linear'); +// wsClient.subscribeV5('execution.fast.spot', 'spot'); +// wsClient.subscribeV5('execution.fast.option', 'option'); ⋮---- -/** 1: Priority, 2: Listing time, 3: Price */ +/** + * The following has the same effect as above, since there's only one private endpoint for V5 account topics: + */ +// wsClient.subscribe('position'); +// wsClient.subscribe('execution'); +// wsClient.subscribe(['order', 'wallet', 'greek']); ⋮---- -/** 0: Default, 1: VIP */ +// To unsubscribe from topics (after a 5 second delay, in this example): +// setTimeout(() => { +// console.log('unsubscribing'); +// wsClient.unsubscribeV5('execution', 'linear'); +// }, 5 * 1000); ⋮---- -export interface QueryCardPointCashbackDetailParamsV5 { - bizTxnId: string; -} +// Topics are tracked per websocket type +// Get a list of subscribed topics (e.g. for public v3 spot topics) (after a 5 second delay) ================ -File: src/types/request/v5-earn-advance-discount.ts +File: src/constants/enum.ts ================ -/** - * /v5/earn/advance/ — product-extra, place order, position, order (Discount Buy, Dual Assets, etc.) - */ -export type GetAdvanceEarnProductExtraInfoParamsV5 = - | { - category: 'DiscountBuy'; - productId?: string; - } - | { - category: 'DualAssets'; - /** Required for Dual Assets quote. */ - productId: string; - }; +/** Full take profit/stop loss mode (a single TP order and a single SL order can be placed, covering the entire position) */ ⋮---- -/** Required for Dual Assets quote. */ +/** Partial take profit/stop loss mode (multiple TP and SL orders can be placed, covering portions of the position) */ ⋮---- -export interface AdvanceEarnDiscountBuyExtraV5 { - initialPrice: string; - purchasePrice: string; - knockoutPrice: string; - knockoutCouponE8: string; - settleType: 'Base' | 'Quote'; - instUid: string; -} +/** This could mean bad request, incorrect value types or even incorrect/missing values */ ⋮---- -export interface AdvanceEarnDualAssetsExtraV5 { - orderDirection: 'BuyLow' | 'SellHigh'; - selectPrice: string; - /** Expected APY in e8 precision; API may return int. */ - apyE8: string | number; -} +/** API key requires specific whitelisted IPs, and this IP was not in the list */ ⋮---- -/** Expected APY in e8 precision; API may return int. */ +/** Account not unified margin, update required */ ⋮---- -export interface AdvanceEarnInterestCardExtraV5 { - awardId: string | number; - specCode: string; -} +/** Seen when placing an order */ ⋮---- -/** - * POST /v5/earn/advance/place-order — Discount Buy - */ -export interface SubmitAdvanceEarnPlaceOrderDiscountBuyV5 { - category: 'DiscountBuy'; - productId: string; - orderType: 'Stake'; - amount: string; - coin: string; - accountType: 'FUND' | 'UNIFIED'; - orderLinkId: string; - discountBuyExtra: AdvanceEarnDiscountBuyExtraV5; -} +/** Seen if a conditional order is too large */ ⋮---- -/** - * POST /v5/earn/advance/place-order — Dual Assets - */ -export interface SubmitAdvanceEarnPlaceOrderDualAssetsV5 { - category: 'DualAssets'; - productId: string; - orderType: 'Stake'; - amount: string; - coin: string; - accountType: 'FUND' | 'UNIFIED'; - orderLinkId: string; - dualAssetsExtra: AdvanceEarnDualAssetsExtraV5; - interestCard?: AdvanceEarnInterestCardExtraV5; -} +/** E.g. trying to change position margin while on cross */ ⋮---- -export type SubmitAdvanceEarnPlaceOrderParamsV5 = - | SubmitAdvanceEarnPlaceOrderDiscountBuyV5 - | SubmitAdvanceEarnPlaceOrderDualAssetsV5; +/** E.g. USDC Options trading, trying to access a symbol that is no longer active */ ⋮---- -export interface GetAdvanceEarnPositionListParamsV5 { - category: 'DiscountBuy' | 'DualAssets' | string; - productId?: string; - coin?: string; - limit?: number; - cursor?: string; -} +/** E.g. USDC Options trading when the account hasn't been opened for USDC Options yet */ ⋮---- -export interface GetAdvanceEarnOrderListParamsV5 { - category: 'DiscountBuy' | 'DualAssets' | string; - orderId?: string; - orderLinkId?: string; - productId?: string; - /** Dual Assets docs use string ms; other categories may use number. */ - startTime?: string | number; - endTime?: string | number; - limit?: number; - cursor?: string; +/** + * Position idx, used to identify positions in different position modes. + * Required if you are under One-Way Mode: + */ +export enum LinearPositionIdx { + OneWayMode = 0, + BuySide = 1, + SellSide = 2, } -⋮---- -/** Dual Assets docs use string ms; other categories may use number. */ ================ -File: src/types/request/v5-earn-fixed-term.ts +File: src/types/request/v5-alpha-lp.ts ================ /** - * /v5/earn/fixed-term/* + * V5 private Alpha LP requests. */ -export interface GetFixedTermEarnProductParamsV5 { - coin?: string; +⋮---- +export interface GetAlphaLPPoolListParamsV5 { + tokenSymbol?: string; } ⋮---- -export interface SubmitFixedTermEarnOrderParamsV5 { - productId: string; - category: 'FixedTermSaving' | 'FundPool' | 'FundPoolPremium'; - coin: string; - amount: string; - accountType: 'FUND' | 'UNIFIED'; - orderLinkId: string; - autoInvest?: boolean; +export interface GetAlphaLPPoolInfoParamsV5 { + poolAddress: string; } ⋮---- -export interface RedeemFixedTermEarnParamsV5 { - productId: string; - /** Early redemption: FundPool only */ - category: 'FundPool'; - positionId: string; +export interface ExecuteAlphaLPStakeParamsV5 { + positionId: number; + poolAddress: string; + payTokenAmount: string; + payTokenCode: string; + rangeUpper?: string; + rangeLower?: string; + priceUpper?: string; + priceLower?: string; } ⋮---- -/** Early redemption: FundPool only */ +export interface ExecuteAlphaLPRedeemParamsV5 { + positionId: number; + poolAddress: string; + dercRatio: string; + receiveTokenCode?: string; +} ⋮---- -export interface GetFixedTermEarnPositionParamsV5 { - productId?: string; - category?: 'FixedTermSaving' | 'FundPool' | 'FundPoolPremium'; - coin?: string; +export interface GetAlphaLPOrderListParamsV5 { + orderType?: 0 | 1 | 2; + tokenCode?: string; + orderStatus?: number[]; + days?: number; + limit?: number; + pageIndex?: number; + poolAddress?: string; } ⋮---- -export interface GetFixedTermEarnOrderListParamsV5 { - orderType?: 'Stake' | 'Redeem' | 'Reinvest'; - productId?: string; - category?: 'FixedTermSaving' | 'FundPool' | 'FundPoolPremium'; - orderId?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; +export interface GetAlphaLPPayTokenListParamsV5 { + chainCode?: string; + tokenAddress?: string; } ⋮---- -export interface SetFixedTermEarnAutoInvestParamsV5 { - productId: string; - category: 'FixedTermSaving' | 'FundPool' | 'FundPoolPremium'; - positionId: string; - status: 'Enable' | 'Disable'; +export interface GetAlphaLPPayTokenPriceParamsV5 { + tokenCode: string[]; + chainCode?: string; } ================ -File: src/types/request/v5-earn-liquidity-mining.ts +File: src/types/request/v5-alpha-prediction.ts ================ /** - * GET /v5/earn/liquidity-mining/product (public, 50 req/s per IP) + * V5 private Alpha prediction market requests. */ -export interface GetLiquidityMiningProductParamsV5 { - baseCoin?: string; - quoteCoin?: string; -} ⋮---- -export interface ReinvestLiquidityMiningParamsV5 { - productId: string; - orderLinkId: string; - positionId: string; - leverage?: string; -} - -================ -File: src/types/request/v5-earn-pwm.ts -================ -/** GET /v5/earn/pwm/investment-plan/detail */ -export interface GetPwmInvestmentPlanDetailParamsV5 { - planId: string; +export interface GetAlphaPredictionEventDetailParamsV5 { + eventId?: string; + slug?: string; + hasMoreMarkets?: boolean; } ⋮---- -/** GET /v5/earn/pwm/investment-plan/new-plan */ -export interface GetPwmPendingInvestmentPlanDetailParamsV5 { - planId: string; +export interface GetAlphaPredictionOrderEstimateParamsV5 { + tokenId: string; + side: 1 | 2; + eventId: string; + amount: string; + orderType: 1; + payTokenCode?: string; } ⋮---- -/** POST /v5/earn/pwm/investment-plan/claim */ -export interface ClaimPwmWithdrawableFundsParamsV5 { - planId: string; - /** Default: FUND */ - toAccountType?: string; - orderLinkId: string; +export interface ExecuteAlphaPredictionBuyParamsV5 { + tokenId: string; + amount: string; + payTokenCode: string; + orderType: 1; + slippage: string; + eventId: string; } ⋮---- -/** Default: FUND */ -⋮---- -/** GET /v5/earn/pwm/investment-plan/asset-trend */ -export interface GetPwmInvestmentPlanAssetTrendParamsV5 { - planId: string; - startTime?: number; - endTime?: number; +export interface ExecuteAlphaPredictionSellParamsV5 { + tokenId: string; + size: string; + orderType: 1; + slippage: string; + eventId: string; + toTokenCode?: string; } ⋮---- -/** GET /v5/earn/pwm/investment-plan/fund-nav */ -export interface GetPwmFundHistoricalNavParamsV5 { - fundId: string; - startTime?: number; - endTime?: number; +export interface GetAlphaPredictionOrderListParamsV5 { + status?: number; + tokenId?: string; + eventId?: string; + side?: 1 | 2; + days?: number; + limit?: number; + pageIndex?: number; } ⋮---- -/** POST /v5/earn/pwm/investment-plan/subscribe */ -export interface SubscribePwmInvestmentPlanParamsV5 { - planId: string; - /** Default: FUND */ - accountType?: string; - orderLinkId: string; +export interface GetAlphaPredictionOrderBookParamsV5 { + tokenIds: string[]; } ⋮---- -/** Default: FUND */ -⋮---- -/** POST /v5/earn/pwm/investment-plan/invest-more */ -export interface InvestMorePwmInvestmentPlanParamsV5 { - planId: string; - /** Default: FUND */ - accountType?: string; - category: string; - productId: string; - amount: string; - orderLinkId: string; +export interface GetAlphaPredictionTokenPriceParamsV5 { + tokenIds: string[]; } ⋮---- -/** Default: FUND */ -⋮---- -/** POST /v5/earn/pwm/investment-plan/redeem */ -export interface RedeemPwmInvestmentPlanParamsV5 { - planId: string; - category: string; - productId: string; - orderLinkId: string; - /** Required for fund products */ - shares?: string; - /** Required for non-fund products */ - amount?: string; - /** Required for FundPool and On-chain Earn */ - positionId?: string; +export interface GetAlphaPredictionPriceHistoryParamsV5 { + tokenId: string; + interval: string; } ⋮---- -/** Required for fund products */ -⋮---- -/** Required for non-fund products */ -⋮---- -/** Required for FundPool and On-chain Earn */ -⋮---- -/** GET /v5/earn/pwm/investment-plan/order */ -export interface GetPwmInvestmentPlanOrdersParamsV5 { - planId?: string; - category?: string; - type?: 'Subscribe' | 'Redeem' | 'AutoReinvest' | string; - status?: 'Completed' | 'Pending' | 'Failed' | string; - startTime?: string; - endTime?: string; +export interface GetAlphaPredictionPositionListParamsV5 { + tokenId?: string; + eventId?: string; limit?: number; - cursor?: string; - orderLinkId?: string; + pageIndex?: number; } ⋮---- -/** POST /v5/earn/pwm/customize-plan/create */ -export interface CreatePwmCustomizeInvestmentPlanProductV5 { - category: string; - productId: string; - fundName: string; - amount: string; +export interface GetAlphaPredictionPositionHistoryParamsV5 { + tokenId?: string; + eventId?: string; + result?: number; + days?: number; + limit?: number; + pageIndex?: number; } ⋮---- -export interface CreatePwmCustomizeInvestmentPlanParamsV5 { - accountType?: string; - products: CreatePwmCustomizeInvestmentPlanProductV5[]; +export interface GetAlphaPredictionPortfolioSummaryParamsV5 { + eventType?: number; } ⋮---- -/** GET /v5/earn/pwm/asset-manager/all-funds */ -export interface GetPwmAllFundsParamsV5 { - coin?: string; - fundId?: string; - status?: string; +export interface GetAlphaPredictionSideMarketListParamsV5 { + eventId: string; + sortBy?: string; + marketType?: number; limit?: number; - cursor?: string; + pageIndex?: number; } ⋮---- -/** POST /v5/earn/pwm/asset-manager/settle-profit */ -export interface SettlePwmFundProfitParamsV5 { - fundId: string; - reqLinkId: string; +export interface GetAlphaPredictionSportsMatchListParamsV5 { + eventType: number; + status?: number; + startTime?: number; + endTime?: number; + stageCode?: string; + limit?: number; + pageIndex?: number; } ⋮---- -/** POST /v5/earn/pwm/asset-manager/create-fund */ -export interface CreatePwmFundParamsV5 { - fundName: string; - coin: string; - profitShareRate: string; - managementFeeRate: string; - fundIntroduction?: string; - reqLinkId: string; +export interface GetAlphaPredictionSportsTimelineStagesParamsV5 { + eventType: number; } ⋮---- -/** POST /v5/earn/pwm/asset-manager/create-investment-plan */ -export interface CreatePwmAssetManagerInvestmentPlanDistributionV5 { - productId: string; - amount: string; +export interface GetAlphaPredictionSportsGroupStageDetailParamsV5 { + eventType: number; + groupName?: string; } + +================ +File: src/types/request/v5-alpha-trade.ts +================ +/** + * V5 private Alpha / on-chain (Web3) trade requests. + */ ⋮---- -export interface CreatePwmAssetManagerInvestmentPlanParamsV5 { - accountUid: string; - planName: string; - planType: 'stable' | 'advanced' | string; - investmentDistribution: CreatePwmAssetManagerInvestmentPlanDistributionV5[]; - reqLinkId: string; +export interface GetAlphaTradeQuoteParamsV5 { + tradeType: 1 | 2; + fromTokenCode: string; + fromTokenAmount: string; + toTokenCode: string; + quoteMode?: 0 | 1 | 2; } ⋮---- -/** GET /v5/earn/pwm/asset-manager/get-investment-plan */ -export interface GetPwmAssetManagerInvestmentPlansParamsV5 { - planId?: string; - status?: string; - subscriptionUid?: string; - limit?: number; - cursor?: string; +export interface ExecuteAlphaTradeParamsV5 { + fromTokenCode: string; + fromTokenAmount: string; + toTokenCode: string; + slippage: string; + quoteData: string; + gas: string; + quoteMode: 0 | 1 | 2; + correctingCode: string; + tenant?: string; } -⋮---- -/** POST /v5/earn/pwm/asset-manager/manage-investment-plan */ -export interface ManagePwmAssetManagerInvestmentPlanFundV5 { - fundId: string; - amount: string; +⋮---- +export interface GetAlphaPayTokenListParamsV5 { + chainCode: string; + tokenAddress: string; } ⋮---- -export interface ManagePwmAssetManagerInvestmentPlanParamsV5 { - planId: string; - updateStatus?: 'Closed' | 'Deleted' | string; - updateFunds?: ManagePwmAssetManagerInvestmentPlanFundV5[]; - reqLinkId: string; +export interface GetAlphaTradeOrderListParamsV5 { + limit: number; + pageIndex: number; + tradeType?: number; + tokenCode?: string; + orderStatus?: number[]; + days?: number; + direction?: 'prev' | 'next'; } ⋮---- -/** GET /v5/earn/pwm/asset-manager/all-order */ -export interface GetPwmAllFundOrdersParamsV5 { - fundId?: string; - orderType?: 'Subscribe' | 'Redeem' | string; - status?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; +export interface GetAlphaBizTokenListParamsV5 { + tokenTag?: number; } ⋮---- -/** POST /v5/earn/pwm/asset-manager/manage-order */ -export interface ManagePwmFundOrderParamsV5 { - orderId: string; - action: 'approve' | 'reject' | string; - reqLinkId: string; +export interface AlphaTokenAddressInfoV5 { + chainCode: string; + tokenAddress: string; } ⋮---- -/** POST /v5/earn/pwm/asset-manager/create-sub-account */ -export interface CreatePwmFundSubAccountParamsV5 { - fundId: string; - reqLinkId: string; +export interface GetAlphaBizTokenPriceListParamsV5 { + tokenAddressInfo: AlphaTokenAddressInfoV5[]; } ⋮---- -/** POST /v5/earn/pwm/fund-transfer */ -export interface PwmFundTransferParamsV5 { - transferId: string; - fromUserId: number; - toUserId: number; - amount: string; - coin: string; +export interface GetAlphaBizTokenDetailsParamsV5 { + chainCode: string; + tokenAddress: string; } ⋮---- -/** GET /v5/earn/pwm/query-fund-transfer-result */ -export interface GetPwmFundTransferRecordsParamsV5 { - transferId?: string; - fromUserId?: number; +export interface GetAlphaAssetDetailParamsV5 { + chainCode: string; + tokenAddress: string; } ================ -File: src/types/request/v5-earn-token.ts +File: src/types/request/v5-card.ts ================ /** - * Earn token product (e.g. BYUSDT) — /v5/earn/token/* + * Bybit Card — /v5/card/* + * Authenticated; API key permission per Bybit (often card-related). */ ⋮---- -export interface GetEarnTokenProductParamsV5 { - /** Currently only BYUSDT */ - coin: string; +export interface QueryCardAssetRecordsParamsV5 { + /** 0: Pending, 1: Cleared, 2: Declined */ + statusCode?: string; + /** Default 100, range [1, 500] */ + limit?: number; + /** Default 1, min 1 */ + page?: number; + /** Last 2/4 digits of card number */ + pan4?: string; + createBeginTime?: number; + createEndTime?: number; + /** Fuzzy search */ + merchName?: string; + /** Authorization / Clearing / Refund (see Bybit) */ + type?: string; + txnId?: string; + cardToken?: string; + orderNo?: string; } ⋮---- -/** Currently only BYUSDT */ -⋮---- -export interface PlaceEarnTokenOrderParamsV5 { - coin: string; - orderLinkId: string; - orderType: 'Mint' | 'Redeem'; - amount: string; - /** Mint: FlexibleSaving; Redeem: UNIFIED */ - accountType: 'FlexibleSaving' | 'UNIFIED'; -} +/** 0: Pending, 1: Cleared, 2: Declined */ ⋮---- -/** Mint: FlexibleSaving; Redeem: UNIFIED */ +/** Default 100, range [1, 500] */ ⋮---- -export interface GetEarnTokenOrderListParamsV5 { - coin: string; - orderLinkId?: string; - orderId?: string; - orderType?: 'Mint' | 'Redeem'; - /** seconds */ - startTime?: number; - /** seconds */ - endTime?: number; - cursor?: string; - limit?: number; -} +/** Default 1, min 1 */ ⋮---- -/** seconds */ +/** Last 2/4 digits of card number */ ⋮---- -/** seconds */ +/** Fuzzy search */ ⋮---- -export interface GetEarnTokenPositionParamsV5 { - coin: string; -} +/** Authorization / Clearing / Refund (see Bybit) */ ⋮---- -export interface GetEarnTokenDailyYieldParamsV5 { - coin: string; +export interface QueryCardPointRecordsParamsV5 { + type?: string; + pageSize?: number; + pageNo?: number; startTime?: number; endTime?: number; - cursor?: string; - limit?: number; + outOrderId?: string; + bizId?: string; + bizTxnId?: string; + /** 1: Earn, 2: Deduct */ + side?: string; } ⋮---- -export interface GetEarnTokenHourlyYieldParamsV5 { - coin: string; - startTime?: number; - endTime?: number; - cursor?: string; - limit?: number; -} +/** 1: Earn, 2: Deduct */ ⋮---- -export interface GetEarnTokenHistoryAprParamsV5 { - coin: string; - /** 1 = 7d, 2 = 30d, 3 = 180d */ - range: 1 | 2 | 3; +export interface QueryCardMallItemListParamsV5 { + pageNo?: number; + pageSize?: number; + /** 1: Virtual, 2: Physical */ + itemType?: number; + /** 1: POINTS, 2: CURRENCY */ + itemBizType?: number; + /** 1: Priority, 2: Listing time, 3: Price */ + orderBy?: number; + asc?: boolean; + /** 0: Default, 1: VIP */ + source?: number; } ⋮---- -/** 1 = 7d, 2 = 30d, 3 = 180d */ +/** 1: Virtual, 2: Physical */ +⋮---- +/** 1: POINTS, 2: CURRENCY */ +⋮---- +/** 1: Priority, 2: Listing time, 3: Price */ +⋮---- +/** 0: Default, 1: VIP */ +⋮---- +export interface QueryCardPointCashbackDetailParamsV5 { + bizTxnId: string; +} ================ -File: src/types/request/v5-position.ts +File: src/types/request/v5-earn-advance-discount.ts ================ -import { - CategoryV5, - ExecTypeV5, - OrderTriggerByV5, - OrderTypeV5, - PositionIdx, - TPSLModeV5, -} from '../shared-v5'; -⋮---- -export interface GetFuturesLeverageParamsV5 { - category: 'linear' | 'inverse'; - symbol?: string; -} +/** + * /v5/earn/advance/ — product-extra, place order, position, order (Discount Buy, Dual Assets, etc.) + */ +export type GetAdvanceEarnProductExtraInfoParamsV5 = + | { + category: 'DiscountBuy'; + productId?: string; + } + | { + category: 'DualAssets'; + /** Required for Dual Assets quote. */ + productId: string; + }; ⋮---- -export interface PositionInfoParamsV5 { - category: CategoryV5; - symbol?: string; - baseCoin?: string; - settleCoin?: string; - limit?: number; - cursor?: string; -} +/** Required for Dual Assets quote. */ ⋮---- -export interface SetLeverageParamsV5 { - category: 'linear' | 'inverse'; - symbol: string; - buyLeverage: string; - sellLeverage: string; +export interface AdvanceEarnDiscountBuyExtraV5 { + initialPrice: string; + purchasePrice: string; + knockoutPrice: string; + knockoutCouponE8: string; + settleType: 'Base' | 'Quote'; + instUid: string; } ⋮---- -export interface SwitchIsolatedMarginParamsV5 { - category: 'linear' | 'inverse'; - symbol: string; - tradeMode: 0 | 1; - buyLeverage: string; - sellLeverage: string; +export interface AdvanceEarnDualAssetsExtraV5 { + orderDirection: 'BuyLow' | 'SellHigh'; + selectPrice: string; + /** Expected APY in e8 precision; API may return int. */ + apyE8: string | number; } ⋮---- -export interface SetTPSLModeParamsV5 { - category: 'linear' | 'inverse'; - symbol: string; - tpSlMode: TPSLModeV5; -} +/** Expected APY in e8 precision; API may return int. */ ⋮---- -export interface SwitchPositionModeParamsV5 { - category: 'linear' | 'inverse'; - symbol?: string; - coin?: string; - mode: 0 | 3; +export interface AdvanceEarnInterestCardExtraV5 { + awardId: string | number; + specCode: string; } ⋮---- -export interface SetRiskLimitParamsV5 { - category: 'linear' | 'inverse'; - symbol: string; - riskId: number; - positionIdx?: PositionIdx; +/** + * POST /v5/earn/advance/place-order — Discount Buy + */ +export interface SubmitAdvanceEarnPlaceOrderDiscountBuyV5 { + category: 'DiscountBuy'; + productId: string; + orderType: 'Stake'; + amount: string; + coin: string; + accountType: 'FUND' | 'UNIFIED'; + orderLinkId: string; + discountBuyExtra: AdvanceEarnDiscountBuyExtraV5; } ⋮---- -export interface SetTradingStopParamsV5 { - category: CategoryV5; - symbol: string; - takeProfit?: string; - stopLoss?: string; - trailingStop?: string; - tpTriggerBy?: OrderTriggerByV5; - slTriggerBy?: OrderTriggerByV5; - activePrice?: string; - tpslMode?: TPSLModeV5; - tpSize?: string; - slSize?: string; - tpLimitPrice?: string; - slLimitPrice?: string; - tpOrderType?: OrderTypeV5; - slOrderType?: OrderTypeV5; - positionIdx: PositionIdx; +/** + * POST /v5/earn/advance/place-order — Dual Assets + */ +export interface SubmitAdvanceEarnPlaceOrderDualAssetsV5 { + category: 'DualAssets'; + productId: string; + orderType: 'Stake'; + amount: string; + coin: string; + accountType: 'FUND' | 'UNIFIED'; + orderLinkId: string; + dualAssetsExtra: AdvanceEarnDualAssetsExtraV5; + interestCard?: AdvanceEarnInterestCardExtraV5; } ⋮---- -export interface SetAutoAddMarginParamsV5 { - category: 'linear'; - symbol: string; - autoAddMargin: 0 | 1; - positionIdx?: PositionIdx; -} +export type SubmitAdvanceEarnPlaceOrderParamsV5 = + | SubmitAdvanceEarnPlaceOrderDiscountBuyV5 + | SubmitAdvanceEarnPlaceOrderDualAssetsV5; ⋮---- -export interface AddOrReduceMarginParamsV5 { - category: 'linear' | 'inverse'; - symbol: string; - margin: string; - positionIDex?: PositionIdx; +export interface GetAdvanceEarnPositionListParamsV5 { + category: 'DiscountBuy' | 'DualAssets' | string; + productId?: string; + coin?: string; + limit?: number; + cursor?: string; } ⋮---- -export interface GetExecutionListParamsV5 { - category: CategoryV5; - symbol?: string; +export interface GetAdvanceEarnOrderListParamsV5 { + category: 'DiscountBuy' | 'DualAssets' | string; orderId?: string; orderLinkId?: string; - baseCoin?: string; - settleCoin?: string; // Settle coin, uppercase only. For linear, inverse, option - startTime?: number; - endTime?: number; - execType?: ExecTypeV5; + productId?: string; + /** Dual Assets docs use string ms; other categories may use number. */ + startTime?: string | number; + endTime?: string | number; limit?: number; cursor?: string; } ⋮---- -settleCoin?: string; // Settle coin, uppercase only. For linear, inverse, option -⋮---- -export interface GetClosedPnLParamsV5 { - category: CategoryV5; - symbol?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; +/** Dual Assets docs use string ms; other categories may use number. */ + +================ +File: src/types/request/v5-earn-fixed-term.ts +================ +/** + * /v5/earn/fixed-term/* + */ +export interface GetFixedTermEarnProductParamsV5 { + coin?: string; } ⋮---- -export interface MovePositionParamsV5 { - fromUid: string; - toUid: string; - list: { - category: 'linear' | 'spot' | 'option' | 'inverse'; - symbol: string; - price: string; - side: 'Buy' | 'Sell'; - qty: string; - }[]; +export interface SubmitFixedTermEarnOrderParamsV5 { + productId: string; + category: 'FixedTermSaving' | 'FundPool' | 'FundPoolPremium'; + coin: string; + amount: string; + accountType: 'FUND' | 'UNIFIED'; + orderLinkId: string; + autoInvest?: boolean; } ⋮---- -export interface GetMovePositionHistoryParamsV5 { - category?: 'linear' | 'spot' | 'option'; - symbol?: string; - startTime?: number; - endTime?: number; - status?: 'Processing' | 'Filled' | 'Rejected'; - blockTradeId?: string; - limit?: string; - cursor?: string; +export interface RedeemFixedTermEarnParamsV5 { + productId: string; + /** Early redemption: FundPool only */ + category: 'FundPool'; + positionId: string; } ⋮---- -export interface ConfirmNewRiskLimitParamsV5 { - category: 'linear' | 'inverse'; - symbol: string; +/** Early redemption: FundPool only */ +⋮---- +export interface GetFixedTermEarnPositionParamsV5 { + productId?: string; + category?: 'FixedTermSaving' | 'FundPool' | 'FundPoolPremium'; + coin?: string; } ⋮---- -export interface GetClosedOptionsPositionsParamsV5 { - category: 'option'; - symbol?: string; +export interface GetFixedTermEarnOrderListParamsV5 { + orderType?: 'Stake' | 'Redeem' | 'Reinvest'; + productId?: string; + category?: 'FixedTermSaving' | 'FundPool' | 'FundPoolPremium'; + orderId?: string; startTime?: number; endTime?: number; limit?: number; cursor?: string; } +⋮---- +export interface SetFixedTermEarnAutoInvestParamsV5 { + productId: string; + category: 'FixedTermSaving' | 'FundPool' | 'FundPoolPremium'; + positionId: string; + status: 'Enable' | 'Disable'; +} ================ -File: src/types/request/v5-rfq.ts +File: src/types/request/v5-earn-pwm.ts ================ -export interface RFQTransactionV5 { - category: 'spot' | 'linear' | 'inverse' | 'option'; // Product type - symbol: string; // Name of the trading contract - side: 'buy' | 'sell'; // Inquiry transaction direction - qty: string; // Transaction quantity - isLeverage?: boolean; // For spot lending, default false +/** GET /v5/earn/pwm/investment-plan/detail */ +export interface GetPwmInvestmentPlanDetailParamsV5 { + planId: string; } ⋮---- -category: 'spot' | 'linear' | 'inverse' | 'option'; // Product type -symbol: string; // Name of the trading contract -side: 'buy' | 'sell'; // Inquiry transaction direction -qty: string; // Transaction quantity -isLeverage?: boolean; // For spot lending, default false -⋮---- -export interface RFQHedgeLegV5 { - category: string; - symbol: string; - side: string; - qty: string; - price?: string; +/** GET /v5/earn/pwm/investment-plan/new-plan */ +export interface GetPwmPendingInvestmentPlanDetailParamsV5 { + planId: string; } ⋮---- -export interface CreateRFQParamsV5 { - counterparties: string[]; // Array of deskCode - rfqLinkId?: string; // Custom ID for inquiry form, 1-32 characters - anonymous?: boolean; // Whether it is anonymous inquiry, default false - strategyType?: string; // Inquiry label, max 36 characters - list: RFQTransactionV5[]; // Transaction list, up to 10 sets - hedge?: RFQHedgeLegV5[]; +/** POST /v5/earn/pwm/investment-plan/claim */ +export interface ClaimPwmWithdrawableFundsParamsV5 { + planId: string; + /** Default: FUND */ + toAccountType?: string; + orderLinkId: string; } ⋮---- -counterparties: string[]; // Array of deskCode -rfqLinkId?: string; // Custom ID for inquiry form, 1-32 characters -anonymous?: boolean; // Whether it is anonymous inquiry, default false -strategyType?: string; // Inquiry label, max 36 characters -list: RFQTransactionV5[]; // Transaction list, up to 10 sets +/** Default: FUND */ ⋮---- -export interface CancelRFQParamsV5 { - rfqId?: string; // Inquiry ID - rfqLinkId?: string; // Inquiry Custom ID +/** GET /v5/earn/pwm/investment-plan/asset-trend */ +export interface GetPwmInvestmentPlanAssetTrendParamsV5 { + planId: string; + startTime?: number; + endTime?: number; } ⋮---- -rfqId?: string; // Inquiry ID -rfqLinkId?: string; // Inquiry Custom ID +/** GET /v5/earn/pwm/investment-plan/fund-nav */ +export interface GetPwmFundHistoricalNavParamsV5 { + fundId: string; + startTime?: number; + endTime?: number; +} ⋮---- -export interface RFQQuoteV5 { - category: 'spot' | 'linear' | 'option'; // Product type - symbol: string; // Name of the trading contract - price: string; // Quote price - isLeverage?: boolean; // For spot lending, default false +/** POST /v5/earn/pwm/investment-plan/subscribe */ +export interface SubscribePwmInvestmentPlanParamsV5 { + planId: string; + /** Default: FUND */ + accountType?: string; + orderLinkId: string; } ⋮---- -category: 'spot' | 'linear' | 'option'; // Product type -symbol: string; // Name of the trading contract -price: string; // Quote price -isLeverage?: boolean; // For spot lending, default false +/** Default: FUND */ ⋮---- -export interface CreateRFQQuoteParamsV5 { - rfqId: string; // Inquiry ID - quoteLinkId?: string; // Quotation custom ID, 1-32 characters - anonymous?: boolean; // Whether it is anonymous quotation, default false - expiresIn?: number; // Validity period in seconds, default 60 - quoteBuyList?: RFQQuoteV5[]; // Quotation buy direction - quoteSellList?: RFQQuoteV5[]; // Quotation sell direction +/** POST /v5/earn/pwm/investment-plan/invest-more */ +export interface InvestMorePwmInvestmentPlanParamsV5 { + planId: string; + /** Default: FUND */ + accountType?: string; + category: string; + productId: string; + amount: string; + orderLinkId: string; } ⋮---- -rfqId: string; // Inquiry ID -quoteLinkId?: string; // Quotation custom ID, 1-32 characters -anonymous?: boolean; // Whether it is anonymous quotation, default false -expiresIn?: number; // Validity period in seconds, default 60 -quoteBuyList?: RFQQuoteV5[]; // Quotation buy direction -quoteSellList?: RFQQuoteV5[]; // Quotation sell direction +/** Default: FUND */ ⋮---- -export interface ExecuteRFQQuoteParamsV5 { - rfqId: string; // Inquiry ID - quoteId: string; // Quotation ID - quoteSide: 'buy' | 'sell'; // The direction of the quote - isHedge?: boolean; +/** POST /v5/earn/pwm/investment-plan/redeem */ +export interface RedeemPwmInvestmentPlanParamsV5 { + planId: string; + category: string; + productId: string; + orderLinkId: string; + /** Required for fund products */ + shares?: string; + /** Required for non-fund products */ + amount?: string; + /** Required for FundPool and On-chain Earn */ + positionId?: string; } ⋮---- -rfqId: string; // Inquiry ID -quoteId: string; // Quotation ID -quoteSide: 'buy' | 'sell'; // The direction of the quote +/** Required for fund products */ ⋮---- -export interface GetRFQDetailsParamsV5 { - rfqId?: string; - rfqLinkId?: string; - status?: - | 'Active' - | 'PendingFill' - | 'Canceled' - | 'Filled' - | 'Expired' - | 'Failed'; - traderType?: 'quote' | 'request'; - startTime?: number; - endTime?: number; +/** Required for non-fund products */ +⋮---- +/** Required for FundPool and On-chain Earn */ +⋮---- +/** GET /v5/earn/pwm/investment-plan/order */ +export interface GetPwmInvestmentPlanOrdersParamsV5 { + planId?: string; + category?: string; + type?: 'Subscribe' | 'Redeem' | 'AutoReinvest' | string; + status?: 'Completed' | 'Pending' | 'Failed' | string; + startTime?: string; + endTime?: string; limit?: number; cursor?: string; + orderLinkId?: string; } ⋮---- -export interface CancelRFQQuoteParamsV5 { - quoteId?: string; // Quotation ID - rfqId?: string; // Inquiry ID - quoteLinkId?: string; // Quotation Custom ID +/** POST /v5/earn/pwm/customize-plan/create */ +export interface CreatePwmCustomizeInvestmentPlanProductV5 { + category: string; + productId: string; + fundName: string; + amount: string; } ⋮---- -quoteId?: string; // Quotation ID -rfqId?: string; // Inquiry ID -quoteLinkId?: string; // Quotation Custom ID -⋮---- -export interface GetRFQRealtimeParamsV5 { - rfqId?: string; // Inquiry ID - rfqLinkId?: string; // Inquiry Custom ID - traderType?: 'quote' | 'request'; // Trader type, default 'request' +export interface CreatePwmCustomizeInvestmentPlanParamsV5 { + accountType?: string; + products: CreatePwmCustomizeInvestmentPlanProductV5[]; } ⋮---- -rfqId?: string; // Inquiry ID -rfqLinkId?: string; // Inquiry Custom ID -traderType?: 'quote' | 'request'; // Trader type, default 'request' -⋮---- -export interface GetRFQListParamsV5 { - rfqId?: string; // Inquiry ID - rfqLinkId?: string; // Custom ID for inquiry form - traderType?: 'quoter' | 'request'; // Trader type, default 'request' - status?: - | 'Active' - | 'Canceled' - | 'PendingFill' - | 'Filled' - | 'Expired' - | 'Failed'; // Status of the inquiry form - limit?: number; // Return number of items, max 100, default 50 - cursor?: string; // Page turning mark +/** GET /v5/earn/pwm/asset-manager/all-funds */ +export interface GetPwmAllFundsParamsV5 { + coin?: string; + fundId?: string; + status?: string; + limit?: number; + cursor?: string; } ⋮---- -rfqId?: string; // Inquiry ID -rfqLinkId?: string; // Custom ID for inquiry form -traderType?: 'quoter' | 'request'; // Trader type, default 'request' -⋮---- -| 'Failed'; // Status of the inquiry form -limit?: number; // Return number of items, max 100, default 50 -cursor?: string; // Page turning mark +/** POST /v5/earn/pwm/asset-manager/settle-profit */ +export interface SettlePwmFundProfitParamsV5 { + fundId: string; + reqLinkId: string; +} ⋮---- -export interface GetRFQQuoteRealtimeParamsV5 { - rfqId?: string; // Inquiry ID - quoteId?: string; // Quotation ID - quoteLinkId?: string; // Quotation Custom ID - traderType?: 'quote' | 'request'; // Trader type, default 'quote' +/** POST /v5/earn/pwm/asset-manager/create-fund */ +export interface CreatePwmFundParamsV5 { + fundName: string; + coin: string; + profitShareRate: string; + managementFeeRate: string; + fundIntroduction?: string; + reqLinkId: string; } ⋮---- -rfqId?: string; // Inquiry ID -quoteId?: string; // Quotation ID -quoteLinkId?: string; // Quotation Custom ID -traderType?: 'quote' | 'request'; // Trader type, default 'quote' +/** POST /v5/earn/pwm/asset-manager/create-investment-plan */ +export interface CreatePwmAssetManagerInvestmentPlanDistributionV5 { + productId: string; + amount: string; +} ⋮---- -export interface GetRFQHistoryParamsV5 { - rfqId?: string; // Inquiry ID - quoteId?: string; // Quotation ID - quoteLinkId?: string; // Quotation custom ID, can only check last 3 months - traderType?: 'quote' | 'request'; // Trader type, default 'quote' - status?: - | 'Active' - | 'Canceled' - | 'PendingFill' - | 'Filled' - | 'Expired' - | 'Failed'; // Status of quotation - limit?: number; // Return number of items, max 100, default 50 - cursor?: string; // Page turning mark +export interface CreatePwmAssetManagerInvestmentPlanParamsV5 { + accountUid: string; + planName: string; + planType: 'stable' | 'advanced' | string; + investmentDistribution: CreatePwmAssetManagerInvestmentPlanDistributionV5[]; + reqLinkId: string; } ⋮---- -rfqId?: string; // Inquiry ID -quoteId?: string; // Quotation ID -quoteLinkId?: string; // Quotation custom ID, can only check last 3 months -traderType?: 'quote' | 'request'; // Trader type, default 'quote' +/** GET /v5/earn/pwm/asset-manager/get-investment-plan */ +export interface GetPwmAssetManagerInvestmentPlansParamsV5 { + planId?: string; + status?: string; + subscriptionUid?: string; + limit?: number; + cursor?: string; +} ⋮---- -| 'Failed'; // Status of quotation -limit?: number; // Return number of items, max 100, default 50 -cursor?: string; // Page turning mark +/** POST /v5/earn/pwm/asset-manager/manage-investment-plan */ +export interface ManagePwmAssetManagerInvestmentPlanFundV5 { + fundId: string; + amount: string; +} ⋮---- -export interface GetRFQTradeListParamsV5 { - rfqId?: string; // Inquiry ID - rfqLinkId?: string; // Custom ID for inquiry form, can only check last 3 months - quoteId?: string; // Quotation ID - quoteLinkId?: string; // Quotation custom ID, can only check last 3 months - status?: 'Filled' | 'Rejected'; // Status - limit?: number; // Return number of items, max 100, default 50 - cursor?: string; // Page turning mark +export interface ManagePwmAssetManagerInvestmentPlanParamsV5 { + planId: string; + updateStatus?: 'Closed' | 'Deleted' | string; + updateFunds?: ManagePwmAssetManagerInvestmentPlanFundV5[]; + reqLinkId: string; } ⋮---- -rfqId?: string; // Inquiry ID -rfqLinkId?: string; // Custom ID for inquiry form, can only check last 3 months -quoteId?: string; // Quotation ID -quoteLinkId?: string; // Quotation custom ID, can only check last 3 months -status?: 'Filled' | 'Rejected'; // Status -limit?: number; // Return number of items, max 100, default 50 -cursor?: string; // Page turning mark +/** GET /v5/earn/pwm/asset-manager/all-order */ +export interface GetPwmAllFundOrdersParamsV5 { + fundId?: string; + orderType?: 'Subscribe' | 'Redeem' | string; + status?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; +} ⋮---- -export interface GetRFQPublicTradesParamsV5 { - startTime?: number; // Timestamp in milliseconds, time range is 7 days - endTime?: number; // Timestamp in milliseconds, time range is 7 days - limit?: number; // Return number of items, max 100, default 50 - cursor?: string; // Page turning mark +/** POST /v5/earn/pwm/asset-manager/manage-order */ +export interface ManagePwmFundOrderParamsV5 { + orderId: string; + action: 'approve' | 'reject' | string; + reqLinkId: string; } ⋮---- -startTime?: number; // Timestamp in milliseconds, time range is 7 days -endTime?: number; // Timestamp in milliseconds, time range is 7 days -limit?: number; // Return number of items, max 100, default 50 -cursor?: string; // Page turning mark +/** POST /v5/earn/pwm/asset-manager/create-sub-account */ +export interface CreatePwmFundSubAccountParamsV5 { + fundId: string; + reqLinkId: string; +} ⋮---- -export interface AcceptNonLPQuoteParamsV5 { - rfqId: string; // Inquiry ID +/** POST /v5/earn/pwm/fund-transfer */ +export interface PwmFundTransferParamsV5 { + transferId: string; + fromUserId: number; + toUserId: number; + amount: string; + coin: string; } ⋮---- -rfqId: string; // Inquiry ID +/** GET /v5/earn/pwm/query-fund-transfer-result */ +export interface GetPwmFundTransferRecordsParamsV5 { + transferId?: string; + fromUserId?: number; +} ================ -File: src/types/request/v5-rwa.ts +File: src/types/request/v5-earn-token.ts ================ /** - * V5 RWA (Real World Assets) earn requests. + * Earn token product (e.g. BYUSDT) — /v5/earn/token/* */ ⋮---- -export interface GetRWAProductListParamsV5 { - coin?: string; +export interface GetEarnTokenProductParamsV5 { + /** Currently only BYUSDT */ + coin: string; } ⋮---- -export interface PlaceRWAOrderParamsV5 { - productId: number; - orderType: 'Stake' | 'Redeem'; +/** Currently only BYUSDT */ +⋮---- +export interface PlaceEarnTokenOrderParamsV5 { coin: string; orderLinkId: string; - stakeAmount?: string; - redeemShares?: string; - accountType?: 'FUND' | 'UNIFIED'; + orderType: 'Mint' | 'Redeem'; + amount: string; + /** Mint: FlexibleSaving; Redeem: UNIFIED */ + accountType: 'FlexibleSaving' | 'UNIFIED'; } ⋮---- -export interface GetRWAOrderListParamsV5 { - orderId?: string; - orderLinkId?: string; - orderType?: 'Stake' | 'Redeem'; - productId?: number; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; -} +/** Mint: FlexibleSaving; Redeem: UNIFIED */ ⋮---- -export interface GetRWANavChartParamsV5 { - productId: number; +export interface GetEarnTokenOrderListParamsV5 { + coin: string; + orderLinkId?: string; + orderId?: string; + orderType?: 'Mint' | 'Redeem'; + /** seconds */ startTime?: number; + /** seconds */ endTime?: number; -} - -================ -File: src/types/request/v5-spot-x.ts -================ -export interface GetLaunchpoolProjectListParamsV5 { - status: number; - activityCoin?: string; - projectId?: string; cursor?: string; limit?: number; } ⋮---- -export interface GetLaunchpoolUserActivityLogParamsV5 { - stakeCoin?: string; - type?: number; - status?: number; - startTime?: string; - endTime?: string; - pageSize?: number; - current?: number; -} +/** seconds */ ⋮---- -export interface GetLaunchpoolUserHistoryParamsV5 { - stakeCoin?: string; - rewardCoin?: string; - startTime?: string; - endTime?: string; - pageSize?: number; - current?: number; +/** seconds */ +⋮---- +export interface GetEarnTokenPositionParamsV5 { + coin: string; } ⋮---- -export interface GetPuzzleProjectListParamsV5 { - status: number; - projectId?: string; - activityCoin?: string; +export interface GetEarnTokenDailyYieldParamsV5 { + coin: string; + startTime?: number; + endTime?: number; cursor?: string; limit?: number; } ⋮---- -export interface GetTokenSplashProjectListParamsV5 { - status: number; - projectId?: string; - activityCoin?: string; +export interface GetEarnTokenHourlyYieldParamsV5 { + coin: string; + startTime?: number; + endTime?: number; cursor?: string; limit?: number; } ⋮---- -export interface GetTokenSplashUserActivityParamsV5 { - projectId?: string; - activityCoin?: string; +export interface GetEarnTokenHistoryAprParamsV5 { + coin: string; + /** 1 = 7d, 2 = 30d, 3 = 180d */ + range: 1 | 2 | 3; } +⋮---- +/** 1 = 7d, 2 = 30d, 3 = 180d */ ================ -File: src/types/request/v5-spreadtrading.ts +File: src/types/request/v5-event.ts ================ -export interface GetSpreadInstrumentsInfoParamsV5 { +export interface GetEventInstrumentsInfoParamsV5 { symbol?: string; - baseCoin?: string; + status?: 'PreLaunch' | 'Trading' | 'Delivering' | 'Closed'; limit?: number; cursor?: string; } ⋮---- -/** GET /v5/spread/max-qty */ -export interface GetSpreadMaxQtyParamsV5 { - symbol: string; - /** 1: Buy, 2: Sell */ - side: '1' | '2'; - orderPrice: string; -} -⋮---- -/** 1: Buy, 2: Sell */ -⋮---- -export interface SubmitSpreadOrderParamsV5 { +export interface GetEventOrderbookParamsV5 { symbol: string; - side: 'Buy' | 'Sell'; - orderType: 'Limit' | 'Market'; - qty: string; - price: string; - orderLinkId: string; - timeInForce: 'IOC' | 'FOK' | 'GTC' | 'PostOnly'; } ⋮---- -export interface AmendSpreadOrderParamsV5 { - symbol: string; +export interface GetEventOrderHistoryParamsV5 { + symbol?: string; orderId?: string; orderLinkId?: string; - qty?: string; - price?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; } ⋮---- -export interface GetSpreadOpenOrdersParamsV5 { +export interface GetEventActiveOrdersParamsV5 { symbol?: string; - baseCoin?: string; orderId?: string; orderLinkId?: string; limit?: number; cursor?: string; } -export interface GetSpreadOrderHistoryParamsV5 { +⋮---- +export interface GetEventPositionInfoParamsV5 { symbol?: string; baseCoin?: string; + settleCoin?: string; + limit?: number; + cursor?: string; +} +⋮---- +export interface GetEventTradeHistoryParamsV5 { + symbol: string; orderId?: string; orderLinkId?: string; startTime?: number; @@ -6035,4088 +4493,4753 @@ export interface GetSpreadOrderHistoryParamsV5 { cursor?: string; } ⋮---- -export interface GetSpreadTradeHistoryParamsV5 { - symbol?: string; +export interface GetEventSettlementRecordsParamsV5 { + symbol: string; orderId?: string; - orderLinkId?: string; startTime?: number; endTime?: number; limit?: number; cursor?: string; } +⋮---- +export interface SubmitEventQuoteParamsV5 { + symbol: string; + orderLinkId: string; + grossPayoutRatio: string; + amount: string; +} +⋮---- +export interface CancelEventQuoteParamsV5 { + orderLinkId?: string; + orderId?: string; +} ================ -File: src/types/request/v5-strategy.ts +File: src/types/request/v5-p2p-trading.ts ================ -import { - OrderSideV5, - PositionIdx, - PovModeV5, - StrategyCategoryV5, - StrategyPreferV5, - StrategyTypeV5, -} from '../shared-v5'; +export interface GetP2PAccountCoinsBalanceParamsV5 { + memberId?: string; + accountType: string; + coin?: string; + withBonus?: 0 | 1; +} ⋮---- -/** POST /v5/strategy/create */ -export interface CreateStrategyOrderParamsV5 { - category: StrategyCategoryV5; - symbol: string; - side: OrderSideV5; - strategyType: StrategyTypeV5; - /** Total order quantity (coin). Either size or positionValue is required */ +export interface GetP2POnlineAdsParamsV5 { + tokenId: string; + currencyId: string; + side: '0' | '1'; // 0: buy; 1: sell + page?: string; size?: string; - /** Total order quantity (value). Either size or positionValue is required */ - positionValue?: string; - reduceOnly?: boolean; - positionIdx?: PositionIdx; - /** Spot leverage type. 0: normal, 1: borrow to trade (UTA_SPOT only) */ - leverageType?: 0 | 1; - /** TWAP / POV: total execution duration (seconds). Range [300, 86400]; TWAP must be divisible by interval */ - duration?: number; - /** TWAP / POV: sub-order placement interval (seconds) */ - interval?: 5 | 10 | 15 | 30 | 60 | 120; - /** TWAP: randomize each sub-order quantity by ±20% */ - isRandom?: boolean; - /** Advanced: activate when market price reaches this value */ - triggerPrice?: string; - /** Advanced: terminate when last traded price reaches this value */ - maxChasePrice?: string; - /** Limit chase: absolute distance from best bid/ask. Mutually exclusive with chasePercentE4 */ - chaseDistance?: string; - /** Limit chase: offset in basis points (1/10000). Mutually exclusive with chaseDistance */ - chasePercentE4?: number; - /** Chase / Iceberg: reference price side, e.g. Bid1, Ask1 */ - chasePrice?: string; - strategyPrefer?: StrategyPreferV5; - limitPrice?: string; - strategySl?: string; - strategyTp?: string; - /** Iceberg: 0 = taker allowed, 1 = post-only */ - postOnly?: 0 | 1; - isRebalance?: boolean; - /** 1: market, 2: limit */ - orderType?: 1 | 2; - orderPriceOffset?: string; - strategyName?: string; - /** POV execution mode */ - mode?: PovModeV5; - /** POV participation rate */ - participationRate?: string; - /** POV: historical traded volume window (seconds), range [60, 14400] */ - referenceWindow?: string; - /** POV: book depth reference levels [1, 10] */ - depthReference?: string; } ⋮---- -/** Total order quantity (coin). Either size or positionValue is required */ +side: '0' | '1'; // 0: buy; 1: sell ⋮---- -/** Total order quantity (value). Either size or positionValue is required */ +export interface P2PTradingPreferenceSetV5 { + hasUnPostAd?: 0 | 1; + isKyc?: 0 | 1; + isEmail?: 0 | 1; + isMobile?: 0 | 1; + hasRegisterTime?: 0 | 1; + registerTimeThreshold?: number; + orderFinishNumberDay30?: number; + completeRateDay30?: string; + nationalLimit?: string; + hasOrderFinishNumberDay30?: 0 | 1; + hasCompleteRateDay30?: 0 | 1; + hasNationalLimit?: 0 | 1; +} ⋮---- -/** Spot leverage type. 0: normal, 1: borrow to trade (UTA_SPOT only) */ +export interface CreateP2PAdParamsV5 { + tokenId: string; + currencyId: string; + side: '0' | '1'; // 0: buy; 1: sell + priceType: '0' | '1'; // 0: fixed rate; 1: floating rate + premium: string; + price: string; + minAmount: string; + maxAmount: string; + remark: string; + tradingPreferenceSet: P2PTradingPreferenceSetV5; + paymentIds: string[]; + quantity: string; + paymentPeriod: string; + itemType: 'ORIGIN' | 'BULK'; +} ⋮---- -/** TWAP / POV: total execution duration (seconds). Range [300, 86400]; TWAP must be divisible by interval */ +side: '0' | '1'; // 0: buy; 1: sell +priceType: '0' | '1'; // 0: fixed rate; 1: floating rate ⋮---- -/** TWAP / POV: sub-order placement interval (seconds) */ +export interface UpdateP2PAdParamsV5 { + id: string; + priceType: '0' | '1'; // 0: fixed rate; 1: floating rate + premium: string; + price: string; + minAmount: string; + maxAmount: string; + remark: string; + tradingPreferenceSet: P2PTradingPreferenceSetV5; + paymentIds: string[]; + actionType: 'MODIFY' | 'ACTIVE'; // MODIFY: modify adv; ACTIVE: reonline adv + quantity: string; + paymentPeriod: string; + itemType?: 'ORIGIN' | 'BULK'; + subsidyAd?: boolean; + securityRiskToken?: string; +} +⋮---- +priceType: '0' | '1'; // 0: fixed rate; 1: floating rate +⋮---- +actionType: 'MODIFY' | 'ACTIVE'; // MODIFY: modify adv; ACTIVE: reonline adv +⋮---- +export interface GetP2PPersonalAdsParamsV5 { + itemId?: string; + status?: '1' | '2'; // 1: Sold Out; 2: Available + side?: '0' | '1'; // 0: buy; 1: sell + tokenId?: string; + page?: string; + size?: string; + currencyId?: string; +} ⋮---- -/** TWAP: randomize each sub-order quantity by ±20% */ +status?: '1' | '2'; // 1: Sold Out; 2: Available +side?: '0' | '1'; // 0: buy; 1: sell ⋮---- -/** Advanced: activate when market price reaches this value */ +export interface GetP2POrdersParamsV5 { + status?: number; + beginTime?: string; + endTime?: string; + tokenId?: string; + side?: number[]; + page: number; + size: number; +} ⋮---- -/** Advanced: terminate when last traded price reaches this value */ +export interface GetP2PPendingOrdersParamsV5 { + status?: number; + beginTime?: string; + endTime?: string; + tokenId?: string; + side?: number[]; + page: number; + size: number; +} ⋮---- -/** Limit chase: absolute distance from best bid/ask. Mutually exclusive with chasePercentE4 */ +export interface MarkP2POrderAsPaidParamsV5 { + orderId: string; + paymentType: string; + paymentId: string; +} ⋮---- -/** Limit chase: offset in basis points (1/10000). Mutually exclusive with chaseDistance */ +export interface SendP2POrderMessageParamsV5 { + message: string; + contentType: string; + orderId: string; + msgUuid?: string; + fileName?: string; +} ⋮---- -/** Chase / Iceberg: reference price side, e.g. Bid1, Ask1 */ +export interface GetP2POrderMessagesParamsV5 { + orderId: string; + currentPage?: string; + size: string; +} ⋮---- -/** Iceberg: 0 = taker allowed, 1 = post-only */ +export interface GetP2PCounterpartyUserInfoParamsV5 { + originalUid: string; + orderId: string; +} ⋮---- -/** 1: market, 2: limit */ +export interface GetP2PChatSessionsParamsV5 { + /** Pagination cursor. Pass 0 for the first page. */ + lastId: number; + size: number; + /** 0: unread; 1: read; 2: all. */ + readStatus: 0 | 1 | 2; + type?: 'GROUP' | 'SINGLE'; +} ⋮---- -/** POV execution mode */ +/** Pagination cursor. Pass 0 for the first page. */ ⋮---- -/** POV participation rate */ +/** 0: unread; 1: read; 2: all. */ ⋮---- -/** POV: historical traded volume window (seconds), range [60, 14400] */ +export interface GetP2PChatSessionIdParamsV5 { + /** Counterparty mask ID from the order detail's targetUserMaskId. */ + userMaskId: string; +} ⋮---- -/** POV: book depth reference levels [1, 10] */ +/** Counterparty mask ID from the order detail's targetUserMaskId. */ ⋮---- -/** GET /v5/strategy/list */ -export interface GetStrategyListParamsV5 { - strategyId?: string; - symbol?: string; - /** 2: running, 3: terminated, 4: terminated unfilled, 5: paused, 6: untriggered */ - status?: '2' | '3' | '4' | '5' | '6'; - category?: StrategyCategoryV5; - strategyType?: StrategyTypeV5; - beginTimeE0?: number; - endTimeE0?: number; - pageSize?: number; - cursor?: string; +export interface SendP2PChatMessageParamsV5 { + /** Message content, up to 1000 characters. Use the uploaded URL for files. */ + message: string; + contentType: 'str' | 'pic' | 'pdf' | 'video'; + /** AES encrypted session ID. */ + sessionId: string; + orderId: string; } ⋮---- -/** 2: running, 3: terminated, 4: terminated unfilled, 5: paused, 6: untriggered */ +/** Message content, up to 1000 characters. Use the uploaded URL for files. */ ⋮---- -/** GET /v5/strategy/order-list */ -export interface GetStrategyOrderListParamsV5 { - strategyId: string; - /** 2: created, 3: create failed, 4: partially filled, 5: fully filled, 6: rejected, 7: canceled */ - status?: '2' | '3' | '4' | '5' | '6' | '7'; - symbol?: string; - strategyType?: StrategyTypeV5; - beginTimeE0?: number; - endTimeE0?: number; - pageSize?: number; - cursor?: string; +/** AES encrypted session ID. */ +⋮---- +export interface GetP2PChatMessagesParamsV5 { + /** Pagination cursor. Pass 0 to start from the latest message. */ + lastId: number; + /** Page size, up to 30. */ + limit: number; + /** AES encrypted session ID. */ + sessionId: string; } ⋮---- -/** 2: created, 3: create failed, 4: partially filled, 5: fully filled, 6: rejected, 7: canceled */ +/** Pagination cursor. Pass 0 to start from the latest message. */ ⋮---- -/** POST /v5/strategy/stop */ -export interface StopStrategyParamsV5 { - strategyId: string; -} +/** Page size, up to 30. */ +⋮---- +/** AES encrypted session ID. */ ================ -File: src/types/request/v5-trade.ts +File: src/types/request/v5-position.ts ================ import { CategoryV5, - OrderFilterV5, - OrderSideV5, - OrderSMPTypeV5, - OrderStatusV5, - OrderTimeInForceV5, + ExecTypeV5, OrderTriggerByV5, OrderTypeV5, PositionIdx, - StopOrderTypeV5, + TPSLModeV5, } from '../shared-v5'; ⋮---- -export interface OrderParamsV5 { +export interface GetFuturesLeverageParamsV5 { + category: 'linear' | 'inverse'; + symbol?: string; +} +⋮---- +export interface PositionInfoParamsV5 { category: CategoryV5; + symbol?: string; + baseCoin?: string; + settleCoin?: string; + limit?: number; + cursor?: string; +} +⋮---- +export interface SetLeverageParamsV5 { + category: 'linear' | 'inverse'; symbol: string; - isLeverage?: 0 | 1; - side: OrderSideV5; - orderType: OrderTypeV5; - qty: string; - marketUnit?: 'baseCoin' | 'quoteCoin'; - slippageToleranceType?: string; - slippageTolerance?: string; - price?: string; - triggerDirection?: 1 | 2; - orderFilter?: OrderFilterV5; - triggerPrice?: string; - triggerBy?: OrderTriggerByV5; - orderIv?: string; - timeInForce?: OrderTimeInForceV5; + buyLeverage: string; + sellLeverage: string; +} +⋮---- +export interface SwitchIsolatedMarginParamsV5 { + category: 'linear' | 'inverse'; + symbol: string; + tradeMode: 0 | 1; + buyLeverage: string; + sellLeverage: string; +} +⋮---- +export interface SetTPSLModeParamsV5 { + category: 'linear' | 'inverse'; + symbol: string; + tpSlMode: TPSLModeV5; +} +⋮---- +export interface SwitchPositionModeParamsV5 { + category: 'linear' | 'inverse'; + symbol?: string; + coin?: string; + mode: 0 | 3; +} +⋮---- +export interface SetRiskLimitParamsV5 { + category: 'linear' | 'inverse'; + symbol: string; + riskId: number; positionIdx?: PositionIdx; - orderLinkId?: string; +} +⋮---- +export interface SetTradingStopParamsV5 { + category: CategoryV5; + symbol: string; takeProfit?: string; stopLoss?: string; + trailingStop?: string; tpTriggerBy?: OrderTriggerByV5; slTriggerBy?: OrderTriggerByV5; - reduceOnly?: boolean; - closeOnTrigger?: boolean; - smpType?: OrderSMPTypeV5; - mmp?: boolean; - tpslMode?: 'Full' | 'Partial'; + activePrice?: string; + tpslMode?: TPSLModeV5; + tpSize?: string; + slSize?: string; tpLimitPrice?: string; slLimitPrice?: string; tpOrderType?: OrderTypeV5; slOrderType?: OrderTypeV5; - bboSideType?: 'Queue' | 'Counterparty'; - bboLevel?: '1' | '2' | '3' | '4' | '5'; - /** Limit IOC/FOK is supported when this is true. */ - rpiTakerAccess?: boolean; + positionIdx: PositionIdx; } ⋮---- -/** Limit IOC/FOK is supported when this is true. */ +export interface SetAutoAddMarginParamsV5 { + category: 'linear'; + symbol: string; + autoAddMargin: 0 | 1; + positionIdx?: PositionIdx; +} ⋮---- -export interface AmendOrderParamsV5 { - category: CategoryV5; +export interface AddOrReduceMarginParamsV5 { + category: 'linear' | 'inverse'; symbol: string; - orderId?: string; - orderLinkId?: string; - orderIv?: string; - triggerPrice?: string; - qty?: string; - price?: string; - tpslMode?: 'Full' | 'Partial'; - takeProfit?: string; - stopLoss?: string; - tpTriggerBy?: OrderTriggerByV5; - slTriggerBy?: OrderTriggerByV5; - triggerBy?: OrderTriggerByV5; - tpLimitPrice?: string; - slLimitPrice?: string; + margin: string; + positionIDex?: PositionIdx; } ⋮---- -export interface CancelOrderParamsV5 { +export interface GetExecutionListParamsV5 { category: CategoryV5; - symbol: string; + symbol?: string; orderId?: string; orderLinkId?: string; - orderFilter?: OrderFilterV5; + baseCoin?: string; + settleCoin?: string; // Settle coin, uppercase only. For linear, inverse, option + startTime?: number; + endTime?: number; + execType?: ExecTypeV5; + limit?: number; + cursor?: string; } ⋮---- -export interface GetAccountOrdersParamsV5 { +settleCoin?: string; // Settle coin, uppercase only. For linear, inverse, option +⋮---- +export interface GetClosedPnLParamsV5 { category: CategoryV5; symbol?: string; - baseCoin?: string; - settleCoin?: string; - orderId?: string; - orderLinkId?: string; - openOnly?: 0 | 1 | 2; - orderFilter?: OrderFilterV5; - orderStatus?: OrderStatusV5; + startTime?: number; + endTime?: number; limit?: number; cursor?: string; } ⋮---- -export interface GetAccountHistoricOrdersParamsV5 { - category: CategoryV5; +export interface MovePositionParamsV5 { + fromUid: string; + toUid: string; + list: { + category: 'linear' | 'spot' | 'option' | 'inverse'; + symbol: string; + price: string; + side: 'Buy' | 'Sell'; + qty: string; + }[]; +} +⋮---- +export interface GetMovePositionHistoryParamsV5 { + category?: 'linear' | 'spot' | 'option'; + symbol?: string; + startTime?: number; + endTime?: number; + status?: 'Processing' | 'Filled' | 'Rejected'; + blockTradeId?: string; + limit?: string; + cursor?: string; +} +⋮---- +export interface ConfirmNewRiskLimitParamsV5 { + category: 'linear' | 'inverse'; + symbol: string; +} +⋮---- +export interface GetClosedOptionsPositionsParamsV5 { + category: 'option'; symbol?: string; - baseCoin?: string; - settleCoin?: string; - orderId?: string; - orderLinkId?: string; - orderFilter?: OrderFilterV5; - orderStatus?: OrderStatusV5; startTime?: number; endTime?: number; limit?: number; cursor?: string; } -⋮---- -export interface CancelAllOrdersParamsV5 { - category: CategoryV5; - symbol?: string; - baseCoin?: string; - settleCoin?: string; - orderFilter?: OrderFilterV5; - stopOrderType?: StopOrderTypeV5; + +================ +File: src/types/request/v5-rfq.ts +================ +export interface RFQTransactionV5 { + category: 'spot' | 'linear' | 'inverse' | 'option'; // Product type + symbol: string; // Name of the trading contract + side: 'buy' | 'sell'; // Inquiry transaction direction + qty: string; // Transaction quantity + isLeverage?: boolean; // For spot lending, default false } ⋮---- -export interface BatchOrderParamsV5 { +category: 'spot' | 'linear' | 'inverse' | 'option'; // Product type +symbol: string; // Name of the trading contract +side: 'buy' | 'sell'; // Inquiry transaction direction +qty: string; // Transaction quantity +isLeverage?: boolean; // For spot lending, default false +⋮---- +export interface RFQHedgeLegV5 { + category: string; symbol: string; - side: OrderSideV5; - isLeverage?: 0 | 1; - orderType: OrderTypeV5; + side: string; qty: string; price?: string; - triggerDirection?: 1 | 2; - triggerBy?: OrderTriggerByV5; - orderIv?: string; - timeInForce?: OrderTimeInForceV5; - positionIdx?: PositionIdx; - orderLinkId?: string; - takeProfit?: string; - stopLoss?: string; - tpTriggerBy?: OrderTriggerByV5; - slTriggerBy?: OrderTriggerByV5; - reduceOnly?: boolean; - closeOnTrigger?: boolean; - smpType?: OrderSMPTypeV5; - mmp?: boolean; - tpslMode?: 'Full' | 'Partial'; - tpLimitPrice?: string; - slLimitPrice?: string; - tpOrderType?: OrderTypeV5; - slOrderType?: OrderTypeV5; } ⋮---- -export interface BatchAmendOrderParamsV5 { - symbol: string; - orderId?: string; - orderLinkId?: string; - orderIv?: string; - triggerPrice?: string; - qty?: string; - price?: string; - tpslMode?: 'Full' | 'Partial'; - takeProfit?: string; - stopLoss?: string; - tpTriggerBy?: OrderTriggerByV5; - slTriggerBy?: OrderTriggerByV5; - triggerBy?: OrderTriggerByV5; - tpLimitPrice?: string; - slLimitPrice?: string; +export interface CreateRFQParamsV5 { + counterparties: string[]; // Array of deskCode + rfqLinkId?: string; // Custom ID for inquiry form, 1-32 characters + anonymous?: boolean; // Whether it is anonymous inquiry, default false + strategyType?: string; // Inquiry label, max 36 characters + list: RFQTransactionV5[]; // Transaction list, up to 10 sets + hedge?: RFQHedgeLegV5[]; } ⋮---- -export interface BatchCancelOrderParamsV5 { - symbol: string; - orderId?: string; - orderLinkId?: string; -} - -================ -File: src/types/response/contract.ts -================ -/* eslint-disable @typescript-eslint/no-explicit-any */ -export interface PaginatedResult { - nextPageCursor: string; - list: TList[]; -} -export interface ContractListResult { - category: string; - list: TList[]; -} +counterparties: string[]; // Array of deskCode +rfqLinkId?: string; // Custom ID for inquiry form, 1-32 characters +anonymous?: boolean; // Whether it is anonymous inquiry, default false +strategyType?: string; // Inquiry label, max 36 characters +list: RFQTransactionV5[]; // Transaction list, up to 10 sets ⋮---- -export interface ContractHistoricOrder { - symbol: string; - orderId: string; - orderLinkId: string; - side: string; - orderType: string; - price: string; - iv: string; - qty: string; - timeInForce: string; - orderStatus: string; - positionIdx: number; - lastPriceOnCreated: string; - createdTime: string; - updatedTime: string; - cancelType: string; - rejectReason: string; - stopOrderType: string; - triggerDirection: number; - triggerBy: string; - triggerPrice: string; - cumExecValue: string; - cumExecFee: string; - cumExecQty: string; - leavesValue: string; - leavesQty: string; - takeProfit: string; - stopLoss: string; - tpslMode: string; - tpLimitPrice: string; - slLimitPrice: string; - tpTriggerBy: string; - slTriggerBy: string; - reduceOnly: boolean; - closeOnTrigger: boolean; - blockTradeId: string; - smpType: string; - smpGroup: string; - smpOrderId: string; +export interface CancelRFQParamsV5 { + rfqId?: string; // Inquiry ID + rfqLinkId?: string; // Inquiry Custom ID } ⋮---- -export interface ContractSymbolTicker { - symbol: string; - bidPrice: string; - askPrice: string; - lastPrice: string; - lastTickDirection: string; - prevPrice24h: string; - price24hPcnt: string; - highPrice24h: string; - lowPrice24h: string; - prevPrice1h: string; - markPrice: string; - indexPrice: string; - openInterest: string; - turnover24h: string; - volume24h: string; - fundingRate: string; - nextFundingTime: string; - predictedDeliveryPrice: string; - basisRate: string; - deliveryFeeRate: string; - deliveryTime: string; +rfqId?: string; // Inquiry ID +rfqLinkId?: string; // Inquiry Custom ID +⋮---- +export interface RFQQuoteV5 { + category: 'spot' | 'linear' | 'option'; // Product type + symbol: string; // Name of the trading contract + price: string; // Quote price + isLeverage?: boolean; // For spot lending, default false } - -================ -File: src/types/response/v5-alpha-lp.ts -================ -/** - * V5 private Alpha LP responses. - */ ⋮---- -export interface AlphaLPPoolV5 { - poolAddress: string; - poolName: string; - poolTag: string; - apy: string; - tvl: string; - token0Symbol: string; - token0IconUrlDay: string; - token0IconUrlNight: string; - token1Symbol: string; - token1IconUrlDay: string; - token1IconUrlNight: string; - chainCode: string; - chainIconUrl: string; +category: 'spot' | 'linear' | 'option'; // Product type +symbol: string; // Name of the trading contract +price: string; // Quote price +isLeverage?: boolean; // For spot lending, default false +⋮---- +export interface CreateRFQQuoteParamsV5 { + rfqId: string; // Inquiry ID + quoteLinkId?: string; // Quotation custom ID, 1-32 characters + anonymous?: boolean; // Whether it is anonymous quotation, default false + expiresIn?: number; // Validity period in seconds, default 60 + quoteBuyList?: RFQQuoteV5[]; // Quotation buy direction + quoteSellList?: RFQQuoteV5[]; // Quotation sell direction } ⋮---- -export interface AlphaLPPoolListResultV5 { - pools: AlphaLPPoolV5[]; +rfqId: string; // Inquiry ID +quoteLinkId?: string; // Quotation custom ID, 1-32 characters +anonymous?: boolean; // Whether it is anonymous quotation, default false +expiresIn?: number; // Validity period in seconds, default 60 +quoteBuyList?: RFQQuoteV5[]; // Quotation buy direction +quoteSellList?: RFQQuoteV5[]; // Quotation sell direction +⋮---- +export interface ExecuteRFQQuoteParamsV5 { + rfqId: string; // Inquiry ID + quoteId: string; // Quotation ID + quoteSide: 'buy' | 'sell'; // The direction of the quote + isHedge?: boolean; } ⋮---- -export interface AlphaLPPoolInfoV5 { - poolAddress: string; - poolName: string; - apy: string; - tvl: string; - feeRate: string; - token0Symbol: string; - token0Reserve: string; - token1Symbol: string; - token1Reserve: string; - priceRangeLower: string; - priceRangeUpper: string; - currentPrice: string; +rfqId: string; // Inquiry ID +quoteId: string; // Quotation ID +quoteSide: 'buy' | 'sell'; // The direction of the quote +⋮---- +export interface GetRFQDetailsParamsV5 { + rfqId?: string; + rfqLinkId?: string; + status?: + | 'Active' + | 'PendingFill' + | 'Canceled' + | 'Filled' + | 'Expired' + | 'Failed'; + traderType?: 'quote' | 'request'; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; } ⋮---- -export interface ExecuteAlphaLPStakeResultV5 { - positionId: number; - orderNo: string; +export interface CancelRFQQuoteParamsV5 { + quoteId?: string; // Quotation ID + rfqId?: string; // Inquiry ID + quoteLinkId?: string; // Quotation Custom ID } ⋮---- -export interface ExecuteAlphaLPRedeemResultV5 { - orderNo: string; -} +quoteId?: string; // Quotation ID +rfqId?: string; // Inquiry ID +quoteLinkId?: string; // Quotation Custom ID ⋮---- -export interface AlphaLPOrderV5 { - orderType: number; - orderNo: string; - orderStatus: number; - poolAddress: string; - poolName: string; - positionId: number; - tokenCode: string; - tokenSymbol: string; - tokenIconUrlDay: string; - tokenIconUrlNight: string; - amount: string; - chainCode: string; - chainIconUrl: string; - gasTokenSymbol: string; - gasOnchain: string; - gasUsd: string | null; - platformFee: string; - platformFeeUsd: string | null; - createTime: number; - executionTime: number; - failureReason?: string; - dercRatio?: string; +export interface GetRFQRealtimeParamsV5 { + rfqId?: string; // Inquiry ID + rfqLinkId?: string; // Inquiry Custom ID + traderType?: 'quote' | 'request'; // Trader type, default 'request' } ⋮---- -export interface AlphaLPOrderListResultV5 { - total: number; - pageIndex: number; - orders: AlphaLPOrderV5[]; -} +rfqId?: string; // Inquiry ID +rfqLinkId?: string; // Inquiry Custom ID +traderType?: 'quote' | 'request'; // Trader type, default 'request' ⋮---- -export interface AlphaLPPayTokenV5 { - tokenCode: string; - tokenSymbol: string; - chainCode: string; - chainIconUrl: string; - decimals: number; - availableBalance: string; - tokenIconUrlDay: string; - tokenIconUrlNight: string; - minStakeAmount: string; - maxStakeAmount: string; +export interface GetRFQListParamsV5 { + rfqId?: string; // Inquiry ID + rfqLinkId?: string; // Custom ID for inquiry form + traderType?: 'quoter' | 'request'; // Trader type, default 'request' + status?: + | 'Active' + | 'Canceled' + | 'PendingFill' + | 'Filled' + | 'Expired' + | 'Failed'; // Status of the inquiry form + limit?: number; // Return number of items, max 100, default 50 + cursor?: string; // Page turning mark } ⋮---- -export interface AlphaLPPayTokenListResultV5 { - tokens: AlphaLPPayTokenV5[]; -} +rfqId?: string; // Inquiry ID +rfqLinkId?: string; // Custom ID for inquiry form +traderType?: 'quoter' | 'request'; // Trader type, default 'request' ⋮---- -export interface AlphaLPPayTokenPriceV5 { - tokenCode: string; - tokenSymbol: string; - priceUsd: string; - chainCode: string; - updateTime: number; -} +| 'Failed'; // Status of the inquiry form +limit?: number; // Return number of items, max 100, default 50 +cursor?: string; // Page turning mark ⋮---- -export interface AlphaLPPayTokenPriceResultV5 { - prices: AlphaLPPayTokenPriceV5[]; +export interface GetRFQQuoteRealtimeParamsV5 { + rfqId?: string; // Inquiry ID + quoteId?: string; // Quotation ID + quoteLinkId?: string; // Quotation Custom ID + traderType?: 'quote' | 'request'; // Trader type, default 'quote' } ⋮---- -export interface AlphaLPPositionV5 { - positionId: number; - poolAddress: string; - poolName: string; - stakedAmount: string; - stakedTokenCode: string; - stakedTokenSymbol: string; - currentValueUsd: string; - earnedRewardsUsd: string; - unrealizedPnl: string; - realizedPnl: string; - apy: string; - token0Amount: string; - token0Symbol: string; - token1Amount: string; - token1Symbol: string; - rangeUpper: string; - rangeLower: string; - createTime: number; - updateTime: number; - status: number; -} +rfqId?: string; // Inquiry ID +quoteId?: string; // Quotation ID +quoteLinkId?: string; // Quotation Custom ID +traderType?: 'quote' | 'request'; // Trader type, default 'quote' ⋮---- -export interface AlphaLPPositionListResultV5 { - positions: AlphaLPPositionV5[]; +export interface GetRFQHistoryParamsV5 { + rfqId?: string; // Inquiry ID + quoteId?: string; // Quotation ID + quoteLinkId?: string; // Quotation custom ID, can only check last 3 months + traderType?: 'quote' | 'request'; // Trader type, default 'quote' + status?: + | 'Active' + | 'Canceled' + | 'PendingFill' + | 'Filled' + | 'Expired' + | 'Failed'; // Status of quotation + limit?: number; // Return number of items, max 100, default 50 + cursor?: string; // Page turning mark } - -================ -File: src/types/response/v5-alpha-prediction.ts -================ -/** - * V5 private Alpha prediction market responses. - */ ⋮---- -export interface AlphaPredictionEngineStatusV5 { - available: boolean; -} +rfqId?: string; // Inquiry ID +quoteId?: string; // Quotation ID +quoteLinkId?: string; // Quotation custom ID, can only check last 3 months +traderType?: 'quote' | 'request'; // Trader type, default 'quote' ⋮---- -export interface AlphaPredictionPayTokenV5 { - tokenCode: string; - symbol: string; - tokenDecimals: number; - tokenIconUrlDay: string; - tokenIconUrlNight: string; - supportChains: string[]; -} +| 'Failed'; // Status of quotation +limit?: number; // Return number of items, max 100, default 50 +cursor?: string; // Page turning mark ⋮---- -export interface AlphaPredictionMarketV5 { - tokenId: string; - outcome: string; - price: string; - side: number; - volume: string; - liquidity: string; +export interface GetRFQTradeListParamsV5 { + rfqId?: string; // Inquiry ID + rfqLinkId?: string; // Custom ID for inquiry form, can only check last 3 months + quoteId?: string; // Quotation ID + quoteLinkId?: string; // Quotation custom ID, can only check last 3 months + status?: 'Filled' | 'Rejected'; // Status + limit?: number; // Return number of items, max 100, default 50 + cursor?: string; // Page turning mark } ⋮---- -export interface AlphaPredictionEventDetailV5 { - eventId: string; - slug: string; - title: string; - description: string; - category: string; - endDate: number; - resolved: boolean; - volume: string; - liquidity: string; - markets: AlphaPredictionMarketV5[]; -} +rfqId?: string; // Inquiry ID +rfqLinkId?: string; // Custom ID for inquiry form, can only check last 3 months +quoteId?: string; // Quotation ID +quoteLinkId?: string; // Quotation custom ID, can only check last 3 months +status?: 'Filled' | 'Rejected'; // Status +limit?: number; // Return number of items, max 100, default 50 +cursor?: string; // Page turning mark ⋮---- -export interface AlphaPredictionOrderEstimateFeeDetailV5 { - serverFee: string; - polymarketFee: string; +export interface GetRFQPublicTradesParamsV5 { + startTime?: number; // Timestamp in milliseconds, time range is 7 days + endTime?: number; // Timestamp in milliseconds, time range is 7 days + limit?: number; // Return number of items, max 100, default 50 + cursor?: string; // Page turning mark } ⋮---- -export interface AlphaPredictionOrderEstimateV5 { - avgPrice: string; - estimatedCost: string; - estimatedReceive: string; - toWin?: string; - feeAmount: string; - feeDetail: AlphaPredictionOrderEstimateFeeDetailV5; - slippage: string; -} +startTime?: number; // Timestamp in milliseconds, time range is 7 days +endTime?: number; // Timestamp in milliseconds, time range is 7 days +limit?: number; // Return number of items, max 100, default 50 +cursor?: string; // Page turning mark ⋮---- -export interface ExecuteAlphaPredictionOrderResultV5 { - orderNo: string; +export interface AcceptNonLPQuoteParamsV5 { + rfqId: string; // Inquiry ID } ⋮---- -export interface AlphaPredictionOrderV5 { - orderNo: string; - tokenId: string; - eventId: string; - side: number; - orderType: number; - orderAmount: string; - filledSize: string; - filledPrice: string; - totalFee: string; - status: number; - createdAt: number; - updatedAt: number; -} +rfqId: string; // Inquiry ID + +================ +File: src/types/request/v5-rwa.ts +================ +/** + * V5 RWA (Real World Assets) earn requests. + */ ⋮---- -export interface AlphaPredictionOrderListResultV5 { - orders: AlphaPredictionOrderV5[]; - total: number; - pageIndex: number; +export interface GetRWAProductListParamsV5 { + coin?: string; } ⋮---- -export interface AlphaPredictionOrderBookLevelV5 { - price: string; - size: string; +export interface PlaceRWAOrderParamsV5 { + productId: number; + orderType: 'Stake' | 'Redeem'; + coin: string; + orderLinkId: string; + stakeAmount?: string; + redeemShares?: string; + accountType?: 'FUND' | 'UNIFIED'; } ⋮---- -export interface AlphaPredictionOrderBookV5 { - tokenId: string; - bids: AlphaPredictionOrderBookLevelV5[]; - asks: AlphaPredictionOrderBookLevelV5[]; +export interface GetRWAOrderListParamsV5 { + orderId?: string; + orderLinkId?: string; + orderType?: 'Stake' | 'Redeem'; + productId?: number; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; } ⋮---- -export interface AlphaPredictionTokenPriceV5 { - tokenId: string; - bestBid: string; - bestAsk: string; - lastPrice: string; - volume24h: string; - updateTime: number; +export interface GetRWANavChartParamsV5 { + productId: number; + startTime?: number; + endTime?: number; } -⋮---- -export interface AlphaPredictionPriceHistoryCandleV5 { - openTime: number; - open: string; - high: string; - low: string; - close: string; - volume: string; + +================ +File: src/types/request/v5-spot-x.ts +================ +export interface GetLaunchpoolProjectListParamsV5 { + status: number; + activityCoin?: string; + projectId?: string; + cursor?: string; + limit?: number; } ⋮---- -export interface AlphaPredictionPriceHistoryV5 { - tokenId: string; - interval: string; - list: AlphaPredictionPriceHistoryCandleV5[]; +export interface GetLaunchpoolUserActivityLogParamsV5 { + stakeCoin?: string; + type?: number; + status?: number; + startTime?: string; + endTime?: string; + pageSize?: number; + current?: number; } ⋮---- -export interface AlphaPredictionPositionV5 { - positionId: string; - tokenId: string; - eventId: string; - outcomeName: string; - shares: string; - cost: string; - avgPrice: string; - currentPrice: string; - value: string; - unrealizedPnl: string; - unrealizedPnlRate: string; - createdAt: number; - finished: boolean; +export interface GetLaunchpoolUserHistoryParamsV5 { + stakeCoin?: string; + rewardCoin?: string; + startTime?: string; + endTime?: string; + pageSize?: number; + current?: number; } ⋮---- -export interface AlphaPredictionPositionListResultV5 { - positions: AlphaPredictionPositionV5[]; - total: number; - totalAssetUsd: string; +export interface GetPuzzleProjectListParamsV5 { + status: number; + projectId?: string; + activityCoin?: string; + cursor?: string; + limit?: number; } ⋮---- -export interface AlphaPredictionPositionHistoryV5 { - positionId: string; - tokenId: string; - eventId: string; - outcomeName: string; - shares: string; - cost: string; - avgPrice: string; - exitPrice: string; - realizedPnl: string; - realizedPnlRate: string; - result: number; - closedAt: number; +export interface GetTokenSplashProjectListParamsV5 { + status: number; + projectId?: string; + activityCoin?: string; + cursor?: string; + limit?: number; } ⋮---- -export interface AlphaPredictionPositionHistoryResultV5 { - positions: AlphaPredictionPositionHistoryV5[]; - total: number; +export interface GetTokenSplashUserActivityParamsV5 { + projectId?: string; + activityCoin?: string; +} + +================ +File: src/types/request/v5-spreadtrading.ts +================ +export interface GetSpreadInstrumentsInfoParamsV5 { + symbol?: string; + baseCoin?: string; + limit?: number; + cursor?: string; } ⋮---- -export interface AlphaPredictionPortfolioSummaryV5 { - positionValue: string; - positionValueUsd: string; - biggestWin: string; - winRate: string; - winCount: number; - lossCount: number; +/** GET /v5/spread/max-qty */ +export interface GetSpreadMaxQtyParamsV5 { + symbol: string; + /** 1: Buy, 2: Sell */ + side: '1' | '2'; + orderPrice: string; } ⋮---- -export interface AlphaPredictionSideMarketTokenV5 { - tokenId: string; - outcome: string; +/** 1: Buy, 2: Sell */ +⋮---- +export interface SubmitSpreadOrderParamsV5 { + symbol: string; + side: 'Buy' | 'Sell'; + orderType: 'Limit' | 'Market'; + qty: string; price: string; - liquidity: string; + orderLinkId: string; + timeInForce: 'IOC' | 'FOK' | 'GTC' | 'PostOnly'; } ⋮---- -export interface AlphaPredictionSideMarketV5 { - marketId: string; - eventId: string; - marketType: number; - question: string; - tokens: AlphaPredictionSideMarketTokenV5[]; - volume24h: string; - endDate: number; - status: number; +export interface AmendSpreadOrderParamsV5 { + symbol: string; + orderId?: string; + orderLinkId?: string; + qty?: string; + price?: string; } ⋮---- -export interface AlphaPredictionSideMarketListResultV5 { - list: AlphaPredictionSideMarketV5[]; - total: number; - pageIndex: number; - pageSize: number; +export interface GetSpreadOpenOrdersParamsV5 { + symbol?: string; + baseCoin?: string; + orderId?: string; + orderLinkId?: string; + limit?: number; + cursor?: string; +} +export interface GetSpreadOrderHistoryParamsV5 { + symbol?: string; + baseCoin?: string; + orderId?: string; + orderLinkId?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; } ⋮---- -export interface AlphaPredictionSportsMatchV5 { - matchId: string; - eventType: number; - stageCode: string; - homeTeam: string; - awayTeam: string; - matchTime: number; - status: number; - eventId: string; +export interface GetSpreadTradeHistoryParamsV5 { + symbol?: string; + orderId?: string; + orderLinkId?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; +} + +================ +File: src/types/request/v5-strategy.ts +================ +import { + OrderSideV5, + PositionIdx, + PovModeV5, + StrategyCategoryV5, + StrategyPreferV5, + StrategyTypeV5, +} from '../shared-v5'; +⋮---- +/** POST /v5/strategy/create */ +export interface CreateStrategyOrderParamsV5 { + category: StrategyCategoryV5; + symbol: string; + side: OrderSideV5; + strategyType: StrategyTypeV5; + /** Total order quantity (coin). Either size or positionValue is required */ + size?: string; + /** Total order quantity (value). Either size or positionValue is required */ + positionValue?: string; + reduceOnly?: boolean; + positionIdx?: PositionIdx; + /** Spot leverage type. 0: normal, 1: borrow to trade (UTA_SPOT only) */ + leverageType?: 0 | 1; + /** TWAP / POV: total execution duration (seconds). Range [300, 86400]; TWAP must be divisible by interval */ + duration?: number; + /** TWAP / POV: sub-order placement interval (seconds) */ + interval?: 5 | 10 | 15 | 30 | 60 | 120; + /** TWAP: randomize each sub-order quantity by ±20% */ + isRandom?: boolean; + /** Advanced: activate when market price reaches this value */ + triggerPrice?: string; + /** Advanced: terminate when last traded price reaches this value */ + maxChasePrice?: string; + /** Limit chase: absolute distance from best bid/ask. Mutually exclusive with chasePercentE4 */ + chaseDistance?: string; + /** Limit chase: offset in basis points (1/10000). Mutually exclusive with chaseDistance */ + chasePercentE4?: number; + /** Chase / Iceberg: reference price side, e.g. Bid1, Ask1 */ + chasePrice?: string; + strategyPrefer?: StrategyPreferV5; + limitPrice?: string; + strategySl?: string; + strategyTp?: string; + /** Iceberg: 0 = taker allowed, 1 = post-only */ + postOnly?: 0 | 1; + isRebalance?: boolean; + /** 1: market, 2: limit */ + orderType?: 1 | 2; + orderPriceOffset?: string; + strategyName?: string; + /** POV execution mode */ + mode?: PovModeV5; + /** POV participation rate */ + participationRate?: string; + /** POV: historical traded volume window (seconds), range [60, 14400] */ + referenceWindow?: string; + /** POV: book depth reference levels [1, 10] */ + depthReference?: string; } ⋮---- -export interface AlphaPredictionSportsMatchListResultV5 { - list: AlphaPredictionSportsMatchV5[]; - total: number; - pageIndex: number; - pageSize: number; -} +/** Total order quantity (coin). Either size or positionValue is required */ ⋮---- -export interface AlphaPredictionSportsTimelineStageV5 { - stageCode: string; - stageName: string; - status: number; - matchCount: number; - startTime: number; - endTime: number; -} +/** Total order quantity (value). Either size or positionValue is required */ ⋮---- -export interface AlphaPredictionSportsTimelineStagesV5 { - eventType: number; - stages: AlphaPredictionSportsTimelineStageV5[]; -} +/** Spot leverage type. 0: normal, 1: borrow to trade (UTA_SPOT only) */ ⋮---- -export interface AlphaPredictionSportsGroupStandingV5 { - rank: number; - teamName: string; - played: number; - won: number; - drawn: number; - lost: number; - goalsFor: number; - goalsAgainst: number; - goalDifference: number; - points: number; -} +/** TWAP / POV: total execution duration (seconds). Range [300, 86400]; TWAP must be divisible by interval */ ⋮---- -export interface AlphaPredictionSportsGroupMatchV5 { - matchId: string; - homeTeam: string; - awayTeam: string; - matchTime: number; - status: number; - homeScore: number; - awayScore: number; - eventId: string; -} +/** TWAP / POV: sub-order placement interval (seconds) */ ⋮---- -export interface AlphaPredictionSportsGroupV5 { - groupName: string; - standings: AlphaPredictionSportsGroupStandingV5[]; - matches: AlphaPredictionSportsGroupMatchV5[]; -} +/** TWAP: randomize each sub-order quantity by ±20% */ ⋮---- -export interface AlphaPredictionSportsGroupStageDetailV5 { - groups: AlphaPredictionSportsGroupV5[]; -} - -================ -File: src/types/response/v5-alpha-trade.ts -================ -/** - * V5 private Alpha / on-chain (Web3) trade responses. - */ +/** Advanced: activate when market price reaches this value */ ⋮---- -export interface AlphaTradeQuoteModeEstimationV5 { - quoteMode: number; - estimatedGas: string; - estimatedGasUsd: string; - estimatedSlippage: string; -} +/** Advanced: terminate when last traded price reaches this value */ ⋮---- -export interface AlphaTradeQuoteResultV5 { - tradeType: number; - fromTokenCode: string; - fromTokenAmount: string; - fromTokenAmountUsd: string; - toTokenCode: string; - toTokenAmount: string; - toTokenAmountUsd: string; - minToTokenAmount: string; - slippage: string; - gas: string; - gasUsd: string; - platformFee: string; - platformFeeUsd: string; - swapRate: string; - lossRate: string; - quoteData: string; - correctingCode: string; - quoteMode: number; - quoteDataId: string; - expireTime: number; - modeEstimations: AlphaTradeQuoteModeEstimationV5[]; - chargeAmount?: string; - timestamp?: number; -} +/** Limit chase: absolute distance from best bid/ask. Mutually exclusive with chasePercentE4 */ ⋮---- -export interface ExecuteAlphaTradeResultV5 { - orderNo: string; -} +/** Limit chase: offset in basis points (1/10000). Mutually exclusive with chaseDistance */ ⋮---- -export interface AlphaPayTokenV5 { - tokenCode: string; - symbol: string; - tokenDecimals: number; - tokenIconUrlDay: string; - tokenIconUrlNight: string; - limit: string; - supportChains: string[]; -} +/** Chase / Iceberg: reference price side, e.g. Bid1, Ask1 */ ⋮---- -export interface AlphaTradeOrderV5 { - orderType: number; - tradeType: number; - orderNo: string; - orderStatus: number; - fromTokenCode: string; - fromTokenAmount: string; - fromTokenSymbol: string; - fromTokenDecimals: number; - fromTokenIconUrlDay?: string; - fromTokenIconUrlNight?: string; - fromChainCode: string; - fromChainIconUrl?: string; - toTokenCode: string; - toTokenAmount: string; - toTokenSymbol: string; - toTokenDecimals: number; - toTokenIconUrlDay?: string; - toTokenIconUrlNight?: string; - toChainCode: string; - toChainIconUrl?: string; - gasTokenSymbol: string; - gasOnchain: string; - gasUsd: string | null; - platformFee: string; - platformFeeUsd: string | null; - quoteMode: number; - createTime: number; - executionTime?: number; - failureReasonCode?: string; - source?: string; - swapRate: string; - actualFromTokenAmount: string; -} +/** Iceberg: 0 = taker allowed, 1 = post-only */ ⋮---- -export interface AlphaTradeOrderListResultV5 { - total: number; - pageIndex: number; - orders: AlphaTradeOrderV5[]; -} +/** 1: market, 2: limit */ ⋮---- -export interface AlphaBizTokenV5 { - tokenCode: string; - chainCode: string; - chainIconUrl: string; - tokenAddress: string; - symbol: string; - tokenDecimals: number; - tokenIconUrlDay: string; - tokenIconUrlNight: string; - createTime: number; - createTimeOnchain: number; - riskFlag: number; - minOrderQuantity: number; - maxOrderQuantity: number; - tokenTags: number[]; - payTokenCodes: string[]; -} +/** POV execution mode */ ⋮---- -export interface AlphaBizTokenPriceV5 { - chainCode: string; - tokenAddress: string; - price: string; - change24h: string; - vol24h: string; - marketCap: string; - liquidity: string; - holders: string; -} +/** POV participation rate */ ⋮---- -export interface AlphaBizTokenPriceListResultV5 { - tokenPriceInfoList: AlphaBizTokenPriceV5[]; -} +/** POV: historical traded volume window (seconds), range [60, 14400] */ ⋮---- -export interface AlphaBizTokenDetailsV5 { - tokenCode: string; - chainCode: string; - chainIconUrl: string; - tokenAddress: string; - symbol: string; - tokenDecimals: number; - tokenIconUrlDay: string; - tokenIconUrlNight: string; - minOrderQuantity: string; - maxOrderQuantity: string; - maxPositionQuantity: string; - tokenDesc: string; - xUrl: string; - officialUrl: string; - whitePaperUrl: string; - tokenTag: number; - riskFlag: number; - createTimeOnchain: number; - status: number; - tokenTags: number[]; - showMessage: number; - content?: string; - linkName?: string; - linkAddress?: string; -} +/** POV: book depth reference levels [1, 10] */ ⋮---- -export interface AlphaAssetV5 { - chainCode: string; - chainIconUrl: string; - tokenAddress: string; - tokenCode: string; - tokenSymbol: string; - tokenDecimals: number; - tokenIconUrlDay: string; - tokenIconUrlNight: string; - tokenAmount: string; - tokenAmountUsd: string; - tradeFlag: number; - pnl: string | null; - pnlRatio: string | null; - costPrice: string | null; - lastPrice: string; - costTotalValue: string | null; - assetStatus: number; - announcementUrl?: string; - estimatedOfflineTime?: number; - delistingTime?: number; +/** GET /v5/strategy/list */ +export interface GetStrategyListParamsV5 { + strategyId?: string; + symbol?: string; + /** 2: running, 3: terminated, 4: terminated unfilled, 5: paused, 6: untriggered */ + status?: '2' | '3' | '4' | '5' | '6'; + category?: StrategyCategoryV5; + strategyType?: StrategyTypeV5; + beginTimeE0?: number; + endTimeE0?: number; + pageSize?: number; + cursor?: string; } ⋮---- -export interface AlphaAssetListResultV5 { - totalAssetUsd: string; - assetList: AlphaAssetV5[]; +/** 2: running, 3: terminated, 4: terminated unfilled, 5: paused, 6: untriggered */ +⋮---- +/** GET /v5/strategy/order-list */ +export interface GetStrategyOrderListParamsV5 { + strategyId: string; + /** 2: created, 3: create failed, 4: partially filled, 5: fully filled, 6: rejected, 7: canceled */ + status?: '2' | '3' | '4' | '5' | '6' | '7'; + symbol?: string; + strategyType?: StrategyTypeV5; + beginTimeE0?: number; + endTimeE0?: number; + pageSize?: number; + cursor?: string; } ⋮---- -export interface AlphaAssetDetailResultV5 { - assetList: AlphaAssetV5[]; +/** 2: created, 3: create failed, 4: partially filled, 5: fully filled, 6: rejected, 7: canceled */ +⋮---- +/** POST /v5/strategy/stop */ +export interface StopStrategyParamsV5 { + strategyId: string; } ================ -File: src/types/response/v5-broker.ts +File: src/types/response/contract.ts ================ -interface EarningDetailV5 { - userId: string; - bizType: 'SPOT' | 'DERIVATIVES' | 'OPTIONS' | 'CONVERT' | 'FIAT_CONVERT'; - symbol: string; - coin: string; - earning: string; - markupEarning: string; - baseFeeEarning: string; - orderId: string; - execTime: string; -} -⋮---- -interface TotalEarningCategoryV5 { - coin: string; - earning: string; -} -⋮---- -export interface ExchangeBrokerEarningResultV5 { - totalEarningCat: { - spot: TotalEarningCategoryV5[]; - derivatives: TotalEarningCategoryV5[]; - options: TotalEarningCategoryV5[]; - convert: TotalEarningCategoryV5[]; - fiatConvert?: TotalEarningCategoryV5[]; - total: TotalEarningCategoryV5[]; - }; - details: EarningDetailV5[]; +/* eslint-disable @typescript-eslint/no-explicit-any */ +export interface PaginatedResult { nextPageCursor: string; + list: TList[]; } -⋮---- -export interface ExchangeBrokerAccountInfoV5 { - subAcctQty: string; - maxSubAcctQty: string; - baseFeeRebateRate: { - spot: string; - derivatives: string; - }; - markupFeeRebateRate: { - spot: string; - derivatives: string; - convert: string; - }; - ts: string; -} -⋮---- -export interface ExchangeBrokerSubAccountDepositRecordV5 { - id: string; - subMemberId: string; - coin: string; - chain: string; - amount: string; - txID: string; - status: number; - toAddress: string; - tag: string; - depositFee: string; - successAt: string; - confirmations: string; - txIndex: string; - blockHash: string; - batchReleaseLimit: string; - depositType: string; -} -⋮---- -export interface BrokerVoucherSpecV5 { - id: string; - coin: string; - amountUnit: 'AWARD_AMOUNT_UNIT_USD' | 'AWARD_AMOUNT_UNIT_COIN'; - productLine: string; - subProductLine: string; - totalAmount: { - [key: string]: string; - }; - usedAmount: string; -} -⋮---- -export interface BrokerIssuedVoucherV5 { - accountId: string; - awardId: string; - specCode: string; - amount: string; - isClaimed: boolean; - startAt: string; - endAt: string; - effectiveAt: string; - ineffectiveAt: string; - usedAmount: string; -} -⋮---- -export interface BrokerRateLimitSetResultItemV5 { - uids: string; - bizType: string; - rate: number; - success: boolean; - msg: string; +export interface ContractListResult { + category: string; + list: TList[]; } ⋮---- -export interface BrokerRateLimitCapItemV5 { - bizType: string; - totalRate: string; - ebCap: string; - uidCap: string; +export interface ContractHistoricOrder { + symbol: string; + orderId: string; + orderLinkId: string; + side: string; + orderType: string; + price: string; + iv: string; + qty: string; + timeInForce: string; + orderStatus: string; + positionIdx: number; + lastPriceOnCreated: string; + createdTime: string; + updatedTime: string; + cancelType: string; + rejectReason: string; + stopOrderType: string; + triggerDirection: number; + triggerBy: string; + triggerPrice: string; + cumExecValue: string; + cumExecFee: string; + cumExecQty: string; + leavesValue: string; + leavesQty: string; + takeProfit: string; + stopLoss: string; + tpslMode: string; + tpLimitPrice: string; + slLimitPrice: string; + tpTriggerBy: string; + slTriggerBy: string; + reduceOnly: boolean; + closeOnTrigger: boolean; + blockTradeId: string; + smpType: string; + smpGroup: string; + smpOrderId: string; } ⋮---- -export interface BrokerRateLimitAllItemV5 { - uids: string; - bizType: string; - rate: number; +export interface ContractSymbolTicker { + symbol: string; + bidPrice: string; + askPrice: string; + lastPrice: string; + lastTickDirection: string; + prevPrice24h: string; + price24hPcnt: string; + highPrice24h: string; + lowPrice24h: string; + prevPrice1h: string; + markPrice: string; + indexPrice: string; + openInterest: string; + turnover24h: string; + volume24h: string; + fundingRate: string; + nextFundingTime: string; + predictedDeliveryPrice: string; + basisRate: string; + deliveryFeeRate: string; + deliveryTime: string; } ================ -File: src/types/response/v5-card.ts +File: src/types/response/v5-alpha-lp.ts ================ -export interface CardAssetRecordV5 { - pan4: string; - pan6: string; - tradeStatus: string; - side: string; - basicAmount: string; - basicCurrency: string; - transactionAmount: string; - transactionCurrency: string; - txnCreate: number; - merchCountry: string; - merchCity: string; - merchName: string; - txnId: string; - declinedReason: string; - totalFees: string; - uid: number; - transactionCurrencyAmount: string; - fxPad: string; - interchangeFee: string; - billAmount: string; - paidAmount: string; - paidCurrency: string; - bonusAmount: string; - foreignTransactionFee: string; - totalTax: string; - paidFiat: string; - withdrawalFee: string; - status: string; - orderNo: string; - mccCode: string; - merchCategoryDesc: string; -} +/** + * V5 private Alpha LP responses. + */ ⋮---- -export interface CardAssetRecordsResultV5 { - pageSize: number; - pageNo: number; - totalCount: number; - data: CardAssetRecordV5[]; +export interface AlphaLPPoolV5 { + poolAddress: string; + poolName: string; + poolTag: string; + apy: string; + tvl: string; + token0Symbol: string; + token0IconUrlDay: string; + token0IconUrlNight: string; + token1Symbol: string; + token1IconUrlDay: string; + token1IconUrlNight: string; + chainCode: string; + chainIconUrl: string; } ⋮---- -export interface CardPointBalanceV5 { - accountId: string; - availablePoint: string | number; - pendingPoint: string | number; - status: string; - updateTime: string | number; - settlementPeriod: number; +export interface AlphaLPPoolListResultV5 { + pools: AlphaLPPoolV5[]; } ⋮---- -export interface CardPointRecordV5 { - outOrderId: string; - point: number; - side: string; - type: string; - subType: string; - createTime: number; - updateTime: number; - bizId: string; - bizTxnId: string; - transactionDate: string; - transactionId: string; - transactionAmount: string; - basicCurrency: string; - merchCategoryDesc: string; - merchName: string; - merchCountry: string; - merchCity: string; - pan4: string; - payFiatAmount: string; - transactionCurrencyAmount: string; +export interface AlphaLPPoolInfoV5 { + poolAddress: string; + poolName: string; + apy: string; + tvl: string; + feeRate: string; + token0Symbol: string; + token0Reserve: string; + token1Symbol: string; + token1Reserve: string; + priceRangeLower: string; + priceRangeUpper: string; + currentPrice: string; } ⋮---- -export interface CardPointRecordsResultV5 { - pageSize: number; - pageNo: number; - totalCount: number; - data: CardPointRecordV5[]; +export interface ExecuteAlphaLPStakeResultV5 { + positionId: number; + orderNo: string; } ⋮---- -export interface CardPointTierInfoV5 { - usedLimit: string; - limit: string; - unit: string; - tier: string; - autoCashback: boolean; +export interface ExecuteAlphaLPRedeemResultV5 { + orderNo: string; } ⋮---- -export interface CardMallItemV5 { - itemId: string; - itemName: string; - priority: number; - onTime: string; - offTime: string; - price: string; - discountPrice: string; - totalNum: number; - redeemNum: number; - picPath: string; - currency: string; - currencyType: number; - itemType: number; - itemBizType: number; +export interface AlphaLPOrderV5 { + orderType: number; + orderNo: string; + orderStatus: number; + poolAddress: string; + poolName: string; + positionId: number; + tokenCode: string; + tokenSymbol: string; + tokenIconUrlDay: string; + tokenIconUrlNight: string; + amount: string; + chainCode: string; + chainIconUrl: string; + gasTokenSymbol: string; + gasOnchain: string; + gasUsd: string | null; + platformFee: string; + platformFeeUsd: string | null; + createTime: number; + executionTime: number; + failureReason?: string; + dercRatio?: string; } ⋮---- -export interface CardMallItemListResultV5 { - pageNo: number; - pageSize: number; - totalCount: number; - data: CardMallItemV5[]; +export interface AlphaLPOrderListResultV5 { + total: number; + pageIndex: number; + orders: AlphaLPOrderV5[]; } ⋮---- -export interface CardPointCashbackDetailV5 { - points: string; - amt: string; - ccy: string; - ccyType: string; - createTime: string; - bizTxnId: string; - sourceId: number; - sourceCode: string; - orderStatus: number; - orderSubStatus: number; - orderShowStatus: string; - failedBizCode: string; -} - -================ -File: src/types/response/v5-earn-advance-discount.ts -================ -export interface AdvanceEarnDiscountBuyOfferV5 { - productId: string; - currentPrice: string; - purchasePrice: string; - knockoutPrice: string; - knockoutCouponE8: string; - maxInvestmentAmount: string; - instUid: string; - expiredAt: string; - category: string; +export interface AlphaLPPayTokenV5 { + tokenCode: string; + tokenSymbol: string; + chainCode: string; + chainIconUrl: string; + decimals: number; + availableBalance: string; + tokenIconUrlDay: string; + tokenIconUrlNight: string; + minStakeAmount: string; + maxStakeAmount: string; } ⋮---- -/** GET /v5/earn/advance/product-extra-info?category=DiscountBuy */ -export interface AdvanceEarnProductExtraInfoDiscountBuyV5 { - offers: AdvanceEarnDiscountBuyOfferV5[]; +export interface AlphaLPPayTokenListResultV5 { + tokens: AlphaLPPayTokenV5[]; } ⋮---- -export interface AdvanceEarnDualAssetQuoteLevelV5 { - selectPrice: string; - apyE8: string; - maxInvestmentAmount: string; - expiredAt: string; +export interface AlphaLPPayTokenPriceV5 { + tokenCode: string; + tokenSymbol: string; + priceUsd: string; + chainCode: string; + updateTime: number; } ⋮---- -export interface AdvanceEarnDualAssetQuoteProductV5 { - productId: string; - currentPrice: string; - buyLowPrice: AdvanceEarnDualAssetQuoteLevelV5[]; - sellHighPrice: AdvanceEarnDualAssetQuoteLevelV5[]; +export interface AlphaLPPayTokenPriceResultV5 { + prices: AlphaLPPayTokenPriceV5[]; } ⋮---- -/** GET /v5/earn/advance/product-extra-info?category=DualAssets&productId= */ -export interface AdvanceEarnProductExtraInfoDualAssetsV5 { - category: 'DualAssets'; - list: AdvanceEarnDualAssetQuoteProductV5[]; +export interface AlphaLPPositionV5 { + positionId: number; + poolAddress: string; + poolName: string; + stakedAmount: string; + stakedTokenCode: string; + stakedTokenSymbol: string; + currentValueUsd: string; + earnedRewardsUsd: string; + unrealizedPnl: string; + realizedPnl: string; + apy: string; + token0Amount: string; + token0Symbol: string; + token1Amount: string; + token1Symbol: string; + rangeUpper: string; + rangeLower: string; + createTime: number; + updateTime: number; + status: number; } ⋮---- -export type AdvanceEarnProductExtraInfoV5 = - | AdvanceEarnProductExtraInfoDiscountBuyV5 - | AdvanceEarnProductExtraInfoDualAssetsV5; -⋮---- -export interface AdvanceEarnPlaceOrderResultV5 { - orderId: string; - orderLinkId: string; +export interface AlphaLPPositionListResultV5 { + positions: AlphaLPPositionV5[]; } + +================ +File: src/types/response/v5-alpha-prediction.ts +================ +/** + * V5 private Alpha prediction market responses. + */ ⋮---- -export interface AdvanceEarnDiscountBuyPositionV5 { - positionId: string; - productId: string; - category: string; - coin: string; - underlyingAsset: string; - amount: string; - purchasePrice: string; - knockoutPrice: string; - knockoutCouponE8: string; - status: string; - orderId: string; - duration: string; - settlementTime: string; - accountType: string; - toAccountType: string; - settleType: string; - expectReceiveAt: string; +export interface AlphaPredictionEngineStatusV5 { + available: boolean; } ⋮---- -export interface AdvanceEarnDualAssetsPositionV5 { - positionId: string; - productId: string; - category: string; - baseCoin: string; - quoteCoin: string; - investCoin: string; - amount: string; - apyE8: string; - direction: 'BuyLow' | 'SellHigh' | string; - targetPrice: string; - settlementTime: string; - status: string; - orderId: string; - duration: string; - expectReturnCoin: string; - expectReturnAmount: string; - accountType: string; - toAccountType: string; - yieldStartAt: string | number; - yieldEndAt: string | number; +export interface AlphaPredictionPayTokenV5 { + tokenCode: string; + symbol: string; + tokenDecimals: number; + tokenIconUrlDay: string; + tokenIconUrlNight: string; + supportChains: string[]; } ⋮---- -export interface AdvanceEarnPositionListV5 { - category: string; - list: (AdvanceEarnDiscountBuyPositionV5 | AdvanceEarnDualAssetsPositionV5)[]; - nextPageCursor: string; +export interface AlphaPredictionMarketV5 { + tokenId: string; + outcome: string; + price: string; + side: number; + volume: string; + liquidity: string; } ⋮---- -export interface AdvanceEarnDiscountBuyOrderV5 { - orderId: string; - orderLinkId: string; - productId: string; +export interface AlphaPredictionEventDetailV5 { + eventId: string; + slug: string; + title: string; + description: string; category: string; - orderType: string; - amount: string; - coin: string; - underlyingAsset: string; - status: string; - createdTime: string; - purchasePrice: string; - knockoutPrice: string; - knockoutCouponE8: string; - duration: string; - settlementTime: string; - accountType: string; - toAccountType: string; - settleType: string; - settlementPrice: string; - settlementCoin: string; - settlementAmount: string; - isVip: boolean; - refundStatus: string; + endDate: number; + resolved: boolean; + volume: string; + liquidity: string; + markets: AlphaPredictionMarketV5[]; } ⋮---- -export interface AdvanceEarnDualAssetsOrderV5 { - orderId: string; - orderLinkId: string; - productId: string; - category: string; - orderType: string; - amount: string; - coin: string; - baseCoin: string; - quoteCoin: string; - status: string; - createdTime: string; - updatedTime: string; - direction: 'BuyLow' | 'SellHigh' | string; - targetPrice: string; - settlementTime: string | number; - estimateApyE8: string | number; - duration: string; - accountType: string; - toAccountType: string; - selectApyE8: string | number; - isVip: boolean; - settlementCoin: string; - settlementAmount: string; - orderMode: string; - settlementPrice: string; - refundStatus: string; - trialBonusAmount: string; - trialBonusPnl: string; +export interface AlphaPredictionOrderEstimateFeeDetailV5 { + serverFee: string; + polymarketFee: string; } ⋮---- -export interface AdvanceEarnOrderListV5 { - category: string; - list: (AdvanceEarnDiscountBuyOrderV5 | AdvanceEarnDualAssetsOrderV5)[]; - nextPageCursor: string; +export interface AlphaPredictionOrderEstimateV5 { + avgPrice: string; + estimatedCost: string; + estimatedReceive: string; + toWin?: string; + feeAmount: string; + feeDetail: AlphaPredictionOrderEstimateFeeDetailV5; + slippage: string; } - -================ -File: src/types/response/v5-earn-fixed-term.ts -================ -export interface FixedTermEarnTieredApyV5 { - min: string; - max: string; - apy: string; +⋮---- +export interface ExecuteAlphaPredictionOrderResultV5 { + orderNo: string; } ⋮---- -export interface FixedTermEarnInterestCoinApyV5 { - coin: string; - apy: string; - expectUnitEarning: string; - currentPrice: string; +export interface AlphaPredictionOrderV5 { + orderNo: string; + tokenId: string; + eventId: string; + side: number; + orderType: number; + orderAmount: string; + filledSize: string; + filledPrice: string; + totalFee: string; + status: number; + createdAt: number; + updatedAt: number; } ⋮---- -export interface FixedTermEarnProductV5 { - productId: string; - category: 'FixedTermSaving' | 'FundPool' | 'FundPoolPremium' | string; - coin: string; - duration: string; - status: 'Available' | 'SoldOut' | 'NotStarted' | string; - tieredApyList: FixedTermEarnTieredApyV5[]; - minStakeAmount: string; - maxStakeAmount: string; - precision: number; - subscribeStartAt: string; - subscribeEndAt: string; - allowEarlyRedemption: boolean; - earlyRedemptionApy: string; - redemptionLimitDuration: string; - allowAutoReinvest: boolean; - interestCoinApyList: FixedTermEarnInterestCoinApyV5[]; - isVip: boolean; - creditTime: string; - specialUserGroupRequired: boolean; - specialUserGroupInfo: string; +export interface AlphaPredictionOrderListResultV5 { + orders: AlphaPredictionOrderV5[]; + total: number; + pageIndex: number; } ⋮---- -export interface FixedTermEarnProductListV5 { - list: FixedTermEarnProductV5[]; +export interface AlphaPredictionOrderBookLevelV5 { + price: string; + size: string; } ⋮---- -export interface FixedTermEarnPlaceOrderResultV5 { - orderId: string; - orderLinkId: string; +export interface AlphaPredictionOrderBookV5 { + tokenId: string; + bids: AlphaPredictionOrderBookLevelV5[]; + asks: AlphaPredictionOrderBookLevelV5[]; } ⋮---- -export interface RedeemFixedTermEarnResultV5 { - redeemAmount: string; - estEarnings: string; +export interface AlphaPredictionTokenPriceV5 { + tokenId: string; + bestBid: string; + bestAsk: string; + lastPrice: string; + volume24h: string; + updateTime: number; } ⋮---- -export interface FixedTermEarnEarlyRedeemInfoV5 { - allowEarlyRedeem: boolean; - earlyRedeemEarning: string; - returnCoin: string; - redemptionLimitDuration: string; +export interface AlphaPredictionPriceHistoryCandleV5 { + openTime: number; + open: string; + high: string; + low: string; + close: string; + volume: string; } ⋮---- -export interface FixedTermEarnPositionInterestV5 { - coin: string; - apy: string; - expectReturnEarning: string; - price: string; +export interface AlphaPredictionPriceHistoryV5 { + tokenId: string; + interval: string; + list: AlphaPredictionPriceHistoryCandleV5[]; } ⋮---- -export interface FixedTermEarnPositionV5 { +export interface AlphaPredictionPositionV5 { positionId: string; - productId: string; - category: string; - coin: string; - amount: string; - effectiveAmount: string; - duration: string; - status: string; - settlementTime: string; - createdAt: string; - orderId: string; - earlyRedeemInfo: FixedTermEarnEarlyRedeemInfoV5 | null; - allowAutoReinvest: boolean; - autoReinvest: string; - interestCoinApyList: FixedTermEarnPositionInterestV5[]; + tokenId: string; + eventId: string; + outcomeName: string; + shares: string; + cost: string; + avgPrice: string; + currentPrice: string; + value: string; + unrealizedPnl: string; + unrealizedPnlRate: string; + createdAt: number; + finished: boolean; } ⋮---- -export interface FixedTermEarnPositionListV5 { - list: FixedTermEarnPositionV5[]; +export interface AlphaPredictionPositionListResultV5 { + positions: AlphaPredictionPositionV5[]; + total: number; + totalAssetUsd: string; } ⋮---- -export interface FixedTermEarnOrderYieldInfoV5 { - coin: string; - amount: string; - status: string; - createdAt: string; - apy: string; +export interface AlphaPredictionPositionHistoryV5 { + positionId: string; + tokenId: string; + eventId: string; + outcomeName: string; + shares: string; + cost: string; + avgPrice: string; + exitPrice: string; + realizedPnl: string; + realizedPnlRate: string; + result: number; + closedAt: number; +} +⋮---- +export interface AlphaPredictionPositionHistoryResultV5 { + positions: AlphaPredictionPositionHistoryV5[]; + total: number; +} +⋮---- +export interface AlphaPredictionPortfolioSummaryV5 { + positionValue: string; + positionValueUsd: string; + biggestWin: string; + winRate: string; + winCount: number; + lossCount: number; +} +⋮---- +export interface AlphaPredictionSideMarketTokenV5 { + tokenId: string; + outcome: string; + price: string; + liquidity: string; } ⋮---- -export interface FixedTermEarnOrderV5 { - orderId: string; - orderLinkId: string; - orderType: string; - status: string; - productId: string; - category: string; - coin: string; - amount: string; - duration: string; - accountType: string; - settlementTime: string; - createdAt: string; - yieldInfoList: FixedTermEarnOrderYieldInfoV5[]; +export interface AlphaPredictionSideMarketV5 { + marketId: string; + eventId: string; + marketType: number; + question: string; + tokens: AlphaPredictionSideMarketTokenV5[]; + volume24h: string; + endDate: number; + status: number; } ⋮---- -export interface FixedTermEarnOrderListV5 { - list: FixedTermEarnOrderV5[]; - nextPageCursor: string; +export interface AlphaPredictionSideMarketListResultV5 { + list: AlphaPredictionSideMarketV5[]; + total: number; + pageIndex: number; + pageSize: number; } - -================ -File: src/types/response/v5-earn-liquidity-mining.ts -================ -export interface LiquidityMiningApyBreakdownV5 { - coin: string; - apy: string; +⋮---- +export interface AlphaPredictionSportsMatchV5 { + matchId: string; + eventType: number; + stageCode: string; + homeTeam: string; + awayTeam: string; + matchTime: number; + status: number; + eventId: string; } ⋮---- -export interface LiquidityMiningProductV5 { - productId: string; - baseCoin: string; - quoteCoin: string; - status: 'Available' | 'NotAvailable' | string; - maxLeverage: number; - minInvestmentQuote: string; - minInvestmentBase: string; - maxInvestmentQuote: string; - maxInvestmentBase: string; - minWithdrawalAmount: string; - minReinvestAmount: string; - baseCoinPrecision: number; - quoteCoinPrecision: number; - yieldCoins: string[]; - apyE8: string; - apy7dE8: string; - poolLiquidityValue: string; - dailyYield: string; - slippageRateE8List: string[]; - apyBreakdown: LiquidityMiningApyBreakdownV5[]; - apy7dBreakdown: LiquidityMiningApyBreakdownV5[]; - slippage_levels?: string[]; +export interface AlphaPredictionSportsMatchListResultV5 { + list: AlphaPredictionSportsMatchV5[]; + total: number; + pageIndex: number; + pageSize: number; } ⋮---- -export interface LiquidityMiningProductResultV5 { - products: LiquidityMiningProductV5[]; +export interface AlphaPredictionSportsTimelineStageV5 { + stageCode: string; + stageName: string; + status: number; + matchCount: number; + startTime: number; + endTime: number; } ⋮---- -export interface ReinvestLiquidityMiningResultV5 { - orderId: string; - orderLinkId: string; +export interface AlphaPredictionSportsTimelineStagesV5 { + eventType: number; + stages: AlphaPredictionSportsTimelineStageV5[]; } - -================ -File: src/types/response/v5-earn-pwm.ts -================ -export interface PwmCoinAmountV5 { - coin: string; - amount: string; +⋮---- +export interface AlphaPredictionSportsGroupStandingV5 { + rank: number; + teamName: string; + played: number; + won: number; + drawn: number; + lost: number; + goalsFor: number; + goalsAgainst: number; + goalDifference: number; + points: number; } ⋮---- -export interface PwmMultiCoinsEarningPositionItemV5 { - category: string; - productId: string; - coin: string; - currentAmount: string; - accumulateYield: string; - apr: string; - positionId: string; - status?: string; +export interface AlphaPredictionSportsGroupMatchV5 { + matchId: string; + homeTeam: string; + awayTeam: string; + matchTime: number; + status: number; + homeScore: number; + awayScore: number; + eventId: string; } ⋮---- -export interface PwmMultiCoinsEarningPositionsV5 { - totalInvestmentUsd: string; - accumulateYieldUsd: string; - weightedAvgApr: string; - items: PwmMultiCoinsEarningPositionItemV5[]; +export interface AlphaPredictionSportsGroupV5 { + groupName: string; + standings: AlphaPredictionSportsGroupStandingV5[]; + matches: AlphaPredictionSportsGroupMatchV5[]; } ⋮---- -export interface PwmFixedYieldPositionItemV5 { - category: string; - productId: string; - coin: string; - currentAmount: string; - accumulateYield: string; - apr: string; - duration: number; - maturityTime: string; - autoReinvest: boolean; - positionId: string; - status?: string; +export interface AlphaPredictionSportsGroupStageDetailV5 { + groups: AlphaPredictionSportsGroupV5[]; } + +================ +File: src/types/response/v5-alpha-trade.ts +================ +/** + * V5 private Alpha / on-chain (Web3) trade responses. + */ ⋮---- -export interface PwmFixedYieldPositionsV5 { - totalInvestmentUsd: string; - accumulateYieldUsd: string; - weightedAvgApr: string; - items: PwmFixedYieldPositionItemV5[]; +export interface AlphaTradeQuoteModeEstimationV5 { + quoteMode: number; + estimatedGas: string; + estimatedGasUsd: string; + estimatedSlippage: string; } ⋮---- -export interface PwmEquityFundPositionItemV5 { - category: string; - productId: string; - fundName: string; - coin: string; - tags: string[]; - nav: string; - userShares: string; - shareValue: string; - holdingValue: string; - accumulateYield: string; - apr30d: string; - aprTotal: string; - sharpRatio: string; - maxDrawdown: string; - createdTime: string; - runningDays: number; - positionId?: string; - status?: string; +export interface AlphaTradeQuoteResultV5 { + tradeType: number; + fromTokenCode: string; + fromTokenAmount: string; + fromTokenAmountUsd: string; + toTokenCode: string; + toTokenAmount: string; + toTokenAmountUsd: string; + minToTokenAmount: string; + slippage: string; + gas: string; + gasUsd: string; + platformFee: string; + platformFeeUsd: string; + swapRate: string; + lossRate: string; + quoteData: string; + correctingCode: string; + quoteMode: number; + quoteDataId: string; + expireTime: number; + modeEstimations: AlphaTradeQuoteModeEstimationV5[]; + chargeAmount?: string; + timestamp?: number; } ⋮---- -export interface PwmEquityFundsPositionsV5 { - totalInvestmentUsd: string; - accumulateYieldUsd: string; - weightedAvgApr: string; - items: PwmEquityFundPositionItemV5[]; +export interface ExecuteAlphaTradeResultV5 { + orderNo: string; } ⋮---- -export interface PwmOnchainEarnPositionItemV5 { - category: string; - productId: string; - coin: string; - stakeAmount: string; - apr: string; - positionId: string; - status?: string; +export interface AlphaPayTokenV5 { + tokenCode: string; + symbol: string; + tokenDecimals: number; + tokenIconUrlDay: string; + tokenIconUrlNight: string; + limit: string; + supportChains: string[]; } ⋮---- -export interface PwmOnchainEarnPositionsV5 { - totalInvestmentUsd: string; - accumulateYieldUsd: string; - items: PwmOnchainEarnPositionItemV5[]; +export interface AlphaTradeOrderV5 { + orderType: number; + tradeType: number; + orderNo: string; + orderStatus: number; + fromTokenCode: string; + fromTokenAmount: string; + fromTokenSymbol: string; + fromTokenDecimals: number; + fromTokenIconUrlDay?: string; + fromTokenIconUrlNight?: string; + fromChainCode: string; + fromChainIconUrl?: string; + toTokenCode: string; + toTokenAmount: string; + toTokenSymbol: string; + toTokenDecimals: number; + toTokenIconUrlDay?: string; + toTokenIconUrlNight?: string; + toChainCode: string; + toChainIconUrl?: string; + gasTokenSymbol: string; + gasOnchain: string; + gasUsd: string | null; + platformFee: string; + platformFeeUsd: string | null; + quoteMode: number; + createTime: number; + executionTime?: number; + failureReasonCode?: string; + source?: string; + swapRate: string; + actualFromTokenAmount: string; } ⋮---- -export interface PwmInvestmentPlanPositionsV5 { - multiCoinsEarning?: PwmMultiCoinsEarningPositionsV5; - fixedYield?: PwmFixedYieldPositionsV5; - equityFunds?: PwmEquityFundsPositionsV5; - onchainEarn?: PwmOnchainEarnPositionsV5; - fundingAccount?: PwmCoinAmountV5[]; +export interface AlphaTradeOrderListResultV5 { + total: number; + pageIndex: number; + orders: AlphaTradeOrderV5[]; } ⋮---- -/** GET /v5/earn/pwm/investment-plan/list */ -export interface PwmInvestmentPlanSummaryV5 { - planId: string; - planName: string; - planType: string; - status: string; - currentAssetUsd?: string; - accumulateYieldUsd?: string; - weightedAvgApr?: string; - createdTime?: string; +export interface AlphaBizTokenV5 { + tokenCode: string; + chainCode: string; + chainIconUrl: string; + tokenAddress: string; + symbol: string; + tokenDecimals: number; + tokenIconUrlDay: string; + tokenIconUrlNight: string; + createTime: number; + createTimeOnchain: number; + riskFlag: number; + minOrderQuantity: number; + maxOrderQuantity: number; + tokenTags: number[]; + payTokenCodes: string[]; } ⋮---- -export interface PwmInvestmentPlanListResultV5 { - list: PwmInvestmentPlanSummaryV5[]; +export interface AlphaBizTokenPriceV5 { + chainCode: string; + tokenAddress: string; + price: string; + change24h: string; + vol24h: string; + marketCap: string; + liquidity: string; + holders: string; } ⋮---- -/** GET /v5/earn/pwm/investment-plan/detail */ -export interface PwmInvestmentPlanDetailV5 { - planId: string; - planName: string; - planType: string; - status: string; - currentAssetUsd: string; - accumulateYieldUsd: string; - weightedAvgApr: string; - currentAssets: PwmCoinAmountV5[]; - positions: PwmInvestmentPlanPositionsV5; - createdTime: string; +export interface AlphaBizTokenPriceListResultV5 { + tokenPriceInfoList: AlphaBizTokenPriceV5[]; } ⋮---- -export interface PwmEquityFundIntroductionV5 { - description: string; - historicalYieldRateMax: string; - historicalYieldRateMin: string; - sharpRatio: string; - maxDrawback: string; - lockupPeriod: string; +export interface AlphaBizTokenDetailsV5 { + tokenCode: string; + chainCode: string; + chainIconUrl: string; + tokenAddress: string; + symbol: string; + tokenDecimals: number; + tokenIconUrlDay: string; + tokenIconUrlNight: string; + minOrderQuantity: string; + maxOrderQuantity: string; + maxPositionQuantity: string; + tokenDesc: string; + xUrl: string; + officialUrl: string; + whitePaperUrl: string; + tokenTag: number; + riskFlag: number; + createTimeOnchain: number; + status: number; + tokenTags: number[]; + showMessage: number; + content?: string; + linkName?: string; + linkAddress?: string; } ⋮---- -export interface PwmPendingMultiCoinsEarningItemV5 { - category: string; - productId: string; - coin: string; - configuredAmount: string; - apr: string; +export interface AlphaAssetV5 { + chainCode: string; + chainIconUrl: string; + tokenAddress: string; + tokenCode: string; + tokenSymbol: string; + tokenDecimals: number; + tokenIconUrlDay: string; + tokenIconUrlNight: string; + tokenAmount: string; + tokenAmountUsd: string; + tradeFlag: number; + pnl: string | null; + pnlRatio: string | null; + costPrice: string | null; + lastPrice: string; + costTotalValue: string | null; + assetStatus: number; + announcementUrl?: string; + estimatedOfflineTime?: number; + delistingTime?: number; } ⋮---- -export interface PwmPendingFixedYieldItemV5 { - category: string; - productId: string; - coin: string; - configuredAmount: string; - apr: string; - duration: number; +export interface AlphaAssetListResultV5 { + totalAssetUsd: string; + assetList: AlphaAssetV5[]; } ⋮---- -export interface PwmPendingEquityFundItemV5 { - category: string; - productId: string; - fundName: string; - coin: string; - configuredAmount: string; - tags: string[]; - introduction: PwmEquityFundIntroductionV5; +export interface AlphaAssetDetailResultV5 { + assetList: AlphaAssetV5[]; } -⋮---- -export interface PwmPendingOnchainEarnItemV5 { - category: string; - productId: string; - coin: string; - configuredAmount: string; - apr: string; + +================ +File: src/types/response/v5-card.ts +================ +export interface CardAssetRecordV5 { + pan4: string; + pan6: string; + tradeStatus: string; + side: string; + basicAmount: string; + basicCurrency: string; + transactionAmount: string; + transactionCurrency: string; + txnCreate: number; + merchCountry: string; + merchCity: string; + merchName: string; + txnId: string; + declinedReason: string; + totalFees: string; + uid: number; + transactionCurrencyAmount: string; + fxPad: string; + interchangeFee: string; + billAmount: string; + paidAmount: string; + paidCurrency: string; + bonusAmount: string; + foreignTransactionFee: string; + totalTax: string; + paidFiat: string; + withdrawalFee: string; + status: string; + orderNo: string; + mccCode: string; + merchCategoryDesc: string; } ⋮---- -export interface PwmPendingInvestmentPlanProductsV5 { - multiCoinsEarning?: { - configuredAmountUsd: string; - items: PwmPendingMultiCoinsEarningItemV5[]; - }; - fixedYield?: { - configuredAmountUsd: string; - items: PwmPendingFixedYieldItemV5[]; - }; - equityFunds?: { - configuredAmountUsd: string; - items: PwmPendingEquityFundItemV5[]; - }; - onchainEarn?: { - configuredAmountUsd: string; - items: PwmPendingOnchainEarnItemV5[]; - }; +export interface CardAssetRecordsResultV5 { + pageSize: number; + pageNo: number; + totalCount: number; + data: CardAssetRecordV5[]; } ⋮---- -/** GET /v5/earn/pwm/investment-plan/new-plan */ -export interface PwmPendingInvestmentPlanDetailV5 { - planId: string; - planName: string; - planType: string; +export interface CardPointBalanceV5 { + accountId: string; + availablePoint: string | number; + pendingPoint: string | number; status: string; - source: string; - totalConfiguredAmountUsd: string; - products: PwmPendingInvestmentPlanProductsV5; - createdTime: string; + updateTime: string | number; + settlementPeriod: number; } ⋮---- -/** POST /v5/earn/pwm/investment-plan/claim */ -export interface ClaimPwmWithdrawableFundsResultV5 { - planId: string; - toAccountType: number; - status: string; - createdTime: string; +export interface CardPointRecordV5 { + outOrderId: string; + point: number; + side: string; + type: string; + subType: string; + createTime: number; + updateTime: number; + bizId: string; + bizTxnId: string; + transactionDate: string; + transactionId: string; + transactionAmount: string; + basicCurrency: string; + merchCategoryDesc: string; + merchName: string; + merchCountry: string; + merchCity: string; + pan4: string; + payFiatAmount: string; + transactionCurrencyAmount: string; } ⋮---- -export interface PwmAssetTrendDataPointV5 { - date: string; - assetValueUsd: string; +export interface CardPointRecordsResultV5 { + pageSize: number; + pageNo: number; + totalCount: number; + data: CardPointRecordV5[]; } ⋮---- -/** GET /v5/earn/pwm/investment-plan/asset-trend */ -export interface PwmInvestmentPlanAssetTrendResultV5 { - planId: string; - dataPoints: PwmAssetTrendDataPointV5[]; +export interface CardPointTierInfoV5 { + usedLimit: string; + limit: string; + unit: string; + tier: string; + autoCashback: boolean; } ⋮---- -export interface PwmFundNavDataPointV5 { - date: string; - nav: string; +export interface CardMallItemV5 { + itemId: string; + itemName: string; + priority: number; + onTime: string; + offTime: string; + price: string; + discountPrice: string; + totalNum: number; + redeemNum: number; + picPath: string; + currency: string; + currencyType: number; + itemType: number; + itemBizType: number; } ⋮---- -/** GET /v5/earn/pwm/investment-plan/fund-nav */ -export interface PwmFundHistoricalNavResultV5 { - fundId: string; - fundName: string; - coin: string; - currentNav: string; - dataPoints: PwmFundNavDataPointV5[]; +export interface CardMallItemListResultV5 { + pageNo: number; + pageSize: number; + totalCount: number; + data: CardMallItemV5[]; } ⋮---- -/** POST /v5/earn/pwm/investment-plan/subscribe */ -export interface SubscribePwmInvestmentPlanResultV5 { - planId: string; - status: string; - orderLinkId: string; +export interface CardPointCashbackDetailV5 { + points: string; + amt: string; + ccy: string; + ccyType: string; + createTime: string; + bizTxnId: string; + sourceId: number; + sourceCode: string; + orderStatus: number; + orderSubStatus: number; + orderShowStatus: string; + failedBizCode: string; } -⋮---- -/** POST /v5/earn/pwm/investment-plan/invest-more */ -export interface InvestMorePwmInvestmentPlanResultV5 { - planId: string; - category: string; + +================ +File: src/types/response/v5-earn-advance-discount.ts +================ +export interface AdvanceEarnDiscountBuyOfferV5 { productId: string; - coin: string; - amount: string; - status: string; - orderLinkId: string; - orderId: string; -} -⋮---- -/** POST /v5/earn/pwm/investment-plan/redeem */ -export interface RedeemPwmInvestmentPlanResultV5 { - orderId: string; - planId: string; + currentPrice: string; + purchasePrice: string; + knockoutPrice: string; + knockoutCouponE8: string; + maxInvestmentAmount: string; + instUid: string; + expiredAt: string; category: string; - productId: string; - shares?: string; - amount?: string; - estimatedAmount?: string; - coin: string; - status: string; - orderLinkId: string; } ⋮---- -/** GET /v5/earn/pwm/investment-plan/order */ -export interface PwmInvestmentPlanOrderV5 { - orderId: string; - planId: string; - type: string; - accountType: string; - coin: string; - amount: string; - category: string; - productId: string; - status: string; - orderTime: string; +/** GET /v5/earn/advance/product-extra-info?category=DiscountBuy */ +export interface AdvanceEarnProductExtraInfoDiscountBuyV5 { + offers: AdvanceEarnDiscountBuyOfferV5[]; } ⋮---- -export interface PwmInvestmentPlanOrdersResultV5 { - list: PwmInvestmentPlanOrderV5[]; - nextPageCursor: string; +export interface AdvanceEarnDualAssetQuoteLevelV5 { + selectPrice: string; + apyE8: string; + maxInvestmentAmount: string; + expiredAt: string; } ⋮---- -/** GET /v5/earn/pwm/customize-plan/product */ -export interface PwmSubscribableProductCardV5 { - category: string; - productId?: string; - fundName?: string; - coin: string; - apr?: string; - aprRangeLow?: string; - aprRangeHigh?: string; - tags?: string[]; - introduction?: string; - aum?: string; - minInvestmentAmount?: string; - maxInvestmentAmount?: string; - duration?: number; - maxDrawdown?: string; - sharpRatio?: string; - estAPR?: string; +export interface AdvanceEarnDualAssetQuoteProductV5 { + productId: string; + currentPrice: string; + buyLowPrice: AdvanceEarnDualAssetQuoteLevelV5[]; + sellHighPrice: AdvanceEarnDualAssetQuoteLevelV5[]; } ⋮---- -export interface PwmSubscribableProductGroupV5 { - type: string; - cards: PwmSubscribableProductCardV5[]; +/** GET /v5/earn/advance/product-extra-info?category=DualAssets&productId= */ +export interface AdvanceEarnProductExtraInfoDualAssetsV5 { + category: 'DualAssets'; + list: AdvanceEarnDualAssetQuoteProductV5[]; } ⋮---- -export interface PwmSubscribableProductInfoResultV5 { - products: PwmSubscribableProductGroupV5[]; -} +export type AdvanceEarnProductExtraInfoV5 = + | AdvanceEarnProductExtraInfoDiscountBuyV5 + | AdvanceEarnProductExtraInfoDualAssetsV5; ⋮---- -/** POST /v5/earn/pwm/customize-plan/create */ -export interface CreatePwmCustomizeInvestmentPlanResultV5 { - planId: string; - planName: string; - status: string; - orderLinkId?: string; +export interface AdvanceEarnPlaceOrderResultV5 { + orderId: string; + orderLinkId: string; } ⋮---- -/** GET /v5/earn/pwm/asset-manager/all-funds */ -export interface PwmAssetManagerFundV5 { - fundId: string; - fundName: string; +export interface AdvanceEarnDiscountBuyPositionV5 { + positionId: string; + productId: string; + category: string; coin: string; + underlyingAsset: string; + amount: string; + purchasePrice: string; + knockoutPrice: string; + knockoutCouponE8: string; status: string; - totalEquity: string; - totalShares: string; - currentNav: string; - currentAPR?: string; - accountUid: string; - subAccountList: string[]; - profitShareRate: string; - managementFeeRate: string; - uncollectedProfit: string; - collectedProfit: string; - totalLoan: string; - createdTime: string; -} -⋮---- -export interface PwmAllFundsResultV5 { - list: PwmAssetManagerFundV5[]; - nextPageCursor: string; + orderId: string; + duration: string; + settlementTime: string; + accountType: string; + toAccountType: string; + settleType: string; + expectReceiveAt: string; } ⋮---- -/** POST /v5/earn/pwm/asset-manager/settle-profit */ -export interface SettlePwmFundProfitResultV5 { - fundId: string; +export interface AdvanceEarnDualAssetsPositionV5 { + positionId: string; + productId: string; + category: string; + baseCoin: string; + quoteCoin: string; + investCoin: string; + amount: string; + apyE8: string; + direction: 'BuyLow' | 'SellHigh' | string; + targetPrice: string; + settlementTime: string; status: string; - totalProfitShared: string; - instIncome: string; - coin: string; - createdTime: string; + orderId: string; + duration: string; + expectReturnCoin: string; + expectReturnAmount: string; + accountType: string; + toAccountType: string; + yieldStartAt: string | number; + yieldEndAt: string | number; } ⋮---- -/** POST /v5/earn/pwm/asset-manager/create-fund */ -export interface CreatePwmFundResultV5 { - fundId: string; - fundName: string; - coin: string; - status: string; - profitShareRate: string; - managementFeeRate: string; - accountUid: string; - createdTime: string; +export interface AdvanceEarnPositionListV5 { + category: string; + list: (AdvanceEarnDiscountBuyPositionV5 | AdvanceEarnDualAssetsPositionV5)[]; + nextPageCursor: string; } ⋮---- -/** POST /v5/earn/pwm/asset-manager/create-investment-plan */ -export interface CreatePwmAssetManagerInvestmentPlanResultV5 { - planId: string; - planType: string; - accountUid: string; +export interface AdvanceEarnDiscountBuyOrderV5 { + orderId: string; + orderLinkId: string; + productId: string; + category: string; + orderType: string; + amount: string; + coin: string; + underlyingAsset: string; status: string; createdTime: string; + purchasePrice: string; + knockoutPrice: string; + knockoutCouponE8: string; + duration: string; + settlementTime: string; + accountType: string; + toAccountType: string; + settleType: string; + settlementPrice: string; + settlementCoin: string; + settlementAmount: string; + isVip: boolean; + refundStatus: string; } ⋮---- -/** GET /v5/earn/pwm/asset-manager/get-investment-plan */ -export interface PwmAssetManagerInvestmentPlanDistributionV5 { +export interface AdvanceEarnDualAssetsOrderV5 { + orderId: string; + orderLinkId: string; + productId: string; category: string; + orderType: string; + amount: string; coin: string; - productId: string; - currentAmount: string; -} -⋮---- -export interface PwmAssetManagerInvestmentPlanV5 { - planId: string; - planName: string; - planType: string; - subscriptionUid: string; + baseCoin: string; + quoteCoin: string; status: string; - source: string; - currentAssetUsd: string; - accumulateYieldUsd: string; - investmentDistribution: PwmAssetManagerInvestmentPlanDistributionV5[]; createdTime: string; + updatedTime: string; + direction: 'BuyLow' | 'SellHigh' | string; + targetPrice: string; + settlementTime: string | number; + estimateApyE8: string | number; + duration: string; + accountType: string; + toAccountType: string; + selectApyE8: string | number; + isVip: boolean; + settlementCoin: string; + settlementAmount: string; + orderMode: string; + settlementPrice: string; + refundStatus: string; + trialBonusAmount: string; + trialBonusPnl: string; } ⋮---- -export interface PwmAssetManagerInvestmentPlansResultV5 { - list: PwmAssetManagerInvestmentPlanV5[]; +export interface AdvanceEarnOrderListV5 { + category: string; + list: (AdvanceEarnDiscountBuyOrderV5 | AdvanceEarnDualAssetsOrderV5)[]; nextPageCursor: string; } -⋮---- -/** POST /v5/earn/pwm/asset-manager/manage-investment-plan */ -export interface ManagePwmAssetManagerInvestmentPlanFundResultV5 { - fundId: string; - amount: string; + +================ +File: src/types/response/v5-earn-fixed-term.ts +================ +export interface FixedTermEarnTieredApyV5 { + min: string; + max: string; + apy: string; } ⋮---- -export interface ManagePwmAssetManagerInvestmentPlanResultV5 { - planId: string; - status: string; - updatedTime: string; - updateFunds: ManagePwmAssetManagerInvestmentPlanFundResultV5[]; +export interface FixedTermEarnInterestCoinApyV5 { + coin: string; + apy: string; + expectUnitEarning: string; + currentPrice: string; } ⋮---- -/** GET /v5/earn/pwm/asset-manager/all-order */ -export interface PwmAssetManagerFundOrderV5 { - orderId: string; - fundId: string; - fundName: string; - accountUid: string; - orderType: string; +export interface FixedTermEarnProductV5 { + productId: string; + category: 'FixedTermSaving' | 'FundPool' | 'FundPoolPremium' | string; coin: string; - amount: string; - shares: string; - status: string; - createdTime: string; + duration: string; + status: 'Available' | 'SoldOut' | 'NotStarted' | string; + tieredApyList: FixedTermEarnTieredApyV5[]; + minStakeAmount: string; + maxStakeAmount: string; + precision: number; + subscribeStartAt: string; + subscribeEndAt: string; + allowEarlyRedemption: boolean; + earlyRedemptionApy: string; + redemptionLimitDuration: string; + allowAutoReinvest: boolean; + interestCoinApyList: FixedTermEarnInterestCoinApyV5[]; + isVip: boolean; + creditTime: string; + specialUserGroupRequired: boolean; + specialUserGroupInfo: string; } ⋮---- -export interface PwmAllFundOrdersResultV5 { - list: PwmAssetManagerFundOrderV5[]; - nextPageCursor: string; +export interface FixedTermEarnProductListV5 { + list: FixedTermEarnProductV5[]; } ⋮---- -/** POST /v5/earn/pwm/asset-manager/manage-order */ -export interface ManagePwmFundOrderResultV5 { +export interface FixedTermEarnPlaceOrderResultV5 { orderId: string; - fundId: string; - accountUid: string; - orderStatus: string; - orderType: string; - action: string; - coin: string; - amount: string; - shares: string; - updatedTime: string; + orderLinkId: string; } ⋮---- -/** POST /v5/earn/pwm/asset-manager/create-sub-account */ -export interface CreatePwmFundSubAccountResultV5 { - fundId: string; - subAccountUid: string; - createdTime: string; - status: string; +export interface RedeemFixedTermEarnResultV5 { + redeemAmount: string; + estEarnings: string; } ⋮---- -/** POST /v5/earn/pwm/fund-transfer */ -export interface PwmFundTransferResultV5 { - transferId: string; - status: string; +export interface FixedTermEarnEarlyRedeemInfoV5 { + allowEarlyRedeem: boolean; + earlyRedeemEarning: string; + returnCoin: string; + redemptionLimitDuration: string; } ⋮---- -/** GET /v5/earn/pwm/query-fund-transfer-result */ -export interface PwmFundTransferRecordV5 { - transferId: string; - status: string; - fromUserId: number; - toUserId: number; - amount: string; +export interface FixedTermEarnPositionInterestV5 { coin: string; + apy: string; + expectReturnEarning: string; + price: string; } - -================ -File: src/types/response/v5-earn-token.ts -================ -/** - * Earn token product (e.g. BYUSDT) — /v5/earn/token/* - */ ⋮---- -export interface EarnTokenProductV5 { +export interface FixedTermEarnPositionV5 { + positionId: string; productId: string; + category: string; coin: string; - mintFeeRateE8: string; - redeemFeeRateE8: string; - minInvestment: string; - userHolding: string; - leftQuota: string; - canMint: boolean; - savingsBalance: string; - aprE8: string; - bonusAprE8: string; - bonusMaxAmount: string; - baseCoinPrecision: number; - tokenPrecision: number; -} -⋮---- -export interface PlaceEarnTokenOrderResultV5 { - orderId: string; - orderLinkId: string; -} -⋮---- -export interface EarnTokenOrderV5 { + amount: string; + effectiveAmount: string; + duration: string; + status: string; + settlementTime: string; + createdAt: string; orderId: string; - orderLinkId: string; - orderType: 'Mint' | 'Redeem'; - fromCoin: string; - toCoin: string; - fromAmount: string; - toAmount: string; - serviceFee: string; - status: 'Success' | 'Processing' | 'Fail'; - createdTime: string; + earlyRedeemInfo: FixedTermEarnEarlyRedeemInfoV5 | null; + allowAutoReinvest: boolean; + autoReinvest: string; + interestCoinApyList: FixedTermEarnPositionInterestV5[]; } ⋮---- -export interface EarnTokenPositionV5 { - totalAmount: string; - totalYield: string; - yesterdayYield: string; - aprE8: number; - bonusAprE8: number; - bonusMaxAmount: string; - hasQuota: boolean; +export interface FixedTermEarnPositionListV5 { + list: FixedTermEarnPositionV5[]; } ⋮---- -export interface EarnTokenDailyYieldRecordV5 { - yield: string; - bonusYield: string; - status: 'Success' | 'Processing'; - createdTime: string; +export interface FixedTermEarnOrderYieldInfoV5 { + coin: string; + amount: string; + status: string; + createdAt: string; + apy: string; } ⋮---- -export interface EarnTokenHourlyYieldRecordV5 { - effectiveAmount: string; - yield: string; - rewardType: 0 | 1; - aprE8: string; - hourlyDate: string; - createdTime: string; +export interface FixedTermEarnOrderV5 { + orderId: string; + orderLinkId: string; + orderType: string; + status: string; + productId: string; + category: string; + coin: string; + amount: string; + duration: string; + accountType: string; + settlementTime: string; + createdAt: string; + yieldInfoList: FixedTermEarnOrderYieldInfoV5[]; } ⋮---- -export interface EarnTokenHistoryAprPointV5 { - timestamp: string; - aprE8: string; +export interface FixedTermEarnOrderListV5 { + list: FixedTermEarnOrderV5[]; + nextPageCursor: string; } ================ -File: src/types/response/v5-rfq.ts +File: src/types/response/v5-earn-pwm.ts ================ -export interface RFQConfigV5 { - deskCode: string; // Own deskCode, unique identification code - maxLegs: number; // Maximum number of legs - maxLP: number; // Maximum number of LPs selected in inquiry form - maxActiveRfq: number; // Maximum number of unfinished inquiry orders allowed - minLimitQtySpotOrder: number; // Spot minimum order quantity multiplier - minLimitQtyContractOrder: number; // Contract minimum order quantity multiplier - minLimitQtyOptionOrder: number; // Option minimum order multiplier - strategyTypes: { - strategyName: string; // Policy name - }[]; - counterparties: { - strategyName: string; // Policy name - }[]; +export interface PwmCoinAmountV5 { + coin: string; + amount: string; } ⋮---- -deskCode: string; // Own deskCode, unique identification code -maxLegs: number; // Maximum number of legs -maxLP: number; // Maximum number of LPs selected in inquiry form -maxActiveRfq: number; // Maximum number of unfinished inquiry orders allowed -minLimitQtySpotOrder: number; // Spot minimum order quantity multiplier -minLimitQtyContractOrder: number; // Contract minimum order quantity multiplier -minLimitQtyOptionOrder: number; // Option minimum order multiplier +export interface PwmMultiCoinsEarningPositionItemV5 { + category: string; + productId: string; + coin: string; + currentAmount: string; + accumulateYield: string; + apr: string; + positionId: string; + status?: string; +} ⋮---- -strategyName: string; // Policy name +export interface PwmMultiCoinsEarningPositionsV5 { + totalInvestmentUsd: string; + accumulateYieldUsd: string; + weightedAvgApr: string; + items: PwmMultiCoinsEarningPositionItemV5[]; +} ⋮---- -strategyName: string; // Policy name +export interface PwmFixedYieldPositionItemV5 { + category: string; + productId: string; + coin: string; + currentAmount: string; + accumulateYield: string; + apr: string; + duration: number; + maturityTime: string; + autoReinvest: boolean; + positionId: string; + status?: string; +} ⋮---- -export interface RFQCounterpartyV5 { - traderName: string; // Name of the bidder - deskCode: string; // Unique identification code of the quotation party - type: string | null; // Quoter type. LP is automated market maker, null means normal quote party +export interface PwmFixedYieldPositionsV5 { + totalInvestmentUsd: string; + accumulateYieldUsd: string; + weightedAvgApr: string; + items: PwmFixedYieldPositionItemV5[]; } ⋮---- -traderName: string; // Name of the bidder -deskCode: string; // Unique identification code of the quotation party -type: string | null; // Quoter type. LP is automated market maker, null means normal quote party +export interface PwmEquityFundPositionItemV5 { + category: string; + productId: string; + fundName: string; + coin: string; + tags: string[]; + nav: string; + userShares: string; + shareValue: string; + holdingValue: string; + accumulateYield: string; + apr30d: string; + aprTotal: string; + sharpRatio: string; + maxDrawdown: string; + createdTime: string; + runningDays: number; + positionId?: string; + status?: string; +} ⋮---- -export interface CreateRFQResultV5 { - rfqId: string; // Inquiry ID - rfqLinkId: string; // Inquiry Custom ID - status: 'Active' | 'Canceled' | 'Filled' | 'Expired' | 'Failed'; // Status of the inquiry form - expiresAt: string; // Expiration time in milliseconds Unix timestamp - deskCode: string; // Inquiry party unique identification code +export interface PwmEquityFundsPositionsV5 { + totalInvestmentUsd: string; + accumulateYieldUsd: string; + weightedAvgApr: string; + items: PwmEquityFundPositionItemV5[]; } ⋮---- -rfqId: string; // Inquiry ID -rfqLinkId: string; // Inquiry Custom ID -status: 'Active' | 'Canceled' | 'Filled' | 'Expired' | 'Failed'; // Status of the inquiry form -expiresAt: string; // Expiration time in milliseconds Unix timestamp -deskCode: string; // Inquiry party unique identification code +export interface PwmOnchainEarnPositionItemV5 { + category: string; + productId: string; + coin: string; + stakeAmount: string; + apr: string; + positionId: string; + status?: string; +} ⋮---- -export interface CancelRFQResultV5 { - rfqId: string; // Inquiry ID - rfqLinkId: string; // Inquiry Custom ID +export interface PwmOnchainEarnPositionsV5 { + totalInvestmentUsd: string; + accumulateYieldUsd: string; + items: PwmOnchainEarnPositionItemV5[]; } ⋮---- -rfqId: string; // Inquiry ID -rfqLinkId: string; // Inquiry Custom ID +export interface PwmInvestmentPlanPositionsV5 { + multiCoinsEarning?: PwmMultiCoinsEarningPositionsV5; + fixedYield?: PwmFixedYieldPositionsV5; + equityFunds?: PwmEquityFundsPositionsV5; + onchainEarn?: PwmOnchainEarnPositionsV5; + fundingAccount?: PwmCoinAmountV5[]; +} ⋮---- -export interface CancelRFQItemV5 { - rfqId: string; // Inquiry ID - rfqLinkId: string; // Inquiry Custom ID - code: number; // Cancel success or failure, 0 means success - msg: string; // Cancellation failure reason +/** GET /v5/earn/pwm/investment-plan/list */ +export interface PwmInvestmentPlanSummaryV5 { + planId: string; + planName: string; + planType: string; + status: string; + currentAssetUsd?: string; + accumulateYieldUsd?: string; + weightedAvgApr?: string; + createdTime?: string; } ⋮---- -rfqId: string; // Inquiry ID -rfqLinkId: string; // Inquiry Custom ID -code: number; // Cancel success or failure, 0 means success -msg: string; // Cancellation failure reason +export interface PwmInvestmentPlanListResultV5 { + list: PwmInvestmentPlanSummaryV5[]; +} ⋮---- -export interface CancelAllRFQResultV5 { - data: CancelRFQItemV5[]; // Array of cancellation results +/** GET /v5/earn/pwm/investment-plan/detail */ +export interface PwmInvestmentPlanDetailV5 { + planId: string; + planName: string; + planType: string; + status: string; + currentAssetUsd: string; + accumulateYieldUsd: string; + weightedAvgApr: string; + currentAssets: PwmCoinAmountV5[]; + positions: PwmInvestmentPlanPositionsV5; + createdTime: string; } ⋮---- -data: CancelRFQItemV5[]; // Array of cancellation results +export interface PwmEquityFundIntroductionV5 { + description: string; + historicalYieldRateMax: string; + historicalYieldRateMin: string; + sharpRatio: string; + maxDrawback: string; + lockupPeriod: string; +} ⋮---- -export interface CreateRFQQuoteResultV5 { - rfqId: string; // Inquiry ID - quoteId: string; // Quotation ID - quoteLinkId: string; // Quotation Custom ID - expiresAt: string; // Expiration time in milliseconds Unix timestamp - deskCode: string; // Quoter's unique identification code - status: 'Active' | 'Canceled' | 'Filled' | 'Expired' | 'Failed'; // Status of quotation +export interface PwmPendingMultiCoinsEarningItemV5 { + category: string; + productId: string; + coin: string; + configuredAmount: string; + apr: string; } ⋮---- -rfqId: string; // Inquiry ID -quoteId: string; // Quotation ID -quoteLinkId: string; // Quotation Custom ID -expiresAt: string; // Expiration time in milliseconds Unix timestamp -deskCode: string; // Quoter's unique identification code -status: 'Active' | 'Canceled' | 'Filled' | 'Expired' | 'Failed'; // Status of quotation +export interface PwmPendingFixedYieldItemV5 { + category: string; + productId: string; + coin: string; + configuredAmount: string; + apr: string; + duration: number; +} ⋮---- -export interface ExecuteRFQQuoteResultV5 { - rfqId: string; // Inquiry ID - rfqLinkId: string; // Inquiry Custom ID - quoteId: string; // Quotation ID - status: 'Processing' | 'Rejected'; // Order status - rejectParty: string; // Empty means passed, "Taker", "Maker", "Bybit" when rejected +export interface PwmPendingEquityFundItemV5 { + category: string; + productId: string; + fundName: string; + coin: string; + configuredAmount: string; + tags: string[]; + introduction: PwmEquityFundIntroductionV5; +} +⋮---- +export interface PwmPendingOnchainEarnItemV5 { + category: string; + productId: string; + coin: string; + configuredAmount: string; + apr: string; +} +⋮---- +export interface PwmPendingInvestmentPlanProductsV5 { + multiCoinsEarning?: { + configuredAmountUsd: string; + items: PwmPendingMultiCoinsEarningItemV5[]; + }; + fixedYield?: { + configuredAmountUsd: string; + items: PwmPendingFixedYieldItemV5[]; + }; + equityFunds?: { + configuredAmountUsd: string; + items: PwmPendingEquityFundItemV5[]; + }; + onchainEarn?: { + configuredAmountUsd: string; + items: PwmPendingOnchainEarnItemV5[]; + }; } ⋮---- -rfqId: string; // Inquiry ID -rfqLinkId: string; // Inquiry Custom ID -quoteId: string; // Quotation ID -status: 'Processing' | 'Rejected'; // Order status -rejectParty: string; // Empty means passed, "Taker", "Maker", "Bybit" when rejected +/** GET /v5/earn/pwm/investment-plan/new-plan */ +export interface PwmPendingInvestmentPlanDetailV5 { + planId: string; + planName: string; + planType: string; + status: string; + source: string; + totalConfiguredAmountUsd: string; + products: PwmPendingInvestmentPlanProductsV5; + createdTime: string; +} ⋮---- -export interface CancelRFQQuoteResultV5 { - rfqId: string; // Inquiry ID - quoteId: string; // Quotation ID - quoteLinkId: string; // Quotation Custom ID +/** POST /v5/earn/pwm/investment-plan/claim */ +export interface ClaimPwmWithdrawableFundsResultV5 { + planId: string; + toAccountType: number; + status: string; + createdTime: string; } ⋮---- -rfqId: string; // Inquiry ID -quoteId: string; // Quotation ID -quoteLinkId: string; // Quotation Custom ID +export interface PwmAssetTrendDataPointV5 { + date: string; + assetValueUsd: string; +} ⋮---- -export interface CancelRFQQuoteItemV5 { - rfqId: string; // Inquiry ID - quoteId: string; // Quotation ID - quoteLinkId: string; // Quotation Custom ID - code: number; // Cancel success or failure, 0 means success - msg: string; // Cancellation failure reason +/** GET /v5/earn/pwm/investment-plan/asset-trend */ +export interface PwmInvestmentPlanAssetTrendResultV5 { + planId: string; + dataPoints: PwmAssetTrendDataPointV5[]; } ⋮---- -rfqId: string; // Inquiry ID -quoteId: string; // Quotation ID -quoteLinkId: string; // Quotation Custom ID -code: number; // Cancel success or failure, 0 means success -msg: string; // Cancellation failure reason +export interface PwmFundNavDataPointV5 { + date: string; + nav: string; +} ⋮---- -export interface RFQLegV5 { - category: 'linear' | 'option' | 'spot'; // Product category - symbol: string; // The unique instrument ID - side: 'buy' | 'sell'; // Inquiry direction - qty: string; // Order quantity of the instrument - isLeverage?: boolean; // For spot lending +/** GET /v5/earn/pwm/investment-plan/fund-nav */ +export interface PwmFundHistoricalNavResultV5 { + fundId: string; + fundName: string; + coin: string; + currentNav: string; + dataPoints: PwmFundNavDataPointV5[]; } ⋮---- -category: 'linear' | 'option' | 'spot'; // Product category -symbol: string; // The unique instrument ID -side: 'buy' | 'sell'; // Inquiry direction -qty: string; // Order quantity of the instrument -isLeverage?: boolean; // For spot lending +/** POST /v5/earn/pwm/investment-plan/subscribe */ +export interface SubscribePwmInvestmentPlanResultV5 { + planId: string; + status: string; + orderLinkId: string; +} ⋮---- -export interface RFQHedgeLegItemV5 { +/** POST /v5/earn/pwm/investment-plan/invest-more */ +export interface InvestMorePwmInvestmentPlanResultV5 { + planId: string; category: string; - symbol: string; - side: string; - qty: string; - price?: string; + productId: string; + coin: string; + amount: string; + status: string; + orderLinkId: string; + orderId: string; } ⋮---- -export interface RFQItemV5 { - rfqId: string; // Inquiry ID - rfqLinkId: string; // Custom ID for inquiry form - counterparties: string[]; // List of bidders - expiresAt: string; // Expiration time in milliseconds Unix timestamp - strategyType: string; // Inquiry label - status: - | 'Active' - | 'Canceled' - | 'PendingFill' - | 'Filled' - | 'Expired' - | 'Failed'; // Status - acceptOtherQuoteStatus?: string; // Whether to accept non-LP quotes. "false": do not accept, "true": accept - deskCode: string; // Unique identification code of the inquiry party - anonymous?: boolean; - createdAt: number; // Time when the trade is created in epoch - updatedAt: number; // Time when the trade is updated in epoch - legs: RFQLegV5[]; // Combination transaction - hedge?: RFQHedgeLegItemV5[]; +/** POST /v5/earn/pwm/investment-plan/redeem */ +export interface RedeemPwmInvestmentPlanResultV5 { + orderId: string; + planId: string; + category: string; + productId: string; + shares?: string; + amount?: string; + estimatedAmount?: string; + coin: string; + status: string; + orderLinkId: string; } ⋮---- -rfqId: string; // Inquiry ID -rfqLinkId: string; // Custom ID for inquiry form -counterparties: string[]; // List of bidders -expiresAt: string; // Expiration time in milliseconds Unix timestamp -strategyType: string; // Inquiry label -⋮---- -| 'Failed'; // Status -acceptOtherQuoteStatus?: string; // Whether to accept non-LP quotes. "false": do not accept, "true": accept -deskCode: string; // Unique identification code of the inquiry party -⋮---- -createdAt: number; // Time when the trade is created in epoch -updatedAt: number; // Time when the trade is updated in epoch -legs: RFQLegV5[]; // Combination transaction -⋮---- -export interface GetRFQRealtimeResultV5 { - list: RFQItemV5[]; // Array of RFQ items +/** GET /v5/earn/pwm/investment-plan/order */ +export interface PwmInvestmentPlanOrderV5 { + orderId: string; + planId: string; + type: string; + accountType: string; + coin: string; + amount: string; + category: string; + productId: string; + status: string; + orderTime: string; } ⋮---- -list: RFQItemV5[]; // Array of RFQ items -⋮---- -export interface RFQHistory { - cursor: string; // Page turning mark - list: RFQItemV5[]; // Array of RFQ items +export interface PwmInvestmentPlanOrdersResultV5 { + list: PwmInvestmentPlanOrderV5[]; + nextPageCursor: string; } ⋮---- -cursor: string; // Page turning mark -list: RFQItemV5[]; // Array of RFQ items -⋮---- -export interface QuoteLegV5 { - category: 'spot' | 'linear' | 'option'; // Product type - symbol: string; // The unique instrument ID or name of trading contract - price: string; // Order price or quote price - qty?: string; // Order quantity - isLeverage?: boolean; // For spot lending - isHedge?: boolean; +/** GET /v5/earn/pwm/customize-plan/product */ +export interface PwmSubscribableProductCardV5 { + category: string; + productId?: string; + fundName?: string; + coin: string; + apr?: string; + aprRangeLow?: string; + aprRangeHigh?: string; + tags?: string[]; + introduction?: string; + aum?: string; + minInvestmentAmount?: string; + maxInvestmentAmount?: string; + duration?: number; + maxDrawdown?: string; + sharpRatio?: string; + estAPR?: string; } ⋮---- -category: 'spot' | 'linear' | 'option'; // Product type -symbol: string; // The unique instrument ID or name of trading contract -price: string; // Order price or quote price -qty?: string; // Order quantity -isLeverage?: boolean; // For spot lending +export interface PwmSubscribableProductGroupV5 { + type: string; + cards: PwmSubscribableProductCardV5[]; +} ⋮---- -export interface RFQQuoteItemV5 { - rfqId: string; // Inquiry ID - rfqLinkId: string; // Custom ID for inquiry form - quoteId: string; // Quotation ID - quoteLinkId: string; // Quotation custom ID - expiresAt: string; // Expiration time in milliseconds Unix timestamp - deskCode: string; // Unique identification code of quotation party - anonymous?: boolean; - status: - | 'Active' - | 'Canceled' - | 'PendingFill' - | 'Filled' - | 'Expired' - | 'Failed'; // Status - execQuoteSide: string; // Execute quote direction, buy or sell - createdAt: number; // Time when the trade is created in epoch - updatedAt: number; // Time when the trade is updated in epoch - quoteBuyList: QuoteLegV5[]; // Quotation buy direction - quoteSellList: QuoteLegV5[]; // Quotation sell direction +export interface PwmSubscribableProductInfoResultV5 { + products: PwmSubscribableProductGroupV5[]; } ⋮---- -rfqId: string; // Inquiry ID -rfqLinkId: string; // Custom ID for inquiry form -quoteId: string; // Quotation ID -quoteLinkId: string; // Quotation custom ID -expiresAt: string; // Expiration time in milliseconds Unix timestamp -deskCode: string; // Unique identification code of quotation party +/** POST /v5/earn/pwm/customize-plan/create */ +export interface CreatePwmCustomizeInvestmentPlanResultV5 { + planId: string; + planName: string; + status: string; + orderLinkId?: string; +} ⋮---- -| 'Failed'; // Status -execQuoteSide: string; // Execute quote direction, buy or sell -createdAt: number; // Time when the trade is created in epoch -updatedAt: number; // Time when the trade is updated in epoch -quoteBuyList: QuoteLegV5[]; // Quotation buy direction -quoteSellList: QuoteLegV5[]; // Quotation sell direction +/** GET /v5/earn/pwm/asset-manager/all-funds */ +export interface PwmAssetManagerFundV5 { + fundId: string; + fundName: string; + coin: string; + status: string; + totalEquity: string; + totalShares: string; + currentNav: string; + currentAPR?: string; + accountUid: string; + subAccountList: string[]; + profitShareRate: string; + managementFeeRate: string; + uncollectedProfit: string; + collectedProfit: string; + totalLoan: string; + createdTime: string; +} ⋮---- -export interface RFQTradeLegV5 { - category: 'linear' | 'option' | 'spot'; // Product category - orderId: string; // Bybit order ID - symbol: string; // The unique instrument ID - side: 'buy' | 'sell'; // Direction - price: string; // Execution price - qty: string; // Number of executions - isLeverage?: boolean; // For spot lending - markPrice: string; // MarkPrice (contract) at transaction time, indexPrice for spot - execFee: string; // Fee for taker or maker in base currency - execId: string; // Unique exec(trade) ID from exchange - resultCode: number; // Status code, 0 means success - resultMessage: string; // Error message about resultCode - rejectParty: string; // Empty if Filled, "Taker"/"Maker"/"bybit" if Rejected +export interface PwmAllFundsResultV5 { + list: PwmAssetManagerFundV5[]; + nextPageCursor: string; } ⋮---- -category: 'linear' | 'option' | 'spot'; // Product category -orderId: string; // Bybit order ID -symbol: string; // The unique instrument ID -side: 'buy' | 'sell'; // Direction -price: string; // Execution price -qty: string; // Number of executions -isLeverage?: boolean; // For spot lending -markPrice: string; // MarkPrice (contract) at transaction time, indexPrice for spot -execFee: string; // Fee for taker or maker in base currency -execId: string; // Unique exec(trade) ID from exchange -resultCode: number; // Status code, 0 means success -resultMessage: string; // Error message about resultCode -rejectParty: string; // Empty if Filled, "Taker"/"Maker"/"bybit" if Rejected +/** POST /v5/earn/pwm/asset-manager/settle-profit */ +export interface SettlePwmFundProfitResultV5 { + fundId: string; + status: string; + totalProfitShared: string; + instIncome: string; + coin: string; + createdTime: string; +} ⋮---- -export interface RFQTradeV5 { - rfqId: string; // Inquiry ID - quoteId: string; // Completed inquiry form and executed quotation ID - quoteSide: 'buy' | 'sell'; // Executed quotation direction - strategyType: string; // Inquiry label - status: 'Filled' | 'Rejected'; // Status - rfqDeskCode: string; // Unique identification code of inquiry party - quoteDestCode: string; // Unique identification code of quotation party - createdAt: number; // Time when trade is created in epoch - updatedAt: number; // Time when trade is updated in epoch - legs: RFQTradeLegV5[]; // Combination transaction +/** POST /v5/earn/pwm/asset-manager/create-fund */ +export interface CreatePwmFundResultV5 { + fundId: string; + fundName: string; + coin: string; + status: string; + profitShareRate: string; + managementFeeRate: string; + accountUid: string; + createdTime: string; } ⋮---- -rfqId: string; // Inquiry ID -quoteId: string; // Completed inquiry form and executed quotation ID -quoteSide: 'buy' | 'sell'; // Executed quotation direction -strategyType: string; // Inquiry label -status: 'Filled' | 'Rejected'; // Status -rfqDeskCode: string; // Unique identification code of inquiry party -quoteDestCode: string; // Unique identification code of quotation party -createdAt: number; // Time when trade is created in epoch -updatedAt: number; // Time when trade is updated in epoch -legs: RFQTradeLegV5[]; // Combination transaction +/** POST /v5/earn/pwm/asset-manager/create-investment-plan */ +export interface CreatePwmAssetManagerInvestmentPlanResultV5 { + planId: string; + planType: string; + accountUid: string; + status: string; + createdTime: string; +} ⋮---- -export interface RFQPublicTradeLegV5 { - category: 'linear' | 'option' | 'spot'; // Product category - symbol: string; // The unique instrument ID - side: 'buy' | 'sell'; // Inquiry direction - price: string; // Execution price - qty: string; // Number of executions - markPrice: string; // MarkPrice (contract) at transaction time, indexPrice for spot +/** GET /v5/earn/pwm/asset-manager/get-investment-plan */ +export interface PwmAssetManagerInvestmentPlanDistributionV5 { + category: string; + coin: string; + productId: string; + currentAmount: string; } ⋮---- -category: 'linear' | 'option' | 'spot'; // Product category -symbol: string; // The unique instrument ID -side: 'buy' | 'sell'; // Inquiry direction -price: string; // Execution price -qty: string; // Number of executions -markPrice: string; // MarkPrice (contract) at transaction time, indexPrice for spot +export interface PwmAssetManagerInvestmentPlanV5 { + planId: string; + planName: string; + planType: string; + subscriptionUid: string; + status: string; + source: string; + currentAssetUsd: string; + accumulateYieldUsd: string; + investmentDistribution: PwmAssetManagerInvestmentPlanDistributionV5[]; + createdTime: string; +} ⋮---- -export interface RFQPublicTradeV5 { - rfqId: string; // Inquiry ID - strategyType: string; // Inquiry label - createdAt: number; // Time when trade is created in epoch - updatedAt: number; // Time when trade is updated in epoch - legs: RFQPublicTradeLegV5[]; // Combination transaction +export interface PwmAssetManagerInvestmentPlansResultV5 { + list: PwmAssetManagerInvestmentPlanV5[]; + nextPageCursor: string; } ⋮---- -rfqId: string; // Inquiry ID -strategyType: string; // Inquiry label -createdAt: number; // Time when trade is created in epoch -updatedAt: number; // Time when trade is updated in epoch -legs: RFQPublicTradeLegV5[]; // Combination transaction +/** POST /v5/earn/pwm/asset-manager/manage-investment-plan */ +export interface ManagePwmAssetManagerInvestmentPlanFundResultV5 { + fundId: string; + amount: string; +} ⋮---- -export interface AcceptNonLPQuoteResultV5 { - rfqId: string; // Inquiry ID +export interface ManagePwmAssetManagerInvestmentPlanResultV5 { + planId: string; + status: string; + updatedTime: string; + updateFunds: ManagePwmAssetManagerInvestmentPlanFundResultV5[]; } ⋮---- -rfqId: string; // Inquiry ID +/** GET /v5/earn/pwm/asset-manager/all-order */ +export interface PwmAssetManagerFundOrderV5 { + orderId: string; + fundId: string; + fundName: string; + accountUid: string; + orderType: string; + coin: string; + amount: string; + shares: string; + status: string; + createdTime: string; +} ⋮---- -export interface RFQDetailQuoteLegV5 { - category: string; - symbol: string; - price: string; - qty: string; - isHedge?: boolean; +export interface PwmAllFundOrdersResultV5 { + list: PwmAssetManagerFundOrderV5[]; + nextPageCursor: string; } ⋮---- -export interface RFQDetailQuoteV5 { - quoteId: string; - deskCode: string; - anonymous?: boolean; +/** POST /v5/earn/pwm/asset-manager/manage-order */ +export interface ManagePwmFundOrderResultV5 { + orderId: string; + fundId: string; + accountUid: string; + orderStatus: string; + orderType: string; + action: string; + coin: string; + amount: string; + shares: string; + updatedTime: string; +} +⋮---- +/** POST /v5/earn/pwm/asset-manager/create-sub-account */ +export interface CreatePwmFundSubAccountResultV5 { + fundId: string; + subAccountUid: string; + createdTime: string; status: string; - createdAt: string; - updatedAt: string; - expiresAt: string; - quoteBuyList?: RFQDetailQuoteLegV5[]; - quoteSellList?: RFQDetailQuoteLegV5[]; } ⋮---- -export interface RFQDetailTradeLegV5 { - category: string; - orderId: string; - symbol: string; - side: string; - price: string; - qty: string; - markPrice: string; - execFee: string; - extraFees: string; - execId: string; - resultCode: number; - resultMessage: string; - rejectParty: string; +/** POST /v5/earn/pwm/fund-transfer */ +export interface PwmFundTransferResultV5 { + transferId: string; + status: string; } ⋮---- -export interface RFQDetailItemV5 { - rfqId: string; - rfqLinkId: string; - counterparties: string[]; - expiresAt: string; - strategyType: string; +/** GET /v5/earn/pwm/query-fund-transfer-result */ +export interface PwmFundTransferRecordV5 { + transferId: string; status: string; - acceptOtherQuoteStatus?: boolean; - execQuoteId?: string; - execQuoteSide?: string; - deskCode: string; - anonymous?: boolean; - createdAt: string; - updatedAt: string; - legs: RFQLegV5[]; - hedge?: RFQHedgeLegItemV5[]; - quoteList?: RFQDetailQuoteV5[]; - tradeLegs?: RFQDetailTradeLegV5[]; + fromUserId: number; + toUserId: number; + amount: string; + coin: string; } ================ -File: src/types/response/v5-rwa.ts +File: src/types/response/v5-earn-token.ts ================ /** - * V5 RWA (Real World Assets) earn responses. + * Earn token product (e.g. BYUSDT) — /v5/earn/token/* */ ⋮---- -export interface RWAProductV5 { - productId: number; +export interface EarnTokenProductV5 { + productId: string; coin: string; - assetSymbol: string; - manager: string; - baseApr: string; - bonusApr: string; - savingType: 'Flexible' | 'Fixed' | string; - duration: number; - nav: string; - minStakeAmount: string; - maxStakeAmount: string; - userMaxAmount: string; - userQuota: string; - minRedeemShare: string; - redeemFeeRate: string; - subscriptionFee: string; - extLink: string; - amountPrecision: number; - sharePrecision: number; + mintFeeRateE8: string; + redeemFeeRateE8: string; + minInvestment: string; + userHolding: string; + leftQuota: string; + canMint: boolean; + savingsBalance: string; + aprE8: string; + bonusAprE8: string; + bonusMaxAmount: string; + baseCoinPrecision: number; + tokenPrecision: number; } ⋮---- -export interface RWAProductListResultV5 { - list: RWAProductV5[]; +export interface PlaceEarnTokenOrderResultV5 { + orderId: string; + orderLinkId: string; } ⋮---- -export interface PlaceRWAOrderResultV5 { +export interface EarnTokenOrderV5 { orderId: string; orderLinkId: string; + orderType: 'Mint' | 'Redeem'; + fromCoin: string; + toCoin: string; + fromAmount: string; + toAmount: string; + serviceFee: string; + status: 'Success' | 'Processing' | 'Fail'; + createdTime: string; } ⋮---- -export interface RWAPositionV5 { - productId: number; - coin: string; - assetSymbol: string; - effectiveShare: string; - processingStakeAmount: string; - processingRedeemShare: string; - bonusEarned: string; - nav: string; - holdAmount: string; - duration: number; +export interface EarnTokenPositionV5 { + totalAmount: string; + totalYield: string; + yesterdayYield: string; + aprE8: number; + bonusAprE8: number; + bonusMaxAmount: string; + hasQuota: boolean; } ⋮---- -export interface RWAPositionListResultV5 { - list: RWAPositionV5[]; +export interface EarnTokenDailyYieldRecordV5 { + yield: string; + bonusYield: string; + status: 'Success' | 'Processing'; + createdTime: string; } ⋮---- -export interface RWAOrderV5 { - orderId: string; - orderLinkId: string; - orderType: 'Stake' | 'Redeem'; - productId: number; - coin: string; - stakeAmount?: string; - redeemShares?: string; - status: 'Processing' | 'Success' | 'Failed' | string; - accountType: 'FUND' | 'UNIFIED' | string; - createdTime: number; - updatedTime: number; - settledShares?: string; - settledAmount?: string; +export interface EarnTokenHourlyYieldRecordV5 { + effectiveAmount: string; + yield: string; + rewardType: 0 | 1; + aprE8: string; + hourlyDate: string; + createdTime: string; } ⋮---- -export interface RWAOrderListResultV5 { - list: RWAOrderV5[]; - nextPageCursor: string; +export interface EarnTokenHistoryAprPointV5 { + timestamp: string; + aprE8: string; } + +================ +File: src/types/response/v5-event.ts +================ +export type EventContractTypeV5 = 'Up_Down' | 'UpDown' | 'Target' | 'Range'; +export type EventContractDirectionV5 = + | 'UP' + | 'DOWN' + | 'ABOVE' + | 'BELOW' + | 'RANGE_IN' + | 'RANGE_OUT'; ⋮---- -export interface RWANavChartPointV5 { - date: string; - nav: string; +export interface EventInstrumentFeeRateRuleV5 { + minSecToDelivery: number; + maxSecToDelivery: number; + baseMarkup: string; } ⋮---- -export interface RWANavChartResultV5 { - productId: number; - list: RWANavChartPointV5[]; +export interface EventInstrumentQuotationLimitV5 { + minSecToDelivery: number; + maxSecToDelivery: number; + quoteMaxAmountPerUser: string; + quoteMinAmountPerUser: string; + quoteMinAmount: string; } - -================ -File: src/types/response/v5-spot-x.ts -================ -export interface LaunchpoolPoolV5 { - poolId: string; - stakeCoin: string; - apr: string; - totalStakedAmount: string; - participantCount: string; +⋮---- +export interface EventInstrumentLotSizeFilterV5 { + minOrderAmount: string; + maxOrderAmount: string; + orderAmountTickSize: string; + quoteMaxValidMs: number; + quoteMinIntervalPerUserMs: number; } ⋮---- -export interface LaunchpoolProjectV5 { - projectId: string; - activityCoin: string; - rewardCoin: string; - status: number; - totalReward: string; - stakeStartTime: string; - stakeEndTime: string; - totalParticipantCount: string; - pools: LaunchpoolPoolV5[]; +export interface EventInstrumentInfoV5 { + symbol: string; + symbolId: number; + baseCoin: string; + quoteCoin: string; + settleCoin: string; + eventContractType: EventContractTypeV5 | string; + durationWindow: string | number; + rvThreshold: string; + rebate: string; + takerFeeRate: string; + makerFeeRate: string; + launchTime: string; + deliveryTime: string; + status: string; + targetPrice: string; + lowerBound: string; + upperBound: string; + callOptionSymbolId: number; + putOptionSymbolId: number; + feeRateRule: EventInstrumentFeeRateRuleV5[]; + lotSizeFilter: EventInstrumentLotSizeFilterV5; + quotationLimit: EventInstrumentQuotationLimitV5[]; } ⋮---- -export interface LaunchpoolProjectListResultV5 { - list: LaunchpoolProjectV5[]; +export interface EventInstrumentInfoResultV5 { nextPageCursor: string; + list: EventInstrumentInfoV5[]; } ⋮---- -export interface LaunchpoolActivityLogItemV5 { - stakeCoin: string; - rewardCoin: string; - amount: string; - type: number; - status: number; - createdTime: string; - orderId: string; -} +/** REST Get Orderbook: each entry is [payoutRatio, orderValue] */ +export type EventOrderbookLevelV5 = [string, string]; ⋮---- -export interface LaunchpoolActivityLogResultV5 { - list: LaunchpoolActivityLogItemV5[]; - total: number; - pageSize: number; - current: number; +export interface EventOrderbookV5 { + s: string; + r: EventOrderbookLevelV5[]; + ts: number; + u: number; + seq: number; + cts: number; } ⋮---- -export interface LaunchpoolStakingPositionV5 { - stakeCoin: string; - rewardCoin: string; - stakeAmount: string; - totalReward: string; - autoRedeemDate: string; +export interface EventOrderHistoryItemV5 { + orderId: string; + orderLinkId: string; + orderStatus: string; + symbol: string; + symbolId: string; + baseCoin: string; + quoteCoin: string; + settleCoin: string; + ecDirection: EventContractDirectionV5 | string; + ecDurationWindow: string; + ecTargetPrice: string; + ecContractType: EventContractTypeV5 | string; + ecLowerBound: string; + ecUpperBound: string; + settleTimeMs: string; + ecOrderValue: string; + ecIndexPrice: string; + orderAvgPayoutRatio: string; + cumExecValue: string; + payoutRatio: string; + tradeFee: string; + transTime: string; + createTime: string; + updateTime: string; + cumPayout: string; + cumExecFee: string; + cancelType: string; + createType: string; + rejectReason: string; + extraFees: string; } ⋮---- -export interface LaunchpoolCurrentStakingResultV5 { - totalInvestmentUsd: string; - totalEarningsUsd: string; - todayEarningsUsd: string; - list: LaunchpoolStakingPositionV5[]; +export interface EventOrderHistoryResultV5 { + list: EventOrderHistoryItemV5[]; + cursor: string; } ⋮---- -export interface LaunchpoolUserHistoryItemV5 { - stakeCoin: string; - rewardCoin: string; - totalReward: string; - stakeStartTime: string; - stakeEndTime: string; +export interface EventActiveOrderV5 { + orderId: string; + orderLinkId: string; + symbol: string; + symbolId: string; + side: string; + orderStatus: string; + payoutRatio: string; + cumExecValue: string; + cumExecFee: string; + leavesValue: string; + ecContractType: EventContractTypeV5 | string; + ecDirection: EventContractDirectionV5 | string; + ecOrderValue: string; + ecSettleTime: string; + ecTargetPrice: string; + ecLowerBound: string; + ecUpperBound: string; + ecDurationWindow: string; + ecIndexPrice: string; + orderAvgPayoutRatio: string; + createType: string; + createdTime: string; + updatedTime: string; } ⋮---- -export interface LaunchpoolUserHistoryResultV5 { - list: LaunchpoolUserHistoryItemV5[]; - total: number; - pageSize: number; - current: number; +export interface EventActiveOrdersResultV5 { + list: EventActiveOrderV5[]; + nextPageCursor: string; } ⋮---- -export interface PuzzleProjectV5 { - projectId: string; - activityCoin: string; - rewardCoin: string; - status: number; - startTime: string; - endTime: string; - totalReward: string; - participantCount: string; +export interface EventPositionV5 { + symbol: string; + baseCoin: string; + settleCoin: string; + side: string; + ecContractType: EventContractTypeV5 | string; + ecDirection: EventContractDirectionV5 | string; + avgPayoutRatio: string; + positionValue: string; + ecSettleTime: string; + cumClosedPnl: string; + createdTime: string; + updatedTime: string; + seq: number; } ⋮---- -export interface PuzzleProjectListResultV5 { - list: PuzzleProjectV5[]; +export interface EventPositionInfoResultV5 { + list: EventPositionV5[]; nextPageCursor: string; } ⋮---- -export interface TokenSplashProjectV5 { - status: number; - projectId: string; - activityCoin: string; - rewardCoin: string; - totalReward: string; - participantCount: string; - registrationStartTime: string; - activityEndTime: string; +export interface EventTradeV5 { + orderId: string; + orderLinkId: string; + execId: string; + symbol: string; + baseCoin: string; + settleCoin: string; + side: string; + execType: string; + execPrice: string; + execValue: string; + execFee: string; + execFeeRate: string; + orderPrice: string; + feeCoin: string; + transTime: string; + timeInForce: string; + crossSeq: string; + ecPayout: string; + ecDurationWindow: string; + settleTimeMs: string; + ecOrderValue: string; + ecContractType: EventContractTypeV5 | string; + ecDirection: EventContractDirectionV5 | string; + ecTargetPrice: string; + ecLowerBound: string; + ecUpperBound: string; + extraFees: string; } ⋮---- -export interface TokenSplashProjectListResultV5 { - list: TokenSplashProjectV5[]; - nextPageCursor: string; +export interface EventTradeHistoryResultV5 { + list: EventTradeV5[]; + cursor: string; } ⋮---- -export interface TokenSplashTradeTaskV5 { - tradeRequiredAmount: string; - tradeUnit: string; - tradedAmount: string; - maxRewardAmount: string; - estimatedRewardAmount: string; - rewardCoin: string; +export interface EventSettlementV5 { + transId: string; + symbol: string; + symbolId: string; + baseCoin: string; + settleCoin: string; + side: string; + ecContractType: EventContractTypeV5 | string; + ecDirection: EventContractDirectionV5 | string; + settlePrice: string; + entryPrice: string; + grossPayoutRatio: string; + ecDurationWindow: string; + ecTargetPrice: string; + ecLowerBound: string; + ecUpperBound: string; + transTime: string; + crossSeq: string; + execFee: string; + execFeeRate: string; + payout: string; + sessionRpl: string; + orderId: string; } ⋮---- -export interface TokenSplashUserActivityItemV5 { - projectId: string; - activityCoin: string; - tradeTask: TokenSplashTradeTaskV5; +export interface EventSettlementRecordsResultV5 { + list: EventSettlementV5[]; + cursor: string; } ⋮---- -export interface TokenSplashUserActivityResultV5 { - list: TokenSplashUserActivityItemV5[]; +export interface EventQuoteResultV5 { + orderLinkId: string; + orderId: string; } ================ -File: src/types/response/v5-spreadtrading.ts +File: src/types/response/v5-p2p-trading.ts ================ -export interface SpreadInstrumentInfoV5 { - symbol: string; - contractType: 'FundingRateArb' | 'CarryTrade' | 'FutureSpread' | 'PerpBasis'; - status: 'Trading' | 'Settling'; - baseCoin: string; - quoteCoin: string; - settleCoin: string; - tickSize: string; - minPrice: string; - maxPrice: string; - lotSize: string; - minSize: string; - maxSize: string; - launchTime: string; - deliveryTime: string; - legs: { - symbol: string; - contractType: 'LinearPerpetual' | 'LinearFutures' | 'Spot'; - }[]; +import { P2PTradingPreferenceSetV5 } from '../request/v5-p2p-trading'; +⋮---- +export interface P2PCoinBalanceV5 { + coin: string; + transferBalance: string; + walletBalance: string; + bonus: string; } ⋮---- -export interface SpreadOrderbookResponseV5 { - s: string; // Symbol - b: [string, string][]; // Bids array [price, size] - a: [string, string][]; // Asks array [price, size] - u: number; // Update ID - ts: number; // Timestamp - seq: number; // Sequence - cts: number; // Cross timestamp +export interface P2PAccountCoinsBalanceV5 { + memberId: string; + accountType: string; + balance: P2PCoinBalanceV5[]; +} +⋮---- +export interface P2POnlineAdV5 { + id: string; + nickName: string; + tokenId: string; + currencyId: string; + side: string; + price: string; + lastQuantity: string; + minAmount: string; + maxAmount: string; + payments: string[]; + recentOrderNum: number; + recentExecuteRate: number; + isOnline: boolean; + authTag: string[]; + paymentPeriod: number; + accountId: number; + userId: number; + priceType: number; + premium: string; + quantity: string; + frozenQuantity: string; + executedQuantity: string; + remark: string; + status: number; + createDate: string; + orderNum: string; + finishNum: string; + fee: string; + lastLogoutTime: string; + blocked: string; + makerContact: boolean; + symbolInfo: { + id: string; + exchangeId: string; + orgId: string; + tokenId: string; + currencyId: string; + status: string; + lowerLimitAlarm: number; + upperLimitAlarm: number; + itemDownRange: string; + itemUpRange: string; + currencyMinQuote: string; + currencyMaxQuote: string; + currencyLowerMaxQuote: string; + tokenMinQuote: string; + tokenMaxQuote: string; + kycCurrencyLimit: string; + itemSideLimit: string; + buyFeeRate: string; + sellFeeRate: string; + orderAutoCancelMinute: number; + orderFinishMinute: number; + tradeSide: number; + currency: { + id: string; + exchangeId: string; + orgId: string; + currencyId: string; + scale: number; + }; + token: { + id: string; + exchangeId: string; + orgId: string; + tokenId: string; + scale: number; + sequence: number; + }; + buyAd: number; + sellAd: number; + }; + tradingPreferenceSet: { + hasUnPostAd: number; + isKyc: number; + isEmail: number; + isMobile: number; + hasRegisterTime: number; + registerTimeThreshold: number; + orderFinishNumberDay30: number; + completeRateDay30: number; + nationalLimit: number; + hasOrderFinishNumberDay30: number; + hasCompleteRateDay30: number; + hasNationalLimit: number; + }; + version: number; + authStatus: number; + recommend: boolean; + recommendTag: string; + userType: string; + itemType: string; } ⋮---- -s: string; // Symbol -b: [string, string][]; // Bids array [price, size] -a: [string, string][]; // Asks array [price, size] -u: number; // Update ID -ts: number; // Timestamp -seq: number; // Sequence -cts: number; // Cross timestamp -⋮---- -export interface SpreadTickerV5 { - symbol: string; // Spread combination symbol name - bidPrice: string; // Bid 1 price - bidSize: string; // Bid 1 size - askPrice: string; // Ask 1 price - askSize: string; // Ask 1 size - lastPrice: string; // Last trade price - highPrice24h: string; // The highest price in the last 24 hours - lowPrice24h: string; // The lowest price in the last 24 hours - prevPrice24h: string; // Price 24 hours ago - volume24h: string; // Volume for 24h +export interface P2POnlineAdsResponseV5 { + count: number; + items: P2POnlineAdV5[]; } ⋮---- -symbol: string; // Spread combination symbol name -bidPrice: string; // Bid 1 price -bidSize: string; // Bid 1 size -askPrice: string; // Ask 1 price -askSize: string; // Ask 1 size -lastPrice: string; // Last trade price -highPrice24h: string; // The highest price in the last 24 hours -lowPrice24h: string; // The lowest price in the last 24 hours -prevPrice24h: string; // Price 24 hours ago -volume24h: string; // Volume for 24h -⋮---- -export interface SpreadRecentTradeV5 { - execId: string; // Execution ID - symbol: string; // Spread combination symbol name - price: string; // Trade price - size: string; // Trade size - side: 'Buy' | 'Sell'; // Side of taker - time: string; // Trade time (ms) - seq?: string; +export interface P2PCreateAdResponseV5 { + itemId: string; + securityRiskToken: string; + riskTokenType: string; + riskVersion: string; + needSecurityRisk: boolean; } ⋮---- -execId: string; // Execution ID -symbol: string; // Spread combination symbol name -price: string; // Trade price -size: string; // Trade size -side: 'Buy' | 'Sell'; // Side of taker -time: string; // Trade time (ms) +export interface P2PPaymentTermV5 { + id: string; + realName: string; + paymentType: number; + bankName: string; + branchName: string; + accountNo: string; + qrcode: string; + visible: number; + payMessage: string; + firstName: string; + lastName: string; + secondLastName: string; + clabe: string; + debitCardNumber: string; + mobile: string; + businessName: string; + concept: string; + paymentExt1: string; + paymentExt2: string; + paymentExt3: string; + paymentExt4: string; + paymentExt5: string; + paymentExt6: string; + paymentTemplateVersion: number; + paymentConfig: { + paymentType: number; + paymentName: string; + paymentDialect: string; + }; + realNameVerified: boolean; +} ⋮---- -export interface SpreadOpenOrderV5 { - symbol: string; - baseCoin: string; - orderType: 'Market' | 'Limit'; - orderLinkId: string; - side: 'Buy' | 'Sell'; - timeInForce: 'GTC' | 'FOK' | 'IOC' | 'PostOnly'; - orderId: string; - leavesQty: string; - orderStatus: 'New' | 'PartiallyFilled'; - cumExecQty: string; +export interface P2PAdDetailV5 { + id: string; + accountId: string; + userId: string; + nickName: string; + tokenId: string; + tokenName: string; + currencyId: string; + side: number; + priceType: number; price: string; - qty: string; - createdTime: string; - updatedTime: string; + premium: string; + lastQuantity: string; + quantity: string; + frozenQuantity: string; + executedQuantity: string; + minAmount: string; + maxAmount: string; + remark: string; + status: number; + createDate: string; + payments: string[]; + orderNum: number; + finishNum: number; + recentOrderNum: number; + recentExecuteRate: number; + fee: string; + isOnline: boolean; + lastLogoutTime: string; + symbolInfo: { + id: string; + exchangeId: string; + orgId: string; + tokenId: string; + currencyId: string; + status: number; + lowerLimitAlarm: number; + upperLimitAlarm: number; + itemDownRange: string; + itemUpRange: string; + currencyMinQuote: string; + currencyMaxQuote: string; + currencyLowerMaxQuote: string; + tokenMinQuote: string; + tokenMaxQuote: string; + kycCurrencyLimit: string; + itemSideLimit: number; + buyFeeRate: string; + sellFeeRate: string; + orderAutoCancelMinute: number; + orderFinishMinute: number; + tradeSide: number; + currency: { + id: string; + exchangeId: string; + orgId: string; + currencyId: string; + scale: number; + }; + token: { + id: string; + exchangeId: string; + orgId: string; + tokenId: string; + scale: number; + sequence: number; + }; + buyAd: { + paymentPeriods: number[]; + }; + sellAd: { + paymentPeriods: number[]; + }; + }; + tradingPreferenceSet: P2PTradingPreferenceSetV5; + paymentTerms: P2PPaymentTermV5[]; + version: number; + updateDate: string; + feeRate: string; + paymentPeriod: number; + itemType: string; } ⋮---- -export interface SpreadOrderHistoryV5 { - symbol: string; - orderType: 'Market' | 'Limit'; - orderLinkId: string; - orderId: string; - contractType: 'FundingRateArb' | 'CarryTrade' | 'FutureSpread' | 'PerpBasis'; - orderStatus: 'Rejected' | 'Cancelled' | 'Filled'; - price: string; - orderQty: string; - timeInForce: 'GTC' | 'FOK' | 'IOC' | 'PostOnly'; - baseCoin: string; - createdAt: string; - updatedAt: string; - side: 'Buy' | 'Sell'; - leavesQty: string; - settleCoin: string; - cumExecQty: string; - qty: string; - leg1Symbol: string; - leg1ProdType: 'Futures' | 'Spot'; - leg1OrderId: string; - leg1Side: string; - leg2ProdType: 'Futures' | 'Spot'; - leg2OrderId: string; - leg2Symbol: string; - leg2Side: string; - cxlRejReason: string; - cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee +export interface P2PPersonalAdsResponseV5 { + count: number; + items: P2PAdDetailV5[]; + hiddenFlag: boolean; } ⋮---- -cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee +export interface P2POrderExtensionV5 { + isDelayWithdraw: boolean; + delayTime: string; + startTime: string; +} ⋮---- -export interface SpreadTradeLegV5 { - symbol: string; - side: 'Buy' | 'Sell'; - execPrice: string; - execTime: string; - execValue: string; - execType: string; - category: 'linear' | 'spot'; - execQty: string; - execFee: string; - feeCurrency: string; // Trading fee currency - execId: string; +export interface P2POrderV5 { + id: string; + side: number; + tokenId: string; + orderType: string; + amount: string; + currencyId: string; + price: string; + notifyTokenQuantity?: string; + notifyTokenId?: string; + fee: string; + targetNickName: string; + targetUserId: string; + status: number; + selfUnreadMsgCount: string; + createDate: string; + transferLastSeconds: string; + appealLastSeconds: string; + userId: string; + sellerRealName: string; + buyerRealName: string; + judgeInfo: { + autoJudgeUnlockTime: string; + dissentResult: string; + preDissent: string; + postDissent: string; + }; + unreadMsgCount: string; + extension: P2POrderExtensionV5; + bulkOrderFlag: boolean; } ⋮---- -feeCurrency: string; // Trading fee currency -⋮---- -export interface SpreadTradeV5 { - symbol: string; - orderLinkId: string; - side: 'Buy' | 'Sell'; - orderId: string; - execPrice: string; - execTime: string; - execType: 'Trade'; - execQty: string; - execId: string; - legs: SpreadTradeLegV5[]; - extraFees: string; +export interface P2POrdersResponseV5 { + count: number; + items: P2POrderV5[]; } ⋮---- -/** GET /v5/spread/max-qty */ -export interface SpreadMaxQtyResultV5 { - /** Maximum order quantity (available balance for the spread order). */ - ab: string; +export interface P2PPaymentConfigItemV5 { + view: boolean; + name: string; + label: string; + placeholder: string; + type: string; + maxLength: string; + required: boolean; } ⋮---- -/** Maximum order quantity (available balance for the spread order). */ - -================ -File: src/types/response/v5-strategy.ts -================ -import { - OrderSideV5, - PositionIdx, - PovModeV5, - StrategyCategoryV5, - StrategyPreferV5, - StrategyTypeV5, -} from '../shared-v5'; +export interface P2PPaymentConfigV5 { + paymentType: string; + checkType: number; + sort: number; + paymentName: string; + addTips: string; + itemTips: string; + online: number; + items: P2PPaymentConfigItemV5[]; +} ⋮---- -export interface CreateStrategyOrderResultV5 { - strategyId: string; - /** null when creation succeeded */ - result: string | null; +export interface P2PPaymentTermDetailV5 { + id: string; + realName: string; + paymentType: number; + bankName: string; + branchName: string; + accountNo: string; + qrcode: string; + visible: number; + payMessage: string; + firstName: string; + lastName: string; + secondLastName: string; + clabe: string; + debitCardNumber: string; + mobile: string; + businessName: string; + concept: string; + online: string; + paymentExt1: string; + paymentExt2: string; + paymentExt3: string; + paymentExt4: string; + paymentExt5: string; + paymentExt6: string; + paymentTemplateVersion: number; + paymentConfigVo: P2PPaymentConfigV5; + ruPaymentPrompt: boolean; } ⋮---- -/** null when creation succeeded */ +export interface P2PAppraiseInfoV5 { + anonymous: string; + appraiseContent: string; + appraiseId: string; + appraiseType: string; + modifyFlag: string; + updateDate: string; +} ⋮---- -export interface StopStrategyResultV5 { - strategyId: string; +export interface P2PJudgeInfoV5 { + autoJudgeUnlockTime: string; + dissentResult: string; + preDissent: string; + postDissent: string; } ⋮---- -export interface StrategyListItemV5 { - strategyId: string; - category: StrategyCategoryV5; - symbol: string; - side: OrderSideV5; - size: string; - strategyType: StrategyTypeV5; - /** 2: running, 3: terminated, 4: terminated unfilled, 5: paused, 6: untriggered */ - status: 2 | 3 | 4 | 5 | 6; - executedSize: string; - executedAvgPrice: string; - executedStartTimeE3: string; - executedEndTimeE3: string; - createdTimeE3: string; - updatedTimeE3: string; - reduceOnly: boolean; - triggerPrice: string; - isTriggered: boolean; - leverageType: 0 | 1; - terminateType: number; - terminateRemark: string; - triggerCount: string; - tradingCount: string; - realizedPnl: string; - strategyName: string; - strategyPrefer: StrategyPreferV5 | string; - duration: number; - executedDuration: number; - isRandom: boolean; - interval: number; - limitPrice: string; - chasePercentE4: string; - chaseDistance: string; - maxChasePrice: string; - chaseOrderPrice: string; - chasePrice: string; - postOnly: number; - isRebalance: boolean; +export interface P2POrderDetailV5 { + id: string; + side: number; + itemId: string; + accountId: string; + userId: string; + nickName: string; + makerUserId: string; + targetAccountId: string; + targetUserId: string; + targetNickName: string; + targetFirstName: string; + targetSecondName: string; + targetUserAuthStatus: number; + targetConnectInformation: string; + payerRealName: string; + sellerRealName: string; + buyerRealName: string; + tokenId: string; + tokenName: string; + currencyId: string; + price: string; + quantity: string; + amount: string; + payCode: string; + paymentType: number; + transferDate: string; + status: number; + createDate: string; + paymentTermList: P2PPaymentTermDetailV5[]; + remark: string; + transferLastSeconds: string; + recentOrderNum: number; + recentExecuteRate: number; + appealLastSeconds: string; + appealContent: string; + appealType: number; + appealNickName: string; + canAppeal: string; + totalAppealTimes: string; + appealedTimes: string; + paymentTermResult: P2PPaymentTermDetailV5; + orderFinishMinute: number; + confirmedPayTerm: P2PPaymentTermDetailV5; + makerFee: string; + takerFee: string; + fee: string; + showContact: boolean; + tokenBalance: string; + fiatBalance: string; + unreadMsgCount: string; + updateDate: string; + extension: P2POrderExtensionV5; + selfUnreadMsgCount: string; + judgeType: string; + canReport: boolean; + canReportDisagree: boolean; + canReportType: string[]; + canReportDisagreeType: string[]; + appraiseStatus: string; + appraiseInfo: P2PAppraiseInfoV5; + canReportDisagreeTypes: string[]; + canReportTypes: string[]; orderType: string; - orderPriceOffset: string; - strategySl: string; - strategyTp: string; - arbitrageOrders: unknown[]; - positionValue: string; - filledPositionValue: string; - /** POV only */ - mode?: PovModeV5 | string; - participationRate?: string; - referenceWindow?: string; - depthReference?: string; + middleToken: string; + beforePrice: string; + beforeQuantity: string; + beforeToken: string; + alternative: string; + appealUserId: string; + notifyTokenId: string; + notifyTokenQuantity: string; + cancelResponsible: string; + chainType: string; + chainAddress: string; + tradeHashCode: string; + estimatedGasFee: string; + gasFeeTokenId: string; + tradingFeeTokenId: string; + onChainInfo: string; + transactionId: string; + displayRefund: string; + chainWithdrawLastSeconds: string; + chainTransferLastSeconds: string; + orderSource: string; + cancelReason: string; + sellerCancelExamineRemainTime: string; + needSellerExamineCancel: boolean; + couponCurrencyAmount: string; + totalCurrencyAmount: string; + usedCoupon: boolean; + couponTokenId: string; + couponQuantity: string; + completedOrderAppealCount: number; + totalCompletedOrderAppealCount: number; + realOrderStatus: number; + appealVersion: number; + judgeInfo: P2PJudgeInfoV5; + helpType: string; + appealFlowStatus: string; + appealSubStatus: string; + bulkOrderFlag: boolean; + targetUserType: string; + targetUserDisplays: string[]; + appealProcessChangeFlag: boolean; + appealNegotiationNode: number; } ⋮---- -/** 2: running, 3: terminated, 4: terminated unfilled, 5: paused, 6: untriggered */ +export interface P2POrderMessageV5 { + id: string; + message: string; + userId: string; + msgType: number; + msgCode: number; + createDate: string; + contentType: string; + orderId: string; + msgUuid: string; + nickName: string; + fileName: string; + accountId: string; + isRead: number; + read: number; + roleType: string; + onlyForCustomer: number; +} ⋮---- -/** POV only */ +export interface P2PChatSessionV5 { + sessionName: string; + sessionId: string; + type: 'GROUP' | 'SINGLE'; + /** The docs specify integers, but response examples use strings. */ + id: string | number; + unreadCount: string | number; +} ⋮---- -export interface StrategyListResultV5 { - list: StrategyListItemV5[]; - nextCursor: string; - prevCursor: string; +/** The docs specify integers, but response examples use strings. */ +⋮---- +export interface P2PChatSessionsResponseV5 { + chatSession: P2PChatSessionV5[]; } ⋮---- -export interface StrategyOrderListItemV5 { - strategyId: string; - orderId: string; - symbol: string; - side: OrderSideV5; - size: string; - price: string; - /** 2: created, 3: create failed, 4: partially filled, 5: fully filled, 6: rejected, 7: canceled */ - status: string; - executedSize: string; - dealTimeE3: string; - parentOrderId: string; - createdTimeE3: string; - updatedTimeE3: string; - code: number; - msg: string; - category: StrategyCategoryV5; - positionIdx: PositionIdx; - leverageType: 0 | 1; - tpPrice: string; - slPrice: string; - orderType: string; - orderPriceOffset: string; - positionValue: string; - filledPositionValue: string; +export interface P2PChatMessageV5 { + /** The docs specify integers, but response examples use strings. */ + id: string | number; + sendUserNickName: string; + contentType: 'str' | 'pic' | 'pdf' | 'video'; + /** JSON string containing content, msgCode, msgType, fileName and size. */ + message: string; + /** Creation timestamp in milliseconds. Examples use strings. */ + createDate: string | number; } ⋮---- -/** 2: created, 3: create failed, 4: partially filled, 5: fully filled, 6: rejected, 7: canceled */ +/** The docs specify integers, but response examples use strings. */ ⋮---- -export interface StrategyOrderListResultV5 { - list: StrategyOrderListItemV5[]; - nextCursor: string; - prevCursor: string; -} - -================ -File: webpack/webpack.config.js -================ -function generateConfig(name) +/** JSON string containing content, msgCode, msgType, fileName and size. */ ⋮---- -// Add '.ts' and '.tsx' as resolvable extensions. +/** Creation timestamp in milliseconds. Examples use strings. */ ⋮---- -// Node.js core modules not available in browsers -// The REST client's https.Agent (for keepAlive) is Node.js-only and won't work in browsers +export interface P2PChatMessagesResponseV5 { + messages: P2PChatMessageV5[]; +} ⋮---- -// All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'. +export interface P2PUserInfoV5 { + nickName: string; + defaultNickName: boolean; + isOnline: boolean; + kycLevel: string; + email: string; + mobile: string; + lastLogoutTime: string; + recentRate: string; + totalFinishCount: number; + totalFinishSellCount: number; + totalFinishBuyCount: number; + recentFinishCount: number; + averageReleaseTime: string; + averageTransferTime: string; + accountCreateDays: number; + firstTradeDays: number; + realName: string; + recentTradeAmount: string; + totalTradeAmount: string; + registerTime: string; + authStatus: number; + kycCountryCode: string; + blocked: string; + goodAppraiseRate: string; + goodAppraiseCount: number; + badAppraiseCount: number; + accountId: number; + paymentCount: number; + contactCount: number; + vipLevel: number; + userCancelCountLimit: number; + paymentRealNameUneditable: boolean; + userId: string; + realNameEn: string; +} ⋮---- -// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'. - -================ -File: .npmrc -================ -min-release-age=30 -save-exact=true - -================ -File: .nvmrc -================ -v24.18.0 +export interface P2PCounterpartyUserInfoV5 { + nickName: string; + defaultNickName: boolean; + whiteFlag: number; + contactConfig: boolean; + isOnline: boolean; + email: string; + mobile: string; + kycLevel: number; + lastLogoutTime: string; + recentRate: number; + totalFinishCount: number; + totalFinishSellCount: number; + totalFinishBuyCount: number; + recentFinishCount: number; + averageReleaseTime: string; + averageTransferTime: string; + accountCreateDays: number; + firstTradeDays: number; + realName: string; + recentTradeAmount: string; + totalTradeAmount: string; + executeNum: number; + orderNum: number; + hasUnPostAd: number; + registerTime: string; + authStatus: number; + kycCountryCode: string; + blocked: string; + goodAppraiseRate: string; + goodAppraiseCount: number; + badAppraiseCount: number; + accountId: string; + paymentCount: number; + contactCount: number; + realNameMask: string; + vipLevel: number; + vipProfit: []; + userTag: []; + userCancelCountLimit: number; + paymentRealNameUneditable: boolean; + lostRoleAffected: boolean; + userCurPrivilege: string[]; + userType: string; + userId: string; + realNameEn: string; + canSubOnline: boolean; + curPrivilegeInfo: []; + openApiSwitch: number; +} +⋮---- +export interface P2PUserPaymentV5 { + id: string; + realName: string; + paymentType: string; + bankName: string; + branchName: string; + accountNo: string; + qrcode: string; + visible: number; + payMessage: string; + firstName: string; + lastName: string; + secondLastName: string; + clabe: string; + debitCardNumber: string; + mobile: string; + businessName: string; + concept: string; + online: string; + countNo: string; + paymentExt1: string; + paymentExt2: string; + paymentExt3: string; + paymentExt4: string; + paymentExt5: string; + paymentExt6: string; + paymentTemplateVersion: number; + hasPaymentTemplateChanged: boolean; + paymentConfigVo: P2PPaymentConfigV5; + realNameVerified: boolean; + channel: string; + currencyBalance: string[]; +} ================ -File: examples/Rest/rest-v5-proxies2.ts +File: src/types/response/v5-rfq.ts ================ -import { HttpsProxyAgent } from 'https-proxy-agent'; +export interface RFQConfigV5 { + deskCode: string; // Own deskCode, unique identification code + maxLegs: number; // Maximum number of legs + maxLP: number; // Maximum number of LPs selected in inquiry form + maxActiveRfq: number; // Maximum number of unfinished inquiry orders allowed + minLimitQtySpotOrder: number; // Spot minimum order quantity multiplier + minLimitQtyContractOrder: number; // Contract minimum order quantity multiplier + minLimitQtyOptionOrder: number; // Option minimum order multiplier + strategyTypes: { + strategyName: string; // Policy name + }[]; + counterparties: { + strategyName: string; // Policy name + }[]; +} ⋮---- -import { RestClientV5 } from '../../src/index'; +deskCode: string; // Own deskCode, unique identification code +maxLegs: number; // Maximum number of legs +maxLP: number; // Maximum number of LPs selected in inquiry form +maxActiveRfq: number; // Maximum number of unfinished inquiry orders allowed +minLimitQtySpotOrder: number; // Spot minimum order quantity multiplier +minLimitQtyContractOrder: number; // Contract minimum order quantity multiplier +minLimitQtyOptionOrder: number; // Option minimum order multiplier ⋮---- -// or -// import { RestClientV5 } from 'bybit-api'; +strategyName: string; // Policy name ⋮---- -/** - * Some proxy services don't work with the proxy configuration that axios supports. - * - * For these, you can try using HttpsProxyAgent or SocksProxyAgent (depending on your proxy type, HTTP or SOCKS). - * - * The following example uses the HttpsProxyAgent (via the npm module https-proxy-agent). - */ +strategyName: string; // Policy name +⋮---- +export interface RFQCounterpartyV5 { + traderName: string; // Name of the bidder + deskCode: string; // Unique identification code of the quotation party + type: string | null; // Quoter type. LP is automated market maker, null means normal quote party +} +⋮---- +traderName: string; // Name of the bidder +deskCode: string; // Unique identification code of the quotation party +type: string | null; // Quoter type. LP is automated market maker, null means normal quote party +⋮---- +export interface CreateRFQResultV5 { + rfqId: string; // Inquiry ID + rfqLinkId: string; // Inquiry Custom ID + status: 'Active' | 'Canceled' | 'Filled' | 'Expired' | 'Failed'; // Status of the inquiry form + expiresAt: string; // Expiration time in milliseconds Unix timestamp + deskCode: string; // Inquiry party unique identification code +} ⋮---- -// Sometimes using a proxy introduces recv timestamp errors (due to the extra latency) -// If that happens, you can try increasing the recv window (which is 5000ms by default) -// recv_window: 10000, - -================ -File: examples/Websocket/Private/ws-private-v5.ts -================ -/* eslint-disable @typescript-eslint/no-empty-function */ -import { DefaultLogger, WebsocketClient, WS_KEY_MAP } from '../../../src'; +rfqId: string; // Inquiry ID +rfqLinkId: string; // Inquiry Custom ID +status: 'Active' | 'Canceled' | 'Filled' | 'Expired' | 'Failed'; // Status of the inquiry form +expiresAt: string; // Expiration time in milliseconds Unix timestamp +deskCode: string; // Inquiry party unique identification code ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from 'bybit-api'; +export interface CancelRFQResultV5 { + rfqId: string; // Inquiry ID + rfqLinkId: string; // Inquiry Custom ID +} ⋮---- -// Create & inject a custom logger to enable the trace logging level (empty function) +rfqId: string; // Inquiry ID +rfqLinkId: string; // Inquiry Custom ID ⋮---- -// trace: (...params) => console.log('trace', ...params), +export interface CancelRFQItemV5 { + rfqId: string; // Inquiry ID + rfqLinkId: string; // Inquiry Custom ID + code: number; // Cancel success or failure, 0 means success + msg: string; // Cancellation failure reason +} ⋮---- -/** - * Prepare an instance of the WebSocket client. This client handles all aspects of connectivity for you: - * - Connections are opened when you subscribe to topics - * - If key & secret are provided, authentication is handled automatically - * - If you subscribe to topics from different v5 products (e.g. spot and linear perps), - * subscription events are automatically routed to the different ws endpoints on bybit's side - * - Heartbeats/ping/pong/reconnects are all handled automatically. - * If a connection drops, the client will clean it up, respawn a fresh connection and resubscribe for you. - */ +rfqId: string; // Inquiry ID +rfqLinkId: string; // Inquiry Custom ID +code: number; // Cancel success or failure, 0 means success +msg: string; // Cancellation failure reason ⋮---- -// testnet: false, -// demoTrading: false, // set testnet to false, if you plan on using demo trading +export interface CancelAllRFQResultV5 { + data: CancelRFQItemV5[]; // Array of cancellation results +} ⋮---- -// console.log('raw message received ', JSON.stringify(data, null, 2)); +data: CancelRFQItemV5[]; // Array of cancellation results ⋮---- -// wsClient.on('exception', (data) => { -// console.error('ws exception: ', data); -// }); +export interface CreateRFQQuoteResultV5 { + rfqId: string; // Inquiry ID + quoteId: string; // Quotation ID + quoteLinkId: string; // Quotation Custom ID + expiresAt: string; // Expiration time in milliseconds Unix timestamp + deskCode: string; // Quoter's unique identification code + status: 'Active' | 'Canceled' | 'Filled' | 'Expired' | 'Failed'; // Status of quotation +} ⋮---- -/** - * For private V5 topics, us the subscribeV5() method on the ws client or use the original subscribe() method. - * - * Note: for private endpoints the "category" field is ignored since there is only one private endpoint - * (compared to one public one per category). - * The "category" is only needed for public topics since bybit has one endpoint for public events per category. - */ +rfqId: string; // Inquiry ID +quoteId: string; // Quotation ID +quoteLinkId: string; // Quotation Custom ID +expiresAt: string; // Expiration time in milliseconds Unix timestamp +deskCode: string; // Quoter's unique identification code +status: 'Active' | 'Canceled' | 'Filled' | 'Expired' | 'Failed'; // Status of quotation ⋮---- -// wsClient.subscribeV5('execution.fast', 'linear'); -// wsClient.subscribeV5('execution.fast.linear', 'linear'); -// wsClient.subscribeV5('execution.fast.spot', 'spot'); -// wsClient.subscribeV5('execution.fast.option', 'option'); +export interface ExecuteRFQQuoteResultV5 { + rfqId: string; // Inquiry ID + rfqLinkId: string; // Inquiry Custom ID + quoteId: string; // Quotation ID + status: 'Processing' | 'Rejected'; // Order status + rejectParty: string; // Empty means passed, "Taker", "Maker", "Bybit" when rejected +} ⋮---- -/** - * The following has the same effect as above, since there's only one private endpoint for V5 account topics: - */ -// wsClient.subscribe('position'); -// wsClient.subscribe('execution'); -// wsClient.subscribe(['order', 'wallet', 'greek']); +rfqId: string; // Inquiry ID +rfqLinkId: string; // Inquiry Custom ID +quoteId: string; // Quotation ID +status: 'Processing' | 'Rejected'; // Order status +rejectParty: string; // Empty means passed, "Taker", "Maker", "Bybit" when rejected ⋮---- -// To unsubscribe from topics (after a 5 second delay, in this example): -// setTimeout(() => { -// console.log('unsubscribing'); -// wsClient.unsubscribeV5('execution', 'linear'); -// }, 5 * 1000); +export interface CancelRFQQuoteResultV5 { + rfqId: string; // Inquiry ID + quoteId: string; // Quotation ID + quoteLinkId: string; // Quotation Custom ID +} ⋮---- -// Topics are tracked per websocket type -// Get a list of subscribed topics (e.g. for public v3 spot topics) (after a 5 second delay) - -================ -File: examples/Websocket/Public/ws-public-allLiquidations.ts -================ -import { - isWsAllLiquidationEvent, - RestClientV5, - WebsocketClient, -} from '../../../src'; +rfqId: string; // Inquiry ID +quoteId: string; // Quotation ID +quoteLinkId: string; // Quotation Custom ID ⋮---- -// or -// import { -// RestClientV5, -// WebsocketClient, -// isWsAllLiquidationEvent, -// } from 'bybit-api'; +export interface CancelRFQQuoteItemV5 { + rfqId: string; // Inquiry ID + quoteId: string; // Quotation ID + quoteLinkId: string; // Quotation Custom ID + code: number; // Cancel success or failure, 0 means success + msg: string; // Cancellation failure reason +} ⋮---- -function onAllLiquidationEvent(event: unknown) +rfqId: string; // Inquiry ID +quoteId: string; // Quotation ID +quoteLinkId: string; // Quotation Custom ID +code: number; // Cancel success or failure, 0 means success +msg: string; // Cancellation failure reason ⋮---- -/** - * - * If you want to receive data for all available symbols, this websocket topic - * requires you to subscribe to each symbol individually. - * - * This can be easily automated by fetching a list of symbols via the REST client, - * generating a list of topics (one per symbol), before simply passing an - * array of topics to the websocket client per product group (linear & inverse perps). - * - */ -async function start() +export interface RFQLegV5 { + category: 'linear' | 'option' | 'spot'; // Product category + symbol: string; // The unique instrument ID + side: 'buy' | 'sell'; // Inquiry direction + qty: string; // Order quantity of the instrument + isLeverage?: boolean; // For spot lending +} ⋮---- -// Make an array of topics ready for submission +category: 'linear' | 'option' | 'spot'; // Product category +symbol: string; // The unique instrument ID +side: 'buy' | 'sell'; // Inquiry direction +qty: string; // Order quantity of the instrument +isLeverage?: boolean; // For spot lending ⋮---- -// subscribe to all linear symbols +export interface RFQHedgeLegItemV5 { + category: string; + symbol: string; + side: string; + qty: string; + price?: string; +} ⋮---- -// subscribe to all inverse symbols - -================ -File: examples/Websocket/Public/ws-public-v5.ts -================ -import { DefaultLogger, WebsocketClient, WS_KEY_MAP } from '../../../src'; +export interface RFQItemV5 { + rfqId: string; // Inquiry ID + rfqLinkId: string; // Custom ID for inquiry form + counterparties: string[]; // List of bidders + expiresAt: string; // Expiration time in milliseconds Unix timestamp + strategyType: string; // Inquiry label + status: + | 'Active' + | 'Canceled' + | 'PendingFill' + | 'Filled' + | 'Expired' + | 'Failed'; // Status + acceptOtherQuoteStatus?: string; // Whether to accept non-LP quotes. "false": do not accept, "true": accept + deskCode: string; // Unique identification code of the inquiry party + anonymous?: boolean; + createdAt: number; // Time when the trade is created in epoch + updatedAt: number; // Time when the trade is updated in epoch + legs: RFQLegV5[]; // Combination transaction + hedge?: RFQHedgeLegItemV5[]; +} ⋮---- -// or -// import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from 'bybit-api'; +rfqId: string; // Inquiry ID +rfqLinkId: string; // Custom ID for inquiry form +counterparties: string[]; // List of bidders +expiresAt: string; // Expiration time in milliseconds Unix timestamp +strategyType: string; // Inquiry label ⋮---- -/** - * Prepare an instance of the WebSocket client. This client handles all aspects of connectivity for you: - * - Connections are opened when you subscribe to topics - * - If key & secret are provided, authentication is handled automatically - * - If you subscribe to topics from different v5 products (e.g. spot and linear perps), - * subscription events are automatically routed to the different ws endpoints on bybit's side - * - Heartbeats/ping/pong/reconnects are all handled automatically. - * If a connection drops, the client will clean it up, respawn a fresh connection and resubscribe for you. - */ +| 'Failed'; // Status +acceptOtherQuoteStatus?: string; // Whether to accept non-LP quotes. "false": do not accept, "true": accept +deskCode: string; // Unique identification code of the inquiry party ⋮---- -/** - * For public V5 topics, use the subscribeV5 method and include the API category this topic is for. - * Category is required, since each category has a different websocket endpoint. - */ +createdAt: number; // Time when the trade is created in epoch +updatedAt: number; // Time when the trade is updated in epoch +legs: RFQLegV5[]; // Combination transaction ⋮---- -// Linear v5 -// -> Just one topic per call -// wsClient.subscribeV5('orderbook.50.BTCUSDT', 'linear'); +export interface GetRFQRealtimeResultV5 { + list: RFQItemV5[]; // Array of RFQ items +} ⋮---- -// -> Or multiple topics in one call -// wsClient.subscribeV5( -// ['orderbook.50.BTCUSDT', 'orderbook.50.ETHUSDT'], -// 'linear' -// ); +list: RFQItemV5[]; // Array of RFQ items ⋮---- -// Inverse v5 -// wsClient.subscribeV5('orderbook.50.BTCUSD', 'inverse'); +export interface RFQHistory { + cursor: string; // Page turning mark + list: RFQItemV5[]; // Array of RFQ items +} ⋮---- -// Spot v5 -// wsClient.subscribeV5('orderbook.50.BTCUSDT', 'spot'); +cursor: string; // Page turning mark +list: RFQItemV5[]; // Array of RFQ items ⋮---- -// Option v5 -// wsClient.subscribeV5('publicTrade.BTC', 'option'); +export interface QuoteLegV5 { + category: 'spot' | 'linear' | 'option'; // Product type + symbol: string; // The unique instrument ID or name of trading contract + price: string; // Order price or quote price + qty?: string; // Order quantity + isLeverage?: boolean; // For spot lending + isHedge?: boolean; +} ⋮---- -// Use the subscribeV5() call for most subscribe calls with v5 websockets +category: 'spot' | 'linear' | 'option'; // Product type +symbol: string; // The unique instrument ID or name of trading contract +price: string; // Order price or quote price +qty?: string; // Order quantity +isLeverage?: boolean; // For spot lending ⋮---- -// Alternatively, you can also use objects in the wsClient.subscribe() call -// wsClient.subscribe({ -// topic: 'orderook.50.BTCUSDT', -// category: 'spot', -// }); +export interface RFQQuoteItemV5 { + rfqId: string; // Inquiry ID + rfqLinkId: string; // Custom ID for inquiry form + quoteId: string; // Quotation ID + quoteLinkId: string; // Quotation custom ID + expiresAt: string; // Expiration time in milliseconds Unix timestamp + deskCode: string; // Unique identification code of quotation party + anonymous?: boolean; + status: + | 'Active' + | 'Canceled' + | 'PendingFill' + | 'Filled' + | 'Expired' + | 'Failed'; // Status + execQuoteSide: string; // Execute quote direction, buy or sell + createdAt: number; // Time when the trade is created in epoch + updatedAt: number; // Time when the trade is updated in epoch + quoteBuyList: QuoteLegV5[]; // Quotation buy direction + quoteSellList: QuoteLegV5[]; // Quotation sell direction +} ⋮---- -/** - * For private V5 topics, just call the same subscribeV5() method on the ws client or use the original subscribe() method. - * - * Note: for private endpoints the "category" field is ignored since there is only one private endpoint - * (compared to one public one per category) - */ +rfqId: string; // Inquiry ID +rfqLinkId: string; // Custom ID for inquiry form +quoteId: string; // Quotation ID +quoteLinkId: string; // Quotation custom ID +expiresAt: string; // Expiration time in milliseconds Unix timestamp +deskCode: string; // Unique identification code of quotation party ⋮---- -// wsClient.subscribeV5('position', 'linear'); -// wsClient.subscribeV5('execution', 'linear'); -// wsClient.subscribeV5(['order', 'wallet', 'greek'], 'linear'); +| 'Failed'; // Status +execQuoteSide: string; // Execute quote direction, buy or sell +createdAt: number; // Time when the trade is created in epoch +updatedAt: number; // Time when the trade is updated in epoch +quoteBuyList: QuoteLegV5[]; // Quotation buy direction +quoteSellList: QuoteLegV5[]; // Quotation sell direction ⋮---- -// To unsubscribe from topics (after a 5 second delay, in this example): +export interface RFQTradeLegV5 { + category: 'linear' | 'option' | 'spot'; // Product category + orderId: string; // Bybit order ID + symbol: string; // The unique instrument ID + side: 'buy' | 'sell'; // Direction + price: string; // Execution price + qty: string; // Number of executions + isLeverage?: boolean; // For spot lending + markPrice: string; // MarkPrice (contract) at transaction time, indexPrice for spot + execFee: string; // Fee for taker or maker in base currency + execId: string; // Unique exec(trade) ID from exchange + resultCode: number; // Status code, 0 means success + resultMessage: string; // Error message about resultCode + rejectParty: string; // Empty if Filled, "Taker"/"Maker"/"bybit" if Rejected +} ⋮---- -// Topics are tracked per websocket type -// Get a list of subscribed topics (e.g. for public v3 spot topics) (after a 5 second delay) - -================ -File: src/types/request/v5-spot-leverage-token.ts -================ -import { LTOrderTypeV5 } from '../shared-v5'; +category: 'linear' | 'option' | 'spot'; // Product category +orderId: string; // Bybit order ID +symbol: string; // The unique instrument ID +side: 'buy' | 'sell'; // Direction +price: string; // Execution price +qty: string; // Number of executions +isLeverage?: boolean; // For spot lending +markPrice: string; // MarkPrice (contract) at transaction time, indexPrice for spot +execFee: string; // Fee for taker or maker in base currency +execId: string; // Unique exec(trade) ID from exchange +resultCode: number; // Status code, 0 means success +resultMessage: string; // Error message about resultCode +rejectParty: string; // Empty if Filled, "Taker"/"Maker"/"bybit" if Rejected ⋮---- -export interface PurchaseSpotLeveragedTokenParamsV5 { - ltCoin: string; - amount: string; - serialNo?: string; +export interface RFQTradeV5 { + rfqId: string; // Inquiry ID + quoteId: string; // Completed inquiry form and executed quotation ID + quoteSide: 'buy' | 'sell'; // Executed quotation direction + strategyType: string; // Inquiry label + status: 'Filled' | 'Rejected'; // Status + rfqDeskCode: string; // Unique identification code of inquiry party + quoteDestCode: string; // Unique identification code of quotation party + createdAt: number; // Time when trade is created in epoch + updatedAt: number; // Time when trade is updated in epoch + legs: RFQTradeLegV5[]; // Combination transaction } ⋮---- -export interface RedeemSpotLeveragedTokenParamsV5 { - ltCoin: string; - quantity: string; - serialNo?: string; -} +rfqId: string; // Inquiry ID +quoteId: string; // Completed inquiry form and executed quotation ID +quoteSide: 'buy' | 'sell'; // Executed quotation direction +strategyType: string; // Inquiry label +status: 'Filled' | 'Rejected'; // Status +rfqDeskCode: string; // Unique identification code of inquiry party +quoteDestCode: string; // Unique identification code of quotation party +createdAt: number; // Time when trade is created in epoch +updatedAt: number; // Time when trade is updated in epoch +legs: RFQTradeLegV5[]; // Combination transaction ⋮---- -export interface GetSpotLeveragedTokenOrderHistoryParamsV5 { - ltCoin?: string; - orderId?: string; - startTime?: number; - endTime?: number; - limit?: number; - ltOrderType?: LTOrderTypeV5; - serialNo?: string; +export interface RFQPublicTradeLegV5 { + category: 'linear' | 'option' | 'spot'; // Product category + symbol: string; // The unique instrument ID + side: 'buy' | 'sell'; // Inquiry direction + price: string; // Execution price + qty: string; // Number of executions + markPrice: string; // MarkPrice (contract) at transaction time, indexPrice for spot } ⋮---- -export interface GetVIPMarginDataParamsV5 { - vipLevel?: string; - currency?: string; -} +category: 'linear' | 'option' | 'spot'; // Product category +symbol: string; // The unique instrument ID +side: 'buy' | 'sell'; // Inquiry direction +price: string; // Execution price +qty: string; // Number of executions +markPrice: string; // MarkPrice (contract) at transaction time, indexPrice for spot ⋮---- -export interface GetSpotMarginCurrencyDataParamsV5 { - currency?: string; +export interface RFQPublicTradeV5 { + rfqId: string; // Inquiry ID + strategyType: string; // Inquiry label + createdAt: number; // Time when trade is created in epoch + updatedAt: number; // Time when trade is updated in epoch + legs: RFQPublicTradeLegV5[]; // Combination transaction } ⋮---- -// Spot Margin Trade (UTA) endpoints -export interface ManualBorrowParamsV5 { - coin: string; - amount: string; -} +rfqId: string; // Inquiry ID +strategyType: string; // Inquiry label +createdAt: number; // Time when trade is created in epoch +updatedAt: number; // Time when trade is updated in epoch +legs: RFQPublicTradeLegV5[]; // Combination transaction ⋮---- -export interface GetMaxBorrowableAmountParamsV5 { - currency: string; +export interface AcceptNonLPQuoteResultV5 { + rfqId: string; // Inquiry ID } ⋮---- -export interface GetPositionTiersParamsV5 { - currency?: string; +rfqId: string; // Inquiry ID +⋮---- +export interface RFQDetailQuoteLegV5 { + category: string; + symbol: string; + price: string; + qty: string; + isHedge?: boolean; } ⋮---- -export interface GetCoinStateParamsV5 { - currency?: string; +export interface RFQDetailQuoteV5 { + quoteId: string; + deskCode: string; + anonymous?: boolean; + status: string; + createdAt: string; + updatedAt: string; + expiresAt: string; + quoteBuyList?: RFQDetailQuoteLegV5[]; + quoteSellList?: RFQDetailQuoteLegV5[]; } ⋮---- -export interface GetAvailableAmountToRepayParamsV5 { - currency: string; +export interface RFQDetailTradeLegV5 { + category: string; + orderId: string; + symbol: string; + side: string; + price: string; + qty: string; + markPrice: string; + execFee: string; + extraFees: string; + execId: string; + resultCode: number; + resultMessage: string; + rejectParty: string; } ⋮---- -export interface SetSpotMarginLeverageParamsV5 { - leverage: string; - currency?: string; +export interface RFQDetailItemV5 { + rfqId: string; + rfqLinkId: string; + counterparties: string[]; + expiresAt: string; + strategyType: string; + status: string; + acceptOtherQuoteStatus?: boolean; + execQuoteId?: string; + execQuoteSide?: string; + deskCode: string; + anonymous?: boolean; + createdAt: string; + updatedAt: string; + legs: RFQLegV5[]; + hedge?: RFQHedgeLegItemV5[]; + quoteList?: RFQDetailQuoteV5[]; + tradeLegs?: RFQDetailTradeLegV5[]; } + +================ +File: src/types/response/v5-rwa.ts +================ +/** + * V5 RWA (Real World Assets) earn responses. + */ ⋮---- -export interface ManualRepayWithoutConversionParamsV5 { +export interface RWAProductV5 { + productId: number; coin: string; - amount?: string; - /** - * ALL: fixed + floating (floating first); FIXED: fixed only; FLEXIBLE: floating only. Default: FLEXIBLE. - */ - repaymentType?: 'ALL' | 'FIXED' | 'FLEXIBLE'; + assetSymbol: string; + manager: string; + baseApr: string; + bonusApr: string; + savingType: 'Flexible' | 'Fixed' | string; + duration: number; + nav: string; + minStakeAmount: string; + maxStakeAmount: string; + userMaxAmount: string; + userQuota: string; + minRedeemShare: string; + redeemFeeRate: string; + subscriptionFee: string; + extLink: string; + amountPrecision: number; + sharePrecision: number; } ⋮---- -/** - * ALL: fixed + floating (floating first); FIXED: fixed only; FLEXIBLE: floating only. Default: FLEXIBLE. - */ -⋮---- -export interface GetAutoRepayModeParamsV5 { - currency?: string; // Coin name, uppercase only. If not passed, returns all currencies +export interface RWAProductListResultV5 { + list: RWAProductV5[]; } ⋮---- -currency?: string; // Coin name, uppercase only. If not passed, returns all currencies -⋮---- -export interface SetAutoRepayModeParamsV5 { - currency?: string; // Coin name, uppercase only. If not passed, enables for all currencies - autoRepayMode: '0' | '1'; // 0: Off, 1: On +export interface PlaceRWAOrderResultV5 { + orderId: string; + orderLinkId: string; } ⋮---- -currency?: string; // Coin name, uppercase only. If not passed, enables for all currencies -autoRepayMode: '0' | '1'; // 0: Off, 1: On -⋮---- -export interface GetSpotMarginLiabilityInfoParamsV5 { - currency: string; +export interface RWAPositionV5 { + productId: number; + coin: string; + assetSymbol: string; + effectiveShare: string; + processingStakeAmount: string; + processingRedeemShare: string; + bonusEarned: string; + nav: string; + holdAmount: string; + duration: number; } ⋮---- -export interface FixedRateBorrowParamsV5 { - orderCurrency: string; - orderAmount: string; - /** e.g. 0.02 = 2% p.a. */ - annualRate: string; - /** 7, 14, 30, 90, 180 (days) */ - term: string; - /** 1: auto repayment; 2: transfer to flexible loan */ - repayType?: '1' | '2'; +export interface RWAPositionListResultV5 { + list: RWAPositionV5[]; } ⋮---- -/** e.g. 0.02 = 2% p.a. */ -⋮---- -/** 7, 14, 30, 90, 180 (days) */ -⋮---- -/** 1: auto repayment; 2: transfer to flexible loan */ +export interface RWAOrderV5 { + orderId: string; + orderLinkId: string; + orderType: 'Stake' | 'Redeem'; + productId: number; + coin: string; + stakeAmount?: string; + redeemShares?: string; + status: 'Processing' | 'Success' | 'Failed' | string; + accountType: 'FUND' | 'UNIFIED' | string; + createdTime: number; + updatedTime: number; + settledShares?: string; + settledAmount?: string; +} ⋮---- -export interface GetFixedRateBorrowOrderInfoParamsV5 { - orderId?: string; - orderCurrency?: string; - state?: string; - term?: string; - limit?: string; - cursor?: string; +export interface RWAOrderListResultV5 { + list: RWAOrderV5[]; + nextPageCursor: string; } ⋮---- -export interface GetFixedRateBorrowContractInfoParamsV5 { - orderId?: string; - orderCurrency?: string; - term?: string; - limit?: string; - cursor?: string; +export interface RWANavChartPointV5 { + date: string; + nav: string; } ⋮---- -export interface GetFixedRateBorrowOrderQuoteParamsV5 { - orderCurrency: string; - term?: string; - orderBy?: 'apy' | 'term' | 'quantity'; - sort?: 0 | 1; - limit?: number; +export interface RWANavChartResultV5 { + productId: number; + list: RWANavChartPointV5[]; +} + +================ +File: src/types/response/v5-spot-x.ts +================ +export interface LaunchpoolPoolV5 { + poolId: string; + stakeCoin: string; + apr: string; + totalStakedAmount: string; + participantCount: string; } ⋮---- -export interface RenewFixedRateBorrowParamsV5 { - loanId: string; - qty?: string; +export interface LaunchpoolProjectV5 { + projectId: string; + activityCoin: string; + rewardCoin: string; + status: number; + totalReward: string; + stakeStartTime: string; + stakeEndTime: string; + totalParticipantCount: string; + pools: LaunchpoolPoolV5[]; } ⋮---- -export interface GetFlexibleAvailableInventoryParamsV5 { - currency: string; +export interface LaunchpoolProjectListResultV5 { + list: LaunchpoolProjectV5[]; + nextPageCursor: string; } ⋮---- -export interface GetFixedRateAvailableInventoryParamsV5 { - currency: string; - term: string; - annualRate: string; +export interface LaunchpoolActivityLogItemV5 { + stakeCoin: string; + rewardCoin: string; + amount: string; + type: number; + status: number; + createdTime: string; + orderId: string; } - -================ -File: src/types/response/v5-crypto-loan.ts -================ -export interface CollateralCoinV5 { - collateralAccuracy: number; - initialLTV: string; - liquidationLTV: string; - marginCallLTV: string; - maxLimit: string; +⋮---- +export interface LaunchpoolActivityLogResultV5 { + list: LaunchpoolActivityLogItemV5[]; + total: number; + pageSize: number; + current: number; } ⋮---- -export interface VipCollateralCoinsV5 { - list: CollateralCoinV5[]; - vipLevel: string; +export interface LaunchpoolStakingPositionV5 { + stakeCoin: string; + rewardCoin: string; + stakeAmount: string; + totalReward: string; + autoRedeemDate: string; } ⋮---- -export interface BorrowableCoinV5 { - borrowingAccuracy: number; - currency: string; - flexibleHourlyInterestRate: string; - hourlyInterestRate7D: string; - hourlyInterestRate14D: string; - hourlyInterestRate30D: string; - hourlyInterestRate90D: string; - hourlyInterestRate180D: string; - maxBorrowingAmount: string; - minBorrowingAmount: string; +export interface LaunchpoolCurrentStakingResultV5 { + totalInvestmentUsd: string; + totalEarningsUsd: string; + todayEarningsUsd: string; + list: LaunchpoolStakingPositionV5[]; } ⋮---- -export interface VipBorrowableCoinsV5 { - list: BorrowableCoinV5[]; - vipLevel: string; +export interface LaunchpoolUserHistoryItemV5 { + stakeCoin: string; + rewardCoin: string; + totalReward: string; + stakeStartTime: string; + stakeEndTime: string; } ⋮---- -export interface AccountBorrowCollateralLimitV5 { - collateralCurrency: string; - loanCurrency: string; - maxCollateralAmount: string; - maxLoanAmount: string; - minCollateralAmount: string; - minLoanAmount: string; +export interface LaunchpoolUserHistoryResultV5 { + list: LaunchpoolUserHistoryItemV5[]; + total: number; + pageSize: number; + current: number; } ⋮---- -export interface UnpaidLoanOrderV5 { - collateralAmount: string; - collateralCurrency: string; - currentLTV: string; - expirationTime: string; - hourlyInterestRate: string; - loanCurrency: string; - loanTerm: string; - orderId: string; - residualInterest: string; - residualPenaltyInterest: string; - totalDebt: string; +export interface PuzzleProjectV5 { + projectId: string; + activityCoin: string; + rewardCoin: string; + status: number; + startTime: string; + endTime: string; + totalReward: string; + participantCount: string; } ⋮---- -export interface RepaymentHistoryV5 { - collateralCurrency: string; - collateralReturn: string; - loanCurrency: string; - loanTerm: string; - orderId: string; - repayAmount: string; - repayId: string; - repayStatus: number; - repayTime: string; - repayType: string; +export interface PuzzleProjectListResultV5 { + list: PuzzleProjectV5[]; + nextPageCursor: string; } ⋮---- -export interface CompletedLoanOrderV5 { - borrowTime: string; - collateralCurrency: string; - expirationTime: string; - hourlyInterestRate: string; - initialCollateralAmount: string; - initialLoanAmount: string; - loanCurrency: string; - loanTerm: string; - orderId: string; - repaidInterest: string; - repaidPenaltyInterest: string; +export interface TokenSplashProjectV5 { status: number; + projectId: string; + activityCoin: string; + rewardCoin: string; + totalReward: string; + participantCount: string; + registrationStartTime: string; + activityEndTime: string; +} +⋮---- +export interface TokenSplashProjectListResultV5 { + list: TokenSplashProjectV5[]; + nextPageCursor: string; } -export interface LoanLTVAdjustmentHistoryV5 { - collateralCurrency: string; - orderId: string; - adjustId: string; - adjustTime: string; - preLTV: string; - afterLTV: string; - direction: number; - amount: string; +⋮---- +export interface TokenSplashTradeTaskV5 { + tradeRequiredAmount: string; + tradeUnit: string; + /** Token counted by the trade task. On-chain tasks use the activity token ID. */ + tradeToken?: string; + tradedAmount: string; + maxRewardAmount: string; + estimatedRewardAmount: string; + rewardCoin: string; } ⋮---- -// New Crypto Loan Types +/** Token counted by the trade task. On-chain tasks use the activity token ID. */ ⋮---- -export interface BorrowCoinV5 { - currency: string; - fixedBorrowable: boolean; - fixedBorrowingAccuracy: number; - flexibleBorrowable: boolean; - flexibleBorrowingAccuracy: number; - maxBorrowingAmount: string; - minFixedBorrowingAmount: string; - minFlexibleBorrowingAmount: string; - vipLevel: string; - flexibleAnnualizedInterestRate: string; - annualizedInterestRate7D: string; - annualizedInterestRate14D: string; - annualizedInterestRate30D: string; - annualizedInterestRate60D: string; - annualizedInterestRate90D: string; - annualizedInterestRate180D: string; +export interface TokenSplashUserActivityItemV5 { + projectId: string; + activityCoin: string; + tradeTask: TokenSplashTradeTaskV5; } ⋮---- -export interface CollateralRatioV5 { - collateralRatio: string; - maxValue: string; - minValue: string; +export interface TokenSplashUserActivityResultV5 { + list: TokenSplashUserActivityItemV5[]; +} + +================ +File: src/types/response/v5-spreadtrading.ts +================ +export interface SpreadInstrumentInfoV5 { + symbol: string; + contractType: 'FundingRateArb' | 'CarryTrade' | 'FutureSpread' | 'PerpBasis'; + status: 'Trading' | 'Settling'; + baseCoin: string; + quoteCoin: string; + settleCoin: string; + tickSize: string; + minPrice: string; + maxPrice: string; + lotSize: string; + minSize: string; + maxSize: string; + launchTime: string; + deliveryTime: string; + legs: { + symbol: string; + contractType: 'LinearPerpetual' | 'LinearFutures' | 'Spot'; + }[]; } ⋮---- -export interface CollateralRatioConfigV5 { - collateralRatioList: CollateralRatioV5[]; - currencies: string; +export interface SpreadOrderbookResponseV5 { + s: string; // Symbol + b: [string, string][]; // Bids array [price, size] + a: [string, string][]; // Asks array [price, size] + u: number; // Update ID + ts: number; // Timestamp + seq: number; // Sequence + cts: number; // Cross timestamp } ⋮---- -export interface CurrencyLiquidationV5 { - currency: string; - liquidationOrder: number; +s: string; // Symbol +b: [string, string][]; // Bids array [price, size] +a: [string, string][]; // Asks array [price, size] +u: number; // Update ID +ts: number; // Timestamp +seq: number; // Sequence +cts: number; // Cross timestamp +⋮---- +export interface SpreadTickerV5 { + symbol: string; // Spread combination symbol name + bidPrice: string; // Bid 1 price + bidSize: string; // Bid 1 size + askPrice: string; // Ask 1 price + askSize: string; // Ask 1 size + lastPrice: string; // Last trade price + highPrice24h: string; // The highest price in the last 24 hours + lowPrice24h: string; // The lowest price in the last 24 hours + prevPrice24h: string; // Price 24 hours ago + volume24h: string; // Volume for 24h } ⋮---- -export interface CollateralDataV5 { - collateralRatioConfigList: CollateralRatioConfigV5[]; - currencyLiquidationList: CurrencyLiquidationV5[]; +symbol: string; // Spread combination symbol name +bidPrice: string; // Bid 1 price +bidSize: string; // Bid 1 size +askPrice: string; // Ask 1 price +askSize: string; // Ask 1 size +lastPrice: string; // Last trade price +highPrice24h: string; // The highest price in the last 24 hours +lowPrice24h: string; // The lowest price in the last 24 hours +prevPrice24h: string; // Price 24 hours ago +volume24h: string; // Volume for 24h +⋮---- +export interface SpreadRecentTradeV5 { + execId: string; // Execution ID + symbol: string; // Spread combination symbol name + price: string; // Trade price + size: string; // Trade size + side: 'Buy' | 'Sell'; // Side of taker + time: string; // Trade time (ms) + seq?: string; } ⋮---- -// Additional New Crypto Loan Types +execId: string; // Execution ID +symbol: string; // Spread combination symbol name +price: string; // Trade price +size: string; // Trade size +side: 'Buy' | 'Sell'; // Side of taker +time: string; // Trade time (ms) ⋮---- -export interface AdjustCollateralAmountV5 { - adjustId: number; +export interface SpreadOpenOrderV5 { + symbol: string; + baseCoin: string; + orderType: 'Market' | 'Limit'; + orderLinkId: string; + side: 'Buy' | 'Sell'; + timeInForce: 'GTC' | 'FOK' | 'IOC' | 'PostOnly'; + orderId: string; + leavesQty: string; + orderStatus: 'New' | 'PartiallyFilled'; + cumExecQty: string; + price: string; + qty: string; + createdTime: string; + updatedTime: string; } ⋮---- -export interface CollateralAdjustmentHistoryV5 { - adjustId: number; - adjustTime: number; - afterLTV: string; - amount: string; - collateralCurrency: string; - direction: number; - preLTV: string; - status: number; +export interface SpreadOrderHistoryV5 { + symbol: string; + orderType: 'Market' | 'Limit'; + orderLinkId: string; + orderId: string; + contractType: 'FundingRateArb' | 'CarryTrade' | 'FutureSpread' | 'PerpBasis'; + orderStatus: 'Rejected' | 'Cancelled' | 'Filled'; + price: string; + orderQty: string; + timeInForce: 'GTC' | 'FOK' | 'IOC' | 'PostOnly'; + baseCoin: string; + createdAt: string; + updatedAt: string; + side: 'Buy' | 'Sell'; + leavesQty: string; + settleCoin: string; + cumExecQty: string; + qty: string; + leg1Symbol: string; + leg1ProdType: 'Futures' | 'Spot'; + leg1OrderId: string; + leg1Side: string; + leg2ProdType: 'Futures' | 'Spot'; + leg2OrderId: string; + leg2Symbol: string; + leg2Side: string; + cxlRejReason: string; + cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee } ⋮---- -export interface BorrowListV5 { - fixedTotalDebt: string; - fixedTotalDebtUSD: string; - flexibleHourlyInterestRate: string; - flexibleTotalDebt: string; - flexibleTotalDebtUSD: string; - loanCurrency: string; +cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee +⋮---- +export interface SpreadTradeLegV5 { + symbol: string; + side: 'Buy' | 'Sell'; + execPrice: string; + execTime: string; + execValue: string; + execType: string; + category: 'linear' | 'spot'; + execQty: string; + execFee: string; + feeCurrency: string; // Trading fee currency + execId: string; } ⋮---- -export interface CollateralListV5 { - amount: string; - amountUSD: string; - currency: string; - ltv: string; +feeCurrency: string; // Trading fee currency +⋮---- +export interface SpreadTradeV5 { + symbol: string; + orderLinkId: string; + side: 'Buy' | 'Sell'; + orderId: string; + execPrice: string; + execTime: string; + execType: 'Trade'; + execQty: string; + execId: string; + legs: SpreadTradeLegV5[]; + extraFees: string; } ⋮---- -export interface SupplyListV5 { - amount: string; - amountUSD: string; - currency: string; +/** GET /v5/spread/max-qty */ +export interface SpreadMaxQtyResultV5 { + /** Maximum order quantity (available balance for the spread order). */ + ab: string; } ⋮---- -export interface CryptoLoanPositionV5 { - borrowList: BorrowListV5[]; - collateralList: CollateralListV5[]; - supplyList: SupplyListV5[]; - totalCollateral: string; - totalDebt: string; - totalSupply: string; - colRes?: string; +/** Maximum order quantity (available balance for the spread order). */ + +================ +File: src/types/response/v5-strategy.ts +================ +import { + OrderSideV5, + PositionIdx, + PovModeV5, + StrategyCategoryV5, + StrategyPreferV5, + StrategyTypeV5, +} from '../shared-v5'; +⋮---- +export interface CreateStrategyOrderResultV5 { + strategyId: string; + /** null when creation succeeded */ + result: string | null; } ⋮---- -// Flexible Loan Types +/** null when creation succeeded */ ⋮---- -export interface BorrowFlexibleV5 { - orderId: string; +export interface StopStrategyResultV5 { + strategyId: string; } ⋮---- -export interface RepayFlexibleV5 { - repayId: string; +export interface StrategyListItemV5 { + strategyId: string; + category: StrategyCategoryV5; + symbol: string; + side: OrderSideV5; + size: string; + strategyType: StrategyTypeV5; + /** 2: running, 3: terminated, 4: terminated unfilled, 5: paused, 6: untriggered */ + status: 2 | 3 | 4 | 5 | 6; + executedSize: string; + executedAvgPrice: string; + executedStartTimeE3: string; + executedEndTimeE3: string; + createdTimeE3: string; + updatedTimeE3: string; + reduceOnly: boolean; + triggerPrice: string; + isTriggered: boolean; + leverageType: 0 | 1; + terminateType: number; + terminateRemark: string; + triggerCount: string; + tradingCount: string; + realizedPnl: string; + strategyName: string; + strategyPrefer: StrategyPreferV5 | string; + duration: number; + executedDuration: number; + isRandom: boolean; + interval: number; + limitPrice: string; + chasePercentE4: string; + chaseDistance: string; + maxChasePrice: string; + chaseOrderPrice: string; + chasePrice: string; + postOnly: number; + isRebalance: boolean; + orderType: string; + orderPriceOffset: string; + strategySl: string; + strategyTp: string; + arbitrageOrders: unknown[]; + positionValue: string; + filledPositionValue: string; + /** POV only */ + mode?: PovModeV5 | string; + participationRate?: string; + referenceWindow?: string; + depthReference?: string; } ⋮---- -export interface OngoingFlexibleLoanV5 { - hourlyInterestRate: string; - loanCurrency: string; - totalDebt: string; - unpaidAmount: string; - unpaidInterest: string; +/** 2: running, 3: terminated, 4: terminated unfilled, 5: paused, 6: untriggered */ +⋮---- +/** POV only */ +⋮---- +export interface StrategyListResultV5 { + list: StrategyListItemV5[]; + nextCursor: string; + prevCursor: string; } ⋮---- -export interface BorrowHistoryFlexibleV5 { - borrowTime: number; - initialLoanAmount: string; - loanCurrency: string; +export interface StrategyOrderListItemV5 { + strategyId: string; orderId: string; - status: number; + symbol: string; + side: OrderSideV5; + size: string; + price: string; + /** 2: created, 3: create failed, 4: partially filled, 5: fully filled, 6: rejected, 7: canceled */ + status: string; + executedSize: string; + dealTimeE3: string; + parentOrderId: string; + createdTimeE3: string; + updatedTimeE3: string; + code: number; + msg: string; + category: StrategyCategoryV5; + positionIdx: PositionIdx; + leverageType: 0 | 1; + tpPrice: string; + slPrice: string; + orderType: string; + orderPriceOffset: string; + positionValue: string; + filledPositionValue: string; } ⋮---- -export interface RepaymentHistoryFlexibleV5 { - loanCurrency: string; - repayAmount: string; - repayId: string; - repayStatus: number; - repayTime: number; - repayType: number; +/** 2: created, 3: create failed, 4: partially filled, 5: fully filled, 6: rejected, 7: canceled */ +⋮---- +export interface StrategyOrderListResultV5 { + list: StrategyOrderListItemV5[]; + nextCursor: string; + prevCursor: string; } + +================ +File: src/types/shared.ts +================ +import { RestClientV5 } from '../rest-client-v5'; +import { SpotClientV3 } from '../spot-client-v3'; ⋮---- -// Fixed Loan Types +export type RESTClient = SpotClientV3 | RestClientV5; ⋮---- -export interface SupplyOrderQuoteFixedV5 { - orderCurrency: string; - term: number; - annualRate: string; - qty: string; -} +export type numberInString = string; ⋮---- -export interface BorrowOrderQuoteFixedV5 { - orderCurrency: string; - term: number; - annualRate: string; - qty: string; -} +export type OrderSide = 'Buy' | 'Sell'; ⋮---- -export interface CreateBorrowOrderFixedV5 { - orderId: string; -} +export type KlineInterval = + | '1m' + | '3m' + | '5m' + | '15m' + | '30m' + | '1h' + | '2h' + | '4h' + | '6h' + | '12h' + | '1d' + | '1w' + | '1M'; ⋮---- -export interface CreateSupplyOrderFixedV5 { - orderId: string; -} +export type KlineIntervalV3 = + | '1' + | '3' + | '5' + | '15' + | '30' + | '60' + | '120' + | '240' + | '360' + | '720' + | 'D' + | 'W' + | 'M'; ⋮---- -export interface BorrowContractInfoFixedV5 { - annualRate: string; - autoRepay: string; // Deprecated - borrowCurrency: string; - borrowTime: string; - interestPaid: string; - loanId: string; - orderId: string; - repayType: string; // 1: Auto Repayment; 2: Transfer to flexible loan; 0: No Automatic Repayment - repaymentTime: string; - residualPenaltyInterest: string; - residualPrincipal: string; - status: number; - term: string; +export interface APIRateLimit { + /** Remaining requests to this endpoint before the next reset */ + remainingRequests: number; + /** Max requests for this endpoint per rollowing window (before next reset) */ + maxRequests: number; + /** + * Timestamp when the rate limit resets if you have exceeded your current maxRequests. + * Otherwise, this is approximately your current timestamp. + */ + resetAtTimestamp: number; } ⋮---- -autoRepay: string; // Deprecated +/** Remaining requests to this endpoint before the next reset */ ⋮---- -repayType: string; // 1: Auto Repayment; 2: Transfer to flexible loan; 0: No Automatic Repayment +/** Max requests for this endpoint per rollowing window (before next reset) */ ⋮---- -export interface SupplyContractInfoFixedV5 { - annualRate: string; - supplyCurrency: string; - supplyTime: string; - supplyAmount: string; - interestPaid: string; - supplyId: string; - orderId: string; - redemptionTime: string; - penaltyInterest: string; - actualRedemptionTime: string; - status: number; - term: string; -} +/** + * Timestamp when the rate limit resets if you have exceeded your current maxRequests. + * Otherwise, this is approximately your current timestamp. + */ ⋮---- -export interface BorrowOrderInfoFixedV5 { - annualRate: string; - orderId: number; - orderTime: string; - filledQty: string; - orderQty: string; - orderCurrency: string; - state: number; - term: number; - repayType: string; // 1: Auto Repayment; 2: Transfer to flexible loan; 0: No Automatic Repayment - strategyType?: 'PARTIAL' | 'FULL' | string; +export interface APIResponseV3 { + retCode: number; + retMsg: 'OK' | string; + result: TResult; + retExtInfo: TExtInfo; + /** + * These are per-UID per-endpoint rate limits, automatically parsed from response headers if available. + * + * Note: + * - this is primarily for V5 (or newer) APIs. + * - these rate limits are per-endpoint per-account, so will not appear for public API calls + */ + rateLimitApi?: APIRateLimit; } ⋮---- -repayType: string; // 1: Auto Repayment; 2: Transfer to flexible loan; 0: No Automatic Repayment +/** + * These are per-UID per-endpoint rate limits, automatically parsed from response headers if available. + * + * Note: + * - this is primarily for V5 (or newer) APIs. + * - these rate limits are per-endpoint per-account, so will not appear for public API calls + */ +⋮---- +export type APIResponseV3WithTime = APIResponseV3< + TResult, + TExtInfo +> & { time: number }; ⋮---- -export interface FixedLoanAvailableInventoryV5 { - currency: string; - term: string; - annualRate: string; - availableInventory: string; - updateTime: string; +/** Flat response envelope used by the P2P chat APIs. */ +export interface APIP2PChatResponse { + ret_code: number; + ret_msg: string; + result: TResult; + rateLimitApi?: APIRateLimit; } ⋮---- -export interface FlexibleLoanAvailableInventoryV5 { - currency: string; - availableInventory: string; - updateTime: string; +export interface APIP2PResponse { + ret_code: number; + ret_msg: string; + result: { + result: TResult; + totalRows: string; + totalPages: string; + currentPage: string; + dayLimit: string; + showDayLimit: boolean; + }; + ext_code: string; + ext_info: TExtInfo; + time_now: string; } ⋮---- -export interface SupplyOrderInfoFixedV5 { - annualRate: string; - orderId: number; - orderTime: string; - filledQty: string; - orderQty: string; - orderCurrency: string; - state: number; - term: number; +/** + * Request Parameter Types + */ +export interface SymbolParam { + symbol: string; } ⋮---- -export interface RepayFixedV5 { - repayId: string; +export interface SymbolLimitParam { + symbol: string; + limit?: TLimit; } ⋮---- -export interface RepaymentHistoryFixedV5 { - details: { - loanCurrency: string; - loanId: string; - repayAmount: string; - }[]; - loanCurrency: string; - repayAmount: string; - repayId: string; - repayStatus: number; - repayTime: number; - repayType: number; +export interface SymbolPeriodLimitParam { + symbol: string; + period: string; + limit?: TLimit; } ⋮---- -export interface RenewBorrowOrderFixedV5 { - orderId: string; +export interface SymbolFromLimitParam { + symbol: string; + from?: number; + limit?: number; } ⋮---- -export interface RenewOrderInfoFixedV5 { - amount: string; - autoRepay: number; - borrowCurrency: string; - contractNo: string; - dueTime: string; - loanId: string; - orderId: number; - renewLoanNo: string; - time: string; +export interface SymbolIntervalFromLimitParam { + symbol: string; + interval: string; + from: number; + limit?: number; } ⋮---- -// Institutional Loan Types -⋮---- -export interface InstitutionalLendingProductInfoV5 { - productId: string; - leverage: string; - supportSpot: number; - supportContract: number; - supportMarginTrading: number; - withdrawLine: string; - transferLine: string; - spotBuyLine: string; - spotSellLine: string; - contractOpenLine: string; - liquidationLine: string; - stopLiquidationLine: string; - contractLeverage: string; - transferRatio: string; - spotSymbols: unknown[]; - contractSymbols: unknown[]; - supportUSDCContract: number; - supportUSDCOptions: number; - USDTPerpetualOpenLine?: string; - USDCContractOpenLine?: string; - USDCOptionsOpenLine?: string; - USDTPerpetualCloseLine?: string; - USDCContractCloseLine?: string; - USDCOptionsCloseLine?: string; - USDTPerpetualLeverage?: { symbol: string; leverage: string }[]; - USDCContractLeverage?: { symbol: string; leverage: string }[]; - deferredLiquidationLine?: string; - deferredLiquidationTime?: string; - marginLeverage?: string; - /** `0`: Default, `1`: CTA, `2`: Hedge */ - productType?: '0' | '1' | '2' | string; +export interface CoinParam { + coin: string; } ⋮---- -/** `0`: Default, `1`: CTA, `2`: Hedge */ -⋮---- -export interface InstitutionalLendingCoinDeltaItemV5 { - coin: string; - coinDeltaSize: string; - coinDeltaAvailableAmount: string; - coinDeltaAmount: string; +export interface WalletFundRecordsReq { + start_date?: string; + end_date?: string; + currency?: string; + coin?: string; + wallet_fund_type?: string; + page?: number; + limit?: number; } ⋮---- -export interface InstitutionalLendingCoinDeltaAmountV5 { - riskUnitDeltaAmount: string; - riskUnitDeltaAvailableAmount: string; - riskUnitDelta?: string; - list: InstitutionalLendingCoinDeltaItemV5[]; +export interface WithdrawRecordsReq { + start_date?: string; + end_date?: string; + coin?: string; + status?: string; + page?: number; + limit?: number; } ⋮---- -export interface UnpaidInfoV5 { - token: string; // Coin - unpaidQty: string; // Unpaid principle - unpaidInterest: string; // Unpaid interest +export interface AssetExchangeRecordsReq { + limit?: number; + from?: number; + direction?: string; } ⋮---- -token: string; // Coin -unpaidQty: string; // Unpaid principle -unpaidInterest: string; // Unpaid interest +/** + * Response types + */ ⋮---- -export interface BalanceInfoV5 { - token: string; // Margin coin - price: string; // Margin coin price - qty: string; // Margin coin quantity - convertedAmount: string; // Margin conversion amount +export interface LeverageFilter { + min_leverage: numberInString; + max_leverage: numberInString; + leverage_step: numberInString; +} +export interface PriceFilter { + min_price: numberInString; + max_price: numberInString; + tick_size: numberInString; } ⋮---- -token: string; // Margin coin -price: string; // Margin coin price -qty: string; // Margin coin quantity -convertedAmount: string; // Margin conversion amount +export interface LotSizeFilter { + max_trading_qty: number; + min_trading_qty: number; + qty_step: number; +} ⋮---- -export interface LTVInfoV5 { - ltv: string; // Risk rate (when liqStatus != 0, returns empty string) - rst: string; // Remaining liquidation time in UTC seconds (when liqStatus != 0, returns empty string) - parentUid: string; // The designated Risk Unit ID - subAccountUids: string[]; // Bound user IDs - unpaidAmount: string; // Total debt in USDT (when liqStatus != 0, returns empty string) - unpaidInfo: UnpaidInfoV5[]; // Debt details (when liqStatus != 0, returns empty array) - balance: string; // Total asset in USDT (when liqStatus != 0, returns empty string) - balanceInfo: BalanceInfoV5[]; // Asset details (when liqStatus != 0, returns empty array) - liqStatus?: number; // Liquidation status: 0=Normal, 1=Under liquidation, 2=Manual repayment in progress, 3=Transfer in progress +export interface SymbolInfo { + name: string; + alias: string; + status: 'Trading' | string; + base_currency: string; + quote_currency: string; + price_scale: number; + taker_fee: numberInString; + maker_fee: numberInString; + leverage_filter: LeverageFilter; + price_filter: PriceFilter; + lot_size_filter: LotSizeFilter; } + +================ +File: webpack/webpack.config.js +================ +function generateConfig(name) ⋮---- -ltv: string; // Risk rate (when liqStatus != 0, returns empty string) -rst: string; // Remaining liquidation time in UTC seconds (when liqStatus != 0, returns empty string) -parentUid: string; // The designated Risk Unit ID -subAccountUids: string[]; // Bound user IDs -unpaidAmount: string; // Total debt in USDT (when liqStatus != 0, returns empty string) -unpaidInfo: UnpaidInfoV5[]; // Debt details (when liqStatus != 0, returns empty array) -balance: string; // Total asset in USDT (when liqStatus != 0, returns empty string) -balanceInfo: BalanceInfoV5[]; // Asset details (when liqStatus != 0, returns empty array) -liqStatus?: number; // Liquidation status: 0=Normal, 1=Under liquidation, 2=Manual repayment in progress, 3=Transfer in progress +// Add '.ts' and '.tsx' as resolvable extensions. ⋮---- -export interface InstitutionalLoanLTVV5 { - ltvInfo: LTVInfoV5[]; // LTV info array - liqStatus?: number; // Liquidation status: 0=Normal, 1=Under liquidation, 2=Manual repayment in progress, 3=Transfer in progress -} +// Node.js core modules not available in browsers +// The REST client's https.Agent (for keepAlive) is Node.js-only and won't work in browsers ⋮---- -ltvInfo: LTVInfoV5[]; // LTV info array -liqStatus?: number; // Liquidation status: 0=Normal, 1=Under liquidation, 2=Manual repayment in progress, 3=Transfer in progress +// All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'. +⋮---- +// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'. + +================ +File: .npmrc +================ +min-release-age=30 +save-exact=true + +================ +File: .nvmrc +================ +v24.18.0 + +================ +File: src/types/request/v5-broker.ts +================ +export interface GetExchangeBrokerEarningsParamsV5 { + bizType?: 'SPOT' | 'DERIVATIVES' | 'OPTIONS' | 'CONVERT' | 'FIAT_CONVERT'; + begin?: string; + end?: string; + uid?: string; + limit?: number; + cursor?: string; +} ⋮---- -export interface RepayInstitutionalLoanResultV5 { - repayOrderStatus: string; // P: processing +export interface GetBrokerSubAccountDepositsV5 { + id?: string; + txID?: string; + subMemberId?: string; + coin?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; } ⋮---- -repayOrderStatus: string; // P: processing +export interface IssueVoucherParamsV5 { + accountId: string; + awardId: string; + specCode: string; + amount: string; + brokerId: string; +} ⋮---- -// Max Loan Amount Response Types +export interface GetBrokerIssuedVoucherParamsV5 { + accountId: string; + awardId: string; + specCode: string; + withUsedAmount?: boolean; +} ⋮---- -export interface MaxLoanAmountV5 { - currency: string; // Coin to borrow - maxLoan: string; // Maximum borrowable amount based on current collateral - notionalUsd: string; // Notional USD value - remainingQuota: string; // Remaining individual platform borrowing limit (shared between main and sub accounts) +/** Set Rate Limit - exchange broker only. API rate limit: 1 req per second. */ +export interface SetBrokerRateLimitParamsV5 { + list: { + uids: string; + bizType: string; + rate: number; + }[]; } ⋮---- -currency: string; // Coin to borrow -maxLoan: string; // Maximum borrowable amount based on current collateral -notionalUsd: string; // Notional USD value -remainingQuota: string; // Remaining individual platform borrowing limit (shared between main and sub accounts) +/** Get All Rate Limits - exchange broker only. API rate limit: 1 req per second. */ +export interface GetAllBrokerRateLimitsParamsV5 { + limit?: string; + cursor?: string; + uids?: string; +} ================ -File: src/types/response/v5-spot-leverage-token.ts +File: src/types/request/v5-earn-liquidity-mining.ts ================ -import { - LeverageTokenStatusV5, - LTOrderStatusV5, - LTOrderTypeV5, -} from '../shared-v5'; -⋮---- -export interface LeverageTokenInfoV5 { - ltCoin: string; - ltName: string; - maxPurchase: string; - minPurchase: string; - maxPurchaseDaily: string; - maxRedeem: string; - minRedeem: string; - maxRedeemDaily: string; - purchaseFeeRate: string; - redeemFeeRate: string; - ltStatus: LeverageTokenStatusV5; - fundFee: string; - fundFeeTime: string; - manageFeeRate: string; - manageFeeTime: string; - value: string; - netValue: string; - total: string; +/** + * GET /v5/earn/liquidity-mining/product (public, 50 req/s per IP) + */ +export interface GetLiquidityMiningProductParamsV5 { + baseCoin?: string; + quoteCoin?: string; } ⋮---- -export interface LeveragedTokenMarketResultV5 { - ltCoin: string; - nav: string; - navTime: string; - circulation: string; - basket: string; - leverage: string; +export interface ReinvestLiquidityMiningParamsV5 { + productId: string; + orderLinkId: string; + positionId: string; + leverage?: string; } + +================ +File: src/types/request/v5-spot-leverage-token.ts +================ +import { LTOrderTypeV5 } from '../shared-v5'; ⋮---- -export interface PurchaseSpotLeveragedTokenResultV5 { +export interface PurchaseSpotLeveragedTokenParamsV5 { ltCoin: string; - ltOrderStatus: LTOrderStatusV5; - execQty: string; - execAmt: string; amount: string; - purchaseId: string; - serialNo: string; - valueCoin: string; -} -export interface RedeemSpotLeveragedTokenResultV5 { - ltCoin: string; - ltOrderStatus: LTOrderStatusV5; - quantity: string; - execQty: string; - execAmt: string; - redeemId: string; - serialNo: string; - valueCoin: string; + serialNo?: string; } ⋮---- -export interface SpotLeveragedTokenOrderHistoryV5 { +export interface RedeemSpotLeveragedTokenParamsV5 { ltCoin: string; - orderId: string; - ltOrderType: LTOrderTypeV5; - orderTime: number; - updateTime: number; - ltOrderStatus: LTOrderStatusV5; - fee: string; - amount: string; - value: string; - valueCoin: string; - serialNo: string; + quantity: string; + serialNo?: string; } ⋮---- -export interface VIPMarginDataV5 { - vipCoinList: { - list: { - borrowable: boolean; - collateralRatio: string; - currency: string; - hourlyBorrowRate: string; - liquidationOrder: string; - marginCollateral: boolean; - maxBorrowingAmount: string; - }[]; - vipLevel: string; - }[]; +export interface GetSpotLeveragedTokenOrderHistoryParamsV5 { + ltCoin?: string; + orderId?: string; + startTime?: number; + endTime?: number; + limit?: number; + ltOrderType?: LTOrderTypeV5; + serialNo?: string; } ⋮---- -export interface SpotMarginCurrencyDataV5 { - currency: string; - flexibleManualBorrowable: boolean; - minFlexibleManualBorrowQty: string; - flexibleManualBorrowAccuracy: string; - fixedManualBorrowable: boolean; - minFixedManualBorrowQty: string; - fixedManualBorrowAccuracy: string; - fixedInterestRateAccuracy: string; - minFixedInterestRate: string; - maxFixedInterestRate: string; +export interface GetVIPMarginDataParamsV5 { + vipLevel?: string; + currency?: string; } ⋮---- -export interface SpotMarginStateV5 { - spotLeverage: string; - spotMarginMode: '1' | '0'; - effectiveLeverage: string; +export interface GetSpotMarginCurrencyDataParamsV5 { + currency?: string; } ⋮---- -// Spot Margin Trade (UTA) response types -export interface ManualBorrowResultV5 { +// Spot Margin Trade (UTA) endpoints +export interface ManualBorrowParamsV5 { coin: string; amount: string; } ⋮---- -export interface MaxBorrowableAmountV5 { +export interface GetMaxBorrowableAmountParamsV5 { currency: string; - maxLoan: string; } ⋮---- -export interface PositionTierV5 { - tier: string; - borrowLimit: string; - positionMMR: string; - positionIMR: string; - maxLeverage: string; +export interface GetPositionTiersParamsV5 { + currency?: string; } ⋮---- -export interface CurrencyPositionTiersV5 { - currency: string; - positionTiersRatioList: PositionTierV5[]; +export interface GetCoinStateParamsV5 { + currency?: string; } ⋮---- -export interface CoinStateV5 { +export interface GetAvailableAmountToRepayParamsV5 { currency: string; - spotLeverage: string; } ⋮---- -export interface AvailableAmountToRepayV5 { - currency: string; - lossLessRepaymentAmount: string; +export interface SetSpotMarginLeverageParamsV5 { + leverage: string; + currency?: string; } ⋮---- -export interface ManualRepayWithoutConversionResultV5 { +export interface ManualRepayWithoutConversionParamsV5 { + coin: string; + amount?: string; /** - * Result status: - * - P: Processing - * - SU: Success - * - FA: Failed + * ALL: fixed + floating (floating first); FIXED: fixed only; FLEXIBLE: floating only. Default: FLEXIBLE. */ - resultStatus: 'P' | 'SU' | 'FA'; + repaymentType?: 'ALL' | 'FIXED' | 'FLEXIBLE'; } ⋮---- /** - * Result status: - * - P: Processing - * - SU: Success - * - FA: Failed + * ALL: fixed + floating (floating first); FIXED: fixed only; FLEXIBLE: floating only. Default: FLEXIBLE. */ ⋮---- -export interface AutoRepayModeItemV5 { - currency: string; // Coin name, uppercase only +export interface GetAutoRepayModeParamsV5 { + currency?: string; // Coin name, uppercase only. If not passed, returns all currencies +} +⋮---- +currency?: string; // Coin name, uppercase only. If not passed, returns all currencies +⋮---- +export interface SetAutoRepayModeParamsV5 { + currency?: string; // Coin name, uppercase only. If not passed, enables for all currencies autoRepayMode: '0' | '1'; // 0: Off, 1: On } ⋮---- -currency: string; // Coin name, uppercase only +currency?: string; // Coin name, uppercase only. If not passed, enables for all currencies autoRepayMode: '0' | '1'; // 0: Off, 1: On ⋮---- -export interface AutoRepayModeResultV5 { - data: AutoRepayModeItemV5[]; +export interface GetSpotMarginLiabilityInfoParamsV5 { + currency: string; } ⋮---- -export interface SpotMarginLiabilityInfoV5 { - currency: string; - totalBorrowAmount: string; - fixedBorrowAmount: string; - flexibleBorrowAmount: string; - spotTotalBorrow: string; - derivativesBorrow: string; +export interface FixedRateBorrowParamsV5 { + orderCurrency: string; + orderAmount: string; + /** e.g. 0.02 = 2% p.a. */ + annualRate: string; + /** 7, 14, 30, 90, 180 (days) */ + term: string; + /** 1: auto repayment; 2: transfer to flexible loan */ + repayType?: '1' | '2'; +} +⋮---- +/** e.g. 0.02 = 2% p.a. */ +⋮---- +/** 7, 14, 30, 90, 180 (days) */ +⋮---- +/** 1: auto repayment; 2: transfer to flexible loan */ +⋮---- +export interface GetFixedRateBorrowOrderInfoParamsV5 { + orderId?: string; + orderCurrency?: string; + state?: string; + term?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface FixedRateBorrowResultV5 { - orderId: string; +export interface GetFixedRateBorrowContractInfoParamsV5 { + orderId?: string; + orderCurrency?: string; + term?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface FixedRateBorrowOrderInfoV5 { - annualRate: string; - orderId: string; - orderTime: string; - filledQty: string; - orderQty: string; +export interface GetFixedRateBorrowOrderQuoteParamsV5 { orderCurrency: string; - state: number; - term: number; - repayType: string; - strategyType: 'PARTIAL' | 'FULL'; + term?: string; + orderBy?: 'apy' | 'term' | 'quantity'; + sort?: 0 | 1; + limit?: number; } ⋮---- -export interface FixedRateBorrowContractInfoV5 { - annualRate: string; - borrowCurrency: string; - borrowTime: string; - interestPaid: string; +export interface RenewFixedRateBorrowParamsV5 { loanId: string; - orderId: string; - repaymentTime: string; - residualPenaltyInterest: string; - residualPrincipal: string; - status: number; - term: string; - repayType: string; - strategyType: 'PARTIAL' | 'FULL'; -} -⋮---- -export interface FixedRateBorrowQuoteV5 { - orderCurrency: string; - term: number; - annualRate: string; - qty: string; + qty?: string; } ⋮---- -export interface FlexibleAvailableInventoryV5 { +export interface GetFlexibleAvailableInventoryParamsV5 { currency: string; - availableInventory: string; - updateTime: string; } ⋮---- -export interface FixedRateAvailableInventoryV5 { +export interface GetFixedRateAvailableInventoryParamsV5 { currency: string; term: string; annualRate: string; - availableInventory: string; - updateTime: string; } ================ -File: src/types/response/v5-trade.ts +File: src/types/request/v5-trade.ts ================ import { CategoryV5, - OrderCancelTypeV5, - OrderCreateTypeV5, - OrderRejectReasonV5, + OrderFilterV5, OrderSideV5, + OrderSMPTypeV5, OrderStatusV5, OrderTimeInForceV5, OrderTriggerByV5, @@ -10125,3123 +9248,3792 @@ import { StopOrderTypeV5, } from '../shared-v5'; ⋮---- -export interface OrderResultV5 { - orderId: string; - orderLinkId: string; -} -⋮---- -export interface AccountOrderV5 { - orderId: string; - orderLinkId: string; - parentOrderLinkId?: string; // Linked parent order for attached TP/SL orders (futures & options) - blockTradeId: string; +export interface OrderParamsV5 { + category: CategoryV5; symbol: string; - price: string; - qty: string; + isLeverage?: 0 | 1; side: OrderSideV5; - isLeverage: '0' | '1'; - positionIdx: PositionIdx; - orderStatus: OrderStatusV5; - createType: OrderCreateTypeV5; - cancelType: OrderCancelTypeV5; - rejectReason: OrderRejectReasonV5; - avgPrice: string; - leavesQty: string; - leavesValue: string; - cumExecQty: string; - cumExecValue: string; - cumExecFee: string; - timeInForce: OrderTimeInForceV5; orderType: OrderTypeV5; - stopOrderType: StopOrderTypeV5; - orderIv: string; - marketUnit: 'baseCoin' | 'quoteCoin'; - slippageToleranceType: string; - slippageTolerance: string; - triggerPrice: string; - takeProfit: string; - stopLoss: string; - tpslMode: 'Full' | 'Partial' | ''; - ocoTriggerType: - | 'OcoTriggerByUnknown' - | 'OcoTriggerTp' - | 'OcoTriggerBySl' - | ''; - tpLimitPrice: string; - slLimitPrice: string; - tpTriggerBy: OrderTriggerByV5; - slTriggerBy: OrderTriggerByV5; - triggerDirection: 1 | 2; - triggerBy: OrderTriggerByV5; - lastPriceOnCreated: string; - basePrice: string; - reduceOnly: boolean; - closeOnTrigger: boolean; - placeType: 'iv' | 'price' | ''; - smpType: string; - smpGroup: string; - smpOrderId: string; - createdTime: string; - updatedTime: string; - extraFees: string; - cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee + qty: string; + marketUnit?: 'baseCoin' | 'quoteCoin'; + slippageToleranceType?: string; + slippageTolerance?: string; + price?: string; + triggerDirection?: 1 | 2; + orderFilter?: OrderFilterV5; + triggerPrice?: string; + triggerBy?: OrderTriggerByV5; + orderIv?: string; + timeInForce?: OrderTimeInForceV5; + positionIdx?: PositionIdx; + orderLinkId?: string; + takeProfit?: string; + stopLoss?: string; + tpTriggerBy?: OrderTriggerByV5; + slTriggerBy?: OrderTriggerByV5; + reduceOnly?: boolean; + closeOnTrigger?: boolean; + smpType?: OrderSMPTypeV5; + mmp?: boolean; + tpslMode?: 'Full' | 'Partial'; + tpLimitPrice?: string; + slLimitPrice?: string; + tpOrderType?: OrderTypeV5; + slOrderType?: OrderTypeV5; + bboSideType?: 'Queue' | 'Counterparty'; + bboLevel?: '1' | '2' | '3' | '4' | '5'; + /** Limit IOC/FOK is supported when this is true. */ rpiTakerAccess?: boolean; - rpiMatchedQty?: string; - fromAccount?: string; - toAccount?: string; - externalEventType?: string; } ⋮---- -parentOrderLinkId?: string; // Linked parent order for attached TP/SL orders (futures & options) +/** Limit IOC/FOK is supported when this is true. */ +⋮---- +export interface AmendOrderParamsV5 { + category: CategoryV5; + symbol: string; + orderId?: string; + orderLinkId?: string; + orderIv?: string; + triggerPrice?: string; + qty?: string; + price?: string; + tpslMode?: 'Full' | 'Partial'; + takeProfit?: string; + stopLoss?: string; + tpTriggerBy?: OrderTriggerByV5; + slTriggerBy?: OrderTriggerByV5; + triggerBy?: OrderTriggerByV5; + tpLimitPrice?: string; + slLimitPrice?: string; +} +⋮---- +export interface CancelOrderParamsV5 { + category: CategoryV5; + symbol: string; + orderId?: string; + orderLinkId?: string; + orderFilter?: OrderFilterV5; +} +⋮---- +export interface GetAccountOrdersParamsV5 { + category: CategoryV5; + symbol?: string; + baseCoin?: string; + settleCoin?: string; + orderId?: string; + orderLinkId?: string; + openOnly?: 0 | 1 | 2; + orderFilter?: OrderFilterV5; + orderStatus?: OrderStatusV5; + limit?: number; + cursor?: string; +} +⋮---- +export interface GetAccountHistoricOrdersParamsV5 { + category: CategoryV5; + symbol?: string; + baseCoin?: string; + settleCoin?: string; + orderId?: string; + orderLinkId?: string; + orderFilter?: OrderFilterV5; + orderStatus?: OrderStatusV5; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; +} +⋮---- +export interface CancelAllOrdersParamsV5 { + category: CategoryV5; + symbol?: string; + baseCoin?: string; + settleCoin?: string; + orderFilter?: OrderFilterV5; + stopOrderType?: StopOrderTypeV5; +} +⋮---- +export interface BatchOrderParamsV5 { + symbol: string; + side: OrderSideV5; + isLeverage?: 0 | 1; + orderType: OrderTypeV5; + qty: string; + price?: string; + triggerDirection?: 1 | 2; + triggerBy?: OrderTriggerByV5; + orderIv?: string; + timeInForce?: OrderTimeInForceV5; + positionIdx?: PositionIdx; + orderLinkId?: string; + takeProfit?: string; + stopLoss?: string; + tpTriggerBy?: OrderTriggerByV5; + slTriggerBy?: OrderTriggerByV5; + reduceOnly?: boolean; + closeOnTrigger?: boolean; + smpType?: OrderSMPTypeV5; + mmp?: boolean; + tpslMode?: 'Full' | 'Partial'; + tpLimitPrice?: string; + slLimitPrice?: string; + tpOrderType?: OrderTypeV5; + slOrderType?: OrderTypeV5; +} ⋮---- -cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee +export interface BatchAmendOrderParamsV5 { + symbol: string; + orderId?: string; + orderLinkId?: string; + orderIv?: string; + triggerPrice?: string; + qty?: string; + price?: string; + tpslMode?: 'Full' | 'Partial'; + takeProfit?: string; + stopLoss?: string; + tpTriggerBy?: OrderTriggerByV5; + slTriggerBy?: OrderTriggerByV5; + triggerBy?: OrderTriggerByV5; + tpLimitPrice?: string; + slLimitPrice?: string; +} ⋮---- -export interface BatchCreateOrderResultV5 { - category: CategoryV5; +export interface BatchCancelOrderParamsV5 { + symbol: string; + orderId?: string; + orderLinkId?: string; +} + +================ +File: src/types/response/v5-broker.ts +================ +interface EarningDetailV5 { + userId: string; + bizType: 'SPOT' | 'DERIVATIVES' | 'OPTIONS' | 'CONVERT' | 'FIAT_CONVERT'; symbol: string; + coin: string; + earning: string; + markupEarning: string; + baseFeeEarning: string; orderId: string; - orderLinkId: string; - createAt?: string; + execTime: string; } ⋮---- -export interface BatchOrdersRetExtInfoV5 { - list: { - code: number; - msg: string; - }[]; +interface TotalEarningCategoryV5 { + coin: string; + earning: string; } ⋮---- -export interface BatchAmendOrderResultV5 { - category: CategoryV5; - symbol: string; - orderId: string; - orderLinkId: string; +export interface ExchangeBrokerEarningResultV5 { + totalEarningCat: { + spot: TotalEarningCategoryV5[]; + derivatives: TotalEarningCategoryV5[]; + options: TotalEarningCategoryV5[]; + convert: TotalEarningCategoryV5[]; + fiatConvert?: TotalEarningCategoryV5[]; + total: TotalEarningCategoryV5[]; + }; + details: EarningDetailV5[]; + nextPageCursor: string; } ⋮---- -export interface BatchCancelOrderResultV5 { - category: CategoryV5; - symbol: string; - orderId: string; - orderLinkId: string; +export interface ExchangeBrokerAccountInfoV5 { + subAcctQty: string; + maxSubAcctQty: string; + baseFeeRebateRate: { + spot: string; + derivatives: string; + }; + markupFeeRebateRate: { + spot: string; + derivatives: string; + convert: string; + }; + ts: string; } ⋮---- -export interface SpotBorrowCheckResultV5 { - symbol: string; - side: OrderSideV5; - maxTradeQty: string; - maxTradeAmount: string; - spotMaxTradeQty: string; - spotMaxTradeAmount: string; - borrowCoin: string; +export interface ExchangeBrokerSubAccountDepositRecordV5 { + id: string; + subMemberId: string; + coin: string; + chain: string; + amount: string; + txID: string; + status: number; + toAddress: string; + tag: string; + depositFee: string; + successAt: string; + confirmations: string; + txIndex: string; + blockHash: string; + batchReleaseLimit: string; + depositType: string; } ⋮---- -export interface PreCheckOrderResultV5 { - orderId: string; - orderLinkId: string; - preImrE4: number; // Initial margin rate before checking (in basis points) - preMmrE4: number; // Maintenance margin rate before checking (in basis points) - postImrE4: number; // Initial margin rate after checking (in basis points) - postMmrE4: number; // Maintenance margin rate after checking (in basis points) +export interface BrokerVoucherSpecV5 { + id: string; + coin: string; + amountUnit: 'AWARD_AMOUNT_UNIT_USD' | 'AWARD_AMOUNT_UNIT_COIN'; + productLine: string; + subProductLine: string; + totalAmount: { + [key: string]: string; + }; + usedAmount: string; } ⋮---- -preImrE4: number; // Initial margin rate before checking (in basis points) -preMmrE4: number; // Maintenance margin rate before checking (in basis points) -postImrE4: number; // Initial margin rate after checking (in basis points) -postMmrE4: number; // Maintenance margin rate after checking (in basis points) +export interface BrokerIssuedVoucherV5 { + accountId: string; + awardId: string; + specCode: string; + amount: string; + isClaimed: boolean; + startAt: string; + endAt: string; + effectiveAt: string; + ineffectiveAt: string; + usedAmount: string; +} +⋮---- +export interface BrokerRateLimitSetResultItemV5 { + uids: string; + bizType: string; + rate: number; + success: boolean; + msg: string; +} +⋮---- +export interface BrokerRateLimitCapItemV5 { + bizType: string; + totalRate: string; + ebCap: string; + uidCap: string; +} +⋮---- +export interface BrokerRateLimitAllItemV5 { + uids: string; + bizType: string; + rate: number; +} ================ -File: src/types/request/v5-account.ts +File: src/types/response/v5-crypto-loan.ts ================ -import { - AccountTypeV5, - CategoryV5, - InstrumentSymbolTypeV5, - TransactionTypeV5, -} from '../shared-v5'; +export interface CollateralCoinV5 { + collateralAccuracy: number; + initialLTV: string; + liquidationLTV: string; + marginCallLTV: string; + maxLimit: string; +} ⋮---- -export interface GetWalletBalanceParamsV5 { - accountType: AccountTypeV5; - coin?: string; +export interface VipCollateralCoinsV5 { + list: CollateralCoinV5[]; + vipLevel: string; } ⋮---- -export interface GetBorrowHistoryParamsV5 { - currency?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; +export interface BorrowableCoinV5 { + borrowingAccuracy: number; + currency: string; + flexibleHourlyInterestRate: string; + hourlyInterestRate7D: string; + hourlyInterestRate14D: string; + hourlyInterestRate30D: string; + hourlyInterestRate90D: string; + hourlyInterestRate180D: string; + maxBorrowingAmount: string; + minBorrowingAmount: string; } ⋮---- -export interface GetFeeRateParamsV5 { - category: CategoryV5; - symbol?: string; - baseCoin?: string; +export interface VipBorrowableCoinsV5 { + list: BorrowableCoinV5[]; + vipLevel: string; } ⋮---- -export interface GetTransactionLogParamsV5 { - accountType?: AccountTypeV5; - category?: CategoryV5; - currency?: string; - baseCoin?: string; - type?: TransactionTypeV5; - /** - * Transaction sub type, "movePosition", used to filter trans logs of Move Position only - */ - transSubType?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; +export interface AccountBorrowCollateralLimitV5 { + collateralCurrency: string; + loanCurrency: string; + maxCollateralAmount: string; + maxLoanAmount: string; + minCollateralAmount: string; + minLoanAmount: string; } ⋮---- -/** - * Transaction sub type, "movePosition", used to filter trans logs of Move Position only - */ +export interface UnpaidLoanOrderV5 { + collateralAmount: string; + collateralCurrency: string; + currentLTV: string; + expirationTime: string; + hourlyInterestRate: string; + loanCurrency: string; + loanTerm: string; + orderId: string; + residualInterest: string; + residualPenaltyInterest: string; + totalDebt: string; +} ⋮---- -export interface MMPModifyParamsV5 { - baseCoin: string; - window: string; - frozenPeriod: string; - qtyLimit: string; - deltaLimit: string; - vegaLimit?: string; +export interface RepaymentHistoryV5 { + collateralCurrency: string; + collateralReturn: string; + loanCurrency: string; + loanTerm: string; + orderId: string; + repayAmount: string; + repayId: string; + repayStatus: number; + repayTime: string; + repayType: string; } ⋮---- -export interface RepayLiabilityParamsV5 { - coin?: string; +export interface CompletedLoanOrderV5 { + borrowTime: string; + collateralCurrency: string; + expirationTime: string; + hourlyInterestRate: string; + initialCollateralAmount: string; + initialLoanAmount: string; + loanCurrency: string; + loanTerm: string; + orderId: string; + repaidInterest: string; + repaidPenaltyInterest: string; + status: number; +} +export interface LoanLTVAdjustmentHistoryV5 { + collateralCurrency: string; + orderId: string; + adjustId: string; + adjustTime: string; + preLTV: string; + afterLTV: string; + direction: number; + amount: string; } ⋮---- -export interface SetCollateralCoinParamsV5 { - coin: string; - collateralSwitch: 'ON' | 'OFF'; +// New Crypto Loan Types +⋮---- +export interface BorrowCoinV5 { + currency: string; + fixedBorrowable: boolean; + fixedBorrowingAccuracy: number; + flexibleBorrowable: boolean; + flexibleBorrowingAccuracy: number; + maxBorrowingAmount: string; + minFixedBorrowingAmount: string; + minFlexibleBorrowingAmount: string; + vipLevel: string; + flexibleAnnualizedInterestRate: string; + annualizedInterestRate7D: string; + annualizedInterestRate14D: string; + annualizedInterestRate30D: string; + annualizedInterestRate60D: string; + annualizedInterestRate90D: string; + annualizedInterestRate180D: string; } ⋮---- -export interface GetClassicTransactionLogsParamsV5 { - currency?: string; - baseCoin?: string; - type?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; +export interface CollateralRatioV5 { + collateralRatio: string; + maxValue: string; + minValue: string; } ⋮---- -export interface SetLimitPriceActionParamsV5 { - category: CategoryV5; - modifyEnable: boolean; +export interface CollateralRatioConfigV5 { + collateralRatioList: CollateralRatioV5[]; + currencies: string; } ⋮---- -/** - * Set Delta Neutral Mode. POST /v5/account/set-delta-mode - * 1: enable, 0: disable. - */ -export interface SetDeltaNeutralModeParamsV5 { - deltaEnable: '1' | '0'; +export interface CurrencyLiquidationV5 { + currency: string; + liquidationOrder: number; } ⋮---- -export interface GetAccountInstrumentsInfoParamsV5 { - category: 'spot' | 'linear' | 'inverse'; - symbol?: string; - /** Filter by `symbolType` (e.g. `commodity`, `stock`, `forex` for linear). */ - symbolType?: InstrumentSymbolTypeV5; - limit?: number; - cursor?: string; +export interface CollateralDataV5 { + collateralRatioConfigList: CollateralRatioConfigV5[]; + currencyLiquidationList: CurrencyLiquidationV5[]; } ⋮---- -/** Filter by `symbolType` (e.g. `commodity`, `stock`, `forex` for linear). */ +// Additional New Crypto Loan Types ⋮---- -/** GET /v5/account/pay-info */ -export interface GetPayInfoParamsV5 { - coin?: string; +export interface AdjustCollateralAmountV5 { + adjustId: number; } ⋮---- -/** GET /v5/account/trade-info-for-analysis */ -export interface GetTradeInfoForAnalysisParamsV5 { - symbol: string; - startTime?: number; - endTime?: number; +export interface CollateralAdjustmentHistoryV5 { + adjustId: number; + adjustTime: number; + afterLTV: string; + amount: string; + collateralCurrency: string; + direction: number; + preLTV: string; + status: number; } ⋮---- -export interface ManualRepayParamsV5 { - coin?: string; - amount?: string; - /** - * ALL: fixed + floating (floating first); FIXED: fixed only; FLEXIBLE: floating only. Default: FLEXIBLE. - * If neither `coin` nor `amount` is set, this must be ALL (repay all liabilities) or the request is rejected. - */ - repaymentType?: 'ALL' | 'FIXED' | 'FLEXIBLE'; +export interface BorrowListV5 { + fixedTotalDebt: string; + fixedTotalDebtUSD: string; + flexibleHourlyInterestRate: string; + flexibleTotalDebt: string; + flexibleTotalDebtUSD: string; + loanCurrency: string; } ⋮---- -/** - * ALL: fixed + floating (floating first); FIXED: fixed only; FLEXIBLE: floating only. Default: FLEXIBLE. - * If neither `coin` nor `amount` is set, this must be ALL (repay all liabilities) or the request is rejected. - */ - -================ -File: src/types/request/v5-asset.ts -================ -import { AccountTypeV5, CategoryV5 } from '../shared-v5'; -⋮---- -export interface GetCoinExchangeRecordParamsV5 { - fromCoin?: string; - toCoin?: string; - limit?: number; - cursor?: string; +export interface CollateralListV5 { + amount: string; + amountUSD: string; + currency: string; + ltv: string; } ⋮---- -export interface GetDeliveryRecordParamsV5 { - category: CategoryV5; - symbol?: string; - startTime?: number; - endTime?: number; - expDate?: string; - limit?: number; - cursor?: string; +export interface SupplyListV5 { + amount: string; + amountUSD: string; + currency: string; } ⋮---- -export interface GetSettlementRecordParamsV5 { - category: CategoryV5; - symbol?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; +export interface CryptoLoanPositionV5 { + borrowList: BorrowListV5[]; + collateralList: CollateralListV5[]; + supplyList: SupplyListV5[]; + totalCollateral: string; + totalDebt: string; + totalSupply: string; + colRes?: string; } ⋮---- -export interface GetAssetInfoParamsV5 { - accountType: AccountTypeV5; - coin?: string; +// Flexible Loan Types +⋮---- +export interface BorrowFlexibleV5 { + orderId: string; } ⋮---- -export interface GetAllCoinsBalanceParamsV5 { - memberId?: string; - accountType: AccountTypeV5; - coin?: string; - withBonus?: number; +export interface RepayFlexibleV5 { + repayId: string; } ⋮---- -export interface GetAccountCoinBalanceParamsV5 { - memberId?: string; - toMemberId?: string; - accountType: AccountTypeV5; - coin: string; - toAccountType?: AccountTypeV5; - withBonus?: number; - withTransferSafeAmount?: 0 | 1; - withLtvTransferSafeAmount?: 0 | 1; +export interface OngoingFlexibleLoanV5 { + hourlyInterestRate: string; + loanCurrency: string; + totalDebt: string; + unpaidAmount: string; + unpaidInterest: string; } ⋮---- -export interface GetInternalTransferParamsV5 { - transferId?: string; - coin?: string; - status?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; +export interface BorrowHistoryFlexibleV5 { + borrowTime: number; + initialLoanAmount: string; + loanCurrency: string; + orderId: string; + status: number; } ⋮---- -export interface UniversalTransferParamsV5 { - transferId: string; - coin: string; - amount: string; - fromMemberId: number; - toMemberId: number; - fromAccountType: AccountTypeV5; - toAccountType: AccountTypeV5; +export interface RepaymentHistoryFlexibleV5 { + loanCurrency: string; + repayAmount: string; + repayId: string; + repayStatus: number; + repayTime: number; + repayType: number; } ⋮---- -export interface GetUniversalTransferRecordsParamsV5 { - transferId?: string; - coin?: string; - status?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; - fromMemberId?: string; - toMemberId?: string; +// Fixed Loan Types +⋮---- +export interface SupplyOrderQuoteFixedV5 { + orderCurrency: string; + term: number; + annualRate: string; + qty: string; } ⋮---- -export interface GetAllowedDepositCoinInfoParamsV5 { - coin?: string; - chain?: string; - limit?: number; - cursor?: string; +export interface BorrowOrderQuoteFixedV5 { + orderCurrency: string; + term: number; + annualRate: string; + qty: string; } ⋮---- -export interface GetDepositRecordParamsV5 { - id?: string; - txID?: string; - coin?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; +export interface CreateBorrowOrderFixedV5 { + orderId: string; } ⋮---- -export interface GetSubAccountDepositRecordParamsV5 { - id?: string; - txID?: string; - subMemberId: string; - coin?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; +export interface CreateSupplyOrderFixedV5 { + orderId: string; } ⋮---- -export interface GetInternalDepositRecordParamsV5 { - txID?: string; - startTime?: number; - endTime?: number; - coin?: string; - cursor?: string; - limit?: number; +export interface BorrowContractInfoFixedV5 { + annualRate: string; + autoRepay: string; // Deprecated + borrowCurrency: string; + borrowTime: string; + interestPaid: string; + loanId: string; + orderId: string; + repayType: string; // 1: Auto Repayment; 2: Transfer to flexible loan; 0: No Automatic Repayment + repaymentTime: string; + residualPenaltyInterest: string; + residualPrincipal: string; + status: number; + term: string; } ⋮---- -export interface GetWithdrawalRecordsParamsV5 { - withdrawID?: string; - txID?: string; - coin?: string; - withdrawType?: number; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; -} +autoRepay: string; // Deprecated ⋮---- -export interface GetWithdrawalAddressListParamsV5 { - coin?: string; - chain?: string; - addressType?: 0 | 1 | 2; - limit?: number; - cursor?: string; +repayType: string; // 1: Auto Repayment; 2: Transfer to flexible loan; 0: No Automatic Repayment +⋮---- +export interface SupplyContractInfoFixedV5 { + annualRate: string; + supplyCurrency: string; + supplyTime: string; + supplyAmount: string; + interestPaid: string; + supplyId: string; + orderId: string; + redemptionTime: string; + penaltyInterest: string; + actualRedemptionTime: string; + status: number; + term: string; } ⋮---- -export interface SubmitDepositOriginatorInfoParamsV5 { - depositId: number; - subAccountId?: number; - /** Travel Rule questionnaire JSON string. See Questionnaire docs. */ - questionnaire: string; +export interface BorrowOrderInfoFixedV5 { + annualRate: string; + orderId: number; + orderTime: string; + filledQty: string; + orderQty: string; + orderCurrency: string; + state: number; + term: number; + repayType: string; // 1: Auto Repayment; 2: Transfer to flexible loan; 0: No Automatic Repayment + strategyType?: 'PARTIAL' | 'FULL' | string; } ⋮---- -/** Travel Rule questionnaire JSON string. See Questionnaire docs. */ +repayType: string; // 1: Auto Repayment; 2: Transfer to flexible loan; 0: No Automatic Repayment ⋮---- -export interface WithdrawParamsV5 { - coin: string; - /** - * When forceChain is 0 or 1, required. When forceChain is 2 (Bybit UID withdraw), may be null/omitted. - */ - chain?: string; - address: string; - tag?: string; - amount: string; - timestamp: number; - forceChain?: number; - /** - * FUND, UTA, or EARN; or comma combo e.g. FUND,UTA,EARN (funding first, then UTA and Earn for remainder). - * SPOT is legacy if still supported for older integrations. - */ - accountType: string; - feeType?: 0 | 1; - requestId?: string; - /** - * Required for Bybit Turkey (TR) site users when creating a withdrawal. Omitted for other regions unless the API requires it. - */ - transactionPurpose?: string; - /** - * Travel Rule questionnaire JSON string (max 16384 bytes). Takes precedence over `beneficiary` / `transactionPurpose` when both are set. - */ - questionnaire?: string; - beneficiary?: { - vaspEntityId?: string; - beneficiaryName?: string; - beneficiaryLegalType?: string; - beneficiaryWalletType?: string; - beneficiaryUnhostedWalletType?: string; - beneficiaryPoiNumber?: string; - beneficiaryPoiType?: string; - beneficiaryPoiIssuingCountry?: string; - beneficiaryPoiExpiredDate?: string; - }; +export interface FixedLoanAvailableInventoryV5 { + currency: string; + term: string; + annualRate: string; + availableInventory: string; + updateTime: string; } ⋮---- -/** - * When forceChain is 0 or 1, required. When forceChain is 2 (Bybit UID withdraw), may be null/omitted. - */ -⋮---- -/** - * FUND, UTA, or EARN; or comma combo e.g. FUND,UTA,EARN (funding first, then UTA and Earn for remainder). - * SPOT is legacy if still supported for older integrations. - */ +export interface FlexibleLoanAvailableInventoryV5 { + currency: string; + availableInventory: string; + updateTime: string; +} ⋮---- -/** - * Required for Bybit Turkey (TR) site users when creating a withdrawal. Omitted for other regions unless the API requires it. - */ +export interface SupplyOrderInfoFixedV5 { + annualRate: string; + orderId: number; + orderTime: string; + filledQty: string; + orderQty: string; + orderCurrency: string; + state: number; + term: number; +} ⋮---- -/** - * Travel Rule questionnaire JSON string (max 16384 bytes). Takes precedence over `beneficiary` / `transactionPurpose` when both are set. - */ +export interface RepayFixedV5 { + repayId: string; +} ⋮---- -export interface ConvertCoinsParamsV5 { - coin?: string; - side?: number; - accountType: - | 'eb_convert_funding' - | 'eb_convert_uta' - | 'eb_convert_spot' - | 'eb_convert_contract' - | 'eb_convert_inverse'; +export interface RepaymentHistoryFixedV5 { + details: { + loanCurrency: string; + loanId: string; + repayAmount: string; + }[]; + loanCurrency: string; + repayAmount: string; + repayId: string; + repayStatus: number; + repayTime: number; + repayType: number; } ⋮---- -export interface RequestConvertQuoteParamsV5 { - fromCoin: string; - toCoin: string; - fromCoinType?: string; - toCoinType?: string; - requestCoin: string; - requestAmount: string; - accountType: - | 'eb_convert_funding' - | 'eb_convert_uta' - | 'eb_convert_spot' - | 'eb_convert_contract' - | 'eb_convert_inverse'; - requestId?: string; +export interface RenewBorrowOrderFixedV5 { + orderId: string; } ⋮---- -export interface GetConvertHistoryParamsV5 { - accountType?: string; - index?: number; - limit?: number; +export interface RenewOrderInfoFixedV5 { + amount: string; + autoRepay: number; + borrowCurrency: string; + contractNo: string; + dueTime: string; + loanId: string; + orderId: number; + renewLoanNo: string; + time: string; } ⋮---- -export interface GetSmallBalanceListParamsV5 { - accountType: 'eb_convert_uta'; // Wallet type, only supports Unified wallet - fromCoin?: string; // Source currency +// Institutional Loan Types +⋮---- +export interface InstitutionalLendingProductInfoV5 { + productId: string; + leverage: string; + supportSpot: number; + supportContract: number; + supportMarginTrading: number; + withdrawLine: string; + transferLine: string; + spotBuyLine: string; + spotSellLine: string; + contractOpenLine: string; + liquidationLine: string; + stopLiquidationLine: string; + contractLeverage: string; + transferRatio: string; + spotSymbols: unknown[]; + contractSymbols: unknown[]; + supportUSDCContract: number; + supportUSDCOptions: number; + USDTPerpetualOpenLine?: string; + USDCContractOpenLine?: string; + USDCOptionsOpenLine?: string; + USDTPerpetualCloseLine?: string; + USDCContractCloseLine?: string; + USDCOptionsCloseLine?: string; + USDTPerpetualLeverage?: { symbol: string; leverage: string }[]; + USDCContractLeverage?: { symbol: string; leverage: string }[]; + deferredLiquidationLine?: string; + deferredLiquidationTime?: string; + marginLeverage?: string; + /** `0`: Default, `1`: CTA, `2`: Hedge */ + productType?: '0' | '1' | '2' | string; } ⋮---- -accountType: 'eb_convert_uta'; // Wallet type, only supports Unified wallet -fromCoin?: string; // Source currency +/** `0`: Default, `1`: CTA, `2`: Hedge */ ⋮---- -export interface GetFiatTradingPairListParamsV5 { - side?: 0 | 1; // 0: buy (buy crypto, sell fiat), 1: sell (sell crypto, buy fiat) +export interface InstitutionalLendingCoinDeltaItemV5 { + coin: string; + coinDeltaSize: string; + coinDeltaAvailableAmount: string; + coinDeltaAmount: string; } ⋮---- -side?: 0 | 1; // 0: buy (buy crypto, sell fiat), 1: sell (sell crypto, buy fiat) -⋮---- -/** Funding Account Transaction History. Interval createTimeFrom-createTimeTo max 7 days. */ -export interface GetFundingAccountTransactionHistoryParamsV5 { - createTimeFrom?: string; - createTimeTo?: string; - limit?: string; - cursor?: string; +export interface InstitutionalLendingCoinDeltaAmountV5 { + riskUnitDeltaAmount: string; + riskUnitDeltaAvailableAmount: string; + riskUnitDelta?: string; + list: InstitutionalLendingCoinDeltaItemV5[]; } ⋮---- -/** Asset Overview. memberId required when querying sub account via master API key. */ -export interface GetAssetOverviewParamsV5 { - memberId?: string; - /** Fiat currency for valuation; defaults to USD if omitted. */ - valuationCurrency?: string; - /** Account type filter; returns all if omitted. */ - accountType?: string; +export interface InstitutionalLendingDelayLiquidationStatusV5 { + ltv: string; + /** 0 normal, 1 passive liquidation, 2 callback liquidation, 3 delay liquidation */ + liquidationStatus: 0 | 1 | 2 | 3; + delayLiqStartTime: string; + delayLiqRemainingSec: string; } ⋮---- -/** Fiat currency for valuation; defaults to USD if omitted. */ -⋮---- -/** Account type filter; returns all if omitted. */ +/** 0 normal, 1 passive liquidation, 2 callback liquidation, 3 delay liquidation */ ⋮---- -/** GET /v5/asset/portfolio-margin */ -export interface GetPortfolioMarginInfoParamsV5 { - baseCoin?: string; +export interface UnpaidInfoV5 { + token: string; // Coin + unpaidQty: string; // Unpaid principle + unpaidInterest: string; // Unpaid interest } ⋮---- -/** GET /v5/asset/total-members-assets */ -export interface GetTotalMembersAssetsParamsV5 { - /** If omitted, defaults to BTC. Total is quoted in this coin. */ - coin?: string; -} +token: string; // Coin +unpaidQty: string; // Unpaid principle +unpaidInterest: string; // Unpaid interest ⋮---- -/** If omitted, defaults to BTC. Total is quoted in this coin. */ - -================ -File: src/types/request/v5-crypto-loan.ts -================ -export interface BorrowCryptoLoanParamsV5 { - loanCurrency: string; - loanAmount?: string; - loanTerm?: string; - collateralCurrency: string; - collateralAmount?: string; +export interface BalanceInfoV5 { + token: string; // Margin coin + price: string; // Margin coin price + qty: string; // Margin coin quantity + convertedAmount: string; // Margin conversion amount } ⋮---- -export interface GetUnpaidLoanOrdersParamsV5 { - orderId?: string; - loanCurrency?: string; - collateralCurrency?: string; - loanTermType?: string; - loanTerm?: string; - limit?: string; - cursor?: string; -} +token: string; // Margin coin +price: string; // Margin coin price +qty: string; // Margin coin quantity +convertedAmount: string; // Margin conversion amount ⋮---- -export interface GetRepaymentHistoryParamsV5 { - orderId?: string; - repayId?: string; - loanCurrency?: string; - limit?: string; - cursor?: string; +export interface LTVInfoV5 { + ltv: string; // Risk rate (when liqStatus != 0, returns empty string) + rst: string; // Remaining liquidation time in UTC seconds (when liqStatus != 0, returns empty string) + parentUid: string; // The designated Risk Unit ID + subAccountUids: string[]; // Bound user IDs + unpaidAmount: string; // Total debt in USDT (when liqStatus != 0, returns empty string) + unpaidInfo: UnpaidInfoV5[]; // Debt details (when liqStatus != 0, returns empty array) + balance: string; // Total asset in USDT (when liqStatus != 0, returns empty string) + balanceInfo: BalanceInfoV5[]; // Asset details (when liqStatus != 0, returns empty array) + liqStatus?: number; // Liquidation status: 0=Normal, 1=Under liquidation, 2=Manual repayment in progress, 3=Transfer in progress } ⋮---- -export interface GetCompletedLoanOrderHistoryParamsV5 { - orderId?: string; - loanCurrency?: string; - collateralCurrency?: string; - limit?: string; - cursor?: string; -} +ltv: string; // Risk rate (when liqStatus != 0, returns empty string) +rst: string; // Remaining liquidation time in UTC seconds (when liqStatus != 0, returns empty string) +parentUid: string; // The designated Risk Unit ID +subAccountUids: string[]; // Bound user IDs +unpaidAmount: string; // Total debt in USDT (when liqStatus != 0, returns empty string) +unpaidInfo: UnpaidInfoV5[]; // Debt details (when liqStatus != 0, returns empty array) +balance: string; // Total asset in USDT (when liqStatus != 0, returns empty string) +balanceInfo: BalanceInfoV5[]; // Asset details (when liqStatus != 0, returns empty array) +liqStatus?: number; // Liquidation status: 0=Normal, 1=Under liquidation, 2=Manual repayment in progress, 3=Transfer in progress ⋮---- -export interface GetLoanLTVAdjustmentHistoryParamsV5 { - orderId?: string; - adjustId?: string; - collateralCurrency?: string; - limit?: string; - cursor?: string; +export interface InstitutionalLoanLTVV5 { + ltvInfo: LTVInfoV5[]; // LTV info array + liqStatus?: number; // Liquidation status: 0=Normal, 1=Under liquidation, 2=Manual repayment in progress, 3=Transfer in progress } ⋮---- -// New Crypto Loan Request Types +ltvInfo: LTVInfoV5[]; // LTV info array +liqStatus?: number; // Liquidation status: 0=Normal, 1=Under liquidation, 2=Manual repayment in progress, 3=Transfer in progress ⋮---- -export interface GetBorrowableCoinsParamsV5 { - vipLevel?: string; - currency?: string; +export interface RepayInstitutionalLoanResultV5 { + repayOrderStatus: string; // P: processing } ⋮---- -export interface GetCollateralCoinsParamsV5 { - currency?: string; +repayOrderStatus: string; // P: processing +⋮---- +// Max Loan Amount Response Types +⋮---- +export interface MaxLoanAmountV5 { + currency: string; // Coin to borrow + maxLoan: string; // Maximum borrowable amount based on current collateral + notionalUsd: string; // Notional USD value + remainingQuota: string; // Remaining individual platform borrowing limit (shared between main and sub accounts) } ⋮---- -export interface GetMaxCollateralAmountParamsV5 { - currency: string; +currency: string; // Coin to borrow +maxLoan: string; // Maximum borrowable amount based on current collateral +notionalUsd: string; // Notional USD value +remainingQuota: string; // Remaining individual platform borrowing limit (shared between main and sub accounts) + +================ +File: src/types/response/v5-earn-liquidity-mining.ts +================ +export interface LiquidityMiningApyBreakdownV5 { + coin: string; + apy: string; } ⋮---- -export interface AdjustCollateralAmountParamsV5 { - currency: string; - amount: string; - direction: '0' | '1'; +export interface LiquidityMiningProductV5 { + productId: string; + baseCoin: string; + quoteCoin: string; + status: 'Available' | 'NotAvailable' | string; + maxLeverage: number; + minInvestmentQuote: string; + minInvestmentBase: string; + maxInvestmentQuote: string; + maxInvestmentBase: string; + minWithdrawalAmount: string; + minReinvestAmount: string; + baseCoinPrecision: number; + quoteCoinPrecision: number; + yieldCoins: string[]; + apyE8: string; + apy7dE8: string; + poolLiquidityValue: string; + dailyYield: string; + slippageRateE8List: string[]; + apyBreakdown: LiquidityMiningApyBreakdownV5[]; + apy7dBreakdown: LiquidityMiningApyBreakdownV5[]; + slippage_levels?: string[]; } ⋮---- -export interface GetCollateralAdjustmentHistoryParamsV5 { - adjustId?: string; - collateralCurrency?: string; - limit?: string; - cursor?: string; +export interface LiquidityMiningProductResultV5 { + products: LiquidityMiningProductV5[]; } ⋮---- -// Flexible Loan Request Types +export interface ReinvestLiquidityMiningResultV5 { + orderId: string; + orderLinkId: string; +} + +================ +File: src/types/response/v5-spot-leverage-token.ts +================ +import { + LeverageTokenStatusV5, + LTOrderStatusV5, + LTOrderTypeV5, +} from '../shared-v5'; ⋮---- -export interface BorrowFlexibleParamsV5 { - loanCurrency: string; - loanAmount: string; - collateralList?: { - currency: string; - amount: string; - }[]; +export interface LeverageTokenInfoV5 { + ltCoin: string; + ltName: string; + maxPurchase: string; + minPurchase: string; + maxPurchaseDaily: string; + maxRedeem: string; + minRedeem: string; + maxRedeemDaily: string; + purchaseFeeRate: string; + redeemFeeRate: string; + ltStatus: LeverageTokenStatusV5; + fundFee: string; + fundFeeTime: string; + manageFeeRate: string; + manageFeeTime: string; + value: string; + netValue: string; + total: string; } ⋮---- -export interface RepayFlexibleParamsV5 { - loanCurrency: string; - amount: string; +export interface LeveragedTokenMarketResultV5 { + ltCoin: string; + nav: string; + navTime: string; + circulation: string; + basket: string; + leverage: string; } ⋮---- -export interface RepayCollateralFlexibleParamsV5 { - loanCurrency: string; - collateralCoin: string; +export interface PurchaseSpotLeveragedTokenResultV5 { + ltCoin: string; + ltOrderStatus: LTOrderStatusV5; + execQty: string; + execAmt: string; amount: string; + purchaseId: string; + serialNo: string; + valueCoin: string; +} +export interface RedeemSpotLeveragedTokenResultV5 { + ltCoin: string; + ltOrderStatus: LTOrderStatusV5; + quantity: string; + execQty: string; + execAmt: string; + redeemId: string; + serialNo: string; + valueCoin: string; } ⋮---- -export interface GetOngoingFlexibleLoansParamsV5 { - loanCurrency?: string; +export interface SpotLeveragedTokenOrderHistoryV5 { + ltCoin: string; + orderId: string; + ltOrderType: LTOrderTypeV5; + orderTime: number; + updateTime: number; + ltOrderStatus: LTOrderStatusV5; + fee: string; + amount: string; + value: string; + valueCoin: string; + serialNo: string; } ⋮---- -export interface GetBorrowHistoryFlexibleParamsV5 { - orderId?: string; - loanCurrency?: string; - limit?: string; - cursor?: string; +export interface VIPMarginDataV5 { + vipCoinList: { + list: { + borrowable: boolean; + collateralRatio: string; + currency: string; + hourlyBorrowRate: string; + liquidationOrder: string; + marginCollateral: boolean; + maxBorrowingAmount: string; + }[]; + vipLevel: string; + }[]; } ⋮---- -export interface GetRepaymentHistoryFlexibleParamsV5 { - repayId?: string; - loanCurrency?: string; - limit?: string; - cursor?: string; +export interface SpotMarginCurrencyDataV5 { + currency: string; + flexibleManualBorrowable: boolean; + minFlexibleManualBorrowQty: string; + flexibleManualBorrowAccuracy: string; + fixedManualBorrowable: boolean; + minFixedManualBorrowQty: string; + fixedManualBorrowAccuracy: string; + fixedInterestRateAccuracy: string; + minFixedInterestRate: string; + maxFixedInterestRate: string; } ⋮---- -// Fixed Loan Request Types -⋮---- -export interface GetSupplyOrderQuoteFixedParamsV5 { - orderCurrency: string; - term?: string; - orderBy: 'apy' | 'term' | 'quantity'; - sort?: number; - limit?: number; +export interface SpotMarginStateV5 { + spotLeverage: string; + spotMarginMode: '1' | '0'; + effectiveLeverage: string; } ⋮---- -export interface GetBorrowOrderQuoteFixedParamsV5 { - orderCurrency: string; - term?: string; - orderBy: 'apy' | 'term' | 'quantity'; - sort?: number; - limit?: number; +// Spot Margin Trade (UTA) response types +export interface ManualBorrowResultV5 { + coin: string; + amount: string; } ⋮---- -export interface CreateBorrowOrderFixedParamsV5 { - orderCurrency: string; - orderAmount: string; - annualRate: string; - term: string; - autoRepay?: string; // Deprecated - repayType?: string; // 1: Auto Repayment (default); 2: Transfer to flexible loan - strategyType?: 'PARTIAL' | 'FULL'; - collateralList?: { - currency: string; - amount: string; - }[]; +export interface MaxBorrowableAmountV5 { + currency: string; + maxLoan: string; } ⋮---- -autoRepay?: string; // Deprecated -repayType?: string; // 1: Auto Repayment (default); 2: Transfer to flexible loan -⋮---- -export interface GetFixedLoanAvailableInventoryParamsV5 { - currency: string; - term: string; - annualRate: string; +export interface PositionTierV5 { + tier: string; + borrowLimit: string; + positionMMR: string; + positionIMR: string; + maxLeverage: string; } ⋮---- -export interface GetFlexibleLoanAvailableInventoryParamsV5 { +export interface CurrencyPositionTiersV5 { currency: string; + positionTiersRatioList: PositionTierV5[]; } ⋮---- -export interface CreateSupplyOrderFixedParamsV5 { - orderCurrency: string; - orderAmount: string; - annualRate: string; - term: string; - /** - * Source account for supply. 0: Funding Account; 1: Earn Flexible Account; 2: ALL. Default: 0 - */ - availableSource?: '0' | '1' | '2'; +export interface CoinStateV5 { + currency: string; + spotLeverage: string; } ⋮---- -/** - * Source account for supply. 0: Funding Account; 1: Earn Flexible Account; 2: ALL. Default: 0 - */ -⋮---- -export interface CancelBorrowOrderFixedParamsV5 { - orderId: string; +export interface AvailableAmountToRepayV5 { + currency: string; + lossLessRepaymentAmount: string; } ⋮---- -export interface CancelSupplyOrderFixedParamsV5 { - orderId: string; +export interface ManualRepayWithoutConversionResultV5 { /** - * Account to receive the refund. 0: Funding Account; 1: EasyEarn. Default: 0 + * Result status: + * - P: Processing + * - SU: Success + * - FA: Failed */ - refundedAccount?: '0' | '1'; + resultStatus: 'P' | 'SU' | 'FA'; } ⋮---- /** - * Account to receive the refund. 0: Funding Account; 1: EasyEarn. Default: 0 + * Result status: + * - P: Processing + * - SU: Success + * - FA: Failed */ ⋮---- -export interface GetBorrowContractInfoFixedParamsV5 { - orderId?: string; - loanId?: string; - orderCurrency?: string; - term?: string; - limit?: string; - cursor?: string; -} -⋮---- -export interface GetSupplyContractInfoFixedParamsV5 { - orderId?: string; - supplyId?: string; - supplyCurrency?: string; - term?: string; - limit?: string; - cursor?: string; +export interface AutoRepayModeItemV5 { + currency: string; // Coin name, uppercase only + autoRepayMode: '0' | '1'; // 0: Off, 1: On } ⋮---- -export interface GetBorrowOrderInfoFixedParamsV5 { - orderId?: string; - orderCurrency?: string; - state?: string; - term?: string; - limit?: string; - cursor?: string; -} +currency: string; // Coin name, uppercase only +autoRepayMode: '0' | '1'; // 0: Off, 1: On ⋮---- -export interface GetSupplyOrderInfoFixedParamsV5 { - orderId?: string; - orderCurrency?: string; - state?: string; - term?: string; - limit?: string; - cursor?: string; +export interface AutoRepayModeResultV5 { + data: AutoRepayModeItemV5[]; } ⋮---- -export interface RepayFixedParamsV5 { - loanId?: string; - loanCurrency?: string; +export interface SpotMarginLiabilityInfoV5 { + currency: string; + totalBorrowAmount: string; + fixedBorrowAmount: string; + flexibleBorrowAmount: string; + spotTotalBorrow: string; + derivativesBorrow: string; } ⋮---- -export interface RepayCollateralFixedParamsV5 { - loanCurrency: string; - collateralCoin: string; - amount: string; +export interface FixedRateBorrowResultV5 { + orderId: string; } ⋮---- -export interface GetRepaymentHistoryFixedParamsV5 { - repayId?: string; - loanCurrency?: string; - limit?: string; - cursor?: string; +export interface FixedRateBorrowOrderInfoV5 { + annualRate: string; + orderId: string; + orderTime: string; + filledQty: string; + orderQty: string; + orderCurrency: string; + state: number; + term: number; + repayType: string; + strategyType: 'PARTIAL' | 'FULL'; } ⋮---- -export interface RenewBorrowOrderFixedParamsV5 { +export interface FixedRateBorrowContractInfoV5 { + annualRate: string; + borrowCurrency: string; + borrowTime: string; + interestPaid: string; loanId: string; - collateralList?: { - currency?: string; - amount?: string; - }[]; -} -⋮---- -export interface GetRenewOrderInfoFixedParamsV5 { - orderId?: string; - orderCurrency?: string; - limit?: string; - cursor?: string; + orderId: string; + repaymentTime: string; + residualPenaltyInterest: string; + residualPrincipal: string; + status: number; + term: string; + repayType: string; + strategyType: 'PARTIAL' | 'FULL'; } ⋮---- -// Max Loan Amount Request Types -⋮---- -export interface GetMaxLoanAmountParamsV5 { - currency: string; // Coin to borrow - collateralList?: { - ccy: string; // Collateral coin - amount: string; // Collateral amount - }[]; +export interface FixedRateBorrowQuoteV5 { + orderCurrency: string; + term: number; + annualRate: string; + qty: string; } ⋮---- -currency: string; // Coin to borrow -⋮---- -ccy: string; // Collateral coin -amount: string; // Collateral amount -⋮---- -// Institutional Loan Request Types -⋮---- -export interface GetCoinDeltaAmountParamsV5 { - coin?: string; +export interface FlexibleAvailableInventoryV5 { + currency: string; + availableInventory: string; + updateTime: string; } ⋮---- -export interface RepayInstitutionalLoanParamsV5 { - token: string; // Coin name - quantity: string; // The qty to be repaid +export interface FixedRateAvailableInventoryV5 { + currency: string; + term: string; + annualRate: string; + availableInventory: string; + updateTime: string; } -⋮---- -token: string; // Coin name -quantity: string; // The qty to be repaid ================ -File: src/types/request/v5-earn.ts +File: src/types/response/v5-trade.ts ================ -export interface GetEarnCouponListParamsV5 { - category: 'FlexibleSaving' | 'DualAssets'; -} +import { + CategoryV5, + OrderCancelTypeV5, + OrderCreateTypeV5, + OrderRejectReasonV5, + OrderSideV5, + OrderStatusV5, + OrderTimeInForceV5, + OrderTriggerByV5, + OrderTypeV5, + PositionIdx, + StopOrderTypeV5, +} from '../shared-v5'; ⋮---- -export interface SubmitStakeRedeemParamsV5 { - category: string; - orderType: 'Stake' | 'Redeem'; - accountType: 'FUND' | 'UNIFIED'; - amount: string; - coin: string; - productId: string; +export interface OrderResultV5 { + orderId: string; orderLinkId: string; - toAccountType?: 'FUND' | 'UNIFIED'; } ⋮---- -export interface GetEarnOrderHistoryParamsV5 { - category: string; - orderId?: string; - orderLinkId?: string; - productId?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; +export interface AccountOrderV5 { + orderId: string; + orderLinkId: string; + parentOrderLinkId?: string; // Linked parent order for attached TP/SL orders (futures & options) + blockTradeId: string; + symbol: string; + price: string; + qty: string; + side: OrderSideV5; + isLeverage: '0' | '1'; + positionIdx: PositionIdx; + orderStatus: OrderStatusV5; + createType: OrderCreateTypeV5; + cancelType: OrderCancelTypeV5; + rejectReason: OrderRejectReasonV5; + avgPrice: string; + leavesQty: string; + leavesValue: string; + cumExecQty: string; + cumExecValue: string; + cumExecFee: string; + timeInForce: OrderTimeInForceV5; + orderType: OrderTypeV5; + stopOrderType: StopOrderTypeV5; + orderIv: string; + marketUnit: 'baseCoin' | 'quoteCoin'; + slippageToleranceType: string; + slippageTolerance: string; + triggerPrice: string; + takeProfit: string; + stopLoss: string; + tpslMode: 'Full' | 'Partial' | ''; + ocoTriggerType: + | 'OcoTriggerByUnknown' + | 'OcoTriggerTp' + | 'OcoTriggerBySl' + | ''; + tpLimitPrice: string; + slLimitPrice: string; + tpTriggerBy: OrderTriggerByV5; + slTriggerBy: OrderTriggerByV5; + triggerDirection: 1 | 2; + triggerBy: OrderTriggerByV5; + lastPriceOnCreated: string; + basePrice: string; + reduceOnly: boolean; + closeOnTrigger: boolean; + placeType: 'iv' | 'price' | ''; + smpType: string; + smpGroup: string; + smpOrderId: string; + createdTime: string; + updatedTime: string; + extraFees: string; + cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee + rpiTakerAccess?: boolean; + rpiMatchedQty?: string; + fromAccount?: string; + toAccount?: string; + externalEventType?: string; } ⋮---- -export interface GetEarnPositionParamsV5 { - category: string; - productId?: string; - coin?: string; -} +parentOrderLinkId?: string; // Linked parent order for attached TP/SL orders (futures & options) ⋮---- -export interface GetEarnYieldHistoryParamsV5 { - category: string; - productId?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; -} +cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee ⋮---- -export interface GetEarnHourlyYieldHistoryParamsV5 { - category: string; - productId?: string; - startTime?: number; - endTime?: number; - limit?: number; - cursor?: string; +export interface BatchCreateOrderResultV5 { + category: CategoryV5; + symbol: string; + orderId: string; + orderLinkId: string; + createAt?: string; } ⋮---- -export interface ModifyEarnPositionParamsV5 { - category: 'OnChain'; - productId: number; - positionId: number; - autoReinvest: 0 | 1; +export interface BatchOrdersRetExtInfoV5 { + list: { + code: number; + msg: string; + }[]; } ⋮---- -export interface GetEarnAprHistoryParamsV5 { - category: 'FlexibleSaving' | 'OnChain'; - productId: string; - startTime?: number; - endTime?: number; +export interface BatchAmendOrderResultV5 { + category: CategoryV5; + symbol: string; + orderId: string; + orderLinkId: string; } ⋮---- -/** - * GET /v5/earn/advance/product — Advanced Earn: Dual Asset, Double Win, Smart Leverage, etc. - * Public, no auth. Rate limit: 50 req/s per IP. - */ -export interface GetAdvanceEarnProductParamsV5 { - category: 'DualAssets' | 'DoubleWin' | 'SmartLeverage' | 'DiscountBuy'; - coin?: string; - /** - * Product duration, e.g. 8h, 1d, 2d, 3d, 6d, 7d, 12d (depends on product). - */ - duration?: string; +export interface BatchCancelOrderResultV5 { + category: CategoryV5; + symbol: string; + orderId: string; + orderLinkId: string; } ⋮---- -/** - * Product duration, e.g. 8h, 1d, 2d, 3d, 6d, 7d, 12d (depends on product). - */ -⋮---- -/** GET /v5/earn/hold-to-earn/yield-history — Hold to Earn airdrop daily PnL (Earn permission) */ -export interface GetHoldToEarnAirdropYieldHistoryParamsV5 { - /** Unix seconds. Cannot be earlier than now minus 3 months */ - timeStart?: number; - /** Unix seconds. Requires timeStart ≤ timeEnd */ - timeEnd?: number; - /** Page size [1, 49] */ - limit: number; - /** Pagination cursor from previous `nextCursor` */ - cursor?: string; +export interface SpotBorrowCheckResultV5 { + symbol: string; + side: OrderSideV5; + maxTradeQty: string; + maxTradeAmount: string; + spotMaxTradeQty: string; + spotMaxTradeAmount: string; + borrowCoin: string; } ⋮---- -/** Unix seconds. Cannot be earlier than now minus 3 months */ -⋮---- -/** Unix seconds. Requires timeStart ≤ timeEnd */ -⋮---- -/** Page size [1, 49] */ +export interface PreCheckOrderResultV5 { + orderId: string; + orderLinkId: string; + preImrE4: number; // Initial margin rate before checking (in basis points) + preMmrE4: number; // Maintenance margin rate before checking (in basis points) + postImrE4: number; // Initial margin rate after checking (in basis points) + postMmrE4: number; // Maintenance margin rate after checking (in basis points) +} ⋮---- -/** Pagination cursor from previous `nextCursor` */ +preImrE4: number; // Initial margin rate before checking (in basis points) +preMmrE4: number; // Maintenance margin rate before checking (in basis points) +postImrE4: number; // Initial margin rate after checking (in basis points) +postMmrE4: number; // Maintenance margin rate after checking (in basis points) ================ -File: src/types/request/v5-market.ts +File: src/types/request/v5-account.ts ================ -import { KlineIntervalV3 } from '../shared'; import { - CategoryV5, - InstrumentStatusV5, - InstrumentSymbolTypeV5, - OptionTypeV5, -} from '../shared-v5'; -⋮---- -export interface GetKlineParamsV5 { - category: 'spot' | 'linear' | 'inverse'; - symbol: string; - interval: KlineIntervalV3; - start?: number; - end?: number; - limit?: number; -} -⋮---- -export interface GetMarkPriceKlineParamsV5 { - /** - * linear (default if omitted), inverse, or option. - */ - category?: 'linear' | 'inverse' | 'option'; - symbol: string; - interval: KlineIntervalV3; - start?: number; - end?: number; - /** - * Futures: [1, 1000], default 200. Options: [1, 500], default 200. - */ - limit?: number; -} -⋮---- -/** - * linear (default if omitted), inverse, or option. - */ -⋮---- -/** - * Futures: [1, 1000], default 200. Options: [1, 500], default 200. - */ + AccountTypeV5, + CategoryV5, + InstrumentSymbolTypeV5, + TransactionTypeV5, +} from '../shared-v5'; ⋮---- -export interface GetIndexPriceKlineParamsV5 { - category: 'linear' | 'inverse'; - symbol: string; - interval: KlineIntervalV3; - start?: number; - end?: number; - limit?: number; +export interface GetWalletBalanceParamsV5 { + accountType: AccountTypeV5; + coin?: string; } ⋮---- -export interface GetPremiumIndexPriceKlineParamsV5 { - category: 'linear'; - symbol: string; - interval: KlineIntervalV3; - start?: number; - end?: number; +export interface GetBorrowHistoryParamsV5 { + currency?: string; + startTime?: number; + endTime?: number; limit?: number; + cursor?: string; } ⋮---- -export interface GetInstrumentsInfoParamsV5 { +export interface GetFeeRateParamsV5 { category: CategoryV5; symbol?: string; - /** Filter by instrument `symbolType` (e.g. `commodity`, `stock`, `forex` for linear). */ - symbolType?: InstrumentSymbolTypeV5; - status?: InstrumentStatusV5; - /** For `category=option`, pass `All` to return all option symbols. */ baseCoin?: string; - limit?: number; - cursor?: string; } ⋮---- -/** Filter by instrument `symbolType` (e.g. `commodity`, `stock`, `forex` for linear). */ -⋮---- -/** For `category=option`, pass `All` to return all option symbols. */ -⋮---- -export interface GetOrderbookParamsV5 { - category: CategoryV5; - symbol: string; +export interface GetTransactionLogParamsV5 { + accountType?: AccountTypeV5; + category?: CategoryV5; + currency?: string; + baseCoin?: string; + type?: TransactionTypeV5; + /** + * Transaction sub type, "movePosition", used to filter trans logs of Move Position only + */ + transSubType?: string; + startTime?: number; + endTime?: number; limit?: number; + cursor?: string; } ⋮---- -export interface GetRPIOrderbookParamsV5 { - category?: 'spot' | 'linear' | 'inverse'; - symbol: string; - limit: number; // Required for RPI orderbook, [1, 50] -} -⋮---- -limit: number; // Required for RPI orderbook, [1, 50] +/** + * Transaction sub type, "movePosition", used to filter trans logs of Move Position only + */ ⋮---- -export interface GetIndexPriceComponentsParamsV5 { - indexName: string; // Index name, like BTCUSDT +export interface MMPModifyParamsV5 { + baseCoin: string; + window: string; + frozenPeriod: string; + qtyLimit: string; + deltaLimit: string; + vegaLimit?: string; } ⋮---- -indexName: string; // Index name, like BTCUSDT -⋮---- -export interface GetADLAlertParamsV5 { - symbol?: string; // Contract name, e.g. BTCUSDT. Uppercase only +export interface RepayLiabilityParamsV5 { + coin?: string; } ⋮---- -symbol?: string; // Contract name, e.g. BTCUSDT. Uppercase only -⋮---- -export interface GetFeeGroupStructureParamsV5 { - productType: string; // Product type. contract only for now - groupId?: string; // Group ID. 1, 2, 3, 4, 5, 6, 7 +export interface SetCollateralCoinParamsV5 { + coin: string; + collateralSwitch: 'ON' | 'OFF'; } ⋮---- -productType: string; // Product type. contract only for now -groupId?: string; // Group ID. 1, 2, 3, 4, 5, 6, 7 -⋮---- -export interface GetTickersParamsV5 { - category: TCategory; - symbol?: string; +export interface GetClassicTransactionLogsParamsV5 { + currency?: string; baseCoin?: string; - expDate?: string; -} -⋮---- -export interface GetFundingRateHistoryParamsV5 { - category: 'linear' | 'inverse'; - symbol: string; + type?: string; startTime?: number; endTime?: number; limit?: number; + cursor?: string; } ⋮---- -export interface GetPublicTradingHistoryParamsV5 { +export interface SetLimitPriceActionParamsV5 { category: CategoryV5; - symbol: string; - baseCoin?: string; - optionType?: OptionTypeV5; - limit?: number; + modifyEnable: boolean; } ⋮---- -export type OpenInterestIntervalV5 = - | '5min' - | '15min' - | '30min' - | '1h' - | '4h' - | '1d'; +/** + * Set Delta Neutral Mode. POST /v5/account/set-delta-mode + * 1: enable, 0: disable. + */ +export interface SetDeltaNeutralModeParamsV5 { + deltaEnable: '1' | '0'; +} ⋮---- -export interface GetOpenInterestParamsV5 { - category: 'linear' | 'inverse'; - symbol: string; - intervalTime: OpenInterestIntervalV5; - startTime?: number; - endTime?: number; +export interface GetAccountInstrumentsInfoParamsV5 { + category: 'spot' | 'linear' | 'inverse'; + symbol?: string; + /** Filter by `symbolType` (e.g. `commodity`, `stock`, `forex` for linear). */ + symbolType?: InstrumentSymbolTypeV5; limit?: number; cursor?: string; } ⋮---- -export interface GetHistoricalVolatilityParamsV5 { - category: 'option'; - baseCoin?: string; - period?: 7 | 14 | 21 | 30 | 60 | 90 | 180 | 270; +/** Filter by `symbolType` (e.g. `commodity`, `stock`, `forex` for linear). */ +⋮---- +/** GET /v5/account/pay-info */ +export interface GetPayInfoParamsV5 { + coin?: string; +} +⋮---- +/** GET /v5/account/trade-info-for-analysis */ +export interface GetTradeInfoForAnalysisParamsV5 { + symbol: string; startTime?: number; endTime?: number; } ⋮---- -export interface GetInsuranceParamsV5 { +export interface ManualRepayParamsV5 { coin?: string; + amount?: string; + /** + * ALL: fixed + floating (floating first); FIXED: fixed only; FLEXIBLE: floating only. Default: FLEXIBLE. + * If neither `coin` nor `amount` is set, this must be ALL (repay all liabilities) or the request is rejected. + */ + repaymentType?: 'ALL' | 'FIXED' | 'FLEXIBLE'; } ⋮---- -export interface GetRiskLimitParamsV5 { - category?: 'linear' | 'inverse'; - symbol?: string; +/** + * ALL: fixed + floating (floating first); FIXED: fixed only; FLEXIBLE: floating only. Default: FLEXIBLE. + * If neither `coin` nor `amount` is set, this must be ALL (repay all liabilities) or the request is rejected. + */ + +================ +File: src/types/request/v5-crypto-loan.ts +================ +export interface BorrowCryptoLoanParamsV5 { + loanCurrency: string; + loanAmount?: string; + loanTerm?: string; + collateralCurrency: string; + collateralAmount?: string; +} +⋮---- +export interface GetUnpaidLoanOrdersParamsV5 { + orderId?: string; + loanCurrency?: string; + collateralCurrency?: string; + loanTermType?: string; + loanTerm?: string; + limit?: string; cursor?: string; } ⋮---- -export interface GetOptionDeliveryPriceParamsV5 { - category: 'option'; - symbol?: string; - baseCoin?: string; - limit?: number; +export interface GetRepaymentHistoryParamsV5 { + orderId?: string; + repayId?: string; + loanCurrency?: string; + limit?: string; cursor?: string; } ⋮---- -export interface GetDeliveryPriceParamsV5 { - category: 'linear' | 'inverse' | 'option'; - symbol?: string; - baseCoin?: string; - settleCoin?: string; - limit?: number; +export interface GetCompletedLoanOrderHistoryParamsV5 { + orderId?: string; + loanCurrency?: string; + collateralCurrency?: string; + limit?: string; cursor?: string; } ⋮---- -export interface GetLongShortRatioParamsV5 { - category: 'linear' | 'inverse'; - symbol: string; - period: OpenInterestIntervalV5; - startTime?: string; - endTime?: string; - limit?: number; +export interface GetLoanLTVAdjustmentHistoryParamsV5 { + orderId?: string; + adjustId?: string; + collateralCurrency?: string; + limit?: string; cursor?: string; } ⋮---- -export interface GetFullDepthOrderbookParamsV5 { - category: 'spot' | 'linear' | 'inverse'; - symbol: string; +// New Crypto Loan Request Types +⋮---- +export interface GetBorrowableCoinsParamsV5 { + vipLevel?: string; + currency?: string; } - -================ -File: src/types/request/v5-user.ts -================ -import { PermissionsV5 } from '../shared-v5'; ⋮---- -export interface CreateSubMemberParamsV5 { - username: string; - password?: string; - /** - * 1: normal, 6: custodial - */ - memberType: 1 | 6; - /** - * 0: quick login disabled (default), 1: quick login enabled - */ - switch?: 0 | 1; - isUta?: boolean; - note?: string; +export interface GetCollateralCoinsParamsV5 { + currency?: string; +} +⋮---- +export interface GetMaxCollateralAmountParamsV5 { + currency: string; +} +⋮---- +export interface AdjustCollateralAmountParamsV5 { + currency: string; + amount: string; + direction: '0' | '1'; +} +⋮---- +export interface GetCollateralAdjustmentHistoryParamsV5 { + adjustId?: string; + collateralCurrency?: string; + limit?: string; + cursor?: string; } ⋮---- -/** - * 1: normal, 6: custodial - */ -⋮---- -/** - * 0: quick login disabled (default), 1: quick login enabled - */ +// Flexible Loan Request Types ⋮---- -export interface CreateSubApiKeyParamsV5 { - subuid: number; - note?: string; - readOnly: 0 | 1; - ips?: string; - permissions: PermissionsV5; +export interface BorrowFlexibleParamsV5 { + loanCurrency: string; + loanAmount: string; + collateralList?: { + currency: string; + amount: string; + }[]; } ⋮---- -export interface UpdateApiKeyParamsV5 { - apikey?: string; - readOnly?: 0 | 1; - permissions: PermissionsV5; +export interface RepayFlexibleParamsV5 { + loanCurrency: string; + amount: string; } ⋮---- -export interface UpdateSubApiKeyUpdateParamsV5 { - readOnly?: number; - ips?: string[]; - permissions: PermissionsV5; +export interface RepayCollateralFlexibleParamsV5 { + loanCurrency: string; + collateralCoin: string; + amount: string; } ⋮---- -export interface DeleteSubMemberParamsV5 { - subMemberId: string; +export interface GetOngoingFlexibleLoansParamsV5 { + loanCurrency?: string; } ⋮---- -export interface GetSubAccountAllApiKeysParamsV5 { - subMemberId: string; - limit?: number; +export interface GetBorrowHistoryFlexibleParamsV5 { + orderId?: string; + loanCurrency?: string; + limit?: string; cursor?: string; } ⋮---- -export interface GetAffiliateUserListParamsV5 { - size?: number; +export interface GetRepaymentHistoryFlexibleParamsV5 { + repayId?: string; + loanCurrency?: string; + limit?: string; cursor?: string; - needDeposit?: boolean; - need30?: boolean; - need365?: boolean; - startDate?: string; - endDate?: string; } ⋮---- -/** GET /v5/affiliate/affiliate-sub-list */ -export interface GetAffiliateSubAffiliateListParamsV5 { - cursor?: string; - /** [0, 100]. Default: 0 */ - size?: number; - /** YYYY-MM-DD. Range with endDate max 3 months */ - startDate?: string; - /** YYYY-MM-DD. Must be provided with startDate or both omitted (T-1 default) */ - endDate?: string; - /** Exact sub-affiliate ID. 0 or omit for all */ - subAffId?: number; +// Fixed Loan Request Types +⋮---- +export interface GetSupplyOrderQuoteFixedParamsV5 { + orderCurrency: string; + term?: string; + orderBy: 'apy' | 'term' | 'quantity'; + sort?: number; + limit?: number; } ⋮---- -/** [0, 100]. Default: 0 */ +export interface GetBorrowOrderQuoteFixedParamsV5 { + orderCurrency: string; + term?: string; + orderBy: 'apy' | 'term' | 'quantity'; + sort?: number; + limit?: number; +} ⋮---- -/** YYYY-MM-DD. Range with endDate max 3 months */ +export interface CreateBorrowOrderFixedParamsV5 { + orderCurrency: string; + orderAmount: string; + annualRate: string; + term: string; + autoRepay?: string; // Deprecated + repayType?: string; // 1: Auto Repayment (default); 2: Transfer to flexible loan + strategyType?: 'PARTIAL' | 'FULL'; + collateralList?: { + currency: string; + amount: string; + }[]; +} ⋮---- -/** YYYY-MM-DD. Must be provided with startDate or both omitted (T-1 default) */ +autoRepay?: string; // Deprecated +repayType?: string; // 1: Auto Repayment (default); 2: Transfer to flexible loan ⋮---- -/** Exact sub-affiliate ID. 0 or omit for all */ +export interface GetFixedLoanAvailableInventoryParamsV5 { + currency: string; + term: string; + annualRate: string; +} ⋮---- -export interface GetAffiliateUserInfoParamsV5 { - /** The master account UID of affiliate's client */ - uid: string; - /** Coin type for filtering, e.g. USDT */ - coin?: string; +export interface GetFlexibleLoanAvailableInventoryParamsV5 { + currency: string; +} +⋮---- +export interface CreateSupplyOrderFixedParamsV5 { + orderCurrency: string; + orderAmount: string; + annualRate: string; + term: string; /** - * Business line filter. 1: Derivatives, 2: Spot, 3: ByFi, 4: USDC, 5: Options + * Source account for supply. 0: Funding Account; 1: Earn Flexible Account; 2: ALL. Default: 0 */ - business?: '1' | '2' | '3' | '4' | '5'; + availableSource?: '0' | '1' | '2'; } ⋮---- -/** The master account UID of affiliate's client */ -⋮---- -/** Coin type for filtering, e.g. USDT */ -⋮---- /** - * Business line filter. 1: Derivatives, 2: Spot, 3: ByFi, 4: USDC, 5: Options + * Source account for supply. 0: Funding Account; 1: Earn Flexible Account; 2: ALL. Default: 0 */ ⋮---- -/** Get Friend Referrals - invitation relationship status. 0: alive; 1: invalid */ -export interface GetFriendReferralsParamsV5 { - status?: string; - size?: string; - cursor?: string; -} -⋮---- -/** Sign Agreement. Only master account. - * - `category` (legacy): 2 = metals (XAU/XAG perps; stock perps share this); 3 = crude oil. New enum values are not added here; prefer `categoryV2`. - * - `categoryV2` (recommended): 1 = metals; 2 = crude oil. Additional values may be added by the API; use a numeric literal or variable. - * - Either `category` or `categoryV2` must be sent. */ -export interface SignAgreementParamsV5 { - agree: boolean; - category?: 2 | 3; - categoryV2?: number; +export interface CancelBorrowOrderFixedParamsV5 { + orderId: string; } - -================ -File: src/types/response/v5-account.ts -================ -import { - AccountMarginModeV5, - AccountTypeV5, - CategoryV5, - TransactionTypeV5, - UnifiedUpdateStatusV5, -} from '../shared-v5'; ⋮---- -export interface WalletBalanceV5Coin { - coin: string; - equity: string; - usdValue: string; - walletBalance: string; - free: string; // spot only - locked: string; // spot only - borrowAmount: string; - availableToBorrow: string; // deprecated field - availableToWithdraw: string; - accruedInterest: string; - totalOrderIM: string; - totalPositionIM: string; - totalPositionMM: string; - unrealisedPnl: string; - cumRealisedPnl: string; - bonus: string; - marginCollateral: boolean; - collateralSwitch: boolean; - spotBorrow: string; - colRes?: string; +export interface CancelSupplyOrderFixedParamsV5 { + orderId: string; + /** + * Account to receive the refund. 0: Funding Account; 1: EasyEarn. Default: 0 + */ + refundedAccount?: '0' | '1'; } ⋮---- -free: string; // spot only -locked: string; // spot only +/** + * Account to receive the refund. 0: Funding Account; 1: EasyEarn. Default: 0 + */ ⋮---- -availableToBorrow: string; // deprecated field +export interface GetBorrowContractInfoFixedParamsV5 { + orderId?: string; + loanId?: string; + orderCurrency?: string; + term?: string; + limit?: string; + cursor?: string; +} ⋮---- -export interface WalletBalanceV5 { - accountType: AccountTypeV5; - accountLTV: string; - accountIMRate: string; - accountMMRate: string; - accountIMRateByMp: string; - accountMMRateByMp: string; - totalInitialMarginByMp: string; - totalMaintenanceMarginByMp: string; - totalEquity: string; - totalWalletBalance: string; - totalMarginBalance: string; - totalAvailableBalance: string; - totalPerpUPL: string; - totalInitialMargin: string; - totalMaintenanceMargin: string; - coin: WalletBalanceV5Coin[]; +export interface GetSupplyContractInfoFixedParamsV5 { + orderId?: string; + supplyId?: string; + supplyCurrency?: string; + term?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface UnifiedAccountUpgradeResultV5 { - unifiedUpdateStatus: UnifiedUpdateStatusV5; - unifiedUpdateMsg: { - msg: string[] | null; - }; +export interface GetBorrowOrderInfoFixedParamsV5 { + orderId?: string; + orderCurrency?: string; + state?: string; + term?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface BorrowHistoryRecordV5 { - currency: string; - createdTime: number; - borrowCost: string; - hourlyBorrowRate: string; - InterestBearingBorrowSize: string; - costExemption: string; - borrowAmount: string; - unrealisedLoss: string; - freeBorrowedAmount: string; +export interface GetSupplyOrderInfoFixedParamsV5 { + orderId?: string; + orderCurrency?: string; + state?: string; + term?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface CollateralInfoV5 { - currency: string; - hourlyBorrowRate: string; - maxBorrowingAmount: string; - freeBorrowAmount: string; - freeBorrowingLimit: string; - borrowAmount: string; - availableToBorrow: string; - borrowable: boolean; - borrowUsageRate: string; - marginCollateral: boolean; - collateralSwitch: boolean; - collateralRatio: string; +export interface RepayFixedParamsV5 { + loanId?: string; + loanCurrency?: string; } ⋮---- -export interface CoinGreeksV5 { - baseCoin: string; - totalDelta: string; - totalGamma: string; - totalVega: string; - totalTheta: string; +export interface RepayCollateralFixedParamsV5 { + loanCurrency: string; + collateralCoin: string; + amount: string; } ⋮---- -export interface FeeRateV5 { - symbol: string; - baseCoin: string; - takerFeeRate: string; - makerFeeRate: string; - rpiMakerFeeRate?: string; +export interface GetRepaymentHistoryFixedParamsV5 { + repayId?: string; + loanCurrency?: string; + limit?: string; + cursor?: string; } ⋮---- -export interface AccountInfoV5 { - unifiedMarginStatus: number; - marginMode: AccountMarginModeV5; - isMasterTrader: boolean; - spotHedgingStatus: string; - updatedTime: string; +export interface RenewBorrowOrderFixedParamsV5 { + loanId: string; + collateralList?: { + currency?: string; + amount?: string; + }[]; } ⋮---- -/** - * Get Trade Behaviour Config / `getLimitPriceAction()` — `/v5/account/user-setting-config` - */ -export interface UserSettingConfigV5 { - lpaSpot: boolean; - lpaPerp: boolean; - /** Spot MNT fee deduction enabled. */ - smsef?: boolean; - /** Futures MNT fee deduction enabled. */ - fmsef?: boolean; - /** Delta Neutral mode; may be absent on older API responses. */ - deltaEnable?: boolean; - smpType?: '0' | '1' | '2' | '3' | string; +export interface GetRenewOrderInfoFixedParamsV5 { + orderId?: string; + orderCurrency?: string; + limit?: string; + cursor?: string; } ⋮---- -/** Spot MNT fee deduction enabled. */ +// Max Loan Amount Request Types ⋮---- -/** Futures MNT fee deduction enabled. */ +export interface GetMaxLoanAmountParamsV5 { + currency: string; // Coin to borrow + collateralList?: { + ccy: string; // Collateral coin + amount: string; // Collateral amount + }[]; +} ⋮---- -/** Delta Neutral mode; may be absent on older API responses. */ +currency: string; // Coin to borrow ⋮---- -export interface TransactionLogV5 { - symbol: string; - category: CategoryV5; - side: string; - transactionTime: string; - type: TransactionTypeV5; - qty: string; - size: string; - currency: string; - tradePrice: string; - funding: string; - fee: string; - cashFlow: string; - change: string; - cashBalance: string; - feeRate: string; - bonusChange: string; - tradeId: string; - orderId: string; - orderLinkId: string; - extraFees: string; - transSubType: string; - displayType?: string; -} +ccy: string; // Collateral coin +amount: string; // Collateral amount ⋮---- -export interface MMPStateV5 { - baseCoin: string; - mmpEnabled: boolean; - window: string; - frozenPeriod: string; - qtyLimit: string; - deltaLimit: string; - vegaLimit?: string; - mmpFrozenUntil: string; - mmpFrozen: boolean; -} +// Institutional Loan Request Types ⋮---- -export interface RepayLiabilityResultV5 { - coin: string; - repaymentQty: string; +export interface GetCoinDeltaAmountParamsV5 { + coin?: string; } ⋮---- -export interface DCPInfoV5 { - product: 'SPOT' | 'DERIVATIVES' | 'OPTIONS'; - dcpStatus: 'ON'; - timeWindow: string; +export interface RepayInstitutionalLoanParamsV5 { + token: string; // Coin name + quantity: string; // The qty to be repaid } ⋮---- -export interface ManualRepayResultV5 { - resultStatus: 'P' | 'SU' | 'FA'; +token: string; // Coin name +quantity: string; // The qty to be repaid + +================ +File: src/types/request/v5-earn.ts +================ +export interface GetEarnCouponListParamsV5 { + category: 'FlexibleSaving' | 'DualAssets'; } ⋮---- -/** GET /v5/account/option-asset-info — response `result` wraps a nested `result` array. */ -export interface OptionAssetInfoRowV5 { - coin: string; - totalDelta: string; - totalRPL: string; - totalUPL: string; - assetIM: string; - assetMM: string; - sendTime: number; +/** GET /v5/earn/flexible-saving/auto-savings. coins is a repeated query param, max 50. */ +export interface GetFlexibleSavingAutoSavingsParamsV5 { + coins?: string[]; } ⋮---- -export interface OptionAssetInfoNestedResultV5 { - result: OptionAssetInfoRowV5[]; +/** POST /v5/earn/flexible-saving/auto-savings. Omit coin to update the global setting. */ +export interface SetFlexibleSavingAutoSavingsParamsV5 { + coin?: string; + isSelected: boolean; + purchaseImmediately?: boolean; } ⋮---- -/** GET /v5/account/pay-info */ -export interface PayInfoCollateralItemV5 { +export interface SubmitStakeRedeemParamsV5 { + category: string; + orderType: 'Stake' | 'Redeem'; + accountType: 'FUND' | 'UNIFIED'; + amount: string; coin: string; - availableSize: string; - availableValue: string; - coinScale: number; - borrowSize: string; - spotHedgeAmount: string; - assetFrozen: string; + productId: string; + orderLinkId: string; + toAccountType?: 'FUND' | 'UNIFIED'; } ⋮---- -export interface PayInfoBorrowBlockV5 { +export interface GetEarnOrderHistoryParamsV5 { + category: string; + orderId?: string; + orderLinkId?: string; + productId?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; +} +⋮---- +export interface GetEarnPositionParamsV5 { + category: string; + productId?: string; coin?: string; - borrowSize: string; - borrowValue?: string; - assetFrozen: string; - availableBalance: string; } ⋮---- -export interface PayInfoResultV5 { - collateralInfo: { - collateralList: PayInfoCollateralItemV5[]; - }; - borrowInfo: PayInfoBorrowBlockV5; +export interface GetEarnYieldHistoryParamsV5 { + category: string; + productId?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; } ⋮---- -/** GET /v5/account/trade-info-for-analysis */ -export interface TradeInfoAnalysisDailyV5 { - day: string; - sumBuyExecValue: string; - sumSellExecValue: string; - sumExecValue: string; +export interface GetEarnHourlyYieldHistoryParamsV5 { + category: string; + productId?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; } ⋮---- -export interface TradeInfoForAnalysisResultV5 { - symbolRnl: string; - netExecQty: string; - sumExecValue: string; - sumExecQty: string; - avgBuyExecPrice: string; - sumBuyExecValue: string; - sumBuyExecQty: string; - sumBuyExecFee: string; - sumBuyOrderQty: string; - avgSellExecPrice: string; - sumSellExecValue: string; - sumSellExecQty: string; - sumSellExecFee: string; - sumSellOrderQty: string; - maxMarginVersion: number; - baseCoin: string; - settleCoin: string; - sumPriceList?: TradeInfoAnalysisDailyV5[]; +export interface ModifyEarnPositionParamsV5 { + category: 'OnChain'; + productId: number; + positionId: number; + autoReinvest: 0 | 1; +} +⋮---- +export interface GetEarnAprHistoryParamsV5 { + category: 'FlexibleSaving' | 'OnChain'; + productId: string; + startTime?: number; + endTime?: number; } - -================ -File: src/types/response/v5-market.ts -================ -import { - CategoryCursorListV5, - CategoryV5, - ContractTypeV5, - CopyTradingV5, - InstrumentStatusV5, - InstrumentSymbolTypeV5, - MarginTradingV5, - OptionTypeV5, - OrderSideV5, -} from '../shared-v5'; ⋮---- /** - * OHLCVT candle used by v5 APIs - * - * - list[0]: startTime string Start time of the candle (ms) - * - list[1]: openPrice string Open price - * - list[2]: highPrice string Highest price - * - list[3]: lowPrice string Lowest price - * - list[4]: closePrice string Close price. Is the last traded price when the candle is not closed - * - list[5]: volume string Trade volume. Unit of contract: pieces of contract. Unit of spot: quantity of coins - * - list[6]: turnover string Turnover. Unit of figure: quantity of quota coin + * GET /v5/earn/advance/product — Advanced Earn: Dual Asset, Double Win, Smart Leverage, etc. + * Public, no auth. Rate limit: 50 req/s per IP. */ -export type OHLCVKlineV5 = [ - string, - string, - string, - string, - string, - string, - string, -]; +export interface GetAdvanceEarnProductParamsV5 { + category: 'DualAssets' | 'DoubleWin' | 'SmartLeverage' | 'DiscountBuy'; + coin?: string; + /** + * Product duration, e.g. 8h, 1d, 2d, 3d, 6d, 7d, 12d (depends on product). + */ + duration?: string; +} ⋮---- /** - * OHLC candle used by v5 APIs - * - * - list[0]: startTime string Start time of the candle (ms) - * - list[1]: openPrice string Open price - * - list[2]: highPrice string Highest price - * - list[3]: lowPrice string Lowest price - * - list[4]: closePrice string Close price. Is the last traded price when the candle is not closed - */ -export type OHLCKlineV5 = [string, string, string, string, string]; + * Product duration, e.g. 8h, 1d, 2d, 3d, 6d, 7d, 12d (depends on product). + */ ⋮---- -export interface LinearInverseInstrumentInfoV5 { - /** The ID of the symbol name. */ - symbolId: number; - symbol: string; - contractType: ContractTypeV5; - status: InstrumentStatusV5; - baseCoin: string; - quoteCoin: string; - /** Region / product class for the pair (`stock`, `forex`, `commodity`, `xstocks`, etc.). */ - symbolType: InstrumentSymbolTypeV5; - launchTime: string; - deliveryTime?: string; - deliveryFeeRate?: string; - priceScale: string; - leverageFilter: { - minLeverage: string; - maxLeverage: string; - leverageStep: string; - }; - priceFilter: { - minPrice: string; - maxPrice: string; - tickSize: string; - }; - lotSizeFilter: { - maxOrderQty: string; - maxMktOrderQty: string; - minOrderQty: string; - qtyStep: string; - postOnlyMaxOrderQty?: string; - minNotionalValue?: string; - }; - unifiedMarginTrade: boolean; - fundingInterval: number; - settleCoin: string; - copyTrading: CopyTradingV5; - upperFundingRate: string; - lowerFundingRate: string; - riskParameters: { - priceLimitRatioX: string; - priceLimitRatioY: string; - }; - isPreListing: boolean; - preListingInfo: { - curAuctionPhase: string; - phases: { - phase: string; - startTime: string; - endTime: string; - }[]; - auctionFeeInfo: { - auctionFeeRate: string; - takerFeeRate: string; - makerFeeRate: string; - }; - } | null; - skipCallAuction?: boolean; // For USDT pre-market contract - displayName: string; - fullName?: string; - marketRegion?: string; - underlyingTicker?: string; +/** GET /v5/earn/hold-to-earn/yield-history — Hold to Earn airdrop daily PnL (Earn permission) */ +export interface GetHoldToEarnAirdropYieldHistoryParamsV5 { + /** Unix seconds. Cannot be earlier than now minus 3 months */ + timeStart?: number; + /** Unix seconds. Requires timeStart ≤ timeEnd */ + timeEnd?: number; + /** Page size [1, 49] */ + limit: number; + /** Pagination cursor from previous `nextCursor` */ + cursor?: string; } ⋮---- -/** The ID of the symbol name. */ -⋮---- -/** Region / product class for the pair (`stock`, `forex`, `commodity`, `xstocks`, etc.). */ +/** Unix seconds. Cannot be earlier than now minus 3 months */ ⋮---- -skipCallAuction?: boolean; // For USDT pre-market contract +/** Unix seconds. Requires timeStart ≤ timeEnd */ ⋮---- -export interface OptionInstrumentInfoV5 { - /** The ID of the symbol name. */ - symbolId: number; - symbol: string; - optionsType: OptionTypeV5; - status: InstrumentStatusV5; - baseCoin: string; - quoteCoin: string; - settleCoin: string; - symbolType: InstrumentSymbolTypeV5; - launchTime: string; - deliveryTime: string; - deliveryFeeRate: string; - priceFilter: { - minPrice: string; - maxPrice: string; - tickSize: string; - }; - lotSizeFilter: { - maxOrderQty: string; - minOrderQty: string; - qtyStep: string; - }; - displayName: string; -} +/** Page size [1, 49] */ ⋮---- -/** The ID of the symbol name. */ +/** Pagination cursor from previous `nextCursor` */ + +================ +File: src/types/request/v5-user.ts +================ +import { PermissionsV5 } from '../shared-v5'; ⋮---- -export interface SpotInstrumentInfoV5 { - /** The ID of the symbol name. */ - symbolId: number; - symbol: string; - baseCoin: string; - quoteCoin: string; +export interface CreateSubMemberParamsV5 { + username: string; + password?: string; /** - * Xstock multiplier for `symbolType` = xstocks pairs. `stock_price = token_price / multiplier`, - * `stock_qty = token_qty * multiplier`. Default `"1"`. + * 1: normal, 6: custodial */ - xstockMultiplier?: string; - symbolType: InstrumentSymbolTypeV5; - innovation: '0' | '1'; // Deprecated, always 0 - status: InstrumentStatusV5; - marginTrading: MarginTradingV5; - stTag: '0' | '1'; - lotSizeFilter: { - basePrecision: string; - quotePrecision: string; - minOrderQty: string; - maxOrderQty: string; - minOrderAmt: string; - maxOrderAmt: string; - maxLimitOrderQty: string; - maxMarketOrderQty: string; - postOnlyMaxLimitOrderSize: string; - }; - priceFilter: { - tickSize: string; - }; - riskParameters: { - priceLimitRatioX: string; - priceLimitRatioY: string; - }; - forbidUplWithdrawal: boolean; + memberType: 1 | 6; + /** + * 0: quick login disabled (default), 1: quick login enabled + */ + switch?: 0 | 1; + isUta?: boolean; + note?: string; } ⋮---- -/** The ID of the symbol name. */ +/** + * 1: normal, 6: custodial + */ ⋮---- /** - * Xstock multiplier for `symbolType` = xstocks pairs. `stock_price = token_price / multiplier`, - * `stock_qty = token_qty * multiplier`. Default `"1"`. + * 0: quick login disabled (default), 1: quick login enabled */ ⋮---- -innovation: '0' | '1'; // Deprecated, always 0 +export interface CreateSubApiKeyParamsV5 { + subuid: number; + note?: string; + readOnly: 0 | 1; + ips?: string; + permissions: PermissionsV5; +} +⋮---- +export interface UpdateApiKeyParamsV5 { + apikey?: string; + readOnly?: 0 | 1; + permissions: PermissionsV5; +} +⋮---- +export interface UpdateSubApiKeyUpdateParamsV5 { + readOnly?: number; + ips?: string[]; + permissions: PermissionsV5; +} +⋮---- +export interface DeleteSubMemberParamsV5 { + subMemberId: string; +} +⋮---- +export interface GetSubAccountAllApiKeysParamsV5 { + subMemberId: string; + limit?: number; + cursor?: string; +} +⋮---- +export interface GetAffiliateUserListParamsV5 { + size?: number; + cursor?: string; + needDeposit?: boolean; + need30?: boolean; + need365?: boolean; + startDate?: string; + endDate?: string; +} +⋮---- +/** GET /v5/affiliate/affiliate-sub-list */ +export interface GetAffiliateSubAffiliateListParamsV5 { + cursor?: string; + /** [0, 100]. Default: 0 */ + size?: number; + /** YYYY-MM-DD. Range with endDate max 3 months */ + startDate?: string; + /** YYYY-MM-DD. Must be provided with startDate or both omitted (T-1 default) */ + endDate?: string; + /** Exact sub-affiliate ID. 0 or omit for all */ + subAffId?: number; +} +⋮---- +/** [0, 100]. Default: 0 */ ⋮---- -type InstrumentInfoV5Mapping = { - linear: LinearInverseInstrumentInfoV5[]; - inverse: LinearInverseInstrumentInfoV5[]; - option: OptionInstrumentInfoV5[]; - spot: SpotInstrumentInfoV5[]; -}; +/** YYYY-MM-DD. Range with endDate max 3 months */ ⋮---- -export type InstrumentInfoResponseV5 = - CategoryCursorListV5; +/** YYYY-MM-DD. Must be provided with startDate or both omitted (T-1 default) */ ⋮---- -// Account Instruments Info (includes RPI permissions) -export interface AccountSpotInstrumentInfoV5 extends SpotInstrumentInfoV5 { - isPublicRpi: boolean; - myRpiPermission: boolean; -} +/** Exact sub-affiliate ID. 0 or omit for all */ ⋮---- -export interface AccountLinearInverseInstrumentInfoV5 - extends LinearInverseInstrumentInfoV5 { - isPublicRpi: boolean; - myRpiPermission: boolean; +export interface GetAffiliateUserInfoParamsV5 { + /** The master account UID of affiliate's client */ + uid: string; + /** Coin type for filtering, e.g. USDT */ + coin?: string; + /** + * Business line filter. 1: Derivatives, 2: Spot, 3: ByFi, 4: USDC, 5: Options + */ + business?: '1' | '2' | '3' | '4' | '5'; } ⋮---- -type AccountInstrumentInfoV5Mapping = { - linear: AccountLinearInverseInstrumentInfoV5[]; - inverse: AccountLinearInverseInstrumentInfoV5[]; - spot: AccountSpotInstrumentInfoV5[]; -}; +/** The master account UID of affiliate's client */ ⋮---- -export type AccountInstrumentInfoResponseV5< - C extends 'spot' | 'linear' | 'inverse', -> = CategoryCursorListV5; +/** Coin type for filtering, e.g. USDT */ ⋮---- /** - * [price, size] - */ -export type OrderbookLevelV5 = [string, string]; + * Business line filter. 1: Derivatives, 2: Spot, 3: ByFi, 4: USDC, 5: Options + */ ⋮---- -export interface OrderbookResponseV5 { - s: string; - b: OrderbookLevelV5[]; - a: OrderbookLevelV5[]; - ts: number; - u: number; - seq: number; - cts: number; +/** Get Friend Referrals - invitation relationship status. 0: alive; 1: invalid */ +export interface GetFriendReferralsParamsV5 { + status?: string; + size?: string; + cursor?: string; } ⋮---- -/** - * RPI Orderbook level: [price, nonRpiSize, rpiSize] - */ -export type RPIOrderbookLevelV5 = [string, string, string]; -⋮---- -export interface RPIOrderbookResponseV5 { - s: string; // Symbol name - b: RPIOrderbookLevelV5[]; // Bids. Sorted by price in descending order - a: RPIOrderbookLevelV5[]; // Asks. Sorted by price in ascending order - ts: number; // The timestamp (ms) that the system generates the data - u: number; // Update ID, is always in sequence corresponds to u in the 50-level WebSocket RPI orderbook stream - seq: number; // Cross sequence - cts: number; // The timestamp from the matching engine when this orderbook data is produced +/** Sign Agreement. Only master account. + * - `category` (legacy): 2 = metals (XAU/XAG perps; stock perps share this); 3 = crude oil. New enum values are not added here; prefer `categoryV2`. + * - `categoryV2` (recommended): 1 = metals; 2 = crude oil. Additional values may be added by the API; use a numeric literal or variable. + * - Either `category` or `categoryV2` must be sent. */ +export interface SignAgreementParamsV5 { + agree: boolean; + category?: 2 | 3; + categoryV2?: number; } + +================ +File: examples/Rest/rest-v5-custom-url.ts +================ +import { RestClientV5 } from '../../src/index'; ⋮---- -s: string; // Symbol name -b: RPIOrderbookLevelV5[]; // Bids. Sorted by price in descending order -a: RPIOrderbookLevelV5[]; // Asks. Sorted by price in ascending order -ts: number; // The timestamp (ms) that the system generates the data -u: number; // Update ID, is always in sequence corresponds to u in the 50-level WebSocket RPI orderbook stream -seq: number; // Cross sequence -cts: number; // The timestamp from the matching engine when this orderbook data is produced +// or +// import { RestClientV5 } from 'bybit-api'; ⋮---- -export interface TickerLinearInverseV5 { - symbol: string; - lastPrice: string; - indexPrice: string; - markPrice: string; - prevPrice24h: string; - price24hPcnt: string; - highPrice24h: string; - lowPrice24h: string; - prevPrice1h: string; - openInterest: string; - openInterestValue: string; - singleOpenInterest?: string; - singleOpenInterestValue?: string; - turnover24h: string; - volume24h: string; - fundingRate: string; - nextFundingTime: string; - predictedDeliveryPrice: string; - basisRate: string; - basisRateYear: string; - fundingIntervalHour: string; - fundingCap: string; - deliveryFeeRate: string; - deliveryTime: string; - ask1Size: string; - bid1Price: string; - ask1Price: string; - bid1Size: string; - preOpenPrice: string; - preQty: string; - curPreListingPhase: string; - basis: string; -} +/** + * The first parameter of the REST client allows you to pass any configuration parameters supported by the SDK. + * + * These include API keys, if you wish to use private endpoints, but also expose other features such as + * setting a custom base URL (e.g. for Turkish users). + * + * Refer to the API documentation for a complete list of domains: https://bybit-exchange.github.io/docs/v5/guide#authentication + */ ⋮---- -export interface TickerOptionV5 { - symbol: string; - bid1Price: string; - bid1Size: string; - bid1Iv: string; - ask1Price: string; - ask1Size: string; - ask1Iv: string; - lastPrice: string; - highPrice24h: string; - lowPrice24h: string; - markPrice: string; - indexPrice: string; - markIv: string; - underlyingPrice: string; - openInterest: string; - turnover24h: string; - volume24h: string; - totalVolume: string; - totalTurnover: string; - delta: string; - gamma: string; - vega: string; - theta: string; - predictedDeliveryPrice: string; - change24h: string; +/** + * You can pass a completely custom base URL, + * e.g. if you're trying to use a domain that hasn't been added yet (please let us know) + */ +// baseUrl: 'https://api5.bybit.com', +// +// +/** + * + * Predefined API regions are available through the `apiRegion` property. + * Choose the region where your Bybit account is registered: + * + */ +// +// +// default: routes to api.bybit.com +// apiRegion: 'default', +// +// +// bytick: routes to api.bytick.com +// apiRegion: 'bytick', +// +// +// NL: Bybit removed api.bybit.nl from Integration Guidance on 2026-09-22. apiRegion no longer includes NL. +// +// +// TK: routes to api.bybit.tr (for Turkey users) +// apiRegion: 'TK', +// +// +// KZ: routes to api.bybit.kz (for Kazakhstan users) +// apiRegion: 'KZ', +// +// +// HK: routes to api.spark-fintech.com and adds x-refer-site-id: HKG +// Testnet routes to api-testnet.spark-fintech.com +// apiRegion: 'HK', +// +// +// GE: routes to api.bybitgeorgia.ge (for Georgia users) +// apiRegion: 'GE', +// +// +// UAE: routes to api.bybit.ae (for United Arab Emirates users) +// apiRegion: 'UAE', +// +// +// EU: routes to api.bybit.eu (for EU and EEA users) +// apiRegion: 'EU', +// +// +// ID: routes to api.bybit.id (for Indonesian users) +// apiRegion: 'ID', +// +// +// JP: routes to api.manepa.jp (for Japan users) +// Testnet routes to api-testnet.manepa.jp +// apiRegion: 'JP', +// +// +/** + * Brazil and Argentina international accounts use the global API domain + * with an x-site-id header. Choose the site ID for your account: + */ +// siteId: 'BRA_BTL', +// siteId: 'ARG_BTL', + +================ +File: src/types/request/v5-asset.ts +================ +import { AccountTypeV5, CategoryV5 } from '../shared-v5'; +⋮---- +export interface GetCoinExchangeRecordParamsV5 { + fromCoin?: string; + toCoin?: string; + limit?: number; + cursor?: string; } ⋮---- -export interface TickerSpotV5 { - symbol: string; - bid1Price: string; - bid1Size: string; - ask1Price: string; - ask1Size: string; - lastPrice: string; - prevPrice24h: string; - price24hPcnt: string; - highPrice24h: string; - lowPrice24h: string; - turnover24h: string; - volume24h: string; - usdIndexPrice: string; +export interface GetDeliveryRecordParamsV5 { + category: CategoryV5; + symbol?: string; + startTime?: number; + endTime?: number; + expDate?: string; + limit?: number; + cursor?: string; } ⋮---- -export interface FundingRateHistoryResponseV5 { - symbol: string; - fundingRate: string; - fundingRateTimestamp: string; +export interface GetSettlementRecordParamsV5 { + category: CategoryV5; + symbol?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; } ⋮---- -export interface PublicTradeV5 { - execId: string; - symbol: string; - price: string; - size: string; - side: OrderSideV5; - time: string; - isBlockTrade: boolean; - isRPITrade: boolean; - mP?: string; - iP?: string; - mIv?: string; - iv?: string; - seq?: string; +export interface GetAssetInfoParamsV5 { + accountType: AccountTypeV5; + coin?: string; } ⋮---- -/** - * - * - openInterest string Open interest - * - timestamp string The timestamp (ms) - */ -export type OpenInterestV5 = { - openInterest: string; - singleOpenInterest?: string; - timestamp: string; -}; +export interface GetAllCoinsBalanceParamsV5 { + memberId?: string; + accountType: AccountTypeV5; + coin?: string; + withBonus?: number; +} ⋮---- -export interface OpenInterestResponseV5 { - category: 'linear' | 'inverse'; - symbol: string; - list: OpenInterestV5[]; - nextPageCursor?: string; +export interface GetAccountCoinBalanceParamsV5 { + memberId?: string; + toMemberId?: string; + accountType: AccountTypeV5; + coin: string; + toAccountType?: AccountTypeV5; + withBonus?: number; + withTransferSafeAmount?: 0 | 1; + withLtvTransferSafeAmount?: 0 | 1; } ⋮---- -export interface HistoricalVolatilityV5 { - period: number; - value: string; - time: string; +export interface GetInternalTransferParamsV5 { + transferId?: string; + coin?: string; + status?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; } ⋮---- -export interface InsuranceDataV5 { +export interface UniversalTransferParamsV5 { + transferId: string; coin: string; - symbols: string; - balance: string; - value: string; + amount: string; + fromMemberId: number; + toMemberId: number; + fromAccountType: AccountTypeV5; + toAccountType: AccountTypeV5; } ⋮---- -export interface InsuranceResponseV5 { - updatedTime: string; - list: InsuranceDataV5[]; +export interface GetUniversalTransferRecordsParamsV5 { + transferId?: string; + coin?: string; + status?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; + fromMemberId?: string; + toMemberId?: string; } ⋮---- -export interface RiskLimitV5 { - id: number; - symbol: string; - riskLimitValue: string; - maintenanceMargin: number; - initialMargin: number; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - section: any; - isLowestRisk: 0 | 1; - maxLeverage: string; - mmDeduction: string; - nextPageCursor?: string; +export interface GetAllowedDepositCoinInfoParamsV5 { + coin?: string; + chain?: string; + limit?: number; + cursor?: string; } ⋮---- -// eslint-disable-next-line @typescript-eslint/no-explicit-any +export interface GetDepositRecordParamsV5 { + id?: string; + txID?: string; + coin?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; +} ⋮---- -/** @deprecated use DeliveryPriceV5 instead */ -export interface OptionDeliveryPriceV5 { - symbol: string; - deliveryPrice: string; - deliveryTime: string; +export interface GetSubAccountDepositRecordParamsV5 { + id?: string; + txID?: string; + subMemberId: string; + coin?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; } ⋮---- -export interface DeliveryPriceV5 { - symbol: string; - deliveryPrice: string; - deliveryTime: string; +export interface GetInternalDepositRecordParamsV5 { + txID?: string; + startTime?: number; + endTime?: number; + coin?: string; + cursor?: string; + limit?: number; } ⋮---- -export interface LongShortRatioV5 { - symbol: string; - buyRatio: string; - sellRatio: string; - timestamp: string; +export interface GetWithdrawalRecordsParamsV5 { + withdrawID?: string; + txID?: string; + coin?: string; + withdrawType?: number; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; } ⋮---- -export interface OrderPriceLimitV5 { - symbol: string; - buyLmt: string; - sellLmt: string; - ts: string; +export interface GetWithdrawalAddressListParamsV5 { + coin?: string; + chain?: string; + addressType?: 0 | 1 | 2; + limit?: number; + cursor?: string; } ⋮---- -export interface IndexPriceComponentV5 { - exchange: string; // Name of the exchange - spotPair: string; // Spot trading pair on the exchange (e.g., BTCUSDT) - equivalentPrice: string; // Equivalent price - multiplier: string; // Multiplier used for the component price - price: string; // Actual price - weight: string; // Weight in the index calculation +export interface SubmitDepositOriginatorInfoParamsV5 { + depositId: number; + subAccountId?: number; + /** Travel Rule questionnaire JSON string. See Questionnaire docs. */ + questionnaire: string; +} +⋮---- +/** Travel Rule questionnaire JSON string. See Questionnaire docs. */ +⋮---- +export interface WithdrawParamsV5 { + coin: string; + /** + * When forceChain is 0 or 1, required. When forceChain is 2 (Bybit UID withdraw), may be null/omitted. + */ + chain?: string; + address: string; + tag?: string; + amount: string; + timestamp: number; + forceChain?: number; + /** + * FUND, UTA, or EARN; or comma combo e.g. FUND,UTA,EARN (funding first, then UTA and Earn for remainder). + * SPOT is legacy if still supported for older integrations. + */ + accountType: string; + feeType?: 0 | 1; + requestId?: string; + /** + * Required for Bybit Turkey (TR) site users when creating a withdrawal. Omitted for other regions unless the API requires it. + */ + transactionPurpose?: string; + /** + * Travel Rule questionnaire JSON string (max 16384 bytes). Takes precedence over `beneficiary` / `transactionPurpose` when both are set. + */ + questionnaire?: string; + beneficiary?: { + vaspEntityId?: string; + beneficiaryName?: string; + beneficiaryLegalType?: string; + beneficiaryWalletType?: string; + beneficiaryUnhostedWalletType?: string; + beneficiaryPoiNumber?: string; + beneficiaryPoiType?: string; + beneficiaryPoiIssuingCountry?: string; + beneficiaryPoiExpiredDate?: string; + }; +} +⋮---- +/** + * When forceChain is 0 or 1, required. When forceChain is 2 (Bybit UID withdraw), may be null/omitted. + */ +⋮---- +/** + * FUND, UTA, or EARN; or comma combo e.g. FUND,UTA,EARN (funding first, then UTA and Earn for remainder). + * SPOT is legacy if still supported for older integrations. + */ +⋮---- +/** + * Required for Bybit Turkey (TR) site users when creating a withdrawal. Omitted for other regions unless the API requires it. + */ +⋮---- +/** + * Travel Rule questionnaire JSON string (max 16384 bytes). Takes precedence over `beneficiary` / `transactionPurpose` when both are set. + */ +⋮---- +export interface ConvertCoinsParamsV5 { + coin?: string; + side?: number; + accountType: + | 'eb_convert_funding' + | 'eb_convert_uta' + | 'eb_convert_spot' + | 'eb_convert_contract' + | 'eb_convert_inverse'; } ⋮---- -exchange: string; // Name of the exchange -spotPair: string; // Spot trading pair on the exchange (e.g., BTCUSDT) -equivalentPrice: string; // Equivalent price -multiplier: string; // Multiplier used for the component price -price: string; // Actual price -weight: string; // Weight in the index calculation -⋮---- -export interface IndexPriceComponentsResponseV5 { - indexName: string; // Name of the index (e.g., BTCUSDT) - lastPrice: string; // Last price of the index - updateTime: string; // Timestamp of the last update in milliseconds - components: IndexPriceComponentV5[]; // List of components contributing to the index price +export interface RequestConvertQuoteParamsV5 { + fromCoin: string; + toCoin: string; + fromCoinType?: string; + toCoinType?: string; + requestCoin: string; + requestAmount: string; + accountType: + | 'eb_convert_funding' + | 'eb_convert_uta' + | 'eb_convert_spot' + | 'eb_convert_contract' + | 'eb_convert_inverse'; + requestId?: string; } ⋮---- -indexName: string; // Name of the index (e.g., BTCUSDT) -lastPrice: string; // Last price of the index -updateTime: string; // Timestamp of the last update in milliseconds -components: IndexPriceComponentV5[]; // List of components contributing to the index price +export interface GetConvertHistoryParamsV5 { + accountType?: string; + index?: number; + limit?: number; +} ⋮---- -export interface ADLAlertItemV5 { - coin: string; // Token of the insurance pool - symbol: string; // Trading pair name - balance: string; // Balance of the insurance fund. Used to determine if ADL is triggered - maxBalance: string; // Maximum balance of the insurance pool in the last 8 hours - insurancePnlRatio: string; // PnL ratio threshold for triggering contract PnL drawdown ADL - pnlRatio: string; // Symbol's PnL drawdown ratio in the last 8 hours. Used to determine whether ADL is triggered or stopped - adlTriggerThreshold: string; // Trigger threshold for contract PnL drawdown ADL - adlStopRatio: string; // Stop ratio threshold for contract PnL drawdown ADL +export interface GetSmallBalanceListParamsV5 { + accountType: 'eb_convert_uta'; // Wallet type, only supports Unified wallet + fromCoin?: string; // Source currency } ⋮---- -coin: string; // Token of the insurance pool -symbol: string; // Trading pair name -balance: string; // Balance of the insurance fund. Used to determine if ADL is triggered -maxBalance: string; // Maximum balance of the insurance pool in the last 8 hours -insurancePnlRatio: string; // PnL ratio threshold for triggering contract PnL drawdown ADL -pnlRatio: string; // Symbol's PnL drawdown ratio in the last 8 hours. Used to determine whether ADL is triggered or stopped -adlTriggerThreshold: string; // Trigger threshold for contract PnL drawdown ADL -adlStopRatio: string; // Stop ratio threshold for contract PnL drawdown ADL +accountType: 'eb_convert_uta'; // Wallet type, only supports Unified wallet +fromCoin?: string; // Source currency ⋮---- -export interface ADLAlertResponseV5 { - updateTime: string; // Latest data update timestamp (ms) - list: ADLAlertItemV5[]; // List of ADL alert items +export interface GetFiatTradingPairListParamsV5 { + side?: 0 | 1; // 0: buy (buy crypto, sell fiat), 1: sell (sell crypto, buy fiat) } ⋮---- -updateTime: string; // Latest data update timestamp (ms) -list: ADLAlertItemV5[]; // List of ADL alert items +side?: 0 | 1; // 0: buy (buy crypto, sell fiat), 1: sell (sell crypto, buy fiat) ⋮---- -export interface FeeGroupLevelV5 { - level: string; // Pro level name or Market Maker level name - takerFeeRate: string; // Taker fee rate - makerFeeRate: string; // Maker fee rate - makerRebate: string; // Maker rebate fee rate - rpiMakerRebate?: string; +/** Funding Account Transaction History. Interval createTimeFrom-createTimeTo max 7 days. */ +export interface GetFundingAccountTransactionHistoryParamsV5 { + createTimeFrom?: string; + createTimeTo?: string; + limit?: string; + cursor?: string; } ⋮---- -level: string; // Pro level name or Market Maker level name -takerFeeRate: string; // Taker fee rate -makerFeeRate: string; // Maker fee rate -makerRebate: string; // Maker rebate fee rate -⋮---- -export interface FeeGroupRatesV5 { - pro: FeeGroupLevelV5[]; // Pro-level fee structures - marketMaker: FeeGroupLevelV5[]; // Market Maker-level fee structures +/** Asset Overview. memberId required when querying sub account via master API key. */ +export interface GetAssetOverviewParamsV5 { + memberId?: string; + /** Fiat currency for valuation; defaults to USD if omitted. */ + valuationCurrency?: string; + /** Account type filter; returns all if omitted. */ + accountType?: string; } ⋮---- -pro: FeeGroupLevelV5[]; // Pro-level fee structures -marketMaker: FeeGroupLevelV5[]; // Market Maker-level fee structures +/** Fiat currency for valuation; defaults to USD if omitted. */ ⋮---- -export interface FeeGroupItemV5 { - groupName: string; // Fee group name - weightingFactor: number; // Group weighting factor - symbolsNumbers: number; // Symbols number - symbols: string[]; // Symbol names - feeRates: FeeGroupRatesV5; // Fee rate details for different categories - updateTime: string; // Latest data update timestamp (ms) -} +/** Account type filter; returns all if omitted. */ ⋮---- -groupName: string; // Fee group name -weightingFactor: number; // Group weighting factor -symbolsNumbers: number; // Symbols number -symbols: string[]; // Symbol names -feeRates: FeeGroupRatesV5; // Fee rate details for different categories -updateTime: string; // Latest data update timestamp (ms) +/** GET /v5/asset/portfolio-margin */ +export interface GetPortfolioMarginInfoParamsV5 { + baseCoin?: string; +} ⋮---- -export interface FeeGroupStructureResponseV5 { - list: FeeGroupItemV5[]; // List of fee group objects +/** GET /v5/asset/total-members-assets */ +export interface GetTotalMembersAssetsParamsV5 { + /** If omitted, defaults to BTC. Total is quoted in this coin. */ + coin?: string; } ⋮---- -list: FeeGroupItemV5[]; // List of fee group objects +/** If omitted, defaults to BTC. Total is quoted in this coin. */ ================ -File: src/types/response/v5-position.ts +File: src/types/request/v5-market.ts ================ +import { KlineIntervalV3 } from '../shared'; import { CategoryV5, - ExecTypeV5, - OrderSideV5, - OrderTypeV5, - PositionIdx, - PositionSideV5, - PositionStatusV5, - StopOrderTypeV5, - TPSLModeV5, - TradeModeV5, + InstrumentStatusV5, + InstrumentSymbolTypeV5, + OptionTypeV5, } from '../shared-v5'; ⋮---- -export interface FuturesLeverageItemV5 { +export interface GetKlineParamsV5 { + category: 'spot' | 'linear' | 'inverse'; symbol: string; - leverage: string; - side: OrderSideV5 | ''; - positionIdx: PositionIdx; + interval: KlineIntervalV3; + start?: number; + end?: number; + limit?: number; } ⋮---- -export interface FuturesLeverageResultV5 { +export interface GetMarkPriceKlineParamsV5 { + /** + * linear (default if omitted), inverse, or option. + */ + category?: 'linear' | 'inverse' | 'option'; + symbol: string; + interval: KlineIntervalV3; + start?: number; + end?: number; + /** + * Futures: [1, 1000], default 200. Options: [1, 500], default 200. + */ + limit?: number; +} +⋮---- +/** + * linear (default if omitted), inverse, or option. + */ +⋮---- +/** + * Futures: [1, 1000], default 200. Options: [1, 500], default 200. + */ +⋮---- +export interface GetIndexPriceKlineParamsV5 { category: 'linear' | 'inverse'; - list: FuturesLeverageItemV5[]; + symbol: string; + interval: KlineIntervalV3; + start?: number; + end?: number; + limit?: number; } ⋮---- -export interface PositionV5 { - positionIdx: PositionIdx; - riskId: number; - riskLimitValue: string; +export interface GetPremiumIndexPriceKlineParamsV5 { + category: 'linear'; symbol: string; - side: PositionSideV5; - size: string; - avgPrice: string; - positionValue: string; - tradeMode: TradeModeV5; - autoAddMargin?: number; - positionStatus: PositionStatusV5; - leverage?: string; - breakEvenPrice?: string; // Break even price, only for linear & inverse - markPrice: string; - liqPrice: string | ''; - bustPrice?: string; - positionIM?: string; - positionMM?: string; - positionBalance?: string; - tpslMode?: TPSLModeV5; - takeProfit?: string; - stopLoss?: string; - trailingStop?: string; - sessionAvgPrice: string | ''; - delta?: string; - gamma?: string; - vega?: string; - theta?: string; - unrealisedPnl: string; - curRealisedPnl: string; - cumRealisedPnl: string; - adlRankIndicator: number; - isReduceOnly: boolean; - mmrSysUpdatedTime: string | ''; - leverageSysUpdatedTime: string | ''; - createdTime: string; - updatedTime: string; - /** Position open timestamp (ms). Default `0` when not set. */ - openTime: number; - positionIMByMp: string; - positionMMByMp: string; - seq: number; - netDeltaRatio?: string; + interval: KlineIntervalV3; + start?: number; + end?: number; + limit?: number; +} +⋮---- +export interface GetInstrumentsInfoParamsV5 { + category: CategoryV5; + symbol?: string; + /** Filter by instrument `symbolType` (e.g. `commodity`, `stock`, `forex` for linear). */ + symbolType?: InstrumentSymbolTypeV5; + status?: InstrumentStatusV5; + /** For `category=option`, pass `All` to return all option symbols. */ + baseCoin?: string; + limit?: number; + cursor?: string; +} +⋮---- +/** Filter by instrument `symbolType` (e.g. `commodity`, `stock`, `forex` for linear). */ +⋮---- +/** For `category=option`, pass `All` to return all option symbols. */ +⋮---- +export interface GetOrderbookParamsV5 { + category: CategoryV5; + symbol: string; + limit?: number; +} +⋮---- +export interface GetRPIOrderbookParamsV5 { + category?: 'spot' | 'linear' | 'inverse'; + symbol: string; + limit: number; // Required for RPI orderbook, [1, 50] +} +⋮---- +limit: number; // Required for RPI orderbook, [1, 50] +⋮---- +export interface GetIndexPriceComponentsParamsV5 { + indexName: string; // Index name, like BTCUSDT } ⋮---- -breakEvenPrice?: string; // Break even price, only for linear & inverse +indexName: string; // Index name, like BTCUSDT ⋮---- -/** Position open timestamp (ms). Default `0` when not set. */ +export interface GetADLAlertParamsV5 { + symbol?: string; // Contract name, e.g. BTCUSDT. Uppercase only +} ⋮---- -export interface SetRiskLimitResultV5 { - category: CategoryV5; - riskId: number; - riskLimitValue: string; +symbol?: string; // Contract name, e.g. BTCUSDT. Uppercase only +⋮---- +export interface GetFeeGroupStructureParamsV5 { + productType: string; // Product type. contract only for now + groupId?: string; // Group ID. 1, 2, 3, 4, 5, 6, 7 } ⋮---- -export interface AddOrReduceMarginResultV5 { - category: CategoryV5; +productType: string; // Product type. contract only for now +groupId?: string; // Group ID. 1, 2, 3, 4, 5, 6, 7 +⋮---- +export interface GetTickersParamsV5 { + category: TCategory; + symbol?: string; + baseCoin?: string; + expDate?: string; +} +⋮---- +export interface GetFundingRateHistoryParamsV5 { + category: 'linear' | 'inverse'; symbol: string; - positionIdx: PositionIdx; - riskId: number; - riskLimitValue: string; - size: string; - avgPrice: string; - liqPrice: string; - bustPrice: string; - markPrice: string; - positionValue: string; - leverage: string; - autoAddMargin: 0 | 1; - positionStatus: PositionStatusV5; - positionIM: string; - positionMM: string; - takeProfit: string; - stopLoss: string; - trailingStop: string; - unrealisedPnl: string; - cumRealisedPnl: string; - createdTime: string; - updatedTime: string; + startTime?: number; + endTime?: number; + limit?: number; } ⋮---- -export interface ExecutionV5 { +export interface GetPublicTradingHistoryParamsV5 { + category: CategoryV5; symbol: string; - orderId: string; - orderLinkId: string; - side: OrderSideV5; - orderPrice: string; - orderQty: string; - leavesQty: string; - orderType: OrderTypeV5; - stopOrderType?: StopOrderTypeV5; - execFee: string; - execFeeV2: string; - feeCurrency: string; // Trading fee currency - execId: string; - execPrice: string; - execQty: string; - execType: ExecTypeV5; - execValue: string; - execTime: string; - isMaker: boolean; - feeRate: string; - tradeIv?: string; - markIv?: string; - markPrice: string; - indexPrice: string; - underlyingPrice?: string; - blockTradeId?: string; - closedSize?: string; - seq: number; - extraFees: string; + baseCoin?: string; + optionType?: OptionTypeV5; + limit?: number; } ⋮---- -feeCurrency: string; // Trading fee currency +export type OpenInterestIntervalV5 = + | '5min' + | '15min' + | '30min' + | '1h' + | '4h' + | '1d'; ⋮---- -export interface ClosedPnLV5 { +export interface GetOpenInterestParamsV5 { + category: 'linear' | 'inverse'; symbol: string; - orderId: string; - side: string; - qty: string; - orderPrice: string; - orderType: OrderTypeV5; - execType: ExecTypeV5; - closedSize: string; - openFee: string; - closeFee: string; - cumEntryValue: string; - avgEntryPrice: string; - cumExitValue: string; - avgExitPrice: string; - closedPnl: string; - fillCount: string; - leverage: string; - createdTime: string; - updatedTime: string; + intervalTime: OpenInterestIntervalV5; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; } ⋮---- -export interface MovePositionResultV5 { - blockTradeId: string; - status: 'Processing' | 'Rejected'; - rejectParty: '' | 'Taker' | 'Maker' | 'bybit'; +export interface GetHistoricalVolatilityParamsV5 { + category: 'option'; + baseCoin?: string; + period?: 7 | 14 | 21 | 30 | 60 | 90 | 180 | 270; + startTime?: number; + endTime?: number; } ⋮---- -export interface MovePositionHistoryV5 { - blockTradeId: string; - category: 'linear' | 'spot' | 'option'; - orderId: string; - userId: number; +export interface GetInsuranceParamsV5 { + coin?: string; +} +⋮---- +export interface GetRiskLimitParamsV5 { + category?: 'linear' | 'inverse'; + symbol?: string; + cursor?: string; +} +⋮---- +export interface GetOptionDeliveryPriceParamsV5 { + category: 'option'; + symbol?: string; + baseCoin?: string; + limit?: number; + cursor?: string; +} +⋮---- +export interface GetDeliveryPriceParamsV5 { + category: 'linear' | 'inverse' | 'option'; + symbol?: string; + baseCoin?: string; + settleCoin?: string; + limit?: number; + cursor?: string; +} +⋮---- +export interface GetLongShortRatioParamsV5 { + category: 'linear' | 'inverse'; symbol: string; - side: 'Buy' | 'Sell'; - price: string; - qty: string; - execFee: string; - status: 'Processing' | 'Filled' | 'Rejected'; - execId: string; - resultCode: number; - resultMessage: string; - createdAt: number; - updatedAt: number; - rejectParty: '' | 'Taker' | 'Maker' | 'bybit'; + period: OpenInterestIntervalV5; + startTime?: string; + endTime?: string; + limit?: number; + cursor?: string; } ⋮---- -export interface ClosedOptionsPositionV5 { +export interface GetFullDepthOrderbookParamsV5 { + category: 'spot' | 'linear' | 'inverse'; symbol: string; - side: 'Buy' | 'Sell'; - totalOpenFee: string; - deliveryFee: string; - totalCloseFee: string; - qty: string; - closeTime: number; - avgExitPrice: string; - deliveryPrice: string; - openTime: number; - avgEntryPrice: string; - totalPnl: string; } +⋮---- +export interface GetOptionBaseCoinsParamsV5 { + /** + * Comma-separated underlying types. + * 0 crypto, 1 commodity, 2 stock, 3 forex, 4 oil. Omit to return all types. + */ + underlyingType?: string; +} +⋮---- +/** + * Comma-separated underlying types. + * 0 crypto, 1 commodity, 2 stock, 3 forex, 4 oil. Omit to return all types. + */ ================ -File: src/types/shared-v5.ts +File: src/types/response/v5-account.ts ================ -export type CategoryV5 = 'spot' | 'linear' | 'inverse' | 'option'; -export type ContractTypeV5 = - | 'InversePerpetual' - | 'LinearPerpetual' - | 'InverseFutures'; -export type CopyTradingV5 = 'none' | 'both' | 'utaOnly' | 'normalOnly'; -⋮---- -export type InstrumentStatusV5 = - | 'PreLaunch' - | 'PendingOpen' - | 'Trading' - | 'Settling' - | 'Delivering' - | 'Closed'; +import { + AccountMarginModeV5, + AccountTypeV5, + CategoryV5, + TransactionTypeV5, + UnifiedUpdateStatusV5, +} from '../shared-v5'; ⋮---- -/** - * Region / product class returned as `symbolType` on instruments-info (and account instruments-info). - * For `category=linear`, includes e.g. `stock`, `forex`, `commodity`, `xstocks`. Spot may return `''`. - */ -export type InstrumentSymbolTypeV5 = - | '' - | 'stock' - | 'forex' - | 'commodity' - | 'xstocks'; +export interface WalletBalanceV5Coin { + coin: string; + equity: string; + usdValue: string; + walletBalance: string; + free: string; // spot only + locked: string; // spot only + borrowAmount: string; + availableToBorrow: string; // deprecated field + availableToWithdraw: string; + accruedInterest: string; + totalOrderIM: string; + totalPositionIM: string; + totalPositionMM: string; + unrealisedPnl: string; + cumRealisedPnl: string; + bonus: string; + marginCollateral: boolean; + collateralSwitch: boolean; + spotBorrow: string; + colRes?: string; +} ⋮---- -export type MarginTradingV5 = 'none' | 'both' | 'utaOnly' | 'normalSpotOnly'; +free: string; // spot only +locked: string; // spot only ⋮---- -/** Product type for strategy APIs (create / list). */ -export type StrategyCategoryV5 = - | 'UTA_USDT' - | 'UTA_USDC' - | 'UTA_USDC_FUTURE' - | 'UTA_SPOT' - | 'UTA_INVERSE' - | 'UTA_INVERSE_FUTURE' - | 'UTA_USDT_FUTURE'; +availableToBorrow: string; // deprecated field ⋮---- -export type StrategyTypeV5 = 'twap' | 'chaseOrder' | 'iceberg' | 'pov'; +export interface WalletBalanceV5 { + accountType: AccountTypeV5; + accountLTV: string; + accountIMRate: string; + accountMMRate: string; + accountIMRateByMp: string; + accountMMRateByMp: string; + totalInitialMarginByMp: string; + totalMaintenanceMarginByMp: string; + totalEquity: string; + totalWalletBalance: string; + totalMarginBalance: string; + totalAvailableBalance: string; + totalPerpUPL: string; + totalInitialMargin: string; + totalMaintenanceMargin: string; + coin: WalletBalanceV5Coin[]; +} ⋮---- -export type StrategyPreferV5 = - | 'limit' - | 'priceSpeedBalance' - | 'fastestExecution' - | 'quickExecution'; +export interface UnifiedAccountUpgradeResultV5 { + unifiedUpdateStatus: UnifiedUpdateStatusV5; + unifiedUpdateMsg: { + msg: string[] | null; + }; +} ⋮---- -/** POV strategy execution mode */ -export type PovModeV5 = - | 'TradedVolume' - | 'OppositeSideLiquidity' - | 'SameSideLiquidity'; +export interface BorrowHistoryRecordV5 { + currency: string; + createdTime: number; + borrowCost: string; + hourlyBorrowRate: string; + InterestBearingBorrowSize: string; + costExemption: string; + borrowAmount: string; + unrealisedLoss: string; + freeBorrowedAmount: string; +} ⋮---- -export type OrderFilterV5 = 'Order' | 'tpslOrder' | 'StopOrder'; -export type OrderSideV5 = 'Buy' | 'Sell'; -export type OrderTypeV5 = 'Market' | 'Limit'; -export type OrderTimeInForceV5 = 'GTC' | 'IOC' | 'FOK' | 'PostOnly' | 'RPI'; -export type OrderTriggerByV5 = 'LastPrice' | 'IndexPrice' | 'MarkPrice'; -export type OCOTriggerTypeV5 = - | 'OcoTriggerByUnknown' - | 'OcoTriggerTp' - | 'OcoTriggerBySl'; +export interface CollateralInfoV5 { + currency: string; + hourlyBorrowRate: string; + maxBorrowingAmount: string; + freeBorrowAmount: string; + freeBorrowingLimit: string; + borrowAmount: string; + availableToBorrow: string; + borrowable: boolean; + borrowUsageRate: string; + marginCollateral: boolean; + collateralSwitch: boolean; + collateralRatio: string; +} ⋮---- -export type OrderSMPTypeV5 = - | 'None' - | 'CancelMaker' - | 'CancelTaker' - | 'CancelBoth'; +export interface CoinGreeksV5 { + baseCoin: string; + totalDelta: string; + totalGamma: string; + totalVega: string; + totalTheta: string; +} ⋮---- -export type OrderStatusV5 = - | 'Created' - | 'New' - | 'Rejected' - | 'PartiallyFilled' - | 'PartiallyFilledCanceled' - | 'Filled' - | 'Cancelled' - | 'Untriggered' - | 'Triggered' - | 'Deactivated' - | 'Active'; +export interface FeeRateV5 { + symbol: string; + baseCoin: string; + takerFeeRate: string; + makerFeeRate: string; + rpiMakerFeeRate?: string; +} +⋮---- +export interface AccountInfoV5 { + unifiedMarginStatus: number; + marginMode: AccountMarginModeV5; + isMasterTrader: boolean; + spotHedgingStatus: string; + updatedTime: string; +} ⋮---- /** - * Defines the types of order creation mechanisms. + * Get Trade Behaviour Config / `getLimitPriceAction()` — `/v5/account/user-setting-config` */ -export type OrderCreateTypeV5 = - /** Represents an order created by a user. */ - | 'CreateByUser' - /** Represents an order created by an admin closing. */ - | 'CreateByAdminClosing' - /** Futures conditional order. */ - | 'CreateByStopOrder' - /** Futures take profit order. */ - | 'CreateByTakeProfit' - /** Futures partial take profit order. */ - | 'CreateByPartialTakeProfit' - /** Futures stop loss order. */ - | 'CreateByStopLoss' - /** Futures partial stop loss order. */ - | 'CreateByPartialStopLoss' - /** Futures trailing stop order. */ - | 'CreateByTrailingStop' - /** Laddered liquidation to reduce the required maintenance margin. */ - | 'CreateByLiq' - /** - * If the position is still subject to liquidation (i.e., does not meet the required maintenance margin level), - * the position shall be taken over by the liquidation engine and closed at the bankruptcy price. - */ - | 'CreateByTakeOver_PassThrough' - /** Auto-Deleveraging(ADL) */ - | 'CreateByAdl_PassThrough' - /** Order placed via Paradigm. */ - | 'CreateByBlock_PassThrough' - /** Order created by move position. */ - | 'CreateByBlockTradeMovePosition_PassThrough' - /** The close order placed via web or app position area - web/app. */ - | 'CreateByClosing' - /** Order created via grid bot - web/app. */ - | 'CreateByFGridBot' - /** Order closed via grid bot - web/app. */ - | 'CloseByFGridBot' - /** Order created by TWAP - web/app. */ - | 'CreateByTWAP' - /** Order created by TV webhook - web/app. */ - | 'CreateByTVSignal' - /** Order created by Mm rate close function - web/app. */ - | 'CreateByMmRateClose' - /** Order created by Martingale bot - web/app. */ - | 'CreateByMartingaleBot' - /** Order closed by Martingale bot - web/app. */ - | 'CloseByMartingaleBot' - /** Order created by Ice berg strategy - web/app. */ - | 'CreateByIceBerg' - /** Order created by arbitrage - web/app. */ - | 'CreateByArbitrage' - /** Option dynamic delta hedge order - web/app */ - | 'CreateByDdh' - /** BBO Order - Best Bid/Offer order */ - | 'CreateByBboOrder'; +export interface UserSettingConfigV5 { + lpaSpot: boolean; + lpaPerp: boolean; + /** Spot MNT fee deduction enabled. */ + smsef?: boolean; + /** Futures MNT fee deduction enabled. */ + fmsef?: boolean; + /** Delta Neutral mode; may be absent on older API responses. */ + deltaEnable?: boolean; + smpType?: '0' | '1' | '2' | '3' | string; +} ⋮---- -/** Represents an order created by a user. */ +/** Spot MNT fee deduction enabled. */ ⋮---- -/** Represents an order created by an admin closing. */ +/** Futures MNT fee deduction enabled. */ ⋮---- -/** Futures conditional order. */ +/** Delta Neutral mode; may be absent on older API responses. */ ⋮---- -/** Futures take profit order. */ +export interface TransactionLogV5 { + symbol: string; + category: CategoryV5; + side: string; + transactionTime: string; + type: TransactionTypeV5; + qty: string; + size: string; + currency: string; + tradePrice: string; + funding: string; + fee: string; + cashFlow: string; + change: string; + cashBalance: string; + feeRate: string; + bonusChange: string; + tradeId: string; + orderId: string; + orderLinkId: string; + extraFees: string; + transSubType: string; + displayType?: string; +} ⋮---- -/** Futures partial take profit order. */ +export interface MMPStateV5 { + baseCoin: string; + mmpEnabled: boolean; + window: string; + frozenPeriod: string; + qtyLimit: string; + deltaLimit: string; + vegaLimit?: string; + mmpFrozenUntil: string; + mmpFrozen: boolean; +} ⋮---- -/** Futures stop loss order. */ +export interface RepayLiabilityResultV5 { + coin: string; + repaymentQty: string; +} ⋮---- -/** Futures partial stop loss order. */ +export interface DCPInfoV5 { + product: 'SPOT' | 'DERIVATIVES' | 'OPTIONS'; + dcpStatus: 'ON'; + timeWindow: string; +} ⋮---- -/** Futures trailing stop order. */ +export interface ManualRepayResultV5 { + resultStatus: 'P' | 'SU' | 'FA'; +} ⋮---- -/** Laddered liquidation to reduce the required maintenance margin. */ +/** GET /v5/account/option-asset-info — response `result` wraps a nested `result` array. */ +export interface OptionAssetInfoRowV5 { + coin: string; + totalDelta: string; + totalRPL: string; + totalUPL: string; + assetIM: string; + assetMM: string; + sendTime: number; +} ⋮---- -/** - * If the position is still subject to liquidation (i.e., does not meet the required maintenance margin level), - * the position shall be taken over by the liquidation engine and closed at the bankruptcy price. - */ +export interface OptionAssetInfoNestedResultV5 { + result: OptionAssetInfoRowV5[]; +} ⋮---- -/** Auto-Deleveraging(ADL) */ +/** GET /v5/account/pay-info */ +export interface PayInfoCollateralItemV5 { + coin: string; + availableSize: string; + availableValue: string; + coinScale: number; + borrowSize: string; + spotHedgeAmount: string; + assetFrozen: string; +} ⋮---- -/** Order placed via Paradigm. */ +export interface PayInfoBorrowBlockV5 { + coin?: string; + borrowSize: string; + borrowValue?: string; + assetFrozen: string; + availableBalance: string; +} ⋮---- -/** Order created by move position. */ +export interface PayInfoResultV5 { + collateralInfo: { + collateralList: PayInfoCollateralItemV5[]; + }; + borrowInfo: PayInfoBorrowBlockV5; +} ⋮---- -/** The close order placed via web or app position area - web/app. */ +/** GET /v5/account/trade-info-for-analysis */ +export interface TradeInfoAnalysisDailyV5 { + day: string; + sumBuyExecValue: string; + sumSellExecValue: string; + sumExecValue: string; +} ⋮---- -/** Order created via grid bot - web/app. */ +export interface TradeInfoForAnalysisResultV5 { + symbolRnl: string; + netExecQty: string; + sumExecValue: string; + sumExecQty: string; + avgBuyExecPrice: string; + sumBuyExecValue: string; + sumBuyExecQty: string; + sumBuyExecFee: string; + sumBuyOrderQty: string; + avgSellExecPrice: string; + sumSellExecValue: string; + sumSellExecQty: string; + sumSellExecFee: string; + sumSellOrderQty: string; + maxMarginVersion: number; + baseCoin: string; + settleCoin: string; + sumPriceList?: TradeInfoAnalysisDailyV5[]; +} + +================ +File: src/types/response/v5-earn.ts +================ +export interface EarnInterestCardV5 { + awardId: number; + specCode: string; + coin: string; + apy: string; + duration: number; + claimedAt: number; + expireAt: number; + usedAt: number; + status: 'InUse' | 'NotUse' | 'Expired' | 'AlreadyUsed' | string; + currentPnl: string; + limitPnl: string; + positionEffectiveAmount: string; + productId: number; + category: 'FlexibleSaving' | 'DualAssets' | string; +} ⋮---- -/** Order closed via grid bot - web/app. */ +export interface EarnAwardCardV5 { + awardId: number; + specCode: string; + claimedAt: number; + usedAt: number; + expireAt: number; + status: 'InUse' | 'NotUse' | 'Expired' | 'AlreadyUsed' | string; + amount: string; + limitPnlPercentage: string; + baseCoin: string; + quoteCoin: string; + direction: 1 | 2; + category: 'FlexibleSaving' | 'DualAssets' | string; +} ⋮---- -/** Order created by TWAP - web/app. */ +export interface EarnCouponListResultV5 { + interestCards: EarnInterestCardV5[]; + awardCards: EarnAwardCardV5[]; +} ⋮---- -/** Order created by TV webhook - web/app. */ +export interface FlexibleSavingAutoSavingsCoinV5 { + coin: string; + isSelected: boolean; + maxStakingAmount: string; + apr: string; +} ⋮---- -/** Order created by Mm rate close function - web/app. */ +export interface FlexibleSavingAutoSavingsV5 { + selectedAll: boolean; + coins: FlexibleSavingAutoSavingsCoinV5[]; +} ⋮---- -/** Order created by Martingale bot - web/app. */ +export interface EarnProductV5 { + category: string; + estimateApr: string; + coin: string; + minStakeAmount: string; + maxStakeAmount: string; + precision: string; + productId: string; + status: 'Available' | 'NotAvailable'; +} ⋮---- -/** Order closed by Martingale bot - web/app. */ +export interface EarnOrderHistoryV5 { + coin: string; + orderValue: string; + orderType: 'Redeem' | 'Stake'; + orderId: string; + orderLinkId: string; + status: 'Success' | 'Fail' | 'Pending'; + createdAt: string; + productId: string; + updatedAt: string; + swapOrderValue: string; + estimateRedeemTime: string; + estimateStakeTime: string; +} ⋮---- -/** Order created by Ice berg strategy - web/app. */ +export interface EarnPositionFreezeDetailV5 { + amount: string; + description: string; +} ⋮---- -/** Order created by arbitrage - web/app. */ +export interface EarnPositionV5 { + coin: string; + productId: string; + amount: string; + totalPnl: string; + claimableYield: string; + id?: string; + status?: string; + orderId?: string; + estimateRedeemTime?: string; + estimateStakeTime?: string; + estimateInterestCalculationTime?: string; + settlementTime?: string; + autoReinvest?: string; + /** Redeemable amount */ + availableAmount: string; + freezeDetails: EarnPositionFreezeDetailV5[]; +} ⋮---- -/** Option dynamic delta hedge order - web/app */ +/** Redeemable amount */ ⋮---- -/** BBO Order - Best Bid/Offer order */ +export interface EarnYieldHistoryV5 { + productId: string; + coin: string; + id: string; + amount: string; + yieldType: string; + distributionMode: string; + effectiveStakingAmount: string; + orderId: string; + status: 'Pending' | 'Success' | 'Fail'; + createdAt: string; +} ⋮---- -export type OrderCancelTypeV5 = - | 'CancelByUser' - | 'CancelByReduceOnly' - | 'CancelByPrepareLiq' - | 'CancelAllBeforeLiq' - | 'CancelByPrepareAdl' - | 'CancelAllBeforeAdl' - | 'CancelByAdmin' - | 'CancelByTpSlTsClear' - | 'CancelByPzSideCh' - | 'UNKNOWN'; +export interface EarnHourlyYieldHistoryV5 { + productId: string; + coin: string; + id: string; + amount: string; + effectiveStakingAmount: string; + status: 'Pending' | 'Success' | 'Fail'; + hourlyDate: string; + createdAt: string; +} ⋮---- -export type OrderRejectReasonV5 = - | 'EC_NoError' - | 'EC_Others' - | 'EC_UnknownMessageType' - | 'EC_MissingClOrdID' - | 'EC_MissingOrigClOrdID' - | 'EC_ClOrdIDOrigClOrdIDAreTheSame' - | 'EC_DuplicatedClOrdID' - | 'EC_OrigClOrdIDDoesNotExist' - | 'EC_TooLateToCancel' - | 'EC_UnknownOrderType' - | 'EC_UnknownSide' - | 'EC_UnknownTimeInForce' - | 'EC_WronglyRouted' - | 'EC_MarketOrderPriceIsNotZero' - | 'EC_LimitOrderInvalidPrice' - | 'EC_NoEnoughQtyToFill' - | 'EC_NoImmediateQtyToFill' - | 'EC_PerCancelRequest' - | 'EC_MarketOrderCannotBePostOnly' - | 'EC_PostOnlyWillTakeLiquidity' - | 'EC_CancelReplaceOrder' - | 'EC_InvalidSymbolStatus'; +export interface EarnAprHistoryPointV5 { + timestamp: string; + apr: string; +} ⋮---- -export type StopOrderTypeV5 = - | 'TakeProfit' - | 'StopLoss' - | 'TrailingStop' - | 'Stop' - | 'PartialTakeProfit' - | 'PartialStopLoss' - | 'tpslOrder' - | 'OcoOrder' - | 'MmRateClose' - | 'BidirectionalTpslOrder'; +/** + * Advanced Earn — Dual Asset product (GET /v5/earn/advance/product). + */ +export interface AdvanceEarnDualAssetProductV5 { + category: string; + productId: string; + baseCoin: string; + quoteCoin: string; + expectReceiveAt: string; + duration: string; + status: 'Available' | 'NotAvailable'; + isVipProduct: boolean; + subscribeStartAt: string; + subscribeEndAt: string; + applyStartAt: string; + settlementTime: string; + minPurchaseQuoteAmount: string; + minPurchaseBaseAmount: string; + remainingAmountQuote: string; + remainingAmountBase: string; + orderPrecisionDigitalQuote: number; + orderPrecisionDigitalBase: number; +} +⋮---- +export interface AdvanceEarnDualAssetProductInfoV5 { + category: string; + list: AdvanceEarnDualAssetProductV5[]; +} ⋮---- /** - * Position index. Used to identify positions in different position modes. - * - * - 0 one-way mode position - * - 1 Buy side of hedge-mode position - * - 2 Sell side of hedge-mode position + * Advanced Earn — Double Win (GET /v5/earn/advance/product?category=DoubleWin). */ -export type PositionIdx = 0 | 1 | 2; +export interface AdvanceEarnDoubleWinProductV5 { + category: string; + productId: string; + investCoin: string; + underlyingAsset: string; + duration: string; + subscribeStartAt: string; + subscribeEndAt: string; + settlementTime: string; + expectReceiveAt: string; + minPurchaseAmount: string; + orderPrecisionDigital: number; + isRfqProduct: boolean; + lowerPriceBuffer: string; + upperPriceBuffer: string; + minDeviationRatio: string; + maxDeviationRatio: string; + priceTickSize: string; +} ⋮---- /** - * Position status. - * - * - 'Normal' - * - 'Liq' in the liquidation progress - * - 'Adl' in the auto-deleverage progress + * Advanced Earn — Smart Leverage (GET /v5/earn/advance/product?category=SmartLeverage). */ -export type PositionStatusV5 = 'Normal' | 'Liq' | 'Adl'; -export type PositionSideV5 = 'Buy' | 'Sell' | 'None' | ''; -⋮---- -export type OptionTypeV5 = 'Call' | 'Put'; +export interface AdvanceEarnSmartLeverageProductV5 { + category: string; + productId: string; + investCoin: string; + underlyingAsset: string; + direction: 'Long' | 'Short'; + leverage: string; + duration: string; + subscribeStartAt: string; + subscribeEndAt: string; + settlementTime: string; + expectReceiveAt: string; + minPurchaseAmount: string; + remainingAmount: string; + orderPrecisionDigital: number; +} ⋮---- /** - * Trade mode. - * - * - 0 cross-margin, - * - 1 isolated margin + * Advanced Earn — Discount Buy (GET /v5/earn/advance/product?category=DiscountBuy). */ -export type TradeModeV5 = 0 | 1; +export interface AdvanceEarnDiscountBuyProductV5 { + category: string; + productId: string; + coin: string; + underlyingAsset: string; + settlementTime: string; + duration: string; + isVipProduct: boolean; + subscribeStartAt: string; + subscribeEndAt: string; + minPurchaseAmount: string; + remainingAmount: string; + orderPrecisionDigital: number; + expectReceiveAt: string; +} ⋮---- -export type TPSLModeV5 = 'Full' | 'Partial'; -export type AccountMarginModeV5 = - | 'ISOLATED_MARGIN' - | 'REGULAR_MARGIN' - | 'PORTFOLIO_MARGIN'; -export type UnifiedUpdateStatusV5 = 'FAIL' | 'PROCESS' | 'SUCCESS'; +export type AdvanceEarnAdvanceProductListItemV5 = + | AdvanceEarnDualAssetProductV5 + | AdvanceEarnDoubleWinProductV5 + | AdvanceEarnSmartLeverageProductV5 + | AdvanceEarnDiscountBuyProductV5; ⋮---- -export type AccountTypeV5 = - | 'CONTRACT' - | 'SPOT' - | 'INVESTMENT' - | 'OPTION' - | 'UNIFIED' - | 'FUND' - | 'EARN'; +export interface AdvanceEarnAdvanceProductInfoV5 { + category: string; + list: AdvanceEarnAdvanceProductListItemV5[]; +} ⋮---- -export type TransactionTypeV5 = - | 'TRANSFER_IN' - | 'TRANSFER_OUT' - | 'TRADE' - | 'SETTLEMENT' - | 'DELIVERY' - | 'LIQUIDATION' - | 'ADL' - | 'AIRDROP' - | 'BONUS_RECOLLECT' - | 'BONUS_RECOLLECT' - | 'FEE_REFUND' - | 'INTEREST' - | 'CURRENCY_BUY' - | 'CURRENCY_SELL' - | 'BORROWED_AMOUNT_INS_LOAN' - | 'PRINCIPLE_REPAYMENT_INS_LOAN' - | 'INTEREST_REPAYMENT_INS_LOAN' - | 'AUTO_SOLD_COLLATERAL_INS_LOAN' - | 'AUTO_BUY_LIABILITY_INS_LOAN' - | 'AUTO_PRINCIPLE_REPAYMENT_INS_LOAN' - | 'AUTO_INTEREST_REPAYMENT_INS_LOAN' - | 'TRANSFER_IN_INS_LOAN' - | 'TRANSFER_OUT_INS_LOAN' - | 'SPOT_REPAYMENT_SELL' - | 'SPOT_REPAYMENT_BUY' - | 'TOKENS_SUBSCRIPTION' - | 'TOKENS_REDEMPTION' - | 'AUTO_DEDUCTION' - | 'FLEXIBLE_STAKING_SUBSCRIPTION' - | 'FLEXIBLE_STAKING_REDEMPTION' - | 'FIXED_STAKING_SUBSCRIPTION' - | 'BORROWED_AMOUNT_INS_LOAN' - | 'PRINCIPLE_REPAYMENT_INS_LOAN' - | 'INTEREST_REPAYMENT_INS_LOAN' - | 'AUTO_SOLD_COLLATERAL_INS_LOAN' - | 'AUTO_BUY_LIABILITY_INS_LOAN' - | 'AUTO_PRINCIPLE_REPAYMENT_INS_LOAN' - | 'AUTO_INTEREST_REPAYMENT_INS_LOAN' - | 'TRANSFER_IN_INS_LOAN' - | 'TRANSFER_OUT_INS_LOAN' - | 'SPOT_REPAYMENT_SELL' - | 'SPOT_REPAYMENT_BUY' - | 'TOKENS_SUBSCRIPTION' - | 'TOKENS_REDEMPTION' - | 'AUTO_DEDUCTION' - | 'FLEXIBLE_STAKING_SUBSCRIPTION' - | 'FLEXIBLE_STAKING_REDEMPTION' - | 'FIXED_STAKING_SUBSCRIPTION' - | 'FLEXIBLE_STAKING_REFUND' - | 'FIXED_STAKING_REFUND' - | 'PREMARKET_TRANSFER_OUT' - | 'PREMARKET_DELIVERY_SELL_NEW_COIN' - | 'PREMARKET_DELIVERY_BUY_NEW_COIN' - | 'PREMARKET_DELIVERY_PLEDGE_PAY_SELLER' - | 'PREMARKET_DELIVERY_PLEDGE_BACK' - | 'PREMARKET_ROLLBACK_PLEDGE_BACK' - | 'PREMARKET_ROLLBACK_PLEDGE_PENALTY_TO_BUYER' - | 'CUSTODY_NETWORK_FEE' - | 'CUSTODY_SETTLE_FEE' - | 'CUSTODY_LOCK' - | 'CUSTODY_UNLOCK' - | 'CUSTODY_UNLOCK_REFUND' - | 'LOANS_BORROW_FUNDS' - | 'LOANS_PLEDGE_ASSET' - | 'BONUS_TRANSFER_IN' - | 'BONUS_TRANSFER_OUT' - | 'PEF_TRANSFER_IN' - | 'PEF_TRANSFER_OUT' - | 'PEF_PROFIT_SHARE' - | 'ONCHAINEARN_SUBSCRIPTION' - | 'ONCHAINEARN_REDEMPTION' - | 'ONCHAINEARN_REFUND' - | 'STRUCTURE_PRODUCT_SUBSCRIPTION' - | 'STRUCTURE_PRODUCT_REFUND' - | 'CLASSIC_WEALTH_MANAGEMENT_SUBSCRIPTION' - | 'PREMIMUM_WEALTH_MANAGEMENT_SUBSCRIPTION' - | 'PREMIMUM_WEALTH_MANAGEMENT_REFUND' - | 'LIQUIDITY_MINING_SUBSCRIPTION' - | 'LIQUIDITY_MINING_REFUND' - | 'PWM_SUBSCRIPTION' - | 'PWM_REFUND' - | 'DEFI_INVESTMENT_SUBSCRIPTION' - | 'DEFI_INVESTMENT_REFUND' - | 'DEFI_INVESTMENT_REDEMPTION' - | 'INSTITUTION_LOAN_IN' - | 'INSTITUTION_PAYBACK_PRINCIPAL_OUT' - | 'INSTITUTION_PAYBACK_INTEREST_OUT' - | 'INSTITUTION_EXCHANGE_SELL' - | 'INSTITUTION_EXCHANGE_BUY' - | 'INSTITUTION_LIQ_PRINCIPAL_OUT' - | 'INSTITUTION_LIQ_INTEREST_OUT' - | 'INSTITUTION_LOAN_TRANSFER_IN' - | 'INSTITUTION_LOAN_TRANSFER_OUT' - | 'INSTITUTION_LOAN_WITHOUT_WITHDRAW' - | 'INSTITUTION_LOAN_RESERVE_IN' - | 'INSTITUTION_LOAN_RESERVE_OUT' - | 'PLATFORM_TOKEN_MNT_LIQRECALLEDMMNT' - | 'PLATFORM_TOKEN_MNT_LIQRETURNEDMNT' - | 'DIVIDEND_SETTLEMENT' - | 'FORWARD_SPLIT_SETTLE' - | 'REVERSE_SPLIT_SETTLE'; +/** GET /v5/earn/hold-to-earn/product — Hold to Earn airdrop products */ +export type HoldToEarnAirdropProductStatusV5 = + | 'NotStarted' + | 'Online' + | 'Ended'; ⋮---- -export type PermissionTypeV5 = - | 'ContractTrade' - | 'Spot' - | 'Wallet' - | 'Options' - | 'Derivatives' - | 'Exchange' - | 'NFT'; +export interface HoldToEarnAirdropProductYieldV5 { + coinName: string; + /** Yesterday's APR for display, e.g. "10%", "0%" */ + apy: string; + personalApy?: string; + multiplier?: string; +} +⋮---- +/** Yesterday's APR for display, e.g. "10%", "0%" */ +⋮---- +export interface HoldToEarnAirdropProductV5 { + coinName: string; + yields: HoldToEarnAirdropProductYieldV5[]; + status: HoldToEarnAirdropProductStatusV5; + announcementUrl: string; + /** Yesterday's avg APR across yield coins */ + apy: string; + personalApy?: string; +} +⋮---- +/** Yesterday's avg APR across yield coins */ +⋮---- +export interface HoldToEarnAirdropProductsResultV5 { + products: HoldToEarnAirdropProductV5[]; +} +⋮---- +/** GET /v5/earn/hold-to-earn/yield-history */ +export interface HoldToEarnAirdropDailyPnlV5 { + coinName: string; + yieldCoinName: string; + effectiveAmount: string; + pnl: string; + apy: string; + createdAt: number; +} +⋮---- +export interface HoldToEarnAirdropYieldHistoryResultV5 { + nextCursor: string; + airdropDailyPnls: HoldToEarnAirdropDailyPnlV5[]; +} + +================ +File: src/types/response/v5-market.ts +================ +import { + CategoryCursorListV5, + CategoryV5, + ContractTypeV5, + CopyTradingV5, + InstrumentStatusV5, + InstrumentSymbolTypeV5, + MarginTradingV5, + OptionTypeV5, + OrderSideV5, +} from '../shared-v5'; ⋮---- /** - * Leveraged token status: + * OHLCVT candle used by v5 APIs * - * - '1' LT can be purchased and redeemed - * - '2' LT can be purchased, but not redeemed - * - '3' LT can be redeemed, but not purchased - * - '4' LT cannot be purchased nor redeemed - * - '5' Adjusting position + * - list[0]: startTime string Start time of the candle (ms) + * - list[1]: openPrice string Open price + * - list[2]: highPrice string Highest price + * - list[3]: lowPrice string Lowest price + * - list[4]: closePrice string Close price. Is the last traded price when the candle is not closed + * - list[5]: volume string Trade volume. Unit of contract: pieces of contract. Unit of spot: quantity of coins + * - list[6]: turnover string Turnover. Unit of figure: quantity of quota coin */ -export type LeverageTokenStatusV5 = '1' | '2' | '3' | '4' | '5'; +export type OHLCVKlineV5 = [ + string, + string, + string, + string, + string, + string, + string, +]; ⋮---- /** - * Leveraged token order type: '1': purchase, '2': redeem + * OHLC candle used by v5 APIs + * + * - list[0]: startTime string Start time of the candle (ms) + * - list[1]: openPrice string Open price + * - list[2]: highPrice string Highest price + * - list[3]: lowPrice string Lowest price + * - list[4]: closePrice string Close price. Is the last traded price when the candle is not closed */ -export type LTOrderTypeV5 = '1' | '2'; +export type OHLCKlineV5 = [string, string, string, string, string]; ⋮---- -/** - * Leveraged token order status: '1': completed, '2': in progress, '3': failed - */ -export type LTOrderStatusV5 = '1' | '2' | '3'; +export interface LinearInverseInstrumentInfoV5 { + /** The ID of the symbol name. */ + symbolId: number; + symbol: string; + contractType: ContractTypeV5; + status: InstrumentStatusV5; + baseCoin: string; + quoteCoin: string; + /** Region / product class for the pair (`stock`, `forex`, `commodity`, `xstocks`, etc.). */ + symbolType: InstrumentSymbolTypeV5; + launchTime: string; + deliveryTime?: string; + deliveryFeeRate?: string; + priceScale: string; + leverageFilter: { + minLeverage: string; + maxLeverage: string; + leverageStep: string; + }; + priceFilter: { + minPrice: string; + maxPrice: string; + tickSize: string; + }; + lotSizeFilter: { + maxOrderQty: string; + maxMktOrderQty: string; + minOrderQty: string; + qtyStep: string; + postOnlyMaxOrderQty?: string; + minNotionalValue?: string; + }; + unifiedMarginTrade: boolean; + fundingInterval: number; + settleCoin: string; + copyTrading: CopyTradingV5; + upperFundingRate: string; + lowerFundingRate: string; + riskParameters: { + priceLimitRatioX: string; + priceLimitRatioY: string; + }; + isPreListing: boolean; + preListingInfo: { + curAuctionPhase: string; + phases: { + phase: string; + startTime: string; + endTime: string; + }[]; + auctionFeeInfo: { + auctionFeeRate: string; + takerFeeRate: string; + makerFeeRate: string; + }; + } | null; + skipCallAuction?: boolean; // For USDT pre-market contract + displayName: string; + fullName?: string; + marketRegion?: string; + underlyingTicker?: string; + /** Symbol tags such as `ST`. Linear and inverse only. */ + tags?: string[]; +} ⋮---- -export type ExecTypeV5 = - | 'Trade' - | 'AdlTrade' - | 'Funding' - | 'BustTrade' - | 'Settle' - | 'BlockTrade' - | 'MovePosition' - /** @deprecated Removed from Bybit execType; kept for older payloads. */ - | 'CorporateAction' - | 'ForwardSplitSettle' - | 'ReverseSplitSettle' - | 'Dividend' - | 'UNKNOWN'; +/** The ID of the symbol name. */ ⋮---- -/** @deprecated Removed from Bybit execType; kept for older payloads. */ +/** Region / product class for the pair (`stock`, `forex`, `commodity`, `xstocks`, etc.). */ +⋮---- +skipCallAuction?: boolean; // For USDT pre-market contract +⋮---- +/** Symbol tags such as `ST`. Linear and inverse only. */ +⋮---- +export interface OptionInstrumentInfoV5 { + /** The ID of the symbol name. */ + symbolId: number; + symbol: string; + optionsType: OptionTypeV5; + status: InstrumentStatusV5; + baseCoin: string; + quoteCoin: string; + settleCoin: string; + symbolType: InstrumentSymbolTypeV5; + launchTime: string; + deliveryTime: string; + deliveryFeeRate: string; + priceFilter: { + minPrice: string; + maxPrice: string; + tickSize: string; + }; + lotSizeFilter: { + maxOrderQty: string; + minOrderQty: string; + qtyStep: string; + }; + displayName: string; +} +⋮---- +/** The ID of the symbol name. */ +⋮---- +export interface SpotInstrumentInfoV5 { + /** The ID of the symbol name. */ + symbolId: number; + symbol: string; + baseCoin: string; + quoteCoin: string; + /** + * Xstock multiplier for `symbolType` = xstocks pairs. `stock_price = token_price / multiplier`, + * `stock_qty = token_qty * multiplier`. Default `"1"`. + */ + xstockMultiplier?: string; + symbolType: InstrumentSymbolTypeV5; + innovation: '0' | '1'; // Deprecated, always 0 + status: InstrumentStatusV5; + marginTrading: MarginTradingV5; + stTag: '0' | '1'; + lotSizeFilter: { + basePrecision: string; + quotePrecision: string; + minOrderQty: string; + maxOrderQty: string; + minOrderAmt: string; + maxOrderAmt: string; + maxLimitOrderQty: string; + maxMarketOrderQty: string; + postOnlyMaxLimitOrderSize: string; + }; + priceFilter: { + tickSize: string; + }; + riskParameters: { + priceLimitRatioX: string; + priceLimitRatioY: string; + }; + forbidUplWithdrawal: boolean; +} +⋮---- +/** The ID of the symbol name. */ ⋮---- /** - * Withdraw type. 0(default): on chain. 1: off chain. 2: all. - */ -export type WithdrawalTypeV5 = '0' | '1' | '2'; + * Xstock multiplier for `symbolType` = xstocks pairs. `stock_price = token_price / multiplier`, + * `stock_qty = token_qty * multiplier`. Default `"1"`. + */ ⋮---- -export interface PermissionsV5 { - ContractTrade?: string[]; - Spot?: string[]; - Wallet?: string[]; - Options?: string[]; - Derivatives?: string[]; - CopyTrading?: string[]; - BlockTrade?: string[]; - Exchange?: string[]; - /** @deprecated , always returns []*/ - NFT?: string[]; - Earn?: string[]; - Affiliate?: string[]; - FiatP2P?: string[]; - /** Bybit Pay (FaitPayOrder) */ - FiatBitPay?: string[]; - FiatConvertBroker?: string[]; - BitCard?: string[]; - ByXPost?: string[]; +innovation: '0' | '1'; // Deprecated, always 0 +⋮---- +type InstrumentInfoV5Mapping = { + linear: LinearInverseInstrumentInfoV5[]; + inverse: LinearInverseInstrumentInfoV5[]; + option: OptionInstrumentInfoV5[]; + spot: SpotInstrumentInfoV5[]; +}; +⋮---- +export type InstrumentInfoResponseV5 = + CategoryCursorListV5; +⋮---- +// Account Instruments Info (includes RPI permissions) +export interface AccountSpotInstrumentInfoV5 extends SpotInstrumentInfoV5 { + isPublicRpi: boolean; + myRpiPermission: boolean; } ⋮---- -/** @deprecated , always returns []*/ +export interface AccountLinearInverseInstrumentInfoV5 + extends LinearInverseInstrumentInfoV5 { + isPublicRpi: boolean; + myRpiPermission: boolean; +} ⋮---- -/** Bybit Pay (FaitPayOrder) */ +type AccountInstrumentInfoV5Mapping = { + linear: AccountLinearInverseInstrumentInfoV5[]; + inverse: AccountLinearInverseInstrumentInfoV5[]; + spot: AccountSpotInstrumentInfoV5[]; +}; ⋮---- -export interface CategoryCursorListV5< - T extends unknown[], - TCategory extends CategoryV5 = CategoryV5, -> { - category: TCategory; - list: T; - nextPageCursor?: string; -} +export type AccountInstrumentInfoResponseV5< + C extends 'spot' | 'linear' | 'inverse', +> = CategoryCursorListV5; ⋮---- /** - * Next page cursor does not exist for spot! + * [price, size] */ -export interface CursorListV5 { - nextPageCursor: string; - list: T; +export type OrderbookLevelV5 = [string, string]; +⋮---- +export interface OrderbookResponseV5 { + s: string; + b: OrderbookLevelV5[]; + a: OrderbookLevelV5[]; + ts: number; + u: number; + seq: number; + cts: number; } ⋮---- /** - * A wrapper type for any responses that have a "nextPageCursor" property, and a "rows" property with an array of elements - * - * ```{ nextPageCursor: "something", rows: someData[] }``` + * RPI Orderbook level: [price, nonRpiSize, rpiSize] */ -export interface CursorRowsV5 { - nextPageCursor: string; - rows: T; +export type RPIOrderbookLevelV5 = [string, string, string]; +⋮---- +export interface RPIOrderbookResponseV5 { + s: string; // Symbol name + b: RPIOrderbookLevelV5[]; // Bids. Sorted by price in descending order + a: RPIOrderbookLevelV5[]; // Asks. Sorted by price in ascending order + ts: number; // The timestamp (ms) that the system generates the data + u: number; // Update ID, is always in sequence corresponds to u in the 50-level WebSocket RPI orderbook stream + seq: number; // Cross sequence + cts: number; // The timestamp from the matching engine when this orderbook data is produced } ⋮---- -export interface CategoryListV5< - T extends unknown[], - TCategory extends CategoryV5, -> { - category: TCategory; - list: T; +s: string; // Symbol name +b: RPIOrderbookLevelV5[]; // Bids. Sorted by price in descending order +a: RPIOrderbookLevelV5[]; // Asks. Sorted by price in ascending order +ts: number; // The timestamp (ms) that the system generates the data +u: number; // Update ID, is always in sequence corresponds to u in the 50-level WebSocket RPI orderbook stream +seq: number; // Cross sequence +cts: number; // The timestamp from the matching engine when this orderbook data is produced +⋮---- +export interface TickerLinearInverseV5 { + symbol: string; + lastPrice: string; + indexPrice: string; + markPrice: string; + prevPrice24h: string; + price24hPcnt: string; + highPrice24h: string; + lowPrice24h: string; + prevPrice1h: string; + openInterest: string; + openInterestValue: string; + singleOpenInterest?: string; + singleOpenInterestValue?: string; + turnover24h: string; + volume24h: string; + fundingRate: string; + nextFundingTime: string; + predictedDeliveryPrice: string; + basisRate: string; + basisRateYear: string; + fundingIntervalHour: string; + fundingCap: string; + deliveryFeeRate: string; + deliveryTime: string; + ask1Size: string; + bid1Price: string; + ask1Price: string; + bid1Size: string; + preOpenPrice: string; + preQty: string; + curPreListingPhase: string; + basis: string; } ⋮---- -export interface CategorySymbolListV5< - T extends unknown[], - TCategory extends CategoryV5, -> { - category: TCategory; +export interface TickerOptionV5 { symbol: string; - list: T; + bid1Price: string; + bid1Size: string; + bid1Iv: string; + ask1Price: string; + ask1Size: string; + ask1Iv: string; + lastPrice: string; + highPrice24h: string; + lowPrice24h: string; + markPrice: string; + indexPrice: string; + markIv: string; + underlyingPrice: string; + openInterest: string; + turnover24h: string; + volume24h: string; + totalVolume: string; + totalTurnover: string; + delta: string; + gamma: string; + vega: string; + theta: string; + predictedDeliveryPrice: string; + change24h: string; } ⋮---- -export interface GetSystemStatusParamsV5 { - id?: string; - state?: string; +export interface TickerSpotV5 { + symbol: string; + bid1Price: string; + bid1Size: string; + ask1Price: string; + ask1Size: string; + lastPrice: string; + prevPrice24h: string; + price24hPcnt: string; + highPrice24h: string; + lowPrice24h: string; + turnover24h: string; + volume24h: string; + usdIndexPrice: string; } ⋮---- -export interface SystemStatusItemV5 { - id: string; - title: string; - state: string; - begin: string; - end: string; - href: string; - serviceTypes: number[]; - product: number[]; - uidSuffix: number[]; - maintainType: string; - env: string; +export interface FundingRateHistoryResponseV5 { + symbol: string; + fundingRate: string; + fundingRateTimestamp: string; } - -================ -File: .gitignore -================ -!.gitkeep -.DS_STORE -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json -pids -*.pid -*.seed -*.pid.lock -node_modules/ -.npm -.eslintcache -.node_repl_history -*.tgz -.yarn-integrity -.env -.env.test -.cache -lib -dist -doc -bundleReport.html -.history/ -rawReq.ts -localtest.sh -localtest.ts -privaterepotracker -restClientRegex.ts -repomix.sh - -examples/ignored -examples/ts-testnet-private.ts -examples/ts-testnet-trade.ts -examples/ts-testnet.ts -*.pem -.issue* -docs/research - -================ -File: src/types/request/index.ts -================ - - -================ -File: src/types/response/index.ts -================ - - -================ -File: src/types/response/v5-earn.ts -================ -export interface EarnInterestCardV5 { - awardId: number; - specCode: string; +⋮---- +export interface PublicTradeV5 { + execId: string; + symbol: string; + price: string; + size: string; + side: OrderSideV5; + time: string; + isBlockTrade: boolean; + isRPITrade: boolean; + mP?: string; + iP?: string; + mIv?: string; + iv?: string; + seq?: string; +} +⋮---- +/** + * + * - openInterest string Open interest + * - timestamp string The timestamp (ms) + */ +export type OpenInterestV5 = { + openInterest: string; + singleOpenInterest?: string; + timestamp: string; +}; +⋮---- +export interface OpenInterestResponseV5 { + category: 'linear' | 'inverse'; + symbol: string; + list: OpenInterestV5[]; + nextPageCursor?: string; +} +⋮---- +export interface HistoricalVolatilityV5 { + period: number; + value: string; + time: string; +} +⋮---- +export interface InsuranceDataV5 { coin: string; - apy: string; - duration: number; - claimedAt: number; - expireAt: number; - usedAt: number; - status: 'InUse' | 'NotUse' | 'Expired' | 'AlreadyUsed' | string; - currentPnl: string; - limitPnl: string; - positionEffectiveAmount: string; - productId: number; - category: 'FlexibleSaving' | 'DualAssets' | string; + symbols: string; + balance: string; + value: string; } ⋮---- -export interface EarnAwardCardV5 { - awardId: number; - specCode: string; - claimedAt: number; - usedAt: number; - expireAt: number; - status: 'InUse' | 'NotUse' | 'Expired' | 'AlreadyUsed' | string; - amount: string; - limitPnlPercentage: string; - baseCoin: string; - quoteCoin: string; - direction: 1 | 2; - category: 'FlexibleSaving' | 'DualAssets' | string; +export interface InsuranceResponseV5 { + updatedTime: string; + list: InsuranceDataV5[]; } ⋮---- -export interface EarnCouponListResultV5 { - interestCards: EarnInterestCardV5[]; - awardCards: EarnAwardCardV5[]; +export interface RiskLimitV5 { + id: number; + symbol: string; + riskLimitValue: string; + maintenanceMargin: number; + initialMargin: number; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + section: any; + isLowestRisk: 0 | 1; + maxLeverage: string; + mmDeduction: string; + nextPageCursor?: string; } ⋮---- -export interface EarnProductV5 { - category: string; - estimateApr: string; - coin: string; - minStakeAmount: string; - maxStakeAmount: string; - precision: string; - productId: string; - status: 'Available' | 'NotAvailable'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +⋮---- +/** @deprecated use DeliveryPriceV5 instead */ +export interface OptionDeliveryPriceV5 { + symbol: string; + deliveryPrice: string; + deliveryTime: string; } ⋮---- -export interface EarnOrderHistoryV5 { - coin: string; - orderValue: string; - orderType: 'Redeem' | 'Stake'; - orderId: string; - orderLinkId: string; - status: 'Success' | 'Fail' | 'Pending'; - createdAt: string; - productId: string; - updatedAt: string; - swapOrderValue: string; - estimateRedeemTime: string; - estimateStakeTime: string; +export interface DeliveryPriceV5 { + symbol: string; + deliveryPrice: string; + deliveryTime: string; } ⋮---- -export interface EarnPositionFreezeDetailV5 { - amount: string; - description: string; +export interface LongShortRatioV5 { + symbol: string; + buyRatio: string; + sellRatio: string; + timestamp: string; } ⋮---- -export interface EarnPositionV5 { - coin: string; - productId: string; - amount: string; - totalPnl: string; - claimableYield: string; - id?: string; - status?: string; - orderId?: string; - estimateRedeemTime?: string; - estimateStakeTime?: string; - estimateInterestCalculationTime?: string; - settlementTime?: string; - autoReinvest?: string; - /** Redeemable amount */ - availableAmount: string; - freezeDetails: EarnPositionFreezeDetailV5[]; +export interface OrderPriceLimitV5 { + symbol: string; + buyLmt: string; + sellLmt: string; + ts: string; } ⋮---- -/** Redeemable amount */ +export interface IndexPriceComponentV5 { + exchange: string; // Name of the exchange + spotPair: string; // Spot trading pair on the exchange (e.g., BTCUSDT) + equivalentPrice: string; // Equivalent price + multiplier: string; // Multiplier used for the component price + price: string; // Actual price + weight: string; // Weight in the index calculation +} ⋮---- -export interface EarnYieldHistoryV5 { - productId: string; - coin: string; - id: string; - amount: string; - yieldType: string; - distributionMode: string; - effectiveStakingAmount: string; - orderId: string; - status: 'Pending' | 'Success' | 'Fail'; - createdAt: string; +exchange: string; // Name of the exchange +spotPair: string; // Spot trading pair on the exchange (e.g., BTCUSDT) +equivalentPrice: string; // Equivalent price +multiplier: string; // Multiplier used for the component price +price: string; // Actual price +weight: string; // Weight in the index calculation +⋮---- +export interface IndexPriceComponentsResponseV5 { + indexName: string; // Name of the index (e.g., BTCUSDT) + lastPrice: string; // Last price of the index + updateTime: string; // Timestamp of the last update in milliseconds + components: IndexPriceComponentV5[]; // List of components contributing to the index price } ⋮---- -export interface EarnHourlyYieldHistoryV5 { - productId: string; - coin: string; - id: string; - amount: string; - effectiveStakingAmount: string; - status: 'Pending' | 'Success' | 'Fail'; - hourlyDate: string; - createdAt: string; +indexName: string; // Name of the index (e.g., BTCUSDT) +lastPrice: string; // Last price of the index +updateTime: string; // Timestamp of the last update in milliseconds +components: IndexPriceComponentV5[]; // List of components contributing to the index price +⋮---- +export interface ADLAlertItemV5 { + coin: string; // Token of the insurance pool + symbol: string; // Trading pair name + balance: string; // Balance of the insurance fund. Used to determine if ADL is triggered + maxBalance: string; // Maximum balance of the insurance pool in the last 8 hours + insurancePnlRatio: string; // PnL ratio threshold for triggering contract PnL drawdown ADL + pnlRatio: string; // Symbol's PnL drawdown ratio in the last 8 hours. Used to determine whether ADL is triggered or stopped + adlTriggerThreshold: string; // Trigger threshold for contract PnL drawdown ADL + adlStopRatio: string; // Stop ratio threshold for contract PnL drawdown ADL } ⋮---- -export interface EarnAprHistoryPointV5 { - timestamp: string; - apr: string; +coin: string; // Token of the insurance pool +symbol: string; // Trading pair name +balance: string; // Balance of the insurance fund. Used to determine if ADL is triggered +maxBalance: string; // Maximum balance of the insurance pool in the last 8 hours +insurancePnlRatio: string; // PnL ratio threshold for triggering contract PnL drawdown ADL +pnlRatio: string; // Symbol's PnL drawdown ratio in the last 8 hours. Used to determine whether ADL is triggered or stopped +adlTriggerThreshold: string; // Trigger threshold for contract PnL drawdown ADL +adlStopRatio: string; // Stop ratio threshold for contract PnL drawdown ADL +⋮---- +export interface ADLAlertResponseV5 { + updateTime: string; // Latest data update timestamp (ms) + list: ADLAlertItemV5[]; // List of ADL alert items } ⋮---- -/** - * Advanced Earn — Dual Asset product (GET /v5/earn/advance/product). - */ -export interface AdvanceEarnDualAssetProductV5 { - category: string; - productId: string; +updateTime: string; // Latest data update timestamp (ms) +list: ADLAlertItemV5[]; // List of ADL alert items +⋮---- +export interface FeeGroupLevelV5 { + level: string; // Pro level name or Market Maker level name + takerFeeRate: string; // Taker fee rate + makerFeeRate: string; // Maker fee rate + makerRebate: string; // Maker rebate fee rate + rpiMakerRebate?: string; +} +⋮---- +level: string; // Pro level name or Market Maker level name +takerFeeRate: string; // Taker fee rate +makerFeeRate: string; // Maker fee rate +makerRebate: string; // Maker rebate fee rate +⋮---- +export interface FeeGroupRatesV5 { + pro: FeeGroupLevelV5[]; // Pro-level fee structures + marketMaker: FeeGroupLevelV5[]; // Market Maker-level fee structures +} +⋮---- +pro: FeeGroupLevelV5[]; // Pro-level fee structures +marketMaker: FeeGroupLevelV5[]; // Market Maker-level fee structures +⋮---- +export interface FeeGroupItemV5 { + groupName: string; // Fee group name + weightingFactor: number; // Group weighting factor + symbolsNumbers: number; // Symbols number + symbols: string[]; // Symbol names + feeRates: FeeGroupRatesV5; // Fee rate details for different categories + updateTime: string; // Latest data update timestamp (ms) +} +⋮---- +groupName: string; // Fee group name +weightingFactor: number; // Group weighting factor +symbolsNumbers: number; // Symbols number +symbols: string[]; // Symbol names +feeRates: FeeGroupRatesV5; // Fee rate details for different categories +updateTime: string; // Latest data update timestamp (ms) +⋮---- +export interface FeeGroupStructureResponseV5 { + list: FeeGroupItemV5[]; // List of fee group objects +} +⋮---- +list: FeeGroupItemV5[]; // List of fee group objects +⋮---- +export interface OptionBaseCoinV5 { baseCoin: string; quoteCoin: string; - expectReceiveAt: string; - duration: string; - status: 'Available' | 'NotAvailable'; - isVipProduct: boolean; - subscribeStartAt: string; - subscribeEndAt: string; - applyStartAt: string; - settlementTime: string; - minPurchaseQuoteAmount: string; - minPurchaseBaseAmount: string; - remainingAmountQuote: string; - remainingAmountBase: string; - orderPrecisionDigitalQuote: number; - orderPrecisionDigitalBase: number; + settleCoin: string; + optionShowName: string; + /** UTC milliseconds. 0 when the option is not scheduled. */ + optionOnlineTime: number; + /** 1 when tradable option symbols exist, otherwise 0 */ + hasSymbol: 0 | 1; + /** 0 crypto, 1 commodity, 2 stock, 3 forex, 4 oil */ + underlyingType: 0 | 1 | 2 | 3 | 4; } ⋮---- -export interface AdvanceEarnDualAssetProductInfoV5 { - category: string; - list: AdvanceEarnDualAssetProductV5[]; -} +/** UTC milliseconds. 0 when the option is not scheduled. */ ⋮---- -/** - * Advanced Earn — Double Win (GET /v5/earn/advance/product?category=DoubleWin). - */ -export interface AdvanceEarnDoubleWinProductV5 { - category: string; - productId: string; - investCoin: string; - underlyingAsset: string; - duration: string; - subscribeStartAt: string; - subscribeEndAt: string; - settlementTime: string; - expectReceiveAt: string; - minPurchaseAmount: string; - orderPrecisionDigital: number; - isRfqProduct: boolean; - lowerPriceBuffer: string; - upperPriceBuffer: string; - minDeviationRatio: string; - maxDeviationRatio: string; - priceTickSize: string; +/** 1 when tradable option symbols exist, otherwise 0 */ +⋮---- +/** 0 crypto, 1 commodity, 2 stock, 3 forex, 4 oil */ +⋮---- +export interface OptionBaseCoinsResultV5 { + list: OptionBaseCoinV5[]; } + +================ +File: src/types/response/v5-position.ts +================ +import { + CategoryV5, + ExecTypeV5, + OrderSideV5, + OrderTypeV5, + PositionIdx, + PositionSideV5, + PositionStatusV5, + StopOrderTypeV5, + TPSLModeV5, + TradeModeV5, +} from '../shared-v5'; ⋮---- -/** - * Advanced Earn — Smart Leverage (GET /v5/earn/advance/product?category=SmartLeverage). - */ -export interface AdvanceEarnSmartLeverageProductV5 { - category: string; - productId: string; - investCoin: string; - underlyingAsset: string; - direction: 'Long' | 'Short'; +export interface FuturesLeverageItemV5 { + symbol: string; leverage: string; - duration: string; - subscribeStartAt: string; - subscribeEndAt: string; - settlementTime: string; - expectReceiveAt: string; - minPurchaseAmount: string; - remainingAmount: string; - orderPrecisionDigital: number; + side: OrderSideV5 | ''; + positionIdx: PositionIdx; } ⋮---- -/** - * Advanced Earn — Discount Buy (GET /v5/earn/advance/product?category=DiscountBuy). - */ -export interface AdvanceEarnDiscountBuyProductV5 { - category: string; - productId: string; - coin: string; - underlyingAsset: string; - settlementTime: string; - duration: string; - isVipProduct: boolean; - subscribeStartAt: string; - subscribeEndAt: string; - minPurchaseAmount: string; - remainingAmount: string; - orderPrecisionDigital: number; - expectReceiveAt: string; +export interface FuturesLeverageResultV5 { + category: 'linear' | 'inverse'; + list: FuturesLeverageItemV5[]; } ⋮---- -export type AdvanceEarnAdvanceProductListItemV5 = - | AdvanceEarnDualAssetProductV5 - | AdvanceEarnDoubleWinProductV5 - | AdvanceEarnSmartLeverageProductV5 - | AdvanceEarnDiscountBuyProductV5; -⋮---- -export interface AdvanceEarnAdvanceProductInfoV5 { - category: string; - list: AdvanceEarnAdvanceProductListItemV5[]; +export interface PositionV5 { + positionIdx: PositionIdx; + riskId: number; + riskLimitValue: string; + symbol: string; + side: PositionSideV5; + size: string; + avgPrice: string; + positionValue: string; + tradeMode: TradeModeV5; + autoAddMargin?: number; + positionStatus: PositionStatusV5; + leverage?: string; + breakEvenPrice?: string; // Break even price, only for linear & inverse + markPrice: string; + liqPrice: string | ''; + bustPrice?: string; + positionIM?: string; + positionMM?: string; + positionBalance?: string; + tpslMode?: TPSLModeV5; + takeProfit?: string; + stopLoss?: string; + trailingStop?: string; + sessionAvgPrice: string | ''; + delta?: string; + gamma?: string; + vega?: string; + theta?: string; + unrealisedPnl: string; + curRealisedPnl: string; + cumRealisedPnl: string; + adlRankIndicator: number; + isReduceOnly: boolean; + mmrSysUpdatedTime: string | ''; + leverageSysUpdatedTime: string | ''; + createdTime: string; + updatedTime: string; + /** Position open timestamp (ms). Default `0` when not set. */ + openTime: number; + positionIMByMp: string; + positionMMByMp: string; + seq: number; + netDeltaRatio?: string; } ⋮---- -/** GET /v5/earn/hold-to-earn/product — Hold to Earn airdrop products */ -export type HoldToEarnAirdropProductStatusV5 = - | 'NotStarted' - | 'Online' - | 'Ended'; +breakEvenPrice?: string; // Break even price, only for linear & inverse ⋮---- -export interface HoldToEarnAirdropProductYieldV5 { - coinName: string; - /** Yesterday's APR for display, e.g. "10%", "0%" */ - apy: string; - personalApy?: string; - multiplier?: string; +/** Position open timestamp (ms). Default `0` when not set. */ +⋮---- +export interface SetRiskLimitResultV5 { + category: CategoryV5; + riskId: number; + riskLimitValue: string; } ⋮---- -/** Yesterday's APR for display, e.g. "10%", "0%" */ +export interface AddOrReduceMarginResultV5 { + category: CategoryV5; + symbol: string; + positionIdx: PositionIdx; + riskId: number; + riskLimitValue: string; + size: string; + avgPrice: string; + liqPrice: string; + bustPrice: string; + markPrice: string; + positionValue: string; + leverage: string; + autoAddMargin: 0 | 1; + positionStatus: PositionStatusV5; + positionIM: string; + positionMM: string; + takeProfit: string; + stopLoss: string; + trailingStop: string; + unrealisedPnl: string; + cumRealisedPnl: string; + createdTime: string; + updatedTime: string; +} ⋮---- -export interface HoldToEarnAirdropProductV5 { - coinName: string; - yields: HoldToEarnAirdropProductYieldV5[]; - status: HoldToEarnAirdropProductStatusV5; - announcementUrl: string; - /** Yesterday's avg APR across yield coins */ - apy: string; - personalApy?: string; +export interface ExecutionV5 { + symbol: string; + orderId: string; + orderLinkId: string; + side: OrderSideV5; + orderPrice: string; + orderQty: string; + leavesQty: string; + orderType: OrderTypeV5; + stopOrderType?: StopOrderTypeV5; + execFee: string; + execFeeV2: string; + feeCurrency: string; // Trading fee currency + execId: string; + execPrice: string; + execQty: string; + execType: ExecTypeV5; + execValue: string; + execTime: string; + isMaker: boolean; + feeRate: string; + tradeIv?: string; + markIv?: string; + markPrice: string; + indexPrice: string; + underlyingPrice?: string; + blockTradeId?: string; + closedSize?: string; + seq: number; + extraFees: string; } ⋮---- -/** Yesterday's avg APR across yield coins */ +feeCurrency: string; // Trading fee currency ⋮---- -export interface HoldToEarnAirdropProductsResultV5 { - products: HoldToEarnAirdropProductV5[]; +export interface ClosedPnLV5 { + symbol: string; + orderId: string; + side: string; + qty: string; + orderPrice: string; + orderType: OrderTypeV5; + execType: ExecTypeV5; + closedSize: string; + openFee: string; + closeFee: string; + cumEntryValue: string; + avgEntryPrice: string; + cumExitValue: string; + avgExitPrice: string; + closedPnl: string; + fillCount: string; + leverage: string; + createdTime: string; + updatedTime: string; } ⋮---- -/** GET /v5/earn/hold-to-earn/yield-history */ -export interface HoldToEarnAirdropDailyPnlV5 { - coinName: string; - yieldCoinName: string; - effectiveAmount: string; - pnl: string; - apy: string; +export interface MovePositionResultV5 { + blockTradeId: string; + status: 'Processing' | 'Rejected'; + rejectParty: '' | 'Taker' | 'Maker' | 'bybit'; +} +⋮---- +export interface MovePositionHistoryV5 { + blockTradeId: string; + category: 'linear' | 'spot' | 'option'; + orderId: string; + userId: number; + symbol: string; + side: 'Buy' | 'Sell'; + price: string; + qty: string; + execFee: string; + status: 'Processing' | 'Filled' | 'Rejected'; + execId: string; + resultCode: number; + resultMessage: string; createdAt: number; + updatedAt: number; + rejectParty: '' | 'Taker' | 'Maker' | 'bybit'; } ⋮---- -export interface HoldToEarnAirdropYieldHistoryResultV5 { - nextCursor: string; - airdropDailyPnls: HoldToEarnAirdropDailyPnlV5[]; +export interface ClosedOptionsPositionV5 { + symbol: string; + side: 'Buy' | 'Sell'; + totalOpenFee: string; + deliveryFee: string; + totalCloseFee: string; + qty: string; + closeTime: number; + avgExitPrice: string; + deliveryPrice: string; + openTime: number; + avgEntryPrice: string; + totalPnl: string; } +================ +File: .gitignore +================ +!.gitkeep +.DS_STORE +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json +pids +*.pid +*.seed +*.pid.lock +node_modules/ +.npm +.eslintcache +.node_repl_history +*.tgz +.yarn-integrity +.env +.env.test +.cache +lib +dist +doc +bundleReport.html +.history/ +rawReq.ts +localtest.sh +localtest.ts +privaterepotracker +restClientRegex.ts +repomix.sh + +examples/ignored +examples/ts-testnet-private.ts +examples/ts-testnet-trade.ts +examples/ts-testnet.ts +*.pem +.issue* +docs/research +tmp + +================ +File: src/types/request/index.ts +================ + + +================ +File: src/types/response/index.ts +================ + + ================ File: src/types/response/v5-user.ts ================ @@ -13393,980 +13185,1428 @@ export interface AffiliateUserListItemV5 { commissions365Day?: Record; } ⋮---- -/** tradfi trade volume in [startDate, endDate] when startDate/endDate in params */ +/** tradfi trade volume in [startDate, endDate] when startDate/endDate in params */ +⋮---- +/** tradfi trade volume in last 30 days. 0 when startDate/endDate in params */ +⋮---- +/** tradfi trade volume in past year. 0 when startDate/endDate in params */ +⋮---- +/** Commission between startDate and endDate when startDate/endDate in params. Coin -> amount */ +⋮---- +/** Commission in last 30 days. Coin -> amount */ +⋮---- +/** Commission in past year. Coin -> amount */ +⋮---- +export interface AffiliateUserInfoV5 { + uid: string; + vipLevel: string; + takerVol30Day: string; + makerVol30Day: string; + tradeVol30Day: string; + depositAmount30Day: string; + takerVol365Day: string; + makerVol365Day: string; + tradeVol365Day: string; + depositAmount365Day: string; + totalWalletBalance: '1' | '2' | '3' | '4'; + depositUpdateTime: string; + volUpdateTime: string; + KycLevel: 0 | 1 | 2; + /** tradfi trade volume in last 30 days (USDT) */ + tradfiTradeVol30Day?: string; + /** tradfi trade volume in past year (USDT) */ + tradfiTradeVol365Day?: string; + /** tradfi commissions in last 30 days. Coin -> amount */ + commissions30Day?: Record; + /** tradfi commissions in past year. Coin -> amount */ + commissions365Day?: Record; + /** Payment amount in the last 30 days */ + paySendAmount30Day: string; + /** Pay first transaction amount */ + payFtt: string; + /** Card first-time transaction amount */ + cardFtt: string; +} +⋮---- +/** tradfi trade volume in last 30 days (USDT) */ +⋮---- +/** tradfi trade volume in past year (USDT) */ +⋮---- +/** tradfi commissions in last 30 days. Coin -> amount */ +⋮---- +/** tradfi commissions in past year. Coin -> amount */ +⋮---- +/** Payment amount in the last 30 days */ +⋮---- +/** Pay first transaction amount */ +⋮---- +/** Card first-time transaction amount */ +⋮---- +export interface AffiliateSubAffiliateListItemV5 { + subAffId: string; + userId: string; + name: string; + email: string; + /** Commission per currency (BTC, ETH, MNT, USDC, USDT) for the queried date range */ + commissionsVol: Record; + commissionsForUsdt: string; + becameAffTime: string; + startDate: string; + endDate: string; +} +⋮---- +/** Commission per currency (BTC, ETH, MNT, USDC, USDT) for the queried date range */ +⋮---- +export interface AffiliateSubAffiliateListResultV5 { + list: AffiliateSubAffiliateListItemV5[]; + nextPageCursor: string; +} +⋮---- +export interface FriendReferralRecordV5 { + id: string; + inviteeUid: string; + status: number; + createdAt: string; + updatedAt: string; +} +⋮---- +export interface ReferralCodeItemV5 { + referralCode: string; + referralLink: string; + scene: number; +} +⋮---- +export interface ReferralCodesResultV5 { + referralCodes: ReferralCodeItemV5[]; +} + +================ +File: src/types/websockets/ws-events.ts +================ +import WebSocket from 'isomorphic-ws'; +⋮---- +import { + RFQItemV5, + RFQPublicTradeV5, + RFQQuoteItemV5, + RFQTradeV5, +} from '../response/v5-rfq'; +import { + CategoryV5, + ExecTypeV5, + OCOTriggerTypeV5, + OrderCancelTypeV5, + OrderCreateTypeV5, + OrderRejectReasonV5, + OrderSideV5, + OrderSMPTypeV5, + OrderStatusV5, + OrderTimeInForceV5, + OrderTriggerByV5, + OrderTypeV5, + PositionIdx, + PositionSideV5, + PositionStatusV5, + StopOrderTypeV5, + SystemStatusItemV5, + TPSLModeV5, + TradeModeV5, +} from '../shared-v5'; +import { WsKey } from './ws-general'; +⋮---- +export interface MessageEventLike { + target: WebSocket; + type: 'message'; + data: string; +} +⋮---- +export function isMessageEvent(msg: unknown): msg is MessageEventLike +⋮---- +export interface WSPublicTopicEventV5 { + id?: string; + topic: TTopic; + type: TType; + /** Cross sequence */ + cs?: number; + /** Event timestamp */ + ts: number; + data: TData; + /** + * matching engine timestamp (correlated with T from public trade channel) + */ + cts: number; + /** + * Internal reference, can be used to determine if this is spot/linear/inverse/etc + */ + wsKey: WsKey; +} +⋮---- +/** Cross sequence */ +⋮---- +/** Event timestamp */ +⋮---- +/** + * matching engine timestamp (correlated with T from public trade channel) + */ +⋮---- +/** + * Internal reference, can be used to determine if this is spot/linear/inverse/etc + */ +⋮---- +export interface WSPrivateTopicEventV5 { + id?: string; + topic: TTopic; + creationTime: number; + data: TData; + wsKey: WsKey; +} +⋮---- +export interface WSOrderbookV5 { + /** Symbol */ + s: string; + /** [price, qty][] */ + b: [string, string][]; + /** [price, qty][] */ + a: [string, string][]; + /** Update ID */ + u: number; + /** Cross sequence */ + seq: number; +} ⋮---- -/** tradfi trade volume in last 30 days. 0 when startDate/endDate in params */ +/** Symbol */ ⋮---- -/** tradfi trade volume in past year. 0 when startDate/endDate in params */ +/** [price, qty][] */ ⋮---- -/** Commission between startDate and endDate when startDate/endDate in params. Coin -> amount */ +/** [price, qty][] */ ⋮---- -/** Commission in last 30 days. Coin -> amount */ +/** Update ID */ ⋮---- -/** Commission in past year. Coin -> amount */ +/** Cross sequence */ ⋮---- -export interface AffiliateUserInfoV5 { - uid: string; - vipLevel: string; - takerVol30Day: string; - makerVol30Day: string; - tradeVol30Day: string; - depositAmount30Day: string; - takerVol365Day: string; - makerVol365Day: string; - tradeVol365Day: string; - depositAmount365Day: string; - totalWalletBalance: '1' | '2' | '3' | '4'; - depositUpdateTime: string; - volUpdateTime: string; - KycLevel: 0 | 1 | 2; - /** tradfi trade volume in last 30 days (USDT) */ - tradfiTradeVol30Day?: string; - /** tradfi trade volume in past year (USDT) */ - tradfiTradeVol365Day?: string; - /** tradfi commissions in last 30 days. Coin -> amount */ - commissions30Day?: Record; - /** tradfi commissions in past year. Coin -> amount */ - commissions365Day?: Record; - /** Payment amount in the last 30 days */ - paySendAmount30Day: string; - /** Pay first transaction amount */ - payFtt: string; - /** Card first-time transaction amount */ - cardFtt: string; +export type WSOrderbookEventV5 = WSPublicTopicEventV5< + string, + 'delta' | 'snapshot', + WSOrderbookV5 +>; +⋮---- +export interface WSTradeV5 { + T: number; + s: string; + S: OrderSideV5; + v: string; + p: string; + L?: string; + i: string; + BT: boolean; + RPI?: boolean; + mP?: string; + iP?: string; + mIv?: string; + iv?: string; } ⋮---- -/** tradfi trade volume in last 30 days (USDT) */ +export type WSTradeEventV5 = WSPublicTopicEventV5< + string, + 'snapshot', + WSTradeV5[] +>; ⋮---- -/** tradfi trade volume in past year (USDT) */ +export interface WSEventOrderbookV5 { + s: string; + r: [string, string][]; + u: number; + seq: number; +} ⋮---- -/** tradfi commissions in last 30 days. Coin -> amount */ +export type WSEventOrderbookEventV5 = WSPublicTopicEventV5< + string, + 'delta' | 'snapshot', + WSEventOrderbookV5 +>; ⋮---- -/** tradfi commissions in past year. Coin -> amount */ +export interface WSEventPublicTradeV5 { + T: number; + s: string; + r: string; + a: string; + i: string; + seq: number; +} ⋮---- -/** Payment amount in the last 30 days */ +export type WSEventPublicTradeEventV5 = WSPublicTopicEventV5< + string, + 'snapshot', + WSEventPublicTradeV5[] +>; ⋮---- -/** Pay first transaction amount */ +/** + * WSTickerV5 is the data structure for the "linear" ticker channel + * */ +export interface WSTickerV5 { + symbol: string; + tickDirection: string; + price24hPcnt: string; + lastPrice: string; + prevPrice24h: string; + highPrice24h: string; + lowPrice24h: string; + prevPrice1h: string; + markPrice: string; + indexPrice: string; + openInterest: string; + openInterestValue: string; + singleOpenInterest?: string; + singleOpenInterestValue?: string; + turnover24h: string; + volume24h: string; + nextFundingTime: string; + fundingRate: string; + bid1Price: string; + bid1Size: string; + ask1Price: string; + ask1Size: string; + deliveryTime?: string; + basisRate?: string; + deliveryFeeRate?: string; + predictedDeliveryPrice?: string; + preOpenPrice?: string; + preQty?: string; + curPreListingPhase?: string; + fundingIntervalHour?: string; + fundingCap?: string; + basisRateYear?: string; +} ⋮---- -/** Card first-time transaction amount */ +export interface WSTickerOptionV5 { + symbol: string; + bidPrice: string; + bidSize: string; + bidIv: string; + askPrice: string; + askSize: string; + askIv: string; + lastPrice: string; + highPrice24h: string; + lowPrice24h: string; + markPrice: string; + indexPrice: string; + markPriceIv: string; + underlyingPrice: string; + openInterest: string; + turnover24h: string; + volume24h: string; + totalVolume: string; + totalTurnover: string; + delta: string; + gamma: string; + vega: string; + theta: string; + predictedDeliveryPrice: string; + change24h: string; +} ⋮---- -export interface AffiliateSubAffiliateListItemV5 { - subAffId: string; - userId: string; - name: string; - email: string; - /** Commission per currency (BTC, ETH, MNT, USDC, USDT) for the queried date range */ - commissionsVol: Record; - commissionsForUsdt: string; - becameAffTime: string; - startDate: string; - endDate: string; +export interface WSTickerSpotV5 { + symbol: string; + lastPrice: string; + highPrice24h: string; + lowPrice24h: string; + prevPrice24h: string; + volume24h: string; + turnover24h: string; + price24hPcnt: string; + usdIndexPrice: string; } ⋮---- -/** Commission per currency (BTC, ETH, MNT, USDC, USDT) for the queried date range */ +export type WSTickerEventV5 = WSPublicTopicEventV5< + string, + 'snapshot' | 'delta', + WSTickerV5 | WSTickerOptionV5 | WSTickerSpotV5 +>; ⋮---- -export interface AffiliateSubAffiliateListResultV5 { - list: AffiliateSubAffiliateListItemV5[]; - nextPageCursor: string; +export interface WSKlineV5 { + start: number; + end: number; + interval: string; + open: string; + close: string; + high: string; + low: string; + volume: string; + turnover: string; + confirm: boolean; + timestamp: number; } ⋮---- -export interface FriendReferralRecordV5 { - id: string; - inviteeUid: string; - status: number; - createdAt: string; - updatedAt: string; +export type WSKlineEventV5 = WSPublicTopicEventV5< + string, + 'snapshot', + WSKlineV5[] +>; +⋮---- +export interface WSLiquidationV5 { + T: number; + s: string; + S: OrderSideV5; + v: string; + p: string; +} +⋮---- +export type WSLiquidationEventV5 = WSPublicTopicEventV5< + string, + 'snapshot', + WSLiquidationV5[] +>; +⋮---- +export interface WSPositionV5 { + category: string; + symbol: string; + side: PositionSideV5; + size: string; + positionIdx: PositionIdx; + tradeMode: TradeModeV5; + positionValue: string; + riskId: number; + riskLimitValue: string; + entryPrice: string; + markPrice: string; + leverage: string; + breakEvenPrice?: string; // Break even price, only for linear & inverse + positionBalance: string; + autoAddMargin: number; + positionMM: string; + positionIM: string; + positionIMByMp: string; + positionMMByMp: string; + liqPrice: string; + bustPrice: string; + tpslMode: string; + takeProfit: string; + stopLoss: string; + trailingStop: string; + unrealisedPnl: string; + curRealisedPnl: string; + sessionAvgPrice: string; + delta: string; + gamma: string; + vega: string; + theta: string; + cumRealisedPnl: string; + positionStatus: PositionStatusV5; + adlRankIndicator: number; + isReduceOnly: boolean; + mmrSysUpdatedTime: string; + leverageSysUpdatedTime: string; + createdTime: string; + updatedTime: string; + /** Position open timestamp (ms). Default `0` when not set. */ + openTime: number; + seq: number; + netDeltaRatio?: string; } ⋮---- -export interface ReferralCodeItemV5 { - referralCode: string; - referralLink: string; - scene: number; -} +breakEvenPrice?: string; // Break even price, only for linear & inverse ⋮---- -export interface ReferralCodesResultV5 { - referralCodes: ReferralCodeItemV5[]; -} - -================ -File: src/types/websockets/ws-events.ts -================ -import WebSocket from 'isomorphic-ws'; +/** Position open timestamp (ms). Default `0` when not set. */ ⋮---- -import { - RFQItemV5, - RFQPublicTradeV5, - RFQQuoteItemV5, - RFQTradeV5, -} from '../response/v5-rfq'; -import { - CategoryV5, - ExecTypeV5, - OCOTriggerTypeV5, - OrderCancelTypeV5, - OrderCreateTypeV5, - OrderRejectReasonV5, - OrderSideV5, - OrderSMPTypeV5, - OrderStatusV5, - OrderTimeInForceV5, - OrderTriggerByV5, - OrderTypeV5, - PositionIdx, - PositionSideV5, - PositionStatusV5, - StopOrderTypeV5, - SystemStatusItemV5, - TPSLModeV5, - TradeModeV5, -} from '../shared-v5'; -import { WsKey } from './ws-general'; +export type WSPositionEventV5 = WSPrivateTopicEventV5< + 'position', + WSPositionV5[] +>; ⋮---- -export interface MessageEventLike { - target: WebSocket; - type: 'message'; - data: string; +export interface WSEventPositionV5 { + symbol: string; + baseCoin: string; + settleCoin: string; + side: string; + ecContractType: string; + ecDirection: string; + avgPayoutRatio: string; + positionValue: string; + ecSettleTime: string; + cumClosedPnl: string; + createdTime: string; + updatedTime: string; + seq: number; } ⋮---- -export function isMessageEvent(msg: unknown): msg is MessageEventLike +export type WSEventPositionEventV5 = WSPrivateTopicEventV5< + 'position.event', + WSEventPositionV5[] +>; ⋮---- -export interface WSPublicTopicEventV5 { - id?: string; - topic: TTopic; - type: TType; - /** Cross sequence */ - cs?: number; - /** Event timestamp */ - ts: number; - data: TData; - /** - * matching engine timestamp (correlated with T from public trade channel) - */ - cts: number; - /** - * Internal reference, can be used to determine if this is spot/linear/inverse/etc - */ - wsKey: WsKey; +export interface WSAccountOrderV5 { + category: CategoryV5; + orderId: string; + orderLinkId: string; + parentOrderLinkId?: string; // Linked parent order for attached TP/SL orders (futures & options) + isLeverage: string; + blockTradeId: string; + symbol: string; + price: string; + qty: string; + side: OrderSideV5; + positionIdx: PositionIdx; + orderStatus: OrderStatusV5; + createType: OrderCreateTypeV5; + cancelType: OrderCancelTypeV5; + rejectReason?: OrderRejectReasonV5; + avgPrice?: string; + leavesQty?: string; + leavesValue?: string; + cumExecQty: string; + cumExecValue: string; + cumExecFee: string; + closedPnl: string; + feeCurrency: string; + timeInForce: OrderTimeInForceV5; + orderType: OrderTypeV5; + stopOrderType: StopOrderTypeV5; + ocoTriggerType?: OCOTriggerTypeV5; + orderIv: string; + marketUnit?: 'baseCoin' | 'quoteCoin'; + triggerPrice: string; + takeProfit: string; + stopLoss: string; + tpslMode?: TPSLModeV5; + tpLimitPrice?: string; + slLimitPrice?: string; + tpTriggerBy: string; + slTriggerBy: string; + triggerDirection: number; + triggerBy: OrderTriggerByV5; + lastPriceOnCreated: string; + reduceOnly: boolean; + closeOnTrigger: boolean; + placeType: string; + smpType: OrderSMPTypeV5; + smpGroup: string; + smpOrderId: string; + createdTime: string; + updatedTime: string; + cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee and feeCurrency + rpiTakerAccess?: boolean; + rpiMatchedQty?: string; } ⋮---- -/** Cross sequence */ -⋮---- -/** Event timestamp */ +parentOrderLinkId?: string; // Linked parent order for attached TP/SL orders (futures & options) ⋮---- -/** - * matching engine timestamp (correlated with T from public trade channel) - */ +cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee and feeCurrency ⋮---- -/** - * Internal reference, can be used to determine if this is spot/linear/inverse/etc - */ +export type WSAccountOrderEventV5 = WSPrivateTopicEventV5< + 'order', + WSAccountOrderV5[] +>; ⋮---- -export interface WSPrivateTopicEventV5 { - id?: string; - topic: TTopic; - creationTime: number; - data: TData; - wsKey: WsKey; +export interface WSEventOrderV5 { + category: 'event' | string; + orderId: string; + orderLinkId: string; + symbol: string; + symbolId: number; + side: string; + baseCoin: string; + quoteCoin: string; + settleCoin: string; + orderStatus: string; + ecContractType: string; + ecDirection: string; + ecDurationWindow: number; + ecTargetPrice: string; + ecLowerBound: string; + ecUpperBound: string; + ecOrderValue: string; + ecIndexPrice: string; + ecSettleTime: string; + payoutRatio: string; + orderAvgPayoutRatio: string; + cumExecValue: string; + cumExecFee: string; + leavesValue: string; + cumPayout: string; + createType: number; + cancelType: string; + rejectReason: string; + extraFees: unknown[]; + transTime: string; + createdTime: string; + updatedTime: string; } ⋮---- -export interface WSOrderbookV5 { - /** Symbol */ - s: string; - /** [price, qty][] */ - b: [string, string][]; - /** [price, qty][] */ - a: [string, string][]; - /** Update ID */ - u: number; - /** Cross sequence */ +export type WSEventOrderEventV5 = WSPrivateTopicEventV5< + 'order' | 'order.event', + WSEventOrderV5[] +>; +⋮---- +export interface WSExecutionV5 { + category: CategoryV5; + symbol: string; + isLeverage: string; + orderId: string; + orderLinkId: string; + side: OrderSideV5; + orderPrice: string; + orderQty: string; + leavesQty: string; + createType: OrderCreateTypeV5; + orderType: OrderTypeV5; + stopOrderType: StopOrderTypeV5; + execFee: string; + feeCurrency: string; // Trading fee currency + execId: string; + execPrice: string; + execQty: string; + execPnl: string; + execType: ExecTypeV5; + execValue: string; + execTime: string; + isMaker: boolean; + feeRate: string; + tradeIv: string; + markIv: string; + markPrice: string; + indexPrice: string; + underlyingPrice: string; + blockTradeId: string; + closedSize: string; + extraFees: string; seq: number; + marketUnit: string; } ⋮---- -/** Symbol */ -⋮---- -/** [price, qty][] */ -⋮---- -/** [price, qty][] */ -⋮---- -/** Update ID */ -⋮---- -/** Cross sequence */ +feeCurrency: string; // Trading fee currency ⋮---- -export type WSOrderbookEventV5 = WSPublicTopicEventV5< - string, - 'delta' | 'snapshot', - WSOrderbookV5 +export type WSExecutionEventV5 = WSPrivateTopicEventV5< + 'execution', + WSExecutionV5[] >; ⋮---- -export interface WSTradeV5 { - T: number; - s: string; - S: OrderSideV5; - v: string; - p: string; - L?: string; - i: string; - BT: boolean; - RPI?: boolean; - mP?: string; - iP?: string; - mIv?: string; - iv?: string; +export interface WSEventExecutionV5 { + category: 'event' | string; + transId: string; + execId: string; + orderId: string; + orderLinkId: string; + symbol: string; + symbolId: number; + baseCoin: string; + quoteCoin: string; + settleCoin: string; + side: string; + feeCoin: string; + execType: string; + execPrice: string; + execValue: string; + execFee: string; + execFeeRate: string; + orderPrice: string; + ecContractType: number | string; + ecDirection: number | string; + ecDurationWindow: number; + ecTargetPrice: string; + ecLowerBound: string; + ecUpperBound: string; + ecOrderValue: string; + ecIndexPrice?: string; + ecPayout: string; + entryPrice: string; + settlePrice: string; + grossPayoutRatio: string; + sessionRpl: string; + transTime: string; + settleTimeMs: string; + crossSeq: string; + timeInForce: string; + extraFees: unknown[]; } ⋮---- -export type WSTradeEventV5 = WSPublicTopicEventV5< - string, - 'snapshot', - WSTradeV5[] +export type WSEventExecutionEventV5 = WSPrivateTopicEventV5< + 'execution' | 'execution.event', + WSEventExecutionV5[] >; ⋮---- -export interface WSEventOrderbookV5 { - s: string; - r: [string, string][]; - u: number; +export interface WSExecutionFastV5 { + category: CategoryV5; + symbol: string; + execId: string; + execPrice: string; + execQty: string; + orderId: string; + isMaker: boolean; + orderLinkId: string; + side: OrderSideV5; + execTime: string; seq: number; + liquidity?: string; } ⋮---- -export type WSEventOrderbookEventV5 = WSPublicTopicEventV5< - string, - 'delta' | 'snapshot', - WSEventOrderbookV5 +export type WSExecutionFastEventV5 = WSPrivateTopicEventV5< + 'execution.fast', + WSExecutionFastV5[] >; ⋮---- -export interface WSEventPublicTradeV5 { - T: number; - s: string; - r: string; - a: string; - i: string; - seq: number; +export interface WSCoinV5 { + coin: string; + equity: string; + usdValue: string; + walletBalance: string; + free?: string; + locked: string; + spotHedgingQty: string; + borrowAmount: string; + availableToBorrow: string; + availableToWithdraw: string; + accruedInterest: string; + totalOrderIM: string; + totalPositionIM: string; + totalPositionMM: string; + unrealisedPnl: string; + cumRealisedPnl: string; + bonus: string; + collateralSwitch: boolean; + marginCollateral: boolean; + spotBorrow: string; + colRes?: string; } ⋮---- -export type WSEventPublicTradeEventV5 = WSPublicTopicEventV5< - string, - 'snapshot', - WSEventPublicTradeV5[] ->; +export interface WSWalletV5 { + accountType: string; + accountLTV: string; + accountIMRate: string; + accountMMRate: string; + accountIMRateByMp: string; + accountMMRateByMp: string; + totalInitialMarginByMp: string; + totalMaintenanceMarginByMp: string; + totalEquity: string; + totalWalletBalance: string; + totalMarginBalance: string; + totalAvailableBalance: string; + totalPerpUPL: string; + totalInitialMargin: string; + totalMaintenanceMargin: string; + coin: WSCoinV5[]; +} ⋮---- -/** - * WSTickerV5 is the data structure for the "linear" ticker channel - * */ -export interface WSTickerV5 { - symbol: string; - tickDirection: string; - price24hPcnt: string; - lastPrice: string; - prevPrice24h: string; - highPrice24h: string; - lowPrice24h: string; - prevPrice1h: string; - markPrice: string; - indexPrice: string; - openInterest: string; - openInterestValue: string; - singleOpenInterest?: string; - singleOpenInterestValue?: string; - turnover24h: string; - volume24h: string; - nextFundingTime: string; - fundingRate: string; - bid1Price: string; - bid1Size: string; - ask1Price: string; - ask1Size: string; - deliveryTime?: string; - basisRate?: string; - deliveryFeeRate?: string; - predictedDeliveryPrice?: string; - preOpenPrice?: string; - preQty?: string; - curPreListingPhase?: string; - fundingIntervalHour?: string; - fundingCap?: string; - basisRateYear?: string; +export type WSWalletEventV5 = WSPrivateTopicEventV5<'wallet', WSWalletV5[]>; +⋮---- +export interface WSGreeksV5 { + baseCoin: string; + totalDelta: string; + totalGamma: string; + totalVega: string; + totalTheta: string; } ⋮---- -export interface WSTickerOptionV5 { +export type WSGreeksEventV5 = WSPrivateTopicEventV5<'greeks', WSGreeksV5[]>; +⋮---- +export interface WSSpreadOrderV5 { + category: 'combination' | 'spot_leg' | 'future_leg'; symbol: string; - bidPrice: string; - bidSize: string; - bidIv: string; - askPrice: string; - askSize: string; - askIv: string; - lastPrice: string; - highPrice24h: string; - lowPrice24h: string; - markPrice: string; - indexPrice: string; - markPriceIv: string; - underlyingPrice: string; - openInterest: string; - turnover24h: string; - volume24h: string; - totalVolume: string; - totalTurnover: string; - delta: string; - gamma: string; - vega: string; - theta: string; - predictedDeliveryPrice: string; - change24h: string; + parentOrderId: string; + orderId: string; + orderLinkId: string; + side: OrderSideV5; + orderStatus: OrderStatusV5; + cancelType: OrderCancelTypeV5; + rejectReason: OrderRejectReasonV5; + timeInForce: OrderTimeInForceV5; + price: string; + qty: string; + avgPrice: string; + leavesQty: string; + leavesValue: string; + cumExecQty: string; + cumExecValue: string; + cumExecFee: string; + orderType: OrderTypeV5; + isLeverage: string; + createdTime: string; + updatedTime: string; + feeCurrency: string; + createType: OrderCreateTypeV5; + closedPnl: string; + cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee and feeCurrency } ⋮---- -export interface WSTickerSpotV5 { +cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee and feeCurrency +⋮---- +export type WSSpreadOrderEventV5 = WSPrivateTopicEventV5< + 'spread.order', + WSSpreadOrderV5[] +>; +⋮---- +export interface WSSpreadExecutionV5 { + category: 'combination' | 'spot_leg' | 'future_leg'; symbol: string; - lastPrice: string; - highPrice24h: string; - lowPrice24h: string; - prevPrice24h: string; - volume24h: string; - turnover24h: string; - price24hPcnt: string; - usdIndexPrice: string; + isLeverage: string; + orderId: string; + orderLinkId: string; + side: OrderSideV5; + orderPrice: string; + orderQty: string; + leavesQty: string; + createType: OrderCreateTypeV5; + orderType: OrderTypeV5; + execFee: string; + execFeeV2: string; + feeCurrency: string; // Trading fee currency + parentExecId: string; + execId: string; + execPrice: string; + execQty: string; + execPnl: string; + execType: ExecTypeV5; + execValue: string; + execTime: string; + isMaker: boolean; + feeRate: string; + markPrice: string; + closedSize: string; + seq: number; } ⋮---- -export type WSTickerEventV5 = WSPublicTopicEventV5< - string, +feeCurrency: string; // Trading fee currency +⋮---- +export type WSSpreadExecutionEventV5 = WSPrivateTopicEventV5< + 'spread.execution', + WSSpreadExecutionV5[] +>; +⋮---- +export interface WSInsuranceV5 { + coin: string; + symbols: string; + balance: string; + updateTime: string; +} +⋮---- +export type WSInsuranceEventV5 = WSPublicTopicEventV5< + 'insurance.USDT' | 'insurance.USDC' | 'insurance.inverse', 'snapshot' | 'delta', - WSTickerV5 | WSTickerOptionV5 | WSTickerSpotV5 + WSInsuranceV5[] >; ⋮---- -export interface WSKlineV5 { - start: number; - end: number; - interval: string; - open: string; - close: string; - high: string; - low: string; - volume: string; - turnover: string; - confirm: boolean; - timestamp: number; +export interface WSPriceLimitV5 { + symbol: string; + buyLmt: string; + sellLmt: string; } ⋮---- -export type WSKlineEventV5 = WSPublicTopicEventV5< +export type WSPriceLimitEventV5 = WSPublicTopicEventV5< string, 'snapshot', - WSKlineV5[] + WSPriceLimitV5 >; ⋮---- -export interface WSLiquidationV5 { - T: number; - s: string; - S: OrderSideV5; - v: string; - p: string; +export interface WSADLAlertV5 { + c: string; // Token of the insurance pool + s: string; // Trading pair name + b: string; // Balance of the insurance fund. For shared insurance pool, follows T+1 refresh (updated daily at 00:00 UTC) + mb: string; // Deprecated: always returns empty string. Previously: Maximum balance of the insurance pool in the last 8 hours + i_pr: string; // PnL ratio threshold for triggering contract PnL drawdown ADL + pr: string; // Symbol's PnL drawdown ratio in the last 8 hours. Used to determine whether ADL is triggered or stopped + adl_tt: string; // Trigger threshold for contract PnL drawdown ADL + adl_sr: string; // Stop ratio threshold for contract PnL drawdown ADL } ⋮---- -export type WSLiquidationEventV5 = WSPublicTopicEventV5< - string, +c: string; // Token of the insurance pool +s: string; // Trading pair name +b: string; // Balance of the insurance fund. For shared insurance pool, follows T+1 refresh (updated daily at 00:00 UTC) +mb: string; // Deprecated: always returns empty string. Previously: Maximum balance of the insurance pool in the last 8 hours +i_pr: string; // PnL ratio threshold for triggering contract PnL drawdown ADL +pr: string; // Symbol's PnL drawdown ratio in the last 8 hours. Used to determine whether ADL is triggered or stopped +adl_tt: string; // Trigger threshold for contract PnL drawdown ADL +adl_sr: string; // Stop ratio threshold for contract PnL drawdown ADL +⋮---- +export type WSADLAlertEventV5 = WSPublicTopicEventV5< + 'adlAlert.USDT' | 'adlAlert.USDC' | 'adlAlert.inverse', 'snapshot', - WSLiquidationV5[] + WSADLAlertV5[] >; ⋮---- -export interface WSPositionV5 { - category: string; - symbol: string; - side: PositionSideV5; - size: string; - positionIdx: PositionIdx; - tradeMode: TradeModeV5; - positionValue: string; - riskId: number; - riskLimitValue: string; - entryPrice: string; - markPrice: string; - leverage: string; - breakEvenPrice?: string; // Break even price, only for linear & inverse - positionBalance: string; - autoAddMargin: number; - positionMM: string; - positionIM: string; - positionIMByMp: string; - positionMMByMp: string; - liqPrice: string; - bustPrice: string; - tpslMode: string; - takeProfit: string; - stopLoss: string; - trailingStop: string; - unrealisedPnl: string; - curRealisedPnl: string; - sessionAvgPrice: string; - delta: string; - gamma: string; - vega: string; - theta: string; - cumRealisedPnl: string; - positionStatus: PositionStatusV5; - adlRankIndicator: number; - isReduceOnly: boolean; - mmrSysUpdatedTime: string; - leverageSysUpdatedTime: string; - createdTime: string; - updatedTime: string; - /** Position open timestamp (ms). Default `0` when not set. */ - openTime: number; - seq: number; - netDeltaRatio?: string; -} +export type WSSystemStatusEventV5 = WSPublicTopicEventV5< + 'system.status', + 'snapshot', + SystemStatusItemV5[] +>; +⋮---- +/** + * RFQ WebSocket Events + */ +⋮---- +/** + * RFQ Inquiry Channel + * Private push for RFQ inquiries sent or received by the user + * Topics: rfq.open.rfqs, rfq.site.rfqs + */ +export type WSRFQInquiryEventV5 = WSPrivateTopicEventV5< + 'rfq.open.rfqs' | 'rfq.site.rfqs', + RFQItemV5[] +>; +⋮---- +/** + * RFQ Quote Channel + * Private push for quotes sent or received by the user + * Topics: rfq.open.quotes, rfq.site.quotes + */ +export type WSRFQQuoteEventV5 = WSPrivateTopicEventV5< + 'rfq.open.quotes' | 'rfq.site.quotes', + RFQQuoteItemV5[] +>; +⋮---- +/** + * RFQ Trade Channel + * Private push for block trades executed by the user + * Topics: rfq.open.trades, rfq.site.trades + */ +export type WSRFQTradeEventV5 = WSPrivateTopicEventV5< + 'rfq.open.trades' | 'rfq.site.trades', + RFQTradeV5[] +>; +⋮---- +/** + * RFQ Public Trade Channel + * Public push for all block trades + * Topics: rfq.open.public.trades, rfq.site.public.trades + */ +export type WSRFQPublicTradeEventV5 = WSPublicTopicEventV5< + 'rfq.open.public.trades' | 'rfq.site.public.trades', + 'snapshot', + RFQPublicTradeV5[] +>; + +================ +File: src/types/shared-v5.ts +================ +export type CategoryV5 = 'spot' | 'linear' | 'inverse' | 'option'; +/** Public WS subscribe/routing category. Event Contract uses `'event'`; REST `CategoryV5` does not. */ +export type WSCategoryV5 = CategoryV5 | 'event'; +export type ContractTypeV5 = + | 'InversePerpetual' + | 'LinearPerpetual' + | 'InverseFutures'; +export type CopyTradingV5 = 'none' | 'both' | 'utaOnly' | 'normalOnly'; +⋮---- +export type InstrumentStatusV5 = + | 'PreLaunch' + | 'PendingOpen' + | 'Trading' + | 'Settling' + | 'Delivering' + | 'Closed'; +⋮---- +/** + * Region / product class returned as `symbolType` on instruments-info (and account instruments-info). + * For `category=linear`, includes e.g. `stock`, `forex`, `commodity`, `xstocks`. Spot may return `''`. + */ +export type InstrumentSymbolTypeV5 = + | '' + | 'stock' + | 'forex' + | 'commodity' + | 'xstocks'; +⋮---- +export type MarginTradingV5 = 'none' | 'both' | 'utaOnly' | 'normalSpotOnly'; +⋮---- +/** Product type for strategy APIs (create / list). */ +export type StrategyCategoryV5 = + | 'UTA_USDT' + | 'UTA_USDC' + | 'UTA_USDC_FUTURE' + | 'UTA_SPOT' + | 'UTA_INVERSE' + | 'UTA_INVERSE_FUTURE' + | 'UTA_USDT_FUTURE'; ⋮---- -breakEvenPrice?: string; // Break even price, only for linear & inverse +export type StrategyTypeV5 = 'twap' | 'chaseOrder' | 'iceberg' | 'pov'; ⋮---- -/** Position open timestamp (ms). Default `0` when not set. */ +export type StrategyPreferV5 = + | 'limit' + | 'priceSpeedBalance' + | 'fastestExecution' + | 'quickExecution'; ⋮---- -export type WSPositionEventV5 = WSPrivateTopicEventV5< - 'position', - WSPositionV5[] ->; +/** POV strategy execution mode */ +export type PovModeV5 = + | 'TradedVolume' + | 'OppositeSideLiquidity' + | 'SameSideLiquidity'; ⋮---- -export interface WSEventPositionV5 { - symbol: string; - baseCoin: string; - settleCoin: string; - side: string; - ecContractType: string; - ecDirection: string; - avgPayoutRatio: string; - positionValue: string; - ecSettleTime: string; - cumClosedPnl: string; - createdTime: string; - updatedTime: string; - seq: number; -} +export type OrderFilterV5 = 'Order' | 'tpslOrder' | 'StopOrder'; +export type OrderSideV5 = 'Buy' | 'Sell'; +export type OrderTypeV5 = 'Market' | 'Limit'; +export type OrderTimeInForceV5 = 'GTC' | 'IOC' | 'FOK' | 'PostOnly' | 'RPI'; +export type OrderTriggerByV5 = 'LastPrice' | 'IndexPrice' | 'MarkPrice'; +export type OCOTriggerTypeV5 = + | 'OcoTriggerByUnknown' + | 'OcoTriggerTp' + | 'OcoTriggerBySl'; ⋮---- -export type WSEventPositionEventV5 = WSPrivateTopicEventV5< - 'position.event', - WSEventPositionV5[] ->; +export type OrderSMPTypeV5 = + | 'None' + | 'CancelMaker' + | 'CancelTaker' + | 'CancelBoth'; ⋮---- -export interface WSAccountOrderV5 { - category: CategoryV5; - orderId: string; - orderLinkId: string; - parentOrderLinkId?: string; // Linked parent order for attached TP/SL orders (futures & options) - isLeverage: string; - blockTradeId: string; - symbol: string; - price: string; - qty: string; - side: OrderSideV5; - positionIdx: PositionIdx; - orderStatus: OrderStatusV5; - createType: OrderCreateTypeV5; - cancelType: OrderCancelTypeV5; - rejectReason?: OrderRejectReasonV5; - avgPrice?: string; - leavesQty?: string; - leavesValue?: string; - cumExecQty: string; - cumExecValue: string; - cumExecFee: string; - closedPnl: string; - feeCurrency: string; - timeInForce: OrderTimeInForceV5; - orderType: OrderTypeV5; - stopOrderType: StopOrderTypeV5; - ocoTriggerType?: OCOTriggerTypeV5; - orderIv: string; - marketUnit?: 'baseCoin' | 'quoteCoin'; - triggerPrice: string; - takeProfit: string; - stopLoss: string; - tpslMode?: TPSLModeV5; - tpLimitPrice?: string; - slLimitPrice?: string; - tpTriggerBy: string; - slTriggerBy: string; - triggerDirection: number; - triggerBy: OrderTriggerByV5; - lastPriceOnCreated: string; - reduceOnly: boolean; - closeOnTrigger: boolean; - placeType: string; - smpType: OrderSMPTypeV5; - smpGroup: string; - smpOrderId: string; - createdTime: string; - updatedTime: string; - cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee and feeCurrency - rpiTakerAccess?: boolean; - rpiMatchedQty?: string; -} +export type OrderStatusV5 = + | 'Created' + | 'New' + | 'Rejected' + | 'PartiallyFilled' + | 'PartiallyFilledCanceled' + | 'Filled' + | 'Cancelled' + | 'Untriggered' + | 'Triggered' + | 'Deactivated' + | 'Active'; ⋮---- -parentOrderLinkId?: string; // Linked parent order for attached TP/SL orders (futures & options) +/** + * Defines the types of order creation mechanisms. + */ +export type OrderCreateTypeV5 = + /** Represents an order created by a user. */ + | 'CreateByUser' + /** Represents an order created by an admin closing. */ + | 'CreateByAdminClosing' + /** Futures conditional order. */ + | 'CreateByStopOrder' + /** Futures take profit order. */ + | 'CreateByTakeProfit' + /** Futures partial take profit order. */ + | 'CreateByPartialTakeProfit' + /** Futures stop loss order. */ + | 'CreateByStopLoss' + /** Futures partial stop loss order. */ + | 'CreateByPartialStopLoss' + /** Futures trailing stop order. */ + | 'CreateByTrailingStop' + /** Laddered liquidation to reduce the required maintenance margin. */ + | 'CreateByLiq' + /** + * If the position is still subject to liquidation (i.e., does not meet the required maintenance margin level), + * the position shall be taken over by the liquidation engine and closed at the bankruptcy price. + */ + | 'CreateByTakeOver_PassThrough' + /** Auto-Deleveraging(ADL) */ + | 'CreateByAdl_PassThrough' + /** Order placed via Paradigm. */ + | 'CreateByBlock_PassThrough' + /** Order created by move position. */ + | 'CreateByBlockTradeMovePosition_PassThrough' + /** The close order placed via web or app position area - web/app. */ + | 'CreateByClosing' + /** Order created via grid bot - web/app. */ + | 'CreateByFGridBot' + /** Order closed via grid bot - web/app. */ + | 'CloseByFGridBot' + /** Order created by TWAP - web/app. */ + | 'CreateByTWAP' + /** Order created by TV webhook - web/app. */ + | 'CreateByTVSignal' + /** Order created by Mm rate close function - web/app. */ + | 'CreateByMmRateClose' + /** Order created by Martingale bot - web/app. */ + | 'CreateByMartingaleBot' + /** Order closed by Martingale bot - web/app. */ + | 'CloseByMartingaleBot' + /** Order created by Ice berg strategy - web/app. */ + | 'CreateByIceBerg' + /** Order created by arbitrage - web/app. */ + | 'CreateByArbitrage' + /** Option dynamic delta hedge order - web/app */ + | 'CreateByDdh' + /** BBO Order - Best Bid/Offer order */ + | 'CreateByBboOrder'; ⋮---- -cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee and feeCurrency +/** Represents an order created by a user. */ ⋮---- -export type WSAccountOrderEventV5 = WSPrivateTopicEventV5< - 'order', - WSAccountOrderV5[] ->; +/** Represents an order created by an admin closing. */ ⋮---- -export interface WSEventOrderV5 { - category: 'event' | string; - orderId: string; - orderLinkId: string; - symbol: string; - symbolId: number; - side: string; - baseCoin: string; - quoteCoin: string; - settleCoin: string; - orderStatus: string; - ecContractType: string; - ecDirection: string; - ecDurationWindow: number; - ecTargetPrice: string; - ecLowerBound: string; - ecUpperBound: string; - ecOrderValue: string; - ecIndexPrice: string; - ecSettleTime: string; - payoutRatio: string; - orderAvgPayoutRatio: string; - cumExecValue: string; - cumExecFee: string; - leavesValue: string; - cumPayout: string; - createType: number; - cancelType: string; - rejectReason: string; - extraFees: unknown[]; - transTime: string; - createdTime: string; - updatedTime: string; -} +/** Futures conditional order. */ ⋮---- -export type WSEventOrderEventV5 = WSPrivateTopicEventV5< - 'order' | 'order.event', - WSEventOrderV5[] ->; +/** Futures take profit order. */ ⋮---- -export interface WSExecutionV5 { - category: CategoryV5; - symbol: string; - isLeverage: string; - orderId: string; - orderLinkId: string; - side: OrderSideV5; - orderPrice: string; - orderQty: string; - leavesQty: string; - createType: OrderCreateTypeV5; - orderType: OrderTypeV5; - stopOrderType: StopOrderTypeV5; - execFee: string; - feeCurrency: string; // Trading fee currency - execId: string; - execPrice: string; - execQty: string; - execPnl: string; - execType: ExecTypeV5; - execValue: string; - execTime: string; - isMaker: boolean; - feeRate: string; - tradeIv: string; - markIv: string; - markPrice: string; - indexPrice: string; - underlyingPrice: string; - blockTradeId: string; - closedSize: string; - extraFees: string; - seq: number; - marketUnit: string; -} +/** Futures partial take profit order. */ ⋮---- -feeCurrency: string; // Trading fee currency +/** Futures stop loss order. */ ⋮---- -export type WSExecutionEventV5 = WSPrivateTopicEventV5< - 'execution', - WSExecutionV5[] ->; +/** Futures partial stop loss order. */ ⋮---- -export interface WSEventExecutionV5 { - category: 'event' | string; - transId: string; - execId: string; - orderId: string; - orderLinkId: string; - symbol: string; - symbolId: number; - baseCoin: string; - quoteCoin: string; - settleCoin: string; - side: string; - feeCoin: string; - execType: string; - execPrice: string; - execValue: string; - execFee: string; - execFeeRate: string; - orderPrice: string; - ecContractType: number | string; - ecDirection: number | string; - ecDurationWindow: number; - ecTargetPrice: string; - ecLowerBound: string; - ecUpperBound: string; - ecOrderValue: string; - ecIndexPrice?: string; - ecPayout: string; - entryPrice: string; - settlePrice: string; - grossPayoutRatio: string; - sessionRpl: string; - transTime: string; - settleTimeMs: string; - crossSeq: string; - timeInForce: string; - extraFees: unknown[]; -} +/** Futures trailing stop order. */ ⋮---- -export type WSEventExecutionEventV5 = WSPrivateTopicEventV5< - 'execution' | 'execution.event', - WSEventExecutionV5[] ->; +/** Laddered liquidation to reduce the required maintenance margin. */ ⋮---- -export interface WSExecutionFastV5 { - category: CategoryV5; - symbol: string; - execId: string; - execPrice: string; - execQty: string; - orderId: string; - isMaker: boolean; - orderLinkId: string; - side: OrderSideV5; - execTime: string; - seq: number; - liquidity?: string; -} +/** + * If the position is still subject to liquidation (i.e., does not meet the required maintenance margin level), + * the position shall be taken over by the liquidation engine and closed at the bankruptcy price. + */ ⋮---- -export type WSExecutionFastEventV5 = WSPrivateTopicEventV5< - 'execution.fast', - WSExecutionFastV5[] ->; +/** Auto-Deleveraging(ADL) */ ⋮---- -export interface WSCoinV5 { - coin: string; - equity: string; - usdValue: string; - walletBalance: string; - free?: string; - locked: string; - spotHedgingQty: string; - borrowAmount: string; - availableToBorrow: string; - availableToWithdraw: string; - accruedInterest: string; - totalOrderIM: string; - totalPositionIM: string; - totalPositionMM: string; - unrealisedPnl: string; - cumRealisedPnl: string; - bonus: string; - collateralSwitch: boolean; - marginCollateral: boolean; - spotBorrow: string; - colRes?: string; -} +/** Order placed via Paradigm. */ ⋮---- -export interface WSWalletV5 { - accountType: string; - accountLTV: string; - accountIMRate: string; - accountMMRate: string; - accountIMRateByMp: string; - accountMMRateByMp: string; - totalInitialMarginByMp: string; - totalMaintenanceMarginByMp: string; - totalEquity: string; - totalWalletBalance: string; - totalMarginBalance: string; - totalAvailableBalance: string; - totalPerpUPL: string; - totalInitialMargin: string; - totalMaintenanceMargin: string; - coin: WSCoinV5[]; -} +/** Order created by move position. */ ⋮---- -export type WSWalletEventV5 = WSPrivateTopicEventV5<'wallet', WSWalletV5[]>; +/** The close order placed via web or app position area - web/app. */ ⋮---- -export interface WSGreeksV5 { - baseCoin: string; - totalDelta: string; - totalGamma: string; - totalVega: string; - totalTheta: string; -} +/** Order created via grid bot - web/app. */ ⋮---- -export type WSGreeksEventV5 = WSPrivateTopicEventV5<'greeks', WSGreeksV5[]>; +/** Order closed via grid bot - web/app. */ ⋮---- -export interface WSSpreadOrderV5 { - category: 'combination' | 'spot_leg' | 'future_leg'; - symbol: string; - parentOrderId: string; - orderId: string; - orderLinkId: string; - side: OrderSideV5; - orderStatus: OrderStatusV5; - cancelType: OrderCancelTypeV5; - rejectReason: OrderRejectReasonV5; - timeInForce: OrderTimeInForceV5; - price: string; - qty: string; - avgPrice: string; - leavesQty: string; - leavesValue: string; - cumExecQty: string; - cumExecValue: string; - cumExecFee: string; - orderType: OrderTypeV5; - isLeverage: string; - createdTime: string; - updatedTime: string; - feeCurrency: string; - createType: OrderCreateTypeV5; - closedPnl: string; - cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee and feeCurrency -} +/** Order created by TWAP - web/app. */ ⋮---- -cumFeeDetail?: Record; // Cumulative trading fee details instead of cumExecFee and feeCurrency +/** Order created by TV webhook - web/app. */ ⋮---- -export type WSSpreadOrderEventV5 = WSPrivateTopicEventV5< - 'spread.order', - WSSpreadOrderV5[] ->; +/** Order created by Mm rate close function - web/app. */ +⋮---- +/** Order created by Martingale bot - web/app. */ +⋮---- +/** Order closed by Martingale bot - web/app. */ +⋮---- +/** Order created by Ice berg strategy - web/app. */ +⋮---- +/** Order created by arbitrage - web/app. */ +⋮---- +/** Option dynamic delta hedge order - web/app */ +⋮---- +/** BBO Order - Best Bid/Offer order */ +⋮---- +export type OrderCancelTypeV5 = + | 'CancelByUser' + | 'CancelByReduceOnly' + | 'CancelByPrepareLiq' + | 'CancelAllBeforeLiq' + | 'CancelByPrepareAdl' + | 'CancelAllBeforeAdl' + | 'CancelByAdmin' + | 'CancelByTpSlTsClear' + | 'CancelByPzSideCh' + | 'UNKNOWN'; +⋮---- +export type OrderRejectReasonV5 = + | 'EC_NoError' + | 'EC_Others' + | 'EC_UnknownMessageType' + | 'EC_MissingClOrdID' + | 'EC_MissingOrigClOrdID' + | 'EC_ClOrdIDOrigClOrdIDAreTheSame' + | 'EC_DuplicatedClOrdID' + | 'EC_OrigClOrdIDDoesNotExist' + | 'EC_TooLateToCancel' + | 'EC_UnknownOrderType' + | 'EC_UnknownSide' + | 'EC_UnknownTimeInForce' + | 'EC_WronglyRouted' + | 'EC_MarketOrderPriceIsNotZero' + | 'EC_LimitOrderInvalidPrice' + | 'EC_NoEnoughQtyToFill' + | 'EC_NoImmediateQtyToFill' + | 'EC_PerCancelRequest' + | 'EC_MarketOrderCannotBePostOnly' + | 'EC_PostOnlyWillTakeLiquidity' + | 'EC_CancelReplaceOrder' + | 'EC_InvalidSymbolStatus'; +⋮---- +export type StopOrderTypeV5 = + | 'TakeProfit' + | 'StopLoss' + | 'TrailingStop' + | 'Stop' + | 'PartialTakeProfit' + | 'PartialStopLoss' + | 'tpslOrder' + | 'OcoOrder' + | 'MmRateClose' + | 'BidirectionalTpslOrder'; +⋮---- +/** + * Position index. Used to identify positions in different position modes. + * + * - 0 one-way mode position + * - 1 Buy side of hedge-mode position + * - 2 Sell side of hedge-mode position + */ +export type PositionIdx = 0 | 1 | 2; +⋮---- +/** + * Position status. + * + * - 'Normal' + * - 'Liq' in the liquidation progress + * - 'Adl' in the auto-deleverage progress + */ +export type PositionStatusV5 = 'Normal' | 'Liq' | 'Adl'; +export type PositionSideV5 = 'Buy' | 'Sell' | 'None' | ''; +⋮---- +export type OptionTypeV5 = 'Call' | 'Put'; +⋮---- +/** + * Trade mode. + * + * - 0 cross-margin, + * - 1 isolated margin + */ +export type TradeModeV5 = 0 | 1; +⋮---- +export type TPSLModeV5 = 'Full' | 'Partial'; +export type AccountMarginModeV5 = + | 'ISOLATED_MARGIN' + | 'REGULAR_MARGIN' + | 'PORTFOLIO_MARGIN'; +export type UnifiedUpdateStatusV5 = 'FAIL' | 'PROCESS' | 'SUCCESS'; ⋮---- -export interface WSSpreadExecutionV5 { - category: 'combination' | 'spot_leg' | 'future_leg'; - symbol: string; - isLeverage: string; - orderId: string; - orderLinkId: string; - side: OrderSideV5; - orderPrice: string; - orderQty: string; - leavesQty: string; - createType: OrderCreateTypeV5; - orderType: OrderTypeV5; - execFee: string; - execFeeV2: string; - feeCurrency: string; // Trading fee currency - parentExecId: string; - execId: string; - execPrice: string; - execQty: string; - execPnl: string; - execType: ExecTypeV5; - execValue: string; - execTime: string; - isMaker: boolean; - feeRate: string; - markPrice: string; - closedSize: string; - seq: number; -} +export type AccountTypeV5 = + | 'CONTRACT' + | 'SPOT' + | 'INVESTMENT' + | 'OPTION' + | 'UNIFIED' + | 'FUND' + | 'EARN'; ⋮---- -feeCurrency: string; // Trading fee currency +export type TransactionTypeV5 = + | 'TRANSFER_IN' + | 'TRANSFER_OUT' + | 'TRADE' + | 'SETTLEMENT' + | 'DELIVERY' + | 'LIQUIDATION' + | 'ADL' + | 'AIRDROP' + | 'BONUS_RECOLLECT' + | 'BONUS_RECOLLECT' + | 'FEE_REFUND' + | 'INTEREST' + | 'CURRENCY_BUY' + | 'CURRENCY_SELL' + | 'BORROWED_AMOUNT_INS_LOAN' + | 'PRINCIPLE_REPAYMENT_INS_LOAN' + | 'INTEREST_REPAYMENT_INS_LOAN' + | 'AUTO_SOLD_COLLATERAL_INS_LOAN' + | 'AUTO_BUY_LIABILITY_INS_LOAN' + | 'AUTO_PRINCIPLE_REPAYMENT_INS_LOAN' + | 'AUTO_INTEREST_REPAYMENT_INS_LOAN' + | 'TRANSFER_IN_INS_LOAN' + | 'TRANSFER_OUT_INS_LOAN' + | 'SPOT_REPAYMENT_SELL' + | 'SPOT_REPAYMENT_BUY' + | 'TOKENS_SUBSCRIPTION' + | 'TOKENS_REDEMPTION' + | 'AUTO_DEDUCTION' + | 'FLEXIBLE_STAKING_SUBSCRIPTION' + | 'FLEXIBLE_STAKING_REDEMPTION' + | 'FIXED_STAKING_SUBSCRIPTION' + | 'BORROWED_AMOUNT_INS_LOAN' + | 'PRINCIPLE_REPAYMENT_INS_LOAN' + | 'INTEREST_REPAYMENT_INS_LOAN' + | 'AUTO_SOLD_COLLATERAL_INS_LOAN' + | 'AUTO_BUY_LIABILITY_INS_LOAN' + | 'AUTO_PRINCIPLE_REPAYMENT_INS_LOAN' + | 'AUTO_INTEREST_REPAYMENT_INS_LOAN' + | 'TRANSFER_IN_INS_LOAN' + | 'TRANSFER_OUT_INS_LOAN' + | 'SPOT_REPAYMENT_SELL' + | 'SPOT_REPAYMENT_BUY' + | 'TOKENS_SUBSCRIPTION' + | 'TOKENS_REDEMPTION' + | 'AUTO_DEDUCTION' + | 'FLEXIBLE_STAKING_SUBSCRIPTION' + | 'FLEXIBLE_STAKING_REDEMPTION' + | 'FIXED_STAKING_SUBSCRIPTION' + | 'FLEXIBLE_STAKING_REFUND' + | 'FIXED_STAKING_REFUND' + | 'PREMARKET_TRANSFER_OUT' + | 'PREMARKET_DELIVERY_SELL_NEW_COIN' + | 'PREMARKET_DELIVERY_BUY_NEW_COIN' + | 'PREMARKET_DELIVERY_PLEDGE_PAY_SELLER' + | 'PREMARKET_DELIVERY_PLEDGE_BACK' + | 'PREMARKET_ROLLBACK_PLEDGE_BACK' + | 'PREMARKET_ROLLBACK_PLEDGE_PENALTY_TO_BUYER' + | 'CUSTODY_NETWORK_FEE' + | 'CUSTODY_SETTLE_FEE' + | 'CUSTODY_LOCK' + | 'CUSTODY_UNLOCK' + | 'CUSTODY_UNLOCK_REFUND' + | 'LOANS_BORROW_FUNDS' + | 'LOANS_PLEDGE_ASSET' + | 'BONUS_TRANSFER_IN' + | 'BONUS_TRANSFER_OUT' + | 'PEF_TRANSFER_IN' + | 'PEF_TRANSFER_OUT' + | 'PEF_PROFIT_SHARE' + | 'ONCHAINEARN_SUBSCRIPTION' + | 'ONCHAINEARN_REDEMPTION' + | 'ONCHAINEARN_REFUND' + | 'STRUCTURE_PRODUCT_SUBSCRIPTION' + | 'STRUCTURE_PRODUCT_REFUND' + | 'CLASSIC_WEALTH_MANAGEMENT_SUBSCRIPTION' + | 'PREMIMUM_WEALTH_MANAGEMENT_SUBSCRIPTION' + | 'PREMIMUM_WEALTH_MANAGEMENT_REFUND' + | 'LIQUIDITY_MINING_SUBSCRIPTION' + | 'LIQUIDITY_MINING_REFUND' + | 'PWM_SUBSCRIPTION' + | 'PWM_REFUND' + | 'DEFI_INVESTMENT_SUBSCRIPTION' + | 'DEFI_INVESTMENT_REFUND' + | 'DEFI_INVESTMENT_REDEMPTION' + | 'INSTITUTION_LOAN_IN' + | 'INSTITUTION_PAYBACK_PRINCIPAL_OUT' + | 'INSTITUTION_PAYBACK_INTEREST_OUT' + | 'INSTITUTION_EXCHANGE_SELL' + | 'INSTITUTION_EXCHANGE_BUY' + | 'INSTITUTION_LIQ_PRINCIPAL_OUT' + | 'INSTITUTION_LIQ_INTEREST_OUT' + | 'INSTITUTION_LOAN_TRANSFER_IN' + | 'INSTITUTION_LOAN_TRANSFER_OUT' + | 'INSTITUTION_LOAN_WITHOUT_WITHDRAW' + | 'INSTITUTION_LOAN_RESERVE_IN' + | 'INSTITUTION_LOAN_RESERVE_OUT' + | 'PLATFORM_TOKEN_MNT_LIQRECALLEDMMNT' + | 'PLATFORM_TOKEN_MNT_LIQRETURNEDMNT' + | 'DIVIDEND_SETTLEMENT' + | 'FORWARD_SPLIT_SETTLE' + | 'REVERSE_SPLIT_SETTLE'; ⋮---- -export type WSSpreadExecutionEventV5 = WSPrivateTopicEventV5< - 'spread.execution', - WSSpreadExecutionV5[] ->; +export type PermissionTypeV5 = + | 'ContractTrade' + | 'Spot' + | 'Wallet' + | 'Options' + | 'Derivatives' + | 'Exchange' + | 'NFT'; ⋮---- -export interface WSInsuranceV5 { - coin: string; - symbols: string; - balance: string; - updateTime: string; -} +/** + * Leveraged token status: + * + * - '1' LT can be purchased and redeemed + * - '2' LT can be purchased, but not redeemed + * - '3' LT can be redeemed, but not purchased + * - '4' LT cannot be purchased nor redeemed + * - '5' Adjusting position + */ +export type LeverageTokenStatusV5 = '1' | '2' | '3' | '4' | '5'; ⋮---- -export type WSInsuranceEventV5 = WSPublicTopicEventV5< - 'insurance.USDT' | 'insurance.USDC' | 'insurance.inverse', - 'snapshot' | 'delta', - WSInsuranceV5[] ->; +/** + * Leveraged token order type: '1': purchase, '2': redeem + */ +export type LTOrderTypeV5 = '1' | '2'; ⋮---- -export interface WSPriceLimitV5 { - symbol: string; - buyLmt: string; - sellLmt: string; -} +/** + * Leveraged token order status: '1': completed, '2': in progress, '3': failed + */ +export type LTOrderStatusV5 = '1' | '2' | '3'; ⋮---- -export type WSPriceLimitEventV5 = WSPublicTopicEventV5< - string, - 'snapshot', - WSPriceLimitV5 ->; +export type ExecTypeV5 = + | 'Trade' + | 'AdlTrade' + | 'Funding' + | 'BustTrade' + | 'Settle' + | 'BlockTrade' + | 'MovePosition' + /** @deprecated Removed from Bybit execType; kept for older payloads. */ + | 'CorporateAction' + | 'ForwardSplitSettle' + | 'ReverseSplitSettle' + | 'Dividend' + | 'UNKNOWN'; ⋮---- -export interface WSADLAlertV5 { - c: string; // Token of the insurance pool - s: string; // Trading pair name - b: string; // Balance of the insurance fund. For shared insurance pool, follows T+1 refresh (updated daily at 00:00 UTC) - mb: string; // Deprecated: always returns empty string. Previously: Maximum balance of the insurance pool in the last 8 hours - i_pr: string; // PnL ratio threshold for triggering contract PnL drawdown ADL - pr: string; // Symbol's PnL drawdown ratio in the last 8 hours. Used to determine whether ADL is triggered or stopped - adl_tt: string; // Trigger threshold for contract PnL drawdown ADL - adl_sr: string; // Stop ratio threshold for contract PnL drawdown ADL -} +/** @deprecated Removed from Bybit execType; kept for older payloads. */ ⋮---- -c: string; // Token of the insurance pool -s: string; // Trading pair name -b: string; // Balance of the insurance fund. For shared insurance pool, follows T+1 refresh (updated daily at 00:00 UTC) -mb: string; // Deprecated: always returns empty string. Previously: Maximum balance of the insurance pool in the last 8 hours -i_pr: string; // PnL ratio threshold for triggering contract PnL drawdown ADL -pr: string; // Symbol's PnL drawdown ratio in the last 8 hours. Used to determine whether ADL is triggered or stopped -adl_tt: string; // Trigger threshold for contract PnL drawdown ADL -adl_sr: string; // Stop ratio threshold for contract PnL drawdown ADL +/** + * Withdraw type. 0(default): on chain. 1: off chain. 2: all. + */ +export type WithdrawalTypeV5 = '0' | '1' | '2'; ⋮---- -export type WSADLAlertEventV5 = WSPublicTopicEventV5< - 'adlAlert.USDT' | 'adlAlert.USDC' | 'adlAlert.inverse', - 'snapshot', - WSADLAlertV5[] ->; +export interface PermissionsV5 { + ContractTrade?: string[]; + Spot?: string[]; + Wallet?: string[]; + Options?: string[]; + Derivatives?: string[]; + CopyTrading?: string[]; + BlockTrade?: string[]; + Exchange?: string[]; + /** @deprecated , always returns []*/ + NFT?: string[]; + Earn?: string[]; + Affiliate?: string[]; + FiatP2P?: string[]; + /** Bybit Pay (FaitPayOrder) */ + FiatBitPay?: string[]; + FiatConvertBroker?: string[]; + BitCard?: string[]; + ByXPost?: string[]; +} ⋮---- -export type WSSystemStatusEventV5 = WSPublicTopicEventV5< - 'system.status', - 'snapshot', - SystemStatusItemV5[] ->; +/** @deprecated , always returns []*/ ⋮---- -/** - * RFQ WebSocket Events - */ +/** Bybit Pay (FaitPayOrder) */ ⋮---- -/** - * RFQ Inquiry Channel - * Private push for RFQ inquiries sent or received by the user - * Topics: rfq.open.rfqs, rfq.site.rfqs - */ -export type WSRFQInquiryEventV5 = WSPrivateTopicEventV5< - 'rfq.open.rfqs' | 'rfq.site.rfqs', - RFQItemV5[] ->; +export interface CategoryCursorListV5< + T extends unknown[], + TCategory extends CategoryV5 = CategoryV5, +> { + category: TCategory; + list: T; + nextPageCursor?: string; +} ⋮---- /** - * RFQ Quote Channel - * Private push for quotes sent or received by the user - * Topics: rfq.open.quotes, rfq.site.quotes + * Next page cursor does not exist for spot! */ -export type WSRFQQuoteEventV5 = WSPrivateTopicEventV5< - 'rfq.open.quotes' | 'rfq.site.quotes', - RFQQuoteItemV5[] ->; +export interface CursorListV5 { + nextPageCursor: string; + list: T; +} ⋮---- /** - * RFQ Trade Channel - * Private push for block trades executed by the user - * Topics: rfq.open.trades, rfq.site.trades + * A wrapper type for any responses that have a "nextPageCursor" property, and a "rows" property with an array of elements + * + * ```{ nextPageCursor: "something", rows: someData[] }``` */ -export type WSRFQTradeEventV5 = WSPrivateTopicEventV5< - 'rfq.open.trades' | 'rfq.site.trades', - RFQTradeV5[] ->; +export interface CursorRowsV5 { + nextPageCursor: string; + rows: T; +} ⋮---- -/** - * RFQ Public Trade Channel - * Public push for all block trades - * Topics: rfq.open.public.trades, rfq.site.public.trades - */ -export type WSRFQPublicTradeEventV5 = WSPublicTopicEventV5< - 'rfq.open.public.trades' | 'rfq.site.public.trades', - 'snapshot', - RFQPublicTradeV5[] ->; - -================ -File: examples/Rest/rest-v5-custom-url.ts -================ -import { RestClientV5 } from '../../src/index'; +export interface CategoryListV5< + T extends unknown[], + TCategory extends CategoryV5, +> { + category: TCategory; + list: T; +} ⋮---- -// or -// import { RestClientV5 } from 'bybit-api'; +export interface CategorySymbolListV5< + T extends unknown[], + TCategory extends CategoryV5, +> { + category: TCategory; + symbol: string; + list: T; +} ⋮---- -/** - * The first parameter of the REST client allows you to pass any configuration parameters supported by the SDK. - * - * These include API keys, if you wish to use private endpoints, but also expose other features such as - * setting a custom base URL (e.g. for Turkish users). - * - * Refer to the API documentation for a complete list of domains: https://bybit-exchange.github.io/docs/v5/guide#authentication - */ +export interface GetSystemStatusParamsV5 { + id?: string; + state?: string; +} ⋮---- -/** - * You can pass a completely custom base URL, - * e.g. if you're trying to use a domain that hasn't been added yet (please let us know) - */ -// baseUrl: 'https://api5.bybit.com', -// -// -/** - * - * Predefined API regions are available through the `apiRegion` property. - * Choose the region where your Bybit account is registered: - * - */ -// -// -// default: routes to api.bybit.com -// apiRegion: 'default', -// -// -// bytick: routes to api.bytick.com -// apiRegion: 'bytick', -// -// -// NL: routes to api.bybit.nl (for Netherlands users) -// apiRegion: 'NL', -// -// -// TK: routes to api.bybit.tr (for Turkey users) -// apiRegion: 'TK', -// -// -// KZ: routes to api.bybit.kz (for Kazakhstan users) -// apiRegion: 'KZ', -// -// -// HK: routes to api.spark-fintech.com and adds x-refer-site-id: HKG -// Testnet routes to api-testnet.spark-fintech.com -// apiRegion: 'HK', -// -// -// GE: routes to api.bybitgeorgia.ge (for Georgia users) -// apiRegion: 'GE', -// -// -// UAE: routes to api.bybit.ae (for United Arab Emirates users) -// apiRegion: 'UAE', -// -// -// EU: routes to api.bybit.eu (for EU and EEA users) -// apiRegion: 'EU', -// -// -// ID: routes to api.bybit.id (for Indonesian users) -// apiRegion: 'ID', -// -// -// JP: routes to api.manepa.jp (for Japan users) -// Testnet routes to api-testnet.manepa.jp -// apiRegion: 'JP', -// -// -/** - * Brazil and Argentina international accounts use the global API domain - * with an x-site-id header. Choose the site ID for your account: - */ -// siteId: 'BRA_BTL', -// siteId: 'ARG_BTL', +export interface SystemStatusItemV5 { + id: string; + title: string; + state: string; + begin: string; + end: string; + href: string; + serviceTypes: number[]; + product: number[]; + uidSuffix: number[]; + maintainType: string; + env: string; +} ================ File: src/types/response/v5-asset.ts @@ -15258,7 +15498,9 @@ import { AmendOrderParamsV5, AmendSpreadOrderParamsV5, ApiKeyInfoV5, + APIP2PChatResponse, APIP2PResponse, + APIRateLimit, APIResponseV3, APIResponseV3WithTime, AssetInfoV5, @@ -15348,6 +15590,7 @@ import { CreateSubMemberResultV5, CreateSupplyOrderFixedParamsV5, CreateSupplyOrderFixedV5, + CreateTaxBatchExportParamsV5, CryptoLoanPositionV5, CurrencyPositionTiersV5, CursorListV5, @@ -15410,6 +15653,7 @@ import { FixedTermEarnProductListV5, FlexibleAvailableInventoryV5, FlexibleLoanAvailableInventoryV5, + FlexibleSavingAutoSavingsV5, FriendReferralRecordV5, FundingAccountTransactionRecordV5, FundingRateHistoryResponseV5, @@ -15513,6 +15757,7 @@ import { GetFixedTermEarnProductParamsV5, GetFlexibleAvailableInventoryParamsV5, GetFlexibleLoanAvailableInventoryParamsV5, + GetFlexibleSavingAutoSavingsParamsV5, GetFriendReferralsParamsV5, GetFullDepthOrderbookParamsV5, GetFundingAccountTransactionHistoryParamsV5, @@ -15540,9 +15785,13 @@ import { GetMovePositionHistoryParamsV5, GetOngoingFlexibleLoansParamsV5, GetOpenInterestParamsV5, + GetOptionBaseCoinsParamsV5, GetOptionDeliveryPriceParamsV5, GetOrderbookParamsV5, GetP2PAccountCoinsBalanceParamsV5, + GetP2PChatMessagesParamsV5, + GetP2PChatSessionIdParamsV5, + GetP2PChatSessionsParamsV5, GetP2PCounterpartyUserInfoParamsV5, GetP2POnlineAdsParamsV5, GetP2POrderMessagesParamsV5, @@ -15604,6 +15853,7 @@ import { GetSupplyOrderInfoFixedParamsV5, GetSupplyOrderQuoteFixedParamsV5, GetSystemStatusParamsV5, + GetTaxBatchExportParamsV5, GetTickersParamsV5, GetTokenSplashProjectListParamsV5, GetTokenSplashUserActivityParamsV5, @@ -15621,6 +15871,7 @@ import { HoldToEarnAirdropYieldHistoryResultV5, IndexPriceComponentsResponseV5, InstitutionalLendingCoinDeltaAmountV5, + InstitutionalLendingDelayLiquidationStatusV5, InstitutionalLendingProductInfoV5, InstitutionalLoanLTVV5, InstrumentInfoResponseV5, @@ -15661,6 +15912,7 @@ import { OngoingFlexibleLoanV5, OpenInterestResponseV5, OptionAssetInfoNestedResultV5, + OptionBaseCoinsResultV5, OptionDeliveryPriceV5, OrderbookResponseV5, OrderParamsV5, @@ -15669,6 +15921,8 @@ import { OrderSideV5, P2PAccountCoinsBalanceV5, P2PAdDetailV5, + P2PChatMessagesResponseV5, + P2PChatSessionsResponseV5, P2PCounterpartyUserInfoV5, P2PCreateAdResponseV5, P2POnlineAdsResponseV5, @@ -15746,6 +16000,7 @@ import { RWAOrderListResultV5, RWAPositionListResultV5, RWAProductListResultV5, + SendP2PChatMessageParamsV5, SendP2POrderMessageParamsV5, SetAutoAddMarginParamsV5, SetAutoRepayModeParamsV5, @@ -15753,6 +16008,7 @@ import { SetCollateralCoinParamsV5, SetDeltaNeutralModeParamsV5, SetFixedTermEarnAutoInvestParamsV5, + SetFlexibleSavingAutoSavingsParamsV5, SetLeverageParamsV5, SetLimitPriceActionParamsV5, SetRiskLimitParamsV5, @@ -15797,6 +16053,8 @@ import { SwitchIsolatedMarginParamsV5, SwitchPositionModeParamsV5, SystemStatusItemV5, + TaxBatchExportResultV5, + TaxBatchExportStatusV5, TickerLinearInverseV5, TickerOptionV5, TickerSpotV5, @@ -16324,6 +16582,13 @@ getFeeGroupStructure( params: GetFeeGroupStructureParamsV5, ): Promise> ⋮---- +/** + * Query option base coins, display names, launch times, and tradable symbol availability. + */ +getOptionBaseCoins( + params?: GetOptionBaseCoinsParamsV5, +): Promise> +⋮---- /** * ****** Trade APIs @@ -17728,6 +17993,26 @@ deleteSubApiKey(params?: { apikey?: string; }): Promise> +⋮---- +/** + * Query tax batch export task status and download URLs by batchId. + */ +getTaxBatchExport( + params: GetTaxBatchExportParamsV5, +): Promise> +⋮---- /** * ****** Affiliate APIs @@ -19080,6 +19365,14 @@ getInstitutionalLendingCoinDeltaAmount( params?: GetCoinDeltaAmountParamsV5, ): Promise> ⋮---- +/** + * Current LTV, liquidation status, and delay-liquidation timing for an institutional loan account. + */ +getInstitutionalLendingDelayLiquidationStatus(): Promise< + APIResponseV3WithTime + > { + return this.getPrivate('/v5/ins-loan/delay-liq-status'); +⋮---- /** * Get Margin Coin Info * @deprecated @@ -19314,6 +19607,20 @@ getEarnProduct(params: { category: string; coin?: string }): Promise< > { return this.get('/v5/earn/product', params); ⋮---- +/** + * Query Flexible Saving auto savings settings. Omit coins to return every supported coin. + */ +getFlexibleSavingAutoSavings( + params?: GetFlexibleSavingAutoSavingsParamsV5, +): Promise> +⋮---- +/** + * Enable or disable Flexible Saving auto savings for one coin, or globally when coin is omitted. + */ +setFlexibleSavingAutoSavings( + params: SetFlexibleSavingAutoSavingsParamsV5, +): Promise> ⋮---- +/** + * Liquidity mining reinvest. Puts claimable yield of a position back into the pool. + * Async; success means the order was accepted. Use order status to track fill. + * Optional `leverage` is an integer string; defaults to "1" (no leverage). + * + * INFO: Earn permission required. Up to 5 requests/second per UID. + */ reinvestLiquidityMining( params: ReinvestLiquidityMiningParamsV5, ): Promise> @@ -20185,6 +20499,27 @@ sendP2POrderMessage( params: SendP2POrderMessageParamsV5, ): Promise> ⋮---- +/** + * + * Chat P2P + */ +⋮---- +/** + * Get P2P chat sessions with cursor pagination and read status filtering. + * @see https://bybit-exchange.github.io/docs/p2p/chat/get-chat-session-list + */ +getP2PChatSessions( + params: GetP2PChatSessionsParamsV5, +): Promise> +⋮---- +/** + * Get the AES encrypted P2P chat session ID for a counterparty. + * @see https://bybit-exchange.github.io/docs/p2p/chat/get-session-id + */ +getP2PChatSessionId( + params: GetP2PChatSessionIdParamsV5, +): Promise> +⋮---- /** * Get chat messages in a P2P order */ @@ -20371,38 +20721,92 @@ getTokenSplashUserActivityParams( params?: GetTokenSplashUserActivityParamsV5, ): Promise> ⋮---- +/** + * + ****** Event Trading (Event Contract) APIs + * + * Market data is public. Trade/position endpoints are market-maker only. + * Public WS: subscribeV5(topics, 'event'). Do not pass category "event" on REST Unified V5 methods. + * + */ +⋮---- +/** + * Get Event Contract instruments info. + * + * INFO: No authentication. + */ getEventInstrumentsInfo( params?: GetEventInstrumentsInfoParamsV5, ): Promise> ⋮---- +/** + * Get Event Contract 25-level orderbook. Each level is [payoutRatio, orderValue]. + * + * INFO: No authentication. + */ getEventOrderbook( params: GetEventOrderbookParamsV5, ): Promise> ⋮---- +/** + * Get Event Contract order history (up to 2 years). Default query window is 7 days if start/end omitted. + * + * INFO: Event Contract maker accounts only. + */ getEventOrderHistory( params?: GetEventOrderHistoryParamsV5, ): Promise> ⋮---- +/** + * Get Event Contract active (unfilled / partially filled) orders. + * + * INFO: Event Contract maker accounts only. + */ getEventActiveOrders( params?: GetEventActiveOrdersParamsV5, ): Promise> ⋮---- +/** + * Get Event Contract position info (UpDown, Target, Range). + * + * INFO: Event Contract maker accounts only. + */ getEventPositionInfo( params?: GetEventPositionInfoParamsV5, ): Promise> ⋮---- +/** + * Get Event Contract trade (execution) history (up to 2 years). Default query window is 7 days if start/end omitted. + * + * INFO: Event Contract maker accounts only. + */ getEventTradeHistory( params: GetEventTradeHistoryParamsV5, ): Promise> ⋮---- +/** + * Get Event Contract settlement records (up to 2 years). Default query window is 7 days if start/end omitted. + * + * INFO: Event Contract maker accounts only. + */ getEventSettlementRecords( params: GetEventSettlementRecordsParamsV5, ): Promise> ⋮---- +/** + * Submit an Event Contract payout-ratio quote. + * + * INFO: Event Contract maker accounts only. + */ submitEventQuote( params: SubmitEventQuoteParamsV5, ): Promise> ⋮---- +/** + * Cancel an Event Contract quote. Pass orderLinkId and/or orderId. + * + * INFO: Event Contract maker accounts only. + */ cancelEventQuote( params?: CancelEventQuoteParamsV5, ): Promise> @@ -20413,8 +20817,8 @@ File: src/websocket-client.ts /* eslint-disable @typescript-eslint/no-unused-vars */ ⋮---- import { - CategoryV5, MessageEventLike, + WSCategoryV5, WSClientConfigurableOptions, WsKey, WsMarket, @@ -20491,7 +20895,7 @@ public connectPrivate(): Promise /** * Subscribe to V5 topics & track/persist them. * @param wsTopics - topic or list of topics - * @param category - the API category this topic is for (e.g. "linear"). + * @param category - the API category this topic is for (e.g. "linear", or "event" for Event Contract public topics). * The value is only important when connecting to public topics and will be ignored for private topics. * @param isPrivateTopic - optional - the library will try to detect private topics, you can use this * to mark a topic as private (if the topic isn't recognised yet) @@ -20515,7 +20919,7 @@ public subscribeV5( * connection reconnects. * * @param wsTopics - topic or list of topics - * @param category - the API category this topic is for (e.g. "linear"). The value is only + * @param category - the API category this topic is for (e.g. "linear", or "event" for Event Contract public topics). The value is only * important when connecting to public topics and will be ignored for private topics. * @param isPrivateTopic - optional - the library will try to detect private topics, you can * use this to mark a topic as private (if the topic isn't recognised yet) @@ -22045,7 +22449,6 @@ Supported API region values in this SDK: - `default` - `bytick` -- `NL` - `TK` - `KZ` - `HK` @@ -22066,7 +22469,7 @@ On WebSocket clients, these mainnet routes are selected automatically: - `ID`: `stream.bybit.id` - `JP`: `stream.manepa.jp` -For `default`, `bytick`, `NL`, `UAE`, and `EU`, WebSocket connections continue to use the global stream because Bybit does not list a dedicated V5 trading stream for those values. This means `apiRegion: 'EU'` selects `api.bybit.eu` for REST API requests and keeps `stream.bybit.com` for WebSocket. Testnet WebSocket connections use `stream-testnet.bybit.com`. +For `default`, `bytick`, `UAE`, and `EU`, WebSocket connections continue to use the global stream because Bybit does not list a dedicated V5 trading stream for those values. This means `apiRegion: 'EU'` selects `api.bybit.eu` for REST API requests and keeps `stream.bybit.com` for WebSocket. Testnet WebSocket connections use `stream-testnet.bybit.com`. New API regions will be supported as they become available. If you're looking for a region not yet supported, please get in touch. @@ -22821,7 +23224,7 @@ const restClientOptions = { /** * Optionally override API domain used: - * apiRegion: 'default' | 'bytick' | 'NL' | 'TK' | 'KZ' | 'HK' | 'GE' | 'UAE' | 'EU' | 'ID' | 'JP', + * apiRegion: 'default' | 'bytick' | 'TK' | 'KZ' | 'HK' | 'GE' | 'UAE' | 'EU' | 'ID' | 'JP', **/ // apiRegion: 'bytick', @@ -23182,7 +23585,6 @@ The following values are currently supported in this option: - `apiRegion: undefined`: if missing or undefined, this SDK will default to the Bybit Global domain `api.bybit.com`. - `apiRegion: "default"`: the Bybit Global domain (same behaviour as above). - `apiRegion: "bytick"`: the alternative Bybit Global domain `api.bytick.com`. -- `apiRegion: "NL"`: the dedicated Bybit Netherlands domain `api.bybit.nl`. - `apiRegion: "TK"`: the dedicated Bybit Turkey domain `api.bybit.tr`. - `apiRegion: "KZ"`: the dedicated Bybit Kazakhstan domain `api.bybit.kz`. - `apiRegion: "HK"`: the dedicated Bybit Hong Kong domain `api.spark-fintech.com`. The SDK also adds `x-refer-site-id: HKG`. Testnet uses `api-testnet.spark-fintech.com`. @@ -23203,7 +23605,7 @@ For WebSocket clients, the same option selects these mainnet stream domains: | `ID` | `stream.bybit.id` | | `JP` | `stream.manepa.jp` | -For `default`, `bytick`, `NL`, `UAE`, and `EU`, WebSocket connections continue to use the global stream because Bybit does not list a dedicated V5 trading stream for those values. This means `apiRegion: 'EU'` selects `api.bybit.eu` for REST and keeps `stream.bybit.com` for WebSocket. Testnet WebSocket connections use `stream-testnet.bybit.com`. For Hong Kong mainnet WebSocket connections, the SDK also adds `x-refer-site-id: HKG` automatically. +For `default`, `bytick`, `UAE`, and `EU`, WebSocket connections continue to use the global stream because Bybit does not list a dedicated V5 trading stream for those values. This means `apiRegion: 'EU'` selects `api.bybit.eu` for REST and keeps `stream.bybit.com` for WebSocket. Testnet WebSocket connections use `stream-testnet.bybit.com`. For Hong Kong mainnet WebSocket connections, the SDK also adds `x-refer-site-id: HKG` automatically. ```typescript const ws = new WebsocketClient({ apiRegion: 'TK' }); @@ -23391,7 +23793,7 @@ File: package.json ================ { "name": "bybit-api", - "version": "4.7.7", + "version": "4.7.10", "description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -23477,7 +23879,7 @@ File: package.json "bugs": { "url": "https://github.com/sieblyio/bybit-api/issues" }, - "homepage": "https://siebly.io/sdk/bybit/javascript" + "homepage": "https://siebly.io/sdk/bybit/javascript/tutorial" } diff --git a/package-lock.json b/package-lock.json index 5ca447c6..20145ff2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bybit-api", - "version": "4.7.9", + "version": "4.7.10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bybit-api", - "version": "4.7.9", + "version": "4.7.10", "license": "MIT", "dependencies": { "@types/ws": "8.18.1", diff --git a/package.json b/package.json index 05987ee3..1663efa9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "4.7.9", + "version": "4.7.10", "description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index 271fe278..4983dc2f 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -149,6 +149,7 @@ import { CreateSubMemberResultV5, CreateSupplyOrderFixedParamsV5, CreateSupplyOrderFixedV5, + CreateTaxBatchExportParamsV5, CryptoLoanPositionV5, CurrencyPositionTiersV5, CursorListV5, @@ -211,6 +212,7 @@ import { FixedTermEarnProductListV5, FlexibleAvailableInventoryV5, FlexibleLoanAvailableInventoryV5, + FlexibleSavingAutoSavingsV5, FriendReferralRecordV5, FundingAccountTransactionRecordV5, FundingRateHistoryResponseV5, @@ -314,6 +316,7 @@ import { GetFixedTermEarnProductParamsV5, GetFlexibleAvailableInventoryParamsV5, GetFlexibleLoanAvailableInventoryParamsV5, + GetFlexibleSavingAutoSavingsParamsV5, GetFriendReferralsParamsV5, GetFullDepthOrderbookParamsV5, GetFundingAccountTransactionHistoryParamsV5, @@ -341,6 +344,7 @@ import { GetMovePositionHistoryParamsV5, GetOngoingFlexibleLoansParamsV5, GetOpenInterestParamsV5, + GetOptionBaseCoinsParamsV5, GetOptionDeliveryPriceParamsV5, GetOrderbookParamsV5, GetP2PAccountCoinsBalanceParamsV5, @@ -408,6 +412,7 @@ import { GetSupplyOrderInfoFixedParamsV5, GetSupplyOrderQuoteFixedParamsV5, GetSystemStatusParamsV5, + GetTaxBatchExportParamsV5, GetTickersParamsV5, GetTokenSplashProjectListParamsV5, GetTokenSplashUserActivityParamsV5, @@ -425,6 +430,7 @@ import { HoldToEarnAirdropYieldHistoryResultV5, IndexPriceComponentsResponseV5, InstitutionalLendingCoinDeltaAmountV5, + InstitutionalLendingDelayLiquidationStatusV5, InstitutionalLendingProductInfoV5, InstitutionalLoanLTVV5, InstrumentInfoResponseV5, @@ -465,6 +471,7 @@ import { OngoingFlexibleLoanV5, OpenInterestResponseV5, OptionAssetInfoNestedResultV5, + OptionBaseCoinsResultV5, OptionDeliveryPriceV5, OrderbookResponseV5, OrderParamsV5, @@ -560,6 +567,7 @@ import { SetCollateralCoinParamsV5, SetDeltaNeutralModeParamsV5, SetFixedTermEarnAutoInvestParamsV5, + SetFlexibleSavingAutoSavingsParamsV5, SetLeverageParamsV5, SetLimitPriceActionParamsV5, SetRiskLimitParamsV5, @@ -604,6 +612,8 @@ import { SwitchIsolatedMarginParamsV5, SwitchPositionModeParamsV5, SystemStatusItemV5, + TaxBatchExportResultV5, + TaxBatchExportStatusV5, TickerLinearInverseV5, TickerOptionV5, TickerSpotV5, @@ -1239,6 +1249,15 @@ export class RestClientV5 extends BaseRestClient { return this.get('/v5/market/fee-group-info', params); } + /** + * Query option base coins, display names, launch times, and tradable symbol availability. + */ + getOptionBaseCoins( + params?: GetOptionBaseCoinsParamsV5, + ): Promise> { + return this.get('/v5/market/option-base-coins', params); + } + /** * ****** Trade APIs @@ -2882,6 +2901,36 @@ export class RestClientV5 extends BaseRestClient { return this.postPrivate('/v5/user/delete-sub-api', params); } + /** + * + ****** Tax + * + */ + + /** + * Export multiple tax report types in one batch. Returns a batchId for status polling. + */ + createTaxBatchExport( + params: CreateTaxBatchExportParamsV5, + ): Promise> { + return this.postPrivate( + '/v5/fht/compliance/tax/private/batch_create', + params, + ); + } + + /** + * Query tax batch export task status and download URLs by batchId. + */ + getTaxBatchExport( + params: GetTaxBatchExportParamsV5, + ): Promise> { + return this.getPrivate( + '/v5/fht/compliance/tax/private/batch_query', + params, + ); + } + /** * ****** Affiliate APIs @@ -4463,6 +4512,15 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/ins-loan/coin-delta-amount', params); } + /** + * Current LTV, liquidation status, and delay-liquidation timing for an institutional loan account. + */ + getInstitutionalLendingDelayLiquidationStatus(): Promise< + APIResponseV3WithTime + > { + return this.getPrivate('/v5/ins-loan/delay-liq-status'); + } + /** * Get Margin Coin Info * @deprecated @@ -4724,6 +4782,24 @@ export class RestClientV5 extends BaseRestClient { return this.get('/v5/earn/product', params); } + /** + * Query Flexible Saving auto savings settings. Omit coins to return every supported coin. + */ + getFlexibleSavingAutoSavings( + params?: GetFlexibleSavingAutoSavingsParamsV5, + ): Promise> { + return this.getPrivate('/v5/earn/flexible-saving/auto-savings', params); + } + + /** + * Enable or disable Flexible Saving auto savings for one coin, or globally when coin is omitted. + */ + setFlexibleSavingAutoSavings( + params: SetFlexibleSavingAutoSavingsParamsV5, + ): Promise> { + return this.postPrivate('/v5/earn/flexible-saving/auto-savings', params); + } + /** * Get Coupon List * Interest-rate coupons and Dual Assets reward cards for FlexibleSaving or DualAssets. diff --git a/src/types/request/index.ts b/src/types/request/index.ts index da64980d..11f91154 100644 --- a/src/types/request/index.ts +++ b/src/types/request/index.ts @@ -32,5 +32,6 @@ export * from './v5-spot-leverage-token'; export * from './v5-spot-x'; export * from './v5-spreadtrading'; export * from './v5-strategy'; +export * from './v5-tax'; export * from './v5-trade'; export * from './v5-user'; diff --git a/src/types/request/v5-earn.ts b/src/types/request/v5-earn.ts index 94e9777c..dfcf37eb 100644 --- a/src/types/request/v5-earn.ts +++ b/src/types/request/v5-earn.ts @@ -2,6 +2,18 @@ export interface GetEarnCouponListParamsV5 { category: 'FlexibleSaving' | 'DualAssets'; } +/** GET /v5/earn/flexible-saving/auto-savings. coins is a repeated query param, max 50. */ +export interface GetFlexibleSavingAutoSavingsParamsV5 { + coins?: string[]; +} + +/** POST /v5/earn/flexible-saving/auto-savings. Omit coin to update the global setting. */ +export interface SetFlexibleSavingAutoSavingsParamsV5 { + coin?: string; + isSelected: boolean; + purchaseImmediately?: boolean; +} + export interface SubmitStakeRedeemParamsV5 { category: string; orderType: 'Stake' | 'Redeem'; diff --git a/src/types/request/v5-market.ts b/src/types/request/v5-market.ts index dc72743e..9755e5cb 100644 --- a/src/types/request/v5-market.ts +++ b/src/types/request/v5-market.ts @@ -175,3 +175,11 @@ export interface GetFullDepthOrderbookParamsV5 { category: 'spot' | 'linear' | 'inverse'; symbol: string; } + +export interface GetOptionBaseCoinsParamsV5 { + /** + * Comma-separated underlying types. + * 0 crypto, 1 commodity, 2 stock, 3 forex, 4 oil. Omit to return all types. + */ + underlyingType?: string; +} diff --git a/src/types/request/v5-tax.ts b/src/types/request/v5-tax.ts new file mode 100644 index 00000000..f275dd17 --- /dev/null +++ b/src/types/request/v5-tax.ts @@ -0,0 +1,32 @@ +export type TaxReportTypeV5 = + | 'ALL' + | 'TRADE' + | 'P&L' + | 'EARN' + | 'DEPOSIT&WITHDRAWAL' + | 'BONUS' + | 'AIRDROP' + | 'CARD'; + +export interface TaxBatchExportItemV5 { + type: TaxReportTypeV5; + /** Subcategory number. Required but ignored when type is ALL; pass "". */ + number: string; +} + +/** POST /v5/fht/compliance/tax/private/batch_create */ +export interface CreateTaxBatchExportParamsV5 { + /** UNIX seconds. Must be within the last 18 months. */ + startTime: number; + /** UNIX seconds. Later than startTime, span at most 12 months. */ + endTime: number; + items: TaxBatchExportItemV5[]; + sourceInstitution?: string; + /** orc is the default when omitted */ + exportFileType?: 'orc' | 'csv'; +} + +/** GET /v5/fht/compliance/tax/private/batch_query */ +export interface GetTaxBatchExportParamsV5 { + batchId: string; +} diff --git a/src/types/response/index.ts b/src/types/response/index.ts index 2d63a2f5..dafb6469 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -29,5 +29,6 @@ export * from './v5-spot-leverage-token'; export * from './v5-spot-x'; export * from './v5-spreadtrading'; export * from './v5-strategy'; +export * from './v5-tax'; export * from './v5-trade'; export * from './v5-user'; diff --git a/src/types/response/v5-crypto-loan.ts b/src/types/response/v5-crypto-loan.ts index bb44b392..68f3888c 100644 --- a/src/types/response/v5-crypto-loan.ts +++ b/src/types/response/v5-crypto-loan.ts @@ -393,6 +393,14 @@ export interface InstitutionalLendingCoinDeltaAmountV5 { list: InstitutionalLendingCoinDeltaItemV5[]; } +export interface InstitutionalLendingDelayLiquidationStatusV5 { + ltv: string; + /** 0 normal, 1 passive liquidation, 2 callback liquidation, 3 delay liquidation */ + liquidationStatus: 0 | 1 | 2 | 3; + delayLiqStartTime: string; + delayLiqRemainingSec: string; +} + export interface UnpaidInfoV5 { token: string; // Coin unpaidQty: string; // Unpaid principle diff --git a/src/types/response/v5-earn.ts b/src/types/response/v5-earn.ts index a17d5359..3f15d017 100644 --- a/src/types/response/v5-earn.ts +++ b/src/types/response/v5-earn.ts @@ -35,6 +35,18 @@ export interface EarnCouponListResultV5 { awardCards: EarnAwardCardV5[]; } +export interface FlexibleSavingAutoSavingsCoinV5 { + coin: string; + isSelected: boolean; + maxStakingAmount: string; + apr: string; +} + +export interface FlexibleSavingAutoSavingsV5 { + selectedAll: boolean; + coins: FlexibleSavingAutoSavingsCoinV5[]; +} + export interface EarnProductV5 { category: string; estimateApr: string; diff --git a/src/types/response/v5-market.ts b/src/types/response/v5-market.ts index 5346d06f..44303623 100644 --- a/src/types/response/v5-market.ts +++ b/src/types/response/v5-market.ts @@ -103,6 +103,8 @@ export interface LinearInverseInstrumentInfoV5 { fullName?: string; marketRegion?: string; underlyingTicker?: string; + /** Symbol tags such as `ST`. Linear and inverse only. */ + tags?: string[]; } export interface OptionInstrumentInfoV5 { @@ -465,3 +467,20 @@ export interface FeeGroupItemV5 { export interface FeeGroupStructureResponseV5 { list: FeeGroupItemV5[]; // List of fee group objects } + +export interface OptionBaseCoinV5 { + baseCoin: string; + quoteCoin: string; + settleCoin: string; + optionShowName: string; + /** UTC milliseconds. 0 when the option is not scheduled. */ + optionOnlineTime: number; + /** 1 when tradable option symbols exist, otherwise 0 */ + hasSymbol: 0 | 1; + /** 0 crypto, 1 commodity, 2 stock, 3 forex, 4 oil */ + underlyingType: 0 | 1 | 2 | 3 | 4; +} + +export interface OptionBaseCoinsResultV5 { + list: OptionBaseCoinV5[]; +} diff --git a/src/types/response/v5-spot-x.ts b/src/types/response/v5-spot-x.ts index a6020a7b..9a3601e1 100644 --- a/src/types/response/v5-spot-x.ts +++ b/src/types/response/v5-spot-x.ts @@ -105,6 +105,8 @@ export interface TokenSplashProjectListResultV5 { export interface TokenSplashTradeTaskV5 { tradeRequiredAmount: string; tradeUnit: string; + /** Token counted by the trade task. On-chain tasks use the activity token ID. */ + tradeToken?: string; tradedAmount: string; maxRewardAmount: string; estimatedRewardAmount: string; diff --git a/src/types/response/v5-tax.ts b/src/types/response/v5-tax.ts new file mode 100644 index 00000000..aa07cc91 --- /dev/null +++ b/src/types/response/v5-tax.ts @@ -0,0 +1,16 @@ +export interface TaxBatchExportResultV5 { + batchId: string; +} + +export interface TaxBatchExportTaskV5 { + type: string; + number: string; + /** 0 queued, 1 processing, 2 succeeded, -1 failed */ + status: 0 | 1 | 2 | -1; + url: string; + queryId: string; +} + +export interface TaxBatchExportStatusV5 { + items: TaxBatchExportTaskV5[]; +} diff --git a/src/util/requestUtils.ts b/src/util/requestUtils.ts index 43494c16..8aa86402 100644 --- a/src/util/requestUtils.ts +++ b/src/util/requestUtils.ts @@ -5,7 +5,6 @@ import { APIRateLimit } from '../types'; export type APIRegion = | 'default' | 'bytick' - | 'NL' | 'TK' | 'KZ' | 'HK' @@ -114,6 +113,7 @@ export interface RestClientOptions { * @param sortProperties sort properties alphabetically before building a query string * @param encodeSerialisedValues URL encode value before serialising * @returns the params object as a serialised string key1=value1&key2=value2&etc + * Array values are repeated keys (coins=BTC&coins=ETH). */ export function serializeParams( params: object = {}, @@ -127,9 +127,28 @@ export function serializeParams( return properties .map((key) => { + const rawValue = params[key]; + + if (Array.isArray(rawValue)) { + return rawValue + .map((item) => { + const value = encodeSerialisedValues + ? encodeURIComponent(item) + : item; + + if (strict_validation === true && typeof item === 'undefined') { + throw new Error( + 'Failed to sign API request due to undefined parameter', + ); + } + return `${key}=${value}`; + }) + .join('&'); + } + const value = encodeSerialisedValues - ? encodeURIComponent(params[key]) - : params[key]; + ? encodeURIComponent(rawValue) + : rawValue; if (strict_validation === true && typeof value === 'undefined') { throw new Error( @@ -138,6 +157,7 @@ export function serializeParams( } return `${key}=${value}`; }) + .filter((part) => part !== '') .join('&'); } @@ -150,7 +170,6 @@ export function getRestBaseUrl( } = { default: 'https://api.bybit.com', bytick: 'https://api.bytick.com', - NL: 'https://api.bybit.nl', TK: 'https://api.bybit.tr', KZ: 'https://api.bybit.kz', HK: 'https://api.spark-fintech.com', From 09c27c6ce5e70a4cd6231fc70d2a182c401e924e Mon Sep 17 00:00:00 2001 From: Jerko J <83344666+JJ-Cro@users.noreply.github.com> Date: Tue, 6 Oct 2026 16:49:59 +0200 Subject: [PATCH 2/7] chore: update Bybit SDK Quickstart Guide and add tests for serializeParams function Enhancements include formatting improvements in the Quickstart Guide for better readability and clarity. Additionally, a new test suite for the serializeParams function has been added, covering various scenarios such as empty inputs, scalar values, encoding, and array handling to ensure robust parameter serialization. --- docs/BYBIT_SDK_QUICKSTART_GUIDE.md | 112 +++++--- test/util/serializeParams.test.ts | 421 +++++++++++++++++++++++++++++ 2 files changed, 498 insertions(+), 35 deletions(-) create mode 100644 test/util/serializeParams.test.ts diff --git a/docs/BYBIT_SDK_QUICKSTART_GUIDE.md b/docs/BYBIT_SDK_QUICKSTART_GUIDE.md index 7a6bf079..820ac23a 100644 --- a/docs/BYBIT_SDK_QUICKSTART_GUIDE.md +++ b/docs/BYBIT_SDK_QUICKSTART_GUIDE.md @@ -213,11 +213,14 @@ siebly: summary: Browse SDK source, releases, issues, and endpoint coverage from GitHub. href: https://github.com/sieblyio/bybit-api --> + # Bybit API JavaScript Tutorial for Node.js and TypeScript + > [!TIP] > This guide can be read in tutorial format on the Siebly Website: [Bybit JavaScript REST API & WebSocket Tutorial](https://siebly.io/sdk/bybit/javascript/tutorial) + This tutorial walks through a practical Bybit REST API, WebSocket stream, and WebSocket API integration using [`bybit-api`](https://www.npmjs.com/package/bybit-api), the Bybit JavaScript and TypeScript SDK by Siebly.io. It also covers HTTP, HTTPS, and SOCKS proxy configuration for REST API calls, streams, and WebSocket API connections. @@ -238,6 +241,7 @@ The SDK handles the repetitive parts: HMAC and RSA request signing, Bybit API en --- + ## Why use the SDK The Bybit API is unified, but a real integration still has several moving parts: @@ -264,6 +268,7 @@ The method names stay close to Bybit's endpoint names, while the SDK handles bas --- + ## Install and API keys If you do not have Node.js installed yet, install it first. The SDK is published to both [GitHub](https://github.com/sieblyio/bybit-api) and [npm](https://www.npmjs.com/package/bybit-api). @@ -333,6 +338,7 @@ For RSA setup details, see [examples/Auth/RSA-sign.md](../examples/Auth/RSA-sign --- + ## Products and clients For new Bybit integrations, start with the current API. Older Bybit SDK surfaces were split into many product-specific clients; this SDK now centers the current API around one REST API client plus WebSocket clients. @@ -363,6 +369,7 @@ As a rule of thumb: For a complete method map, see [docs/endpointFunctionList.md](./endpointFunctionList.md). + ### REST API, streams, and WebSocket API Bybit exposes several different integration flows. Keep them separate in your architecture: @@ -379,6 +386,7 @@ Use the REST API when you want maximum endpoint coverage or a simple one-off req --- + ## Start building: first calls If you only want the fastest path to a working integration, start here. @@ -386,6 +394,7 @@ If you only want the fastest path to a working integration, start here. ### 1. First public REST API request + ```typescript import { RestClientV5 } from 'bybit-api'; @@ -432,6 +441,7 @@ See also: [public REST API example](../examples/Rest/rest-v5-public.ts) ### 2. First public WebSocket stream + ```typescript import { WebsocketClient, isWsOrderbookEventV5 } from 'bybit-api'; @@ -451,7 +461,10 @@ ws.on('reconnect', (data) => console.log('reconnecting', data.wsKey)); ws.on('reconnected', (data) => console.log('reconnected', data.wsKey)); ws.on('exception', console.error); -ws.subscribeV5(['orderbook.50.BTCUSDT', 'tickers.BTCUSDT', 'publicTrade.BTCUSDT'], 'linear'); +ws.subscribeV5( + ['orderbook.50.BTCUSDT', 'tickers.BTCUSDT', 'publicTrade.BTCUSDT'], + 'linear', +); ``` For public streams, pass the category so the SDK can route the topic to the right public endpoint. @@ -461,6 +474,7 @@ See also: [public WebSocket example](../examples/Websocket/Public/ws-public-v5.t ### 3. First private account WebSocket stream + ```typescript import { WebsocketClient } from 'bybit-api'; @@ -500,6 +514,7 @@ See also: [private WebSocket example](../examples/Websocket/Private/ws-private-v Use demo trading before placing live orders. Demo trading uses a separate Bybit demo account and separate API keys. + ```typescript import { RestClientV5 } from 'bybit-api'; @@ -542,6 +557,7 @@ See also: [Demo trading example](../examples/Rest/demo-trading.ts) The WebSocket API lets you submit order commands over a persistent WebSocket connection and await responses. Bybit supports WebSocket API order commands in live and testnet environments, but not demo trading. + ```typescript import { WebsocketAPIClient } from 'bybit-api'; @@ -592,6 +608,7 @@ See also: [WebSocket API client example](../examples/Websocket/WS-API/ws-api-cli --- + ## REST API Most Bybit integrations start with `RestClientV5`. It covers the current REST API surface and uses Bybit's `category` parameter to distinguish product groups where the endpoint requires it. @@ -888,7 +905,10 @@ const coinBalance = await client.getCoinBalance({ coin: 'USDT', }); -const transferableCoins = await client.getTransferableCoinList('UNIFIED', 'FUND'); +const transferableCoins = await client.getTransferableCoinList( + 'UNIFIED', + 'FUND', +); const deposits = await client.getDepositRecords({ coin: 'USDT', @@ -922,6 +942,7 @@ If an endpoint exists in Bybit's API docs, search for the endpoint path or metho --- + ## WebSocket Streams Use `WebsocketClient` when you want event-driven updates instead of REST API polling. The same client handles public streams, private account streams, and raw WebSocket API commands. @@ -969,7 +990,12 @@ ws.on('update', (data) => console.log('public update', JSON.stringify(data))); ws.on('exception', console.error); ws.subscribeV5( - ['orderbook.50.BTCUSDT', 'publicTrade.BTCUSDT', 'tickers.BTCUSDT', 'kline.5.BTCUSDT'], + [ + 'orderbook.50.BTCUSDT', + 'publicTrade.BTCUSDT', + 'tickers.BTCUSDT', + 'kline.5.BTCUSDT', + ], 'linear', ); ``` @@ -1011,7 +1037,10 @@ ws.on('authenticated', (data) => console.log('authenticated', data.wsKey)); ws.on('update', (data) => console.log('private update', JSON.stringify(data))); ws.on('exception', console.error); -ws.subscribeV5(['order', 'execution', 'position', 'wallet', 'greeks'], 'linear'); +ws.subscribeV5( + ['order', 'execution', 'position', 'wallet', 'greeks'], + 'linear', +); ``` Private topics currently share the private endpoint. The category parameter is ignored for private routing, but passing the category keeps your code consistent with `subscribeV5(...)`. @@ -1044,6 +1073,7 @@ Do not subscribe to the same topic in multiple clients unless you intentionally --- + ## WebSocket API Bybit's WebSocket API is a request/response API over a persistent WebSocket connection. In this SDK, you can use it in two ways: @@ -1123,15 +1153,19 @@ const ws = new WebsocketClient({ testnet: true, }); -const result = await ws.sendWSAPIRequest(WS_KEY_MAP.v5PrivateTrade, 'order.create', { - category: 'linear', - symbol: 'BTCUSDT', - side: 'Buy', - orderType: 'Limit', - qty: '0.001', - price: '10000', - timeInForce: 'PostOnly', -}); +const result = await ws.sendWSAPIRequest( + WS_KEY_MAP.v5PrivateTrade, + 'order.create', + { + category: 'linear', + symbol: 'BTCUSDT', + side: 'Buy', + orderType: 'Limit', + qty: '0.001', + price: '10000', + timeInForce: 'PostOnly', + }, +); console.log(result); ``` @@ -1148,6 +1182,7 @@ See also: --- + ## Environments and regions ### Live @@ -1213,11 +1248,11 @@ Do not combine `testnet: true` with `demoTrading: true`. Bybit's demo trading do Bybit uses two regional API access models. Use the configuration that matches the site where your account is registered: -| Account setup | REST API endpoint | WebSocket endpoint | SDK configuration | -| --- | --- | --- | --- | -| Account with a dedicated regional domain | Matching regional API domain | Regional mainnet stream when Bybit lists one, otherwise the global stream | Set `apiRegion` | -| Brazil international account | `api.bybit.com` | `stream.bybit.com` | Set `siteId: 'BRA_BTL'` | -| Argentina international account | `api.bybit.com` | `stream.bybit.com` | Set `siteId: 'ARG_BTL'` | +| Account setup | REST API endpoint | WebSocket endpoint | SDK configuration | +| ---------------------------------------- | ---------------------------- | ------------------------------------------------------------------------- | ----------------------- | +| Account with a dedicated regional domain | Matching regional API domain | Regional mainnet stream when Bybit lists one, otherwise the global stream | Set `apiRegion` | +| Brazil international account | `api.bybit.com` | `stream.bybit.com` | Set `siteId: 'BRA_BTL'` | +| Argentina international account | `api.bybit.com` | `stream.bybit.com` | Set `siteId: 'ARG_BTL'` | `apiRegion` selects the regional REST API domain and, where Bybit lists one, the regional mainnet WebSocket domain. `siteId` keeps the default global domains and adds the `x-site-id` header to REST API requests and Node.js WebSocket handshakes. Only set `siteId` when Bybit documents it for your account. Do not derive or invent a value. @@ -1299,6 +1334,7 @@ See also: [custom REST API URL example](../examples/Rest/rest-v5-custom-url.ts) --- + ## Proxies for REST API and WebSocket Use a proxy when a deployment needs a fixed egress IP, must cross an approved corporate network, or has a controlled network failover path. A proxy does not change Bybit account eligibility, product categories, account mode, or the selected live, testnet, or demo environment. @@ -1400,7 +1436,9 @@ const key = process.env.BYBIT_API_KEY; const secret = process.env.BYBIT_API_SECRET; if (!key || !secret) { - throw new Error('Set BYBIT_API_KEY and BYBIT_API_SECRET before running this example.'); + throw new Error( + 'Set BYBIT_API_KEY and BYBIT_API_SECRET before running this example.', + ); } const proxyAgent = new HttpsProxyAgent(proxyUrl); @@ -1519,6 +1557,7 @@ See also: --- + ## Production notes Before a Bybit integration trades unattended, make these decisions explicit. @@ -1546,22 +1585,23 @@ When the SDK emits `reconnect`, pause risky actions if your strategy depends on ws.on('reconnected', async ({ wsKey }) => { console.log('reconnected', wsKey); - const [wallet, positions, regularOpenOrders, stopOpenOrders] = await Promise.all([ - client.getWalletBalance({ accountType: 'UNIFIED' }), - client.getPositionInfo({ category: 'linear', settleCoin: 'USDT' }), - client.getActiveOrders({ - category: 'linear', - settleCoin: 'USDT', - openOnly: 0, - orderFilter: 'Order', - }), - client.getActiveOrders({ - category: 'linear', - settleCoin: 'USDT', - openOnly: 0, - orderFilter: 'StopOrder', - }), - ]); + const [wallet, positions, regularOpenOrders, stopOpenOrders] = + await Promise.all([ + client.getWalletBalance({ accountType: 'UNIFIED' }), + client.getPositionInfo({ category: 'linear', settleCoin: 'USDT' }), + client.getActiveOrders({ + category: 'linear', + settleCoin: 'USDT', + openOnly: 0, + orderFilter: 'Order', + }), + client.getActiveOrders({ + category: 'linear', + settleCoin: 'USDT', + openOnly: 0, + orderFilter: 'StopOrder', + }), + ]); const openOrders = [ ...(regularOpenOrders.result?.list ?? []), @@ -1717,6 +1757,7 @@ For raw HTTP request/response tracing during local debugging, the repo also supp --- + ## FAQ **Do I need API keys for public market data?** @@ -1763,6 +1804,7 @@ No. This guide covers the common first steps and production concerns. For full m --- + ## Next steps If you want to learn more about integrating with the Bybit API and WebSockets: diff --git a/test/util/serializeParams.test.ts b/test/util/serializeParams.test.ts new file mode 100644 index 00000000..ee7e57ee --- /dev/null +++ b/test/util/serializeParams.test.ts @@ -0,0 +1,421 @@ +import { serializeParams } from '../../src/util/requestUtils'; + +const undefinedParamError = + 'Failed to sign API request due to undefined parameter'; + +/** + * Private GET signing calls serializeParams(params, strict, false, encode). + * sortProperties is false on that path. The function default is true. + */ +function serializeForSigning( + params: object, + strictValidation = false, + encodeValues = true, +): string { + return serializeParams(params, strictValidation, false, encodeValues); +} + +describe('serializeParams', () => { + describe('empty input', () => { + it('returns an empty string when called with no arguments', () => { + expect(serializeParams()).toBe(''); + }); + + it('returns an empty string for undefined params', () => { + expect(serializeParams(undefined)).toBe(''); + }); + + it('returns an empty string for an empty object', () => { + expect(serializeParams({})).toBe(''); + }); + + it('throws when params is null', () => { + expect(() => serializeParams(null as unknown as object)).toThrow( + TypeError, + ); + }); + }); + + describe('scalar values', () => { + it('serialises one string', () => { + expect(serializeParams({ symbol: 'BTCUSDT' })).toBe('symbol=BTCUSDT'); + }); + + it('sorts string keys alphabetically by default', () => { + expect( + serializeParams({ + symbol: 'BTCUSDT', + category: 'linear', + limit: '50', + }), + ).toBe('category=linear&limit=50&symbol=BTCUSDT'); + }); + + it('keeps insertion order when sortProperties is false', () => { + expect( + serializeParams( + { symbol: 'BTCUSDT', category: 'linear', limit: '50' }, + false, + false, + ), + ).toBe('symbol=BTCUSDT&category=linear&limit=50'); + }); + + it('serialises integers, floats, and negative numbers', () => { + expect( + serializeParams({ + limit: 50, + price: 1.25, + offset: -3, + }), + ).toBe('limit=50&offset=-3&price=1.25'); + }); + + it('serialises true and false', () => { + expect(serializeParams({ reduceOnly: false, isSelected: true })).toBe( + 'isSelected=true&reduceOnly=false', + ); + }); + + it('serialises null as the string null', () => { + expect(serializeParams({ cursor: null })).toBe('cursor=null'); + }); + + it('keeps an empty string value', () => { + expect(serializeParams({ cursor: '' })).toBe('cursor='); + }); + + it('serialises NaN and Infinity through ToString', () => { + expect( + serializeParams({ bad: Number.NaN, big: Number.POSITIVE_INFINITY }), + ).toBe('bad=NaN&big=Infinity'); + }); + + it('serialises a bigint', () => { + expect(serializeParams({ limit: BigInt(1) })).toBe('limit=1'); + }); + }); + + describe('encoding', () => { + it('encodes space, plus, percent, ampersand, equals, unicode, and slash', () => { + expect( + serializeParams({ + space: 'a b', + plus: 'a+b', + percent: 'abc%def', + pair: 'a&b=c', + coin: '乙', + symbol: 'BTC/USDT', + }), + ).toBe( + 'coin=%E4%B9%99&pair=a%26b%3Dc&percent=abc%25def&plus=a%2Bb&space=a%20b&symbol=BTC%2FUSDT', + ); + }); + + it('leaves special characters raw when encoding is disabled', () => { + expect( + serializeParams( + { + cursor: 'abc%def', + pair: 'a&b=c', + space: 'a b', + }, + false, + true, + false, + ), + ).toBe('cursor=abc%def&pair=a&b=c&space=a b'); + }); + + it('encodes a percent in a cursor so it cannot break the signature', () => { + expect(serializeParams({ cursor: 'abc%def' })).toBe('cursor=abc%25def'); + }); + + it('does not split a comma-separated string into repeated keys', () => { + expect(serializeParams({ coins: 'BTC,ETH' })).toBe('coins=BTC%2CETH'); + }); + + it('does not encode the key itself', () => { + expect(serializeParams({ 'a b': 'c' })).toBe('a b=c'); + }); + }); + + describe('key order', () => { + it('sorts uppercase before lowercase', () => { + expect(serializeParams({ symbol: 'B', Symbol: 'A' })).toBe( + 'Symbol=A&symbol=B', + ); + }); + + it('sorts numeric-looking keys lexicographically, not numerically', () => { + expect(serializeParams({ 10: 'x', 2: 'y' })).toBe('10=x&2=y'); + }); + + it('lists integer-index keys first when sorting is disabled', () => { + expect( + serializeParams({ b: '1', a: '2', 10: 'x', 2: 'y' }, false, false), + ).toBe('2=y&10=x&b=1&a=2'); + }); + + it('ignores symbol keys', () => { + const params: Record = { symbol: 'BTCUSDT' }; + params[Symbol('hidden')] = 'nope'; + + expect(serializeParams(params)).toBe('symbol=BTCUSDT'); + }); + + it('ignores inherited keys', () => { + const proto = { leaked: 'yes' }; + const params = Object.create(proto) as { symbol?: string }; + params.symbol = 'BTCUSDT'; + + expect(serializeParams(params)).toBe('symbol=BTCUSDT'); + }); + + it('stringifies a plain object instead of expanding it', () => { + expect(serializeParams({ extra: { coin: 'BTC' } })).toBe( + 'extra=%5Bobject%20Object%5D', + ); + }); + + it('does not treat an array-like object as an array', () => { + expect( + serializeParams({ + list: { 0: 'BTC', 1: 'ETH', length: 2 }, + }), + ).toBe('list=%5Bobject%20Object%5D'); + }); + }); + + describe('arrays', () => { + it('repeats the key once per item', () => { + expect(serializeParams({ coins: ['BTC', 'ETH'] })).toBe( + 'coins=BTC&coins=ETH', + ); + }); + + it('keeps array item order and does not sort the items', () => { + expect(serializeParams({ coins: ['ETH', 'BTC', 'SOL'] })).toBe( + 'coins=ETH&coins=BTC&coins=SOL', + ); + }); + + it('serialises a one-item array as a single pair', () => { + expect(serializeParams({ coins: ['BTC'] })).toBe('coins=BTC'); + }); + + it('serialises numbers and booleans inside an array', () => { + expect(serializeParams({ side: [0, 1, false, true] })).toBe( + 'side=0&side=1&side=false&side=true', + ); + }); + + it('serialises null inside an array as the string null', () => { + expect(serializeParams({ coins: [null] })).toBe('coins=null'); + }); + + it('keeps an empty string inside an array', () => { + expect(serializeParams({ coins: ['', 'BTC'] })).toBe('coins=&coins=BTC'); + }); + + it('encodes special characters inside array items', () => { + expect(serializeParams({ coins: ['BTC USDT', 'ETH&SOL', 'a+b'] })).toBe( + 'coins=BTC%20USDT&coins=ETH%26SOL&coins=a%2Bb', + ); + }); + + it('leaves array items raw when encoding is disabled', () => { + expect( + serializeParams({ coins: ['BTC USDT', 'ETH&SOL'] }, false, true, false), + ).toBe('coins=BTC USDT&coins=ETH&SOL'); + }); + + it('stringifies a nested array as one comma-joined value', () => { + expect(serializeParams({ coins: [['BTC', 'ETH']] })).toBe( + 'coins=BTC%2CETH', + ); + }); + + it('stringifies an object inside an array', () => { + expect(serializeParams({ coins: [{ coin: 'BTC' }] })).toBe( + 'coins=%5Bobject%20Object%5D', + ); + }); + + it('omits an empty array', () => { + expect(serializeParams({ coins: [] })).toBe(''); + }); + + it('omits an empty array without leaving a dangling ampersand when sorted', () => { + expect( + serializeParams({ + symbol: 'BTCUSDT', + coins: [], + category: 'spot', + }), + ).toBe('category=spot&symbol=BTCUSDT'); + }); + + it('omits an empty array without leaving a dangling ampersand in insertion order', () => { + expect( + serializeParams( + { symbol: 'BTCUSDT', coins: [], category: 'spot' }, + false, + false, + ), + ).toBe('symbol=BTCUSDT&category=spot'); + }); + + it('returns an empty string when every value is an empty array', () => { + expect(serializeParams({ a: [], b: [] })).toBe(''); + }); + + it('serialises more than one array and sorts the keys around them', () => { + expect( + serializeParams({ + tags: ['ST'], + coins: ['BTC', 'ETH'], + }), + ).toBe('coins=BTC&coins=ETH&tags=ST'); + }); + + it('preserves order across a long array', () => { + const coins = Array.from({ length: 50 }, (_, index) => `C${index}`); + + expect(serializeParams({ coins })).toBe( + coins.map((coin) => `coins=${coin}`).join('&'), + ); + }); + + it('turns a sparse hole into an empty join gap', () => { + // map skips holes, then join treats the skipped slot as an empty string. + const coins = ['BTC']; + coins[2] = 'ETH'; + + expect(serializeParams({ coins }, false)).toBe('coins=BTC&&coins=ETH'); + }); + }); + + describe('strict validation', () => { + it('throws when an array item is undefined', () => { + expect(() => + serializeParams({ coins: ['BTC', undefined] }, true), + ).toThrow(undefinedParamError); + }); + + it('throws for an undefined array item even when encoding is disabled', () => { + expect(() => + serializeParams({ coins: [undefined, 'ETH'] }, true, true, false), + ).toThrow(undefinedParamError); + }); + + it('does not throw for a sparse hole, even when strict validation is on', () => { + const coins = ['BTC']; + coins[2] = 'ETH'; + + expect(serializeParams({ coins }, true)).toBe('coins=BTC&&coins=ETH'); + }); + + it('allows a fully defined array when strict validation is on', () => { + expect(serializeParams({ coins: ['BTC', 'ETH'] }, true)).toBe( + 'coins=BTC&coins=ETH', + ); + }); + + it('does not throw for a scalar undefined when encoding is on', () => { + // encodeURIComponent(undefined) is the string "undefined", so the + // typeof check never sees the original undefined value. + expect(serializeParams({ cursor: undefined }, true, true, true)).toBe( + 'cursor=undefined', + ); + }); + + it('throws for a scalar undefined when encoding is off', () => { + expect(() => + serializeParams({ cursor: undefined }, true, true, false), + ).toThrow(undefinedParamError); + }); + + it('serialises a scalar undefined as the string undefined when strict validation is off', () => { + expect(serializeParams({ cursor: undefined }, false, true, true)).toBe( + 'cursor=undefined', + ); + expect(serializeParams({ cursor: undefined }, false, true, false)).toBe( + 'cursor=undefined', + ); + }); + }); + + describe('values that must not be dropped', () => { + it('keeps zero and false next to a normal string', () => { + expect( + serializeParams({ + symbol: 'BTCUSDT', + limit: 0, + reduceOnly: false, + }), + ).toBe('limit=0&reduceOnly=false&symbol=BTCUSDT'); + }); + + it('keeps zero and false inside an array', () => { + expect(serializeParams({ flags: [0, false, ''] })).toBe( + 'flags=0&flags=false&flags=', + ); + }); + }); + + describe('private GET signing call', () => { + it('keeps caller key order instead of sorting', () => { + expect( + serializeForSigning({ + category: 'linear', + symbol: 'BTCUSDT', + limit: 50, + }), + ).toBe('category=linear&symbol=BTCUSDT&limit=50'); + }); + + it('repeats coins in caller order', () => { + expect(serializeForSigning({ coins: ['ETH', 'BTC'] })).toBe( + 'coins=ETH&coins=BTC', + ); + }); + + it('places a repeated coins list after earlier scalar params', () => { + expect( + serializeForSigning({ + category: 'spot', + coins: ['BTC', 'ETH'], + }), + ).toBe('category=spot&coins=BTC&coins=ETH'); + }); + + it('drops an empty coins list without joining the neighbours with a double ampersand', () => { + expect( + serializeForSigning({ + category: 'spot', + coins: [], + symbol: 'BTCUSDT', + }), + ).toBe('category=spot&symbol=BTCUSDT'); + }); + + it('encodes a cursor percent on the signing path', () => { + expect(serializeForSigning({ cursor: 'abc%def' })).toBe( + 'cursor=abc%25def', + ); + }); + + it('can disable encoding on the signing path', () => { + expect(serializeForSigning({ cursor: 'abc%def' }, false, false)).toBe( + 'cursor=abc%def', + ); + }); + + it('still throws for an undefined array item on the signing path', () => { + expect(() => + serializeForSigning({ coins: ['BTC', undefined] }, true), + ).toThrow(undefinedParamError); + }); + }); +}); From e1fc7172ed0a3f26d9c55ca96d6a5fa6e28261f6 Mon Sep 17 00:00:00 2001 From: "Tiago Siebler @ Siebly.io" Date: Thu, 8 Oct 2026 14:13:03 +0100 Subject: [PATCH 3/7] chore: logo updates to fix adaptive background --- docs/images/logoBrightMode2.svg | 1 + docs/images/logoDarkMode2.svg | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/images/logoBrightMode2.svg b/docs/images/logoBrightMode2.svg index ce117491..90249839 100644 --- a/docs/images/logoBrightMode2.svg +++ b/docs/images/logoBrightMode2.svg @@ -1,5 +1,6 @@ + diff --git a/docs/images/logoDarkMode2.svg b/docs/images/logoDarkMode2.svg index bc5fe947..9feb2bc6 100644 --- a/docs/images/logoDarkMode2.svg +++ b/docs/images/logoDarkMode2.svg @@ -1,5 +1,6 @@ + From 281da2b2213717a3a33f761aa6539d1e7541d75a Mon Sep 17 00:00:00 2001 From: "Tiago Siebler @ Siebly.io" Date: Thu, 8 Oct 2026 15:18:55 +0100 Subject: [PATCH 4/7] feat: tighten new serialisation gates & more tests to protect old vs new behaviour --- .github/workflows/e2etest.yml | 14 +- src/rest-client-v5.ts | 4 +- src/util/BaseRestClient.ts | 92 ++++++++---- src/util/requestUtils.ts | 69 +++++---- test/util/serializeParams.test.ts | 180 +++++++++++++++++----- test/v5/private.serialization.test.ts | 208 ++++++++++++++++++++++++++ 6 files changed, 460 insertions(+), 107 deletions(-) create mode 100644 test/v5/private.serialization.test.ts diff --git a/.github/workflows/e2etest.yml b/.github/workflows/e2etest.yml index 01e568ed..3de91195 100644 --- a/.github/workflows/e2etest.yml +++ b/.github/workflows/e2etest.yml @@ -12,7 +12,6 @@ env: PROXY_PORT: ${{ secrets.PROXY_PORT }} PROXY_USER: ${{ secrets.PROXY_USER }} - jobs: E2ETests: name: 'Build & Test' @@ -34,6 +33,9 @@ jobs: - name: Build run: npm run build + - name: Test parameter serialization + run: npm run test -- --runInBand --runTestsByPath test/util/serializeParams.test.ts + - name: Test Public Read API Calls run: npm run test -- public.read.test.ts @@ -57,13 +59,13 @@ jobs: env: API_KEY_COM_RSA: ${{ secrets.API_KEY_COM_RSA }} API_SECRET_COM_RSA: ${{ secrets.API_SECRET_COM_RSA }} - + - name: Test Private Write RSA API Calls run: npm run test -- private.writeRSA.test.ts env: API_KEY_COM_RSA: ${{ secrets.API_KEY_COM_RSA }} API_SECRET_COM_RSA: ${{ secrets.API_SECRET_COM_RSA }} - + - name: Test RSA/HMAC automatic detection run: npm run test -- rsa-auth.test.ts env: @@ -72,4 +74,8 @@ jobs: API_KEY_COM_RSA: ${{ secrets.API_KEY_COM_RSA }} API_SECRET_COM_RSA: ${{ secrets.API_SECRET_COM_RSA }} - + - name: Test live private GET serialization (HMAC) + run: npm run test -- --runInBand --runTestsByPath test/v5/private.serialization.test.ts + env: + API_KEY_COM: ${{ secrets.API_KEY_COM }} + API_SECRET_COM: ${{ secrets.API_SECRET_COM }} diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index 4983dc2f..1470cf74 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -4788,7 +4788,9 @@ export class RestClientV5 extends BaseRestClient { getFlexibleSavingAutoSavings( params?: GetFlexibleSavingAutoSavingsParamsV5, ): Promise> { - return this.getPrivate('/v5/earn/flexible-saving/auto-savings', params); + return this.getPrivate('/v5/earn/flexible-saving/auto-savings', params, { + serialiserArrayFormat: 'repeat', + }); } /** diff --git a/src/util/BaseRestClient.ts b/src/util/BaseRestClient.ts index 26a15c01..c914d616 100644 --- a/src/util/BaseRestClient.ts +++ b/src/util/BaseRestClient.ts @@ -10,6 +10,7 @@ import { getRestBaseUrl, isEUAPIRegion, parseRateLimitHeaders, + RestCallOptions, RestClientOptions, RestClientType, serializeParams, @@ -60,6 +61,12 @@ if (ENABLE_HTTP_TRACE) { }); } +/** Request flags set by the REST method, rather than by the caller. */ +interface InternalRestCallOptions extends RestCallOptions { + isPublicApi: boolean; + isFileUpload?: boolean; +} + interface SignedRequestContext { timestamp?: number; api_key?: string; @@ -200,36 +207,56 @@ export default abstract class BaseRestClient { } } - get(endpoint: string, params?: any) { - const isPublicAPI = true; - return this._call('GET', endpoint, params, isPublicAPI); + get(endpoint: string, params?: any, callOptions?: RestCallOptions) { + return this._call('GET', endpoint, params, { + ...callOptions, + isPublicApi: true, + isFileUpload: false, + }); } - getPrivate(endpoint: string, params?: any) { - const isPublicAPI = false; - return this._call('GET', endpoint, params, isPublicAPI); + getPrivate(endpoint: string, params?: any, callOptions?: RestCallOptions) { + return this._call('GET', endpoint, params, { + ...callOptions, + isPublicApi: false, + isFileUpload: false, + }); } - post(endpoint: string, params?: any) { - const isPublicAPI = true; - return this._call('POST', endpoint, params, isPublicAPI); + post(endpoint: string, params?: any, callOptions?: RestCallOptions) { + return this._call('POST', endpoint, params, { + ...callOptions, + isPublicApi: true, + isFileUpload: false, + }); } - postPrivate(endpoint: string, params?: any) { - const isPublicAPI = false; - return this._call('POST', endpoint, params, isPublicAPI); + postPrivate(endpoint: string, params?: any, callOptions?: RestCallOptions) { + return this._call('POST', endpoint, params, { + ...callOptions, + isPublicApi: false, + isFileUpload: false, + }); } - postPrivateFile(endpoint: string, params?: FileUploadRequestParams) { - const isPublicAPI = false; - const isFileUpload = true; - - return this._call('POST', endpoint, params, isPublicAPI, isFileUpload); + postPrivateFile( + endpoint: string, + params?: FileUploadRequestParams, + callOptions?: RestCallOptions, + ) { + return this._call('POST', endpoint, params, { + ...callOptions, + isPublicApi: false, + isFileUpload: true, + }); } - deletePrivate(endpoint: string, params?: any) { - const isPublicAPI = false; - return this._call('DELETE', endpoint, params, isPublicAPI); + deletePrivate(endpoint: string, params?: any, callOptions?: RestCallOptions) { + return this._call('DELETE', endpoint, params, { + ...callOptions, + isPublicApi: false, + isFileUpload: false, + }); } private async prepareSignParams( @@ -237,6 +264,7 @@ export default abstract class BaseRestClient { signMethod: SignMethod, params?: TParams, isPublicApi?: true, + callOptions?: RestCallOptions, ): Promise>; private async prepareSignParams( @@ -244,6 +272,7 @@ export default abstract class BaseRestClient { signMethod: SignMethod, params?: TParams, isPublicApi?: false | undefined, + callOptions?: RestCallOptions, ): Promise>; private async prepareSignParams( @@ -251,6 +280,7 @@ export default abstract class BaseRestClient { signMethod: SignMethod, params?: TParams, isPublicApi?: boolean, + callOptions?: RestCallOptions, ): Promise | UnsignedRequest>; private async prepareSignParams( @@ -258,6 +288,7 @@ export default abstract class BaseRestClient { signMethod: SignMethod, params?: TParams, isPublicApi?: boolean, + callOptions?: RestCallOptions, ) { if (isPublicApi) { return { @@ -278,17 +309,17 @@ export default abstract class BaseRestClient { this.timeOffset = await this.fetchTimeOffset(); } - return this.signRequest(params || {}, method, signMethod); + return this.signRequest(params || {}, method, signMethod, callOptions); } /** Returns an axios request object. Handles signing process automatically if this is a private API call */ private async buildRequest( method: Method, url: string, - params?: any, - isPublicApi?: boolean, - isFileUpload?: boolean, + params: any, + callOptions: InternalRestCallOptions, ): Promise { + const { isPublicApi, isFileUpload } = callOptions; const options: AxiosRequestConfig = { ...this.globalRequestOptions, url: url, @@ -313,6 +344,7 @@ export default abstract class BaseRestClient { isFileUpload ? 'v5authWithFile' : 'v5auth', params, isPublicApi, + callOptions, ); const headers: AxiosRequestConfig['headers'] = { @@ -351,9 +383,8 @@ export default abstract class BaseRestClient { private async _call( method: Method, endpoint: string, - params?: any, - isPublicApi?: boolean, - isFileUpload?: boolean, + params: any, + callOptions: InternalRestCallOptions, ): Promise { // Sanity check to make sure it's only ever prefixed by one forward slash const requestUrl = [this.baseUrl, endpoint].join( @@ -365,14 +396,13 @@ export default abstract class BaseRestClient { method, requestUrl, params, - isPublicApi, - isFileUpload, + callOptions, ); if (ENABLE_HTTP_TRACE) { console.log( 'full request: ', - isFileUpload + callOptions.isFileUpload ? { ...options, data: ``, @@ -458,6 +488,7 @@ export default abstract class BaseRestClient { data: T, method: Method, signMethod: SignMethod, + callOptions?: RestCallOptions, ): Promise> { const timestamp = Date.now() + (this.timeOffset || 0); @@ -516,6 +547,7 @@ export default abstract class BaseRestClient { strictParamValidation, sortProperties, encodeSerialisedValues, + callOptions?.serialiserArrayFormat, ) : JSON.stringify(res.originalParams); diff --git a/src/util/requestUtils.ts b/src/util/requestUtils.ts index 8aa86402..c2b4dbd0 100644 --- a/src/util/requestUtils.ts +++ b/src/util/requestUtils.ts @@ -14,6 +14,23 @@ export type APIRegion = | 'ID' | 'JP'; +/** SDK options for an individual REST method call, separate from API parameters. */ +export interface RestCallOptions { + /** + * Array format for private GET query parameters. Values: + * + * - `comma` (default): `{ coins: ["BTC", "ETH"] }` becomes + * `?coins=BTC%2CETH`. An empty array becomes `?coins=`. + * - `repeat`: `{ coins: ["BTC", "ETH"] }` becomes `?coins=BTC&coins=ETH`. + * Some endpoints require this. Empty arrays are omitted completely. + * + * Examples assume `encodeSerialisedValues` is enabled (the default). + * Public requests and JSON/multipart bodies retain their existing + * serialization. + */ + serialiserArrayFormat?: 'comma' | 'repeat'; +} + export interface RestClientOptions { /** Your API key */ key?: string; @@ -112,53 +129,43 @@ export interface RestClientOptions { * @param strict_validation throw if any properties are undefined * @param sortProperties sort properties alphabetically before building a query string * @param encodeSerialisedValues URL encode value before serialising + * @param arrayFormat array representation, defaulting to legacy comma coercion * @returns the params object as a serialised string key1=value1&key2=value2&etc - * Array values are repeated keys (coins=BTC&coins=ETH). */ export function serializeParams( params: object = {}, strict_validation = false, sortProperties = true, encodeSerialisedValues = true, + arrayFormat: RestCallOptions['serialiserArrayFormat'] = 'comma', ): string { const properties = sortProperties ? Object.keys(params).sort() : Object.keys(params); - return properties - .map((key) => { - const rawValue = params[key]; - - if (Array.isArray(rawValue)) { - return rawValue - .map((item) => { - const value = encodeSerialisedValues - ? encodeURIComponent(item) - : item; - - if (strict_validation === true && typeof item === 'undefined') { - throw new Error( - 'Failed to sign API request due to undefined parameter', - ); - } - return `${key}=${value}`; - }) - .join('&'); - } - - const value = encodeSerialisedValues - ? encodeURIComponent(rawValue) - : rawValue; - - if (strict_validation === true && typeof value === 'undefined') { + const parts: string[] = []; + for (const key of properties) { + const rawValue = params[key]; + const repeatArray = arrayFormat === 'repeat' && Array.isArray(rawValue); + const values = repeatArray ? rawValue : [rawValue]; + + for (const item of values) { + const value = encodeSerialisedValues ? encodeURIComponent(item) : item; + + // Preserve legacy validation after coercion; repeated items validate raw values. + const validationValue = repeatArray ? item : value; + if ( + strict_validation === true && + typeof validationValue === 'undefined' + ) { throw new Error( 'Failed to sign API request due to undefined parameter', ); } - return `${key}=${value}`; - }) - .filter((part) => part !== '') - .join('&'); + parts.push(`${key}=${value}`); + } + } + return parts.join('&'); } export function getRestBaseUrl( diff --git a/test/util/serializeParams.test.ts b/test/util/serializeParams.test.ts index ee7e57ee..a057714b 100644 --- a/test/util/serializeParams.test.ts +++ b/test/util/serializeParams.test.ts @@ -4,15 +4,37 @@ const undefinedParamError = 'Failed to sign API request due to undefined parameter'; /** - * Private GET signing calls serializeParams(params, strict, false, encode). + * Private GET requests preserve insertion order when serializing parameters. * sortProperties is false on that path. The function default is true. */ -function serializeForSigning( +function serializeForRepeatedQuery( params: object, strictValidation = false, encodeValues = true, ): string { - return serializeParams(params, strictValidation, false, encodeValues); + const sortProperties = false; // preserve insertion order for repeated query params + return serializeParams( + params, + strictValidation, + sortProperties, + encodeValues, + 'repeat', + ); +} + +function serializeRepeatedParams( + params: object, + strictValidation = false, + sortProperties = true, + encodeValues = true, +): string { + return serializeParams( + params, + strictValidation, + sortProperties, + encodeValues, + 'repeat', + ); } describe('serializeParams', () => { @@ -187,68 +209,136 @@ describe('serializeParams', () => { }); }); - describe('arrays', () => { + describe.each([false, true])('legacy arrays, strict=%s', (strict) => { + describe.each([false, true])('sorted=%s', (sorted) => { + describe.each([false, true])('encoded=%s', (encoded) => { + it.each([ + { coins: ['BTC', 'ETH'], raw: 'BTC,ETH', escaped: 'BTC%2CETH' }, + { coins: [], raw: '', escaped: '' }, + { + coins: [null, undefined, 'BTC'], + raw: ',,BTC', + escaped: '%2C%2CBTC', + }, + { coins: [0, false, ''], raw: '0,false,', escaped: '0%2Cfalse%2C' }, + { coins: ['a&b', 'c d'], raw: 'a&b,c d', escaped: 'a%26b%2Cc%20d' }, + { + coins: [['BTC', 'ETH'], ['SOL']], + raw: 'BTC,ETH,SOL', + escaped: 'BTC%2CETH%2CSOL', + }, + ])('preserves legacy coercion of $coins', ({ coins, raw, escaped }) => { + const expected = `coins=${encoded ? escaped : raw}`; + expect(serializeParams({ coins }, strict, sorted, encoded)).toBe( + expected, + ); + expect( + serializeParams({ coins }, strict, sorted, encoded, 'comma'), + ).toBe(expected); + }); + }); + }); + }); + + it('preserves empty legacy arrays between scalar values', () => { + expect(serializeParams({ z: 0, coins: [], a: false }, false, false)).toBe( + 'z=0&coins=&a=false', + ); + expect(serializeParams({ z: 0, coins: [], a: false })).toBe( + 'a=false&coins=&z=0', + ); + }); + + it('preserves legacy sparse-array coercion, including strict mode', () => { + const coins = ['BTC']; + coins[2] = 'ETH'; + expect(serializeParams({ coins }, true)).toBe('coins=BTC%2C%2CETH'); + }); + + it.each(['comma', 'repeat'] as const)( + 'does not mutate input in %s mode', + (format) => { + const coins = Object.freeze(['ETH', 'BTC']); + const params = Object.freeze({ z: 0, coins, a: false }); + expect(serializeParams(params, false, true, true, format)).toBe( + format === 'comma' + ? 'a=false&coins=ETH%2CBTC&z=0' + : 'a=false&coins=ETH&coins=BTC&z=0', + ); + expect(Object.keys(params)).toEqual(['z', 'coins', 'a']); + expect(coins).toEqual(['ETH', 'BTC']); + }, + ); + + describe('explicit repeated-key arrays', () => { it('repeats the key once per item', () => { - expect(serializeParams({ coins: ['BTC', 'ETH'] })).toBe( + expect(serializeRepeatedParams({ coins: ['BTC', 'ETH'] })).toBe( 'coins=BTC&coins=ETH', ); }); it('keeps array item order and does not sort the items', () => { - expect(serializeParams({ coins: ['ETH', 'BTC', 'SOL'] })).toBe( + expect(serializeRepeatedParams({ coins: ['ETH', 'BTC', 'SOL'] })).toBe( 'coins=ETH&coins=BTC&coins=SOL', ); }); it('serialises a one-item array as a single pair', () => { - expect(serializeParams({ coins: ['BTC'] })).toBe('coins=BTC'); + expect(serializeRepeatedParams({ coins: ['BTC'] })).toBe('coins=BTC'); }); it('serialises numbers and booleans inside an array', () => { - expect(serializeParams({ side: [0, 1, false, true] })).toBe( + expect(serializeRepeatedParams({ side: [0, 1, false, true] })).toBe( 'side=0&side=1&side=false&side=true', ); }); it('serialises null inside an array as the string null', () => { - expect(serializeParams({ coins: [null] })).toBe('coins=null'); + expect(serializeRepeatedParams({ coins: [null] })).toBe('coins=null'); }); it('keeps an empty string inside an array', () => { - expect(serializeParams({ coins: ['', 'BTC'] })).toBe('coins=&coins=BTC'); + expect(serializeRepeatedParams({ coins: ['', 'BTC'] })).toBe( + 'coins=&coins=BTC', + ); }); it('encodes special characters inside array items', () => { - expect(serializeParams({ coins: ['BTC USDT', 'ETH&SOL', 'a+b'] })).toBe( - 'coins=BTC%20USDT&coins=ETH%26SOL&coins=a%2Bb', - ); + expect( + serializeRepeatedParams({ coins: ['BTC USDT', 'ETH&SOL', 'a+b'] }), + ).toBe('coins=BTC%20USDT&coins=ETH%26SOL&coins=a%2Bb'); }); it('leaves array items raw when encoding is disabled', () => { expect( - serializeParams({ coins: ['BTC USDT', 'ETH&SOL'] }, false, true, false), + serializeRepeatedParams( + { coins: ['BTC USDT', 'ETH&SOL'] }, + false, + true, + false, + ), ).toBe('coins=BTC USDT&coins=ETH&SOL'); }); it('stringifies a nested array as one comma-joined value', () => { - expect(serializeParams({ coins: [['BTC', 'ETH']] })).toBe( + expect(serializeRepeatedParams({ coins: [['BTC', 'ETH']] })).toBe( 'coins=BTC%2CETH', ); }); it('stringifies an object inside an array', () => { - expect(serializeParams({ coins: [{ coin: 'BTC' }] })).toBe( + expect(serializeRepeatedParams({ coins: [{ coin: 'BTC' }] })).toBe( 'coins=%5Bobject%20Object%5D', ); }); it('omits an empty array', () => { - expect(serializeParams({ coins: [] })).toBe(''); + expect(serializeRepeatedParams({ coins: [] })).toBe(''); }); it('omits an empty array without leaving a dangling ampersand when sorted', () => { expect( - serializeParams({ + serializeRepeatedParams({ symbol: 'BTCUSDT', coins: [], category: 'spot', @@ -258,7 +348,7 @@ describe('serializeParams', () => { it('omits an empty array without leaving a dangling ampersand in insertion order', () => { expect( - serializeParams( + serializeRepeatedParams( { symbol: 'BTCUSDT', coins: [], category: 'spot' }, false, false, @@ -267,12 +357,12 @@ describe('serializeParams', () => { }); it('returns an empty string when every value is an empty array', () => { - expect(serializeParams({ a: [], b: [] })).toBe(''); + expect(serializeRepeatedParams({ a: [], b: [] })).toBe(''); }); it('serialises more than one array and sorts the keys around them', () => { expect( - serializeParams({ + serializeRepeatedParams({ tags: ['ST'], coins: ['BTC', 'ETH'], }), @@ -282,42 +372,50 @@ describe('serializeParams', () => { it('preserves order across a long array', () => { const coins = Array.from({ length: 50 }, (_, index) => `C${index}`); - expect(serializeParams({ coins })).toBe( + expect(serializeRepeatedParams({ coins })).toBe( coins.map((coin) => `coins=${coin}`).join('&'), ); }); - it('turns a sparse hole into an empty join gap', () => { - // map skips holes, then join treats the skipped slot as an empty string. + it('treats a sparse hole as an undefined item', () => { const coins = ['BTC']; coins[2] = 'ETH'; - expect(serializeParams({ coins }, false)).toBe('coins=BTC&&coins=ETH'); + expect(serializeRepeatedParams({ coins }, false)).toBe( + 'coins=BTC&coins=undefined&coins=ETH', + ); }); }); describe('strict validation', () => { it('throws when an array item is undefined', () => { expect(() => - serializeParams({ coins: ['BTC', undefined] }, true), + serializeRepeatedParams({ coins: ['BTC', undefined] }, true), ).toThrow(undefinedParamError); }); it('throws for an undefined array item even when encoding is disabled', () => { expect(() => - serializeParams({ coins: [undefined, 'ETH'] }, true, true, false), + serializeRepeatedParams( + { coins: [undefined, 'ETH'] }, + true, + true, + false, + ), ).toThrow(undefinedParamError); }); - it('does not throw for a sparse hole, even when strict validation is on', () => { + it('rejects a sparse hole when strict validation is on', () => { const coins = ['BTC']; coins[2] = 'ETH'; - expect(serializeParams({ coins }, true)).toBe('coins=BTC&&coins=ETH'); + expect(() => serializeRepeatedParams({ coins }, true)).toThrow( + undefinedParamError, + ); }); it('allows a fully defined array when strict validation is on', () => { - expect(serializeParams({ coins: ['BTC', 'ETH'] }, true)).toBe( + expect(serializeRepeatedParams({ coins: ['BTC', 'ETH'] }, true)).toBe( 'coins=BTC&coins=ETH', ); }); @@ -358,16 +456,16 @@ describe('serializeParams', () => { }); it('keeps zero and false inside an array', () => { - expect(serializeParams({ flags: [0, false, ''] })).toBe( + expect(serializeRepeatedParams({ flags: [0, false, ''] })).toBe( 'flags=0&flags=false&flags=', ); }); }); - describe('private GET signing call', () => { + describe('private GET serializer settings with explicit repeat format', () => { it('keeps caller key order instead of sorting', () => { expect( - serializeForSigning({ + serializeForRepeatedQuery({ category: 'linear', symbol: 'BTCUSDT', limit: 50, @@ -376,14 +474,14 @@ describe('serializeParams', () => { }); it('repeats coins in caller order', () => { - expect(serializeForSigning({ coins: ['ETH', 'BTC'] })).toBe( + expect(serializeForRepeatedQuery({ coins: ['ETH', 'BTC'] })).toBe( 'coins=ETH&coins=BTC', ); }); it('places a repeated coins list after earlier scalar params', () => { expect( - serializeForSigning({ + serializeForRepeatedQuery({ category: 'spot', coins: ['BTC', 'ETH'], }), @@ -392,7 +490,7 @@ describe('serializeParams', () => { it('drops an empty coins list without joining the neighbours with a double ampersand', () => { expect( - serializeForSigning({ + serializeForRepeatedQuery({ category: 'spot', coins: [], symbol: 'BTCUSDT', @@ -401,20 +499,20 @@ describe('serializeParams', () => { }); it('encodes a cursor percent on the signing path', () => { - expect(serializeForSigning({ cursor: 'abc%def' })).toBe( + expect(serializeForRepeatedQuery({ cursor: 'abc%def' })).toBe( 'cursor=abc%25def', ); }); it('can disable encoding on the signing path', () => { - expect(serializeForSigning({ cursor: 'abc%def' }, false, false)).toBe( - 'cursor=abc%def', - ); + expect( + serializeForRepeatedQuery({ cursor: 'abc%def' }, false, false), + ).toBe('cursor=abc%def'); }); it('still throws for an undefined array item on the signing path', () => { expect(() => - serializeForSigning({ coins: ['BTC', undefined] }, true), + serializeForRepeatedQuery({ coins: ['BTC', undefined] }, true), ).toThrow(undefinedParamError); }); }); diff --git a/test/v5/private.serialization.test.ts b/test/v5/private.serialization.test.ts new file mode 100644 index 00000000..cdc41e61 --- /dev/null +++ b/test/v5/private.serialization.test.ts @@ -0,0 +1,208 @@ +import { RestClientOptions, RestClientV5 } from '../../src'; +import { getTestProxy } from '../proxy.util'; + +/** Real, read-only mainnet requests. The key needs wallet and Earn read access. */ +describe('Private GET serialization (HMAC)', () => { + let api: RestClientV5; + + function createClient(options: RestClientOptions = {}): RestClientV5 { + return new RestClientV5( + { + key: process.env.API_KEY_COM, + secret: process.env.API_SECRET_COM, + testnet: false, + recv_window: 10000, + ...options, + }, + { ...getTestProxy(), timeout: 15000 }, + ); + } + + beforeAll(() => { + expect(process.env.API_KEY_COM).toEqual(expect.any(String)); + expect(process.env.API_SECRET_COM).toEqual(expect.any(String)); + api = createClient(); + }); + + it('preserves legacy wallet arrays and returns both requested coins', async () => { + const response = await liveRequest( + api.getWalletBalance({ + accountType: 'UNIFIED', + // JavaScript callers could already pass arrays despite the string type. + coin: ['BTC', 'ETH'] as unknown as string, + }), + ); + + expectWalletCoins(response, ['BTC', 'ETH']); + }); + + it('preserves comma-separated wallet strings', async () => { + const response = await liveRequest( + api.getWalletBalance({ accountType: 'UNIFIED', coin: 'BTC,ETH' }), + ); + expectWalletCoins(response, ['BTC', 'ETH']); + }); + + it('preserves signed scalar queries with numeric values', async () => { + const response = await liveRequest( + api.getActiveOrders({ + category: 'linear', + symbol: 'BTCUSDT', + openOnly: 0, + limit: 1, + }), + ); + expect(response.retCode).toBe(0); + expect(response.result.category).toBe('linear'); + }); + + it.each([ + { coins: ['BTC'] }, + { coins: ['BTC', 'ETH'] }, + { coins: ['ETH', 'BTC'] }, + { coins: ['BTC', 'ETH', 'BTC'] }, + ])( + 'Earn returns exactly the requested coin set for $coins', + async ({ coins }) => { + const response = await liveRequest( + api.getFlexibleSavingAutoSavings({ coins }), + ); + expectEarnCoins(response, coins); + }, + ); + + it('Earn treats an empty array like omitted coins', async () => { + const all = await liveRequest(api.getFlexibleSavingAutoSavings()); + expect(all.retCode).toBe(0); + expect(all.result.coins.length).toBeGreaterThan(0); + + const empty = await liveRequest( + api.getFlexibleSavingAutoSavings({ coins: [] }), + ); + expectEarnCoins( + empty, + all.result.coins.map((coin) => coin.coin), + ); + }); + + it('Earn accepts 50 supported coins and rejects 51', async () => { + const all = await liveRequest(api.getFlexibleSavingAutoSavings()); + expect(all.retCode).toBe(0); + const supported = [...new Set(all.result.coins.map((coin) => coin.coin))]; + // Fail visibly if the live environment cannot exercise the documented limit. + expect(supported.length).toBeGreaterThanOrEqual(51); + + const coins = supported.slice(0, 50); + const accepted = await liveRequest( + api.getFlexibleSavingAutoSavings({ coins }), + ); + expectEarnCoins(accepted, coins); + + const rejected = await liveRequest( + api.getFlexibleSavingAutoSavings({ coins: supported.slice(0, 51) }), + ); + expect(rejected.retCode).toBe(180001); + }, 60000); + + it.each([ + { label: 'strict validation', options: { strict_param_validation: true } }, + { label: 'encoding disabled', options: { encodeSerialisedValues: false } }, + ])( + 'preserves both formats with $label', + async ({ options }) => { + const client = createClient(options); + const wallet = await liveRequest( + client.getWalletBalance({ + accountType: 'UNIFIED', + coin: ['BTC', 'ETH'] as unknown as string, + }), + ); + expectWalletCoins(wallet, ['BTC', 'ETH']); + const earn = await liveRequest( + client.getFlexibleSavingAutoSavings({ coins: ['BTC', 'ETH'] }), + ); + expectEarnCoins(earn, ['BTC', 'ETH']); + }, + 40000, + ); + + it('accepts explicit request options through getPrivate', async () => { + const response = await liveRequest( + api.getPrivate( + '/v5/earn/flexible-saving/auto-savings', + { coins: ['BTC', 'ETH'] }, + { serialiserArrayFormat: 'repeat' }, + ), + ); + expectEarnCoins(response, ['BTC', 'ETH']); + }); + + it('keeps serialization options local to concurrent requests', async () => { + const [wallet, earn] = await Promise.all([ + liveRequest( + api.getWalletBalance({ + accountType: 'UNIFIED', + coin: ['BTC', 'ETH'] as unknown as string, + }), + ), + liveRequest(api.getFlexibleSavingAutoSavings({ coins: ['BTC', 'ETH'] })), + ]); + expectWalletCoins(wallet, ['BTC', 'ETH']); + expectEarnCoins(earn, ['BTC', 'ETH']); + + const subsequent = await liveRequest( + api.getWalletBalance({ + accountType: 'UNIFIED', + coin: ['BTC', 'ETH'] as unknown as string, + }), + ); + expectWalletCoins(subsequent, ['BTC', 'ETH']); + }, 40000); + + it('preserves public GET requests when SDK request options are present', async () => { + const publicClient = createClient({ key: undefined, secret: undefined }); + const response = await liveRequest( + publicClient.get( + '/v5/market/tickers', + { category: 'linear', symbol: 'BTCUSDT' }, + { serialiserArrayFormat: 'repeat' }, + ), + ); + expect(response.retCode).toBe(0); + expect(response.result.list.map((ticker) => ticker.symbol)).toEqual([ + 'BTCUSDT', + ]); + }); +}); + +function expectWalletCoins( + response: Awaited>, + requested: string[], +) { + expect(response.retCode).toBe(0); + const coins = response.result.list.flatMap((account) => + account.coin.map((coin) => coin.coin), + ); + expect([...new Set(coins)].sort()).toEqual([...new Set(requested)].sort()); +} + +function expectEarnCoins( + response: Awaited>, + requested: string[], +) { + expect(response.retCode).toBe(0); + expect(typeof response.result.selectedAll).toBe('boolean'); + const coins = response.result.coins.map((coin) => coin.coin); + expect([...new Set(coins)].sort()).toEqual([...new Set(requested)].sort()); +} + +/** Keep credentials and account data out of network failure reports. */ +async function liveRequest(request: Promise): Promise { + try { + return await request; + } catch (error) { + throw new Error( + `Live API request failed (code: ${error?.code ?? 'unknown'})`, + ); + } +} From c0282b01e30ca9087b0a4ebff7b126aba35b72eb Mon Sep 17 00:00:00 2001 From: "Tiago Siebler @ Siebly.io" Date: Thu, 8 Oct 2026 15:22:20 +0100 Subject: [PATCH 5/7] chore: move test phase down --- .github/workflows/e2etest.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2etest.yml b/.github/workflows/e2etest.yml index 3de91195..5be9cdc2 100644 --- a/.github/workflows/e2etest.yml +++ b/.github/workflows/e2etest.yml @@ -33,9 +33,6 @@ jobs: - name: Build run: npm run build - - name: Test parameter serialization - run: npm run test -- --runInBand --runTestsByPath test/util/serializeParams.test.ts - - name: Test Public Read API Calls run: npm run test -- public.read.test.ts @@ -74,7 +71,10 @@ jobs: API_KEY_COM_RSA: ${{ secrets.API_KEY_COM_RSA }} API_SECRET_COM_RSA: ${{ secrets.API_SECRET_COM_RSA }} - - name: Test live private GET serialization (HMAC) + - name: Test parameter serialization (public) + run: npm run test -- --runInBand --runTestsByPath test/util/serializeParams.test.ts + + - name: Test parameter serialization (private GET, HMAC) run: npm run test -- --runInBand --runTestsByPath test/v5/private.serialization.test.ts env: API_KEY_COM: ${{ secrets.API_KEY_COM }} From db62786844c22e23e9c92778ee99d5d91df63604 Mon Sep 17 00:00:00 2001 From: "Tiago Siebler @ Siebly.io" Date: Thu, 8 Oct 2026 15:50:41 +0100 Subject: [PATCH 6/7] fix: fussy tests --- jest.config.ts | 1 + test/v5/private.readRSA.test.ts | 18 +++++++++++------- test/v5/private.writeHMAC.test.ts | 26 +++++++++++++------------- test/v5/private.writeRSA.test.ts | 26 +++++++++++++------------- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/jest.config.ts b/jest.config.ts index aadee858..7bb4b2cd 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -133,6 +133,7 @@ const config: Config = { // roots: [ // "" // ], + roots: ['/test'], // Allows you to use a custom runner instead of Jest's default test runner // runner: "jest-runner", diff --git a/test/v5/private.readRSA.test.ts b/test/v5/private.readRSA.test.ts index 39f97246..a40c3126 100644 --- a/test/v5/private.readRSA.test.ts +++ b/test/v5/private.readRSA.test.ts @@ -275,13 +275,17 @@ describe('Private READ V5 REST API Endpoints', () => { }); it('querySubMemberAddress()', async () => { - expect( - await api.querySubMemberAddress(settleCoin, 'TRC20', 'fakeid'), - ).toMatchObject({ - // ...successResponseObjectV3(), - // Expected, since sub account ID is fake - retCode: API_ERROR_CODE.PARAMS_MISSING_OR_WRONG, - }); + const response = await api.querySubMemberAddress( + settleCoin, + 'TRC20', + 'fakeid', + ); + + // The fake subaccount ID is invalid, but compliance may reject it first. + expect([ + API_ERROR_CODE.PARAMS_MISSING_OR_WRONG, + API_ERROR_CODE.COMPLIANCE_RULES_TRIGGERED, + ]).toContain(response.retCode); }); it('getCoinInfo()', async () => { diff --git a/test/v5/private.writeHMAC.test.ts b/test/v5/private.writeHMAC.test.ts index 6d629ad8..46a8a83f 100644 --- a/test/v5/private.writeHMAC.test.ts +++ b/test/v5/private.writeHMAC.test.ts @@ -41,20 +41,20 @@ describe('Private WRITE V5 REST API Endpoints', () => { describe('Trade APIs', () => { it('submitOrder()', async () => { - expect( - await api.submitOrder({ - category: 'linear', - symbol: linearSymbol, - orderType: orderType, - side: orderSide, - qty: '1', - positionIdx: 1, - }), - ).toMatchObject({ - // ...successResponseObjectV3(), - // retMsg: '', - retCode: API_ERROR_CODE.V5_INSUFFICIENT_BALANCE, + const response = await api.submitOrder({ + category: 'linear', + symbol: linearSymbol, + orderType: orderType, + side: orderSide, + qty: '1', + positionIdx: 1, }); + + // Test accounts have no balance, but compliance may reject the request first. + expect([ + API_ERROR_CODE.V5_INSUFFICIENT_BALANCE, + API_ERROR_CODE.COMPLIANCE_RULES_TRIGGERED, + ]).toContain(response.retCode); }); it('amendOrder()', async () => { diff --git a/test/v5/private.writeRSA.test.ts b/test/v5/private.writeRSA.test.ts index b119088f..caeb520f 100644 --- a/test/v5/private.writeRSA.test.ts +++ b/test/v5/private.writeRSA.test.ts @@ -41,20 +41,20 @@ describe('Private WRITE V5 REST API Endpoints', () => { describe('Trade APIs', () => { it('submitOrder()', async () => { - expect( - await api.submitOrder({ - category: 'linear', - symbol: linearSymbol, - orderType: orderType, - side: orderSide, - qty: '1', - positionIdx: 1, - }), - ).toMatchObject({ - // ...successResponseObjectV3(), - // retMsg: '', - retCode: API_ERROR_CODE.V5_INSUFFICIENT_BALANCE, + const response = await api.submitOrder({ + category: 'linear', + symbol: linearSymbol, + orderType: orderType, + side: orderSide, + qty: '1', + positionIdx: 1, }); + + // Test accounts have no balance, but compliance may reject the request first. + expect([ + API_ERROR_CODE.V5_INSUFFICIENT_BALANCE, + API_ERROR_CODE.COMPLIANCE_RULES_TRIGGERED, + ]).toContain(response.retCode); }); it('amendOrder()', async () => { From fb60791f36bb58672898433d564210028c767a0d Mon Sep 17 00:00:00 2001 From: "Tiago Siebler @ Siebly.io" Date: Thu, 8 Oct 2026 16:10:15 +0100 Subject: [PATCH 7/7] feat(v4.8.0): bump minor version due to expansion of the internal HTTP serialisation --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 20145ff2..7c1bf3d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bybit-api", - "version": "4.7.10", + "version": "4.8.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bybit-api", - "version": "4.7.10", + "version": "4.8.0", "license": "MIT", "dependencies": { "@types/ws": "8.18.1", diff --git a/package.json b/package.json index 1663efa9..4febdcaa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "4.7.10", + "version": "4.8.0", "description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.", "main": "lib/index.js", "types": "lib/index.d.ts",