@axis-markets/client 0.3.1 → 0.5.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 +45 -13
- package/lib/axis-client.cjs +2 -0
- package/lib/axis-client.cjs.map +1 -0
- package/lib/footprint.cjs +2 -0
- package/lib/footprint.cjs.map +1 -0
- package/package.json +24 -5
- package/src/api-client.js +1 -1
- package/src/footprint.d.ts +32 -0
- package/src/footprint.js +123 -0
- package/src/index.d.ts +523 -531
- package/src/index.js +22 -3
- package/lib/axisContractClient.js +0 -2
package/src/index.d.ts
CHANGED
|
@@ -1,531 +1,523 @@
|
|
|
1
|
-
/** Trading order type - instructions to contract how to execute the trade */
|
|
2
|
-
export enum OrderKind {
|
|
3
|
-
Limit = 1,
|
|
4
|
-
Fill = 2,
|
|
5
|
-
FillOrKill = 3,
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/** Trade direction instructions */
|
|
9
|
-
export enum TradeDirection {
|
|
10
|
-
Sell = 1,
|
|
11
|
-
Buy = 2,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** Order properties, stored on-chain */
|
|
15
|
-
export interface Order {
|
|
16
|
-
/** Amount left to sell/buy */
|
|
17
|
-
amount: bigint;
|
|
18
|
-
/** Buying token address */
|
|
19
|
-
buying: string;
|
|
20
|
-
/** expiration timestamp */
|
|
21
|
-
expires: bigint;
|
|
22
|
-
/** Unique order identifier */
|
|
23
|
-
id: bigint;
|
|
24
|
-
/** Order type */
|
|
25
|
-
kind: OrderKind;
|
|
26
|
-
/** Maker address */
|
|
27
|
-
owner: string;
|
|
28
|
-
/** Order price */
|
|
29
|
-
price: bigint;
|
|
30
|
-
/** Initial selling/buying amount */
|
|
31
|
-
quote: bigint;
|
|
32
|
-
/** Selling token address */
|
|
33
|
-
selling: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** Orderbook trade event */
|
|
37
|
-
export interface TradeContractEvent {
|
|
38
|
-
/** Bought tokens amount */
|
|
39
|
-
bought: bigint;
|
|
40
|
-
/** Bought asset address */
|
|
41
|
-
buying: string;
|
|
42
|
-
/** Unique trade id */
|
|
43
|
-
id: bigint;
|
|
44
|
-
/** Seller account address */
|
|
45
|
-
maker: string;
|
|
46
|
-
/** Order id */
|
|
47
|
-
order: bigint;
|
|
48
|
-
/** Sold asset address */
|
|
49
|
-
selling: string;
|
|
50
|
-
/** Sold tokens amount */
|
|
51
|
-
sold: bigint;
|
|
52
|
-
/** Trader account address */
|
|
53
|
-
taker: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** Orderbook swap event */
|
|
57
|
-
export interface SwapContractEvent {
|
|
58
|
-
/** Unique swap id (last trade id assigned while settling the swap legs) */
|
|
59
|
-
id: bigint;
|
|
60
|
-
/** Trader account address */
|
|
61
|
-
trader: string;
|
|
62
|
-
/** Sold asset address */
|
|
63
|
-
selling: string;
|
|
64
|
-
/** Bought asset address */
|
|
65
|
-
buying: string;
|
|
66
|
-
/** Amount of `selling` tokens sold */
|
|
67
|
-
sold: bigint;
|
|
68
|
-
/** Amount of `buying` tokens received */
|
|
69
|
-
bought: bigint;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** A trade step in a multi-market swap path. */
|
|
73
|
-
export interface TradeStep {
|
|
74
|
-
/** Asset to buy at this step */
|
|
75
|
-
asset: string;
|
|
76
|
-
/** Maker order IDs to match */
|
|
77
|
-
orders: Array<bigint>;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
export
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
*
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
*
|
|
177
|
-
* @param
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
*
|
|
184
|
-
* @param
|
|
185
|
-
* @param
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
*
|
|
192
|
-
* @param
|
|
193
|
-
* @
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
*
|
|
200
|
-
* @
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
*
|
|
207
|
-
* @
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
|
|
321
|
-
/** 24h
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
|
|
397
|
-
/** Order
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
/**
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
*
|
|
465
|
-
* @
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
*
|
|
472
|
-
* @
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
*
|
|
479
|
-
* @
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
*
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
*
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
*
|
|
499
|
-
* @
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
*
|
|
506
|
-
* @
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
*
|
|
513
|
-
* @
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
*
|
|
520
|
-
* @
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* Retrieve recent trades
|
|
527
|
-
* @param params - Filter parameters
|
|
528
|
-
* @returns Recent trades matching the filter
|
|
529
|
-
*/
|
|
530
|
-
getTrades(params?: TradesParams): Promise<ApiTrade[]>;
|
|
531
|
-
}
|
|
1
|
+
/** Trading order type - instructions to contract how to execute the trade */
|
|
2
|
+
export enum OrderKind {
|
|
3
|
+
Limit = 1,
|
|
4
|
+
Fill = 2,
|
|
5
|
+
FillOrKill = 3,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Trade direction instructions */
|
|
9
|
+
export enum TradeDirection {
|
|
10
|
+
Sell = 1,
|
|
11
|
+
Buy = 2,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Order properties, stored on-chain */
|
|
15
|
+
export interface Order {
|
|
16
|
+
/** Amount left to sell/buy */
|
|
17
|
+
amount: bigint;
|
|
18
|
+
/** Buying token address */
|
|
19
|
+
buying: string;
|
|
20
|
+
/** expiration timestamp */
|
|
21
|
+
expires: bigint;
|
|
22
|
+
/** Unique order identifier */
|
|
23
|
+
id: bigint;
|
|
24
|
+
/** Order type */
|
|
25
|
+
kind: OrderKind;
|
|
26
|
+
/** Maker address */
|
|
27
|
+
owner: string;
|
|
28
|
+
/** Order price */
|
|
29
|
+
price: bigint;
|
|
30
|
+
/** Initial selling/buying amount */
|
|
31
|
+
quote: bigint;
|
|
32
|
+
/** Selling token address */
|
|
33
|
+
selling: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Orderbook trade event */
|
|
37
|
+
export interface TradeContractEvent {
|
|
38
|
+
/** Bought tokens amount */
|
|
39
|
+
bought: bigint;
|
|
40
|
+
/** Bought asset address */
|
|
41
|
+
buying: string;
|
|
42
|
+
/** Unique trade id */
|
|
43
|
+
id: bigint;
|
|
44
|
+
/** Seller account address */
|
|
45
|
+
maker: string;
|
|
46
|
+
/** Order id */
|
|
47
|
+
order: bigint;
|
|
48
|
+
/** Sold asset address */
|
|
49
|
+
selling: string;
|
|
50
|
+
/** Sold tokens amount */
|
|
51
|
+
sold: bigint;
|
|
52
|
+
/** Trader account address */
|
|
53
|
+
taker: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Orderbook swap event */
|
|
57
|
+
export interface SwapContractEvent {
|
|
58
|
+
/** Unique swap id (last trade id assigned while settling the swap legs) */
|
|
59
|
+
id: bigint;
|
|
60
|
+
/** Trader account address */
|
|
61
|
+
trader: string;
|
|
62
|
+
/** Sold asset address */
|
|
63
|
+
selling: string;
|
|
64
|
+
/** Bought asset address */
|
|
65
|
+
buying: string;
|
|
66
|
+
/** Amount of `selling` tokens sold */
|
|
67
|
+
sold: bigint;
|
|
68
|
+
/** Amount of `buying` tokens received */
|
|
69
|
+
bought: bigint;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** A trade step in a multi-market swap path. */
|
|
73
|
+
export interface TradeStep {
|
|
74
|
+
/** Asset to buy at this step */
|
|
75
|
+
asset: string;
|
|
76
|
+
/** Maker order IDs to match */
|
|
77
|
+
orders: Array<bigint>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Standard contract errors */
|
|
81
|
+
export declare const ContractErrors: {
|
|
82
|
+
701: {message: "NotAuthorized"};
|
|
83
|
+
702: {message: "InsufficientBalance"};
|
|
84
|
+
703: {message: "OrderNotFound"};
|
|
85
|
+
704: {message: "Overflow"};
|
|
86
|
+
705: {message: "InvalidMatch"};
|
|
87
|
+
706: {message: "InvalidPrice"};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface ClientInitializationParams {
|
|
91
|
+
/** Public key of the account that will interact with the contract */
|
|
92
|
+
publicKey: string;
|
|
93
|
+
/** Callback for signing transactions generated by the client */
|
|
94
|
+
signTransaction: SignTransactionCallback;
|
|
95
|
+
/** URL of the RPC server */
|
|
96
|
+
rpcUrl: string;
|
|
97
|
+
/** DEX contract ID */
|
|
98
|
+
contractId: string;
|
|
99
|
+
/** Network passphrase (Pubnet passphrase by default) */
|
|
100
|
+
networkPassphrase?: string;
|
|
101
|
+
/** Transaction fee (0.1 XLM by default) */
|
|
102
|
+
fee?: string;
|
|
103
|
+
/** Declare every supplied order id in the read-write footprint of trading transactions (enabled by default) */
|
|
104
|
+
autoFootprint?: boolean;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type SignTransactionCallback = (
|
|
108
|
+
tx: string,
|
|
109
|
+
context: {network: string; networkPassphrase: string; accountToSign: string}
|
|
110
|
+
) => Promise<{signedTxXdr: string; signerAddress?: string}>;
|
|
111
|
+
|
|
112
|
+
export interface TradeArguments {
|
|
113
|
+
/** Trading order behavior */
|
|
114
|
+
kind: OrderKind,
|
|
115
|
+
/** Trader address */
|
|
116
|
+
trader: string;
|
|
117
|
+
/** Tokens amount */
|
|
118
|
+
amount: bigint;
|
|
119
|
+
/** Selling token address */
|
|
120
|
+
selling: string;
|
|
121
|
+
/** Buying token address */
|
|
122
|
+
buying: string;
|
|
123
|
+
/** Price a trader willing to accept */
|
|
124
|
+
price: bigint;
|
|
125
|
+
/** List of order IDs to match before creating the order on-chain */
|
|
126
|
+
orders: Array<bigint>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface SellTradeArguments extends TradeArguments {
|
|
130
|
+
/** Amount of `selling` tokens to sell */
|
|
131
|
+
amount: bigint;
|
|
132
|
+
/** Price a trader willing to accept, minimum `buying` tokens per 1 `selling` */
|
|
133
|
+
price: bigint;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface BuyTradeArguments extends TradeArguments {
|
|
137
|
+
/** Amount of `buying` tokens to acquire */
|
|
138
|
+
amount: bigint;
|
|
139
|
+
/** Price a trader willing to accept, maximum `selling` tokens per 1 `buying` */
|
|
140
|
+
price: bigint;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface SwapArguments {
|
|
144
|
+
/** Trade direction: `Sell` or `Buy` */
|
|
145
|
+
direction: TradeDirection,
|
|
146
|
+
/** Trader address */
|
|
147
|
+
trader: string,
|
|
148
|
+
/** Token address sent by the trader */
|
|
149
|
+
selling: string,
|
|
150
|
+
/** Maximum amount of selling tokens to send */
|
|
151
|
+
sellingAmount: bigint,
|
|
152
|
+
/** Minimum amount of buying tokens to receive */
|
|
153
|
+
buyingAmount: bigint,
|
|
154
|
+
/** Ordered list of the trade route steps */
|
|
155
|
+
path: Array<TradeStep>
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export declare class AxisContractClient {
|
|
159
|
+
constructor(params: ClientInitializationParams);
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Retrieve last order id
|
|
163
|
+
* @returns Last created order id
|
|
164
|
+
*/
|
|
165
|
+
last(): Promise<bigint>;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Fetch existing order
|
|
169
|
+
* @param id - ID of the order to fetch
|
|
170
|
+
* @returns Order fetched from the storage
|
|
171
|
+
*/
|
|
172
|
+
order(id: bigint): Promise<Order>;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Cancel existing order
|
|
176
|
+
* @param ids - ID of the order to cancel
|
|
177
|
+
* @param trader - Trader address
|
|
178
|
+
*/
|
|
179
|
+
cancel(ids: Array<bigint>, trader: string): Promise<void>;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Fill existing orders using another matching order from the orderbook
|
|
183
|
+
* @param trader - Trader address
|
|
184
|
+
* @param takerOrderId - ID of the order that serves as a taker
|
|
185
|
+
* @param orders - List of order IDs to match
|
|
186
|
+
* @returns Amount of sold and bought tokens
|
|
187
|
+
*/
|
|
188
|
+
fill_order(trader: string, takerOrderId: bigint, orders: Array<bigint>): Promise<[bigint, bigint]>;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Trade with DEX and create buy limit order if quote not executed in full
|
|
192
|
+
* @param params - Trade parameters
|
|
193
|
+
* @returns Amount of sold tokens, bought tokens, and ID of the newly created order if any
|
|
194
|
+
*/
|
|
195
|
+
buy(params: BuyTradeArguments): Promise<[bigint, bigint, bigint]>;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Trade with DEX and create sell limit order if quote not executed in full
|
|
199
|
+
* @param params - Trade parameters
|
|
200
|
+
* @returns Amount of sold tokens, bought tokens, and ID of the newly created order if any
|
|
201
|
+
*/
|
|
202
|
+
sell(params: SellTradeArguments): Promise<[bigint, bigint, bigint]>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Swap tokens across several markets.
|
|
206
|
+
* @param params - Trade parameters
|
|
207
|
+
* @returns Amount of sold tokens and bought tokens
|
|
208
|
+
*/
|
|
209
|
+
swap(params: SwapArguments): Promise<[bigint, bigint]>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Error thrown when the Aggregator API responds with a non-success HTTP status */
|
|
213
|
+
export declare class AxisApiError extends Error {
|
|
214
|
+
constructor(message: string, status: number);
|
|
215
|
+
|
|
216
|
+
/** HTTP status code associated with the error */
|
|
217
|
+
readonly status: number;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface QuoteParams {
|
|
221
|
+
/** Asset to sell (`XLM` | `CODE:Issuer` | `CODE-Issuer` | contractId) */
|
|
222
|
+
sellingAsset: string;
|
|
223
|
+
/** Asset to buy (same format as `sellingAsset`) */
|
|
224
|
+
buyingAsset: string;
|
|
225
|
+
/** Trade amount in stroops (1 unit = 10,000,000 stroops) */
|
|
226
|
+
amount: string | number;
|
|
227
|
+
/** Restrict to the direct market only (no intermediate-asset routes) */
|
|
228
|
+
direct?: boolean;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface QuotePathStep {
|
|
232
|
+
/** Selling asset contract id at this hop */
|
|
233
|
+
selling: string;
|
|
234
|
+
/** Buying asset contract id at this hop */
|
|
235
|
+
buying: string;
|
|
236
|
+
/** Maker order IDs matched at this hop */
|
|
237
|
+
orders: string[];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface QuotePath {
|
|
241
|
+
/** Amount sold, in stroops */
|
|
242
|
+
sold: string;
|
|
243
|
+
/** Amount bought, in stroops */
|
|
244
|
+
bought: string;
|
|
245
|
+
/** Ordered list of hops in the route */
|
|
246
|
+
path: QuotePathStep[];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface QuoteResult {
|
|
250
|
+
/** Base58-encoded quote id */
|
|
251
|
+
id: string;
|
|
252
|
+
/** Quote status */
|
|
253
|
+
status: 'success' | 'unfeasible' | 'rejected';
|
|
254
|
+
/** Trade direction */
|
|
255
|
+
direction: 'strict_send' | 'strict_receive';
|
|
256
|
+
/** Selling asset contract id */
|
|
257
|
+
sellingAsset: string;
|
|
258
|
+
/** Buying asset contract id */
|
|
259
|
+
buyingAsset: string;
|
|
260
|
+
/** Ledger sequence the quote was computed for */
|
|
261
|
+
ledger: number;
|
|
262
|
+
/** Candidate routes ranked by profitability (up to 10) */
|
|
263
|
+
paths: QuotePath[];
|
|
264
|
+
/** Error message (present only if status is not `success`) */
|
|
265
|
+
error?: string;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export interface DepthParams {
|
|
269
|
+
/** Market identifier `BASE/QUOTE` */
|
|
270
|
+
market: string;
|
|
271
|
+
/** Percentage band (±) around the center price (0 < depth ≤ 100, default 20) */
|
|
272
|
+
depth?: number;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export interface OrderbookDepth {
|
|
276
|
+
/** Ledger sequence */
|
|
277
|
+
ledger: number;
|
|
278
|
+
/** UNIX timestamp (seconds) */
|
|
279
|
+
timestamp: number;
|
|
280
|
+
/** `[price, quantity]` pairs sorted descending by price */
|
|
281
|
+
bids: Array<[string, string]>;
|
|
282
|
+
/** `[price, quantity]` pairs sorted ascending by price */
|
|
283
|
+
asks: Array<[string, string]>;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export interface CandlesParams {
|
|
287
|
+
/** Market identifier `BASE/QUOTE` */
|
|
288
|
+
market: string;
|
|
289
|
+
/** Lower boundary (UNIX seconds, default 0) */
|
|
290
|
+
from?: number;
|
|
291
|
+
/** Upper boundary (UNIX seconds, defaults to `from + resolution * 200`) */
|
|
292
|
+
to?: number;
|
|
293
|
+
/** Resolution in seconds or alias (`5m`,`15m`,`30m`,`1h`,`2h`,`4h`,`12h`,`1d`,`3d`,`1w`,`2w`, default `auto`) */
|
|
294
|
+
resolution?: number | string;
|
|
295
|
+
/** Sort order (default `desc`) */
|
|
296
|
+
order?: 'asc' | 'desc';
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** OHLCVT candle row: `[timestamp, open, high, low, close, baseVolume, quoteVolume, tradeCount]` */
|
|
300
|
+
export type Candle = [number, string, string, string, string, string, string, number];
|
|
301
|
+
|
|
302
|
+
export interface TickerEntry {
|
|
303
|
+
/** Market symbol `BASE/QUOTE` */
|
|
304
|
+
symbol: string;
|
|
305
|
+
/** Opening price 24h ago */
|
|
306
|
+
openPrice: string;
|
|
307
|
+
/** Highest price in the 24h window */
|
|
308
|
+
highPrice: string;
|
|
309
|
+
/** Lowest price in the 24h window */
|
|
310
|
+
lowPrice: string;
|
|
311
|
+
/** Most recent trade price */
|
|
312
|
+
lastPrice: string;
|
|
313
|
+
/** 24h base asset volume */
|
|
314
|
+
volume: string;
|
|
315
|
+
/** 24h quote asset volume */
|
|
316
|
+
quoteVolume: string;
|
|
317
|
+
/** 24h price change (percent) */
|
|
318
|
+
change: number;
|
|
319
|
+
/** Volume-weighted average price */
|
|
320
|
+
avgPrice: string;
|
|
321
|
+
/** 24h trade count */
|
|
322
|
+
trades: number;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface Ticker24hResult {
|
|
326
|
+
/** Ledger sequence */
|
|
327
|
+
ledger: number;
|
|
328
|
+
/** UNIX timestamp (seconds) */
|
|
329
|
+
timestamp: number;
|
|
330
|
+
/** Per-market 24h stats, sorted by trade count descending */
|
|
331
|
+
ticker: TickerEntry[];
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export interface MarketsParams {
|
|
335
|
+
/** Pagination cursor (`baseAsset-quoteAsset`) */
|
|
336
|
+
cursor?: string;
|
|
337
|
+
/** Max markets to return */
|
|
338
|
+
limit?: number | string;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export interface MarketInfo {
|
|
342
|
+
/** Base asset contract id */
|
|
343
|
+
baseAsset: string;
|
|
344
|
+
/** Quote asset contract id */
|
|
345
|
+
quoteAsset: string;
|
|
346
|
+
/** Pagination cursor for this market */
|
|
347
|
+
cursor: string;
|
|
348
|
+
/** Supported order types */
|
|
349
|
+
orderTypes: string[];
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export interface OrdersParams {
|
|
353
|
+
/** Filter by order owner address */
|
|
354
|
+
owner?: string;
|
|
355
|
+
/** Filter by asset(s) - matches orders selling or buying any of them */
|
|
356
|
+
asset?: string | string[];
|
|
357
|
+
/** Pagination cursor (order id) */
|
|
358
|
+
cursor?: string | bigint;
|
|
359
|
+
/** Max orders to return */
|
|
360
|
+
limit?: number | string;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export interface OrderHistoryParams {
|
|
364
|
+
/** Filter by order owner address */
|
|
365
|
+
owner?: string;
|
|
366
|
+
/** Asset pair `[base, quote]` (contract ids) */
|
|
367
|
+
pair?: string[];
|
|
368
|
+
/** Pagination cursor (order id) */
|
|
369
|
+
cursor?: string | bigint;
|
|
370
|
+
/** Max orders to return */
|
|
371
|
+
limit?: number | string;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface TradesParams {
|
|
375
|
+
/** Filter by trader address */
|
|
376
|
+
trader?: string;
|
|
377
|
+
/** Asset pair `[base, quote]` (contract ids) */
|
|
378
|
+
pair?: string[];
|
|
379
|
+
/** Pagination cursor (trade id) */
|
|
380
|
+
cursor?: string | bigint;
|
|
381
|
+
/** Max trades to return */
|
|
382
|
+
limit?: number | string;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/** Serialized order returned by the API */
|
|
386
|
+
export interface ApiOrder {
|
|
387
|
+
/** Order ID */
|
|
388
|
+
id: string;
|
|
389
|
+
/** Order status (`ACTIVE`|`FILLED`|`CANCELED`) */
|
|
390
|
+
status: string;
|
|
391
|
+
/** Order kind (`LIMIT`) */
|
|
392
|
+
kind: string;
|
|
393
|
+
/** Buying asset contract id */
|
|
394
|
+
buying: string;
|
|
395
|
+
/** Selling asset contract id */
|
|
396
|
+
selling: string;
|
|
397
|
+
/** Order price */
|
|
398
|
+
price: string;
|
|
399
|
+
/** Rational price representation */
|
|
400
|
+
rprice: string;
|
|
401
|
+
/** Total quote amount */
|
|
402
|
+
quote: string;
|
|
403
|
+
/** Amount left to sell/buy */
|
|
404
|
+
amount: string;
|
|
405
|
+
/** Maker address */
|
|
406
|
+
owner: string;
|
|
407
|
+
/** Expiration timestamp (UTC) */
|
|
408
|
+
expires?: string;
|
|
409
|
+
/** Iceberg amount */
|
|
410
|
+
iceberg?: string;
|
|
411
|
+
/** Stop price */
|
|
412
|
+
stop?: string;
|
|
413
|
+
/** Creation timestamp (UTC) */
|
|
414
|
+
created?: string;
|
|
415
|
+
/** Last update timestamp (UTC) */
|
|
416
|
+
updated?: string;
|
|
417
|
+
/** Pagination cursor */
|
|
418
|
+
cursor?: string;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** Serialized trade returned by the API */
|
|
422
|
+
export interface ApiTrade {
|
|
423
|
+
/** Trade ID */
|
|
424
|
+
id: string;
|
|
425
|
+
/** Matched order ID */
|
|
426
|
+
order: string;
|
|
427
|
+
/** Taker account address */
|
|
428
|
+
taker: string;
|
|
429
|
+
/** Maker account address */
|
|
430
|
+
maker: string;
|
|
431
|
+
/** Sold asset contract id */
|
|
432
|
+
soldAsset: string;
|
|
433
|
+
/** Bought asset contract id */
|
|
434
|
+
boughtAsset: string;
|
|
435
|
+
/** Sold tokens amount */
|
|
436
|
+
sold: string;
|
|
437
|
+
/** Bought tokens amount */
|
|
438
|
+
bought: string;
|
|
439
|
+
/** Approximate trade price */
|
|
440
|
+
price: string;
|
|
441
|
+
/** Pagination cursor */
|
|
442
|
+
cursor?: string;
|
|
443
|
+
/** Trade timestamp (UTC) */
|
|
444
|
+
timestamp: string;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** HTTP client for the AXIS Aggregator REST API */
|
|
448
|
+
export declare class AxisApiClient {
|
|
449
|
+
/** @param serverUrl - Base URL of the Aggregator server */
|
|
450
|
+
constructor(serverUrl: string);
|
|
451
|
+
|
|
452
|
+
/** Base URL of the Aggregator server */
|
|
453
|
+
readonly serverUrl: string;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Price quote and candidate trade routes for selling a fixed amount of the source asset
|
|
457
|
+
* @param params - Quote request parameters
|
|
458
|
+
* @returns Best routes ranked by profitability
|
|
459
|
+
*/
|
|
460
|
+
quoteSell(params: QuoteParams): Promise<QuoteResult>;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Price quote and candidate trade routes for buying a fixed amount of the destination asset
|
|
464
|
+
* @param params - Quote request parameters
|
|
465
|
+
* @returns Best routes ranked by profitability
|
|
466
|
+
*/
|
|
467
|
+
quoteBuy(params: QuoteParams): Promise<QuoteResult>;
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Order book depth aggregated into price buckets around the mid price
|
|
471
|
+
* @param params - Depth request parameters
|
|
472
|
+
* @returns Aggregated bids and asks
|
|
473
|
+
*/
|
|
474
|
+
getDepth(params: DepthParams): Promise<OrderbookDepth>;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* OHLCVT candlestick data (open, high, low, close, base volume, quote volume, trade count)
|
|
478
|
+
* @param params - Candles request parameters
|
|
479
|
+
* @returns Time-bucketed candles, max 200 per response
|
|
480
|
+
*/
|
|
481
|
+
getCandles(params: CandlesParams): Promise<Candle[]>;
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* 24-hour ticker statistics for every available market
|
|
485
|
+
* @returns Aggregated 24h stats per market
|
|
486
|
+
*/
|
|
487
|
+
getTicker24h(): Promise<Ticker24hResult>;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* List all active markets with pagination
|
|
491
|
+
* @param params - Pagination parameters
|
|
492
|
+
* @returns Active markets
|
|
493
|
+
*/
|
|
494
|
+
getMarkets(params?: MarketsParams): Promise<MarketInfo[]>;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Retrieve active orders, filterable by owner or asset
|
|
498
|
+
* @param params - Filter parameters
|
|
499
|
+
* @returns Active orders matching the filter
|
|
500
|
+
*/
|
|
501
|
+
getOrders(params?: OrdersParams): Promise<ApiOrder[]>;
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Retrieve a single order by ID
|
|
505
|
+
* @param id - Order ID
|
|
506
|
+
* @returns Order, or null if not found
|
|
507
|
+
*/
|
|
508
|
+
getOrder(id: bigint | string | number): Promise<ApiOrder | null>;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Retrieve archived/historical orders
|
|
512
|
+
* @param params - Filter parameters
|
|
513
|
+
* @returns Archived orders matching the filter
|
|
514
|
+
*/
|
|
515
|
+
getOrderHistory(params?: OrderHistoryParams): Promise<ApiOrder[]>;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Retrieve recent trades
|
|
519
|
+
* @param params - Filter parameters
|
|
520
|
+
* @returns Recent trades matching the filter
|
|
521
|
+
*/
|
|
522
|
+
getTrades(params?: TradesParams): Promise<ApiTrade[]>;
|
|
523
|
+
}
|