Skip to content

Commit

Permalink
chore(): separated types per group, added rebates endpoints and types
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ-Cro committed May 23, 2024
1 parent 1d004e8 commit 68338ad
Show file tree
Hide file tree
Showing 34 changed files with 1,989 additions and 1,811 deletions.
334 changes: 219 additions & 115 deletions src/RestClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,159 @@
import { AxiosRequestConfig } from 'axios';
import {
GetAgencyCommissionHistoryReq,
GetAgencyTransactionHistoryReq,
GetBrokerCommissionHistoryReq,
GetBrokerTransactionHistoryReq,
} from 'types/requests/rebate.js';
import {
CreateStpGroupResp,
GetAccountDetailResp,
StpResp,
} from 'types/response/account.js';
import {
GetLoanCollateralizationRatioResp,
GetLoanCollateralRecordsResp,
GetLoanOrdersResp,
GetLoanRepaymentHistoryResp,
} from 'types/response/collateralloan.js';
import {
GetDeliveryAccountResp,
GetDeliveryBookResp,
GetDeliveryCandlesticksResp,
GetDeliveryClosedPositionsResp,
GetDeliveryLiquidationHistoryResp,
GetDeliveryOrderBookResp,
GetDeliverySettlementHistoryResp,
GetDeliveryTickersResp,
GetDeliveryTradesResp,
GetDeliveryTradingHistoryResp,
} from 'types/response/delivery.js';
import {
GetDualInvestmentOrdersResp,
GetDualInvestmentProductsResp,
GetStructuredProductListResp,
GetStructuredProductOrdersResp,
} from 'types/response/earn.js';
import {
GetLendingCurrenciesResp,
GetLendingInterestRecordsResp,
GetLendingOrdersResp,
GetLendingRecordsResp,
} from 'types/response/earnuni.js';
import {
FlashSwapOrderResp,
GetFlashSwapCurrencyPairsResp,
SubmitFlashSwapOrderPreviewResp,
} from 'types/response/flashswap.js';
import {
DeleteFuturesBatchOrdersResp,
GetFuturesAccountResp,
GetFuturesAutoDeleveragingHistoryResp,
GetFuturesCandlesticksResp,
GetFuturesLiquidationHistoryResp,
GetFuturesOrderBookResp,
GetFuturesPositionHistoryResp,
GetFuturesStatsResp,
GetFuturesTickersResp,
GetFuturesTradesResp,
GetFuturesTradingHistoryResp,
GetIndexConstituentsResp,
GetLiquidationHistoryResp,
GetPremiumIndexKLineResp,
GetRiskLimitTiersResp,
ToggleFuturesDualModeResp,
} from 'types/response/futures.js';
import {
GetCrossMarginAccountHistoryResp,
GetCrossMarginAccountResp,
GetCrossMarginCurrenciesResp,
GetMarginAccountsResp,
GetMarginBalanceHistoryResp,
SubmitCrossMarginBorrowLoanResp,
} from 'types/response/margin.js';
import {
GetLendingMarketsResp,
GetMarginUNIInterestRecordsResp,
GetMarginUNILoanRecordsResp,
GetMarginUNILoansResp,
GetMarginUNIMaxBorrowResp,
} from 'types/response/marginuni.js';
import {
GetMultiLoanAdjustmentRecordsResp,
GetMultiLoanCurrencyQuotaResp,
GetMultiLoanFixedRatesResp,
GetMultiLoanOrdersResp,
GetMultiLoanRatioResp,
GetMultiLoanRepayRecordsResp,
GetMultiLoanSupportedCurrenciesResp,
RepayMultiLoanResp,
UpdateMultiLoanResp,
} from 'types/response/multicollateralLoan.js';
import {
GetOptionsAccountChangeResp,
GetOptionsAccountResp,
GetOptionsCandlesticksResp,
GetOptionsContractsResp,
GetOptionsLiquidationResp,
GetOptionsMySettlementsResp,
GetOptionsOrderBookResp,
GetOptionsPersonalHistoryResp,
GetOptionsPositionsUnderlyingResp,
GetOptionsSettlementHistoryResp,
GetOptionsTickersResp,
GetOptionsTradesResp,
GetOptionsUnderlyingCandlesticksResp,
SubmitOptionsOrderResp,
} from 'types/response/options.js';
import {
GetAgencyCommissionHistoryResp,
GetAgencyTransactionHistoryResp,
GetBrokerCommissionHistoryResp,
GetBrokerTransactionHistoryResp,
} from 'types/response/rebate.js';
import {
DeleteSpotBatchOrdersResp,
GetSpotAccountBookResp,
GetSpotAccountsResp,
GetSpotBatchFeeRatesResp,
GetSpotCandlesticksResp,
GetSpotCurrenciesResp,
GetSpotFeeRatesResp,
GetSpotOpenOrdersResp,
GetSpotOrderBookResp,
GetSpotTickerResp,
GetSpotTradesResp,
GetSpotTradingHistoryResp,
SubmitSpotBatchOrdersResp,
} from 'types/response/spot.js';
import {
CreateSubAccountApiKeyResp,
SubAccountResp,
} from 'types/response/subaccount.js';
import {
GetUnifiedAccountInfoResp,
GetUnifiedCurrencyDiscountTiersResp,
GetUnifiedInterestRecordsResp,
GetUnifiedLoanRecordsResp,
GetUnifiedLoansResp,
GetUnifiedRiskUnitDetailsResp,
PortfolioMarginCalculatorResp,
} from 'types/response/unified.js';
import {
APIResponse,
CreateDepositAddressResp,
GetBalancesResp,
GetCurrencyChainsResp,
GetSavedAddressResp,
GetSmallBalanceHistoryResp,
GetSmallBalancesResp,
GetTradingFeesResp,
GetWithdrawalStatusResp,
SubAccountCrossMarginBalancesResp,
SubAccountFuturesBalancesResp,
SubAccountMarginBalancesResp,
SubAccountTransferRecordResp,
} from 'types/response/wallet.js';

