@myx-trade/sdk 0.0.1
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/dist/arbitrum-MLVIRDTQ.png +0 -0
- package/dist/index.d.mts +1152 -0
- package/dist/index.d.ts +1152 -0
- package/dist/index.js +17356 -0
- package/dist/index.mjs +17292 -0
- package/dist/linea-ZTA3FOH3.png +0 -0
- package/dist/opbnb-5K2AGQHT.png +0 -0
- package/package.json +59 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1152 @@
|
|
|
1
|
+
import * as ethers from 'ethers';
|
|
2
|
+
import { ZeroAddress, AddressLike, Signer } from 'ethers';
|
|
3
|
+
export { formatUnits, parseUnits } from 'ethers';
|
|
4
|
+
import { Options, Event } from 'reconnecting-websocket';
|
|
5
|
+
import { WalletClient } from 'viem';
|
|
6
|
+
|
|
7
|
+
type Address$1 = `0x${string}` | typeof ZeroAddress;
|
|
8
|
+
declare enum ChainId {
|
|
9
|
+
LINEA_SEPOLIA = 59141,
|
|
10
|
+
LINEA_MAINNET = 59144,
|
|
11
|
+
ARB_TESTNET = 421614,
|
|
12
|
+
ARB_MAINNET = 42161,
|
|
13
|
+
OPBNB_TESTNET = 5611,
|
|
14
|
+
OPBNB_MAINNET = 204,
|
|
15
|
+
SCROLL_MAINNET = 534352,
|
|
16
|
+
BSC_TESTNET = 97,
|
|
17
|
+
BSC_MAINNET = 56
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface CreatePoolRequest {
|
|
21
|
+
chainId: ChainId;
|
|
22
|
+
marketId?: string;
|
|
23
|
+
baseToken: AddressLike;
|
|
24
|
+
}
|
|
25
|
+
declare enum PoolType {
|
|
26
|
+
Base = 0,
|
|
27
|
+
Quote = 1
|
|
28
|
+
}
|
|
29
|
+
declare enum TriggerType$1 {
|
|
30
|
+
TP = 1,
|
|
31
|
+
SL = 2
|
|
32
|
+
}
|
|
33
|
+
interface TpSl {
|
|
34
|
+
amount: number;
|
|
35
|
+
triggerPrice: number;
|
|
36
|
+
triggerType: TriggerType$1;
|
|
37
|
+
}
|
|
38
|
+
interface TpSLParams {
|
|
39
|
+
amount: bigint;
|
|
40
|
+
triggerPrice: bigint;
|
|
41
|
+
triggerType: bigint;
|
|
42
|
+
minQuoteOut: bigint;
|
|
43
|
+
}
|
|
44
|
+
interface AddTpSLParams {
|
|
45
|
+
slippage: number;
|
|
46
|
+
chainId: ChainId;
|
|
47
|
+
poolId: string;
|
|
48
|
+
poolType: PoolType;
|
|
49
|
+
tpsl: TpSl[];
|
|
50
|
+
}
|
|
51
|
+
interface CancelTpSLParams {
|
|
52
|
+
chainId: ChainId;
|
|
53
|
+
orderId: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare const createPool: ({ chainId, baseToken }: CreatePoolRequest) => Promise<string | undefined>;
|
|
57
|
+
|
|
58
|
+
declare const getMarketPoolId: ({ chainId, baseToken }: CreatePoolRequest) => Promise<string | undefined>;
|
|
59
|
+
declare const getMarketPools: (chainId: ChainId) => Promise<string[]>;
|
|
60
|
+
declare const getPoolInfo$1: (chainId: ChainId, poolId: string, marketPrice?: bigint) => Promise<{
|
|
61
|
+
quotePool: {
|
|
62
|
+
poolToken: string;
|
|
63
|
+
exchangeRate: bigint;
|
|
64
|
+
poolTokenPrice: bigint;
|
|
65
|
+
poolTokenSupply: bigint;
|
|
66
|
+
};
|
|
67
|
+
basePool: {
|
|
68
|
+
poolToken: string;
|
|
69
|
+
exchangeRate: bigint;
|
|
70
|
+
poolTokenPrice: bigint;
|
|
71
|
+
poolTokenSupply: bigint;
|
|
72
|
+
};
|
|
73
|
+
reserveInfo: {
|
|
74
|
+
baseTotalAmount: bigint;
|
|
75
|
+
baseReservedAmount: bigint;
|
|
76
|
+
quoteTotalAmount: bigint;
|
|
77
|
+
quoteReservedAmount: bigint;
|
|
78
|
+
};
|
|
79
|
+
fundingInfo: {
|
|
80
|
+
nextFundingRate: bigint;
|
|
81
|
+
lastFundingFeeTracker: bigint;
|
|
82
|
+
nextEpochTime: bigint;
|
|
83
|
+
};
|
|
84
|
+
}>;
|
|
85
|
+
|
|
86
|
+
declare const getUserGenesisShare: (chainId: ChainId, tokenAddress: string, account: string) => Promise<bigint>;
|
|
87
|
+
|
|
88
|
+
declare const addTpSl: (params: AddTpSLParams) => Promise<ethers.ContractTransactionReceipt | null>;
|
|
89
|
+
|
|
90
|
+
declare const cancelTpSl: (params: CancelTpSLParams) => Promise<ethers.ContractTransactionReceipt | null>;
|
|
91
|
+
|
|
92
|
+
declare const reprime: (chainId: ChainId, poolId: string) => Promise<ethers.ContractTransactionReceipt | null>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Trading related types and enums
|
|
96
|
+
*/
|
|
97
|
+
declare const OrderType: {
|
|
98
|
+
readonly MARKET: 0;
|
|
99
|
+
readonly LIMIT: 1;
|
|
100
|
+
readonly STOP: 2;
|
|
101
|
+
readonly CONDITIONAL: 3;
|
|
102
|
+
};
|
|
103
|
+
type OrderType = (typeof OrderType)[keyof typeof OrderType];
|
|
104
|
+
declare const TriggerType: {
|
|
105
|
+
readonly NONE: 0;
|
|
106
|
+
readonly GTE: 1;
|
|
107
|
+
readonly LTE: 2;
|
|
108
|
+
};
|
|
109
|
+
type TriggerType = (typeof TriggerType)[keyof typeof TriggerType];
|
|
110
|
+
declare const OperationType: {
|
|
111
|
+
readonly INCREASE: 0;
|
|
112
|
+
readonly DECREASE: 1;
|
|
113
|
+
};
|
|
114
|
+
type OperationType = (typeof OperationType)[keyof typeof OperationType];
|
|
115
|
+
declare const Direction: {
|
|
116
|
+
readonly LONG: 0;
|
|
117
|
+
readonly SHORT: 1;
|
|
118
|
+
};
|
|
119
|
+
type Direction = (typeof Direction)[keyof typeof Direction];
|
|
120
|
+
declare const TimeInForce: {
|
|
121
|
+
readonly IOC: 0;
|
|
122
|
+
};
|
|
123
|
+
type TimeInForce = (typeof TimeInForce)[keyof typeof TimeInForce];
|
|
124
|
+
interface Position$1 {
|
|
125
|
+
positionId: string;
|
|
126
|
+
poolId: string;
|
|
127
|
+
direction: Direction;
|
|
128
|
+
size: string;
|
|
129
|
+
collateral: string;
|
|
130
|
+
leverage: number;
|
|
131
|
+
entryPrice: string;
|
|
132
|
+
markPrice: string;
|
|
133
|
+
pnl: string;
|
|
134
|
+
unrealizedPnl: string;
|
|
135
|
+
liquidationPrice: string;
|
|
136
|
+
marginRatio: string;
|
|
137
|
+
timestamp: number;
|
|
138
|
+
}
|
|
139
|
+
interface Order$1 {
|
|
140
|
+
orderId: string;
|
|
141
|
+
poolId: string;
|
|
142
|
+
positionId?: string;
|
|
143
|
+
orderType: OrderType;
|
|
144
|
+
triggerType: TriggerType;
|
|
145
|
+
operation: OperationType;
|
|
146
|
+
direction: Direction;
|
|
147
|
+
size: string;
|
|
148
|
+
collateralAmount: string;
|
|
149
|
+
orderPrice?: string;
|
|
150
|
+
triggerPrice?: string;
|
|
151
|
+
timeInForce: TimeInForce;
|
|
152
|
+
postOnly: boolean;
|
|
153
|
+
slippagePct: string;
|
|
154
|
+
leverage: number;
|
|
155
|
+
status: OrderStatus;
|
|
156
|
+
createdAt: number;
|
|
157
|
+
updatedAt: number;
|
|
158
|
+
}
|
|
159
|
+
declare const OrderStatus: {
|
|
160
|
+
readonly PENDING: 0;
|
|
161
|
+
readonly PARTIAL: 1;
|
|
162
|
+
readonly FILLED: 2;
|
|
163
|
+
readonly CANCELLED: 3;
|
|
164
|
+
readonly REJECTED: 4;
|
|
165
|
+
readonly EXPIRED: 5;
|
|
166
|
+
};
|
|
167
|
+
type OrderStatus = (typeof OrderStatus)[keyof typeof OrderStatus];
|
|
168
|
+
interface PlaceOrderParams {
|
|
169
|
+
chainId: number;
|
|
170
|
+
address: string;
|
|
171
|
+
poolId: string;
|
|
172
|
+
positionId: number;
|
|
173
|
+
orderType: OrderType;
|
|
174
|
+
triggerType: TriggerType;
|
|
175
|
+
direction: Direction;
|
|
176
|
+
collateralAmount: string;
|
|
177
|
+
size: string;
|
|
178
|
+
price: string;
|
|
179
|
+
timeInForce: TimeInForce;
|
|
180
|
+
postOnly: boolean;
|
|
181
|
+
slippagePct: string;
|
|
182
|
+
executionFeeToken: string;
|
|
183
|
+
leverage: number;
|
|
184
|
+
tpSize?: string;
|
|
185
|
+
tpPrice?: string;
|
|
186
|
+
slSize?: string;
|
|
187
|
+
slPrice?: string;
|
|
188
|
+
}
|
|
189
|
+
interface PositionTpSlOrderParams {
|
|
190
|
+
chainId: number;
|
|
191
|
+
address: string;
|
|
192
|
+
poolId: string;
|
|
193
|
+
positionId: number;
|
|
194
|
+
executionFeeToken: string;
|
|
195
|
+
tpTriggerType: TriggerType;
|
|
196
|
+
slTriggerType: TriggerType;
|
|
197
|
+
direction: Direction;
|
|
198
|
+
tpSize?: string;
|
|
199
|
+
tpPrice?: string;
|
|
200
|
+
slSize?: string;
|
|
201
|
+
slPrice?: string;
|
|
202
|
+
}
|
|
203
|
+
interface TradingResult {
|
|
204
|
+
success: boolean;
|
|
205
|
+
orderId?: string;
|
|
206
|
+
transactionHash: string;
|
|
207
|
+
gasUsed?: string;
|
|
208
|
+
error?: string;
|
|
209
|
+
}
|
|
210
|
+
interface UpdateOrderTpSlParams {
|
|
211
|
+
orderId: string;
|
|
212
|
+
tpSize: string;
|
|
213
|
+
tpPrice: string;
|
|
214
|
+
slSize: string;
|
|
215
|
+
slPrice: string;
|
|
216
|
+
address: string;
|
|
217
|
+
executionFeeToken: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
interface ObjectType<T> {
|
|
221
|
+
[key: string]: T;
|
|
222
|
+
}
|
|
223
|
+
type Address = `0x${string}`;
|
|
224
|
+
type NetWorkFee = {
|
|
225
|
+
paymentType: number;
|
|
226
|
+
volScale: number;
|
|
227
|
+
};
|
|
228
|
+
declare enum ErrorCode {
|
|
229
|
+
SUCCESS = 9200,
|
|
230
|
+
SUCCESS_ORIGIN = 0,
|
|
231
|
+
IDENTITY_VERIFICATION_FAILED = 9401,
|
|
232
|
+
PERMISSION_DENIED = 9403,
|
|
233
|
+
NOT_EXIST = 9404,
|
|
234
|
+
REQUEST_LIMIT = 9429,
|
|
235
|
+
SERVICE_ERROR = 9500,
|
|
236
|
+
MISS_REQUESTED_PARAMETER = 9900,
|
|
237
|
+
INVALID_PARAMETER = 9901,
|
|
238
|
+
NETWORK_ERROR = "ERR_NETWORK"
|
|
239
|
+
}
|
|
240
|
+
interface BaseResponse {
|
|
241
|
+
code: ErrorCode;
|
|
242
|
+
msg: string | null;
|
|
243
|
+
}
|
|
244
|
+
type DashboardType = {
|
|
245
|
+
lpAsset: string;
|
|
246
|
+
cumTradeAmount: string;
|
|
247
|
+
cumEarnings: string;
|
|
248
|
+
accountCount: number;
|
|
249
|
+
positionAmount: string;
|
|
250
|
+
positionAmountRate: string | number;
|
|
251
|
+
accountCountRate: string | number;
|
|
252
|
+
tradeAmountRate: number | string;
|
|
253
|
+
lpAssetRate: string | number;
|
|
254
|
+
earningsRate: string | number;
|
|
255
|
+
};
|
|
256
|
+
interface StatDashBoardResponse extends BaseResponse {
|
|
257
|
+
data: DashboardType;
|
|
258
|
+
}
|
|
259
|
+
type AccessTokenType = {
|
|
260
|
+
accessToken: string;
|
|
261
|
+
expireAt: number;
|
|
262
|
+
allowAccount: string;
|
|
263
|
+
appId: string;
|
|
264
|
+
};
|
|
265
|
+
interface AccessTokenResponse$1 extends BaseResponse {
|
|
266
|
+
data: AccessTokenType;
|
|
267
|
+
}
|
|
268
|
+
declare enum MarketPoolState {
|
|
269
|
+
Cook = 0,// 市场建立
|
|
270
|
+
Primed = 1,// 扣款手续费,等待准备oracle
|
|
271
|
+
Trench = 2,// 上架交易
|
|
272
|
+
PreBench = 3,// 预下架
|
|
273
|
+
Bench = 4
|
|
274
|
+
}
|
|
275
|
+
type MarketPool = {
|
|
276
|
+
chainId: number;
|
|
277
|
+
marketId: string;
|
|
278
|
+
poolId: string;
|
|
279
|
+
oracleId?: number | null;
|
|
280
|
+
globalId: number;
|
|
281
|
+
state: MarketPoolState;
|
|
282
|
+
baseSymbol: string;
|
|
283
|
+
quoteSymbol: string;
|
|
284
|
+
baseDecimals: number;
|
|
285
|
+
quoteDecimals: number;
|
|
286
|
+
baseToken: string;
|
|
287
|
+
quoteToken: string;
|
|
288
|
+
basePoolToken: string;
|
|
289
|
+
quotePoolToken: string;
|
|
290
|
+
oracleType?: number | null;
|
|
291
|
+
feedId?: number | null;
|
|
292
|
+
activeTime: number;
|
|
293
|
+
};
|
|
294
|
+
interface MarketPoolResponse extends BaseResponse {
|
|
295
|
+
data: MarketPool[];
|
|
296
|
+
}
|
|
297
|
+
interface PoolResponse extends BaseResponse {
|
|
298
|
+
data: MarketPool;
|
|
299
|
+
}
|
|
300
|
+
declare enum OracleType {
|
|
301
|
+
Chainlink = 1,
|
|
302
|
+
Pyth = 2
|
|
303
|
+
}
|
|
304
|
+
type PriceType = {
|
|
305
|
+
oracleId: number;
|
|
306
|
+
price: string;
|
|
307
|
+
vaa: string;
|
|
308
|
+
publishTime: number;
|
|
309
|
+
oracleType?: OracleType;
|
|
310
|
+
nativeFee?: number | string;
|
|
311
|
+
poolId: string;
|
|
312
|
+
};
|
|
313
|
+
interface PriceResponse extends BaseResponse {
|
|
314
|
+
data: PriceType[];
|
|
315
|
+
}
|
|
316
|
+
interface ApiResponse<T = Record<string, any>> extends BaseResponse {
|
|
317
|
+
data: T;
|
|
318
|
+
}
|
|
319
|
+
interface PositionType {
|
|
320
|
+
poolId: string;
|
|
321
|
+
positionId: string;
|
|
322
|
+
direction: Direction;
|
|
323
|
+
entryPrice: string;
|
|
324
|
+
fundingRateIndex: string;
|
|
325
|
+
size: string;
|
|
326
|
+
riskTier: number;
|
|
327
|
+
collateralAmount: string;
|
|
328
|
+
txTime: number;
|
|
329
|
+
}
|
|
330
|
+
interface PositionResponse extends BaseResponse {
|
|
331
|
+
data: PositionType[];
|
|
332
|
+
}
|
|
333
|
+
interface PoolOpenOrder {
|
|
334
|
+
amount: string;
|
|
335
|
+
chainId: number;
|
|
336
|
+
minQuoteOut: string;
|
|
337
|
+
orderId: number;
|
|
338
|
+
poolId: string;
|
|
339
|
+
poolType: PoolType;
|
|
340
|
+
triggerPrice: string;
|
|
341
|
+
triggerType: TriggerType$1;
|
|
342
|
+
txTime: number;
|
|
343
|
+
user: string;
|
|
344
|
+
}
|
|
345
|
+
interface PoolOpenOrdersResponse extends BaseResponse {
|
|
346
|
+
data: PoolOpenOrder[];
|
|
347
|
+
}
|
|
348
|
+
interface AccessTokenRequest {
|
|
349
|
+
accessToken: string;
|
|
350
|
+
}
|
|
351
|
+
declare enum HttpKlineIntervalEnum {
|
|
352
|
+
Minute1 = 1,
|
|
353
|
+
Minute5 = 5,
|
|
354
|
+
Minute15 = 15,
|
|
355
|
+
Minute30 = 30,
|
|
356
|
+
Hour1 = 60,
|
|
357
|
+
Hour4 = 240,
|
|
358
|
+
Day1 = 1440,
|
|
359
|
+
Week1 = 10080,
|
|
360
|
+
Month1 = 40320
|
|
361
|
+
}
|
|
362
|
+
interface KlineDataItemType {
|
|
363
|
+
time: number;
|
|
364
|
+
open: string;
|
|
365
|
+
close: string;
|
|
366
|
+
high: string;
|
|
367
|
+
low: string;
|
|
368
|
+
}
|
|
369
|
+
interface TickerDataItem {
|
|
370
|
+
chainId: ChainId;
|
|
371
|
+
poolId: string;
|
|
372
|
+
oracleId: number;
|
|
373
|
+
price: string;
|
|
374
|
+
change: string;
|
|
375
|
+
high: string;
|
|
376
|
+
low: string;
|
|
377
|
+
volume: string;
|
|
378
|
+
turnover: string;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Get pools
|
|
383
|
+
*/
|
|
384
|
+
declare const getPools: () => Promise<MarketPoolResponse>;
|
|
385
|
+
declare const getOraclePrice: (chainId: ChainId, poolIds?: string[]) => Promise<PriceResponse>;
|
|
386
|
+
interface LevelConfig {
|
|
387
|
+
fundingFeeRate1: number;
|
|
388
|
+
fundingFeeRate1Max: number;
|
|
389
|
+
fundingFeeRate2: number;
|
|
390
|
+
fundingFeeSeconds: number;
|
|
391
|
+
leverage: number;
|
|
392
|
+
lockLiquidity: number;
|
|
393
|
+
lockPriceRate: number;
|
|
394
|
+
lockSeconds: number;
|
|
395
|
+
maintainCollateralRate: number;
|
|
396
|
+
minOrderSizeInUsd: number;
|
|
397
|
+
name: string;
|
|
398
|
+
slip: number;
|
|
399
|
+
}
|
|
400
|
+
interface PoolLevelConfig {
|
|
401
|
+
level: number;
|
|
402
|
+
levelName: string;
|
|
403
|
+
levelConfig: LevelConfig;
|
|
404
|
+
}
|
|
405
|
+
interface GetPoolLevelConfigParams {
|
|
406
|
+
poolId: string;
|
|
407
|
+
chainId: ChainId;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Get Pool Level Config
|
|
411
|
+
*/
|
|
412
|
+
declare const getPoolLevelConfig: ({ poolId, chainId, }: GetPoolLevelConfigParams) => Promise<ApiResponse<PoolLevelConfig>>;
|
|
413
|
+
declare const getPoolDetail: (chainId: number, poolId: string) => Promise<PoolResponse>;
|
|
414
|
+
declare const getPositions: (accessToken: string, chainId: ChainId) => Promise<PositionResponse>;
|
|
415
|
+
declare const getOrders: (accessToken: string, chainId: ChainId) => Promise<PositionResponse>;
|
|
416
|
+
declare const getPoolOpenOrders: (accessToken: string, chainId: ChainId) => Promise<PoolOpenOrdersResponse>;
|
|
417
|
+
/**
|
|
418
|
+
* Get Kline Data
|
|
419
|
+
*/
|
|
420
|
+
interface GetKlineDataParams {
|
|
421
|
+
chainId: ChainId;
|
|
422
|
+
poolId: string;
|
|
423
|
+
endTime: number;
|
|
424
|
+
limit: number;
|
|
425
|
+
interval: HttpKlineIntervalEnum;
|
|
426
|
+
}
|
|
427
|
+
declare const getKlineData: ({ chainId, poolId, endTime, limit, interval, }: GetKlineDataParams) => Promise<ApiResponse<KlineDataItemType[]>>;
|
|
428
|
+
/**
|
|
429
|
+
* Get Kline Latest Bar
|
|
430
|
+
*/
|
|
431
|
+
declare const getKlineLatestBar: (params: Pick<GetKlineDataParams, "chainId" | "poolId" | "interval">) => Promise<ApiResponse<KlineDataItemType>>;
|
|
432
|
+
interface GetTickerDataParams {
|
|
433
|
+
chainId: ChainId;
|
|
434
|
+
poolIds: string[];
|
|
435
|
+
}
|
|
436
|
+
declare const getTickerData: ({ chainId, poolIds, }: GetTickerDataParams) => Promise<ApiResponse<TickerDataItem[]>>;
|
|
437
|
+
declare const getAllTickers: () => Promise<ApiResponse<TickerDataItem[]>>;
|
|
438
|
+
|
|
439
|
+
declare const getPoolInfo: (chainId: ChainId, poolId: string) => Promise<MarketPool | undefined>;
|
|
440
|
+
|
|
441
|
+
declare const getOpenOrders: (chainId: ChainId) => Promise<PoolOpenOrder[]>;
|
|
442
|
+
|
|
443
|
+
type index$3_AddTpSLParams = AddTpSLParams;
|
|
444
|
+
type index$3_CancelTpSLParams = CancelTpSLParams;
|
|
445
|
+
type index$3_CreatePoolRequest = CreatePoolRequest;
|
|
446
|
+
type index$3_PoolType = PoolType;
|
|
447
|
+
declare const index$3_PoolType: typeof PoolType;
|
|
448
|
+
type index$3_TpSLParams = TpSLParams;
|
|
449
|
+
type index$3_TpSl = TpSl;
|
|
450
|
+
declare const index$3_addTpSl: typeof addTpSl;
|
|
451
|
+
declare const index$3_cancelTpSl: typeof cancelTpSl;
|
|
452
|
+
declare const index$3_createPool: typeof createPool;
|
|
453
|
+
declare const index$3_getMarketPoolId: typeof getMarketPoolId;
|
|
454
|
+
declare const index$3_getMarketPools: typeof getMarketPools;
|
|
455
|
+
declare const index$3_getOpenOrders: typeof getOpenOrders;
|
|
456
|
+
declare const index$3_getUserGenesisShare: typeof getUserGenesisShare;
|
|
457
|
+
declare const index$3_reprime: typeof reprime;
|
|
458
|
+
declare namespace index$3 {
|
|
459
|
+
export { type index$3_AddTpSLParams as AddTpSLParams, type index$3_CancelTpSLParams as CancelTpSLParams, type index$3_CreatePoolRequest as CreatePoolRequest, index$3_PoolType as PoolType, type index$3_TpSLParams as TpSLParams, type index$3_TpSl as TpSl, TriggerType$1 as TriggerType, index$3_addTpSl as addTpSl, index$3_cancelTpSl as cancelTpSl, index$3_createPool as createPool, index$3_getMarketPoolId as getMarketPoolId, index$3_getMarketPools as getMarketPools, index$3_getOpenOrders as getOpenOrders, getPoolInfo as getPoolDetail, getPoolInfo$1 as getPoolInfo, index$3_getUserGenesisShare as getUserGenesisShare, index$3_reprime as reprime };
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
type DepositTpSl = Pick<TpSl, 'triggerType' | 'triggerPrice'>;
|
|
463
|
+
interface Deposit {
|
|
464
|
+
chainId: ChainId;
|
|
465
|
+
poolId: string;
|
|
466
|
+
decimals?: number;
|
|
467
|
+
amount: number;
|
|
468
|
+
slippage: number;
|
|
469
|
+
tpsl?: DepositTpSl[];
|
|
470
|
+
}
|
|
471
|
+
interface WithdrawParams {
|
|
472
|
+
chainId: ChainId;
|
|
473
|
+
poolId: string;
|
|
474
|
+
amount: number;
|
|
475
|
+
slippage: number;
|
|
476
|
+
}
|
|
477
|
+
interface RewardsParams {
|
|
478
|
+
chainId: ChainId;
|
|
479
|
+
poolId: string;
|
|
480
|
+
account: string;
|
|
481
|
+
}
|
|
482
|
+
interface ClaimParams {
|
|
483
|
+
chainId: ChainId;
|
|
484
|
+
poolId: string;
|
|
485
|
+
}
|
|
486
|
+
interface ClaimRebatesParams {
|
|
487
|
+
chainId: ChainId;
|
|
488
|
+
poolIds: string[];
|
|
489
|
+
}
|
|
490
|
+
interface PreviewWithdrawDataParams {
|
|
491
|
+
chainId: ChainId;
|
|
492
|
+
poolId: string;
|
|
493
|
+
account: string;
|
|
494
|
+
amount: string | number;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
declare const claimBasePoolRebate: (params: ClaimParams) => Promise<ethers.ContractTransactionResponse | undefined>;
|
|
498
|
+
declare const claimBasePoolRebates: (params: ClaimRebatesParams) => Promise<ethers.ContractTransactionResponse | undefined>;
|
|
499
|
+
|
|
500
|
+
declare const deposit$1: (params: Deposit) => Promise<ethers.ContractTransactionResponse | undefined>;
|
|
501
|
+
|
|
502
|
+
declare const withdraw$1: (params: WithdrawParams) => Promise<ethers.ContractTransactionReceipt | null | undefined>;
|
|
503
|
+
|
|
504
|
+
declare const getRewards$1: (params: RewardsParams) => Promise<bigint | undefined>;
|
|
505
|
+
|
|
506
|
+
declare const previewUserWithdrawData: ({ chainId, account, poolId, amount }: PreviewWithdrawDataParams) => Promise<{
|
|
507
|
+
baseAmountOut: bigint;
|
|
508
|
+
rebateAmount: bigint;
|
|
509
|
+
} | undefined>;
|
|
510
|
+
|
|
511
|
+
declare const getLpPrice$1: (chainId: ChainId, poolId: string) => Promise<bigint | undefined>;
|
|
512
|
+
|
|
513
|
+
declare const index$2_claimBasePoolRebate: typeof claimBasePoolRebate;
|
|
514
|
+
declare const index$2_claimBasePoolRebates: typeof claimBasePoolRebates;
|
|
515
|
+
declare const index$2_previewUserWithdrawData: typeof previewUserWithdrawData;
|
|
516
|
+
declare namespace index$2 {
|
|
517
|
+
export { index$2_claimBasePoolRebate as claimBasePoolRebate, index$2_claimBasePoolRebates as claimBasePoolRebates, deposit$1 as deposit, getLpPrice$1 as getLpPrice, getRewards$1 as getRewards, index$2_previewUserWithdrawData as previewUserWithdrawData, withdraw$1 as withdraw };
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
declare const deposit: (params: Deposit) => Promise<ethers.ContractTransactionResponse | undefined>;
|
|
521
|
+
|
|
522
|
+
declare const withdraw: (params: WithdrawParams) => Promise<ethers.ContractTransactionReceipt | null | undefined>;
|
|
523
|
+
|
|
524
|
+
declare const transfer: (chainId: ChainId, fromPoolId: string, toPoolId: string, amount: number) => Promise<ethers.ContractTransactionResponse | null>;
|
|
525
|
+
|
|
526
|
+
declare const getRewards: (params: RewardsParams) => Promise<bigint | undefined>;
|
|
527
|
+
|
|
528
|
+
declare const claimQuotePoolRebate: (params: ClaimParams) => Promise<ethers.ContractTransactionResponse | undefined>;
|
|
529
|
+
declare const claimQuotePoolRebates: (params: ClaimRebatesParams) => Promise<ethers.ContractTransactionResponse | undefined>;
|
|
530
|
+
|
|
531
|
+
declare const getLpPrice: (chainId: ChainId, poolId: string) => Promise<bigint | undefined>;
|
|
532
|
+
|
|
533
|
+
declare const index$1_claimQuotePoolRebate: typeof claimQuotePoolRebate;
|
|
534
|
+
declare const index$1_claimQuotePoolRebates: typeof claimQuotePoolRebates;
|
|
535
|
+
declare const index$1_deposit: typeof deposit;
|
|
536
|
+
declare const index$1_getLpPrice: typeof getLpPrice;
|
|
537
|
+
declare const index$1_getRewards: typeof getRewards;
|
|
538
|
+
declare const index$1_transfer: typeof transfer;
|
|
539
|
+
declare const index$1_withdraw: typeof withdraw;
|
|
540
|
+
declare namespace index$1 {
|
|
541
|
+
export { index$1_claimQuotePoolRebate as claimQuotePoolRebate, index$1_claimQuotePoolRebates as claimQuotePoolRebates, index$1_deposit as deposit, index$1_getLpPrice as getLpPrice, index$1_getRewards as getRewards, index$1_transfer as transfer, index$1_withdraw as withdraw };
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
declare const getMarket: (chainId: ChainId, marketId: string) => Promise<([string, string, bigint, bigint, bigint, bigint, bigint] & {
|
|
545
|
+
marketId: string;
|
|
546
|
+
quoteToken: string;
|
|
547
|
+
baseReserveRatio: bigint;
|
|
548
|
+
quoteReserveRatio: bigint;
|
|
549
|
+
oracleFeeUsd: bigint;
|
|
550
|
+
oracleRefundFeeUsd: bigint;
|
|
551
|
+
poolPrimeThreshold: bigint;
|
|
552
|
+
}) | undefined>;
|
|
553
|
+
|
|
554
|
+
declare const getOracleFee: (chainId: ChainId, marketId: string) => Promise<bigint | undefined>;
|
|
555
|
+
|
|
556
|
+
declare const index_getMarket: typeof getMarket;
|
|
557
|
+
declare const index_getOracleFee: typeof getOracleFee;
|
|
558
|
+
declare namespace index {
|
|
559
|
+
export { index_getMarket as getMarket, index_getOracleFee as getOracleFee };
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
declare const getPricesData: (chainId: ChainId, poolIds: string[]) => Promise<{
|
|
563
|
+
poolId: string;
|
|
564
|
+
price: string;
|
|
565
|
+
value: bigint;
|
|
566
|
+
publishTime: number;
|
|
567
|
+
oracleType: OracleType;
|
|
568
|
+
vaa: string;
|
|
569
|
+
}[] | undefined>;
|
|
570
|
+
declare const getPriceData: (chainId: ChainId, poolId: string) => Promise<{
|
|
571
|
+
poolId: string;
|
|
572
|
+
price: string;
|
|
573
|
+
value: bigint;
|
|
574
|
+
publishTime: number;
|
|
575
|
+
oracleType: OracleType;
|
|
576
|
+
vaa: string;
|
|
577
|
+
} | undefined>;
|
|
578
|
+
|
|
579
|
+
declare const COMMON_PRICE_DECIMALS = 30;
|
|
580
|
+
declare const COMMON_LP_AMOUNT_DECIMALS = 18;
|
|
581
|
+
|
|
582
|
+
interface MarketInfo {
|
|
583
|
+
readonly marketId: string;
|
|
584
|
+
readonly quoteToken: Address$1;
|
|
585
|
+
readonly oracleFeeUsd: bigint;
|
|
586
|
+
readonly oracleRefundFeeUsd: bigint;
|
|
587
|
+
readonly baseReserveRatio: number;
|
|
588
|
+
readonly quoteReserveRatio: number;
|
|
589
|
+
readonly poolPrimeThreshold: bigint;
|
|
590
|
+
readonly decimals: number;
|
|
591
|
+
readonly lpDecimals: number;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
type MarketInfoMap = {
|
|
595
|
+
readonly [chainId: number]: MarketInfo;
|
|
596
|
+
};
|
|
597
|
+
declare const Market: MarketInfoMap;
|
|
598
|
+
|
|
599
|
+
declare const approve: (chainId: ChainId, account: string, tokenAddress: string, approveAddress: string, amount: bigint) => Promise<void>;
|
|
600
|
+
|
|
601
|
+
declare const getAllowanceApproved: (chainId: ChainId, account: string, tokenAddress: string, approveAddress: string, approveAmount: bigint) => Promise<boolean>;
|
|
602
|
+
|
|
603
|
+
declare const getBalanceOf: (chainId: ChainId, account: string, tokenAddress: string) => Promise<bigint>;
|
|
604
|
+
|
|
605
|
+
declare const bigintTradingGasToRatioCalculator: (gas: bigint, ratio: Number) => bigint;
|
|
606
|
+
declare const bigintTradingGasPriceWithRatio: (chainId: ChainId) => Promise<{
|
|
607
|
+
gasPrice: bigint;
|
|
608
|
+
}>;
|
|
609
|
+
declare const bigintAmountSlipperCalculator: (amount: bigint, slipper?: Number) => bigint;
|
|
610
|
+
|
|
611
|
+
interface WebSocketConfig extends Omit<Options, "maxReconnectionDelay" | "minReconnectionDelay"> {
|
|
612
|
+
url: string;
|
|
613
|
+
protocols?: string | string[];
|
|
614
|
+
initialReconnectDelay?: number;
|
|
615
|
+
maxReconnectDelay?: number;
|
|
616
|
+
reconnectMultiplier?: number;
|
|
617
|
+
maxReconnectAttempts?: number;
|
|
618
|
+
maxEnqueuedMessages?: number;
|
|
619
|
+
requestTimeout?: number;
|
|
620
|
+
heartbeatInterval?: number;
|
|
621
|
+
heartbeatMessage?: string;
|
|
622
|
+
noMessageTimeout: number;
|
|
623
|
+
onBeforeReSubscribe?: (() => void) | (() => Promise<void>);
|
|
624
|
+
}
|
|
625
|
+
interface WebSocketEvents extends Record<string | symbol, any> {
|
|
626
|
+
open: Event;
|
|
627
|
+
message: MessageEvent;
|
|
628
|
+
close: CloseEvent;
|
|
629
|
+
error: unknown;
|
|
630
|
+
reconnecting: {
|
|
631
|
+
detail: number;
|
|
632
|
+
};
|
|
633
|
+
maxreconnectattempts: void;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* MYX WebSocket Topic Enum
|
|
637
|
+
*/
|
|
638
|
+
declare enum WebSocketTopicEnum {
|
|
639
|
+
Ticker = "ticker",
|
|
640
|
+
TickerAll = "ticker.*",
|
|
641
|
+
Kline = "candle",
|
|
642
|
+
Order = "order",
|
|
643
|
+
Position = "position"
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* MYX Kline Resolution
|
|
647
|
+
*/
|
|
648
|
+
type KlineResolution = "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "1d" | "1w" | "1M";
|
|
649
|
+
/**
|
|
650
|
+
* @description Ticker Data
|
|
651
|
+
*/
|
|
652
|
+
interface NativeTickerData {
|
|
653
|
+
/**
|
|
654
|
+
* Change
|
|
655
|
+
*/
|
|
656
|
+
C: string;
|
|
657
|
+
/**
|
|
658
|
+
* Timestamp
|
|
659
|
+
*/
|
|
660
|
+
E: number;
|
|
661
|
+
/**
|
|
662
|
+
* Turnover
|
|
663
|
+
*/
|
|
664
|
+
T: string;
|
|
665
|
+
/**
|
|
666
|
+
* High Price
|
|
667
|
+
*/
|
|
668
|
+
h: string;
|
|
669
|
+
/**
|
|
670
|
+
* Index Price
|
|
671
|
+
*/
|
|
672
|
+
i: string;
|
|
673
|
+
/**
|
|
674
|
+
* Low Price
|
|
675
|
+
*/
|
|
676
|
+
l: string;
|
|
677
|
+
/**
|
|
678
|
+
* Latest Price
|
|
679
|
+
*/
|
|
680
|
+
p: string;
|
|
681
|
+
/**
|
|
682
|
+
* Volume
|
|
683
|
+
*/
|
|
684
|
+
v: string;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* MyxTickersDataResponse
|
|
688
|
+
*/
|
|
689
|
+
interface TickersDataResponse {
|
|
690
|
+
/**
|
|
691
|
+
* topic
|
|
692
|
+
*/
|
|
693
|
+
type: WebSocketTopicEnum.Ticker;
|
|
694
|
+
/**
|
|
695
|
+
* globalId
|
|
696
|
+
*/
|
|
697
|
+
globalId: number;
|
|
698
|
+
/**
|
|
699
|
+
* ticker data
|
|
700
|
+
*/
|
|
701
|
+
data: NativeTickerData;
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Kline Data
|
|
705
|
+
*/
|
|
706
|
+
interface KlineData {
|
|
707
|
+
/**
|
|
708
|
+
* Timestamp
|
|
709
|
+
*/
|
|
710
|
+
E: number;
|
|
711
|
+
/**
|
|
712
|
+
* Turnover
|
|
713
|
+
*/
|
|
714
|
+
T: string;
|
|
715
|
+
/**
|
|
716
|
+
* Close Price
|
|
717
|
+
*/
|
|
718
|
+
c: string;
|
|
719
|
+
/**
|
|
720
|
+
* High Price
|
|
721
|
+
*/
|
|
722
|
+
h: string;
|
|
723
|
+
/**
|
|
724
|
+
* Low Price
|
|
725
|
+
*/
|
|
726
|
+
l: string;
|
|
727
|
+
/**
|
|
728
|
+
* Open Price
|
|
729
|
+
*/
|
|
730
|
+
o: string;
|
|
731
|
+
/**
|
|
732
|
+
* Timestamp
|
|
733
|
+
*/
|
|
734
|
+
t: number;
|
|
735
|
+
/**
|
|
736
|
+
* Volume
|
|
737
|
+
*/
|
|
738
|
+
v: string;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Kline Data Response
|
|
742
|
+
*/
|
|
743
|
+
interface KlineDataResponse {
|
|
744
|
+
/**
|
|
745
|
+
* topic
|
|
746
|
+
*/
|
|
747
|
+
type: WebSocketTopicEnum.Kline;
|
|
748
|
+
/**
|
|
749
|
+
* globalId
|
|
750
|
+
*/
|
|
751
|
+
globalId: number;
|
|
752
|
+
/**
|
|
753
|
+
* resolution
|
|
754
|
+
*/
|
|
755
|
+
resolution: KlineResolution;
|
|
756
|
+
/**
|
|
757
|
+
*/
|
|
758
|
+
/**
|
|
759
|
+
* kline data
|
|
760
|
+
*/
|
|
761
|
+
data: KlineData;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
interface MyxSubscriptionOptions {
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
type OnTickersCallback = (data: TickersDataResponse) => void;
|
|
768
|
+
type OnKlineCallback = (data: KlineDataResponse) => void;
|
|
769
|
+
type OnOrderCallback = (data: any) => void;
|
|
770
|
+
type OnPositionCallback = (data: any) => void;
|
|
771
|
+
type OnTickersAllCallback = (data: any) => void;
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* MyxLogger
|
|
775
|
+
* @description MyxLogger is a logger for Myx SDK
|
|
776
|
+
* @author Myx
|
|
777
|
+
* @version 1.0.0
|
|
778
|
+
* @since 2025-09-19
|
|
779
|
+
* @license MIT
|
|
780
|
+
* @copyright Myx
|
|
781
|
+
* @description MyxLogger is a logger for Myx SDK
|
|
782
|
+
*/
|
|
783
|
+
type LogLevel = "debug" | "info" | "error" | "warn" | "none";
|
|
784
|
+
interface LoggerOptions {
|
|
785
|
+
logLevel?: LogLevel;
|
|
786
|
+
}
|
|
787
|
+
declare class Logger {
|
|
788
|
+
private options;
|
|
789
|
+
constructor(options?: LoggerOptions);
|
|
790
|
+
/**
|
|
791
|
+
* debug
|
|
792
|
+
*/
|
|
793
|
+
debug(message: string, ...args: any[]): void;
|
|
794
|
+
/**
|
|
795
|
+
* info
|
|
796
|
+
*/
|
|
797
|
+
info(message: string, ...args: any[]): void;
|
|
798
|
+
/**
|
|
799
|
+
* error
|
|
800
|
+
*/
|
|
801
|
+
error(message: string, ...args: any[]): void;
|
|
802
|
+
/**
|
|
803
|
+
* warn
|
|
804
|
+
*/
|
|
805
|
+
warn(message: string, ...args: any[]): void;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
interface AccessTokenResponse {
|
|
809
|
+
accessToken: string;
|
|
810
|
+
expireAt: number;
|
|
811
|
+
}
|
|
812
|
+
interface MyxClientConfig {
|
|
813
|
+
chainId: number;
|
|
814
|
+
signer: Signer;
|
|
815
|
+
walletClient?: WalletClient;
|
|
816
|
+
brokerAddress: string;
|
|
817
|
+
isTestnet?: boolean;
|
|
818
|
+
poolingInterval?: number;
|
|
819
|
+
seamlessMode?: boolean;
|
|
820
|
+
seamlessKeyPath?: string;
|
|
821
|
+
seamlessKeyPassword?: string;
|
|
822
|
+
socketConfig?: Partial<Omit<WebSocketConfig, "url">>;
|
|
823
|
+
logLevel?: LogLevel;
|
|
824
|
+
getAccessToken?: (() => Promise<AccessTokenResponse | undefined>) | (() => AccessTokenResponse | undefined);
|
|
825
|
+
}
|
|
826
|
+
declare class ConfigManager {
|
|
827
|
+
private config;
|
|
828
|
+
private accessToken?;
|
|
829
|
+
private accessTokenExpiry?;
|
|
830
|
+
constructor(config: MyxClientConfig);
|
|
831
|
+
private validateConfig;
|
|
832
|
+
/**
|
|
833
|
+
* 获取有效的 accessToken,自动处理获取和刷新
|
|
834
|
+
* @param forceRefresh 是否强制刷新
|
|
835
|
+
* @returns Promise<string | null> 有效的 accessToken 或 null
|
|
836
|
+
*/
|
|
837
|
+
getAccessToken(forceRefresh?: boolean): Promise<string | null>;
|
|
838
|
+
/**
|
|
839
|
+
* 设置 accessToken 和过期时间
|
|
840
|
+
* @param token accessToken
|
|
841
|
+
* @param expiryInSeconds token 有效期(秒),默认1小时
|
|
842
|
+
*/
|
|
843
|
+
setAccessToken(token: string, expiryInSeconds?: number): void;
|
|
844
|
+
/**
|
|
845
|
+
* 获取当前存储的 accessToken(不会触发刷新)
|
|
846
|
+
* @returns string | undefined 当前的 accessToken
|
|
847
|
+
*/
|
|
848
|
+
getCurrentAccessToken(): string | undefined;
|
|
849
|
+
/**
|
|
850
|
+
* 检查当前 accessToken 是否有效
|
|
851
|
+
* @returns boolean token 是否有效
|
|
852
|
+
*/
|
|
853
|
+
isAccessTokenValid(): boolean;
|
|
854
|
+
/**
|
|
855
|
+
* 清除 accessToken
|
|
856
|
+
*/
|
|
857
|
+
clearAccessToken(): void;
|
|
858
|
+
getConfig(): MyxClientConfig;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
declare class SubScription {
|
|
862
|
+
private wsClient;
|
|
863
|
+
private configManager;
|
|
864
|
+
private logger;
|
|
865
|
+
constructor(configManager: ConfigManager, logger: Logger);
|
|
866
|
+
/**
|
|
867
|
+
*
|
|
868
|
+
* getters
|
|
869
|
+
*/
|
|
870
|
+
get isConnected(): boolean;
|
|
871
|
+
/**
|
|
872
|
+
* public methods
|
|
873
|
+
*/
|
|
874
|
+
connect(): void;
|
|
875
|
+
disconnect(): void;
|
|
876
|
+
reconnect(): void;
|
|
877
|
+
/**
|
|
878
|
+
* tickers subscription methods
|
|
879
|
+
*/
|
|
880
|
+
subscribeTickers(globalId: number, callback: OnTickersCallback): void;
|
|
881
|
+
unsubscribeTickers(globalId: number, callback: OnTickersCallback): void;
|
|
882
|
+
/**
|
|
883
|
+
* kline subscription methods
|
|
884
|
+
*/
|
|
885
|
+
subscribeKline(globalId: number, resolution: KlineResolution, callback: OnKlineCallback): void;
|
|
886
|
+
unsubscribeKline(globalId: number, resolution: KlineResolution, callback: OnKlineCallback): void;
|
|
887
|
+
private getAccessToken;
|
|
888
|
+
private clientAuth;
|
|
889
|
+
private prevAccessToken;
|
|
890
|
+
/**
|
|
891
|
+
* with auth methods
|
|
892
|
+
*/
|
|
893
|
+
auth(isReconnect?: boolean): Promise<void>;
|
|
894
|
+
/**
|
|
895
|
+
* these methods are private data of the account, please ensure that the auth method is called before calling these methods
|
|
896
|
+
*/
|
|
897
|
+
/**
|
|
898
|
+
* position subscription methods
|
|
899
|
+
*/
|
|
900
|
+
subscribePosition(callback: OnPositionCallback): Promise<void>;
|
|
901
|
+
unsubscribePosition(callback: OnPositionCallback): void;
|
|
902
|
+
/**
|
|
903
|
+
* order subscription methods
|
|
904
|
+
*/
|
|
905
|
+
subscribeOrder(callback: OnOrderCallback): Promise<void>;
|
|
906
|
+
unsubscribeOrder(callback: OnOrderCallback): void;
|
|
907
|
+
/**
|
|
908
|
+
* event listen
|
|
909
|
+
*/
|
|
910
|
+
on<K extends keyof WebSocketEvents>(event: K, handler: (data: WebSocketEvents[K]) => void): void;
|
|
911
|
+
/**
|
|
912
|
+
* event remove listen
|
|
913
|
+
*/
|
|
914
|
+
off<K extends keyof WebSocketEvents>(event: K, handler: (data: WebSocketEvents[K]) => void): void;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
declare class Utils {
|
|
918
|
+
private configManager;
|
|
919
|
+
private logger;
|
|
920
|
+
constructor(configManager: ConfigManager, logger: Logger);
|
|
921
|
+
getOrderIdFromTransaction(receipt: any): string | null;
|
|
922
|
+
private getApproveQuoteAmount;
|
|
923
|
+
needsApproval(quoteAddress: string, requiredAmount: string, spenderAddress?: string): Promise<boolean>;
|
|
924
|
+
approveAuthorization({ quoteAddress, amount, spenderAddress, }: {
|
|
925
|
+
quoteAddress: string;
|
|
926
|
+
amount?: string;
|
|
927
|
+
spenderAddress?: string;
|
|
928
|
+
}): Promise<{
|
|
929
|
+
code: number;
|
|
930
|
+
message: any;
|
|
931
|
+
}>;
|
|
932
|
+
getNetworkFee(quoteAddress: string): Promise<any>;
|
|
933
|
+
getOraclePrice(poolId: string): Promise<{
|
|
934
|
+
poolId: string;
|
|
935
|
+
price: string;
|
|
936
|
+
value: bigint;
|
|
937
|
+
publishTime: number;
|
|
938
|
+
oracleType: OracleType;
|
|
939
|
+
vaa: string;
|
|
940
|
+
} | {
|
|
941
|
+
price: string;
|
|
942
|
+
vaa: string;
|
|
943
|
+
publishTime: number;
|
|
944
|
+
poolId: string;
|
|
945
|
+
value: number;
|
|
946
|
+
}>;
|
|
947
|
+
transferKlineResolutionToInterval(resolution: KlineResolution): HttpKlineIntervalEnum;
|
|
948
|
+
getErrorMessage(error: any, fallbackErrorMessage?: string): Promise<any>;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
declare class Markets {
|
|
952
|
+
private configManager;
|
|
953
|
+
private utils;
|
|
954
|
+
constructor(configManager: ConfigManager, utils: Utils);
|
|
955
|
+
getMarkets(): Promise<never[]>;
|
|
956
|
+
listPools(): Promise<MarketPool[]>;
|
|
957
|
+
getPoolLevelConfig(poolId: string): Promise<PoolLevelConfig>;
|
|
958
|
+
/**
|
|
959
|
+
* kline start
|
|
960
|
+
*/
|
|
961
|
+
getKlineList({ interval, ...params }: Pick<GetKlineDataParams, "poolId" | "limit" | "endTime"> & {
|
|
962
|
+
interval: KlineResolution;
|
|
963
|
+
}): Promise<KlineDataItemType[]>;
|
|
964
|
+
getKlineLatestBar({ interval, ...params }: Pick<GetKlineDataParams, "poolId" | "limit" | "endTime"> & {
|
|
965
|
+
interval: KlineResolution;
|
|
966
|
+
}): Promise<KlineDataItemType>;
|
|
967
|
+
/**
|
|
968
|
+
* kline end
|
|
969
|
+
*/
|
|
970
|
+
/**
|
|
971
|
+
* ticker start
|
|
972
|
+
*/
|
|
973
|
+
getTickerList(params: Omit<GetTickerDataParams, "chainId">): Promise<TickerDataItem[]>;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
declare class Position {
|
|
977
|
+
private configManager;
|
|
978
|
+
private logger;
|
|
979
|
+
private utils;
|
|
980
|
+
constructor(configManager: ConfigManager, logger: Logger, utils: Utils);
|
|
981
|
+
listPositions(): Promise<{
|
|
982
|
+
code: number;
|
|
983
|
+
message: string;
|
|
984
|
+
data?: undefined;
|
|
985
|
+
} | {
|
|
986
|
+
code: number;
|
|
987
|
+
data: PositionType[];
|
|
988
|
+
message?: undefined;
|
|
989
|
+
}>;
|
|
990
|
+
/**
|
|
991
|
+
* @desc temp skip eip7702
|
|
992
|
+
* @todo adjustCollateral 调整保证金
|
|
993
|
+
*/
|
|
994
|
+
adjustCollateral({ poolId, positionId, adjustAmount, quoteToken, }: {
|
|
995
|
+
poolId: string;
|
|
996
|
+
positionId: string;
|
|
997
|
+
adjustAmount: string;
|
|
998
|
+
quoteToken: string;
|
|
999
|
+
}): Promise<{
|
|
1000
|
+
code: number;
|
|
1001
|
+
data: {
|
|
1002
|
+
hash: any;
|
|
1003
|
+
};
|
|
1004
|
+
message: string;
|
|
1005
|
+
} | {
|
|
1006
|
+
code: number;
|
|
1007
|
+
message: any;
|
|
1008
|
+
data?: undefined;
|
|
1009
|
+
}>;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Order related types and interfaces
|
|
1014
|
+
*/
|
|
1015
|
+
|
|
1016
|
+
interface UpdateOrderParams {
|
|
1017
|
+
orderId: string;
|
|
1018
|
+
tpSize: string;
|
|
1019
|
+
tpPrice: string;
|
|
1020
|
+
slSize: string;
|
|
1021
|
+
slPrice: string;
|
|
1022
|
+
useOrderCollateral: boolean;
|
|
1023
|
+
executionFeeToken: string;
|
|
1024
|
+
size: string;
|
|
1025
|
+
price: string;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
declare class Order {
|
|
1029
|
+
private configManager;
|
|
1030
|
+
private logger;
|
|
1031
|
+
private utils;
|
|
1032
|
+
constructor(configManager: ConfigManager, logger: Logger, utils: Utils);
|
|
1033
|
+
createIncreaseOrder(params: PlaceOrderParams): Promise<{
|
|
1034
|
+
code: number;
|
|
1035
|
+
message: string;
|
|
1036
|
+
data: {
|
|
1037
|
+
success: boolean;
|
|
1038
|
+
orderId: string | null;
|
|
1039
|
+
transactionHash: string;
|
|
1040
|
+
blockNumber: number | undefined;
|
|
1041
|
+
gasUsed: string | undefined;
|
|
1042
|
+
status: string;
|
|
1043
|
+
confirmations: number;
|
|
1044
|
+
timestamp: number;
|
|
1045
|
+
receipt: ethers.ContractTransactionReceipt | null;
|
|
1046
|
+
};
|
|
1047
|
+
} | {
|
|
1048
|
+
code: number;
|
|
1049
|
+
message: any;
|
|
1050
|
+
data?: undefined;
|
|
1051
|
+
}>;
|
|
1052
|
+
createDecreaseOrder(params: PlaceOrderParams): Promise<{
|
|
1053
|
+
code: number;
|
|
1054
|
+
message: string;
|
|
1055
|
+
data: {
|
|
1056
|
+
success: boolean;
|
|
1057
|
+
orderId: string | null;
|
|
1058
|
+
transactionHash: string;
|
|
1059
|
+
blockNumber: number | undefined;
|
|
1060
|
+
gasUsed: string | undefined;
|
|
1061
|
+
status: string;
|
|
1062
|
+
confirmations: number;
|
|
1063
|
+
timestamp: number;
|
|
1064
|
+
receipt: ethers.ContractTransactionReceipt | null;
|
|
1065
|
+
};
|
|
1066
|
+
} | {
|
|
1067
|
+
code: number;
|
|
1068
|
+
message: any;
|
|
1069
|
+
data?: undefined;
|
|
1070
|
+
}>;
|
|
1071
|
+
createPositionTpSlOrder(params: PositionTpSlOrderParams): Promise<{
|
|
1072
|
+
code: number;
|
|
1073
|
+
message: string;
|
|
1074
|
+
data: {
|
|
1075
|
+
success: boolean;
|
|
1076
|
+
orderId: string | null;
|
|
1077
|
+
transactionHash: string;
|
|
1078
|
+
blockNumber: number | undefined;
|
|
1079
|
+
gasUsed: string | undefined;
|
|
1080
|
+
status: string;
|
|
1081
|
+
confirmations: number;
|
|
1082
|
+
timestamp: number;
|
|
1083
|
+
receipt: ethers.ContractTransactionReceipt | null;
|
|
1084
|
+
};
|
|
1085
|
+
} | {
|
|
1086
|
+
code: number;
|
|
1087
|
+
message: any;
|
|
1088
|
+
data?: undefined;
|
|
1089
|
+
}>;
|
|
1090
|
+
cancelOrder(orderId: string): Promise<{
|
|
1091
|
+
code: number;
|
|
1092
|
+
message: any;
|
|
1093
|
+
}>;
|
|
1094
|
+
cancelOrders(orderIds: string[]): Promise<{
|
|
1095
|
+
code: number;
|
|
1096
|
+
message: any;
|
|
1097
|
+
}>;
|
|
1098
|
+
updateOrderTpSl(params: UpdateOrderParams): Promise<ethers.ContractTransactionReceipt | {
|
|
1099
|
+
code: number;
|
|
1100
|
+
message: string;
|
|
1101
|
+
} | null>;
|
|
1102
|
+
getOrders(): Promise<{
|
|
1103
|
+
code: number;
|
|
1104
|
+
message: string;
|
|
1105
|
+
data?: undefined;
|
|
1106
|
+
} | {
|
|
1107
|
+
code: number;
|
|
1108
|
+
data: PositionType[];
|
|
1109
|
+
message?: undefined;
|
|
1110
|
+
}>;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
declare class Account {
|
|
1114
|
+
private configManager;
|
|
1115
|
+
private logger;
|
|
1116
|
+
private utils;
|
|
1117
|
+
constructor(configManager: ConfigManager, logger: Logger, utils: Utils);
|
|
1118
|
+
/**
|
|
1119
|
+
* get locked assets
|
|
1120
|
+
*/
|
|
1121
|
+
getUserAssets(): Promise<any>;
|
|
1122
|
+
/**
|
|
1123
|
+
* get tradable amount
|
|
1124
|
+
*/
|
|
1125
|
+
getTradableAmount({ poolId }: {
|
|
1126
|
+
poolId: string;
|
|
1127
|
+
}): Promise<any>;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
declare class MyxClient {
|
|
1131
|
+
/**
|
|
1132
|
+
* private properties
|
|
1133
|
+
*/
|
|
1134
|
+
private configManager;
|
|
1135
|
+
private logger;
|
|
1136
|
+
/**
|
|
1137
|
+
* public properties
|
|
1138
|
+
*/
|
|
1139
|
+
subscription: SubScription;
|
|
1140
|
+
markets: Markets;
|
|
1141
|
+
position: Position;
|
|
1142
|
+
order: Order;
|
|
1143
|
+
utils: Utils;
|
|
1144
|
+
account: Account;
|
|
1145
|
+
/**
|
|
1146
|
+
* 获取配置管理器(用于访问 accessToken 相关方法)
|
|
1147
|
+
*/
|
|
1148
|
+
getConfigManager(): ConfigManager;
|
|
1149
|
+
constructor(options: MyxClientConfig);
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
export { type AccessTokenRequest, type AccessTokenResponse$1 as AccessTokenResponse, type AccessTokenType, type Address, type ApiResponse, type BaseResponse, COMMON_LP_AMOUNT_DECIMALS, COMMON_PRICE_DECIMALS, type DashboardType, Direction, ErrorCode, type GetKlineDataParams, type GetPoolLevelConfigParams, type GetTickerDataParams, HttpKlineIntervalEnum, type KlineDataItemType, type KlineDataResponse, type KlineResolution, type LevelConfig, Market, type MarketInfoMap, type MarketPool, type MarketPoolResponse, MarketPoolState, MyxClient, type MyxClientConfig, type MyxSubscriptionOptions, type NetWorkFee, type ObjectType, type OnKlineCallback, type OnOrderCallback, type OnPositionCallback, type OnTickersAllCallback, type OnTickersCallback, OperationType, OracleType, type Order$1 as Order, OrderStatus, OrderType, type PlaceOrderParams, type PoolLevelConfig, type PoolOpenOrder, type PoolOpenOrdersResponse, type PoolResponse, type Position$1 as Position, type PositionResponse, type PositionTpSlOrderParams, type PositionType, type PriceResponse, type PriceType, type StatDashBoardResponse, type TickerDataItem, type TickersDataResponse, TimeInForce, type TradingResult, TriggerType, type UpdateOrderTpSlParams, approve, index$2 as base, bigintAmountSlipperCalculator, bigintTradingGasPriceWithRatio, bigintTradingGasToRatioCalculator, getAllTickers, getAllowanceApproved, getBalanceOf, getKlineData, getKlineLatestBar, getOraclePrice, getOrders, getPoolDetail, getPoolLevelConfig, getPoolOpenOrders, getPools, getPositions, getPriceData, getPricesData, getTickerData, index as market, index$3 as pool, index$1 as quote };
|