From 9bb6cae03287d0b78ef9634b1f4a845f5a1b7492 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Wed, 26 Mar 2025 11:13:03 +0100 Subject: [PATCH] chore(4.1.0): updated earn types to include V5 suffix --- package-lock.json | 4 +- package.json | 2 +- src/rest-client-v5.ts | 450 +++++++++++++++++----------------- src/types/request/v5-earn.ts | 6 +- src/types/response/v5-earn.ts | 6 +- 5 files changed, 234 insertions(+), 234 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4553183..5cd2830 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bybit-api", - "version": "4.0.2", + "version": "4.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bybit-api", - "version": "4.0.2", + "version": "4.1.0", "license": "MIT", "dependencies": { "axios": "^1.7.9", diff --git a/package.json b/package.json index 1a6463e..572bfe8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "4.0.2", + "version": "4.1.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", diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index 90e77aa..f41fa98 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -1,225 +1,225 @@ /* eslint-disable max-len */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { - APIResponseV3, - APIResponseV3WithTime, - AccountBorrowCollateralLimitV5, - AccountCoinBalanceV5, - AccountInfoV5, - AccountMarginModeV5, - AccountOrderV5, - AccountTypeV5, - AddOrReduceMarginParamsV5, - AddOrReduceMarginResultV5, - AffiliateUserInfoV5, - AffiliateUserListItemV5, - AllCoinsBalanceV5, - AllowedDepositCoinInfoV5, - AmendOrderParamsV5, - ApiKeyInfoV5, - AssetInfoV5, - BatchAmendOrderParamsV5, - BatchAmendOrderResultV5, - BatchCancelOrderParamsV5, - BatchCancelOrderResultV5, - BatchCreateOrderResultV5, - BatchOrderParamsV5, - BatchOrdersResponseV5, - BorrowCryptoLoanParamsV5, - BorrowHistoryRecordV5, - BrokerIssuedVoucherV5, - BrokerVoucherSpecV5, - CancelAllOrdersParamsV5, - CancelOrderParamsV5, - CategoryCursorListV5, - CategoryListV5, - CategorySymbolListV5, - CategoryV5, - ClosedPnLV5, - CoinExchangeRecordV5, - CoinGreeksV5, - CoinInfoV5, - CollateralInfoV5, - CompletedLoanOrderV5, - ConfirmNewRiskLimitParamsV5, - ConvertCoinSpecV5, - ConvertCoinsParamsV5, - ConvertHistoryRecordV5, - ConvertQuoteV5, - ConvertStatusV5, - CreateP2PAdParamsV5, - CreateSubApiKeyParamsV5, - CreateSubApiKeyResultV5, - CreateSubMemberParamsV5, - CreateSubMemberResultV5, - CursorListV5, - CursorRowsV5, - DCPInfoV5, - DeleteSubMemberParamsV5, - DeliveryPriceV5, - DeliveryRecordV5, - DepositAddressChainV5, - DepositRecordV5, - EarnOrderHistory, - EarnPosition, - EarnProduct, - ExchangeBrokerAccountInfoV5, - ExchangeBrokerEarningResultV5, - ExchangeBrokerSubAccountDepositRecordV5, - ExecutionV5, - FeeRateV5, - FundingRateHistoryResponseV5, - GetAccountCoinBalanceParamsV5, - GetAccountHistoricOrdersParamsV5, - GetAccountOrdersParamsV5, - GetAllCoinsBalanceParamsV5, - GetAllowedDepositCoinInfoParamsV5, - GetAssetInfoParamsV5, - GetBorrowHistoryParamsV5, - GetBrokerIssuedVoucherParamsV5, - GetBrokerSubAccountDepositsV5, - GetClassicTransactionLogsParamsV5, - GetClosedPnLParamsV5, - GetCoinExchangeRecordParamsV5, - GetCompletedLoanOrderHistoryParamsV5, - GetConvertHistoryParamsV5, - GetDeliveryPriceParamsV5, - GetDeliveryRecordParamsV5, - GetDepositRecordParamsV5, - GetEarnOrderHistoryParams, - GetEarnPositionParams, - GetExchangeBrokerEarningsParamsV5, - GetExecutionListParamsV5, - GetFeeRateParamsV5, - GetFundingRateHistoryParamsV5, - GetHistoricalVolatilityParamsV5, - GetIndexPriceKlineParamsV5, - GetInstrumentsInfoParamsV5, - GetInsuranceParamsV5, - GetInternalDepositRecordParamsV5, - GetInternalTransferParamsV5, - GetKlineParamsV5, - GetLoanLTVAdjustmentHistoryParamsV5, - GetLongShortRatioParamsV5, - GetMarkPriceKlineParamsV5, - GetMovePositionHistoryParamsV5, - GetOpenInterestParamsV5, - GetOptionDeliveryPriceParamsV5, - GetOrderbookParamsV5, - GetP2PAccountCoinsBalanceParamsV5, - GetP2PCounterpartyUserInfoParamsV5, - GetP2POnlineAdsParamsV5, - GetP2POrderMessagesParamsV5, - GetP2POrdersParamsV5, - GetP2PPendingOrdersParamsV5, - GetP2PPersonalAdsParamsV5, - GetPreUpgradeClosedPnlParamsV5, - GetPreUpgradeOptionDeliveryRecordParamsV5, - GetPreUpgradeOrderHistoryParamsV5, - GetPreUpgradeTradeHistoryParamsV5, - GetPreUpgradeTransactionLogParamsV5, - GetPreUpgradeUSDCSessionParamsV5, - GetPremiumIndexPriceKlineParamsV5, - GetPublicTradingHistoryParamsV5, - GetRepaymentHistoryParamsV5, - GetRiskLimitParamsV5, - GetSettlementRecordParamsV5, - GetSpotLeveragedTokenOrderHistoryParamsV5, - GetSubAccountAllApiKeysParamsV5, - GetSubAccountDepositRecordParamsV5, - GetTickersParamsV5, - GetTransactionLogParamsV5, - GetUniversalTransferRecordsParamsV5, - GetUnpaidLoanOrdersParamsV5, - GetVIPMarginDataParamsV5, - GetWalletBalanceParamsV5, - GetWithdrawalRecordsParamsV5, - HistoricalVolatilityV5, - InstrumentInfoResponseV5, - InsuranceResponseV5, - InternalDepositRecordV5, - InternalTransferRecordV5, - IssueVoucherParamsV5, - LeverageTokenInfoV5, - LeveragedTokenMarketResultV5, - LoanLTVAdjustmentHistoryV5, - LongShortRatioV5, - MMPModifyParamsV5, - MMPStateV5, - MarkP2POrderAsPaidParamsV5, - MovePositionHistoryV5, - MovePositionParamsV5, - MovePositionResultV5, - OHLCKlineV5, - OHLCVKlineV5, - OpenInterestResponseV5, - OptionDeliveryPriceV5, - OrderParamsV5, - OrderResultV5, - OrderSideV5, - OrderbookResponseV5, - P2PAccountCoinsBalanceV5, - P2PAdDetailV5, - P2PCounterpartyUserInfoV5, - P2PCreateAdResponseV5, - P2POnlineAdsResponseV5, - P2POrderDetailV5, - P2POrderMessageV5, - P2POrdersResponseV5, - P2PPersonalAdsResponseV5, - P2PUserInfoV5, - P2PUserPaymentV5, - PositionInfoParamsV5, - PositionV5, - PreUpgradeOptionsDelivery, - PreUpgradeTransaction, - PreUpgradeUSDCSessionSettlement, - PublicTradeV5, - PurchaseSpotLeveragedTokenParamsV5, - PurchaseSpotLeveragedTokenResultV5, - RedeemSpotLeveragedTokenParamsV5, - RedeemSpotLeveragedTokenResultV5, - RepayLiabilityParamsV5, - RepayLiabilityResultV5, - RepaymentHistoryV5, - RequestConvertQuoteParamsV5, - RiskLimitV5, - SendP2POrderMessageParamsV5, - SetAutoAddMarginParamsV5, - SetCollateralCoinParamsV5, - SetLeverageParamsV5, - SetRiskLimitParamsV5, - SetRiskLimitResultV5, - SetTPSLModeParamsV5, - SetTradingStopParamsV5, - SettlementRecordV5, - SpotBorrowCheckResultV5, - SpotLeveragedTokenOrderHistoryV5, - SpotMarginStateV5, - SubMemberV5, - SubmitStakeRedeemParams, - SwitchIsolatedMarginParamsV5, - SwitchPositionModeParamsV5, - TPSLModeV5, - TickerLinearInverseV5, - TickerOptionV5, - TickerSpotV5, - TransactionLogV5, - UnifiedAccountUpgradeResultV5, - UniversalTransferParamsV5, - UniversalTransferRecordV5, - UnpaidLoanOrderV5, - UpdateApiKeyParamsV5, - UpdateApiKeyResultV5, - UpdateP2PAdParamsV5, - VIPMarginDataV5, - VaspEntityV5, - VipBorrowableCoinsV5, - VipCollateralCoinsV5, - WalletBalanceV5, - WithdrawParamsV5, - WithdrawableAmountV5, - WithdrawalRecordV5, + APIResponseV3, + APIResponseV3WithTime, + AccountBorrowCollateralLimitV5, + AccountCoinBalanceV5, + AccountInfoV5, + AccountMarginModeV5, + AccountOrderV5, + AccountTypeV5, + AddOrReduceMarginParamsV5, + AddOrReduceMarginResultV5, + AffiliateUserInfoV5, + AffiliateUserListItemV5, + AllCoinsBalanceV5, + AllowedDepositCoinInfoV5, + AmendOrderParamsV5, + ApiKeyInfoV5, + AssetInfoV5, + BatchAmendOrderParamsV5, + BatchAmendOrderResultV5, + BatchCancelOrderParamsV5, + BatchCancelOrderResultV5, + BatchCreateOrderResultV5, + BatchOrderParamsV5, + BatchOrdersResponseV5, + BorrowCryptoLoanParamsV5, + BorrowHistoryRecordV5, + BrokerIssuedVoucherV5, + BrokerVoucherSpecV5, + CancelAllOrdersParamsV5, + CancelOrderParamsV5, + CategoryCursorListV5, + CategoryListV5, + CategorySymbolListV5, + CategoryV5, + ClosedPnLV5, + CoinExchangeRecordV5, + CoinGreeksV5, + CoinInfoV5, + CollateralInfoV5, + CompletedLoanOrderV5, + ConfirmNewRiskLimitParamsV5, + ConvertCoinSpecV5, + ConvertCoinsParamsV5, + ConvertHistoryRecordV5, + ConvertQuoteV5, + ConvertStatusV5, + CreateP2PAdParamsV5, + CreateSubApiKeyParamsV5, + CreateSubApiKeyResultV5, + CreateSubMemberParamsV5, + CreateSubMemberResultV5, + CursorListV5, + CursorRowsV5, + DCPInfoV5, + DeleteSubMemberParamsV5, + DeliveryPriceV5, + DeliveryRecordV5, + DepositAddressChainV5, + DepositRecordV5, + EarnOrderHistoryV5, + EarnPositionV5, + EarnProductV5, + ExchangeBrokerAccountInfoV5, + ExchangeBrokerEarningResultV5, + ExchangeBrokerSubAccountDepositRecordV5, + ExecutionV5, + FeeRateV5, + FundingRateHistoryResponseV5, + GetAccountCoinBalanceParamsV5, + GetAccountHistoricOrdersParamsV5, + GetAccountOrdersParamsV5, + GetAllCoinsBalanceParamsV5, + GetAllowedDepositCoinInfoParamsV5, + GetAssetInfoParamsV5, + GetBorrowHistoryParamsV5, + GetBrokerIssuedVoucherParamsV5, + GetBrokerSubAccountDepositsV5, + GetClassicTransactionLogsParamsV5, + GetClosedPnLParamsV5, + GetCoinExchangeRecordParamsV5, + GetCompletedLoanOrderHistoryParamsV5, + GetConvertHistoryParamsV5, + GetDeliveryPriceParamsV5, + GetDeliveryRecordParamsV5, + GetDepositRecordParamsV5, + GetEarnOrderHistoryParamsV5, + GetEarnPositionParamsV5, + GetExchangeBrokerEarningsParamsV5, + GetExecutionListParamsV5, + GetFeeRateParamsV5, + GetFundingRateHistoryParamsV5, + GetHistoricalVolatilityParamsV5, + GetIndexPriceKlineParamsV5, + GetInstrumentsInfoParamsV5, + GetInsuranceParamsV5, + GetInternalDepositRecordParamsV5, + GetInternalTransferParamsV5, + GetKlineParamsV5, + GetLoanLTVAdjustmentHistoryParamsV5, + GetLongShortRatioParamsV5, + GetMarkPriceKlineParamsV5, + GetMovePositionHistoryParamsV5, + GetOpenInterestParamsV5, + GetOptionDeliveryPriceParamsV5, + GetOrderbookParamsV5, + GetP2PAccountCoinsBalanceParamsV5, + GetP2PCounterpartyUserInfoParamsV5, + GetP2POnlineAdsParamsV5, + GetP2POrderMessagesParamsV5, + GetP2POrdersParamsV5, + GetP2PPendingOrdersParamsV5, + GetP2PPersonalAdsParamsV5, + GetPreUpgradeClosedPnlParamsV5, + GetPreUpgradeOptionDeliveryRecordParamsV5, + GetPreUpgradeOrderHistoryParamsV5, + GetPreUpgradeTradeHistoryParamsV5, + GetPreUpgradeTransactionLogParamsV5, + GetPreUpgradeUSDCSessionParamsV5, + GetPremiumIndexPriceKlineParamsV5, + GetPublicTradingHistoryParamsV5, + GetRepaymentHistoryParamsV5, + GetRiskLimitParamsV5, + GetSettlementRecordParamsV5, + GetSpotLeveragedTokenOrderHistoryParamsV5, + GetSubAccountAllApiKeysParamsV5, + GetSubAccountDepositRecordParamsV5, + GetTickersParamsV5, + GetTransactionLogParamsV5, + GetUniversalTransferRecordsParamsV5, + GetUnpaidLoanOrdersParamsV5, + GetVIPMarginDataParamsV5, + GetWalletBalanceParamsV5, + GetWithdrawalRecordsParamsV5, + HistoricalVolatilityV5, + InstrumentInfoResponseV5, + InsuranceResponseV5, + InternalDepositRecordV5, + InternalTransferRecordV5, + IssueVoucherParamsV5, + LeverageTokenInfoV5, + LeveragedTokenMarketResultV5, + LoanLTVAdjustmentHistoryV5, + LongShortRatioV5, + MMPModifyParamsV5, + MMPStateV5, + MarkP2POrderAsPaidParamsV5, + MovePositionHistoryV5, + MovePositionParamsV5, + MovePositionResultV5, + OHLCKlineV5, + OHLCVKlineV5, + OpenInterestResponseV5, + OptionDeliveryPriceV5, + OrderParamsV5, + OrderResultV5, + OrderSideV5, + OrderbookResponseV5, + P2PAccountCoinsBalanceV5, + P2PAdDetailV5, + P2PCounterpartyUserInfoV5, + P2PCreateAdResponseV5, + P2POnlineAdsResponseV5, + P2POrderDetailV5, + P2POrderMessageV5, + P2POrdersResponseV5, + P2PPersonalAdsResponseV5, + P2PUserInfoV5, + P2PUserPaymentV5, + PositionInfoParamsV5, + PositionV5, + PreUpgradeOptionsDelivery, + PreUpgradeTransaction, + PreUpgradeUSDCSessionSettlement, + PublicTradeV5, + PurchaseSpotLeveragedTokenParamsV5, + PurchaseSpotLeveragedTokenResultV5, + RedeemSpotLeveragedTokenParamsV5, + RedeemSpotLeveragedTokenResultV5, + RepayLiabilityParamsV5, + RepayLiabilityResultV5, + RepaymentHistoryV5, + RequestConvertQuoteParamsV5, + RiskLimitV5, + SendP2POrderMessageParamsV5, + SetAutoAddMarginParamsV5, + SetCollateralCoinParamsV5, + SetLeverageParamsV5, + SetRiskLimitParamsV5, + SetRiskLimitResultV5, + SetTPSLModeParamsV5, + SetTradingStopParamsV5, + SettlementRecordV5, + SpotBorrowCheckResultV5, + SpotLeveragedTokenOrderHistoryV5, + SpotMarginStateV5, + SubMemberV5, + SubmitStakeRedeemParamsV5, + SwitchIsolatedMarginParamsV5, + SwitchPositionModeParamsV5, + TPSLModeV5, + TickerLinearInverseV5, + TickerOptionV5, + TickerSpotV5, + TransactionLogV5, + UnifiedAccountUpgradeResultV5, + UniversalTransferParamsV5, + UniversalTransferRecordV5, + UnpaidLoanOrderV5, + UpdateApiKeyParamsV5, + UpdateApiKeyResultV5, + UpdateP2PAdParamsV5, + VIPMarginDataV5, + VaspEntityV5, + VipBorrowableCoinsV5, + VipCollateralCoinsV5, + WalletBalanceV5, + WithdrawParamsV5, + WithdrawableAmountV5, + WithdrawalRecordV5, } from './types'; import { REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; @@ -2587,7 +2587,7 @@ export class RestClientV5 extends BaseRestClient { */ getEarnProduct(params: { category: string; coin?: string }): Promise< APIResponseV3WithTime<{ - list: EarnProduct[]; + list: EarnProductV5[]; }> > { return this.get('/v5/earn/product', params); @@ -2603,7 +2603,7 @@ export class RestClientV5 extends BaseRestClient { * within 48 hours. Once the redemption request is initiated, it cannot be canceled, * and your principal will continue to earn interest until the process is completed. */ - submitStakeRedeem(params: SubmitStakeRedeemParams): Promise< + submitStakeRedeem(params: SubmitStakeRedeemParamsV5): Promise< APIResponseV3WithTime<{ orderId: string; orderLinkId: string; @@ -2620,9 +2620,9 @@ export class RestClientV5 extends BaseRestClient { * Note: Either orderId or orderLinkId is required. If both are passed, * make sure they're matched, otherwise returning empty result */ - getEarnOrderHistory(params: GetEarnOrderHistoryParams): Promise< + getEarnOrderHistory(params: GetEarnOrderHistoryParamsV5): Promise< APIResponseV3WithTime<{ - list: EarnOrderHistory[]; + list: EarnOrderHistoryV5[]; }> > { return this.getPrivate('/v5/earn/order', params); @@ -2635,9 +2635,9 @@ export class RestClientV5 extends BaseRestClient { * * Note: Fully redeemed position is also returned in the response */ - getEarnPosition(params: GetEarnPositionParams): Promise< + getEarnPosition(params: GetEarnPositionParamsV5): Promise< APIResponseV3WithTime<{ - list: EarnPosition[]; + list: EarnPositionV5[]; }> > { return this.getPrivate('/v5/earn/position', params); diff --git a/src/types/request/v5-earn.ts b/src/types/request/v5-earn.ts index b25c354..2734e74 100644 --- a/src/types/request/v5-earn.ts +++ b/src/types/request/v5-earn.ts @@ -1,4 +1,4 @@ -export interface SubmitStakeRedeemParams { +export interface SubmitStakeRedeemParamsV5 { category: string; orderType: 'Stake' | 'Redeem'; accountType: 'FUND' | 'UNIFIED'; @@ -8,13 +8,13 @@ export interface SubmitStakeRedeemParams { orderLinkId: string; } -export interface GetEarnOrderHistoryParams { +export interface GetEarnOrderHistoryParamsV5 { category: string; orderId?: string; orderLinkId?: string; } -export interface GetEarnPositionParams { +export interface GetEarnPositionParamsV5 { category: string; productId?: string; coin?: string; diff --git a/src/types/response/v5-earn.ts b/src/types/response/v5-earn.ts index e25a07a..15a1680 100644 --- a/src/types/response/v5-earn.ts +++ b/src/types/response/v5-earn.ts @@ -1,4 +1,4 @@ -export interface EarnProduct { +export interface EarnProductV5 { category: string; estimateApr: string; coin: string; @@ -9,7 +9,7 @@ export interface EarnProduct { status: 'Available' | 'NotAvailable'; } -export interface EarnOrderHistory { +export interface EarnOrderHistoryV5 { coin: string; orderValue: string; orderType: 'Redeem' | 'Stake'; @@ -21,7 +21,7 @@ export interface EarnOrderHistory { updatedAt: string; } -export interface EarnPosition { +export interface EarnPositionV5 { coin: string; productId: string; amount: string;