diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index 0c6f5af..8abc82f 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -50,6 +50,24 @@ import { CTSpotTraderProfitSummaryV2, CTSpotTraderTotalOrderDetailV2, CTSpotTraderUnrealizedProfitV2, + EarnLoanCurrenciesV2, + EarnLoanDebtsV2, + EarnLoanHistoryV2, + EarnLoanLiquidationRecordsV2, + EarnLoanOrdersV2, + EarnLoanPledgeRateHistoryV2, + EarnLoanRepayHistoryV2, + EarnLoanRepayResponseV2, + EarnSavingsAccountV2, + EarnSavingsAssetsV2, + EarnSavingsProductsV2, + EarnSavingsRecordsV2, + EarnSavingsSubscriptionDetailV2, + EarnSharkfinAccountV2, + EarnSharkfinAssetsV2, + EarnSharkfinProductsV2, + EarnSharkfinRecordsV2, + EarnSharkfinSubscriptionDetailV2, FundingAssetsV2, FuturesAccountBillRequestV2, FuturesAccountBillV2, @@ -2480,30 +2498,30 @@ export class RestClientV2 extends BaseRestClient { getEarnSavingsProducts(params?: { coin?: string; filter?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/earn/savings/product', params); } - getEarnSavingsAccount(): Promise> { + getEarnSavingsAccount(): Promise> { return this.getPrivate('/api/v2/earn/savings/account'); } getEarnSavingsAssets( params: GetEarnSavingsAssetsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/savings/assets', params); } getEarnSavingsRecords( params: GetEarnSavingsRecordsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/savings/records', params); } getEarnSavingsSubscription(params: { productId: string; periodType: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/earn/savings/subscribe-info', params); } @@ -2511,25 +2529,45 @@ export class RestClientV2 extends BaseRestClient { productId: string; periodType: string; amount: string; - }): Promise> { + }): Promise< + APIResponse<{ + orderId: string; + status: string; + }> + > { return this.postPrivate('/api/v2/earn/savings/subscribe', params); } getEarnSavingsSubscriptionResult(params: { productId: string; periodType: string; - }): Promise> { + }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > { return this.getPrivate('/api/v2/earn/savings/subscribe-result', params); } - earnRedeemSavings(params: RedeemSavingsRequestV2): Promise> { + earnRedeemSavings(params: RedeemSavingsRequestV2): Promise< + APIResponse<{ + orderId: string; + status: string; + }> + > { return this.postPrivate('/api/v2/earn/savings/redeem', params); } getEarnSavingsRedemptionResult(params: { orderId: string; periodType: string; - }): Promise> { + }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > { return this.getPrivate('/api/v2/earn/savings/redeem-result', params); } @@ -2541,7 +2579,14 @@ export class RestClientV2 extends BaseRestClient { * */ - getEarnAccount(params?: { coin?: string }): Promise> { + getEarnAccount(params?: { coin?: string }): Promise< + APIResponse< + { + coin: string; + amount: string; + }[] + > + > { return this.getPrivate('/api/v2/earn/account/assets', params); } @@ -2557,42 +2602,47 @@ export class RestClientV2 extends BaseRestClient { coin: string; limit?: string; idLessThan?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/earn/sharkfin/product', params); } - getSharkfinAccount(): Promise> { + getSharkfinAccount(): Promise> { return this.getPrivate('/api/v2/earn/sharkfin/account'); } getSharkfinAssets( params: GetSharkfinAssetsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/sharkfin/assets', params); } getSharkfinRecords( params: GetSharkfinRecordsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/sharkfin/records', params); } getSharkfinSubscription(params: { productId: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/earn/sharkfin/subscribe-info', params); } - subscribeSharkfin(params: { - productId: string; - amount: string; - }): Promise> { + subscribeSharkfin(params: { productId: string; amount: string }): Promise< + APIResponse<{ + orderId: string; + status: string; + }> + > { return this.postPrivate('/api/v2/earn/sharkfin/subscribe', params); } - getSharkfinSubscriptionResult(params: { - orderId: string; - }): Promise> { + getSharkfinSubscriptionResult(params: { orderId: string }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > { return this.getPrivate('/api/v2/earn/sharkfin/subscribe-result', params); } @@ -2604,17 +2654,28 @@ export class RestClientV2 extends BaseRestClient { * */ - getLoanCurrencies(params?: { coin?: string }): Promise> { + getLoanCurrencies(params?: { + coin?: string; + }): Promise> { return this.get('/api/v2/earn/loan/public/coinInfos', params); } getLoanEstInterestAndBorrowable( params: GetLoanEstInterestAndBorrowableRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + hourInterest: string; + loanAmount: string; + }> + > { return this.get('/api/v2/earn/loan/public/hour-interest', params); } - borrowLoan(params: BorrowLoanRequestV2): Promise> { + borrowLoan(params: BorrowLoanRequestV2): Promise< + APIResponse<{ + orderId: string; + }> + > { return this.postPrivate('/api/v2/earn/loan/borrow', params); } @@ -2622,43 +2683,51 @@ export class RestClientV2 extends BaseRestClient { orderId?: string; loanCoin?: string; pledgeCoin?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/earn/loan/ongoing-orders', params); } - repayLoan(params: RepayLoanRequestV2): Promise> { + repayLoan( + params: RepayLoanRequestV2, + ): Promise> { return this.postPrivate('/api/v2/earn/loan/repay', params); } getRepayHistory( params: GetLoanRepayHistoryRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/loan/repay-history', params); } - updateLoanPledgeRate( - params: ModifyLoanPledgeRateRequestV2, - ): Promise> { + updateLoanPledgeRate(params: ModifyLoanPledgeRateRequestV2): Promise< + APIResponse<{ + loanCoin: string; + pledgeCoin: string; + afterPledgeRate: string; + }> + > { return this.postPrivate('/api/v2/earn/loan/revise-pledge', params); } getLoanPledgeRateHistory( params: GetLoanPledgeRateHistoryRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/loan/revise-history', params); } - getLoanHistory(params: GetLoanHistoryRequestV2): Promise> { + getLoanHistory( + params: GetLoanHistoryRequestV2, + ): Promise> { return this.getPrivate('/api/v2/earn/loan/borrow-history', params); } - getLoanDebts(): Promise> { + getLoanDebts(): Promise> { return this.getPrivate('/api/v2/earn/loan/debts'); } getLoanLiquidationRecords( params: GetLiquidationRecordsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/loan/reduces', params); } } diff --git a/src/types/response/index.ts b/src/types/response/index.ts index e1eef1e..c0a4a58 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -4,6 +4,7 @@ export * from './v1/spot'; export * from './v2/broker'; export * from './v2/common'; export * from './v2/copy-trading'; +export * from './v2/earn'; export * from './v2/futures'; export * from './v2/margin'; export * from './v2/spot'; diff --git a/src/types/response/v2/earn.ts b/src/types/response/v2/earn.ts new file mode 100644 index 0000000..1caed6e --- /dev/null +++ b/src/types/response/v2/earn.ts @@ -0,0 +1,306 @@ +/** + * + * + * Earn | Savings + * + * + */ + +export interface EarnSavingsProductsV2 { + productId: string; + coin: string; + periodType: string; + period: string; + apyType: string; + advanceRedeem: string; + settleMethod: string; + apyList: { + rateLevel: string; + minStepVal: string; + maxStepVal: string; + currentApy: string; + }[]; + status: string; + productLevel: string; +} + +export interface EarnSavingsAccountV2 { + btcAmount: string; + usdtAmount: string; + btc24hEarning: string; + usdt24hEarning: string; + btcTotalEarning: string; + usdtTotalEarning: string; +} + +export interface EarnSavingsAssetsV2 { + resultList: { + productId: string; + orderId: string; + productCoin: string; + interestCoin: string; + periodType: string; + period: string; + holdAmount: string; + lastProfit: string; + totalProfit: string; + holdDays: string; + status: string; + allowRedemption: string; + productLevel: string; + apy: { + rateLevel: string; + minApy: string; + maxApy: string; + currentApy: string; + }[]; + }[]; + endId: string; +} + +export interface EarnSavingsRecordsV2 { + resultList: { + orderId: string; + coinName: string; + settleCoinName: string; + productType: string; + period: string; + productLevel: string; + amount: string; + ts: string; + orderType: string; + }[]; + endId: string; +} + +export interface EarnSavingsSubscriptionDetailV2 { + singleMinAmount: string; + singleMaxAmount: string; + remainingAmount: string; + subscribePrecision: string; + profitPrecision: string; + subscribeTime: string; + interestTime: string; + settleTime: string; + expireTime: string; + redeemTime: string; + settleMethod: string; + apyList: { + rateLevel: string; + minStepVal: string; + maxStepVal: string; + currentApy: string; + }[]; + redeemDelay: string; +} + +/** + * + * + * Earn | Earn Account + * + * + */ + +/** + * + * + * Earn | Shark Fin + * + * + */ + +export interface EarnSharkfinProductsV2 { + resultList: { + productId: string; + productName: string; + productCoin: string; + subscribeCoin: string; + farmingStartTime: string; + farmingEndTime: string; + lowerRate: string; + defaultRate: string; + upperRate: string; + period: string; + interestStartTime: string; + status: string; + minAmount: string; + limitAmount: string; + soldAmount: string; + endTime: string; + startTime: string; + }[]; + endId: string; +} + +export interface EarnSharkfinAccountV2 { + btcSubscribeAmount: string; + usdtSubscribeAmount: string; + btcHistoricalAmount: string; + usdtHistoricalAmount: string; + btcTotalEarning: string; + usdtTotalEarning: string; +} + +export interface EarnSharkfinAssetsV2 { + resultList: { + productId: string; + interestStartTime: string; + interestEndTime: string; + productCoin: string; + subscribeCoin: string; + trend: string; + settleTime: string; + interestAmount: string; + productStatus: string; + }[]; + endId: string; +} + +export interface EarnSharkfinRecordsV2 { + resultList: { + orderId: string; + product: string; + period: string; + amount: string; + ts: string; + type: string; + }[]; + endId: string; +} + +export interface EarnSharkfinSubscriptionDetailV2 { + productCoin: string; + subscribeCoin: string; + interestTime: string; + expirationTime: string; + minPrice: string; + currentPrice: string; + maxPrice: string; + minRate: string; + defaultRate: string; + maxRate: string; + period: string; + productMinAmount: string; + availableBalance: string; + userAmount: string; + remainingAmount: string; + profitPrecision: string; + subscribePrecision: string; +} + +/** + * + * + * Earn | Loan + * + * + */ + +export interface EarnLoanCurrenciesV2 { + loanInfos: { + coin: string; + hourRate7D: string; + rate7D: string; + hourRate30D: string; + rate30D: string; + minUsdt: string; + maxUsdt: string; + min: string; + max: string; + }[]; + pledgeInfos: { + coin: string; + initRate: string; + supRate: string; + forceRate: string; + minUsdt: string; + maxUsdt: string; + }[]; +} + +export interface EarnLoanOrdersV2 { + orderId: string; + loanCoin: string; + loanAmount: string; + interestAmount: string; + hourInterestRate: string; + pledgeCoin: string; + pledgeAmount: string; + pledgeRate: string; + supRate: string; + forceRate: string; + borrowTime: string; + expireTime: string; +} + +export interface EarnLoanRepayResponseV2 { + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; +} + +export interface EarnLoanRepayHistoryV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; + repayTime: string; +} + +export interface EarnLoanPledgeRateHistoryV2 { + loanCoin: string; + pledgeCoin: string; + orderId: string; + reviseTime: string; + reviseSide: string; + reviseAmount: string; + afterPledgeRate: string; + beforePledgeRate: string; +} + +export interface EarnLoanHistoryV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + initPledgeAmount: string; + initLoanAmount: string; + hourRate: string; + daily: string; + borrowTime: string; + status: string; +} + +export interface EarnLoanDebtsV2 { + pledgeInfos: { + coin: string; + amount: string; + amountUsdt: string; + }[]; + loanInfos: { + coin: string; + amount: string; + amountUsdt: string; + }[]; +} + +export interface EarnLoanLiquidationRecordsV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + reduceTime: string; + pledgeRate: string; + pledgePrice: string; + status: string; + pledgeAmount: string; + reduceFee: string; + residueAmount: string; + runlockAmount: string; + repayLoanAmount: string; +}