import {
BaseRestClient,
Expand Down Expand Up @@ -110,121 +265,6 @@ import {
UpdateSpotOrderReq,
UpdateSubAccountApiKeyReq,
} from './types/requests/shared.types.js';
import {
APIResponse,
CreateDepositAddressResp,
CreateStpGroupResp,
CreateSubAccountApiKeyResp,
DeleteFuturesBatchOrdersResp,
DeleteSpotBatchOrdersResp,
FlashSwapOrderResp,
GetAccountDetailResp,
GetBalancesResp,
GetCrossMarginAccountHistoryResp,
GetCrossMarginAccountResp,
GetCrossMarginCurrenciesResp,
GetCurrencyChainsResp,
GetDeliveryAccountResp,
GetDeliveryBookResp,
GetDeliveryCandlesticksResp,
GetDeliveryClosedPositionsResp,
GetDeliveryLiquidationHistoryResp,
GetDeliveryOrderBookResp,
GetDeliverySettlementHistoryResp,
GetDeliveryTickersResp,
GetDeliveryTradesResp,
GetDeliveryTradingHistoryResp,
GetDualInvestmentOrdersResp,
GetDualInvestmentProductsResp,
GetFlashSwapCurrencyPairsResp,
GetFuturesAccountResp,
GetFuturesAutoDeleveragingHistoryResp,
GetFuturesCandlesticksResp,
GetFuturesLiquidationHistoryResp,
GetFuturesOrderBookResp,
GetFuturesPositionHistoryResp,
GetFuturesStatsResp,
GetFuturesTickersResp,
GetFuturesTradesResp,
GetFuturesTradingHistoryResp,
GetIndexConstituentsResp,
GetLendingCurrenciesResp,
GetLendingInterestRecordsResp,
GetLendingMarketsResp,
GetLendingOrdersResp,
GetLendingRecordsResp,
GetLiquidationHistoryResp,
GetLoanCollateralizationRatioResp,
GetLoanCollateralRecordsResp,
GetLoanOrdersResp,
GetLoanRepaymentHistoryResp,
GetMarginAccountsResp,
GetMarginBalanceHistoryResp,
GetMarginUNIInterestRecordsResp,
GetMarginUNILoanRecordsResp,
GetMarginUNILoansResp,
GetMarginUNIMaxBorrowResp,
GetMultiLoanAdjustmentRecordsResp,
GetMultiLoanCurrencyQuotaResp,
GetMultiLoanFixedRatesResp,
GetMultiLoanOrdersResp,
GetMultiLoanRatioResp,
GetMultiLoanRepayRecordsResp,
GetMultiLoanSupportedCurrenciesResp,
GetOptionsAccountChangeResp,
GetOptionsAccountResp,
GetOptionsCandlesticksResp,
GetOptionsContractsResp,
GetOptionsLiquidationResp,
GetOptionsMySettlementsResp,
GetOptionsOrderBookResp,
GetOptionsPersonalHistoryResp,
GetOptionsPositionsUnderlyingResp,
GetOptionsSettlementHistoryResp,
GetOptionsTickersResp,
GetOptionsTradesResp,
GetOptionsUnderlyingCandlesticksResp,
GetPremiumIndexKLineResp,
GetRiskLimitTiersResp,
GetSavedAddressResp,
GetSmallBalanceHistoryResp,
GetSmallBalancesResp,
GetSpotAccountBookResp,
GetSpotAccountsResp,
GetSpotBatchFeeRatesResp,
GetSpotCandlesticksResp,
GetSpotCurrenciesResp,
GetSpotFeeRatesResp,
GetSpotOpenOrdersResp,
GetSpotOrderBookResp,
GetSpotTickerResp,
GetSpotTradesResp,
GetSpotTradingHistoryResp,
GetStructuredProductListResp,
GetStructuredProductOrdersResp,
GetTradingFeesResp,
GetUnifiedAccountInfoResp,
GetUnifiedCurrencyDiscountTiersResp,
GetUnifiedInterestRecordsResp,
GetUnifiedLoanRecordsResp,
GetUnifiedLoansResp,
GetUnifiedRiskUnitDetailsResp,
GetWithdrawalStatusResp,
PortfolioMarginCalculatorResp,
RepayMultiLoanResp,
StpResp,
SubAccountCrossMarginBalancesResp,
SubAccountFuturesBalancesResp,
SubAccountMarginBalancesResp,
SubAccountResp,
SubAccountTransferRecordResp,
SubmitCrossMarginBorrowLoanResp,
SubmitFlashSwapOrderPreviewResp,
SubmitOptionsOrderResp,
SubmitSpotBatchOrdersResp,
ToggleFuturesDualModeResp,
UpdateMultiLoanResp,
} from './types/response/shared.types.js';
import {
CancelBatchOrder,
Contract,
Expand Down Expand Up @@ -3821,4 +3861,68 @@ export class RestClient extends BaseRestClient {
query: query,
});
}

