From 7b7258b009089c7b1506a042f2fa56f3900dc2b0 Mon Sep 17 00:00:00 2001 From: Jerko J <83344666+JJ-Cro@users.noreply.github.com> Date: Tue, 15 Oct 2024 12:34:43 +0200 Subject: [PATCH 1/3] feat(): added Crypto Loan endpoints --- README.md | 1 + docs/endpointFunctionList.md | 16 +- .../Crypto-Loan/adjust-collateral-amount.js | 20 ++ examples/apidoc/V5/Crypto-Loan/borrow.js | 22 ++ .../get-account-borrow-collateral-limit.js | 19 ++ .../V5/Crypto-Loan/get-borrowable-coins.js | 19 ++ .../V5/Crypto-Loan/get-collateral-coins.js | 19 ++ .../get-completed-loan-order-history.js | 16 ++ .../get-loan-LTV-adjustment-history.js | 16 ++ ...max-allowed-reduction-collateral-amount.js | 16 ++ .../get-repayment-transaction-history.js | 16 ++ .../V5/Crypto-Loan/get-unpaid-loan-orders.js | 16 ++ examples/apidoc/V5/Crypto-Loan/repay.js | 19 ++ package-lock.json | 4 +- package.json | 2 +- src/rest-client-v5.ts | 216 ++++++++++++++++++ src/types/request/v5-crypto-loan.ts | 41 ++++ src/types/response/v5-crypto-loan.ts | 92 ++++++++ 18 files changed, 566 insertions(+), 4 deletions(-) create mode 100644 examples/apidoc/V5/Crypto-Loan/adjust-collateral-amount.js create mode 100644 examples/apidoc/V5/Crypto-Loan/borrow.js create mode 100644 examples/apidoc/V5/Crypto-Loan/get-account-borrow-collateral-limit.js create mode 100644 examples/apidoc/V5/Crypto-Loan/get-borrowable-coins.js create mode 100644 examples/apidoc/V5/Crypto-Loan/get-collateral-coins.js create mode 100644 examples/apidoc/V5/Crypto-Loan/get-completed-loan-order-history.js create mode 100644 examples/apidoc/V5/Crypto-Loan/get-loan-LTV-adjustment-history.js create mode 100644 examples/apidoc/V5/Crypto-Loan/get-max-allowed-reduction-collateral-amount.js create mode 100644 examples/apidoc/V5/Crypto-Loan/get-repayment-transaction-history.js create mode 100644 examples/apidoc/V5/Crypto-Loan/get-unpaid-loan-orders.js create mode 100644 examples/apidoc/V5/Crypto-Loan/repay.js create mode 100644 src/types/request/v5-crypto-loan.ts create mode 100644 src/types/response/v5-crypto-loan.ts diff --git a/README.md b/README.md index 9375401b..bb57b33b 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Node.js & JavaScript SDK for the Bybit REST APIs and WebSockets: - Issues? Check the [issues tab](https://github.com/tiagosiebler/bybit-api/issues). - Discuss & collaborate with other node devs? Join our [Node.js Algo Traders](https://t.me/nodetraders) engineering community on telegram. +- Follow our announcement channel for real-time updates on [X/Twitter](https://x.com/QuantSDKs) diff --git a/docs/endpointFunctionList.md b/docs/endpointFunctionList.md index 1e9bb3f8..0ee3e417 100644 --- a/docs/endpointFunctionList.md +++ b/docs/endpointFunctionList.md @@ -182,6 +182,17 @@ This table includes all endpoints from the official Exchange API docs and corres | `getSpotMarginBorrowOrderDetail()` | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/orders` | | `getSpotMarginRepaymentOrderDetail()` | :closed_lock_with_key: | GET | `/v5/spot-cross-margin-trade/repay-history` | | `toggleSpotCrossMarginTrade()` | :closed_lock_with_key: | POST | `/v5/spot-cross-margin-trade/switch` | +| `getCollateralCoins()` | | GET | `/v5/crypto-loan/collateral-data` | +| `getBorrowableCoins()` | | GET | `/v5/crypto-loan/loanable-data` | +| `getAccountBorrowCollateralLimit()` | :closed_lock_with_key: | GET | `/v5/crypto-loan/borrowable-collateralisable-number` | +| `borrowCryptoLoan()` | :closed_lock_with_key: | POST | `/v5/crypto-loan/borrow` | +| `repayCryptoLoan()` | :closed_lock_with_key: | POST | `/v5/crypto-loan/repay` | +| `getUnpaidLoanOrders()` | :closed_lock_with_key: | GET | `/v5/crypto-loan/ongoing-orders` | +| `getRepaymentHistory()` | :closed_lock_with_key: | GET | `/v5/crypto-loan/repayment-history` | +| `getCompletedLoanOrderHistory()` | :closed_lock_with_key: | GET | `/v5/crypto-loan/borrow-history` | +| `getMaxAllowedReductionCollateralAmount()` | :closed_lock_with_key: | GET | `/v5/crypto-loan/max-collateral-amount` | +| `adjustCollateralAmount()` | :closed_lock_with_key: | POST | `/v5/crypto-loan/adjust-ltv` | +| `getLoanLTVAdjustmentHistory()` | :closed_lock_with_key: | GET | `/v5/crypto-loan/adjustment-history` | | `getInstitutionalLendingProductInfo()` | | GET | `/v5/ins-loan/product-infos` | | `getInstitutionalLendingMarginCoinInfo()` | | GET | `/v5/ins-loan/ensure-tokens` | | `getInstitutionalLendingMarginCoinInfoWithConversionRate()` | | GET | `/v5/ins-loan/ensure-tokens-convert` | @@ -192,4 +203,7 @@ This table includes all endpoints from the official Exchange API docs and corres | `bindOrUnbindUID()` | :closed_lock_with_key: | POST | `/v5/ins-loan/association-uid` | | `getExchangeBrokerEarnings()` | :closed_lock_with_key: | GET | `/v5/broker/earnings-info` | | `getExchangeBrokerAccountInfo()` | :closed_lock_with_key: | GET | `/v5/broker/account-info` | -| `getBrokerSubAccountDeposits()` | :closed_lock_with_key: | GET | `/v5/broker/asset/query-sub-member-deposit-record` | \ No newline at end of file +| `getBrokerSubAccountDeposits()` | :closed_lock_with_key: | GET | `/v5/broker/asset/query-sub-member-deposit-record` | +| `getBrokerVoucherSpec()` | :closed_lock_with_key: | POST | `/v5/broker/award/info` | +| `issueBrokerVoucher()` | :closed_lock_with_key: | POST | `/v5/broker/award/distribute-award` | +| `getBrokerIssuedVoucher()` | :closed_lock_with_key: | POST | `/v5/broker/award/distribution-record` | \ No newline at end of file diff --git a/examples/apidoc/V5/Crypto-Loan/adjust-collateral-amount.js b/examples/apidoc/V5/Crypto-Loan/adjust-collateral-amount.js new file mode 100644 index 00000000..993c7c86 --- /dev/null +++ b/examples/apidoc/V5/Crypto-Loan/adjust-collateral-amount.js @@ -0,0 +1,20 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .adjustCollateralAmount({ + orderId: '1794267532472646144', + amount: '0.001', + direction: '1', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Crypto-Loan/borrow.js b/examples/apidoc/V5/Crypto-Loan/borrow.js new file mode 100644 index 00000000..df4e386f --- /dev/null +++ b/examples/apidoc/V5/Crypto-Loan/borrow.js @@ -0,0 +1,22 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .borrowCryptoLoan({ + loanCurrency: 'USDT', + loanAmount: '550', + collateralCurrency: 'BTC', + loanTerm: null, + collateralAmount: null, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Crypto-Loan/get-account-borrow-collateral-limit.js b/examples/apidoc/V5/Crypto-Loan/get-account-borrow-collateral-limit.js new file mode 100644 index 00000000..8aa462a9 --- /dev/null +++ b/examples/apidoc/V5/Crypto-Loan/get-account-borrow-collateral-limit.js @@ -0,0 +1,19 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getAccountBorrowCollateralLimit({ + loanCurrency: 'USDT', + collateralCurrency: 'BTC', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Crypto-Loan/get-borrowable-coins.js b/examples/apidoc/V5/Crypto-Loan/get-borrowable-coins.js new file mode 100644 index 00000000..88ef32fd --- /dev/null +++ b/examples/apidoc/V5/Crypto-Loan/get-borrowable-coins.js @@ -0,0 +1,19 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getBorrowableCoins({ + currency: 'USDT', + vipLevel: 'VIP0', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Crypto-Loan/get-collateral-coins.js b/examples/apidoc/V5/Crypto-Loan/get-collateral-coins.js new file mode 100644 index 00000000..475a3ae7 --- /dev/null +++ b/examples/apidoc/V5/Crypto-Loan/get-collateral-coins.js @@ -0,0 +1,19 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getCollateralCoins({ + currency: 'ETH', + vipLevel: 'PRO1', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Crypto-Loan/get-completed-loan-order-history.js b/examples/apidoc/V5/Crypto-Loan/get-completed-loan-order-history.js new file mode 100644 index 00000000..2fff06df --- /dev/null +++ b/examples/apidoc/V5/Crypto-Loan/get-completed-loan-order-history.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getCompletedLoanOrderHistory({ orderId: '1794267532472646144' }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Crypto-Loan/get-loan-LTV-adjustment-history.js b/examples/apidoc/V5/Crypto-Loan/get-loan-LTV-adjustment-history.js new file mode 100644 index 00000000..0d785467 --- /dev/null +++ b/examples/apidoc/V5/Crypto-Loan/get-loan-LTV-adjustment-history.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getLoanLTVAdjustmentHistory({ adjustId: '1794271131730737664' }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Crypto-Loan/get-max-allowed-reduction-collateral-amount.js b/examples/apidoc/V5/Crypto-Loan/get-max-allowed-reduction-collateral-amount.js new file mode 100644 index 00000000..8ebcb5b3 --- /dev/null +++ b/examples/apidoc/V5/Crypto-Loan/get-max-allowed-reduction-collateral-amount.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getMaxAllowedReductionCollateralAmount({ orderId: '1794267532472646144' }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Crypto-Loan/get-repayment-transaction-history.js b/examples/apidoc/V5/Crypto-Loan/get-repayment-transaction-history.js new file mode 100644 index 00000000..25d93261 --- /dev/null +++ b/examples/apidoc/V5/Crypto-Loan/get-repayment-transaction-history.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getRepaymentHistory({ repayId: '1794271131730737664' }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Crypto-Loan/get-unpaid-loan-orders.js b/examples/apidoc/V5/Crypto-Loan/get-unpaid-loan-orders.js new file mode 100644 index 00000000..1d9b7343 --- /dev/null +++ b/examples/apidoc/V5/Crypto-Loan/get-unpaid-loan-orders.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getUnpaidLoanOrders({ orderId: '1793683005081680384' }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Crypto-Loan/repay.js b/examples/apidoc/V5/Crypto-Loan/repay.js new file mode 100644 index 00000000..36990370 --- /dev/null +++ b/examples/apidoc/V5/Crypto-Loan/repay.js @@ -0,0 +1,19 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .repayCryptoLoan({ + orderId: '1794267532472646144', + amount: '100', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/package-lock.json b/package-lock.json index 1559d692..6d21d578 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bybit-api", - "version": "3.10.19", + "version": "3.10.20", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bybit-api", - "version": "3.10.19", + "version": "3.10.20", "license": "MIT", "dependencies": { "axios": "^1.6.6", diff --git a/package.json b/package.json index 64e244b2..3f96b725 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "3.10.19", + "version": "3.10.20", "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 9a30bf4a..487e3123 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -179,6 +179,22 @@ import { WithdrawParamsV5, WithdrawalRecordV5, } from './types'; +import { + BorrowCryptoLoanParamsV5, + GetCompletedLoanOrderHistoryParamsV5, + GetLoanLTVAdjustmentHistoryParamsV5, + GetRepaymentHistoryParamsV5, + GetUnpaidLoanOrdersParamsV5, +} from './types/request/v5-crypto-loan'; +import { + AccountBorrowCollateralLimitV5, + CompletedLoanOrderV5, + LoanLTVAdjustmentHistoryV5, + RepaymentHistoryV5, + UnpaidLoanOrderV5, + VipBorrowableCoinListV5, + VipCollateralCoinListV5, +} from './types/response/v5-crypto-loan'; import { REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; @@ -2022,6 +2038,206 @@ export class RestClientV5 extends BaseRestClient { return this.postPrivate('/v5/spot-cross-margin-trade/switch', params); } + /** + * + ****** Crypto Loan + * + */ + + /** + * Get Collateral Coins + * + * INFO: Do not need authentication + */ + getCollateralCoins(params?: { + vipLevel?: string; + currency?: string; + }): Promise< + APIResponseV3WithTime<{ + vipCoinList: VipCollateralCoinListV5[]; + }> + > { + return this.get('/v5/crypto-loan/collateral-data', params); + } + + /** + * Get Borrowable Coins + * + * INFO: Do not need authentication + */ + getBorrowableCoins(params?: { + vipLevel?: string; + currency?: string; + }): Promise< + APIResponseV3WithTime<{ + vipCoinList: VipBorrowableCoinListV5[]; + }> + > { + return this.get('/v5/crypto-loan/loanable-data', params); + } + + /** + * Get Account Borrow/Collateral Limit + * Query the account borrowable/collateral limit + * + * Permission: "Spot trade" + */ + getAccountBorrowCollateralLimit(params: { + loanCurrency: string; + collateralCurrency: string; + }): Promise> { + return this.getPrivate( + '/v5/crypto-loan/borrowable-collateralisable-number', + params, + ); + } + + /** + * Borrow Crypto Loan + * + * Permission: "Spot trade" + * + * INFO: + * The loan funds are released to the Funding account + * The collateral funds are deducted from the Funding account, so make sure you have enough collateral amount in the funding wallet + */ + borrowCryptoLoan(params: BorrowCryptoLoanParamsV5): Promise< + APIResponseV3WithTime<{ + orderId: string; + }> + > { + return this.postPrivate('/v5/crypto-loan/borrow', params); + } + + /** + * Repay Crypto Loan + * + * You can repay partial loan. If there is interest occurred, interest will be repaid in priority + * + * Permission: "Spot trade" + * + * INFO: + * The repaid amount will be deducted from Funding account + * The collateral amount will not be auto returned when you don't fully repay the debt, but you can also adjust collateral amount + */ + repayCryptoLoan(params: { orderId: string; amount: string }): Promise< + APIResponseV3WithTime<{ + repayId: string; + }> + > { + return this.postPrivate('/v5/crypto-loan/repay', params); + } + + /** + * Get Unpaid Loan Orders + * Query the ongoing loan orders, which are not fully repaid + * + * Permission: "Spot trade" + */ + getUnpaidLoanOrders(params?: GetUnpaidLoanOrdersParamsV5): Promise< + APIResponseV3WithTime<{ + list: UnpaidLoanOrderV5[]; + nextPageCursor: string; + }> + > { + return this.getPrivate('/v5/crypto-loan/ongoing-orders', params); + } + + /** + * Get Repayment Transaction History + * Query repaid transaction history + * + * Permission: "Spot trade" + * + * INFO: + * Support querying last 6 months completed loan orders + * Only successful repayments can be queried + */ + getRepaymentHistory(params?: GetRepaymentHistoryParamsV5): Promise< + APIResponseV3WithTime<{ + list: RepaymentHistoryV5[]; + nextPageCursor: string; + }> + > { + return this.getPrivate('/v5/crypto-loan/repayment-history', params); + } + + /** + * Get Completed Loan Order History + * Query the completed loan orders + * + * Permission: "Spot trade" + * + * INFO: + * Support querying last 6 months completed loan orders + */ + getCompletedLoanOrderHistory( + params?: GetCompletedLoanOrderHistoryParamsV5, + ): Promise< + APIResponseV3WithTime<{ + list: CompletedLoanOrderV5[]; + nextPageCursor: string; + }> + > { + return this.getPrivate('/v5/crypto-loan/borrow-history', params); + } + + /** + * Get Max. Allowed Reduction Collateral Amount + * Query the maximum allowed reduction collateral amount + * + * Permission: "Spot trade" + */ + getMaxAllowedReductionCollateralAmount(params: { orderId: string }): Promise< + APIResponseV3WithTime<{ + maxCollateralAmount: string; + }> + > { + return this.getPrivate('/v5/crypto-loan/max-collateral-amount', params); + } + + /** + * Adjust Collateral Amount + * You can increase or reduce collateral amount. When you reduce, please follow the max. allowed reduction amount. + * + * Permission: "Spot trade" + * + * INFO: + * The adjusted collateral amount will be returned to or deducted from Funding account + */ + adjustCollateralAmount(params: { + orderId: string; + amount: string; + direction: '0' | '1'; + }): Promise< + APIResponseV3WithTime<{ + adjustId: string; + }> + > { + return this.postPrivate('/v5/crypto-loan/adjust-ltv', params); + } + + /** + * Get Loan LTV Adjustment History + * Query the transaction history of collateral amount adjustment + * + * Permission: "Spot trade" + * + * INFO: + * Support querying last 6 months adjustment transactions + * Only the ltv adjustment transactions launched by the user can be queried + */ + getLoanLTVAdjustmentHistory( + params?: GetLoanLTVAdjustmentHistoryParamsV5, + ): Promise< + APIResponseV3WithTime<{ + list: LoanLTVAdjustmentHistoryV5[]; + nextPageCursor: string; + }> + > { + return this.getPrivate('/v5/crypto-loan/adjustment-history', params); + } + /** * ****** Institutional Lending diff --git a/src/types/request/v5-crypto-loan.ts b/src/types/request/v5-crypto-loan.ts new file mode 100644 index 00000000..551700d6 --- /dev/null +++ b/src/types/request/v5-crypto-loan.ts @@ -0,0 +1,41 @@ +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 GetRepaymentHistoryParamsV5 { + orderId?: string; + repayId?: string; + loanCurrency?: string; + limit?: string; + cursor?: string; +} + +export interface GetCompletedLoanOrderHistoryParamsV5 { + orderId?: string; + loanCurrency?: string; + collateralCurrency?: string; + limit?: string; + cursor?: string; +} + +export interface GetLoanLTVAdjustmentHistoryParamsV5 { + orderId?: string; + adjustId?: string; + collateralCurrency?: string; + limit?: string; + cursor?: string; +} diff --git a/src/types/response/v5-crypto-loan.ts b/src/types/response/v5-crypto-loan.ts new file mode 100644 index 00000000..b0582804 --- /dev/null +++ b/src/types/response/v5-crypto-loan.ts @@ -0,0 +1,92 @@ +export interface CollateralCoinV5 { + collateralAccuracy: number; + currency: string; + initialLTV: string; + liquidationLTV: string; + marginCallLTV: string; + maxLimit: string; +} + +export interface VipCollateralCoinListV5 { + list: CollateralCoinV5[]; + vipLevel: 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 VipBorrowableCoinListV5 { + list: BorrowableCoinV5[]; + vipLevel: string; +} + +export interface AccountBorrowCollateralLimitV5 { + collateralCurrency: string; + loanCurrency: string; + maxCollateralAmount: string; + maxLoanAmount: string; + minCollateralAmount: string; + minLoanAmount: string; +} + +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 RepaymentHistoryV5 { + collateralCurrency: string; + collateralReturn: string; + loanCurrency: string; + loanTerm: string; + orderId: string; + repayAmount: string; + repayId: string; + repayStatus: number; + repayTime: string; + repayType: 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; + } From f7e829eb455f31e44269ef55b037aab8bd1af169 Mon Sep 17 00:00:00 2001 From: Jerko J <83344666+JJ-Cro@users.noreply.github.com> Date: Tue, 15 Oct 2024 12:36:33 +0200 Subject: [PATCH 2/3] chore(): fixed types --- src/rest-client-v5.ts | 28 ++++++++++++---------------- src/types/request/index.ts | 1 + src/types/response/index.ts | 1 + 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index 487e3123..d0ab3fa3 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -2,6 +2,7 @@ import { APIResponseV3, APIResponseV3WithTime, + AccountBorrowCollateralLimitV5, AccountCoinBalanceV5, AccountInfoV5, AccountMarginModeV5, @@ -22,6 +23,7 @@ import { BatchCreateOrderResultV5, BatchOrderParamsV5, BatchOrdersResponseV5, + BorrowCryptoLoanParamsV5, BorrowHistoryRecordV5, BrokerIssuedVoucherV5, BrokerVoucherSpecV5, @@ -36,6 +38,7 @@ import { CoinGreeksV5, CoinInfoV5, CollateralInfoV5, + CompletedLoanOrderV5, ConfirmNewRiskLimitParamsV5, ConvertCoinSpecV5, ConvertCoinsParamsV5, @@ -72,6 +75,7 @@ import { GetClassicTransactionLogsParamsV5, GetClosedPnLParamsV5, GetCoinExchangeRecordParamsV5, + GetCompletedLoanOrderHistoryParamsV5, GetConvertHistoryParamsV5, GetDeliveryPriceParamsV5, GetDeliveryRecordParamsV5, @@ -87,6 +91,7 @@ import { GetInternalDepositRecordParamsV5, GetInternalTransferParamsV5, GetKlineParamsV5, + GetLoanLTVAdjustmentHistoryParamsV5, GetLongShortRatioParamsV5, GetMarkPriceKlineParamsV5, GetMovePositionHistoryParamsV5, @@ -101,6 +106,7 @@ import { GetPreUpgradeUSDCSessionParamsV5, GetPremiumIndexPriceKlineParamsV5, GetPublicTradingHistoryParamsV5, + GetRepaymentHistoryParamsV5, GetRiskLimitParamsV5, GetSettlementRecordParamsV5, GetSpotLeveragedTokenOrderHistoryParamsV5, @@ -109,6 +115,7 @@ import { GetTickersParamsV5, GetTransactionLogParamsV5, GetUniversalTransferRecordsParamsV5, + GetUnpaidLoanOrdersParamsV5, GetVIPMarginDataParamsV5, GetWalletBalanceParamsV5, GetWithdrawalRecordsParamsV5, @@ -120,6 +127,7 @@ import { IssueVoucherParamsV5, LeverageTokenInfoV5, LeveragedTokenMarketResultV5, + LoanLTVAdjustmentHistoryV5, LongShortRatioV5, MMPModifyParamsV5, MMPStateV5, @@ -146,6 +154,7 @@ import { RedeemSpotLeveragedTokenResultV5, RepayLiabilityParamsV5, RepayLiabilityResultV5, + RepaymentHistoryV5, RequestConvertQuoteParamsV5, RiskLimitV5, SetAutoAddMarginParamsV5, @@ -171,30 +180,17 @@ import { UnifiedAccountUpgradeResultV5, UniversalTransferParamsV5, UniversalTransferRecordV5, + UnpaidLoanOrderV5, UpdateApiKeyParamsV5, UpdateApiKeyResultV5, VIPMarginDataV5, VaspEntityV5, + VipBorrowableCoinListV5, + VipCollateralCoinListV5, WalletBalanceV5, WithdrawParamsV5, WithdrawalRecordV5, } from './types'; -import { - BorrowCryptoLoanParamsV5, - GetCompletedLoanOrderHistoryParamsV5, - GetLoanLTVAdjustmentHistoryParamsV5, - GetRepaymentHistoryParamsV5, - GetUnpaidLoanOrdersParamsV5, -} from './types/request/v5-crypto-loan'; -import { - AccountBorrowCollateralLimitV5, - CompletedLoanOrderV5, - LoanLTVAdjustmentHistoryV5, - RepaymentHistoryV5, - UnpaidLoanOrderV5, - VipBorrowableCoinListV5, - VipCollateralCoinListV5, -} from './types/response/v5-crypto-loan'; import { REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; diff --git a/src/types/request/index.ts b/src/types/request/index.ts index 4c8cfdc3..40bd9841 100644 --- a/src/types/request/index.ts +++ b/src/types/request/index.ts @@ -17,3 +17,4 @@ export * from './v5-trade'; export * from './v5-user'; export * from './v5-spot-leverage-token'; export * from './v5-broker'; +export * from './v5-crypto-loan'; diff --git a/src/types/response/index.ts b/src/types/response/index.ts index 7d289b77..ca2cf2ab 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -13,3 +13,4 @@ export * from './v5-user'; export * from './v5-spot-leverage-token'; export * from './v5-broker'; export * from './v5-preupgrade'; +export * from './v5-crypto-loan'; From 599ba5ad8cf891e257e3e202bcd9b7dc4b1ef79b Mon Sep 17 00:00:00 2001 From: Jerko J <83344666+JJ-Cro@users.noreply.github.com> Date: Tue, 15 Oct 2024 12:42:53 +0200 Subject: [PATCH 3/3] chore(): small type update --- src/rest-client-v5.ts | 8 ++++---- src/types/response/v5-crypto-loan.ts | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index d0ab3fa3..dfbb08b8 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -185,8 +185,8 @@ import { UpdateApiKeyResultV5, VIPMarginDataV5, VaspEntityV5, - VipBorrowableCoinListV5, - VipCollateralCoinListV5, + VipBorrowableCoinsV5, + VipCollateralCoinsV5, WalletBalanceV5, WithdrawParamsV5, WithdrawalRecordV5, @@ -2050,7 +2050,7 @@ export class RestClientV5 extends BaseRestClient { currency?: string; }): Promise< APIResponseV3WithTime<{ - vipCoinList: VipCollateralCoinListV5[]; + vipCoinList: VipCollateralCoinsV5[]; }> > { return this.get('/v5/crypto-loan/collateral-data', params); @@ -2066,7 +2066,7 @@ export class RestClientV5 extends BaseRestClient { currency?: string; }): Promise< APIResponseV3WithTime<{ - vipCoinList: VipBorrowableCoinListV5[]; + vipCoinList: VipBorrowableCoinsV5[]; }> > { return this.get('/v5/crypto-loan/loanable-data', params); diff --git a/src/types/response/v5-crypto-loan.ts b/src/types/response/v5-crypto-loan.ts index b0582804..e379de79 100644 --- a/src/types/response/v5-crypto-loan.ts +++ b/src/types/response/v5-crypto-loan.ts @@ -7,7 +7,7 @@ export interface CollateralCoinV5 { maxLimit: string; } -export interface VipCollateralCoinListV5 { +export interface VipCollateralCoinsV5 { list: CollateralCoinV5[]; vipLevel: string; } @@ -25,7 +25,7 @@ export interface BorrowableCoinV5 { minBorrowingAmount: string; } -export interface VipBorrowableCoinListV5 { +export interface VipBorrowableCoinsV5 { list: BorrowableCoinV5[]; vipLevel: string; } @@ -81,12 +81,12 @@ export interface CompletedLoanOrderV5 { status: number; } export interface LoanLTVAdjustmentHistoryV5 { - collateralCurrency: string; - orderId: string; - adjustId: string; - adjustTime: string; - preLTV: string; - afterLTV: string; - direction: number; - amount: string; - } + collateralCurrency: string; + orderId: string; + adjustId: string; + adjustTime: string; + preLTV: string; + afterLTV: string; + direction: number; + amount: string; +}