Skip to content

Commit

Permalink
chore(): refactor & clean types
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagosiebler committed Jun 12, 2024
1 parent a5efe89 commit 687fe8f
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 130 deletions.
148 changes: 71 additions & 77 deletions src/RestClient.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/types/request/futures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface GetFuturesTradesReq {
to?: number;
}

export interface GetFuturesCandlesticksReq {
export interface GetFuturesCandlesReq {
settle: 'btc' | 'usdt' | 'usd';
contract: string;
from?: number;
Expand Down
2 changes: 1 addition & 1 deletion src/types/request/spot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface GetSpotTradesReq {
page?: number;
}

export interface GetSpotCandlesticksReq {
export interface GetSpotCandlesReq {
currency_pair: string;
limit?: number;
from?: number;
Expand Down
10 changes: 5 additions & 5 deletions src/types/response/futures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* ==========================================================================================================================
*/

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

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

export interface GetFuturesCandlesticksResp {
export interface FuturesCandle {
t: number;
v?: number;
c: string;
Expand All @@ -31,15 +31,15 @@ export interface GetFuturesCandlesticksResp {
sum: string;
}

export interface GetPremiumIndexKLineResp {
export interface PremiumIndexKLine {
t: number;
c: string;
h: string;
l: string;
o: string;
}

export interface GetFuturesTickersResp {
export interface FuturesTicker {
contract: string;
last: string;
change_percentage: string;
Expand Down
49 changes: 16 additions & 33 deletions src/types/response/spot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* ==========================================================================================================================
*/

export interface GetSpotCurrenciesResp {
export interface SpotCurrency {
currency: string;
delisted: boolean;
withdraw_disabled: boolean;
Expand All @@ -14,7 +14,7 @@ export interface GetSpotCurrenciesResp {
chain: string;
}

export interface GetSpotTickerResp {
export interface SpotTicker {
currency_pair: string;
last: string;
lowest_ask: string;
Expand All @@ -32,15 +32,15 @@ export interface GetSpotTickerResp {
etf_leverage: string | null;
}

export interface GetSpotOrderBookResp {
export interface SpotOrderBook {
id?: number;
current: number;
update: number;
asks: [string, string][];
bids: [string, string][];
}

export interface GetSpotTradesResp {
export interface SpotTrade {
id: string;
create_time: string;
create_time_ms: string;
Expand All @@ -59,20 +59,18 @@ export interface GetSpotTradesResp {
text: string;
}

export type GetSpotCandlesticksResp = [
[
string, // Unix timestamp with second precision
string, // Trading volume in quote currency
string, // Closing price
string, // Highest price
string, // Lowest price
string, // Opening price
string, // Trading volume in base currency
boolean, // Whether the window is closed
],
export type SpotCandle = [
string, // Unix timestamp with second precision
string, // Trading volume in quote currency
string, // Closing price
string, // Highest price
string, // Lowest price
string, // Opening price
string, // Trading volume in base currency
boolean, // Whether the window is closed
];

export interface GetSpotFeeRatesResp {
export interface SpotFeeRates {
user_id: number;
taker_fee: string;
maker_fee: string;
Expand All @@ -85,29 +83,14 @@ export interface GetSpotFeeRatesResp {
debit_fee: number;
}

export interface GetSpotBatchFeeRatesResp {
[key: string]: {
user_id: number;
taker_fee: string;
maker_fee: string;
gt_discount: boolean;
gt_taker_fee: string;
gt_maker_fee: string;
loan_fee: string;
point_type: string;
currency_pair: string;
debit_fee: number;
};
}

export interface GetSpotAccountsResp {
export interface SpotAccount {
currency: string;
available: string;
locked: string;
update_id: number;
}

export interface GetSpotAccountBookResp {
export interface SpotAccountBook {
id: string;
time: number;
currency: string;
Expand Down
6 changes: 3 additions & 3 deletions src/types/response/subaccount.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface SubAccountResp {
export interface SubAccount {
remark?: string;
login_name: string;
password?: string;
Expand All @@ -9,7 +9,7 @@ export interface SubAccountResp {
create_time: number;
}

export interface CreateSubAccountApiKeyResp {
export interface CreatedSubAccountAPIKey {
user_id: string;
mode?: number;
name?: string;
Expand All @@ -34,7 +34,7 @@ export interface CreateSubAccountApiKeyResp {
last_access: number;
}

export interface SubAccountKey {
export interface SubAccountAPIKey {
user_id?: string;
mode?: number;
name?: string;
Expand Down
10 changes: 5 additions & 5 deletions src/types/response/unified.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface GetUnifiedAccountInfoResp {
export interface UnifiedAccountInfo {
user_id: number;
refresh_time: number;
locked: boolean;
Expand Down Expand Up @@ -31,7 +31,7 @@ export interface GetUnifiedAccountInfoResp {
spot_hedge: boolean;
}

export interface GetUnifiedLoansResp {
export interface UnifiedLoan {
currency: string;
currency_pair: string;
amount: string;
Expand All @@ -40,7 +40,7 @@ export interface GetUnifiedLoansResp {
update_time: number;
}

export interface GetUnifiedLoanRecordsResp {
export interface UnifiedLoanRecord {
id: number;
type: 'borrow' | 'repay';
repayment_type: 'none' | 'manual_repay' | 'auto_repay' | 'cancel_auto_repay';
Expand All @@ -49,7 +49,7 @@ export interface GetUnifiedLoanRecordsResp {
amount: string;
create_time: number;
}
export interface GetUnifiedInterestRecordsResp {
export interface UnifiedInterestRecord {
currency: string;
currency_pair: string;
actual_rate: string;
Expand Down Expand Up @@ -84,7 +84,7 @@ export interface GetUnifiedCurrencyDiscountTiersResp {
}[];
}

export interface PortfolioMarginCalculatorResp {
export interface PortfolioMarginCalculation {
maintain_margin_total: string;
initial_margin_total: string;
calculate_time: number;
Expand Down
8 changes: 4 additions & 4 deletions src/types/response/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface GetCurrencyChainsResp {
export interface CurrencyChain {
chain: string;
name_cn: string;
name_en: string;
Expand All @@ -21,7 +21,7 @@ export interface CreateDepositAddressResp {
}[];
}

export interface SubAccountTransferRecordResp {
export interface SubAccountTransferRecord {
currency: string;
sub_account: string;
direction: 'to' | 'from';
Expand Down Expand Up @@ -133,7 +133,7 @@ export interface SubAccountCrossMarginBalancesResp {
};
}

export interface GetSavedAddressResp {
export interface SavedAddress {
currency: string;
chain: string;
address: string;
Expand Down Expand Up @@ -175,7 +175,7 @@ export interface GetBalancesResp {
};
}

export interface GetSmallBalancesResp {
export interface SmallBalanceRecord {
currency: string;
available_balance: string;
estimated_as_btc: string;
Expand Down
2 changes: 1 addition & 1 deletion src/types/response/withdrawal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface Withdrawal {
export interface WithdrawalRecord {
id: string;
txid: string;
withdraw_order_id: string;
Expand Down
1 change: 1 addition & 0 deletions src/types/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type GateBaseUrlKey =

// interfaces

// Used for spot and flash swap
export interface CurrencyPair {
id?: string;
base?: string;
Expand Down

0 comments on commit 687fe8f

Please sign in to comment.