/**==========================================================================================================================
* REBATES
* ==========================================================================================================================
*/

/**
* The agency obtains the transaction history of the recommended user.
* Record time range cannot exceed 30 days.
*
* @param params Parameters for retrieving transaction history
* @returns Promise<APIResponse<GetAgencyTransactionHistoryResp>>
*/
getAgencyTransactionHistory(
params: GetAgencyTransactionHistoryReq,
): Promise<APIResponse<GetAgencyTransactionHistoryResp>> {
return this.getPrivate('/rebate/agency/transaction_history', params);
}

/**
* The agency obtains the commission history of the recommended user.
* Record time range cannot exceed 30 days.
*
* @param params Parameters for retrieving commission history
* @returns Promise<APIResponse<GetAgencyCommissionHistoryResp>>
*/
getAgencyCommissionHistory(
params: GetAgencyCommissionHistoryReq,
): Promise<APIResponse<GetAgencyCommissionHistoryResp>> {
return this.getPrivate('/rebate/agency/commission_history', params);
}

/**
* The broker obtains the user's commission rebate records.
* Record time range cannot exceed 30 days.
*
* @param params Parameters for retrieving commission rebate records
* @returns Promise<APIResponse<GetBrokerCommissionHistoryResp>>
*/
getBrokerCommissionHistory(
params: GetBrokerCommissionHistoryReq,
): Promise<APIResponse<GetBrokerCommissionHistoryResp>> {
return this.getPrivate('/rebate/broker/commission_history', params);
}

/**
* The broker obtains the user's trading history.
* Record time range cannot exceed 30 days.
*
* @param params Parameters for retrieving trading history
* @returns Promise<APIResponse<GetBrokerTransactionHistoryResp>>
*/
getBrokerTransactionHistory(
params: GetBrokerTransactionHistoryReq,
): Promise<APIResponse<GetBrokerTransactionHistoryResp>> {
return this.getPrivate('/rebate/broker/transaction_history', params);
}

/**
* User retrieves rebate information.
*/
getUserRebateInfo(): Promise<APIResponse<{ invite_uid: number }>> {
return this.getPrivate('/rebate/user/info');
}
}
Empty file added src/types/requests/account.ts
Empty file.
Empty file added src/types/requests/delivery.ts
Empty file.
Empty file added src/types/requests/earn.ts
Empty file.
Empty file added src/types/requests/earnuni.ts
Empty file.
Empty file added src/types/requests/flashswap.ts
Empty file.
Empty file added src/types/requests/futures.ts
Empty file.
Empty file added src/types/requests/margin.ts
Empty file.
Empty file added src/types/requests/marginuni.ts
Empty file.
Empty file added src/types/requests/options.ts
Empty file.
29 changes: 29 additions & 0 deletions src/types/requests/rebate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export interface GetAgencyTransactionHistoryReq {
currency_pair?: string;
user_id?: number;
from?: number;
to?: number;
limit?: number;
offset?: number;
}

export interface GetAgencyCommissionHistoryReq {
currency?: string;
user_id?: number;
from?: number;
to?: number;
limit?: number;
offset?: number;
}

export interface GetBrokerCommissionHistoryReq {
limit?: number;
offset?: number;
user_id?: number;
}

export interface GetBrokerTransactionHistoryReq {
limit?: number;
offset?: number;
user_id?: number;
}
Empty file added src/types/requests/spot.ts
Empty file.
Empty file.
Empty file added src/types/requests/unified.ts
Empty file.
Empty file added src/types/requests/wallet.ts
Empty file.
Empty file.
Loading

0 comments on commit 68338ad

Please sign in to comment.