Skip to content

Commit

Permalink
chore(): type cleaning, fixes & refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagosiebler committed Jun 12, 2024
1 parent 4124513 commit ad1fb3c
Show file tree
Hide file tree
Showing 22 changed files with 369 additions and 377 deletions.
427 changes: 210 additions & 217 deletions src/RestClient.ts

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions src/types/request/delivery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* ==========================================================================================================================
*/

import { FuturesPriceTriggeredOrder } from '../shared';

export interface GetDeliveryOrderBookReq {
settle: 'usdt';
contract: string;
Expand All @@ -22,7 +20,7 @@ export interface GetDeliveryTradesReq {
to?: number;
}

export interface GetDeliveryCandlesticksReq {
export interface GetDeliveryCandlesReq {
settle: 'usdt';
contract: string;
from?: number;
Expand Down Expand Up @@ -117,12 +115,6 @@ export interface GetDeliverySettlementHistoryReq {
limit?: number;
at?: number;
}

export interface submitDeliveryTriggeredOrderReq
extends FuturesPriceTriggeredOrder {
settle: 'usdt';
}

export interface GetDeliveryAutoOrdersReq {
settle: 'usdt';
status: 'open' | 'finished';
Expand Down
29 changes: 25 additions & 4 deletions src/types/request/futures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* ==========================================================================================================================
*/

import { FuturesPriceTriggeredOrder } from '../response/futures';

export interface GetFuturesOrderBookReq {
settle: 'btc' | 'usdt' | 'usd';
contract: string;
Expand Down Expand Up @@ -168,8 +166,31 @@ export interface GetFuturesLiquidationHistoryReq {
at?: number;
}

export interface SubmitFuturesPriceTriggeredOrderReq
extends FuturesPriceTriggeredOrder {
export interface SubmitFuturesTriggeredOrderReq {
initial: {
contract: string;
size?: number;
price?: string;
close?: boolean;
tif?: 'gtc' | 'ioc';
text?: string;
reduce_only?: boolean;
auto_size?: string;
};
trigger: {
strategy_type?: 0 | 1;
price_type?: 0 | 1 | 2;
price?: string;
rule?: 1 | 2;
expiration?: number;
};
order_type?:
| 'close-long-order'
| 'close-short-order'
| 'close-long-position'
| 'close-short-position'
| 'plan-close-long-position'
| 'plan-close-short-position';
settle: 'btc' | 'usdt' | 'usd';
}

Expand Down
4 changes: 2 additions & 2 deletions src/types/request/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ export interface GetOptionsOrderBookReq {
with_id?: boolean;
}

export interface GetOptionsCandlesticksReq {
export interface GetOptionsCandlesReq {
contract: string;
limit?: number;
from?: number;
to?: number;
interval?: '1m' | '5m' | '15m' | '30m' | '1h';
}

export interface GetOptionsUnderlyingCandlesticksReq {
export interface GetOptionsUnderlyingCandlesReq {
underlying: string;
limit?: number;
from?: number;
Expand Down
Empty file removed src/types/request/shared.types.ts
Empty file.
4 changes: 2 additions & 2 deletions src/types/request/subaccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export interface CreateSubAccountApiKeyReq {
ip_whitelist?: string[]; // IP white list
}

export interface UpdateSubAccountApiKeyReq extends CreateSubAccountApiKeyReq {
export type UpdateSubAccountApiKeyReq = {
key: string;
}
} & CreateSubAccountApiKeyReq;
6 changes: 3 additions & 3 deletions src/types/response/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* ==========================================================================================================================
*/

export interface GetAccountDetailResp {
export interface AccountDetail {
user_id: number;
ip_whitelist: string[];
currency_pairs: string[];
Expand All @@ -13,14 +13,14 @@ export interface GetAccountDetailResp {
tier: number;
}

export interface CreateStpGroupResp {
export interface StpGroup {
id: number;
name: string;
creator_id: number;
create_time: number;
}

export interface StpResp {
export interface StpGroupUser {
user_id: number;
stp_id: number;
create_time: number;
Expand Down
8 changes: 4 additions & 4 deletions src/types/response/collateralloan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* ==========================================================================================================================
*/

export interface GetLoanOrdersResp {
export interface LoanOrder {
order_id: number;
collateral_currency: string;
collateral_amount: string;
Expand All @@ -22,7 +22,7 @@ export interface GetLoanOrdersResp {
left_repay_interest: string;
}

export interface GetLoanRepaymentHistoryResp {
export interface LoanRepaymentHistoryRecord {
order_id: number;
record_id: number;
repaid_amount: string;
Expand All @@ -38,7 +38,7 @@ export interface GetLoanRepaymentHistoryResp {
after_left_collateral: string;
}

export interface GetLoanCollateralRecordsResp {
export interface LoanCollateralRecord {
order_id: number;
record_id: number;
borrow_currency: string;
Expand All @@ -51,7 +51,7 @@ export interface GetLoanCollateralRecordsResp {
operate_time: number;
}

export interface GetLoanCollateralizationRatioResp {
export interface LoanCollateralRatio {
collateral_currency: string;
borrow_currency: string;
init_ltv: string;
Expand Down
20 changes: 10 additions & 10 deletions src/types/response/delivery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* ==========================================================================================================================
*/

export interface GetDeliveryOrderBookResp {
export interface DeliveryOrderBook {
id?: number;
current: number;
update: number;
asks: { p: string; s: number }[];
bids: { p: string; s: number }[];
}

export interface GetDeliveryTradesResp {
export interface DeliveryTrade {
id: number;
create_time: number;
create_time_ms: number;
Expand All @@ -21,7 +21,7 @@ export interface GetDeliveryTradesResp {
is_internal?: boolean;
}

export interface GetDeliveryCandlesticksResp {
export interface DeliveryCandle {
t: number;
v?: number;
c: string;
Expand All @@ -30,7 +30,7 @@ export interface GetDeliveryCandlesticksResp {
o: string;
}

export interface GetDeliveryTickersResp {
export interface DeliveryTicker {
contract: string;
last: string;
change_percentage: string;
Expand All @@ -54,7 +54,7 @@ export interface GetDeliveryTickersResp {
highest_bid: string;
}

export interface GetDeliveryAccountResp {
export interface DeliveryAccount {
total: string;
unrealised_pnl: string;
position_margin: string;
Expand Down Expand Up @@ -82,7 +82,7 @@ export interface GetDeliveryAccountResp {
};
}

export interface GetDeliveryBookResp {
export interface DeliveryBook {
time: number;
change: string;
balance: string;
Expand All @@ -101,7 +101,7 @@ export interface GetDeliveryBookResp {
trade_id?: string;
}

export interface GetDeliveryTradingHistoryResp {
export interface DeliveryTradingHistoryRecord {
id: number;
create_time: number;
contract: string;
Expand All @@ -114,7 +114,7 @@ export interface GetDeliveryTradingHistoryResp {
point_fee: string;
}

export interface GetDeliveryClosedPositionsResp {
export interface DeliveryClosedPosition {
time: number;
contract: string;
side: 'long' | 'short';
Expand All @@ -129,7 +129,7 @@ export interface GetDeliveryClosedPositionsResp {
short_price: string;
}

export interface GetDeliveryLiquidationHistoryResp {
export interface DeliveryLiquidationHistoryRecord {
time: number;
contract: string;
leverage?: string;
Expand All @@ -144,7 +144,7 @@ export interface GetDeliveryLiquidationHistoryResp {
left: number;
}

export interface GetDeliverySettlementHistoryResp {
export interface DeliverySettlementHistoryRecord {
time: number;
contract: string;
leverage: string;
Expand Down
8 changes: 4 additions & 4 deletions src/types/response/earn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* ==========================================================================================================================
*/

export interface GetDualInvestmentProductsResp {
export interface DualInvestmentProduct {
id: number;
instrument_name: string;
invest_currency: string;
Expand All @@ -19,7 +19,7 @@ export interface GetDualInvestmentProductsResp {
status: 'NOTSTARTED' | 'ONGOING' | 'ENDED';
}

export interface GetDualInvestmentOrdersResp {
export interface DualInvestmentOrder {
id: number;
plan_id: number;
copies: string;
Expand All @@ -43,7 +43,7 @@ export interface GetDualInvestmentOrdersResp {
delivery_time: number;
}

export interface GetStructuredProductListResp {
export interface StructuredProduct {
id: number;
type: string;
name_en: string;
Expand All @@ -58,7 +58,7 @@ export interface GetStructuredProductListResp {
status: 'in_process' | 'will_begin' | 'wait_settlement' | 'done';
}

export interface GetStructuredProductOrdersResp {
export interface StructuredProductOrder {
id: number;
pid: string;
lock_coin: string;
Expand Down
8 changes: 4 additions & 4 deletions src/types/response/earnuni.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* ==========================================================================================================================
*/

export interface GetLendingCurrenciesResp {
export interface LendingCurrency {
currency: string;
min_lend_amount: string;
max_lend_amount: string;
max_rate: string;
min_rate: string;
}

export interface GetLendingOrdersResp {
export interface LendingOrder {
currency: string;
current_amount: string;
amount: string;
Expand All @@ -24,7 +24,7 @@ export interface GetLendingOrdersResp {
update_time: number;
}

export interface GetLendingRecordsResp {
export interface LendingRecord {
currency: string;
amount: string;
last_wallet_amount: string;
Expand All @@ -34,7 +34,7 @@ export interface GetLendingRecordsResp {
create_time: number;
}

export interface GetLendingInterestRecordsResp {
export interface LendingInterestRecord {
status: number;
currency: string;
actual_rate: string;
Expand Down
4 changes: 2 additions & 2 deletions src/types/response/flashswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* ==========================================================================================================================
*/

export interface GetFlashSwapCurrencyPairsResp {
export interface FlashSwapCurrencyPair {
currency_pair: string;
sell_currency: string;
buy_currency: string;
Expand All @@ -13,7 +13,7 @@ export interface GetFlashSwapCurrencyPairsResp {
buy_max_amount: string;
}

export interface FlashSwapOrderResp {
export interface FlashSwapOrder {
id: number;
create_time: number;
user_id: number;
Expand Down
Loading

0 comments on commit ad1fb3c

Please sign in to comment.