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