feat(): added all Earn response types

This commit is contained in:
JJ-Cro
2024-12-16 12:26:57 +01:00
parent d2995530f1
commit c68899574a
3 changed files with 411 additions and 35 deletions

View File

@@ -50,6 +50,24 @@ import {
CTSpotTraderProfitSummaryV2, CTSpotTraderProfitSummaryV2,
CTSpotTraderTotalOrderDetailV2, CTSpotTraderTotalOrderDetailV2,
CTSpotTraderUnrealizedProfitV2, CTSpotTraderUnrealizedProfitV2,
EarnLoanCurrenciesV2,
EarnLoanDebtsV2,
EarnLoanHistoryV2,
EarnLoanLiquidationRecordsV2,
EarnLoanOrdersV2,
EarnLoanPledgeRateHistoryV2,
EarnLoanRepayHistoryV2,
EarnLoanRepayResponseV2,
EarnSavingsAccountV2,
EarnSavingsAssetsV2,
EarnSavingsProductsV2,
EarnSavingsRecordsV2,
EarnSavingsSubscriptionDetailV2,
EarnSharkfinAccountV2,
EarnSharkfinAssetsV2,
EarnSharkfinProductsV2,
EarnSharkfinRecordsV2,
EarnSharkfinSubscriptionDetailV2,
FundingAssetsV2, FundingAssetsV2,
FuturesAccountBillRequestV2, FuturesAccountBillRequestV2,
FuturesAccountBillV2, FuturesAccountBillV2,
@@ -2480,30 +2498,30 @@ export class RestClientV2 extends BaseRestClient {
getEarnSavingsProducts(params?: { getEarnSavingsProducts(params?: {
coin?: string; coin?: string;
filter?: string; filter?: string;
}): Promise<APIResponse<any>> { }): Promise<APIResponse<EarnSavingsProductsV2[]>> {
return this.getPrivate('/api/v2/earn/savings/product', params); return this.getPrivate('/api/v2/earn/savings/product', params);
} }
getEarnSavingsAccount(): Promise<APIResponse<any>> { getEarnSavingsAccount(): Promise<APIResponse<EarnSavingsAccountV2>> {
return this.getPrivate('/api/v2/earn/savings/account'); return this.getPrivate('/api/v2/earn/savings/account');
} }
getEarnSavingsAssets( getEarnSavingsAssets(
params: GetEarnSavingsAssetsRequestV2, params: GetEarnSavingsAssetsRequestV2,
): Promise<APIResponse<any>> { ): Promise<APIResponse<EarnSavingsAssetsV2>> {
return this.getPrivate('/api/v2/earn/savings/assets', params); return this.getPrivate('/api/v2/earn/savings/assets', params);
} }
getEarnSavingsRecords( getEarnSavingsRecords(
params: GetEarnSavingsRecordsRequestV2, params: GetEarnSavingsRecordsRequestV2,
): Promise<APIResponse<any>> { ): Promise<APIResponse<EarnSavingsRecordsV2>> {
return this.getPrivate('/api/v2/earn/savings/records', params); return this.getPrivate('/api/v2/earn/savings/records', params);
} }
getEarnSavingsSubscription(params: { getEarnSavingsSubscription(params: {
productId: string; productId: string;
periodType: string; periodType: string;
}): Promise<APIResponse<any>> { }): Promise<APIResponse<EarnSavingsSubscriptionDetailV2>> {
return this.getPrivate('/api/v2/earn/savings/subscribe-info', params); return this.getPrivate('/api/v2/earn/savings/subscribe-info', params);
} }
@@ -2511,25 +2529,45 @@ export class RestClientV2 extends BaseRestClient {
productId: string; productId: string;
periodType: string; periodType: string;
amount: string; amount: string;
}): Promise<APIResponse<any>> { }): Promise<
APIResponse<{
orderId: string;
status: string;
}>
> {
return this.postPrivate('/api/v2/earn/savings/subscribe', params); return this.postPrivate('/api/v2/earn/savings/subscribe', params);
} }
getEarnSavingsSubscriptionResult(params: { getEarnSavingsSubscriptionResult(params: {
productId: string; productId: string;
periodType: string; periodType: string;
}): Promise<APIResponse<any>> { }): Promise<
APIResponse<{
result: 'success' | 'fail';
msg: string;
}>
> {
return this.getPrivate('/api/v2/earn/savings/subscribe-result', params); return this.getPrivate('/api/v2/earn/savings/subscribe-result', params);
} }
earnRedeemSavings(params: RedeemSavingsRequestV2): Promise<APIResponse<any>> { earnRedeemSavings(params: RedeemSavingsRequestV2): Promise<
APIResponse<{
orderId: string;
status: string;
}>
> {
return this.postPrivate('/api/v2/earn/savings/redeem', params); return this.postPrivate('/api/v2/earn/savings/redeem', params);
} }
getEarnSavingsRedemptionResult(params: { getEarnSavingsRedemptionResult(params: {
orderId: string; orderId: string;
periodType: string; periodType: string;
}): Promise<APIResponse<any>> { }): Promise<
APIResponse<{
result: 'success' | 'fail';
msg: string;
}>
> {
return this.getPrivate('/api/v2/earn/savings/redeem-result', params); return this.getPrivate('/api/v2/earn/savings/redeem-result', params);
} }
@@ -2541,7 +2579,14 @@ export class RestClientV2 extends BaseRestClient {
* *
*/ */
getEarnAccount(params?: { coin?: string }): Promise<APIResponse<any>> { getEarnAccount(params?: { coin?: string }): Promise<
APIResponse<
{
coin: string;
amount: string;
}[]
>
> {
return this.getPrivate('/api/v2/earn/account/assets', params); return this.getPrivate('/api/v2/earn/account/assets', params);
} }
@@ -2557,42 +2602,47 @@ export class RestClientV2 extends BaseRestClient {
coin: string; coin: string;
limit?: string; limit?: string;
idLessThan?: string; idLessThan?: string;
}): Promise<APIResponse<any>> { }): Promise<APIResponse<EarnSharkfinProductsV2>> {
return this.getPrivate('/api/v2/earn/sharkfin/product', params); return this.getPrivate('/api/v2/earn/sharkfin/product', params);
} }
getSharkfinAccount(): Promise<APIResponse<any>> { getSharkfinAccount(): Promise<APIResponse<EarnSharkfinAccountV2>> {
return this.getPrivate('/api/v2/earn/sharkfin/account'); return this.getPrivate('/api/v2/earn/sharkfin/account');
} }
getSharkfinAssets( getSharkfinAssets(
params: GetSharkfinAssetsRequestV2, params: GetSharkfinAssetsRequestV2,
): Promise<APIResponse<any>> { ): Promise<APIResponse<EarnSharkfinAssetsV2>> {
return this.getPrivate('/api/v2/earn/sharkfin/assets', params); return this.getPrivate('/api/v2/earn/sharkfin/assets', params);
} }
getSharkfinRecords( getSharkfinRecords(
params: GetSharkfinRecordsRequestV2, params: GetSharkfinRecordsRequestV2,
): Promise<APIResponse<any>> { ): Promise<APIResponse<EarnSharkfinRecordsV2>> {
return this.getPrivate('/api/v2/earn/sharkfin/records', params); return this.getPrivate('/api/v2/earn/sharkfin/records', params);
} }
getSharkfinSubscription(params: { getSharkfinSubscription(params: {
productId: string; productId: string;
}): Promise<APIResponse<any>> { }): Promise<APIResponse<EarnSharkfinSubscriptionDetailV2>> {
return this.getPrivate('/api/v2/earn/sharkfin/subscribe-info', params); return this.getPrivate('/api/v2/earn/sharkfin/subscribe-info', params);
} }
subscribeSharkfin(params: { subscribeSharkfin(params: { productId: string; amount: string }): Promise<
productId: string; APIResponse<{
amount: string; orderId: string;
}): Promise<APIResponse<any>> { status: string;
}>
> {
return this.postPrivate('/api/v2/earn/sharkfin/subscribe', params); return this.postPrivate('/api/v2/earn/sharkfin/subscribe', params);
} }
getSharkfinSubscriptionResult(params: { getSharkfinSubscriptionResult(params: { orderId: string }): Promise<
orderId: string; APIResponse<{
}): Promise<APIResponse<any>> { result: 'success' | 'fail';
msg: string;
}>
> {
return this.getPrivate('/api/v2/earn/sharkfin/subscribe-result', params); return this.getPrivate('/api/v2/earn/sharkfin/subscribe-result', params);
} }
@@ -2604,17 +2654,28 @@ export class RestClientV2 extends BaseRestClient {
* *
*/ */
getLoanCurrencies(params?: { coin?: string }): Promise<APIResponse<any>> { getLoanCurrencies(params?: {
coin?: string;
}): Promise<APIResponse<EarnLoanCurrenciesV2>> {
return this.get('/api/v2/earn/loan/public/coinInfos', params); return this.get('/api/v2/earn/loan/public/coinInfos', params);
} }
getLoanEstInterestAndBorrowable( getLoanEstInterestAndBorrowable(
params: GetLoanEstInterestAndBorrowableRequestV2, params: GetLoanEstInterestAndBorrowableRequestV2,
): Promise<APIResponse<any>> { ): Promise<
APIResponse<{
hourInterest: string;
loanAmount: string;
}>
> {
return this.get('/api/v2/earn/loan/public/hour-interest', params); return this.get('/api/v2/earn/loan/public/hour-interest', params);
} }
borrowLoan(params: BorrowLoanRequestV2): Promise<APIResponse<any>> { borrowLoan(params: BorrowLoanRequestV2): Promise<
APIResponse<{
orderId: string;
}>
> {
return this.postPrivate('/api/v2/earn/loan/borrow', params); return this.postPrivate('/api/v2/earn/loan/borrow', params);
} }
@@ -2622,43 +2683,51 @@ export class RestClientV2 extends BaseRestClient {
orderId?: string; orderId?: string;
loanCoin?: string; loanCoin?: string;
pledgeCoin?: string; pledgeCoin?: string;
}): Promise<APIResponse<any>> { }): Promise<APIResponse<EarnLoanOrdersV2[]>> {
return this.getPrivate('/api/v2/earn/loan/ongoing-orders', params); return this.getPrivate('/api/v2/earn/loan/ongoing-orders', params);
} }
repayLoan(params: RepayLoanRequestV2): Promise<APIResponse<any>> { repayLoan(
params: RepayLoanRequestV2,
): Promise<APIResponse<EarnLoanRepayResponseV2>> {
return this.postPrivate('/api/v2/earn/loan/repay', params); return this.postPrivate('/api/v2/earn/loan/repay', params);
} }
getRepayHistory( getRepayHistory(
params: GetLoanRepayHistoryRequestV2, params: GetLoanRepayHistoryRequestV2,
): Promise<APIResponse<any>> { ): Promise<APIResponse<EarnLoanRepayHistoryV2>> {
return this.getPrivate('/api/v2/earn/loan/repay-history', params); return this.getPrivate('/api/v2/earn/loan/repay-history', params);
} }
updateLoanPledgeRate( updateLoanPledgeRate(params: ModifyLoanPledgeRateRequestV2): Promise<
params: ModifyLoanPledgeRateRequestV2, APIResponse<{
): Promise<APIResponse<any>> { loanCoin: string;
pledgeCoin: string;
afterPledgeRate: string;
}>
> {
return this.postPrivate('/api/v2/earn/loan/revise-pledge', params); return this.postPrivate('/api/v2/earn/loan/revise-pledge', params);
} }
getLoanPledgeRateHistory( getLoanPledgeRateHistory(
params: GetLoanPledgeRateHistoryRequestV2, params: GetLoanPledgeRateHistoryRequestV2,
): Promise<APIResponse<any>> { ): Promise<APIResponse<EarnLoanPledgeRateHistoryV2[]>> {
return this.getPrivate('/api/v2/earn/loan/revise-history', params); return this.getPrivate('/api/v2/earn/loan/revise-history', params);
} }
getLoanHistory(params: GetLoanHistoryRequestV2): Promise<APIResponse<any>> { getLoanHistory(
params: GetLoanHistoryRequestV2,
): Promise<APIResponse<EarnLoanHistoryV2[]>> {
return this.getPrivate('/api/v2/earn/loan/borrow-history', params); return this.getPrivate('/api/v2/earn/loan/borrow-history', params);
} }
getLoanDebts(): Promise<APIResponse<any>> { getLoanDebts(): Promise<APIResponse<EarnLoanDebtsV2>> {
return this.getPrivate('/api/v2/earn/loan/debts'); return this.getPrivate('/api/v2/earn/loan/debts');
} }
getLoanLiquidationRecords( getLoanLiquidationRecords(
params: GetLiquidationRecordsRequestV2, params: GetLiquidationRecordsRequestV2,
): Promise<APIResponse<any>> { ): Promise<APIResponse<EarnLoanLiquidationRecordsV2[]>> {
return this.getPrivate('/api/v2/earn/loan/reduces', params); return this.getPrivate('/api/v2/earn/loan/reduces', params);
} }
} }

View File

@@ -4,6 +4,7 @@ export * from './v1/spot';
export * from './v2/broker'; export * from './v2/broker';
export * from './v2/common'; export * from './v2/common';
export * from './v2/copy-trading'; export * from './v2/copy-trading';
export * from './v2/earn';
export * from './v2/futures'; export * from './v2/futures';
export * from './v2/margin'; export * from './v2/margin';
export * from './v2/spot'; export * from './v2/spot';

View File

@@ -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;
}