@yuants/vendor-gate 0.4.18 → 0.4.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { encodeHex, formatTime, HmacSHA512, sha512 } from '@yuants/utils';
2
- const BASE_URL = 'https://api.gateio.ws';
2
+ import { join } from 'path';
3
+ const BASE_URL = 'https://api.gateio.ws/api/v4';
3
4
  const serializeQueryParams = (params) => {
4
5
  if (!params)
5
6
  return undefined;
@@ -11,7 +12,7 @@ const serializeQueryParams = (params) => {
11
12
  };
12
13
  const createRequestArtifacts = (method, path, params) => {
13
14
  const url = new URL(BASE_URL);
14
- url.pathname = path;
15
+ url.pathname = join(url.pathname, path);
15
16
  const searchParams = serializeQueryParams(params);
16
17
  if (method === 'GET' && searchParams) {
17
18
  Object.entries(searchParams).forEach(([key, value]) => url.searchParams.set(key, value));
@@ -36,7 +37,7 @@ const parseJSON = async (response, path, params) => {
36
37
  return JSON.parse(text);
37
38
  }
38
39
  catch (error) {
39
- console.error(formatTime(Date.now()), 'GateRequestFailed', path, JSON.stringify(params !== null && params !== void 0 ? params : {}), text, {
40
+ console.info(formatTime(Date.now()), 'GateRequestFailed', path, JSON.stringify(params !== null && params !== void 0 ? params : {}), text, {
40
41
  status: response.status,
41
42
  headers: toHeaderObject(response.headers),
42
43
  });
@@ -1 +1 @@
1
- {"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/api/http-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE1E,MAAM,QAAQ,GAAG,uBAAuB,CAAC;AAgBzC,MAAM,oBAAoB,GAAG,CAAC,MAAmB,EAAsC,EAAE;IACvF,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MA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B;QAClC,GAAG,EAAE,UAAU,CAAC,UAAU;QAC1B,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,GAAG,SAAS,EAAE;KAC1B,CAAC;IAEF,kCAAkC;IAClC,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE;QAC1B,OAAO,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;KACvD;IAED,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;IAEtF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE;QACrC,MAAM;QACN,OAAO;QACP,IAAI,EAAE,IAAI,IAAI,SAAS;KACxB,CAAC,CAAC;IACH,OAAO,SAAS,CAAY,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC,CAAC","sourcesContent":["import { encodeHex, formatTime, HmacSHA512, sha512 } from '@yuants/utils';\n\nconst BASE_URL = 'https://api.gateio.ws';\n\nexport type HttpMethod = 'GET' | 'POST' | 'DELETE' | 'PUT';\n\nexport type GateParams = Record<string, string | number | boolean | undefined>;\n\nexport interface IGateCredential {\n access_key: string;\n secret_key: string;\n}\n\ninterface IRequestArtifacts {\n url: URL;\n body: string;\n}\n\nconst serializeQueryParams = (params?: GateParams): Record<string, string> | undefined => {\n if (!params) return undefined;\n const normalizedEntries = Object.entries(params).filter(([, value]) => value !== undefined);\n if (normalizedEntries.length === 0) {\n return undefined;\n }\n return Object.fromEntries(normalizedEntries.map(([key, value]) => [key, `${value}`]));\n};\n\nconst createRequestArtifacts = (method: HttpMethod, path: string, params?: GateParams): IRequestArtifacts => {\n const url = new URL(BASE_URL);\n url.pathname = path;\n const searchParams = serializeQueryParams(params);\n if (method === 'GET' && searchParams) {\n Object.entries(searchParams).forEach(([key, value]) => url.searchParams.set(key, value));\n }\n const rawBody = method === 'GET' ? '' : JSON.stringify(params);\n const body = rawBody;\n return { url, body };\n};\n\nconst toHeaderObject = (headers: Headers): Record<string, string> => {\n const iterable = headers as unknown as Iterable<[string, string]>;\n return Object.fromEntries(Array.from(iterable));\n};\n\nconst parseJSON = async <TResponse>(\n response: Response,\n path: string,\n params?: GateParams,\n): Promise<TResponse> => {\n const text = await response.text();\n if (process.env.LOG_LEVEL === 'DEBUG') {\n console.debug(formatTime(Date.now()), 'GateResponse', path, JSON.stringify(params ?? {}), text, {\n status: response.status,\n headers: toHeaderObject(response.headers),\n });\n }\n try {\n return JSON.parse(text) as TResponse;\n } catch (error) {\n console.error(formatTime(Date.now()), 'GateRequestFailed', path, JSON.stringify(params ?? {}), text, {\n status: response.status,\n headers: toHeaderObject(response.headers),\n });\n throw error;\n }\n};\n\nexport const requestPublic = async <TResponse>(\n method: HttpMethod,\n path: string,\n params?: GateParams,\n): Promise<TResponse> => {\n const { url, body } = createRequestArtifacts(method, path, params);\n const headers: Record<string, string> = {\n Accept: 'application/json',\n };\n if (body) {\n headers['Content-Type'] = 'application/json';\n }\n console.info(formatTime(Date.now()), method, url.href);\n const response = await fetch(url.href, {\n method,\n headers,\n body: body || undefined,\n });\n return parseJSON<TResponse>(response, path, params);\n};\n\nexport const requestPrivate = async <TResponse>(\n credential: IGateCredential,\n method: HttpMethod,\n path: string,\n params?: GateParams,\n): Promise<TResponse> => {\n const { url, body } = createRequestArtifacts(method, path, params);\n const timestamp = Date.now() / 1000;\n\n const bodyDigest = encodeHex(await sha512(new TextEncoder().encode(body)));\n const signTarget = `${method}\\n${url.pathname}\\n${url.searchParams}\\n${bodyDigest}\\n${timestamp}`;\n const sign = encodeHex(\n await HmacSHA512(new TextEncoder().encode(signTarget), new TextEncoder().encode(credential.secret_key)),\n );\n\n const headers: Record<string, string> = {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n KEY: credential.access_key,\n SIGN: sign,\n Timestamp: `${timestamp}`,\n };\n\n // Add Channel ID header if exists\n if (process.env.CHANNEL_ID) {\n headers['X-Gate-Channel-Id'] = process.env.CHANNEL_ID;\n }\n\n console.info(formatTime(Date.now()), method, url.href, JSON.stringify(headers), body);\n\n const response = await fetch(url.href, {\n method,\n headers,\n body: body || undefined,\n });\n return parseJSON<TResponse>(response, path, params);\n};\n"]}
1
+ {"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/api/http-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,QAAQ,GAAG,8BAA8B,CAAC;AAgBhD,MAAM,oBAAoB,GAAG,CAAC,MAAmB,EAAsC,EAAE;IACvF,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IAC5F,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE;QAClC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AACxF,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,MAAkB,EAAE,IAAY,EAAE,MAAmB,EAAqB,EAAE;IAC1G,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAA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QACP,IAAI,EAAE,IAAI,IAAI,SAAS;KACxB,CAAC,CAAC;IACH,OAAO,SAAS,CAAY,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC,CAAC","sourcesContent":["import { encodeHex, formatTime, HmacSHA512, sha512 } from '@yuants/utils';\nimport { join } from 'path';\n\nconst BASE_URL = 'https://api.gateio.ws/api/v4';\n\nexport type HttpMethod = 'GET' | 'POST' | 'DELETE' | 'PUT';\n\nexport type GateParams = Record<string, string | number | boolean | undefined>;\n\nexport interface IGateCredential {\n access_key: string;\n secret_key: string;\n}\n\ninterface IRequestArtifacts {\n url: URL;\n body: string;\n}\n\nconst serializeQueryParams = (params?: GateParams): Record<string, string> | undefined => {\n if (!params) return undefined;\n const normalizedEntries = Object.entries(params).filter(([, value]) => value !== undefined);\n if (normalizedEntries.length === 0) {\n return undefined;\n }\n return Object.fromEntries(normalizedEntries.map(([key, value]) => [key, `${value}`]));\n};\n\nconst createRequestArtifacts = (method: HttpMethod, path: string, params?: GateParams): IRequestArtifacts => {\n const url = new URL(BASE_URL);\n url.pathname = join(url.pathname, path);\n const searchParams = serializeQueryParams(params);\n if (method === 'GET' && searchParams) {\n Object.entries(searchParams).forEach(([key, value]) => url.searchParams.set(key, value));\n }\n const rawBody = method === 'GET' ? '' : JSON.stringify(params);\n const body = rawBody;\n return { url, body };\n};\n\nconst toHeaderObject = (headers: Headers): Record<string, string> => {\n const iterable = headers as unknown as Iterable<[string, string]>;\n return Object.fromEntries(Array.from(iterable));\n};\n\nconst parseJSON = async <TResponse>(\n response: Response,\n path: string,\n params?: GateParams,\n): Promise<TResponse> => {\n const text = await response.text();\n if (process.env.LOG_LEVEL === 'DEBUG') {\n console.debug(formatTime(Date.now()), 'GateResponse', path, JSON.stringify(params ?? {}), text, {\n status: response.status,\n headers: toHeaderObject(response.headers),\n });\n }\n try {\n return JSON.parse(text) as TResponse;\n } catch (error) {\n console.info(formatTime(Date.now()), 'GateRequestFailed', path, JSON.stringify(params ?? {}), text, {\n status: response.status,\n headers: toHeaderObject(response.headers),\n });\n throw error;\n }\n};\n\nexport const requestPublic = async <TResponse>(\n method: HttpMethod,\n path: string,\n params?: GateParams,\n): Promise<TResponse> => {\n const { url, body } = createRequestArtifacts(method, path, params);\n const headers: Record<string, string> = {\n Accept: 'application/json',\n };\n if (body) {\n headers['Content-Type'] = 'application/json';\n }\n console.info(formatTime(Date.now()), method, url.href);\n const response = await fetch(url.href, {\n method,\n headers,\n body: body || undefined,\n });\n return parseJSON<TResponse>(response, path, params);\n};\n\nexport const requestPrivate = async <TResponse>(\n credential: IGateCredential,\n method: HttpMethod,\n path: string,\n params?: GateParams,\n): Promise<TResponse> => {\n const { url, body } = createRequestArtifacts(method, path, params);\n const timestamp = Date.now() / 1000;\n\n const bodyDigest = encodeHex(await sha512(new TextEncoder().encode(body)));\n const signTarget = `${method}\\n${url.pathname}\\n${url.searchParams}\\n${bodyDigest}\\n${timestamp}`;\n const sign = encodeHex(\n await HmacSHA512(new TextEncoder().encode(signTarget), new TextEncoder().encode(credential.secret_key)),\n );\n\n const headers: Record<string, string> = {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n KEY: credential.access_key,\n SIGN: sign,\n Timestamp: `${timestamp}`,\n };\n\n // Add Channel ID header if exists\n if (process.env.CHANNEL_ID) {\n headers['X-Gate-Channel-Id'] = process.env.CHANNEL_ID;\n }\n\n console.info(formatTime(Date.now()), method, url.href, JSON.stringify(headers), body);\n\n const response = await fetch(url.href, {\n method,\n headers,\n body: body || undefined,\n });\n return parseJSON<TResponse>(response, path, params);\n};\n"]}
@@ -5,26 +5,26 @@ const callPrivate = (credential, method, path, params) => requestPrivate(credent
5
5
  *
6
6
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AF
7
7
  */
8
- export const getAccountDetail = (credential) => callPrivate(credential, 'GET', '/api/v4/account/detail');
9
- export const getUnifiedAccounts = (credential, params) => callPrivate(credential, 'GET', '/api/v4/unified/accounts', params);
8
+ export const getAccountDetail = (credential) => callPrivate(credential, 'GET', '/account/detail');
9
+ export const getUnifiedAccounts = (credential, params) => callPrivate(credential, 'GET', '/unified/accounts', params);
10
10
  /**
11
11
  * 获取用户仓位列表
12
12
  *
13
13
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E4%BB%93%E4%BD%8D%E5%88%97%E8%A1%A8
14
14
  */
15
- export const getFuturePositions = (credential, quote_currency, params) => callPrivate(credential, 'GET', `/api/v4/futures/${quote_currency}/positions`, params);
15
+ export const getFuturePositions = (credential, quote_currency, params) => callPrivate(credential, 'GET', `/futures/${quote_currency}/positions`, params);
16
16
  /**
17
17
  * 查询合约订单列表
18
18
  *
19
19
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8
20
20
  */
21
- export const getFuturesOrders = (credential, settle, params) => callPrivate(credential, 'GET', `/api/v4/futures/${settle}/orders`, params);
21
+ export const getFuturesOrders = (credential, settle, params) => callPrivate(credential, 'GET', `/futures/${settle}/orders`, params);
22
22
  /**
23
23
  * 获取合约账号
24
24
  *
25
25
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%90%88%E7%BA%A6%E8%B4%A6%E5%8F%B7
26
26
  */
27
- export const getFuturesAccounts = (credential, settle) => callPrivate(credential, 'GET', `/api/v4/futures/${settle}/accounts`);
27
+ export const getFuturesAccounts = (credential, settle) => callPrivate(credential, 'GET', `/futures/${settle}/accounts`);
28
28
  /**
29
29
  * 合约交易下单
30
30
  *
@@ -42,13 +42,13 @@ export const getFuturesAccounts = (credential, settle) => callPrivate(credential
42
42
  *
43
43
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E4%B8%8B%E5%8D%95
44
44
  */
45
- export const postFutureOrders = (credential, settle, params) => callPrivate(credential, 'POST', `/api/v4/futures/${settle}/orders`, params);
45
+ export const postFutureOrders = (credential, settle, params) => callPrivate(credential, 'POST', `/futures/${settle}/orders`, params);
46
46
  /**
47
47
  * 撤销单个订单
48
48
  *
49
49
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%92%A4%E9%94%80%E5%8D%95%E4%B8%AA%E8%AE%A2%E5%8D%95-2
50
50
  */
51
- export const deleteFutureOrders = (credential, settle, order_id) => callPrivate(credential, 'DELETE', `/api/v4/futures/${settle}/orders/${order_id}`);
51
+ export const deleteFutureOrders = (credential, settle, order_id) => callPrivate(credential, 'DELETE', `/futures/${settle}/orders/${order_id}`);
52
52
  /**
53
53
  * 提现
54
54
  *
@@ -56,19 +56,19 @@ export const deleteFutureOrders = (credential, settle, order_id) => callPrivate(
56
56
  *
57
57
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%8F%90%E7%8E%B0
58
58
  */
59
- export const postWithdrawals = (credential, params) => callPrivate(credential, 'POST', '/api/v4/withdrawals', params);
59
+ export const postWithdrawals = (credential, params) => callPrivate(credential, 'POST', '/withdrawals', params);
60
60
  /**
61
61
  * 获取币种充值地址
62
62
  *
63
63
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80
64
64
  */
65
- export const getDepositAddress = (credential, params) => callPrivate(credential, 'GET', '/api/v4/wallet/deposit_address', params);
65
+ export const getDepositAddress = (credential, params) => callPrivate(credential, 'GET', '/wallet/deposit_address', params);
66
66
  /**
67
67
  * 创建新的子账户
68
68
  *
69
69
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%88%9B%E5%BB%BA%E6%96%B0%E7%9A%84%E5%AD%90%E8%B4%A6%E6%88%B7
70
70
  */
71
- export const getSubAccountList = (credential, params) => callPrivate(credential, 'GET', '/api/v4/sub_accounts', params);
71
+ export const getSubAccountList = (credential, params) => callPrivate(credential, 'GET', '/sub_accounts', params);
72
72
  /**
73
73
  * 获取充值记录
74
74
  *
@@ -76,7 +76,7 @@ export const getSubAccountList = (credential, params) => callPrivate(credential,
76
76
  *
77
77
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%85%85%E5%80%BC%E8%AE%B0%E5%BD%95
78
78
  */
79
- export const getDepositHistory = (credential, params) => callPrivate(credential, 'GET', '/api/v4/wallet/deposits', params);
79
+ export const getDepositHistory = (credential, params) => callPrivate(credential, 'GET', '/wallet/deposits', params);
80
80
  /**
81
81
  * 获取提现记录
82
82
  *
@@ -84,13 +84,13 @@ export const getDepositHistory = (credential, params) => callPrivate(credential,
84
84
  *
85
85
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80
86
86
  */
87
- export const getWithdrawalHistory = (credential, params) => callPrivate(credential, 'GET', '/api/v4/wallet/withdrawals', params);
87
+ export const getWithdrawalHistory = (credential, params) => callPrivate(credential, 'GET', '/wallet/withdrawals', params);
88
88
  /**
89
89
  * 获取现货交易账户列表
90
90
  *
91
91
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%8E%B0%E8%B4%A7%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E5%88%97%E8%A1%A8
92
92
  */
93
- export const getSpotAccounts = (credential, params) => callPrivate(credential, 'GET', '/api/v4/spot/accounts', params);
93
+ export const getSpotAccounts = (credential, params) => callPrivate(credential, 'GET', '/spot/accounts', params);
94
94
  /**
95
95
  * 交易账户互转
96
96
  *
@@ -98,11 +98,11 @@ export const getSpotAccounts = (credential, params) => callPrivate(credential, '
98
98
  *
99
99
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E4%BA%92%E8%BD%AC
100
100
  */
101
- export const postWalletTransfer = (credential, params) => callPrivate(credential, 'POST', '/api/v4/wallet/transfers', params);
101
+ export const postWalletTransfer = (credential, params) => callPrivate(credential, 'POST', '/wallet/transfers', params);
102
102
  /**
103
103
  * 获取统一账户最多可转出
104
104
  *
105
105
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E7%BB%9F%E4%B8%80%E8%B4%A6%E6%88%B7%E6%9C%80%E5%A4%9A%E5%8F%AF%E8%BD%AC%E5%87%BA
106
106
  */
107
- export const getUnifiedTransferable = (credential, params) => callPrivate(credential, 'GET', `/api/v4/unified/transferable`, params);
107
+ export const getUnifiedTransferable = (credential, params) => callPrivate(credential, 'GET', `/unified/transferable`, params);
108
108
  //# sourceMappingURL=private-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"private-api.js","sourceRoot":"","sources":["../../src/api/private-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI/C,MAAM,WAAW,GAAG,CAClB,UAAuB,EACvB,MAAkB,EAClB,IAAY,EACZ,MAAmB,EACnB,EAAE,CAAC,cAAc,CAAY,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEjE;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,UAAuB,EAStB,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,wBAAwB,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,UAAuB,EACvB,MAA8B,EAiC7B,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,0BAA0B,EAAE,MAAM,CAAC,CAAC;AAEzE;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,UAAuB,EACvB,cAAsB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M,CAAC,MAAM,iBAAiB,GAAG,CAC/B,UAAuB,EACvB,MAEC,EAYD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,sBAAsB,EAAE,MAAM,CAAC,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,UAAuB,EACvB,MAMC,EAcD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,yBAAyB,EAAE,MAAM,CAAC,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,UAAuB,EACvB,MAMC,EAcD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,4BAA4B,EAAE,MAAM,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,UAAuB,EACvB,MAEC,EAQD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,CAAC,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,UAAuB,EACvB,MAOC,EAGA,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,0BAA0B,EAAE,MAAM,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,UAAuB,EACvB,MAEC,EAIA,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,8BAA8B,EAAE,MAAM,CAAC,CAAC","sourcesContent":["import type { GateParams, HttpMethod, IGateCredential } from './http-client';\nimport { requestPrivate } from './http-client';\n\nexport type ICredential = IGateCredential;\n\nconst callPrivate = <TResponse>(\n credential: ICredential,\n method: HttpMethod,\n path: string,\n params?: GateParams,\n) => requestPrivate<TResponse>(credential, method, path, params);\n\n/**\n * 获取用户账户信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AF\n */\nexport const getAccountDetail = (\n credential: ICredential,\n): Promise<{\n user_id: number;\n ip_whitelist: string[];\n currency_pairs: string[];\n key: {\n mode: number;\n };\n tier: number;\n}> => callPrivate(credential, 'GET', '/api/v4/account/detail');\n\nexport const getUnifiedAccounts = (\n credential: ICredential,\n params?: { currency?: string },\n): Promise<{\n user_id: string;\n refresh_time: number;\n locket: boolean;\n balances: Record<\n string,\n {\n available: string;\n freeze: string;\n borrowed: string;\n negative_liab: string;\n futures_pos_liab: string;\n equity: string;\n total_freeze: string;\n total_liab: string;\n spot_in_use: string;\n }\n >;\n total: string;\n borrowed: string;\n total_initial_margin: string;\n total_margin_balance: string;\n total_maintenance_margin: string;\n total_initial_margin_rate: string;\n total_maintenance_margin_rate: string;\n total_avail_margin: string;\n unified_account_total: string;\n unified_account_total_liab: string;\n unified_account_total_equity: string;\n leverage: string;\n spot_order_loss: string;\n spot_hedge: boolean;\n}> => callPrivate(credential, 'GET', '/api/v4/unified/accounts', params);\n\n/**\n * 获取用户仓位列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E4%BB%93%E4%BD%8D%E5%88%97%E8%A1%A8\n */\nexport const getFuturePositions = (\n credential: ICredential,\n quote_currency: string,\n params?: { holding?: boolean; limit?: number; offset?: number },\n): Promise<\n {\n user: number;\n contract: string;\n size: number;\n leverage: string;\n risk_limit: string;\n leverage_max: string;\n maintenance_rate: string;\n value: string;\n margin: string;\n entry_price: string;\n mark_price: string;\n unrealised_pnl: string;\n realised_pnl: string;\n mode: string;\n }[]\n> => callPrivate(credential, 'GET', `/api/v4/futures/${quote_currency}/positions`, params);\n\n/**\n * 查询合约订单列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8\n */\nexport const getFuturesOrders = (\n credential: ICredential,\n settle: string,\n params: {\n contract?: string;\n status: string;\n limit?: number;\n offset?: number;\n last_id?: number;\n },\n): Promise<\n {\n id: string;\n contract: string;\n create_time: number;\n size: number;\n price: string;\n is_close: boolean;\n fill_price: string;\n left?: number;\n status?: string;\n text: string;\n }[]\n> => callPrivate(credential, 'GET', `/api/v4/futures/${settle}/orders`, params);\n\n/**\n * 获取合约账号\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%90%88%E7%BA%A6%E8%B4%A6%E5%8F%B7\n */\nexport const getFuturesAccounts = (\n credential: ICredential,\n settle: string,\n): Promise<{\n user: number;\n currency: string;\n total: string;\n unrealised_pnl: string;\n position_margin: string;\n order_margin: string;\n available: string;\n point: string;\n bonus: string;\n in_dual_mode: boolean;\n enable_evolved_classic: boolean;\n history: {\n dnw: string;\n pnl: string;\n fee: string;\n refr: string;\n fund: string;\n point_dnw: string;\n point_fee: string;\n point_refr: string;\n bonus_dnw: string;\n bonus_offset: string;\n };\n}> => callPrivate(credential, 'GET', `/api/v4/futures/${settle}/accounts`);\n\n/**\n * 合约交易下单\n *\n * 下单时指定的是合约张数 size ,而非币的数量,每一张合约对应的币的数量是合约详情接口里返回的 quanto_multiplier\n *\n * 0 成交的订单在撤单 10 分钟之后无法再获取到,会提到订单不存在\n *\n * 设置 reduce_only 为 true 可以防止在减仓的时候穿仓\n *\n * 单仓模式下,如果需要平仓,需要设置 size 为 0 ,close 为 true\n *\n * 双仓模式下,平仓需要使用 auto_size 来设置平仓方向,并同时设置 reduce_only 为 true,size 为 0\n *\n * 设置 stp_act 决定使用限制用户自成交的策略,详细用法参考body参数stp_act\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E4%B8%8B%E5%8D%95\n */\nexport const postFutureOrders = (\n credential: ICredential,\n settle: string,\n params: {\n contract: string;\n size: number;\n iceberg?: number;\n price?: string;\n close?: boolean;\n reduce_only?: boolean;\n tif?: string;\n text?: string;\n auto_size?: string;\n stp_act?: string;\n },\n): Promise<{\n label?: string;\n message?: string;\n detail?: string;\n id: number;\n user: number;\n contract: string;\n create_time: number;\n size: number;\n iceberg: number;\n left: number;\n price: string;\n fill_price: string;\n mkfr: string;\n tkfr: string;\n tif: string;\n refu: number;\n is_reduce_only: boolean;\n is_close: boolean;\n is_liq: boolean;\n text: string;\n status: string;\n finish_time: number;\n finish_as: string;\n stp_id: number;\n stp_act: string;\n amend_text: string;\n}> => callPrivate(credential, 'POST', `/api/v4/futures/${settle}/orders`, params);\n\n/**\n * 撤销单个订单\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%92%A4%E9%94%80%E5%8D%95%E4%B8%AA%E8%AE%A2%E5%8D%95-2\n */\nexport const deleteFutureOrders = (credential: ICredential, settle: string, order_id: string): Promise<{}> =>\n callPrivate(credential, 'DELETE', `/api/v4/futures/${settle}/orders/${order_id}`);\n\n/**\n * 提现\n *\n * POST /withdrawals\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%8F%90%E7%8E%B0\n */\nexport const postWithdrawals = (\n credential: ICredential,\n params: {\n withdraw_order_id?: string;\n amount: string;\n currency: string;\n address?: string;\n memo?: string;\n chain: string;\n },\n): Promise<{\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n}> => callPrivate(credential, 'POST', '/api/v4/withdrawals', params);\n\n/**\n * 获取币种充值地址\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80\n */\nexport const getDepositAddress = (\n credential: ICredential,\n params: {\n currency: string;\n },\n): Promise<{\n currency: string;\n address: string;\n multichain_addresses: {\n chain: string;\n address: string;\n payment_id: string;\n payment_name: string;\n obtain_failed: boolean;\n }[];\n}> => callPrivate(credential, 'GET', '/api/v4/wallet/deposit_address', params);\n\n/**\n * 创建新的子账户\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%88%9B%E5%BB%BA%E6%96%B0%E7%9A%84%E5%AD%90%E8%B4%A6%E6%88%B7\n */\nexport const getSubAccountList = (\n credential: ICredential,\n params?: {\n type?: string;\n },\n): Promise<\n {\n remark: string;\n login_name: string;\n password: string;\n email: string;\n state: number;\n type: number;\n user_id: number;\n create_time: number;\n }[]\n> => callPrivate(credential, 'GET', '/api/v4/sub_accounts', params);\n\n/**\n * 获取充值记录\n *\n * 记录查询时间范围不允许超过 30 天\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%85%85%E5%80%BC%E8%AE%B0%E5%BD%95\n */\nexport const getDepositHistory = (\n credential: ICredential,\n params?: {\n currency?: string;\n from?: number;\n to?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<\n {\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n }[]\n> => callPrivate(credential, 'GET', '/api/v4/wallet/deposits', params);\n\n/**\n * 获取提现记录\n *\n * 记录查询时间范围不允许超过 30 天\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80\n */\nexport const getWithdrawalHistory = (\n credential: ICredential,\n params?: {\n currency?: string;\n from?: number;\n to?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<\n {\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n }[]\n> => callPrivate(credential, 'GET', '/api/v4/wallet/withdrawals', params);\n\n/**\n * 获取现货交易账户列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%8E%B0%E8%B4%A7%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E5%88%97%E8%A1%A8\n */\nexport const getSpotAccounts = (\n credential: ICredential,\n params?: {\n currency?: string;\n },\n): Promise<\n {\n currency: string;\n available: string;\n locked: string;\n update_id: string;\n }[]\n> => callPrivate(credential, 'GET', '/api/v4/spot/accounts', params);\n\n/**\n * 交易账户互转\n *\n * POST /wallet/transfers\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E4%BA%92%E8%BD%AC\n */\nexport const postWalletTransfer = (\n credential: ICredential,\n params: {\n currency: string;\n from: string;\n to: string;\n amount: string;\n currency_pair?: string;\n settle?: string;\n },\n): Promise<{\n tx_id: string;\n}> => callPrivate(credential, 'POST', '/api/v4/wallet/transfers', params);\n\n/**\n * 获取统一账户最多可转出\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E7%BB%9F%E4%B8%80%E8%B4%A6%E6%88%B7%E6%9C%80%E5%A4%9A%E5%8F%AF%E8%BD%AC%E5%87%BA\n */\nexport const getUnifiedTransferable = (\n credential: ICredential,\n params: {\n currency: string;\n },\n): Promise<{\n currency: string;\n amount: string;\n}> => callPrivate(credential, 'GET', `/api/v4/unified/transferable`, params);\n"]}
1
+ {"version":3,"file":"private-api.js","sourceRoot":"","sources":["../../src/api/private-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI/C,MAAM,WAAW,GAAG,CAClB,UAAuB,EACvB,MAAkB,EAClB,IAAY,EACZ,MAAmB,EACnB,EAAE,CAAC,cAAc,CAAY,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEjE;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,UAAuB,EAStB,EA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AAuB,EAAE,MAAM,CAAC,CAAC","sourcesContent":["import type { GateParams, HttpMethod, IGateCredential } from './http-client';\nimport { requestPrivate } from './http-client';\n\nexport type ICredential = IGateCredential;\n\nconst callPrivate = <TResponse>(\n credential: ICredential,\n method: HttpMethod,\n path: string,\n params?: GateParams,\n) => requestPrivate<TResponse>(credential, method, path, params);\n\n/**\n * 获取用户账户信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AF\n */\nexport const getAccountDetail = (\n credential: ICredential,\n): Promise<{\n user_id: number;\n ip_whitelist: string[];\n currency_pairs: string[];\n key: {\n mode: number;\n };\n tier: number;\n}> => callPrivate(credential, 'GET', '/account/detail');\n\nexport const getUnifiedAccounts = (\n credential: ICredential,\n params?: { currency?: string },\n): Promise<{\n user_id: string;\n refresh_time: number;\n locket: boolean;\n balances: Record<\n string,\n {\n available: string;\n freeze: string;\n borrowed: string;\n negative_liab: string;\n futures_pos_liab: string;\n equity: string;\n total_freeze: string;\n total_liab: string;\n spot_in_use: string;\n }\n >;\n total: string;\n borrowed: string;\n total_initial_margin: string;\n total_margin_balance: string;\n total_maintenance_margin: string;\n total_initial_margin_rate: string;\n total_maintenance_margin_rate: string;\n total_avail_margin: string;\n unified_account_total: string;\n unified_account_total_liab: string;\n unified_account_total_equity: string;\n leverage: string;\n spot_order_loss: string;\n spot_hedge: boolean;\n}> => callPrivate(credential, 'GET', '/unified/accounts', params);\n\n/**\n * 获取用户仓位列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E4%BB%93%E4%BD%8D%E5%88%97%E8%A1%A8\n */\nexport const getFuturePositions = (\n credential: ICredential,\n quote_currency: string,\n params?: { holding?: boolean; limit?: number; offset?: number },\n): Promise<\n {\n user: number;\n contract: string;\n size: number;\n leverage: string;\n risk_limit: string;\n leverage_max: string;\n maintenance_rate: string;\n value: string;\n margin: string;\n entry_price: string;\n mark_price: string;\n unrealised_pnl: string;\n realised_pnl: string;\n mode: string;\n }[]\n> => callPrivate(credential, 'GET', `/futures/${quote_currency}/positions`, params);\n\n/**\n * 查询合约订单列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8\n */\nexport const getFuturesOrders = (\n credential: ICredential,\n settle: string,\n params: {\n contract?: string;\n status: string;\n limit?: number;\n offset?: number;\n last_id?: number;\n },\n): Promise<\n {\n id: string;\n contract: string;\n create_time: number;\n size: number;\n price: string;\n is_close: boolean;\n fill_price: string;\n left?: number;\n status?: string;\n text: string;\n }[]\n> => callPrivate(credential, 'GET', `/futures/${settle}/orders`, params);\n\n/**\n * 获取合约账号\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%90%88%E7%BA%A6%E8%B4%A6%E5%8F%B7\n */\nexport const getFuturesAccounts = (\n credential: ICredential,\n settle: string,\n): Promise<{\n user: number;\n currency: string;\n total: string;\n unrealised_pnl: string;\n position_margin: string;\n order_margin: string;\n available: string;\n point: string;\n bonus: string;\n in_dual_mode: boolean;\n enable_evolved_classic: boolean;\n history: {\n dnw: string;\n pnl: string;\n fee: string;\n refr: string;\n fund: string;\n point_dnw: string;\n point_fee: string;\n point_refr: string;\n bonus_dnw: string;\n bonus_offset: string;\n };\n}> => callPrivate(credential, 'GET', `/futures/${settle}/accounts`);\n\n/**\n * 合约交易下单\n *\n * 下单时指定的是合约张数 size ,而非币的数量,每一张合约对应的币的数量是合约详情接口里返回的 quanto_multiplier\n *\n * 0 成交的订单在撤单 10 分钟之后无法再获取到,会提到订单不存在\n *\n * 设置 reduce_only 为 true 可以防止在减仓的时候穿仓\n *\n * 单仓模式下,如果需要平仓,需要设置 size 为 0 ,close 为 true\n *\n * 双仓模式下,平仓需要使用 auto_size 来设置平仓方向,并同时设置 reduce_only 为 true,size 为 0\n *\n * 设置 stp_act 决定使用限制用户自成交的策略,详细用法参考body参数stp_act\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E4%B8%8B%E5%8D%95\n */\nexport const postFutureOrders = (\n credential: ICredential,\n settle: string,\n params: {\n contract: string;\n size: number;\n iceberg?: number;\n price?: string;\n close?: boolean;\n reduce_only?: boolean;\n tif?: string;\n text?: string;\n auto_size?: string;\n stp_act?: string;\n },\n): Promise<{\n label?: string;\n message?: string;\n detail?: string;\n id: number;\n user: number;\n contract: string;\n create_time: number;\n size: number;\n iceberg: number;\n left: number;\n price: string;\n fill_price: string;\n mkfr: string;\n tkfr: string;\n tif: string;\n refu: number;\n is_reduce_only: boolean;\n is_close: boolean;\n is_liq: boolean;\n text: string;\n status: string;\n finish_time: number;\n finish_as: string;\n stp_id: number;\n stp_act: string;\n amend_text: string;\n}> => callPrivate(credential, 'POST', `/futures/${settle}/orders`, params);\n\n/**\n * 撤销单个订单\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%92%A4%E9%94%80%E5%8D%95%E4%B8%AA%E8%AE%A2%E5%8D%95-2\n */\nexport const deleteFutureOrders = (credential: ICredential, settle: string, order_id: string): Promise<{}> =>\n callPrivate(credential, 'DELETE', `/futures/${settle}/orders/${order_id}`);\n\n/**\n * 提现\n *\n * POST /withdrawals\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%8F%90%E7%8E%B0\n */\nexport const postWithdrawals = (\n credential: ICredential,\n params: {\n withdraw_order_id?: string;\n amount: string;\n currency: string;\n address?: string;\n memo?: string;\n chain: string;\n },\n): Promise<{\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n}> => callPrivate(credential, 'POST', '/withdrawals', params);\n\n/**\n * 获取币种充值地址\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80\n */\nexport const getDepositAddress = (\n credential: ICredential,\n params: {\n currency: string;\n },\n): Promise<{\n currency: string;\n address: string;\n multichain_addresses: {\n chain: string;\n address: string;\n payment_id: string;\n payment_name: string;\n obtain_failed: boolean;\n }[];\n}> => callPrivate(credential, 'GET', '/wallet/deposit_address', params);\n\n/**\n * 创建新的子账户\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%88%9B%E5%BB%BA%E6%96%B0%E7%9A%84%E5%AD%90%E8%B4%A6%E6%88%B7\n */\nexport const getSubAccountList = (\n credential: ICredential,\n params?: {\n type?: string;\n },\n): Promise<\n {\n remark: string;\n login_name: string;\n password: string;\n email: string;\n state: number;\n type: number;\n user_id: number;\n create_time: number;\n }[]\n> => callPrivate(credential, 'GET', '/sub_accounts', params);\n\n/**\n * 获取充值记录\n *\n * 记录查询时间范围不允许超过 30 天\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%85%85%E5%80%BC%E8%AE%B0%E5%BD%95\n */\nexport const getDepositHistory = (\n credential: ICredential,\n params?: {\n currency?: string;\n from?: number;\n to?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<\n {\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n }[]\n> => callPrivate(credential, 'GET', '/wallet/deposits', params);\n\n/**\n * 获取提现记录\n *\n * 记录查询时间范围不允许超过 30 天\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80\n */\nexport const getWithdrawalHistory = (\n credential: ICredential,\n params?: {\n currency?: string;\n from?: number;\n to?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<\n {\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n }[]\n> => callPrivate(credential, 'GET', '/wallet/withdrawals', params);\n\n/**\n * 获取现货交易账户列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%8E%B0%E8%B4%A7%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E5%88%97%E8%A1%A8\n */\nexport const getSpotAccounts = (\n credential: ICredential,\n params?: {\n currency?: string;\n },\n): Promise<\n {\n currency: string;\n available: string;\n locked: string;\n update_id: string;\n }[]\n> => callPrivate(credential, 'GET', '/spot/accounts', params);\n\n/**\n * 交易账户互转\n *\n * POST /wallet/transfers\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E4%BA%92%E8%BD%AC\n */\nexport const postWalletTransfer = (\n credential: ICredential,\n params: {\n currency: string;\n from: string;\n to: string;\n amount: string;\n currency_pair?: string;\n settle?: string;\n },\n): Promise<{\n tx_id: string;\n}> => callPrivate(credential, 'POST', '/wallet/transfers', params);\n\n/**\n * 获取统一账户最多可转出\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E7%BB%9F%E4%B8%80%E8%B4%A6%E6%88%B7%E6%9C%80%E5%A4%9A%E5%8F%AF%E8%BD%AC%E5%87%BA\n */\nexport const getUnifiedTransferable = (\n credential: ICredential,\n params: {\n currency: string;\n },\n): Promise<{\n currency: string;\n amount: string;\n}> => callPrivate(credential, 'GET', `/unified/transferable`, params);\n"]}
@@ -5,7 +5,7 @@ import { requestPublic } from './http-client';
5
5
  *
6
6
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E6%89%80%E6%9C%89%E7%9A%84%E5%90%88%E7%BA%A6%E4%BF%A1%E6%81%AF
7
7
  */
8
- export const getFuturesContracts = (settle, params) => requestPublic('GET', `/api/v4/futures/${settle}/contracts`, params);
8
+ export const getFuturesContracts = (settle, params) => requestPublic('GET', `/futures/${settle}/contracts`, params);
9
9
  /**
10
10
  * 合约市场历史资金费率
11
11
  *
@@ -15,25 +15,25 @@ export const getFuturesContracts = (settle, params) => requestPublic('GET', `/ap
15
15
  *
16
16
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E5%B8%82%E5%9C%BA%E5%8E%86%E5%8F%B2%E8%B5%84%E9%87%91%E8%B4%B9%E7%8E%87
17
17
  */
18
- export const getFutureFundingRate = (settle, params) => requestPublic('GET', `/api/v4/futures/${settle}/funding_rate`, params);
18
+ export const getFutureFundingRate = (settle, params) => requestPublic('GET', `/futures/${settle}/funding_rate`, params);
19
19
  /**
20
20
  * 查询合约市场深度信息
21
21
  *
22
22
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E5%B8%82%E5%9C%BA%E6%B7%B1%E5%BA%A6%E4%BF%A1%E6%81%AF
23
23
  */
24
- export const getFuturesOrderBook = async (settle, params) => rateLimiter.schedule(`futures-order-book:${settle}`, 200, 10000, () => requestPublic('GET', `/api/v4/futures/${settle}/order_book`, params));
24
+ export const getFuturesOrderBook = async (settle, params) => rateLimiter.schedule(`futures-order-book:${settle}`, 200, 10000, () => requestPublic('GET', `/futures/${settle}/order_book`, params));
25
25
  /**
26
26
  * 获取所有合约交易行情统计
27
27
  *
28
28
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E6%89%80%E6%9C%89%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E8%A1%8C%E6%83%85%E7%BB%9F%E8%AE%A1
29
29
  */
30
- export const getFuturesTickers = (settle, params) => requestPublic('GET', `/api/v4/futures/${settle}/tickers`, params);
30
+ export const getFuturesTickers = (settle, params) => requestPublic('GET', `/futures/${settle}/tickers`, params);
31
31
  /**
32
32
  * 获取交易对 ticker 信息
33
33
  *
34
34
  * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E4%BA%A4%E6%98%93%E5%AF%B9-ticker-%E4%BF%A1%E6%81%AF
35
35
  */
36
- export const getSpotTickers = (params) => requestPublic('GET', `/api/v4/spot/tickers`, params);
36
+ export const getSpotTickers = (params) => requestPublic('GET', `/spot/tickers`, params);
37
37
  /**
38
38
  * 查询支持的所有现货交易对
39
39
  * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E6%94%AF%E6%8C%81%E7%9A%84%E6%89%80%E6%9C%89%E4%BA%A4%E6%98%93%E5%AF%B9
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../../src/api/public-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,MAAc,EACd,MAA4C,EA8C5C,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,mBAAmB,MAAM,YAAY,EAAE,MAAM,CAAC,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,MAAc,EACd,MAA4C,EAM5C,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,mBAAmB,MAAM,eAAe,EAAE,MAAM,CAAC,CAAC;AAE5E;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EACtC,MAAc,EACd,MAKC,EAaA,EAAE,CACH,WAAW,CAAC,QAAQ,CAAC,sBAAsB,MAAM,EAAE,EAAE,GAAG,EAAE,KAAM,EAAE,GAAG,EAAE,CACrE,aAAa,CAAC,KAAK,EAAE,mBAAmB,MAAM,aAAa,EAAE,MAAM,CAAC,CACrE,CAAC;AAEJ;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,MAAc,EACd,MAA8B,EAyB9B,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,mBAAmB,MAAM,UAAU,EAAE,MAAM,CAAC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAG9B,EAoBC,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,sBAAsB,EAAE,MAAM,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAqBlC,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import { rateLimiter } from './rate-limiter';\nimport { requestPublic } from './http-client';\n\n/**\n * 查询所有的合约信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E6%89%80%E6%9C%89%E7%9A%84%E5%90%88%E7%BA%A6%E4%BF%A1%E6%81%AF\n */\nexport const getFuturesContracts = (\n settle: string,\n params?: { limit?: number; offset?: number },\n): Promise<\n {\n name: string;\n type: string;\n quanto_multiplier: string;\n ref_discount_rate: string;\n order_price_deviate: string;\n maintenance_rate: string;\n mark_type: string;\n last_price: string;\n mark_price: string;\n index_price: string;\n funding_rate_indicative: string;\n mark_price_round: string;\n funding_offset: number;\n in_delisting: boolean;\n risk_limit_base: string;\n interest_rate: string;\n order_price_round: string;\n order_size_min: number;\n ref_rebate_rate: string;\n funding_interval: number;\n risk_limit_step: string;\n leverage_min: string;\n leverage_max: string;\n risk_limit_max: string;\n maker_fee_rate: string;\n taker_fee_rate: string;\n funding_rate: string;\n order_size_max: number;\n funding_next_apply: number;\n short_users: number;\n config_change_time: number;\n trade_size: number;\n position_size: number;\n long_users: number;\n funding_impact_value: string;\n orders_limit: number;\n trade_id: number;\n orderbook_id: number;\n enable_bonus: boolean;\n enable_credit: boolean;\n create_time: number;\n funding_cap_ratio: string;\n }[]\n> => requestPublic('GET', `/api/v4/futures/${settle}/contracts`, params);\n\n/**\n * 合约市场历史资金费率\n *\n * - Note: 该接口返回的数据是按照时间倒序排列的\n * - Note: limit 参数最大值为 1000\n * - Note: t 字段为秒级时间戳 (Unix Second),r 字段为资金费率 (0-1 单位)\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E5%B8%82%E5%9C%BA%E5%8E%86%E5%8F%B2%E8%B5%84%E9%87%91%E8%B4%B9%E7%8E%87\n */\nexport const getFutureFundingRate = (\n settle: string,\n params: { contract: string; limit?: number },\n): Promise<\n {\n t: number;\n r: string;\n }[]\n> => requestPublic('GET', `/api/v4/futures/${settle}/funding_rate`, params);\n\n/**\n * 查询合约市场深度信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E5%B8%82%E5%9C%BA%E6%B7%B1%E5%BA%A6%E4%BF%A1%E6%81%AF\n */\nexport const getFuturesOrderBook = async (\n settle: string,\n params: {\n contract: string;\n interval?: string;\n limit?: number;\n with_id?: boolean;\n },\n): Promise<{\n id: number;\n current: number;\n update: number;\n asks: {\n p: string;\n s: string;\n }[];\n bids: {\n p: string;\n s: string;\n }[];\n}> =>\n rateLimiter.schedule(`futures-order-book:${settle}`, 200, 10_000, () =>\n requestPublic('GET', `/api/v4/futures/${settle}/order_book`, params),\n );\n\n/**\n * 获取所有合约交易行情统计\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E6%89%80%E6%9C%89%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E8%A1%8C%E6%83%85%E7%BB%9F%E8%AE%A1\n */\nexport const getFuturesTickers = (\n settle: string,\n params?: { contract?: string },\n): Promise<\n {\n contract: string;\n last: string;\n change_percentage: string;\n total_size: string;\n low_24h: string;\n high_24h: string;\n volume_24h: string;\n volume_24h_btc: string;\n volume_24h_usd: string;\n volume_24h_base: string;\n volume_24h_quote: string;\n volume_24h_settle: string;\n mark_price: string;\n funding_rate: string;\n funding_rate_indicative: string;\n index_price: string;\n quanto_base_rate: string;\n basis_rate: string;\n basis_value: string;\n lowest_ask: string;\n highest_bid: string;\n }[]\n> => requestPublic('GET', `/api/v4/futures/${settle}/tickers`, params);\n\n/**\n * 获取交易对 ticker 信息\n *\n * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E4%BA%A4%E6%98%93%E5%AF%B9-ticker-%E4%BF%A1%E6%81%AF\n */\nexport const getSpotTickers = (params: {\n currency_pair?: string;\n timezone?: string;\n}): Promise<\n Array<{\n currency_pair: string;\n last: string;\n lowest_ask: string;\n lowest_size: string;\n highest_bid: string;\n highest_size: string;\n change_percentage: string;\n change_utc0: string;\n change_utc8: string;\n base_volume: string;\n quote_volume: string;\n high_24h: string;\n low_24h: string;\n etf_net_value: string;\n etf_pre_net_value: string;\n etf_pre_timestamp: string;\n etf_leverage: string;\n }>\n> => requestPublic('GET', `/api/v4/spot/tickers`, params);\n\n/**\n * 查询支持的所有现货交易对\n * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E6%94%AF%E6%8C%81%E7%9A%84%E6%89%80%E6%9C%89%E4%BA%A4%E6%98%93%E5%AF%B9\n */\nexport const getSpotCurrencyPairs = (): Promise<\n Array<{\n id: string;\n base: string;\n base_name: string;\n quote: string;\n quote_name: string;\n fee: string;\n min_base_amount: string;\n min_quote_amount: string;\n max_base_amount: string;\n max_quote_amount: string;\n amount_precision: Number;\n precision: Number;\n trade_status: string;\n sell_start: Number;\n buy_start: number;\n delisting_time: number;\n trade_url: string;\n st_tag: boolean;\n }>\n> => requestPublic('GET', `/spot/currency_pairs`);\n"]}
1
+ {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../../src/api/public-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,MAAc,EACd,MAA4C,EA8C5C,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,MAAM,YAAY,EAAE,MAAM,CAAC,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,MAAc,EACd,MAA4C,EAM5C,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,MAAM,eAAe,EAAE,MAAM,CAAC,CAAC;AAErE;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EACtC,MAAc,EACd,MAKC,EAaA,EAAE,CACH,WAAW,CAAC,QAAQ,CAAC,sBAAsB,MAAM,EAAE,EAAE,GAAG,EAAE,KAAM,EAAE,GAAG,EAAE,CACrE,aAAa,CAAC,KAAK,EAAE,YAAY,MAAM,aAAa,EAAE,MAAM,CAAC,CAC9D,CAAC;AAEJ;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,MAAc,EACd,MAA8B,EAyB9B,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,MAAM,UAAU,EAAE,MAAM,CAAC,CAAC;AAEhE;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAG9B,EAoBC,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAqBlC,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import { rateLimiter } from './rate-limiter';\nimport { requestPublic } from './http-client';\n\n/**\n * 查询所有的合约信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E6%89%80%E6%9C%89%E7%9A%84%E5%90%88%E7%BA%A6%E4%BF%A1%E6%81%AF\n */\nexport const getFuturesContracts = (\n settle: string,\n params?: { limit?: number; offset?: number },\n): Promise<\n {\n name: string;\n type: string;\n quanto_multiplier: string;\n ref_discount_rate: string;\n order_price_deviate: string;\n maintenance_rate: string;\n mark_type: string;\n last_price: string;\n mark_price: string;\n index_price: string;\n funding_rate_indicative: string;\n mark_price_round: string;\n funding_offset: number;\n in_delisting: boolean;\n risk_limit_base: string;\n interest_rate: string;\n order_price_round: string;\n order_size_min: number;\n ref_rebate_rate: string;\n funding_interval: number;\n risk_limit_step: string;\n leverage_min: string;\n leverage_max: string;\n risk_limit_max: string;\n maker_fee_rate: string;\n taker_fee_rate: string;\n funding_rate: string;\n order_size_max: number;\n funding_next_apply: number;\n short_users: number;\n config_change_time: number;\n trade_size: number;\n position_size: number;\n long_users: number;\n funding_impact_value: string;\n orders_limit: number;\n trade_id: number;\n orderbook_id: number;\n enable_bonus: boolean;\n enable_credit: boolean;\n create_time: number;\n funding_cap_ratio: string;\n }[]\n> => requestPublic('GET', `/futures/${settle}/contracts`, params);\n\n/**\n * 合约市场历史资金费率\n *\n * - Note: 该接口返回的数据是按照时间倒序排列的\n * - Note: limit 参数最大值为 1000\n * - Note: t 字段为秒级时间戳 (Unix Second),r 字段为资金费率 (0-1 单位)\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E5%B8%82%E5%9C%BA%E5%8E%86%E5%8F%B2%E8%B5%84%E9%87%91%E8%B4%B9%E7%8E%87\n */\nexport const getFutureFundingRate = (\n settle: string,\n params: { contract: string; limit?: number },\n): Promise<\n {\n t: number;\n r: string;\n }[]\n> => requestPublic('GET', `/futures/${settle}/funding_rate`, params);\n\n/**\n * 查询合约市场深度信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E5%B8%82%E5%9C%BA%E6%B7%B1%E5%BA%A6%E4%BF%A1%E6%81%AF\n */\nexport const getFuturesOrderBook = async (\n settle: string,\n params: {\n contract: string;\n interval?: string;\n limit?: number;\n with_id?: boolean;\n },\n): Promise<{\n id: number;\n current: number;\n update: number;\n asks: {\n p: string;\n s: string;\n }[];\n bids: {\n p: string;\n s: string;\n }[];\n}> =>\n rateLimiter.schedule(`futures-order-book:${settle}`, 200, 10_000, () =>\n requestPublic('GET', `/futures/${settle}/order_book`, params),\n );\n\n/**\n * 获取所有合约交易行情统计\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E6%89%80%E6%9C%89%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E8%A1%8C%E6%83%85%E7%BB%9F%E8%AE%A1\n */\nexport const getFuturesTickers = (\n settle: string,\n params?: { contract?: string },\n): Promise<\n {\n contract: string;\n last: string;\n change_percentage: string;\n total_size: string;\n low_24h: string;\n high_24h: string;\n volume_24h: string;\n volume_24h_btc: string;\n volume_24h_usd: string;\n volume_24h_base: string;\n volume_24h_quote: string;\n volume_24h_settle: string;\n mark_price: string;\n funding_rate: string;\n funding_rate_indicative: string;\n index_price: string;\n quanto_base_rate: string;\n basis_rate: string;\n basis_value: string;\n lowest_ask: string;\n highest_bid: string;\n }[]\n> => requestPublic('GET', `/futures/${settle}/tickers`, params);\n\n/**\n * 获取交易对 ticker 信息\n *\n * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E4%BA%A4%E6%98%93%E5%AF%B9-ticker-%E4%BF%A1%E6%81%AF\n */\nexport const getSpotTickers = (params: {\n currency_pair?: string;\n timezone?: string;\n}): Promise<\n Array<{\n currency_pair: string;\n last: string;\n lowest_ask: string;\n lowest_size: string;\n highest_bid: string;\n highest_size: string;\n change_percentage: string;\n change_utc0: string;\n change_utc8: string;\n base_volume: string;\n quote_volume: string;\n high_24h: string;\n low_24h: string;\n etf_net_value: string;\n etf_pre_net_value: string;\n etf_pre_timestamp: string;\n etf_leverage: string;\n }>\n> => requestPublic('GET', `/spot/tickers`, params);\n\n/**\n * 查询支持的所有现货交易对\n * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E6%94%AF%E6%8C%81%E7%9A%84%E6%89%80%E6%9C%89%E4%BA%A4%E6%98%93%E5%AF%B9\n */\nexport const getSpotCurrencyPairs = (): Promise<\n Array<{\n id: string;\n base: string;\n base_name: string;\n quote: string;\n quote_name: string;\n fee: string;\n min_base_amount: string;\n min_quote_amount: string;\n max_base_amount: string;\n max_quote_amount: string;\n amount_precision: Number;\n precision: Number;\n trade_status: string;\n sell_start: Number;\n buy_start: number;\n delisting_time: number;\n trade_url: string;\n st_tag: boolean;\n }>\n> => requestPublic('GET', `/spot/currency_pairs`);\n"]}
@@ -1,8 +1,8 @@
1
- import { createProductCache } from '@yuants/data-product';
1
+ import { createClientProductCache } from '@yuants/data-product';
2
2
  import { Terminal } from '@yuants/protocol';
3
3
  import { encodePath } from '@yuants/utils';
4
4
  import { getFuturesContracts, getSpotCurrencyPairs } from '../../api/public-api';
5
- export const productCache = createProductCache(Terminal.fromNodeEnv());
5
+ export const productCache = createClientProductCache(Terminal.fromNodeEnv());
6
6
  export const listProducts = async () => {
7
7
  const [futureProducts, spotProducts] = await Promise.all([
8
8
  getFuturesContracts('usdt', {}),
@@ -1 +1 @@
1
- {"version":3,"file":"product.js","sourceRoot":"","sources":["../../../src/services/markets/product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjF,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC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AC,EAAE,CAAC;QAC/C,aAAa,EAAE,IAAI,CAAC,IAAI;QACxB,cAAc,EAAE,IAAI,CAAC,KAAK;QAC1B,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QAC1C,WAAW,EAAE,CAAC;QACd,IAAI,EAAE,EAAE;QACR,gBAAgB,EAAE,EAAE;QACpB,WAAW,EAAE,CAAC;QACd,gBAAgB,EAAE,CAAC;QACnB,iBAAiB,EAAE,CAAC;QACpB,YAAY,EAAE,CAAC;QACf,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,KAAK;QAClB,SAAS,EAAE,gBAAgB;QAC3B,gBAAgB,EAAE,KAAK;KACxB,CAAC,CAAC,CAAC;IAEJ,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;AAC1B,CAAC,CAAC","sourcesContent":["import { createProductCache } from '@yuants/data-product';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { getFuturesContracts, getSpotCurrencyPairs } from '../../api/public-api';\n\nexport const productCache = createProductCache(Terminal.fromNodeEnv());\n\nexport const listProducts = async () => {\n const [futureProducts, spotProducts] = await Promise.all([\n getFuturesContracts('usdt', {}),\n getSpotCurrencyPairs(),\n ]);\n const fps = futureProducts.map((contract) => {\n const [base, quote] = contract.name.split('_');\n return {\n datasource_id: 'GATE',\n product_id: encodePath('GATE', 'FUTURE', contract.name),\n base_currency: base,\n quote_currency: quote,\n value_scale: Number(contract.quanto_multiplier),\n price_step: Number(contract.order_price_round),\n volume_step: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 1 / Number(contract.leverage_max),\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: true,\n market_id: 'GATE/USDT-FUTURE',\n no_interest_rate: false,\n };\n });\n const sps = spotProducts.map((spot) => ({\n datasource_id: 'GATE',\n product_id: encodePath('GATE', 'SPOT', spot.id),\n base_currency: spot.base,\n quote_currency: spot.quote,\n value_scale: 1,\n price_step: Number(`1e-${spot.precision}`),\n volume_step: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 0,\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: false,\n market_id: 'GATE/USDT-SPOT',\n no_interest_rate: false,\n }));\n\n return [...fps, ...sps];\n};\n"]}
1
+ {"version":3,"file":"product.js","sourceRoot":"","sources":["../../../src/services/markets/product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjF,MAAM,CAAC,MAAM,YAAY,GAAG,wBAAwB,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;AAE7E,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE;IACrC,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACvD,mBAAmB,CAAC,MAAM,EAAE,EAAE,CAAC;QAC/B,oBAAoB,EAAE;KACvB,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC1C,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/C,OAAO;YACL,aAAa,EAAE,MAAM;YACrB,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC;YACvD,aAAa,EAAE,IAAI;YACnB,cAAc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C,CAAC;AAC1B,CAAC,CAAC","sourcesContent":["import { createClientProductCache } from '@yuants/data-product';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { getFuturesContracts, getSpotCurrencyPairs } from '../../api/public-api';\n\nexport const productCache = createClientProductCache(Terminal.fromNodeEnv());\n\nexport const listProducts = async () => {\n const [futureProducts, spotProducts] = await Promise.all([\n getFuturesContracts('usdt', {}),\n getSpotCurrencyPairs(),\n ]);\n const fps = futureProducts.map((contract) => {\n const [base, quote] = contract.name.split('_');\n return {\n datasource_id: 'GATE',\n product_id: encodePath('GATE', 'FUTURE', contract.name),\n base_currency: base,\n quote_currency: quote,\n value_scale: Number(contract.quanto_multiplier),\n price_step: Number(contract.order_price_round),\n volume_step: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 1 / Number(contract.leverage_max),\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: true,\n market_id: 'GATE/USDT-FUTURE',\n no_interest_rate: false,\n };\n });\n const sps = spotProducts.map((spot) => ({\n datasource_id: 'GATE',\n product_id: encodePath('GATE', 'SPOT', spot.id),\n base_currency: spot.base,\n quote_currency: spot.quote,\n value_scale: 1,\n price_step: Number(`1e-${spot.precision}`),\n volume_step: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 0,\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: false,\n market_id: 'GATE/USDT-SPOT',\n no_interest_rate: false,\n }));\n\n return [...fps, ...sps];\n};\n"]}
@@ -1,5 +1,5 @@
1
1
  import { getFuturesOrders } from '../../api/private-api';
2
- import { decodePath } from '@yuants/utils';
2
+ import { decodePath, newError } from '@yuants/utils';
3
3
  const resolveOrderDirection = (order) => {
4
4
  const isLong = order.size > 0;
5
5
  if (order.is_close) {
@@ -9,6 +9,8 @@ const resolveOrderDirection = (order) => {
9
9
  };
10
10
  export const listOrders = async (credential) => {
11
11
  const orders = await getFuturesOrders(credential, 'usdt', { status: 'open' });
12
+ if (Array.isArray(orders) === false)
13
+ throw newError('InvalidResponse', { orders });
12
14
  return orders.map((order) => {
13
15
  const volume = Math.abs(order.size);
14
16
  const leftVolume = typeof order.left === 'number' ? Math.abs(order.left) : undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"listOrders.js","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAe,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,MAAM,qBAAqB,GAAG,CAAC,KAA0C,EAAkB,EAAE;IAC3F,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;IAC9B,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;KAC9C;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,UAAuB,EAAE,EAAE;IAC1D,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9E,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAU,EAAE;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACrF,MAAM,aAAa,GAAG,UAAU,KAAK,SAAS,CAAC,CAAC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BAAyB,QAAQ,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC","sourcesContent":["import { IOrder } from '@yuants/data-order';\nimport { getFuturesOrders, ICredential } from '../../api/private-api';\nimport { decodePath } from '@yuants/utils';\n\ntype OrderDirection = 'OPEN_LONG' | 'OPEN_SHORT' | 'CLOSE_LONG' | 'CLOSE_SHORT';\n\nconst resolveOrderDirection = (order: { size: number; is_close: boolean }): OrderDirection => {\n const isLong = order.size > 0;\n if (order.is_close) {\n return isLong ? 'CLOSE_SHORT' : 'CLOSE_LONG';\n }\n return isLong ? 'OPEN_LONG' : 'OPEN_SHORT';\n};\n\nexport const listOrders = async (credential: ICredential) => {\n const orders = await getFuturesOrders(credential, 'usdt', { status: 'open' });\n return orders.map((order): IOrder => {\n const volume = Math.abs(order.size);\n const leftVolume = typeof order.left === 'number' ? Math.abs(order.left) : undefined;\n const traded_volume = leftVolume !== undefined ? Math.max(volume - leftVolume, 0) : undefined;\n const price = Number(order.price);\n const traded_price = Number(order.fill_price);\n return {\n order_id: `${order.id}`,\n account_id: '',\n product_id: order.contract,\n order_direction: resolveOrderDirection(order),\n volume,\n price: Number.isFinite(price) ? price : undefined,\n submit_at: order.create_time * 1000,\n traded_volume,\n traded_price: Number.isFinite(traded_price) ? traded_price : undefined,\n order_status: order.status,\n };\n });\n};\n\nexport const getOrdersByProductId = async function (\n credential: ICredential,\n product_id: string,\n): Promise<IOrder[]> {\n const [_, instType] = decodePath(product_id); // GATE/FUTURE/ADAUSDT\n // if (instType === 'SPOT') {\n // const orders = await listSpotOrders(credential);\n // return orders.filter((order) => order.product_id === product_id);\n // }\n if (instType === 'FUTURE') {\n const orders = await listOrders(credential);\n return orders.filter((order) => order.product_id === product_id);\n }\n throw new Error(`Unsupported instType: ${instType}`);\n};\n"]}
1
+ {"version":3,"file":"listOrders.js","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAe,MAAM,uBAAuB,CAAC;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,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9C,OAAO;YACL,QAAQ,EAAE,GAAG,KAAK,CAAC,EAAE,EAAE;YACvB,UAAU,EAAE,EAAE;YACd,UAAU,EAAE,KAAK,CAAC,QAAQ;YAC1B,eAAe,EAAE,qBAAqB,CAAC,KAAK,CAAC;YAC7C,MAAM;YACN,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YACjD,SAAS,EAAE,KAAK,CAAC,WAAW,GAAG,IAAI;YACnC,aAAa;YACb,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;YACtE,YAAY,EAAE,KAAK,CAAC,MAAM;SAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,WACvC,UAAuB,EACvB,UAAkB;IAElB,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,sBAAsB;IACpE,6BAA6B;IAC7B,qDAAqD;IACrD,sEAAsE;IACtE,IAAI;IACJ,IAAI,QAAQ,KAAK,QAAQ,EAAE;QACzB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC;QAC5C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;KAClE;IACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC","sourcesContent":["import { IOrder } from '@yuants/data-order';\nimport { getFuturesOrders, ICredential } from '../../api/private-api';\nimport { decodePath, newError } from '@yuants/utils';\n\ntype OrderDirection = 'OPEN_LONG' | 'OPEN_SHORT' | 'CLOSE_LONG' | 'CLOSE_SHORT';\n\nconst resolveOrderDirection = (order: { size: number; is_close: boolean }): OrderDirection => {\n const isLong = order.size > 0;\n if (order.is_close) {\n return isLong ? 'CLOSE_SHORT' : 'CLOSE_LONG';\n }\n return isLong ? 'OPEN_LONG' : 'OPEN_SHORT';\n};\n\nexport const listOrders = async (credential: ICredential) => {\n const orders = await getFuturesOrders(credential, 'usdt', { status: 'open' });\n if (Array.isArray(orders) === false) throw newError('InvalidResponse', { orders });\n return orders.map((order): IOrder => {\n const volume = Math.abs(order.size);\n const leftVolume = typeof order.left === 'number' ? Math.abs(order.left) : undefined;\n const traded_volume = leftVolume !== undefined ? Math.max(volume - leftVolume, 0) : undefined;\n const price = Number(order.price);\n const traded_price = Number(order.fill_price);\n return {\n order_id: `${order.id}`,\n account_id: '',\n product_id: order.contract,\n order_direction: resolveOrderDirection(order),\n volume,\n price: Number.isFinite(price) ? price : undefined,\n submit_at: order.create_time * 1000,\n traded_volume,\n traded_price: Number.isFinite(traded_price) ? traded_price : undefined,\n order_status: order.status,\n };\n });\n};\n\nexport const getOrdersByProductId = async function (\n credential: ICredential,\n product_id: string,\n): Promise<IOrder[]> {\n const [_, instType] = decodePath(product_id); // GATE/FUTURE/ADAUSDT\n // if (instType === 'SPOT') {\n // const orders = await listSpotOrders(credential);\n // return orders.filter((order) => order.product_id === product_id);\n // }\n if (instType === 'FUTURE') {\n const orders = await listOrders(credential);\n return orders.filter((order) => order.product_id === product_id);\n }\n throw new Error(`Unsupported instType: ${instType}`);\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/api/http-client.ts"],"names":[],"mappings":"AAIA,oBAAY,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE3D,oBAAY,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;AAE/E,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAwDD,eAAO,MAAM,aAAa,sBAChB,UAAU,QACZ,MAAM,WACH,UAAU,uBAgBpB,CAAC;AAEF,eAAO,MAAM,cAAc,0BACb,eAAe,UACnB,UAAU,QACZ,MAAM,WACH,UAAU,uBAgCpB,CAAC"}
1
+ {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/api/http-client.ts"],"names":[],"mappings":"AAKA,oBAAY,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE3D,oBAAY,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;AAE/E,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAwDD,eAAO,MAAM,aAAa,sBAChB,UAAU,QACZ,MAAM,WACH,UAAU,uBAgBpB,CAAC;AAEF,eAAO,MAAM,cAAc,0BACb,eAAe,UACnB,UAAU,QACZ,MAAM,WACH,UAAU,uBAgCpB,CAAC"}
@@ -2,7 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requestPrivate = exports.requestPublic = void 0;
4
4
  const utils_1 = require("@yuants/utils");
5
- const BASE_URL = 'https://api.gateio.ws';
5
+ const path_1 = require("path");
6
+ const BASE_URL = 'https://api.gateio.ws/api/v4';
6
7
  const serializeQueryParams = (params) => {
7
8
  if (!params)
8
9
  return undefined;
@@ -14,7 +15,7 @@ const serializeQueryParams = (params) => {
14
15
  };
15
16
  const createRequestArtifacts = (method, path, params) => {
16
17
  const url = new URL(BASE_URL);
17
- url.pathname = path;
18
+ url.pathname = (0, path_1.join)(url.pathname, path);
18
19
  const searchParams = serializeQueryParams(params);
19
20
  if (method === 'GET' && searchParams) {
20
21
  Object.entries(searchParams).forEach(([key, value]) => url.searchParams.set(key, value));
@@ -39,7 +40,7 @@ const parseJSON = async (response, path, params) => {
39
40
  return JSON.parse(text);
40
41
  }
41
42
  catch (error) {
42
- console.error((0, utils_1.formatTime)(Date.now()), 'GateRequestFailed', path, JSON.stringify(params !== null && params !== void 0 ? params : {}), text, {
43
+ console.info((0, utils_1.formatTime)(Date.now()), 'GateRequestFailed', path, JSON.stringify(params !== null && params !== void 0 ? params : {}), text, {
43
44
  status: response.status,
44
45
  headers: toHeaderObject(response.headers),
45
46
  });
@@ -1 +1 @@
1
- {"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/api/http-client.ts"],"names":[],"mappings":";;;AAAA,yCAA0E;AAE1E,MAAM,QAAQ,GAAG,uBAAuB,CAAC;AAgBzC,MAAM,oBAAoB,GAAG,CAAC,MAAmB,EAAsC,EAAE;IACvF,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IAC5F,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE;QAClC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AACxF,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,MAAkB,EAAE,IAAY,EAAE,MAAmB,EAAqB,EAAE;IAC1G,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC;IACpB,MAAM,YAAY,GAAG,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ACN,OAAO;QACP,IAAI,EAAE,IAAI,IAAI,SAAS;KACxB,CAAC,CAAC;IACH,OAAO,SAAS,CAAY,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC,CAAC;AApCW,QAAA,cAAc,kBAoCzB","sourcesContent":["import { encodeHex, formatTime, HmacSHA512, sha512 } from '@yuants/utils';\n\nconst BASE_URL = 'https://api.gateio.ws';\n\nexport type HttpMethod = 'GET' | 'POST' | 'DELETE' | 'PUT';\n\nexport type GateParams = Record<string, string | number | boolean | undefined>;\n\nexport interface IGateCredential {\n access_key: string;\n secret_key: string;\n}\n\ninterface IRequestArtifacts {\n url: URL;\n body: string;\n}\n\nconst serializeQueryParams = (params?: GateParams): Record<string, string> | undefined => {\n if (!params) return undefined;\n const normalizedEntries = Object.entries(params).filter(([, value]) => value !== undefined);\n if (normalizedEntries.length === 0) {\n return undefined;\n }\n return Object.fromEntries(normalizedEntries.map(([key, value]) => [key, `${value}`]));\n};\n\nconst createRequestArtifacts = (method: HttpMethod, path: string, params?: GateParams): IRequestArtifacts => {\n const url = new URL(BASE_URL);\n url.pathname = path;\n const searchParams = serializeQueryParams(params);\n if (method === 'GET' && searchParams) {\n Object.entries(searchParams).forEach(([key, value]) => url.searchParams.set(key, value));\n }\n const rawBody = method === 'GET' ? '' : JSON.stringify(params);\n const body = rawBody;\n return { url, body };\n};\n\nconst toHeaderObject = (headers: Headers): Record<string, string> => {\n const iterable = headers as unknown as Iterable<[string, string]>;\n return Object.fromEntries(Array.from(iterable));\n};\n\nconst parseJSON = async <TResponse>(\n response: Response,\n path: string,\n params?: GateParams,\n): Promise<TResponse> => {\n const text = await response.text();\n if (process.env.LOG_LEVEL === 'DEBUG') {\n console.debug(formatTime(Date.now()), 'GateResponse', path, JSON.stringify(params ?? {}), text, {\n status: response.status,\n headers: toHeaderObject(response.headers),\n });\n }\n try {\n return JSON.parse(text) as TResponse;\n } catch (error) {\n console.error(formatTime(Date.now()), 'GateRequestFailed', path, JSON.stringify(params ?? {}), text, {\n status: response.status,\n headers: toHeaderObject(response.headers),\n });\n throw error;\n }\n};\n\nexport const requestPublic = async <TResponse>(\n method: HttpMethod,\n path: string,\n params?: GateParams,\n): Promise<TResponse> => {\n const { url, body } = createRequestArtifacts(method, path, params);\n const headers: Record<string, string> = {\n Accept: 'application/json',\n };\n if (body) {\n headers['Content-Type'] = 'application/json';\n }\n console.info(formatTime(Date.now()), method, url.href);\n const response = await fetch(url.href, {\n method,\n headers,\n body: body || undefined,\n });\n return parseJSON<TResponse>(response, path, params);\n};\n\nexport const requestPrivate = async <TResponse>(\n credential: IGateCredential,\n method: HttpMethod,\n path: string,\n params?: GateParams,\n): Promise<TResponse> => {\n const { url, body } = createRequestArtifacts(method, path, params);\n const timestamp = Date.now() / 1000;\n\n const bodyDigest = encodeHex(await sha512(new TextEncoder().encode(body)));\n const signTarget = `${method}\\n${url.pathname}\\n${url.searchParams}\\n${bodyDigest}\\n${timestamp}`;\n const sign = encodeHex(\n await HmacSHA512(new TextEncoder().encode(signTarget), new TextEncoder().encode(credential.secret_key)),\n );\n\n const headers: Record<string, string> = {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n KEY: credential.access_key,\n SIGN: sign,\n Timestamp: `${timestamp}`,\n };\n\n // Add Channel ID header if exists\n if (process.env.CHANNEL_ID) {\n headers['X-Gate-Channel-Id'] = process.env.CHANNEL_ID;\n }\n\n console.info(formatTime(Date.now()), method, url.href, JSON.stringify(headers), body);\n\n const response = await fetch(url.href, {\n method,\n headers,\n body: body || undefined,\n });\n return parseJSON<TResponse>(response, path, params);\n};\n"]}
1
+ {"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/api/http-client.ts"],"names":[],"mappings":";;;AAAA,yCAA0E;AAC1E,+BAA4B;AAE5B,MAAM,QAAQ,GAAG,8BAA8B,CAAC;AAgBhD,MAAM,oBAAoB,GAAG,CAAC,MAAmB,EAAsC,EAAE;IACvF,IAAI,CAAC,MAAM;QAAE,OAAO,S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,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CACxG,CAAC;IAEF,MAAM,OAAO,GAA2B;QACtC,MAAM,EAAE,kBAAkB;QAC1B,cAAc,EAAE,kBAAkB;QAClC,GAAG,EAAE,UAAU,CAAC,UAAU;QAC1B,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,GAAG,SAAS,EAAE;KAC1B,CAAC;IAEF,kCAAkC;IAClC,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE;QAC1B,OAAO,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;KACvD;IAED,OAAO,CAAC,IAAI,CAAC,IAAA,kBAAU,EAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;IAEtF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE;QACrC,MAAM;QACN,OAAO;QACP,IAAI,EAAE,IAAI,IAAI,SAAS;KACxB,CAAC,CAAC;IACH,OAAO,SAAS,CAAY,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC,CAAC;AApCW,QAAA,cAAc,kBAoCzB","sourcesContent":["import { encodeHex, formatTime, HmacSHA512, sha512 } from '@yuants/utils';\nimport { join } from 'path';\n\nconst BASE_URL = 'https://api.gateio.ws/api/v4';\n\nexport type HttpMethod = 'GET' | 'POST' | 'DELETE' | 'PUT';\n\nexport type GateParams = Record<string, string | number | boolean | undefined>;\n\nexport interface IGateCredential {\n access_key: string;\n secret_key: string;\n}\n\ninterface IRequestArtifacts {\n url: URL;\n body: string;\n}\n\nconst serializeQueryParams = (params?: GateParams): Record<string, string> | undefined => {\n if (!params) return undefined;\n const normalizedEntries = Object.entries(params).filter(([, value]) => value !== undefined);\n if (normalizedEntries.length === 0) {\n return undefined;\n }\n return Object.fromEntries(normalizedEntries.map(([key, value]) => [key, `${value}`]));\n};\n\nconst createRequestArtifacts = (method: HttpMethod, path: string, params?: GateParams): IRequestArtifacts => {\n const url = new URL(BASE_URL);\n url.pathname = join(url.pathname, path);\n const searchParams = serializeQueryParams(params);\n if (method === 'GET' && searchParams) {\n Object.entries(searchParams).forEach(([key, value]) => url.searchParams.set(key, value));\n }\n const rawBody = method === 'GET' ? '' : JSON.stringify(params);\n const body = rawBody;\n return { url, body };\n};\n\nconst toHeaderObject = (headers: Headers): Record<string, string> => {\n const iterable = headers as unknown as Iterable<[string, string]>;\n return Object.fromEntries(Array.from(iterable));\n};\n\nconst parseJSON = async <TResponse>(\n response: Response,\n path: string,\n params?: GateParams,\n): Promise<TResponse> => {\n const text = await response.text();\n if (process.env.LOG_LEVEL === 'DEBUG') {\n console.debug(formatTime(Date.now()), 'GateResponse', path, JSON.stringify(params ?? {}), text, {\n status: response.status,\n headers: toHeaderObject(response.headers),\n });\n }\n try {\n return JSON.parse(text) as TResponse;\n } catch (error) {\n console.info(formatTime(Date.now()), 'GateRequestFailed', path, JSON.stringify(params ?? {}), text, {\n status: response.status,\n headers: toHeaderObject(response.headers),\n });\n throw error;\n }\n};\n\nexport const requestPublic = async <TResponse>(\n method: HttpMethod,\n path: string,\n params?: GateParams,\n): Promise<TResponse> => {\n const { url, body } = createRequestArtifacts(method, path, params);\n const headers: Record<string, string> = {\n Accept: 'application/json',\n };\n if (body) {\n headers['Content-Type'] = 'application/json';\n }\n console.info(formatTime(Date.now()), method, url.href);\n const response = await fetch(url.href, {\n method,\n headers,\n body: body || undefined,\n });\n return parseJSON<TResponse>(response, path, params);\n};\n\nexport const requestPrivate = async <TResponse>(\n credential: IGateCredential,\n method: HttpMethod,\n path: string,\n params?: GateParams,\n): Promise<TResponse> => {\n const { url, body } = createRequestArtifacts(method, path, params);\n const timestamp = Date.now() / 1000;\n\n const bodyDigest = encodeHex(await sha512(new TextEncoder().encode(body)));\n const signTarget = `${method}\\n${url.pathname}\\n${url.searchParams}\\n${bodyDigest}\\n${timestamp}`;\n const sign = encodeHex(\n await HmacSHA512(new TextEncoder().encode(signTarget), new TextEncoder().encode(credential.secret_key)),\n );\n\n const headers: Record<string, string> = {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n KEY: credential.access_key,\n SIGN: sign,\n Timestamp: `${timestamp}`,\n };\n\n // Add Channel ID header if exists\n if (process.env.CHANNEL_ID) {\n headers['X-Gate-Channel-Id'] = process.env.CHANNEL_ID;\n }\n\n console.info(formatTime(Date.now()), method, url.href, JSON.stringify(headers), body);\n\n const response = await fetch(url.href, {\n method,\n headers,\n body: body || undefined,\n });\n return parseJSON<TResponse>(response, path, params);\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"private-api.d.ts","sourceRoot":"","sources":["../../src/api/private-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,eAAe,EAAE,MAAM,eAAe,CAAC;AAG7E,oBAAY,WAAW,GAAG,eAAe,CAAC;AAS1C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,eACf,WAAW,KACtB,QAAQ;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,GAAG,EAAE;QACH,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;CACd,CAA6D,CAAC;AAE/D,eAAO,MAAM,kBAAkB,eACjB,WAAW,WACd;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,KAC7B,QAAQ;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OACR,MAAM,EACN;QACE,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,C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AAC;CACjB,KACA,QACD;IACE,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,EAAE,CACoE,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,eAAe,eACd,WAAW,WACd;IACP,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,KACA,QACD;IACE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,EAAE,CAC+D,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,eACjB,WAAW,UACf;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,KACA,QAAQ;IACT,KAAK,EAAE,MAAM,CAAC;CACf,CAAwE,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,eACrB,WAAW,UACf;IACN,QAAQ,EAAE,MAAM,CAAC;CAClB,KACA,QAAQ;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAA2E,CAAC"}
1
+ {"version":3,"file":"private-api.d.ts","sourceRoot":"","sources":["../../src/api/private-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,eAAe,EAAE,MAAM,eAAe,CAAC;AAG7E,oBAA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,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,KACA,QAAQ;IACT,KAAK,EAAE,MAAM,CAAC;CACf,CAAiE,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,eACrB,WAAW,UACf;IACN,QAAQ,EAAE,MAAM,CAAC;CAClB,KACA,QAAQ;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAoE,CAAC"}
@@ -8,30 +8,30 @@ const callPrivate = (credential, method, path, params) => (0, http_client_1.requ
8
8
  *
9
9
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AF
10
10
  */
11
- const getAccountDetail = (credential) => callPrivate(credential, 'GET', '/api/v4/account/detail');
11
+ const getAccountDetail = (credential) => callPrivate(credential, 'GET', '/account/detail');
12
12
  exports.getAccountDetail = getAccountDetail;
13
- const getUnifiedAccounts = (credential, params) => callPrivate(credential, 'GET', '/api/v4/unified/accounts', params);
13
+ const getUnifiedAccounts = (credential, params) => callPrivate(credential, 'GET', '/unified/accounts', params);
14
14
  exports.getUnifiedAccounts = getUnifiedAccounts;
15
15
  /**
16
16
  * 获取用户仓位列表
17
17
  *
18
18
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E4%BB%93%E4%BD%8D%E5%88%97%E8%A1%A8
19
19
  */
20
- const getFuturePositions = (credential, quote_currency, params) => callPrivate(credential, 'GET', `/api/v4/futures/${quote_currency}/positions`, params);
20
+ const getFuturePositions = (credential, quote_currency, params) => callPrivate(credential, 'GET', `/futures/${quote_currency}/positions`, params);
21
21
  exports.getFuturePositions = getFuturePositions;
22
22
  /**
23
23
  * 查询合约订单列表
24
24
  *
25
25
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8
26
26
  */
27
- const getFuturesOrders = (credential, settle, params) => callPrivate(credential, 'GET', `/api/v4/futures/${settle}/orders`, params);
27
+ const getFuturesOrders = (credential, settle, params) => callPrivate(credential, 'GET', `/futures/${settle}/orders`, params);
28
28
  exports.getFuturesOrders = getFuturesOrders;
29
29
  /**
30
30
  * 获取合约账号
31
31
  *
32
32
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%90%88%E7%BA%A6%E8%B4%A6%E5%8F%B7
33
33
  */
34
- const getFuturesAccounts = (credential, settle) => callPrivate(credential, 'GET', `/api/v4/futures/${settle}/accounts`);
34
+ const getFuturesAccounts = (credential, settle) => callPrivate(credential, 'GET', `/futures/${settle}/accounts`);
35
35
  exports.getFuturesAccounts = getFuturesAccounts;
36
36
  /**
37
37
  * 合约交易下单
@@ -50,14 +50,14 @@ exports.getFuturesAccounts = getFuturesAccounts;
50
50
  *
51
51
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E4%B8%8B%E5%8D%95
52
52
  */
53
- const postFutureOrders = (credential, settle, params) => callPrivate(credential, 'POST', `/api/v4/futures/${settle}/orders`, params);
53
+ const postFutureOrders = (credential, settle, params) => callPrivate(credential, 'POST', `/futures/${settle}/orders`, params);
54
54
  exports.postFutureOrders = postFutureOrders;
55
55
  /**
56
56
  * 撤销单个订单
57
57
  *
58
58
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%92%A4%E9%94%80%E5%8D%95%E4%B8%AA%E8%AE%A2%E5%8D%95-2
59
59
  */
60
- const deleteFutureOrders = (credential, settle, order_id) => callPrivate(credential, 'DELETE', `/api/v4/futures/${settle}/orders/${order_id}`);
60
+ const deleteFutureOrders = (credential, settle, order_id) => callPrivate(credential, 'DELETE', `/futures/${settle}/orders/${order_id}`);
61
61
  exports.deleteFutureOrders = deleteFutureOrders;
62
62
  /**
63
63
  * 提现
@@ -66,21 +66,21 @@ exports.deleteFutureOrders = deleteFutureOrders;
66
66
  *
67
67
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%8F%90%E7%8E%B0
68
68
  */
69
- const postWithdrawals = (credential, params) => callPrivate(credential, 'POST', '/api/v4/withdrawals', params);
69
+ const postWithdrawals = (credential, params) => callPrivate(credential, 'POST', '/withdrawals', params);
70
70
  exports.postWithdrawals = postWithdrawals;
71
71
  /**
72
72
  * 获取币种充值地址
73
73
  *
74
74
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80
75
75
  */
76
- const getDepositAddress = (credential, params) => callPrivate(credential, 'GET', '/api/v4/wallet/deposit_address', params);
76
+ const getDepositAddress = (credential, params) => callPrivate(credential, 'GET', '/wallet/deposit_address', params);
77
77
  exports.getDepositAddress = getDepositAddress;
78
78
  /**
79
79
  * 创建新的子账户
80
80
  *
81
81
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%88%9B%E5%BB%BA%E6%96%B0%E7%9A%84%E5%AD%90%E8%B4%A6%E6%88%B7
82
82
  */
83
- const getSubAccountList = (credential, params) => callPrivate(credential, 'GET', '/api/v4/sub_accounts', params);
83
+ const getSubAccountList = (credential, params) => callPrivate(credential, 'GET', '/sub_accounts', params);
84
84
  exports.getSubAccountList = getSubAccountList;
85
85
  /**
86
86
  * 获取充值记录
@@ -89,7 +89,7 @@ exports.getSubAccountList = getSubAccountList;
89
89
  *
90
90
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%85%85%E5%80%BC%E8%AE%B0%E5%BD%95
91
91
  */
92
- const getDepositHistory = (credential, params) => callPrivate(credential, 'GET', '/api/v4/wallet/deposits', params);
92
+ const getDepositHistory = (credential, params) => callPrivate(credential, 'GET', '/wallet/deposits', params);
93
93
  exports.getDepositHistory = getDepositHistory;
94
94
  /**
95
95
  * 获取提现记录
@@ -98,14 +98,14 @@ exports.getDepositHistory = getDepositHistory;
98
98
  *
99
99
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80
100
100
  */
101
- const getWithdrawalHistory = (credential, params) => callPrivate(credential, 'GET', '/api/v4/wallet/withdrawals', params);
101
+ const getWithdrawalHistory = (credential, params) => callPrivate(credential, 'GET', '/wallet/withdrawals', params);
102
102
  exports.getWithdrawalHistory = getWithdrawalHistory;
103
103
  /**
104
104
  * 获取现货交易账户列表
105
105
  *
106
106
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%8E%B0%E8%B4%A7%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E5%88%97%E8%A1%A8
107
107
  */
108
- const getSpotAccounts = (credential, params) => callPrivate(credential, 'GET', '/api/v4/spot/accounts', params);
108
+ const getSpotAccounts = (credential, params) => callPrivate(credential, 'GET', '/spot/accounts', params);
109
109
  exports.getSpotAccounts = getSpotAccounts;
110
110
  /**
111
111
  * 交易账户互转
@@ -114,13 +114,13 @@ exports.getSpotAccounts = getSpotAccounts;
114
114
  *
115
115
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E4%BA%92%E8%BD%AC
116
116
  */
117
- const postWalletTransfer = (credential, params) => callPrivate(credential, 'POST', '/api/v4/wallet/transfers', params);
117
+ const postWalletTransfer = (credential, params) => callPrivate(credential, 'POST', '/wallet/transfers', params);
118
118
  exports.postWalletTransfer = postWalletTransfer;
119
119
  /**
120
120
  * 获取统一账户最多可转出
121
121
  *
122
122
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E7%BB%9F%E4%B8%80%E8%B4%A6%E6%88%B7%E6%9C%80%E5%A4%9A%E5%8F%AF%E8%BD%AC%E5%87%BA
123
123
  */
124
- const getUnifiedTransferable = (credential, params) => callPrivate(credential, 'GET', `/api/v4/unified/transferable`, params);
124
+ const getUnifiedTransferable = (credential, params) => callPrivate(credential, 'GET', `/unified/transferable`, params);
125
125
  exports.getUnifiedTransferable = getUnifiedTransferable;
126
126
  //# sourceMappingURL=private-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"private-api.js","sourceRoot":"","sources":["../../src/api/private-api.ts"],"names":[],"mappings":";;;AACA,+CAA+C;AAI/C,MAAM,WAAW,GAAG,CAClB,UAAuB,EACvB,MAAkB,EAClB,IAAY,EACZ,MAAmB,EACnB,EAAE,CAAC,IAAA,4BAAc,EAAY,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEjE;;;;GAIG;AACI,MAAM,gBAAgB,GAAG,CAC9B,UAAuB,EAStB,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,wBAAwB,CAAC,CAAC;AAVlD,QAAA,gBAAgB,oBAUkC;AAExD,MAAM,kBAAkB,GAAG,CAChC,UAAuB,EACvB,MAA8B,EAiC7B,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,0BAA0B,EAAE,MAAM,CAAC,CAAC;AAnC5D,QAAA,kBAAkB,sBAmC0C;AAEzE;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAChC,UAAuB,EACvB,cAAsB,EACtB,MAA+D,EAkB/D,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,mBAAmB,cAAc,YAAY,EAAE,MAAM,CAAC,CAAC;AArB9E,QAAA,kBAAkB,sBAqB4D;AAE3F;;;;GAIG;AACI,MAAM,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vB,MAEC,EAYD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,sBAAsB,EAAE,MAAM,CAAC,CAAC;AAhBvD,QAAA,iBAAiB,qBAgBsC;AAEpE;;;;;;GAMG;AACI,MAAM,iBAAiB,GAAG,CAC/B,UAAuB,EACvB,MAMC,EAcD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,yBAAyB,EAAE,MAAM,CAAC,CAAC;AAtB1D,QAAA,iBAAiB,qBAsByC;AAEvE;;;;;;GAMG;AACI,MAAM,oBAAoB,GAAG,CAClC,UAAuB,EACvB,MAMC,EAcD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,4BAA4B,EAAE,MAAM,CAAC,CAAC;AAtB7D,QAAA,oBAAoB,wBAsByC;AAE1E;;;;GAIG;AACI,MAAM,eAAe,GAAG,CAC7B,UAAuB,EACvB,MAEC,EAQD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,CAAC,CAAC;AAZxD,QAAA,eAAe,mBAYyC;AAErE;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,CAChC,UAAuB,EACvB,MAOC,EAGA,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,0BAA0B,EAAE,MAAM,CAAC,CAAC;AAZ7D,QAAA,kBAAkB,sBAY2C;AAE1E;;;;GAIG;AACI,MAAM,sBAAsB,GAAG,CACpC,UAAuB,EACvB,MAEC,EAIA,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,8BAA8B,EAAE,MAAM,CAAC,CAAC;AARhE,QAAA,sBAAsB,0BAQ0C","sourcesContent":["import type { GateParams, HttpMethod, IGateCredential } from './http-client';\nimport { requestPrivate } from './http-client';\n\nexport type ICredential = IGateCredential;\n\nconst callPrivate = <TResponse>(\n credential: ICredential,\n method: HttpMethod,\n path: string,\n params?: GateParams,\n) => requestPrivate<TResponse>(credential, method, path, params);\n\n/**\n * 获取用户账户信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AF\n */\nexport const getAccountDetail = (\n credential: ICredential,\n): Promise<{\n user_id: number;\n ip_whitelist: string[];\n currency_pairs: string[];\n key: {\n mode: number;\n };\n tier: number;\n}> => callPrivate(credential, 'GET', '/api/v4/account/detail');\n\nexport const getUnifiedAccounts = (\n credential: ICredential,\n params?: { currency?: string },\n): Promise<{\n user_id: string;\n refresh_time: number;\n locket: boolean;\n balances: Record<\n string,\n {\n available: string;\n freeze: string;\n borrowed: string;\n negative_liab: string;\n futures_pos_liab: string;\n equity: string;\n total_freeze: string;\n total_liab: string;\n spot_in_use: string;\n }\n >;\n total: string;\n borrowed: string;\n total_initial_margin: string;\n total_margin_balance: string;\n total_maintenance_margin: string;\n total_initial_margin_rate: string;\n total_maintenance_margin_rate: string;\n total_avail_margin: string;\n unified_account_total: string;\n unified_account_total_liab: string;\n unified_account_total_equity: string;\n leverage: string;\n spot_order_loss: string;\n spot_hedge: boolean;\n}> => callPrivate(credential, 'GET', '/api/v4/unified/accounts', params);\n\n/**\n * 获取用户仓位列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E4%BB%93%E4%BD%8D%E5%88%97%E8%A1%A8\n */\nexport const getFuturePositions = (\n credential: ICredential,\n quote_currency: string,\n params?: { holding?: boolean; limit?: number; offset?: number },\n): Promise<\n {\n user: number;\n contract: string;\n size: number;\n leverage: string;\n risk_limit: string;\n leverage_max: string;\n maintenance_rate: string;\n value: string;\n margin: string;\n entry_price: string;\n mark_price: string;\n unrealised_pnl: string;\n realised_pnl: string;\n mode: string;\n }[]\n> => callPrivate(credential, 'GET', `/api/v4/futures/${quote_currency}/positions`, params);\n\n/**\n * 查询合约订单列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8\n */\nexport const getFuturesOrders = (\n credential: ICredential,\n settle: string,\n params: {\n contract?: string;\n status: string;\n limit?: number;\n offset?: number;\n last_id?: number;\n },\n): Promise<\n {\n id: string;\n contract: string;\n create_time: number;\n size: number;\n price: string;\n is_close: boolean;\n fill_price: string;\n left?: number;\n status?: string;\n text: string;\n }[]\n> => callPrivate(credential, 'GET', `/api/v4/futures/${settle}/orders`, params);\n\n/**\n * 获取合约账号\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%90%88%E7%BA%A6%E8%B4%A6%E5%8F%B7\n */\nexport const getFuturesAccounts = (\n credential: ICredential,\n settle: string,\n): Promise<{\n user: number;\n currency: string;\n total: string;\n unrealised_pnl: string;\n position_margin: string;\n order_margin: string;\n available: string;\n point: string;\n bonus: string;\n in_dual_mode: boolean;\n enable_evolved_classic: boolean;\n history: {\n dnw: string;\n pnl: string;\n fee: string;\n refr: string;\n fund: string;\n point_dnw: string;\n point_fee: string;\n point_refr: string;\n bonus_dnw: string;\n bonus_offset: string;\n };\n}> => callPrivate(credential, 'GET', `/api/v4/futures/${settle}/accounts`);\n\n/**\n * 合约交易下单\n *\n * 下单时指定的是合约张数 size ,而非币的数量,每一张合约对应的币的数量是合约详情接口里返回的 quanto_multiplier\n *\n * 0 成交的订单在撤单 10 分钟之后无法再获取到,会提到订单不存在\n *\n * 设置 reduce_only 为 true 可以防止在减仓的时候穿仓\n *\n * 单仓模式下,如果需要平仓,需要设置 size 为 0 ,close 为 true\n *\n * 双仓模式下,平仓需要使用 auto_size 来设置平仓方向,并同时设置 reduce_only 为 true,size 为 0\n *\n * 设置 stp_act 决定使用限制用户自成交的策略,详细用法参考body参数stp_act\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E4%B8%8B%E5%8D%95\n */\nexport const postFutureOrders = (\n credential: ICredential,\n settle: string,\n params: {\n contract: string;\n size: number;\n iceberg?: number;\n price?: string;\n close?: boolean;\n reduce_only?: boolean;\n tif?: string;\n text?: string;\n auto_size?: string;\n stp_act?: string;\n },\n): Promise<{\n label?: string;\n message?: string;\n detail?: string;\n id: number;\n user: number;\n contract: string;\n create_time: number;\n size: number;\n iceberg: number;\n left: number;\n price: string;\n fill_price: string;\n mkfr: string;\n tkfr: string;\n tif: string;\n refu: number;\n is_reduce_only: boolean;\n is_close: boolean;\n is_liq: boolean;\n text: string;\n status: string;\n finish_time: number;\n finish_as: string;\n stp_id: number;\n stp_act: string;\n amend_text: string;\n}> => callPrivate(credential, 'POST', `/api/v4/futures/${settle}/orders`, params);\n\n/**\n * 撤销单个订单\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%92%A4%E9%94%80%E5%8D%95%E4%B8%AA%E8%AE%A2%E5%8D%95-2\n */\nexport const deleteFutureOrders = (credential: ICredential, settle: string, order_id: string): Promise<{}> =>\n callPrivate(credential, 'DELETE', `/api/v4/futures/${settle}/orders/${order_id}`);\n\n/**\n * 提现\n *\n * POST /withdrawals\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%8F%90%E7%8E%B0\n */\nexport const postWithdrawals = (\n credential: ICredential,\n params: {\n withdraw_order_id?: string;\n amount: string;\n currency: string;\n address?: string;\n memo?: string;\n chain: string;\n },\n): Promise<{\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n}> => callPrivate(credential, 'POST', '/api/v4/withdrawals', params);\n\n/**\n * 获取币种充值地址\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80\n */\nexport const getDepositAddress = (\n credential: ICredential,\n params: {\n currency: string;\n },\n): Promise<{\n currency: string;\n address: string;\n multichain_addresses: {\n chain: string;\n address: string;\n payment_id: string;\n payment_name: string;\n obtain_failed: boolean;\n }[];\n}> => callPrivate(credential, 'GET', '/api/v4/wallet/deposit_address', params);\n\n/**\n * 创建新的子账户\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%88%9B%E5%BB%BA%E6%96%B0%E7%9A%84%E5%AD%90%E8%B4%A6%E6%88%B7\n */\nexport const getSubAccountList = (\n credential: ICredential,\n params?: {\n type?: string;\n },\n): Promise<\n {\n remark: string;\n login_name: string;\n password: string;\n email: string;\n state: number;\n type: number;\n user_id: number;\n create_time: number;\n }[]\n> => callPrivate(credential, 'GET', '/api/v4/sub_accounts', params);\n\n/**\n * 获取充值记录\n *\n * 记录查询时间范围不允许超过 30 天\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%85%85%E5%80%BC%E8%AE%B0%E5%BD%95\n */\nexport const getDepositHistory = (\n credential: ICredential,\n params?: {\n currency?: string;\n from?: number;\n to?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<\n {\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n }[]\n> => callPrivate(credential, 'GET', '/api/v4/wallet/deposits', params);\n\n/**\n * 获取提现记录\n *\n * 记录查询时间范围不允许超过 30 天\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80\n */\nexport const getWithdrawalHistory = (\n credential: ICredential,\n params?: {\n currency?: string;\n from?: number;\n to?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<\n {\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n }[]\n> => callPrivate(credential, 'GET', '/api/v4/wallet/withdrawals', params);\n\n/**\n * 获取现货交易账户列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%8E%B0%E8%B4%A7%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E5%88%97%E8%A1%A8\n */\nexport const getSpotAccounts = (\n credential: ICredential,\n params?: {\n currency?: string;\n },\n): Promise<\n {\n currency: string;\n available: string;\n locked: string;\n update_id: string;\n }[]\n> => callPrivate(credential, 'GET', '/api/v4/spot/accounts', params);\n\n/**\n * 交易账户互转\n *\n * POST /wallet/transfers\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E4%BA%92%E8%BD%AC\n */\nexport const postWalletTransfer = (\n credential: ICredential,\n params: {\n currency: string;\n from: string;\n to: string;\n amount: string;\n currency_pair?: string;\n settle?: string;\n },\n): Promise<{\n tx_id: string;\n}> => callPrivate(credential, 'POST', '/api/v4/wallet/transfers', params);\n\n/**\n * 获取统一账户最多可转出\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E7%BB%9F%E4%B8%80%E8%B4%A6%E6%88%B7%E6%9C%80%E5%A4%9A%E5%8F%AF%E8%BD%AC%E5%87%BA\n */\nexport const getUnifiedTransferable = (\n credential: ICredential,\n params: {\n currency: string;\n },\n): Promise<{\n currency: string;\n amount: string;\n}> => callPrivate(credential, 'GET', `/api/v4/unified/transferable`, params);\n"]}
1
+ {"version":3,"file":"private-api.js","sourceRoot":"","sources":["../../src/api/private-api.ts"],"names":[],"mappings":";;;AACA,+CAA+C;AAI/C,MAAM,WAAW,GAAG,CAClB,UAAuB,EACvB,MAAkB,EAClB,IAAY,EACZ,MAAmB,EACnB,EAAE,CAAC,IAAA,4BAAc,EAAY,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEjE;;;;GAIG;AACI,M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AE9D;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,CAChC,UAAuB,EACvB,MAOC,EAGA,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAZtD,QAAA,kBAAkB,sBAYoC;AAEnE;;;;GAIG;AACI,MAAM,sBAAsB,GAAG,CACpC,UAAuB,EACvB,MAEC,EAIA,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,CAAC,CAAC;AARzD,QAAA,sBAAsB,0BAQmC","sourcesContent":["import type { GateParams, HttpMethod, IGateCredential } from './http-client';\nimport { requestPrivate } from './http-client';\n\nexport type ICredential = IGateCredential;\n\nconst callPrivate = <TResponse>(\n credential: ICredential,\n method: HttpMethod,\n path: string,\n params?: GateParams,\n) => requestPrivate<TResponse>(credential, method, path, params);\n\n/**\n * 获取用户账户信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AF\n */\nexport const getAccountDetail = (\n credential: ICredential,\n): Promise<{\n user_id: number;\n ip_whitelist: string[];\n currency_pairs: string[];\n key: {\n mode: number;\n };\n tier: number;\n}> => callPrivate(credential, 'GET', '/account/detail');\n\nexport const getUnifiedAccounts = (\n credential: ICredential,\n params?: { currency?: string },\n): Promise<{\n user_id: string;\n refresh_time: number;\n locket: boolean;\n balances: Record<\n string,\n {\n available: string;\n freeze: string;\n borrowed: string;\n negative_liab: string;\n futures_pos_liab: string;\n equity: string;\n total_freeze: string;\n total_liab: string;\n spot_in_use: string;\n }\n >;\n total: string;\n borrowed: string;\n total_initial_margin: string;\n total_margin_balance: string;\n total_maintenance_margin: string;\n total_initial_margin_rate: string;\n total_maintenance_margin_rate: string;\n total_avail_margin: string;\n unified_account_total: string;\n unified_account_total_liab: string;\n unified_account_total_equity: string;\n leverage: string;\n spot_order_loss: string;\n spot_hedge: boolean;\n}> => callPrivate(credential, 'GET', '/unified/accounts', params);\n\n/**\n * 获取用户仓位列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E4%BB%93%E4%BD%8D%E5%88%97%E8%A1%A8\n */\nexport const getFuturePositions = (\n credential: ICredential,\n quote_currency: string,\n params?: { holding?: boolean; limit?: number; offset?: number },\n): Promise<\n {\n user: number;\n contract: string;\n size: number;\n leverage: string;\n risk_limit: string;\n leverage_max: string;\n maintenance_rate: string;\n value: string;\n margin: string;\n entry_price: string;\n mark_price: string;\n unrealised_pnl: string;\n realised_pnl: string;\n mode: string;\n }[]\n> => callPrivate(credential, 'GET', `/futures/${quote_currency}/positions`, params);\n\n/**\n * 查询合约订单列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8\n */\nexport const getFuturesOrders = (\n credential: ICredential,\n settle: string,\n params: {\n contract?: string;\n status: string;\n limit?: number;\n offset?: number;\n last_id?: number;\n },\n): Promise<\n {\n id: string;\n contract: string;\n create_time: number;\n size: number;\n price: string;\n is_close: boolean;\n fill_price: string;\n left?: number;\n status?: string;\n text: string;\n }[]\n> => callPrivate(credential, 'GET', `/futures/${settle}/orders`, params);\n\n/**\n * 获取合约账号\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%90%88%E7%BA%A6%E8%B4%A6%E5%8F%B7\n */\nexport const getFuturesAccounts = (\n credential: ICredential,\n settle: string,\n): Promise<{\n user: number;\n currency: string;\n total: string;\n unrealised_pnl: string;\n position_margin: string;\n order_margin: string;\n available: string;\n point: string;\n bonus: string;\n in_dual_mode: boolean;\n enable_evolved_classic: boolean;\n history: {\n dnw: string;\n pnl: string;\n fee: string;\n refr: string;\n fund: string;\n point_dnw: string;\n point_fee: string;\n point_refr: string;\n bonus_dnw: string;\n bonus_offset: string;\n };\n}> => callPrivate(credential, 'GET', `/futures/${settle}/accounts`);\n\n/**\n * 合约交易下单\n *\n * 下单时指定的是合约张数 size ,而非币的数量,每一张合约对应的币的数量是合约详情接口里返回的 quanto_multiplier\n *\n * 0 成交的订单在撤单 10 分钟之后无法再获取到,会提到订单不存在\n *\n * 设置 reduce_only 为 true 可以防止在减仓的时候穿仓\n *\n * 单仓模式下,如果需要平仓,需要设置 size 为 0 ,close 为 true\n *\n * 双仓模式下,平仓需要使用 auto_size 来设置平仓方向,并同时设置 reduce_only 为 true,size 为 0\n *\n * 设置 stp_act 决定使用限制用户自成交的策略,详细用法参考body参数stp_act\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E4%B8%8B%E5%8D%95\n */\nexport const postFutureOrders = (\n credential: ICredential,\n settle: string,\n params: {\n contract: string;\n size: number;\n iceberg?: number;\n price?: string;\n close?: boolean;\n reduce_only?: boolean;\n tif?: string;\n text?: string;\n auto_size?: string;\n stp_act?: string;\n },\n): Promise<{\n label?: string;\n message?: string;\n detail?: string;\n id: number;\n user: number;\n contract: string;\n create_time: number;\n size: number;\n iceberg: number;\n left: number;\n price: string;\n fill_price: string;\n mkfr: string;\n tkfr: string;\n tif: string;\n refu: number;\n is_reduce_only: boolean;\n is_close: boolean;\n is_liq: boolean;\n text: string;\n status: string;\n finish_time: number;\n finish_as: string;\n stp_id: number;\n stp_act: string;\n amend_text: string;\n}> => callPrivate(credential, 'POST', `/futures/${settle}/orders`, params);\n\n/**\n * 撤销单个订单\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%92%A4%E9%94%80%E5%8D%95%E4%B8%AA%E8%AE%A2%E5%8D%95-2\n */\nexport const deleteFutureOrders = (credential: ICredential, settle: string, order_id: string): Promise<{}> =>\n callPrivate(credential, 'DELETE', `/futures/${settle}/orders/${order_id}`);\n\n/**\n * 提现\n *\n * POST /withdrawals\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%8F%90%E7%8E%B0\n */\nexport const postWithdrawals = (\n credential: ICredential,\n params: {\n withdraw_order_id?: string;\n amount: string;\n currency: string;\n address?: string;\n memo?: string;\n chain: string;\n },\n): Promise<{\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n}> => callPrivate(credential, 'POST', '/withdrawals', params);\n\n/**\n * 获取币种充值地址\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80\n */\nexport const getDepositAddress = (\n credential: ICredential,\n params: {\n currency: string;\n },\n): Promise<{\n currency: string;\n address: string;\n multichain_addresses: {\n chain: string;\n address: string;\n payment_id: string;\n payment_name: string;\n obtain_failed: boolean;\n }[];\n}> => callPrivate(credential, 'GET', '/wallet/deposit_address', params);\n\n/**\n * 创建新的子账户\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%88%9B%E5%BB%BA%E6%96%B0%E7%9A%84%E5%AD%90%E8%B4%A6%E6%88%B7\n */\nexport const getSubAccountList = (\n credential: ICredential,\n params?: {\n type?: string;\n },\n): Promise<\n {\n remark: string;\n login_name: string;\n password: string;\n email: string;\n state: number;\n type: number;\n user_id: number;\n create_time: number;\n }[]\n> => callPrivate(credential, 'GET', '/sub_accounts', params);\n\n/**\n * 获取充值记录\n *\n * 记录查询时间范围不允许超过 30 天\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%85%85%E5%80%BC%E8%AE%B0%E5%BD%95\n */\nexport const getDepositHistory = (\n credential: ICredential,\n params?: {\n currency?: string;\n from?: number;\n to?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<\n {\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n }[]\n> => callPrivate(credential, 'GET', '/wallet/deposits', params);\n\n/**\n * 获取提现记录\n *\n * 记录查询时间范围不允许超过 30 天\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80\n */\nexport const getWithdrawalHistory = (\n credential: ICredential,\n params?: {\n currency?: string;\n from?: number;\n to?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<\n {\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n }[]\n> => callPrivate(credential, 'GET', '/wallet/withdrawals', params);\n\n/**\n * 获取现货交易账户列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%8E%B0%E8%B4%A7%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E5%88%97%E8%A1%A8\n */\nexport const getSpotAccounts = (\n credential: ICredential,\n params?: {\n currency?: string;\n },\n): Promise<\n {\n currency: string;\n available: string;\n locked: string;\n update_id: string;\n }[]\n> => callPrivate(credential, 'GET', '/spot/accounts', params);\n\n/**\n * 交易账户互转\n *\n * POST /wallet/transfers\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E4%BA%92%E8%BD%AC\n */\nexport const postWalletTransfer = (\n credential: ICredential,\n params: {\n currency: string;\n from: string;\n to: string;\n amount: string;\n currency_pair?: string;\n settle?: string;\n },\n): Promise<{\n tx_id: string;\n}> => callPrivate(credential, 'POST', '/wallet/transfers', params);\n\n/**\n * 获取统一账户最多可转出\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E7%BB%9F%E4%B8%80%E8%B4%A6%E6%88%B7%E6%9C%80%E5%A4%9A%E5%8F%AF%E8%BD%AC%E5%87%BA\n */\nexport const getUnifiedTransferable = (\n credential: ICredential,\n params: {\n currency: string;\n },\n): Promise<{\n currency: string;\n amount: string;\n}> => callPrivate(credential, 'GET', `/unified/transferable`, params);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../src/api/public-api.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,WACtB,MAAM,WACL;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3C,QACD;IACE,MAAM,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB,EAAE,MAAM,CAAC;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,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eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC,CAC6C,CAAC"}
@@ -8,7 +8,7 @@ const http_client_1 = require("./http-client");
8
8
  *
9
9
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E6%89%80%E6%9C%89%E7%9A%84%E5%90%88%E7%BA%A6%E4%BF%A1%E6%81%AF
10
10
  */
11
- const getFuturesContracts = (settle, params) => (0, http_client_1.requestPublic)('GET', `/api/v4/futures/${settle}/contracts`, params);
11
+ const getFuturesContracts = (settle, params) => (0, http_client_1.requestPublic)('GET', `/futures/${settle}/contracts`, params);
12
12
  exports.getFuturesContracts = getFuturesContracts;
13
13
  /**
14
14
  * 合约市场历史资金费率
@@ -19,28 +19,28 @@ exports.getFuturesContracts = getFuturesContracts;
19
19
  *
20
20
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E5%B8%82%E5%9C%BA%E5%8E%86%E5%8F%B2%E8%B5%84%E9%87%91%E8%B4%B9%E7%8E%87
21
21
  */
22
- const getFutureFundingRate = (settle, params) => (0, http_client_1.requestPublic)('GET', `/api/v4/futures/${settle}/funding_rate`, params);
22
+ const getFutureFundingRate = (settle, params) => (0, http_client_1.requestPublic)('GET', `/futures/${settle}/funding_rate`, params);
23
23
  exports.getFutureFundingRate = getFutureFundingRate;
24
24
  /**
25
25
  * 查询合约市场深度信息
26
26
  *
27
27
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E5%B8%82%E5%9C%BA%E6%B7%B1%E5%BA%A6%E4%BF%A1%E6%81%AF
28
28
  */
29
- const getFuturesOrderBook = async (settle, params) => rate_limiter_1.rateLimiter.schedule(`futures-order-book:${settle}`, 200, 10000, () => (0, http_client_1.requestPublic)('GET', `/api/v4/futures/${settle}/order_book`, params));
29
+ const getFuturesOrderBook = async (settle, params) => rate_limiter_1.rateLimiter.schedule(`futures-order-book:${settle}`, 200, 10000, () => (0, http_client_1.requestPublic)('GET', `/futures/${settle}/order_book`, params));
30
30
  exports.getFuturesOrderBook = getFuturesOrderBook;
31
31
  /**
32
32
  * 获取所有合约交易行情统计
33
33
  *
34
34
  * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E6%89%80%E6%9C%89%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E8%A1%8C%E6%83%85%E7%BB%9F%E8%AE%A1
35
35
  */
36
- const getFuturesTickers = (settle, params) => (0, http_client_1.requestPublic)('GET', `/api/v4/futures/${settle}/tickers`, params);
36
+ const getFuturesTickers = (settle, params) => (0, http_client_1.requestPublic)('GET', `/futures/${settle}/tickers`, params);
37
37
  exports.getFuturesTickers = getFuturesTickers;
38
38
  /**
39
39
  * 获取交易对 ticker 信息
40
40
  *
41
41
  * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E4%BA%A4%E6%98%93%E5%AF%B9-ticker-%E4%BF%A1%E6%81%AF
42
42
  */
43
- const getSpotTickers = (params) => (0, http_client_1.requestPublic)('GET', `/api/v4/spot/tickers`, params);
43
+ const getSpotTickers = (params) => (0, http_client_1.requestPublic)('GET', `/spot/tickers`, params);
44
44
  exports.getSpotTickers = getSpotTickers;
45
45
  /**
46
46
  * 查询支持的所有现货交易对
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../../src/api/public-api.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAC7C,+CAA8C;AAE9C;;;;GA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';\n\n/**\n * 查询所有的合约信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E6%89%80%E6%9C%89%E7%9A%84%E5%90%88%E7%BA%A6%E4%BF%A1%E6%81%AF\n */\nexport const getFuturesContracts = (\n settle: string,\n params?: { limit?: number; offset?: number },\n): Promise<\n {\n name: string;\n type: string;\n quanto_multiplier: string;\n ref_discount_rate: string;\n order_price_deviate: string;\n maintenance_rate: string;\n mark_type: string;\n last_price: string;\n mark_price: string;\n index_price: string;\n funding_rate_indicative: string;\n mark_price_round: string;\n funding_offset: number;\n in_delisting: boolean;\n risk_limit_base: string;\n interest_rate: string;\n order_price_round: string;\n order_size_min: number;\n ref_rebate_rate: string;\n funding_interval: number;\n risk_limit_step: string;\n leverage_min: string;\n leverage_max: string;\n risk_limit_max: string;\n maker_fee_rate: string;\n taker_fee_rate: string;\n funding_rate: string;\n order_size_max: number;\n funding_next_apply: number;\n short_users: number;\n config_change_time: number;\n trade_size: number;\n position_size: number;\n long_users: number;\n funding_impact_value: string;\n orders_limit: number;\n trade_id: number;\n orderbook_id: number;\n enable_bonus: boolean;\n enable_credit: boolean;\n create_time: number;\n funding_cap_ratio: string;\n }[]\n> => requestPublic('GET', `/api/v4/futures/${settle}/contracts`, params);\n\n/**\n * 合约市场历史资金费率\n *\n * - Note: 该接口返回的数据是按照时间倒序排列的\n * - Note: limit 参数最大值为 1000\n * - Note: t 字段为秒级时间戳 (Unix Second),r 字段为资金费率 (0-1 单位)\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E5%B8%82%E5%9C%BA%E5%8E%86%E5%8F%B2%E8%B5%84%E9%87%91%E8%B4%B9%E7%8E%87\n */\nexport const getFutureFundingRate = (\n settle: string,\n params: { contract: string; limit?: number },\n): Promise<\n {\n t: number;\n r: string;\n }[]\n> => requestPublic('GET', `/api/v4/futures/${settle}/funding_rate`, params);\n\n/**\n * 查询合约市场深度信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E5%B8%82%E5%9C%BA%E6%B7%B1%E5%BA%A6%E4%BF%A1%E6%81%AF\n */\nexport const getFuturesOrderBook = async (\n settle: string,\n params: {\n contract: string;\n interval?: string;\n limit?: number;\n with_id?: boolean;\n },\n): Promise<{\n id: number;\n current: number;\n update: number;\n asks: {\n p: string;\n s: string;\n }[];\n bids: {\n p: string;\n s: string;\n }[];\n}> =>\n rateLimiter.schedule(`futures-order-book:${settle}`, 200, 10_000, () =>\n requestPublic('GET', `/api/v4/futures/${settle}/order_book`, params),\n );\n\n/**\n * 获取所有合约交易行情统计\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E6%89%80%E6%9C%89%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E8%A1%8C%E6%83%85%E7%BB%9F%E8%AE%A1\n */\nexport const getFuturesTickers = (\n settle: string,\n params?: { contract?: string },\n): Promise<\n {\n contract: string;\n last: string;\n change_percentage: string;\n total_size: string;\n low_24h: string;\n high_24h: string;\n volume_24h: string;\n volume_24h_btc: string;\n volume_24h_usd: string;\n volume_24h_base: string;\n volume_24h_quote: string;\n volume_24h_settle: string;\n mark_price: string;\n funding_rate: string;\n funding_rate_indicative: string;\n index_price: string;\n quanto_base_rate: string;\n basis_rate: string;\n basis_value: string;\n lowest_ask: string;\n highest_bid: string;\n }[]\n> => requestPublic('GET', `/api/v4/futures/${settle}/tickers`, params);\n\n/**\n * 获取交易对 ticker 信息\n *\n * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E4%BA%A4%E6%98%93%E5%AF%B9-ticker-%E4%BF%A1%E6%81%AF\n */\nexport const getSpotTickers = (params: {\n currency_pair?: string;\n timezone?: string;\n}): Promise<\n Array<{\n currency_pair: string;\n last: string;\n lowest_ask: string;\n lowest_size: string;\n highest_bid: string;\n highest_size: string;\n change_percentage: string;\n change_utc0: string;\n change_utc8: string;\n base_volume: string;\n quote_volume: string;\n high_24h: string;\n low_24h: string;\n etf_net_value: string;\n etf_pre_net_value: string;\n etf_pre_timestamp: string;\n etf_leverage: string;\n }>\n> => requestPublic('GET', `/api/v4/spot/tickers`, params);\n\n/**\n * 查询支持的所有现货交易对\n * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E6%94%AF%E6%8C%81%E7%9A%84%E6%89%80%E6%9C%89%E4%BA%A4%E6%98%93%E5%AF%B9\n */\nexport const getSpotCurrencyPairs = (): Promise<\n Array<{\n id: string;\n base: string;\n base_name: string;\n quote: string;\n quote_name: string;\n fee: string;\n min_base_amount: string;\n min_quote_amount: string;\n max_base_amount: string;\n max_quote_amount: string;\n amount_precision: Number;\n precision: Number;\n trade_status: string;\n sell_start: Number;\n buy_start: number;\n delisting_time: number;\n trade_url: string;\n st_tag: boolean;\n }>\n> => requestPublic('GET', `/spot/currency_pairs`);\n"]}
1
+ {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../../src/api/public-api.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAC7C,+CAA8C;AAE9C;;;;GAIG;AACI,MAAM,mBAAmB,GAAG,CACjC,MAAc,EACd,MAA4C,EA8C5C,EAAE,CAAC,IAAA,2BAAa,EAAC,KAAK,EAAE,YAAY,MAAM,YAAY,EAAE,MAAM,CAAC,CAAC;AAhDrD,QAAA,mBAAmB,uBAgDkC;AAElE;;;;;;;;GAQG;AACI,MAAM,oBAAoB,GAAG,CAClC,MAAc,EACd,MAA4C,EAM5C,EAAE,CAAC,IAAA,2BAAa,EAAC,KAAK,EAAE,YAAY,MAAM,eAAe,EAAE,MAAM,CAAC,CAAC;AARxD,QAAA,oBAAoB,wBAQoC;AAErE;;;;GAIG;AACI,MAAM,mBAAmB,GAAG,KAAK,EACtC,MAAc,EACd,MAKC,EAaA,EAAE,CACH,0BAAW,CAAC,QAAQ,CAAC,sBAAsB,MAAM,EAAE,EAAE,GAAG,EAAE,KAAM,EAAE,GAAG,EAAE,CACrE,IAAA,2BAAa,EAAC,KAAK,EAAE,YAAY,MAAM,aAAa,EAAE,MAAM,CAAC,CAC9D,CAAC;AAvBS,QAAA,mBAAmB,uBAuB5B;AAEJ;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,CAC/B,MAAc,EACd,MAA8B,EAyB9B,EAAE,CAAC,IAAA,2BAAa,EAAC,KAAK,EAAE,YAAY,MAAM,UAAU,EAAE,MAAM,CAAC,CAAC;AA3BnD,QAAA,iBAAiB,qBA2BkC;AAEhE;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAAC,MAG9B,EAoBC,EAAE,CAAC,IAAA,2BAAa,EAAC,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;AAvBtC,QAAA,cAAc,kBAuBwB;AAEnD;;;GAGG;AACI,MAAM,oBAAoB,GAAG,GAqBlC,EAAE,CAAC,IAAA,2BAAa,EAAC,KAAK,EAAE,sBAAsB,CAAC,CAAC;AArBrC,QAAA,oBAAoB,wBAqBiB","sourcesContent":["import { rateLimiter } from './rate-limiter';\nimport { requestPublic } from './http-client';\n\n/**\n * 查询所有的合约信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E6%89%80%E6%9C%89%E7%9A%84%E5%90%88%E7%BA%A6%E4%BF%A1%E6%81%AF\n */\nexport const getFuturesContracts = (\n settle: string,\n params?: { limit?: number; offset?: number },\n): Promise<\n {\n name: string;\n type: string;\n quanto_multiplier: string;\n ref_discount_rate: string;\n order_price_deviate: string;\n maintenance_rate: string;\n mark_type: string;\n last_price: string;\n mark_price: string;\n index_price: string;\n funding_rate_indicative: string;\n mark_price_round: string;\n funding_offset: number;\n in_delisting: boolean;\n risk_limit_base: string;\n interest_rate: string;\n order_price_round: string;\n order_size_min: number;\n ref_rebate_rate: string;\n funding_interval: number;\n risk_limit_step: string;\n leverage_min: string;\n leverage_max: string;\n risk_limit_max: string;\n maker_fee_rate: string;\n taker_fee_rate: string;\n funding_rate: string;\n order_size_max: number;\n funding_next_apply: number;\n short_users: number;\n config_change_time: number;\n trade_size: number;\n position_size: number;\n long_users: number;\n funding_impact_value: string;\n orders_limit: number;\n trade_id: number;\n orderbook_id: number;\n enable_bonus: boolean;\n enable_credit: boolean;\n create_time: number;\n funding_cap_ratio: string;\n }[]\n> => requestPublic('GET', `/futures/${settle}/contracts`, params);\n\n/**\n * 合约市场历史资金费率\n *\n * - Note: 该接口返回的数据是按照时间倒序排列的\n * - Note: limit 参数最大值为 1000\n * - Note: t 字段为秒级时间戳 (Unix Second),r 字段为资金费率 (0-1 单位)\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E5%B8%82%E5%9C%BA%E5%8E%86%E5%8F%B2%E8%B5%84%E9%87%91%E8%B4%B9%E7%8E%87\n */\nexport const getFutureFundingRate = (\n settle: string,\n params: { contract: string; limit?: number },\n): Promise<\n {\n t: number;\n r: string;\n }[]\n> => requestPublic('GET', `/futures/${settle}/funding_rate`, params);\n\n/**\n * 查询合约市场深度信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E5%B8%82%E5%9C%BA%E6%B7%B1%E5%BA%A6%E4%BF%A1%E6%81%AF\n */\nexport const getFuturesOrderBook = async (\n settle: string,\n params: {\n contract: string;\n interval?: string;\n limit?: number;\n with_id?: boolean;\n },\n): Promise<{\n id: number;\n current: number;\n update: number;\n asks: {\n p: string;\n s: string;\n }[];\n bids: {\n p: string;\n s: string;\n }[];\n}> =>\n rateLimiter.schedule(`futures-order-book:${settle}`, 200, 10_000, () =>\n requestPublic('GET', `/futures/${settle}/order_book`, params),\n );\n\n/**\n * 获取所有合约交易行情统计\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E6%89%80%E6%9C%89%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E8%A1%8C%E6%83%85%E7%BB%9F%E8%AE%A1\n */\nexport const getFuturesTickers = (\n settle: string,\n params?: { contract?: string },\n): Promise<\n {\n contract: string;\n last: string;\n change_percentage: string;\n total_size: string;\n low_24h: string;\n high_24h: string;\n volume_24h: string;\n volume_24h_btc: string;\n volume_24h_usd: string;\n volume_24h_base: string;\n volume_24h_quote: string;\n volume_24h_settle: string;\n mark_price: string;\n funding_rate: string;\n funding_rate_indicative: string;\n index_price: string;\n quanto_base_rate: string;\n basis_rate: string;\n basis_value: string;\n lowest_ask: string;\n highest_bid: string;\n }[]\n> => requestPublic('GET', `/futures/${settle}/tickers`, params);\n\n/**\n * 获取交易对 ticker 信息\n *\n * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E4%BA%A4%E6%98%93%E5%AF%B9-ticker-%E4%BF%A1%E6%81%AF\n */\nexport const getSpotTickers = (params: {\n currency_pair?: string;\n timezone?: string;\n}): Promise<\n Array<{\n currency_pair: string;\n last: string;\n lowest_ask: string;\n lowest_size: string;\n highest_bid: string;\n highest_size: string;\n change_percentage: string;\n change_utc0: string;\n change_utc8: string;\n base_volume: string;\n quote_volume: string;\n high_24h: string;\n low_24h: string;\n etf_net_value: string;\n etf_pre_net_value: string;\n etf_pre_timestamp: string;\n etf_leverage: string;\n }>\n> => requestPublic('GET', `/spot/tickers`, params);\n\n/**\n * 查询支持的所有现货交易对\n * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E6%94%AF%E6%8C%81%E7%9A%84%E6%89%80%E6%9C%89%E4%BA%A4%E6%98%93%E5%AF%B9\n */\nexport const getSpotCurrencyPairs = (): Promise<\n Array<{\n id: string;\n base: string;\n base_name: string;\n quote: string;\n quote_name: string;\n fee: string;\n min_base_amount: string;\n min_quote_amount: string;\n max_base_amount: string;\n max_quote_amount: string;\n amount_precision: Number;\n precision: Number;\n trade_status: string;\n sell_start: Number;\n buy_start: number;\n delisting_time: number;\n trade_url: string;\n st_tag: boolean;\n }>\n> => requestPublic('GET', `/spot/currency_pairs`);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"product.d.ts","sourceRoot":"","sources":["../../../src/services/markets/product.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY,yEAA6C,CAAC;AAEvE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;IAkDxB,CAAC"}
1
+ {"version":3,"file":"product.d.ts","sourceRoot":"","sources":["../../../src/services/markets/product.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY,yEAAmD,CAAC;AAE7E,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;IAkDxB,CAAC"}
@@ -5,7 +5,7 @@ const data_product_1 = require("@yuants/data-product");
5
5
  const protocol_1 = require("@yuants/protocol");
6
6
  const utils_1 = require("@yuants/utils");
7
7
  const public_api_1 = require("../../api/public-api");
8
- exports.productCache = (0, data_product_1.createProductCache)(protocol_1.Terminal.fromNodeEnv());
8
+ exports.productCache = (0, data_product_1.createClientProductCache)(protocol_1.Terminal.fromNodeEnv());
9
9
  const listProducts = async () => {
10
10
  const [futureProducts, spotProducts] = await Promise.all([
11
11
  (0, public_api_1.getFuturesContracts)('usdt', {}),
@@ -1 +1 @@
1
- {"version":3,"file":"product.js","sourceRoot":"","sources":["../../../src/services/markets/product.ts"],"names":[],"mappings":";;;AAAA,uDAA0D;AAC1D,+CAA4C;AAC5C,yCAA2C;AAC3C,qDAAiF;AAEpE,QAAA,YAAY,GAAG,IAAA,iCAAkB,EAAC,mBAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;AAEhE,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE;IACrC,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACvD,IAAA,gCAAmB,EAAC,MAAM,EAAE,EAAE,CAAC;QAC/B,IAAA,iCAAoB,GAAE;KACvB,CAAC,CA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d,IAAI,EAAE,EAAE;QACR,gBAAgB,EAAE,EAAE;QACpB,WAAW,EAAE,CAAC;QACd,gBAAgB,EAAE,CAAC;QACnB,iBAAiB,EAAE,CAAC;QACpB,YAAY,EAAE,CAAC;QACf,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,KAAK;QAClB,SAAS,EAAE,gBAAgB;QAC3B,gBAAgB,EAAE,KAAK;KACxB,CAAC,CAAC,CAAC;IAEJ,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;AAC1B,CAAC,CAAC;AAlDW,QAAA,YAAY,gBAkDvB","sourcesContent":["import { createProductCache } from '@yuants/data-product';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { getFuturesContracts, getSpotCurrencyPairs } from '../../api/public-api';\n\nexport const productCache = createProductCache(Terminal.fromNodeEnv());\n\nexport const listProducts = async () => {\n const [futureProducts, spotProducts] = await Promise.all([\n getFuturesContracts('usdt', {}),\n getSpotCurrencyPairs(),\n ]);\n const fps = futureProducts.map((contract) => {\n const [base, quote] = contract.name.split('_');\n return {\n datasource_id: 'GATE',\n product_id: encodePath('GATE', 'FUTURE', contract.name),\n base_currency: base,\n quote_currency: quote,\n value_scale: Number(contract.quanto_multiplier),\n price_step: Number(contract.order_price_round),\n volume_step: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 1 / Number(contract.leverage_max),\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: true,\n market_id: 'GATE/USDT-FUTURE',\n no_interest_rate: false,\n };\n });\n const sps = spotProducts.map((spot) => ({\n datasource_id: 'GATE',\n product_id: encodePath('GATE', 'SPOT', spot.id),\n base_currency: spot.base,\n quote_currency: spot.quote,\n value_scale: 1,\n price_step: Number(`1e-${spot.precision}`),\n volume_step: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 0,\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: false,\n market_id: 'GATE/USDT-SPOT',\n no_interest_rate: false,\n }));\n\n return [...fps, ...sps];\n};\n"]}
1
+ {"version":3,"file":"product.js","sourceRoot":"","sources":["../../../src/services/markets/product.ts"],"names":[],"mappings":";;;AAAA,uDAAgE;AAChE,+CAA4C;AAC5C,yCAA2C;AAC3C,qDAAiF;AAEpE,QAAA,YAAY,GAAG,IAAA,uCAAwB,EAAC,mBAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;AAEtE,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE;IACrC,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACvD,IAAA,gCAAmB,EAAC,MAAM,EAAE,EAAE,CAAC;QAC/B,IAAA,iCAAoB,GAAE;KACvB,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC1C,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/C,OAAO;YACL,aAAa,EAAE,MAAM;YACrB,UAAU,EAAE,IAAA,kBAAU,EAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC;YACvD,aAAa,EAAE,IAAI;YACnB,cAAc,EAAE,KAAK;YACrB,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC;YAC/C,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC;YAC9C,WAAW,EAAE,CAAC;YACd,IAAI,EAAE,EAAE;YACR,gBAAgB,EAAE,EAAE;YACpB,WAAW,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC;YAC9C,gBAAgB,EAAE,CAAC;YACnB,iBAAiB,EAAE,CAAC;YACpB,YAAY,EAAE,CAAC;YACf,UAAU,EAAE,CAAC;YACb,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,kBAAkB;YAC7B,gBAAgB,EAAE,KAAK;SACxB,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACtC,aAAa,EAAE,MAAM;QACrB,UAAU,EAAE,IAAA,kBAAU,EAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;QAC/C,aAAa,EAAE,IAAI,CAAC,IAAI;QACxB,cAAc,EAAE,IAAI,CAAC,KAAK;QAC1B,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QAC1C,WAAW,EAAE,CAAC;QACd,IAAI,EAAE,EAAE;QACR,gBAAgB,EAAE,EAAE;QACpB,WAAW,EAAE,CAAC;QACd,gBAAgB,EAAE,CAAC;QACnB,iBAAiB,EAAE,CAAC;QACpB,YAAY,EAAE,CAAC;QACf,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,KAAK;QAClB,SAAS,EAAE,gBAAgB;QAC3B,gBAAgB,EAAE,KAAK;KACxB,CAAC,CAAC,CAAC;IAEJ,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;AAC1B,CAAC,CAAC;AAlDW,QAAA,YAAY,gBAkDvB","sourcesContent":["import { createClientProductCache } from '@yuants/data-product';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { getFuturesContracts, getSpotCurrencyPairs } from '../../api/public-api';\n\nexport const productCache = createClientProductCache(Terminal.fromNodeEnv());\n\nexport const listProducts = async () => {\n const [futureProducts, spotProducts] = await Promise.all([\n getFuturesContracts('usdt', {}),\n getSpotCurrencyPairs(),\n ]);\n const fps = futureProducts.map((contract) => {\n const [base, quote] = contract.name.split('_');\n return {\n datasource_id: 'GATE',\n product_id: encodePath('GATE', 'FUTURE', contract.name),\n base_currency: base,\n quote_currency: quote,\n value_scale: Number(contract.quanto_multiplier),\n price_step: Number(contract.order_price_round),\n volume_step: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 1 / Number(contract.leverage_max),\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: true,\n market_id: 'GATE/USDT-FUTURE',\n no_interest_rate: false,\n };\n });\n const sps = spotProducts.map((spot) => ({\n datasource_id: 'GATE',\n product_id: encodePath('GATE', 'SPOT', spot.id),\n base_currency: spot.base,\n quote_currency: spot.quote,\n value_scale: 1,\n price_step: Number(`1e-${spot.precision}`),\n volume_step: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 0,\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: false,\n market_id: 'GATE/USDT-SPOT',\n no_interest_rate: false,\n }));\n\n return [...fps, ...sps];\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"listOrders.d.ts","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAoB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAatE,eAAO,MAAM,UAAU,eAAsB,WAAW,sBAqBvD,CAAC;AAEF,eAAO,MAAM,oBAAoB,eACnB,WAAW,cACX,MAAM,KACjB,QAAQ,MAAM,EAAE,CAWlB,CAAC"}
1
+ {"version":3,"file":"listOrders.d.ts","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAoB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAatE,eAAO,MAAM,UAAU,eAAsB,WAAW,sBAsBvD,CAAC;AAEF,eAAO,MAAM,oBAAoB,eACnB,WAAW,cACX,MAAM,KACjB,QAAQ,MAAM,EAAE,CAWlB,CAAC"}
@@ -12,6 +12,8 @@ const resolveOrderDirection = (order) => {
12
12
  };
13
13
  const listOrders = async (credential) => {
14
14
  const orders = await (0, private_api_1.getFuturesOrders)(credential, 'usdt', { status: 'open' });
15
+ if (Array.isArray(orders) === false)
16
+ throw (0, utils_1.newError)('InvalidResponse', { orders });
15
17
  return orders.map((order) => {
16
18
  const volume = Math.abs(order.size);
17
19
  const leftVolume = typeof order.left === 'number' ? Math.abs(order.left) : undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"listOrders.js","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":";;;AACA,uDAAsE;AACtE,yCAA2C;AAI3C,MAAM,qBAAqB,GAAG,CAAC,KAA0C,EAAkB,EAAE;IAC3F,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;IAC9B,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;KAC9C;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;AAC7C,CAAC,CAAC;AAEK,MAAM,UAAU,GAAG,KAAK,EAAE,UAAuB,EAAE,EAAE;IAC1D,MAAM,MAAM,GAAG,MAAM,IAAA,8BAAgB,EAAC,UAAU,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9E,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAU,EAAE;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CA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EAAC,UAAU,CAAC,CAAC;QAC5C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;KAClE;IACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC;AAdW,QAAA,oBAAoB,wBAc/B","sourcesContent":["import { IOrder } from '@yuants/data-order';\nimport { getFuturesOrders, ICredential } from '../../api/private-api';\nimport { decodePath } from '@yuants/utils';\n\ntype OrderDirection = 'OPEN_LONG' | 'OPEN_SHORT' | 'CLOSE_LONG' | 'CLOSE_SHORT';\n\nconst resolveOrderDirection = (order: { size: number; is_close: boolean }): OrderDirection => {\n const isLong = order.size > 0;\n if (order.is_close) {\n return isLong ? 'CLOSE_SHORT' : 'CLOSE_LONG';\n }\n return isLong ? 'OPEN_LONG' : 'OPEN_SHORT';\n};\n\nexport const listOrders = async (credential: ICredential) => {\n const orders = await getFuturesOrders(credential, 'usdt', { status: 'open' });\n return orders.map((order): IOrder => {\n const volume = Math.abs(order.size);\n const leftVolume = typeof order.left === 'number' ? Math.abs(order.left) : undefined;\n const traded_volume = leftVolume !== undefined ? Math.max(volume - leftVolume, 0) : undefined;\n const price = Number(order.price);\n const traded_price = Number(order.fill_price);\n return {\n order_id: `${order.id}`,\n account_id: '',\n product_id: order.contract,\n order_direction: resolveOrderDirection(order),\n volume,\n price: Number.isFinite(price) ? price : undefined,\n submit_at: order.create_time * 1000,\n traded_volume,\n traded_price: Number.isFinite(traded_price) ? traded_price : undefined,\n order_status: order.status,\n };\n });\n};\n\nexport const getOrdersByProductId = async function (\n credential: ICredential,\n product_id: string,\n): Promise<IOrder[]> {\n const [_, instType] = decodePath(product_id); // GATE/FUTURE/ADAUSDT\n // if (instType === 'SPOT') {\n // const orders = await listSpotOrders(credential);\n // return orders.filter((order) => order.product_id === product_id);\n // }\n if (instType === 'FUTURE') {\n const orders = await listOrders(credential);\n return orders.filter((order) => order.product_id === product_id);\n }\n throw new Error(`Unsupported instType: ${instType}`);\n};\n"]}
1
+ {"version":3,"file":"listOrders.js","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":";;;AACA,uDAAsE;AACtE,yCAAqD;AAIrD,MAAM,qBAAqB,GAAG,CAAC,KAA0C,EAAkB,EAAE;IAC3F,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;IAC9B,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;KAC9C;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;AAC7C,CAAC,CAAC;AAEK,MAAM,UAAU,GAAG,KAAK,EAAE,UAAuB,EAAE,EAAE;IAC1D,MAAM,MAAM,GAAG,MAAM,IAAA,8BAAgB,EAAC,UAAU,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9E,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK;QAAE,MAAM,IAAA,gBAAQ,EAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACnF,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAU,EAAE;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACrF,MAAM,aAAa,GAAG,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC,CAAC,CAA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AC,CAAC;AAdW,QAAA,oBAAoB,wBAc/B","sourcesContent":["import { IOrder } from '@yuants/data-order';\nimport { getFuturesOrders, ICredential } from '../../api/private-api';\nimport { decodePath, newError } from '@yuants/utils';\n\ntype OrderDirection = 'OPEN_LONG' | 'OPEN_SHORT' | 'CLOSE_LONG' | 'CLOSE_SHORT';\n\nconst resolveOrderDirection = (order: { size: number; is_close: boolean }): OrderDirection => {\n const isLong = order.size > 0;\n if (order.is_close) {\n return isLong ? 'CLOSE_SHORT' : 'CLOSE_LONG';\n }\n return isLong ? 'OPEN_LONG' : 'OPEN_SHORT';\n};\n\nexport const listOrders = async (credential: ICredential) => {\n const orders = await getFuturesOrders(credential, 'usdt', { status: 'open' });\n if (Array.isArray(orders) === false) throw newError('InvalidResponse', { orders });\n return orders.map((order): IOrder => {\n const volume = Math.abs(order.size);\n const leftVolume = typeof order.left === 'number' ? Math.abs(order.left) : undefined;\n const traded_volume = leftVolume !== undefined ? Math.max(volume - leftVolume, 0) : undefined;\n const price = Number(order.price);\n const traded_price = Number(order.fill_price);\n return {\n order_id: `${order.id}`,\n account_id: '',\n product_id: order.contract,\n order_direction: resolveOrderDirection(order),\n volume,\n price: Number.isFinite(price) ? price : undefined,\n submit_at: order.create_time * 1000,\n traded_volume,\n traded_price: Number.isFinite(traded_price) ? traded_price : undefined,\n order_status: order.status,\n };\n });\n};\n\nexport const getOrdersByProductId = async function (\n credential: ICredential,\n product_id: string,\n): Promise<IOrder[]> {\n const [_, instType] = decodePath(product_id); // GATE/FUTURE/ADAUSDT\n // if (instType === 'SPOT') {\n // const orders = await listSpotOrders(credential);\n // return orders.filter((order) => order.product_id === product_id);\n // }\n if (instType === 'FUTURE') {\n const orders = await listOrders(credential);\n return orders.filter((order) => order.product_id === product_id);\n }\n throw new Error(`Unsupported instType: ${instType}`);\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuants/vendor-gate",
3
- "version": "0.4.18",
3
+ "version": "0.4.20",
4
4
  "main": "lib/index.js",
5
5
  "files": [
6
6
  "lib",
@@ -11,14 +11,14 @@
11
11
  "@yuants/cache": "0.3.3",
12
12
  "@yuants/protocol": "0.53.2",
13
13
  "@yuants/transfer": "0.2.39",
14
- "@yuants/data-account": "0.8.4",
14
+ "@yuants/data-account": "0.9.0",
15
15
  "@yuants/data-order": "0.6.6",
16
16
  "@yuants/sql": "0.9.30",
17
17
  "@yuants/data-product": "0.5.0",
18
18
  "@yuants/utils": "0.14.0",
19
19
  "@yuants/data-series": "0.3.51",
20
20
  "@yuants/data-interest-rate": "0.1.48",
21
- "@yuants/exchange": "0.3.1",
21
+ "@yuants/exchange": "0.4.0",
22
22
  "@yuants/data-quote": "0.2.43",
23
23
  "rxjs": "~7.5.6"
24
24
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "apps/vendor-gate/AGENTS.md": "59be8d734f8a91ae5f7377e7c688f1fccb8641b7",
3
- "apps/vendor-gate/CHANGELOG.json": "32fa927ca61f02b55a52aa0894bfe99856d068e5",
4
- "apps/vendor-gate/CHANGELOG.md": "1ce1276a5e60ca24b2b1add15d57517882c33386",
3
+ "apps/vendor-gate/CHANGELOG.json": "0963c4a2a98ed1c9e6fda0788b796ae7fdecd780",
4
+ "apps/vendor-gate/CHANGELOG.md": "4b4bddf5492ba51c5b417fb578467d34b3264817",
5
5
  "apps/vendor-gate/README.md": "ea5ee3a61cd87d9104d729902dfaccac9b9913e0",
6
6
  "apps/vendor-gate/SESSION_NOTES.md": "768c89019ebca263968450d853c8038b0d56f619",
7
7
  "apps/vendor-gate/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c",
@@ -9,10 +9,10 @@
9
9
  "apps/vendor-gate/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
10
10
  "apps/vendor-gate/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
11
11
  "apps/vendor-gate/etc/vendor-gate.api.md": "970682cd589432de553cc5cee2a0abe73814a515",
12
- "apps/vendor-gate/package.json": "c89d41b5bd3da8401aab853dc79b92096085372d",
13
- "apps/vendor-gate/src/api/http-client.ts": "013dcdfebaf136c83274638ceb697146a8e3f218",
14
- "apps/vendor-gate/src/api/private-api.ts": "644570bc10fd22b7e9d4d6a0267397af9d5510f0",
15
- "apps/vendor-gate/src/api/public-api.ts": "faaad3eeeaa9a32e2b96a38a111878011867bd1e",
12
+ "apps/vendor-gate/package.json": "edbe9859e0c68be0ba58c985263830ca22a6f7e2",
13
+ "apps/vendor-gate/src/api/http-client.ts": "97e0e70454c6072f388f90442ec4afabe6feb93b",
14
+ "apps/vendor-gate/src/api/private-api.ts": "23714cd97a56a34fd0e52d752296e0ae5ac47592",
15
+ "apps/vendor-gate/src/api/public-api.ts": "ee1a246a8833a7d9bb06e829b09a3bd80e0d86bf",
16
16
  "apps/vendor-gate/src/api/rate-limiter.ts": "047c51029ffcaf98190cfd04d96816bbced5fa7c",
17
17
  "apps/vendor-gate/src/index.ts": "31888627bccab532d55bd91833d80c72a4afae9b",
18
18
  "apps/vendor-gate/src/services/accounts/future.ts": "4e762c193fe8ae4dbe3ae15d45b03bdf0a0fb8c8",
@@ -22,10 +22,10 @@
22
22
  "apps/vendor-gate/src/services/default-credential.ts": "b9ffa157b818148450bfaaf4851597e91901190c",
23
23
  "apps/vendor-gate/src/services/exchange.ts": "5672321dea53f8c4592d8d2163de47075ba8fef5",
24
24
  "apps/vendor-gate/src/services/markets/interest-rate.ts": "e669eb1d664448f309bb062907b273157d1c111e",
25
- "apps/vendor-gate/src/services/markets/product.ts": "64b6c0758e022a0b2c42d69b35bd5d7bd1bfa9c3",
25
+ "apps/vendor-gate/src/services/markets/product.ts": "217bf64b307adca4c251333462b75f73d0d85e83",
26
26
  "apps/vendor-gate/src/services/markets/quote.ts": "1624d58b9c607ae01300de292de3ed49a2f2e037",
27
27
  "apps/vendor-gate/src/services/orders/cancelOrder.ts": "7dfdd30eaac89742f1050bf0fb47d8053ccecb28",
28
- "apps/vendor-gate/src/services/orders/listOrders.ts": "9e4bd2c53cd768d609d1368fd37ff783f9b4d52f",
28
+ "apps/vendor-gate/src/services/orders/listOrders.ts": "cc59845c6ab9acb6b0513866aff56031a68328c2",
29
29
  "apps/vendor-gate/src/services/orders/submitOrder.ts": "321398ad18bb4012d2a40e4f704bc827ccfaff93",
30
30
  "apps/vendor-gate/src/services/transfer.ts": "cf7d6cbcef3fe217b607f0bba7719d62ac603d66",
31
31
  "apps/vendor-gate/tsconfig.json": "81da8f78196974b5d15da0edb6b2d9f48641063c",
@@ -33,14 +33,14 @@
33
33
  "libraries/cache/temp/package-deps.json": "a4afa15e6462983f9d3735d31dc1ed8a683fb4dc",
34
34
  "libraries/protocol/temp/package-deps.json": "0bd43721e96039b52d7b59c834dc6df45cf75e3f",
35
35
  "libraries/transfer/temp/package-deps.json": "36c58299bd6c841c5ba7252d71881a881570d08c",
36
- "libraries/data-account/temp/package-deps.json": "ae6b0c69040d0d1989525e843717b6e303d95ef2",
36
+ "libraries/data-account/temp/package-deps.json": "711aeba1f1f5f03741475a4290e56d18b39e5305",
37
37
  "libraries/data-order/temp/package-deps.json": "2adac9fc0423f9b1b7ddaa8946ab7af374cc22e1",
38
38
  "libraries/sql/temp/package-deps.json": "4a9a7ec55f04b20459e664e81e76fa74b6c77b39",
39
39
  "libraries/data-product/temp/package-deps.json": "a03f08f30800d5fb52c5d019bda4f8e7ec04e344",
40
40
  "libraries/utils/temp/package-deps.json": "6d58e9b325e8d16de8a878c32010f626b12a01da",
41
41
  "libraries/data-series/temp/package-deps.json": "c89ebffe302757903aa54eff78f76cb855486b8c",
42
42
  "libraries/data-interest-rate/temp/package-deps.json": "cef1e1cb0116ad593c24635684e0cbf03488d67c",
43
- "libraries/exchange/temp/package-deps.json": "ee94ff641b8afcd48484829a1d6d66ffede2a69c",
43
+ "libraries/exchange/temp/package-deps.json": "d30a450879e4d67f56466262bd88a72506594d68",
44
44
  "libraries/data-quote/temp/package-deps.json": "34d079eab44d2bf65e07b112ac2099c6e92a015e",
45
45
  "libraries/extension/temp/package-deps.json": "9569c553c2f9a7d50b70d8f101fc2d3825aaccb9",
46
46
  "tools/toolkit/temp/package-deps.json": "23e053490eb8feade23e4d45de4e54883e322711"