Skip to content

Commit

Permalink
Merge pull request #311 from tiagosiebler/v3.8.2
Browse files Browse the repository at this point in the history
v3.8.2: feat(#310) add set collateral coin endpoints
  • Loading branch information
tiagosiebler authored Jan 25, 2024
2 parents d86db86 + 9ba44d9 commit 0c87217
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
32 changes: 32 additions & 0 deletions src/rest-client-v5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ import {
PurchaseSpotLeveragedTokenResultV5,
RedeemSpotLeveragedTokenParamsV5,
RedeemSpotLeveragedTokenResultV5,
RepayLiabilityParamsV5,
RepayLiabilityResultV5,
RiskLimitV5,
SetAutoAddMarginParamsV5,
SetCollateralCoinParamsV5,
SetLeverageParamsV5,
SetRiskLimitParamsV5,
SetRiskLimitResultV5,
Expand Down Expand Up @@ -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<APIResponseV3WithTime<CursorListV5<RepayLiabilityResultV5[]>>> {
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<APIResponseV3WithTime<{}>> {
return this.postPrivate('/v5/account/set-collateral-switch', params);
}

batchSetCollateralCoin(params: {
request: SetCollateralCoinParamsV5[];
}): Promise<APIResponseV3WithTime<{ list: SetCollateralCoinParamsV5[] }>> {
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.
Expand Down
9 changes: 9 additions & 0 deletions src/types/request/v5-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,12 @@ export interface MMPModifyParamsV5 {
qtyLimit: string;
deltaLimit: string;
}

export interface RepayLiabilityParamsV5 {
coin?: string;
}

export interface SetCollateralCoinParamsV5 {
coin: string;
collateralSwitch: 'ON' | 'OFF';
}
5 changes: 5 additions & 0 deletions src/types/response/v5-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,8 @@ export interface MMPStateV5 {
mmpFrozenUntil: string;
mmpFrozen: boolean;
}

export interface RepayLiabilityResultV5 {
coin: string;
repaymentQty: string;
}

0 comments on commit 0c87217

Please sign in to comment.