Skip to content

Commit

Permalink
feat(): Added new endpoints, updated types, updated endpoint map
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ-Cro committed Sep 9, 2024
1 parent d9531fc commit 73a471f
Show file tree
Hide file tree
Showing 8 changed files with 340 additions and 280 deletions.
545 changes: 275 additions & 270 deletions docs/endpointFunctionList.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gateio-api",
"version": "1.0.15",
"version": "1.0.16",
"description": "Complete & robust Node.js SDK for Gate.io's REST APIs, WebSockets & WebSocket APIs, with TypeScript declarations.",
"scripts": {
"clean": "rm -rf dist/*",
Expand Down
46 changes: 39 additions & 7 deletions src/RestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ import {
GetOptionsSettlementHistoryReq,
GetOptionsTradesReq,
GetOptionsUnderlyingCandlesReq,
OptionsMMPSettingsReq,
SubmitOptionsOrderReq,
} from './types/request/options.js';
import {
Expand Down Expand Up @@ -244,6 +245,7 @@ import {
OptionsAccountChangeRecord,
OptionsCandle,
OptionsContract,
OptionsMMPSettings,
OptionsOrderBook,
OptionsPositionsUnderlying,
OptionsSettlementHistoryRecord,
Expand Down Expand Up @@ -910,13 +912,7 @@ export class RestClient extends BaseRestClient {
/**
* Query mode of the unified account
*
* @returns Promise<{
* mode: 'classic' | 'multi_currency' | 'portfolio';
* settings: {
* usdt_futures?: boolean;
* spot_hedge?: boolean;
* };
* }>
* @returns Promise<SetUnifiedAccountModeReq>
*/
getUnifiedAccountMode(): Promise<SetUnifiedAccountModeReq> {
return this.getPrivate('/unified/unified_mode');
Expand Down Expand Up @@ -3283,6 +3279,42 @@ export class RestClient extends BaseRestClient {
return this.getPrivate(`/options/my_trades`, params);
}

/**
* Set MMP (Market Maker Protection) settings
*
* @param params Parameters for setting MMP settings
* @returns Promise<OptionsMMPSetings>
*/
setOptionsMMPSettings(
params: OptionsMMPSettingsReq,
): Promise<OptionsMMPSettings> {
return this.postPrivate('/options/mmp', { body: params });
}

/**
* Query MMP (Market Maker Protection) settings
*
* @param params Parameters for querying MMP settings
* @returns Promise<OptionsMMPSetings[]>
*/
getOptionsMMPSettings(params?: {
underlying?: string;
}): Promise<OptionsMMPSettings[]> {
return this.getPrivate('/options/mmp', params);
}

/**
* Reset MMP (Market Maker Protection) settings
*
* @param params Parameters for resetting MMP settings
* @returns Promise<OptionsMMPSettings>
*/
resetOptionsMMPSettings(params: {
underlying: string;
}): Promise<OptionsMMPSettings> {
return this.postPrivate('/options/mmp/reset', { body: params });
}

/**==========================================================================================================================
* EARN UNI
* ==========================================================================================================================
Expand Down
8 changes: 8 additions & 0 deletions src/types/request/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,11 @@ export interface GetOptionsPersonalHistoryReq {
from?: number;
to?: number;
}

export interface OptionsMMPSettingsReq {
underlying: string;
window: number; // Time window in milliseconds, between 1-5000, 0 to disable MMP
frozen_period: number; // Frozen period in milliseconds, 0 to freeze indefinitely until reset API is called
qty_limit: string; // Maximum transaction volume (positive number, up to 2 decimal places)
delta_limit: string; // Maximum net delta value (positive number, up to 2 decimal places)
}
4 changes: 4 additions & 0 deletions src/types/request/unified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export interface GetUnifiedInterestRecordsReq {
currency?: string;
page?: number;
limit?: number;
from?: number;
to?: number;
type?: 'platform' | 'margin';
}

Expand All @@ -31,6 +33,8 @@ export interface SetUnifiedAccountModeReq {
settings?: {
usdt_futures?: boolean;
spot_hedge?: boolean;
use_funding?: boolean;
options?: boolean;
};
}

Expand Down
10 changes: 10 additions & 0 deletions src/types/response/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,13 @@ export interface OptionsUserHistoryRecord {
underlying_price: string;
role: 'taker' | 'maker';
}

export interface OptionsMMPSettings {
underlying: string;
window: number;
frozen_period: number;
qty_limit: string;
delta_limit: string;
trigger_time_ms: number; // Trigger freeze time in milliseconds, 0 means no freeze triggered
frozen_until_ms: number; // Unfreeze time in milliseconds, if no frozen period is configured, no unfreeze time after freeze is triggered
}
1 change: 1 addition & 0 deletions src/types/response/withdrawal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface WithdrawalRecord {
id: string;
txid: string;
block_number: string;
withdraw_order_id: string;
timestamp: string;
amount: string;
Expand Down

0 comments on commit 73a471f

Please sign in to comment.