From 9ba44d9477d183b2dbe84681f48818dee40f7af9 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Thu, 25 Jan 2024 10:44:24 +0000 Subject: [PATCH] v3.8.2: feat(#310) add set collateral coin endpoints --- package-lock.json | 4 ++-- package.json | 2 +- src/rest-client-v5.ts | 32 ++++++++++++++++++++++++++++++++ src/types/request/v5-account.ts | 9 +++++++++ src/types/response/v5-account.ts | 5 +++++ 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7b89ff9..496fc07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bybit-api", - "version": "3.8.1", + "version": "3.8.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bybit-api", - "version": "3.8.1", + "version": "3.8.2", "license": "MIT", "dependencies": { "axios": "^0.21.0", diff --git a/package.json b/package.json index 51c1b15..7f80c86 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "3.8.1", + "version": "3.8.2", "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 fac72de..fce2c9e 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -109,8 +109,11 @@ import { PurchaseSpotLeveragedTokenResultV5, RedeemSpotLeveragedTokenParamsV5, RedeemSpotLeveragedTokenResultV5, + RepayLiabilityParamsV5, + RepayLiabilityResultV5, RiskLimitV5, SetAutoAddMarginParamsV5, + SetCollateralCoinParamsV5, SetLeverageParamsV5, SetRiskLimitParamsV5, SetRiskLimitResultV5, @@ -766,6 +769,35 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/account/borrow-history', params); } + /** + * You can manually repay the liabilities of Unified account + * Applicable: Unified Account + * Permission: USDC Contracts + * + * - Input the specific coin: repay the liability of this coin in particular + * - No coin specified: repay the liability of all coins + */ + repayLiability( + params?: RepayLiabilityParamsV5, + ): Promise>> { + return this.postPrivate('/v5/account/quick-repayment', params); + } + + /** + * You can decide whether the assets in the Unified account needs to be collateral coins. + */ + setCollateralCoin( + params: SetCollateralCoinParamsV5, + ): Promise> { + return this.postPrivate('/v5/account/set-collateral-switch', params); + } + + batchSetCollateralCoin(params: { + request: SetCollateralCoinParamsV5[]; + }): Promise> { + return this.postPrivate('/v5/account/set-collateral-switch-batch', params); + } + /** * Get the collateral information of the current unified margin account, including loan interest rate, * loanable amount, collateral conversion rate, whether it can be mortgaged as margin, etc. diff --git a/src/types/request/v5-account.ts b/src/types/request/v5-account.ts index 50b53ae..38f3159 100644 --- a/src/types/request/v5-account.ts +++ b/src/types/request/v5-account.ts @@ -38,3 +38,12 @@ export interface MMPModifyParamsV5 { qtyLimit: string; deltaLimit: string; } + +export interface RepayLiabilityParamsV5 { + coin?: string; +} + +export interface SetCollateralCoinParamsV5 { + coin: string; + collateralSwitch: 'ON' | 'OFF'; +} diff --git a/src/types/response/v5-account.ts b/src/types/response/v5-account.ts index 7fd3232..8650413 100644 --- a/src/types/response/v5-account.ts +++ b/src/types/response/v5-account.ts @@ -120,3 +120,8 @@ export interface MMPStateV5 { mmpFrozenUntil: string; mmpFrozen: boolean; } + +export interface RepayLiabilityResultV5 { + coin: string; + repaymentQty: string; +}