From dbc168447af593690569355cc5aea08f161f2dd8 Mon Sep 17 00:00:00 2001 From: Jerko J <83344666+JJ-Cro@users.noreply.github.com> Date: Fri, 4 Oct 2024 14:38:16 +0200 Subject: [PATCH] feat(): Added endpoints, updated types --- docs/endpointFunctionList.md | 1 + package-lock.json | 4 ++-- package.json | 2 +- src/RestClient.ts | 30 +++++++++++++++++++++++++----- src/types/request/futures.ts | 8 ++++++++ src/types/response/futures.ts | 2 ++ src/types/response/wallet.ts | 1 + 7 files changed, 40 insertions(+), 8 deletions(-) diff --git a/docs/endpointFunctionList.md b/docs/endpointFunctionList.md index 55a1b70..7406cfd 100644 --- a/docs/endpointFunctionList.md +++ b/docs/endpointFunctionList.md @@ -258,6 +258,7 @@ This table includes all endpoints from the official Exchange API docs and corres | `cancelAllOpenOptionsOrders()` | :closed_lock_with_key: | DELETE | `/options/orders` | | `getOptionsOrder()` | :closed_lock_with_key: | GET | `/options/orders/{order_id}` | | `cancelOptionsOrder()` | :closed_lock_with_key: | DELETE | `/options/orders/{order_id}` | +| `submitOptionsCountdownCancel()` | :closed_lock_with_key: | POST | `/options/countdown_cancel_all` | | `getOptionsPersonalHistory()` | :closed_lock_with_key: | GET | `/options/my_trades` | | `setOptionsMMPSettings()` | :closed_lock_with_key: | POST | `/options/mmp` | | `getOptionsMMPSettings()` | :closed_lock_with_key: | GET | `/options/mmp` | diff --git a/package-lock.json b/package-lock.json index 7a7ece6..ba57cf5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gateio-api", - "version": "1.0.16", + "version": "1.0.17", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gateio-api", - "version": "1.0.16", + "version": "1.0.17", "license": "MIT", "dependencies": { "axios": "^1.6.6", diff --git a/package.json b/package.json index 81009a3..a6de7a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gateio-api", - "version": "1.0.16", + "version": "1.0.17", "description": "Complete & robust Node.js SDK for Gate.io's REST APIs, WebSockets & WebSocket APIs, with TypeScript declarations.", "scripts": { "clean": "rm -rf dist/*", diff --git a/src/RestClient.ts b/src/RestClient.ts index f615c8b..0acca38 100644 --- a/src/RestClient.ts +++ b/src/RestClient.ts @@ -45,6 +45,7 @@ import { import { BatchAmendOrderReq, DeleteAllFuturesOrdersReq, + GetFundingRatesReq, GetFuturesAccountBookReq, GetFuturesAutoOrdersReq, GetFuturesCandlesReq, @@ -1949,11 +1950,7 @@ export class RestClient extends BaseRestClient { * r: string; * }[]> */ - getFundingRates(params: { - settle: 'btc' | 'usdt' | 'usd'; - contract: string; - limit?: number; - }): Promise< + getFundingRates(params: GetFundingRatesReq): Promise< { t: number; r: string; @@ -3267,6 +3264,29 @@ export class RestClient extends BaseRestClient { return this.deletePrivate(`/options/orders/${params.order_id}`); } + /** + * Countdown cancel orders for options + * + * Option order heartbeat detection. When the timeout set by the user is reached, + * if there is no cancel or new countdown set, related pending orders will be + * automatically cancelled. This endpoint can be called repeatedly to set a new + * countdown or cancel the countdown. + * + * @param params Parameters for setting countdown cancel orders + * @returns Promise<{ + * triggerTime: number; + * }> + */ + submitOptionsCountdownCancel(params: { + timeout: number; + contract?: string; + underlying?: string; + }): Promise<{ + triggerTime: number; + }> { + return this.postPrivate('/options/countdown_cancel_all', { body: params }); + } + /** * List personal trading history * diff --git a/src/types/request/futures.ts b/src/types/request/futures.ts index 6dab4e3..9e762ac 100644 --- a/src/types/request/futures.ts +++ b/src/types/request/futures.ts @@ -38,6 +38,14 @@ export interface GetFuturesStatsReq { limit?: number; } +export interface GetFundingRatesReq { + settle: 'btc' | 'usdt' | 'usd'; + contract: string; + limit?: number; + from?: number; + to?: number; +} + export interface GetLiquidationHistoryReq { settle: 'btc' | 'usdt' | 'usd'; contract?: string; diff --git a/src/types/response/futures.ts b/src/types/response/futures.ts index 80196ea..40bd0d5 100644 --- a/src/types/response/futures.ts +++ b/src/types/response/futures.ts @@ -61,6 +61,8 @@ export interface FuturesTicker { basis_value: string; lowest_ask: string; highest_bid: string; + lowest_size: string; + highest_size: string; } export interface FuturesStats { diff --git a/src/types/response/wallet.ts b/src/types/response/wallet.ts index 02d550a..1f50233 100644 --- a/src/types/response/wallet.ts +++ b/src/types/response/wallet.ts @@ -203,4 +203,5 @@ export interface PushOrder { | 'REFUSED' | 'RECEIVING' | 'RECEIVED'; + message: string; }