@andy-liquid-labs/lighter-ts-sdk 1.0.0
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.
- package/README.md +381 -0
- package/dist/index.d.mts +3686 -0
- package/dist/index.d.ts +3686 -0
- package/dist/index.js +6168 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5939 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +57 -0
- package/src/api/exchange/change-account-tier.ts +38 -0
- package/src/api/exchange/fastwithdraw.ts +38 -0
- package/src/api/exchange/index.ts +7 -0
- package/src/api/exchange/notification-ack.ts +36 -0
- package/src/api/exchange/send-tx-batch.ts +53 -0
- package/src/api/exchange/send-tx.ts +105 -0
- package/src/api/exchange/tokens-create.ts +50 -0
- package/src/api/exchange/tokens-revoke.ts +38 -0
- package/src/api/index.ts +3 -0
- package/src/api/info/account-by-l1-address.ts +23 -0
- package/src/api/info/account.ts +80 -0
- package/src/api/info/announcement.ts +24 -0
- package/src/api/info/api-keys.ts +32 -0
- package/src/api/info/asset-details.ts +42 -0
- package/src/api/info/candles.ts +31 -0
- package/src/api/info/exchange-stats.ts +16 -0
- package/src/api/info/fastbridge-info.ts +15 -0
- package/src/api/info/funding-rates.ts +22 -0
- package/src/api/info/fundings.ts +29 -0
- package/src/api/info/index.ts +20 -0
- package/src/api/info/next-nonce.ts +26 -0
- package/src/api/info/order-book-details.ts +125 -0
- package/src/api/info/order-books.ts +23 -0
- package/src/api/info/recent-trades.ts +24 -0
- package/src/api/info/root-info.ts +13 -0
- package/src/api/info/root-status.ts +13 -0
- package/src/api/info/tx-from-l1-hash.ts +20 -0
- package/src/api/info/tx.ts +45 -0
- package/src/api/info/txs.ts +19 -0
- package/src/api/info/withdrawal-delay.ts +13 -0
- package/src/api/info-private/account-active-orders.ts +31 -0
- package/src/api/info-private/account-inactive-orders.ts +83 -0
- package/src/api/info-private/account-limits.ts +35 -0
- package/src/api/info-private/account-metadata.ts +43 -0
- package/src/api/info-private/deposit-history.ts +49 -0
- package/src/api/info-private/export.ts +41 -0
- package/src/api/info-private/fastwithdraw-info.ts +35 -0
- package/src/api/info-private/index.ts +18 -0
- package/src/api/info-private/l1-metadata.ts +35 -0
- package/src/api/info-private/liquidations.ts +96 -0
- package/src/api/info-private/pnl.ts +52 -0
- package/src/api/info-private/position-funding.ts +54 -0
- package/src/api/info-private/public-pools-metadata.ts +46 -0
- package/src/api/info-private/referral-points.ts +43 -0
- package/src/api/info-private/tokens.ts +44 -0
- package/src/api/info-private/trades.ts +66 -0
- package/src/api/info-private/transfer-fee-info.ts +37 -0
- package/src/api/info-private/transfer-history.ts +54 -0
- package/src/api/info-private/withdraw-history.ts +49 -0
- package/src/client/clientManager.ts +121 -0
- package/src/client/exchange-client.ts +637 -0
- package/src/client/http/client.ts +137 -0
- package/src/client/http/index.ts +6 -0
- package/src/client/http/interface.ts +89 -0
- package/src/client/index.ts +11 -0
- package/src/client/info-client.ts +383 -0
- package/src/client/info-private-client.ts +444 -0
- package/src/client/txClient.ts +597 -0
- package/src/client/ws-client.ts +457 -0
- package/src/crypto/ecgfp5.ts +722 -0
- package/src/crypto/goldilocks.ts +136 -0
- package/src/crypto/gorand.ts +777 -0
- package/src/crypto/index.ts +6 -0
- package/src/crypto/poseidon2.ts +365 -0
- package/src/crypto/scalar.ts +375 -0
- package/src/index.ts +112 -0
- package/src/signer/index.ts +5 -0
- package/src/signer/keyManager.ts +132 -0
- package/src/types/bridge.ts +24 -0
- package/src/types/constants.ts +252 -0
- package/src/types/errors.ts +168 -0
- package/src/types/index.ts +12 -0
- package/src/types/requests.ts +197 -0
- package/src/types/txInfo.ts +1277 -0
- package/src/types/txInfoPools.ts +502 -0
- package/src/types/txInfoSerializer.ts +348 -0
- package/src/types/ws.ts +407 -0
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import axios, { AxiosInstance } from "axios";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AccountActiveOrdersRequest,
|
|
5
|
+
AccountInactiveOrdersRequest,
|
|
6
|
+
AccountLimitsRequest,
|
|
7
|
+
AccountLimitsResponse,
|
|
8
|
+
AccountMetadataRequest,
|
|
9
|
+
AccountMetadataResponse,
|
|
10
|
+
DepositHistoryRequest,
|
|
11
|
+
DepositHistoryResponse,
|
|
12
|
+
ExportRequest,
|
|
13
|
+
ExportResponse,
|
|
14
|
+
FastWithdrawInfoRequest,
|
|
15
|
+
FastWithdrawInfoResponse,
|
|
16
|
+
getAccountActiveOrders,
|
|
17
|
+
getAccountInactiveOrders,
|
|
18
|
+
getAccountLimits,
|
|
19
|
+
getAccountMetadata,
|
|
20
|
+
getDepositHistory,
|
|
21
|
+
getExport,
|
|
22
|
+
getFastWithdrawInfo,
|
|
23
|
+
getL1Metadata,
|
|
24
|
+
getLiquidations,
|
|
25
|
+
getPnL,
|
|
26
|
+
getPositionFunding,
|
|
27
|
+
getPublicPools,
|
|
28
|
+
getReferralPoints,
|
|
29
|
+
getTokens,
|
|
30
|
+
getTrades,
|
|
31
|
+
getTransferFeeInfo,
|
|
32
|
+
getTransferHistory,
|
|
33
|
+
getWithdrawHistory,
|
|
34
|
+
L1MetadataRequest,
|
|
35
|
+
L1MetadataResponse,
|
|
36
|
+
LiquidationsRequest,
|
|
37
|
+
LiquidationsResponse,
|
|
38
|
+
Orders,
|
|
39
|
+
PnLRequest,
|
|
40
|
+
PnLResponse,
|
|
41
|
+
PositionFundingRequest,
|
|
42
|
+
PositionFundingResponse,
|
|
43
|
+
PublicPoolsRequest,
|
|
44
|
+
PublicPoolsResponse,
|
|
45
|
+
ReferralPointsRequest,
|
|
46
|
+
ReferralPointsResponse,
|
|
47
|
+
TokensRequest,
|
|
48
|
+
TokensResponse,
|
|
49
|
+
TradesRequest,
|
|
50
|
+
TradesResponse,
|
|
51
|
+
TransferFeeInfoRequest,
|
|
52
|
+
TransferFeeInfoResponse,
|
|
53
|
+
TransferHistoryRequest,
|
|
54
|
+
TransferHistoryResponse,
|
|
55
|
+
WithdrawHistoryRequest,
|
|
56
|
+
WithdrawHistoryResponse,
|
|
57
|
+
} from "../api/info-private";
|
|
58
|
+
import { TxClient } from "./txClient";
|
|
59
|
+
|
|
60
|
+
export interface InfoPrivateClientConfig {
|
|
61
|
+
baseURL?: string;
|
|
62
|
+
txClient: TxClient;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const DEFAULT_DEADLINE = 120;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* InfoPrivateClient - Client for private/authenticated info endpoints
|
|
69
|
+
*
|
|
70
|
+
* Provides access to API endpoints that require authentication.
|
|
71
|
+
* Authentication is handled automatically using the provided TxClient.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const txClient = createClient(httpClient, privateKey, chainId, apiKeyIndex, accountIndex);
|
|
76
|
+
* const client = new InfoPrivateClient({
|
|
77
|
+
* baseURL: "https://mainnet.zklighter.elliot.ai",
|
|
78
|
+
* txClient
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* const orders = await client.getAccountActiveOrders({
|
|
82
|
+
* account_index: 0,
|
|
83
|
+
* market_id: 1
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export class InfoPrivateClient {
|
|
88
|
+
private readonly baseURL: string;
|
|
89
|
+
private readonly axiosInstance: AxiosInstance;
|
|
90
|
+
private readonly txClient: TxClient;
|
|
91
|
+
|
|
92
|
+
constructor(config: InfoPrivateClientConfig) {
|
|
93
|
+
this.baseURL = config.baseURL || "https://mainnet.zklighter.elliot.ai";
|
|
94
|
+
this.txClient = config.txClient;
|
|
95
|
+
|
|
96
|
+
this.axiosInstance = this.createAxiosInstance();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private createAxiosInstance(): AxiosInstance {
|
|
100
|
+
return axios.create({
|
|
101
|
+
baseURL: this.baseURL,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get the axios instance for custom requests
|
|
107
|
+
*/
|
|
108
|
+
public getAxiosInstance(): AxiosInstance {
|
|
109
|
+
return this.axiosInstance;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Get active orders for an account in a specific market
|
|
114
|
+
* @param params - Account index and market ID to retrieve active orders for
|
|
115
|
+
* @returns List of active orders
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const orders = await client.getAccountActiveOrders({
|
|
119
|
+
* account_index: 0,
|
|
120
|
+
* market_id: 1
|
|
121
|
+
* });
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
public async getAccountActiveOrders(
|
|
125
|
+
params: AccountActiveOrdersRequest,
|
|
126
|
+
): Promise<Orders> {
|
|
127
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
128
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
129
|
+
return getAccountActiveOrders(this.axiosInstance, params, auth);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Get inactive orders for an account
|
|
134
|
+
* @param params - Account index and optional filters for inactive orders
|
|
135
|
+
* @returns List of inactive orders with pagination support
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* const orders = await client.getAccountInactiveOrders({
|
|
139
|
+
* account_index: 0,
|
|
140
|
+
* limit: 50,
|
|
141
|
+
* market_id: 1
|
|
142
|
+
* });
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
public async getAccountInactiveOrders(
|
|
146
|
+
params: AccountInactiveOrdersRequest,
|
|
147
|
+
): Promise<Orders> {
|
|
148
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
149
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
150
|
+
return getAccountInactiveOrders(this.axiosInstance, params, auth);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Get account limits and tier information
|
|
155
|
+
* @param params - Account index to retrieve limits for
|
|
156
|
+
* @returns Account limits including max LLP percentage, user tier, and pool creation permissions
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const limits = await client.getAccountLimits({ account_index: 0 });
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
public async getAccountLimits(
|
|
163
|
+
params: AccountLimitsRequest,
|
|
164
|
+
): Promise<AccountLimitsResponse> {
|
|
165
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
166
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
167
|
+
return getAccountLimits(this.axiosInstance, params, auth);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Get account metadata by index or L1 address
|
|
172
|
+
* @param params - Account index or L1 address to retrieve metadata for
|
|
173
|
+
* @returns Account metadata including account index, L1 address, and public key
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* const metadata = await client.getAccountMetadata({ account_index: 0 });
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
public async getAccountMetadata(
|
|
180
|
+
params: AccountMetadataRequest,
|
|
181
|
+
): Promise<AccountMetadataResponse> {
|
|
182
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
183
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
184
|
+
return getAccountMetadata(this.axiosInstance, params, auth);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Get L1 metadata for an address
|
|
189
|
+
* @param params - L1 address to retrieve metadata for
|
|
190
|
+
* @returns L1 metadata including all account indices associated with the address
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* const metadata = await client.getL1Metadata({ l1_address: '0x...' });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
public async getL1Metadata(
|
|
197
|
+
params: L1MetadataRequest,
|
|
198
|
+
): Promise<L1MetadataResponse> {
|
|
199
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
200
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
201
|
+
return getL1Metadata(this.axiosInstance, params, auth);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Get API tokens for an account
|
|
206
|
+
* @param params - Account index to retrieve tokens for
|
|
207
|
+
* @returns List of API tokens with their creation dates and expiry information
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* const tokens = await client.getTokens({ account_index: 0 });
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
public async getTokens(params: TokensRequest): Promise<TokensResponse> {
|
|
214
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
215
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
216
|
+
return getTokens(this.axiosInstance, params, auth);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Get deposit history for an account
|
|
221
|
+
* @param params - Account index and optional filters
|
|
222
|
+
* @returns List of deposits with pagination support
|
|
223
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* const deposits = await client.getDepositHistory({
|
|
226
|
+
* account_index: 0,
|
|
227
|
+
* limit: 50
|
|
228
|
+
* });
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
public async getDepositHistory(
|
|
232
|
+
params: DepositHistoryRequest,
|
|
233
|
+
): Promise<DepositHistoryResponse> {
|
|
234
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
235
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
236
|
+
return getDepositHistory(this.axiosInstance, params, auth);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Get withdrawal history for an account
|
|
241
|
+
* @param params - Account index and optional filters
|
|
242
|
+
* @returns List of withdrawals with pagination support
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* const withdrawals = await client.getWithdrawHistory({
|
|
246
|
+
* account_index: 0,
|
|
247
|
+
* limit: 50
|
|
248
|
+
* });
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
public async getWithdrawHistory(
|
|
252
|
+
params: WithdrawHistoryRequest,
|
|
253
|
+
): Promise<WithdrawHistoryResponse> {
|
|
254
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
255
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
256
|
+
return getWithdrawHistory(this.axiosInstance, params, auth);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Get fast withdraw information for an account
|
|
261
|
+
* @param params - Account index to retrieve fast withdraw info for
|
|
262
|
+
* @returns Fast withdraw information including available liquidity and fees
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* const info = await client.getFastWithdrawInfo({ account_index: 0 });
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
public async getFastWithdrawInfo(
|
|
269
|
+
params: FastWithdrawInfoRequest,
|
|
270
|
+
): Promise<FastWithdrawInfoResponse> {
|
|
271
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
272
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
273
|
+
return getFastWithdrawInfo(this.axiosInstance, params, auth);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Get transfer fee information between accounts
|
|
278
|
+
* @param params - From and to account indices and optional asset index
|
|
279
|
+
* @returns Transfer fee information including fee amount and fee percentage
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* const feeInfo = await client.getTransferFeeInfo({
|
|
283
|
+
* from_account_index: 0,
|
|
284
|
+
* to_account_index: 1
|
|
285
|
+
* });
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
public async getTransferFeeInfo(
|
|
289
|
+
params: TransferFeeInfoRequest,
|
|
290
|
+
): Promise<TransferFeeInfoResponse> {
|
|
291
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
292
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
293
|
+
return getTransferFeeInfo(this.axiosInstance, params, auth);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Get transfer history for an account
|
|
298
|
+
* @param params - Account index and optional filters
|
|
299
|
+
* @returns List of transfers with pagination support
|
|
300
|
+
* @example
|
|
301
|
+
* ```typescript
|
|
302
|
+
* const transfers = await client.getTransferHistory({
|
|
303
|
+
* account_index: 0,
|
|
304
|
+
* limit: 50
|
|
305
|
+
* });
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
public async getTransferHistory(
|
|
309
|
+
params: TransferHistoryRequest,
|
|
310
|
+
): Promise<TransferHistoryResponse> {
|
|
311
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
312
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
313
|
+
return getTransferHistory(this.axiosInstance, params, auth);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Get liquidation history for an account
|
|
318
|
+
* @param params - Account index and optional filters
|
|
319
|
+
* @returns List of liquidations with pagination support
|
|
320
|
+
* @example
|
|
321
|
+
* ```typescript
|
|
322
|
+
* const liquidations = await client.getLiquidations({
|
|
323
|
+
* account_index: 0,
|
|
324
|
+
* limit: 50
|
|
325
|
+
* });
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
public async getLiquidations(
|
|
329
|
+
params: LiquidationsRequest,
|
|
330
|
+
): Promise<LiquidationsResponse> {
|
|
331
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
332
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
333
|
+
return getLiquidations(this.axiosInstance, params, auth);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Get profit and loss data for an account or market
|
|
338
|
+
* @param params - Account index and optional market ID
|
|
339
|
+
* @returns PnL data including realized and unrealized PnL
|
|
340
|
+
* @example
|
|
341
|
+
* ```typescript
|
|
342
|
+
* const pnl = await client.getPnL({
|
|
343
|
+
* account_index: 0,
|
|
344
|
+
* market_id: 1
|
|
345
|
+
* });
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
public async getPnL(params: PnLRequest): Promise<PnLResponse> {
|
|
349
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
350
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
351
|
+
return getPnL(this.axiosInstance, params, auth);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Get position funding history for an account
|
|
356
|
+
* @param params - Account index and optional filters
|
|
357
|
+
* @returns List of funding payments with pagination support
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* const funding = await client.getPositionFunding({
|
|
361
|
+
* account_index: 0,
|
|
362
|
+
* limit: 50
|
|
363
|
+
* });
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
public async getPositionFunding(
|
|
367
|
+
params: PositionFundingRequest,
|
|
368
|
+
): Promise<PositionFundingResponse> {
|
|
369
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
370
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
371
|
+
return getPositionFunding(this.axiosInstance, params, auth);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Get public liquidity pools metadata
|
|
376
|
+
* @param params - Optional account index to filter by owner
|
|
377
|
+
* @returns List of public pools with metadata
|
|
378
|
+
* @example
|
|
379
|
+
* ```typescript
|
|
380
|
+
* const pools = await client.getPublicPools({ account_index: 0 });
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
public async getPublicPools(
|
|
384
|
+
params?: PublicPoolsRequest,
|
|
385
|
+
): Promise<PublicPoolsResponse> {
|
|
386
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
387
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
388
|
+
return getPublicPools(this.axiosInstance, params, auth);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Get referral points for an account
|
|
393
|
+
* @param params - Account index to retrieve referral points for
|
|
394
|
+
* @returns Referral points data including total points and referral code
|
|
395
|
+
* @example
|
|
396
|
+
* ```typescript
|
|
397
|
+
* const points = await client.getReferralPoints({ account_index: 0 });
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
public async getReferralPoints(
|
|
401
|
+
params: ReferralPointsRequest,
|
|
402
|
+
): Promise<ReferralPointsResponse> {
|
|
403
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
404
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
405
|
+
return getReferralPoints(this.axiosInstance, params, auth);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Get trades for an account or market
|
|
410
|
+
* @param params - Account index and optional market ID and filters
|
|
411
|
+
* @returns List of trades with pagination support
|
|
412
|
+
* @example
|
|
413
|
+
* ```typescript
|
|
414
|
+
* const trades = await client.getTrades({
|
|
415
|
+
* account_index: 0,
|
|
416
|
+
* market_id: 1,
|
|
417
|
+
* limit: 50
|
|
418
|
+
* });
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
public async getTrades(params: TradesRequest): Promise<TradesResponse> {
|
|
422
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
423
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
424
|
+
return getTrades(this.axiosInstance, params, auth);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Export data (funding or trade data) for an account
|
|
429
|
+
* @param params - Account index and export type
|
|
430
|
+
* @returns Export data in CSV format
|
|
431
|
+
* @example
|
|
432
|
+
* ```typescript
|
|
433
|
+
* const exportData = await client.getExport({
|
|
434
|
+
* account_index: 0,
|
|
435
|
+
* export_type: 'trades'
|
|
436
|
+
* });
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
439
|
+
public async getExport(params: ExportRequest): Promise<ExportResponse> {
|
|
440
|
+
const deadline = Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE;
|
|
441
|
+
const auth = await this.txClient.getAuthToken(new Date(deadline * 1000));
|
|
442
|
+
return getExport(this.axiosInstance, params, auth);
|
|
443
|
+
}
|
|
444
|
+
}
|