diff --git a/package.json b/package.json index e37e94ef..3c2d2223 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "binance", - "version": "2.10.3", + "version": "2.10.4", "description": "Node.js & JavaScript SDK for Binance REST APIs & WebSockets, with TypeScript & end-to-end tests.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/main-client.ts b/src/main-client.ts index 6cfa0c86..d5dbdcee 100644 --- a/src/main-client.ts +++ b/src/main-client.ts @@ -187,7 +187,6 @@ import { EnableConvertSubAccountParams, AcceptQuoteRequestParams, ReplaceSpotOrderParams, - ReplaceSpotOrderResultError, ReplaceSpotOrderResultSuccess, NewSpotSOROrderParams, SOROrderResponseFull, @@ -204,6 +203,20 @@ import { } from './util/requestUtils'; import BaseRestClient from './util/BaseRestClient'; +import { + SimpleEarnAccountResponse, + SimpleEarnFlexibleProductListResponse, + SimpleEarnFlexibleProductPositionParams, + SimpleEarnLockedProductListResponse, + SimpleEarnLockedProductPositionParams, + SimpleEarnLockedProductPositionResponse, + SimpleEarnProductListParams, + SimpleEarnRedeemParams, + SimpleEarnRedeemResponse, + SimpleEarnSubscribeFlexibleProductResponse, + SimpleEarnSubscribeLockedProductResponse, + SimpleEarnSubscribeProductParams, +} from './types/simpleEarn'; export class MainClient extends BaseRestClient { constructor( @@ -1145,6 +1158,64 @@ export class MainClient extends BaseRestClient { ); } + /** + * + * Simple earn Endpoints + * + **/ + + getFlexibleSavingProducts( + params?: SimpleEarnProductListParams, + ): Promise { + return this.getPrivate(`/sapi/v1/simple-earn/flexible/list`, params); + } + + getSimpleEarnLockedProductList( + params?: SimpleEarnProductListParams, + ): Promise { + return this.getPrivate(`/sapi/v1/simple-earn/locked/list`, params); + } + + purchaseFlexibleProduct( + params: SimpleEarnSubscribeProductParams, + ): Promise { + return this.postPrivate(`/sapi/v1/simple-earn/flexible/subscribe`, params); + } + + subscribeSimpleEarnLockedProduct( + params: SimpleEarnSubscribeProductParams, + ): Promise { + return this.postPrivate(`/sapi/v1/simple-earn/locked/subscribe`, params); + } + + redeemLockedProduct( + params: SimpleEarnRedeemParams, + ): Promise { + return this.postPrivate(`/sapi/v1/simple-earn/locked/redeem`, params); + } + + redeemFlexibleProduct( + params: SimpleEarnRedeemParams, + ): Promise { + return this.postPrivate(`/sapi/v1/simple-earn/flexible/redeem`, params); + } + + getFlexibleProductPosition( + params?: SimpleEarnFlexibleProductPositionParams, + ): Promise { + return this.getPrivate(`/sapi/v1/simple-earn/flexible/position`, params); + } + + getLockedProductPosition( + params?: SimpleEarnLockedProductPositionParams, + ): Promise { + return this.getPrivate(`/sapi/v1/simple-earn/locked/position`, params); + } + + getSimpleEarnAccount(): Promise { + return this.getPrivate(`/sapi/v1/simple-earn/account`); + } + /** * * Staking Endpoints @@ -1188,27 +1259,6 @@ export class MainClient extends BaseRestClient { * Savings Endpoints * **/ - getFlexibleSavingProducts( - params: FlexibleSavingBasicParams, - ): Promise { - return this.getPrivate(`sapi/v1/simple-earn/flexible/list`, params); - } - - purchaseFlexibleProduct( - params: PurchaseFlexibleProductParams, - ): Promise { - return this.postPrivate(`sapi/v1/simple-earn/flexible/subscribe`, params); - } - - redeemFlexibleProduct(params: RedeemFlexibleProductParams): Promise<{}> { - return this.postPrivate(`sapi/v1/simple-earn/flexible/redeem`, params); - } - - getFlexibleProductPosition(params: { - asset?: string; - }): Promise { - return this.getPrivate(`sapi/v1/simple-earn/flexible/position`, params); - } getLeftDailyPurchaseQuotaFlexibleProduct(params: { productId: string; diff --git a/src/types/simpleEarn.ts b/src/types/simpleEarn.ts new file mode 100644 index 00000000..5e7edbf6 --- /dev/null +++ b/src/types/simpleEarn.ts @@ -0,0 +1,121 @@ +export interface SimpleEarnProductListParams { + asset?: string; + current?: number; + size?: number; +} + +export interface SimpleEarnFlexibleProduct { + asset: string; + latestAnnualInterestRate: string; + tierAnnualPercentageRate: Record; + airDropPercentageRate: string; + canPurchase: boolean; + canRedeem: boolean; + isSoldOut: boolean; + hot: boolean; + minPurchaseAmount: string; + productId: string; + subscriptionStartTime: number; + status: string; +} + +export interface SimpleEarnFlexibleProductListResponse { + rows: SimpleEarnFlexibleProduct[]; + total: number; +} + +export interface SimpleEarnLockedProduct { + projectId: string; + detail: { + asset: string; + rewardAsset: string; + duration: number; + renewable: boolean; + isSoldOut: boolean; + apr: string; + status: string; + subscriptionStartTime: number; + extraRewardAsset: string; + extraRewardAPR: string; + }; + quota: { + totalPersonalQuota: string; + minimum: string; + }; +} + +export interface SimpleEarnLockedProductListResponse { + rows: SimpleEarnLockedProduct[]; + total: number; +} + +export interface SimpleEarnSubscribeProductParams { + productId: string; + amount: number; + autoSubscribe?: boolean; + sourceAccount?: 'SPOT' | 'FUND' | 'ALL'; +} + +export interface SimpleEarnSubscribeFlexibleProductResponse { + purchaseId: string; + success: boolean; +} + +export interface SimpleEarnSubscribeLockedProductResponse { + purchaseId: string; + positionId: string; + success: boolean; +} + +export interface SimpleEarnRedeemParams { + positionId: string; +} + +export interface SimpleEarnRedeemResponse { + success: boolean; + redeemId: string; +} + +export interface SimpleEarnFlexibleProductPositionParams { + asset?: string; + productId?: string; + current?: number; + size?: number; +} + +export interface SimpleEarnLockedProductPositionParams { + asset?: string; + productId?: string; + current?: number; + size?: number; + positionId?: string; +} + +export interface SimpleEarnLockedProductPosition { + positionId: string; + projectId: string; + asset: string; + amount: string; + purchaseTime: string; + duration: string; + accrualDays: string; + rewardAsset: string; + APY: string; + isRenewable: boolean; + isAutoRenew: boolean; + redeemDate: string; +} + +export interface SimpleEarnLockedProductPositionResponse { + rows: SimpleEarnLockedProductPosition[]; + total: number; +} + +export interface SimpleEarnAccountResponse { + totalAmountInBTC: string; + totalAmountInUSDT: string; + totalFlexibleAmountInBTC: string; + totalFlexibleAmountInUSDT: string; + totalLockedinBTC: string; + totalLockedinUSDT: string; +}