@bronlabs/intents-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,499 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "address",
6
+ "name": "_oracle",
7
+ "type": "address"
8
+ },
9
+ {
10
+ "internalType": "address",
11
+ "name": "_solverRegister",
12
+ "type": "address"
13
+ }
14
+ ],
15
+ "stateMutability": "nonpayable",
16
+ "type": "constructor"
17
+ },
18
+ {
19
+ "inputs": [],
20
+ "name": "BC_INVALID_CALLER",
21
+ "type": "error"
22
+ },
23
+ {
24
+ "inputs": [],
25
+ "name": "BC_INVALID_ORDER_STATUS",
26
+ "type": "error"
27
+ },
28
+ {
29
+ "inputs": [],
30
+ "name": "BC_INVALID_PARAMS",
31
+ "type": "error"
32
+ },
33
+ {
34
+ "inputs": [],
35
+ "name": "BC_NOT_ENOUGH_OPERATION_AMOUNT",
36
+ "type": "error"
37
+ },
38
+ {
39
+ "inputs": [],
40
+ "name": "BC_TIMEOUT",
41
+ "type": "error"
42
+ },
43
+ {
44
+ "anonymous": false,
45
+ "inputs": [
46
+ {
47
+ "indexed": false,
48
+ "internalType": "string",
49
+ "name": "orderId",
50
+ "type": "string"
51
+ },
52
+ {
53
+ "indexed": false,
54
+ "internalType": "enum IOrderEngine.OrderStatus",
55
+ "name": "status",
56
+ "type": "uint8"
57
+ }
58
+ ],
59
+ "name": "OrderStatusChanged",
60
+ "type": "event"
61
+ },
62
+ {
63
+ "inputs": [],
64
+ "name": "MAX_ACTION_DURATION",
65
+ "outputs": [
66
+ {
67
+ "internalType": "uint256",
68
+ "name": "",
69
+ "type": "uint256"
70
+ }
71
+ ],
72
+ "stateMutability": "view",
73
+ "type": "function"
74
+ },
75
+ {
76
+ "inputs": [
77
+ {
78
+ "components": [
79
+ {
80
+ "internalType": "string",
81
+ "name": "orderId",
82
+ "type": "string"
83
+ },
84
+ {
85
+ "internalType": "string",
86
+ "name": "baseNetworkId",
87
+ "type": "string"
88
+ },
89
+ {
90
+ "internalType": "string",
91
+ "name": "baseTokenAddress",
92
+ "type": "string"
93
+ },
94
+ {
95
+ "internalType": "string",
96
+ "name": "quoteNetworkId",
97
+ "type": "string"
98
+ },
99
+ {
100
+ "internalType": "string",
101
+ "name": "quoteTokenAddress",
102
+ "type": "string"
103
+ },
104
+ {
105
+ "internalType": "string",
106
+ "name": "recipientAddress",
107
+ "type": "string"
108
+ },
109
+ {
110
+ "internalType": "uint256",
111
+ "name": "amount",
112
+ "type": "uint256"
113
+ },
114
+ {
115
+ "internalType": "uint256",
116
+ "name": "baseTokenPriceToUsd_e4",
117
+ "type": "uint256"
118
+ },
119
+ {
120
+ "internalType": "uint256",
121
+ "name": "startPrice_e18",
122
+ "type": "uint256"
123
+ },
124
+ {
125
+ "internalType": "uint256",
126
+ "name": "endPrice_e18",
127
+ "type": "uint256"
128
+ },
129
+ {
130
+ "internalType": "uint256",
131
+ "name": "auctionDuration",
132
+ "type": "uint256"
133
+ }
134
+ ],
135
+ "internalType": "struct IOrderEngine.InitOrderParams",
136
+ "name": "_initOrderParams",
137
+ "type": "tuple"
138
+ }
139
+ ],
140
+ "name": "createOrder",
141
+ "outputs": [
142
+ {
143
+ "internalType": "string",
144
+ "name": "",
145
+ "type": "string"
146
+ }
147
+ ],
148
+ "stateMutability": "nonpayable",
149
+ "type": "function"
150
+ },
151
+ {
152
+ "inputs": [
153
+ {
154
+ "internalType": "string",
155
+ "name": "_orderId",
156
+ "type": "string"
157
+ }
158
+ ],
159
+ "name": "executeSolverTimeout",
160
+ "outputs": [],
161
+ "stateMutability": "nonpayable",
162
+ "type": "function"
163
+ },
164
+ {
165
+ "inputs": [
166
+ {
167
+ "internalType": "string",
168
+ "name": "_orderId",
169
+ "type": "string"
170
+ }
171
+ ],
172
+ "name": "executeUserTimeout",
173
+ "outputs": [],
174
+ "stateMutability": "nonpayable",
175
+ "type": "function"
176
+ },
177
+ {
178
+ "inputs": [
179
+ {
180
+ "internalType": "string",
181
+ "name": "_orderId",
182
+ "type": "string"
183
+ }
184
+ ],
185
+ "name": "getRecipientAddressOnBaseChain",
186
+ "outputs": [
187
+ {
188
+ "internalType": "string",
189
+ "name": "",
190
+ "type": "string"
191
+ }
192
+ ],
193
+ "stateMutability": "view",
194
+ "type": "function"
195
+ },
196
+ {
197
+ "inputs": [
198
+ {
199
+ "internalType": "string",
200
+ "name": "_orderId",
201
+ "type": "string"
202
+ }
203
+ ],
204
+ "name": "getRecipientAddressOnQuoteChain",
205
+ "outputs": [
206
+ {
207
+ "internalType": "string",
208
+ "name": "",
209
+ "type": "string"
210
+ }
211
+ ],
212
+ "stateMutability": "view",
213
+ "type": "function"
214
+ },
215
+ {
216
+ "inputs": [
217
+ {
218
+ "internalType": "string",
219
+ "name": "_orderId",
220
+ "type": "string"
221
+ }
222
+ ],
223
+ "name": "liquidateOrder",
224
+ "outputs": [],
225
+ "stateMutability": "nonpayable",
226
+ "type": "function"
227
+ },
228
+ {
229
+ "inputs": [],
230
+ "name": "oracle",
231
+ "outputs": [
232
+ {
233
+ "internalType": "address",
234
+ "name": "",
235
+ "type": "address"
236
+ }
237
+ ],
238
+ "stateMutability": "view",
239
+ "type": "function"
240
+ },
241
+ {
242
+ "inputs": [
243
+ {
244
+ "internalType": "string",
245
+ "name": "",
246
+ "type": "string"
247
+ }
248
+ ],
249
+ "name": "orders",
250
+ "outputs": [
251
+ {
252
+ "internalType": "address",
253
+ "name": "user",
254
+ "type": "address"
255
+ },
256
+ {
257
+ "internalType": "address",
258
+ "name": "solver",
259
+ "type": "address"
260
+ },
261
+ {
262
+ "components": [
263
+ {
264
+ "internalType": "string",
265
+ "name": "networkId",
266
+ "type": "string"
267
+ },
268
+ {
269
+ "internalType": "string",
270
+ "name": "recipientAddress",
271
+ "type": "string"
272
+ },
273
+ {
274
+ "internalType": "string",
275
+ "name": "userTxHash",
276
+ "type": "string"
277
+ },
278
+ {
279
+ "internalType": "string",
280
+ "name": "tokenAddress",
281
+ "type": "string"
282
+ }
283
+ ],
284
+ "internalType": "struct IOrderEngine.BaseParams",
285
+ "name": "baseParams",
286
+ "type": "tuple"
287
+ },
288
+ {
289
+ "components": [
290
+ {
291
+ "internalType": "string",
292
+ "name": "networkId",
293
+ "type": "string"
294
+ },
295
+ {
296
+ "internalType": "string",
297
+ "name": "recipientAddress",
298
+ "type": "string"
299
+ },
300
+ {
301
+ "internalType": "string",
302
+ "name": "solverTxHash",
303
+ "type": "string"
304
+ },
305
+ {
306
+ "internalType": "string",
307
+ "name": "tokenAddress",
308
+ "type": "string"
309
+ }
310
+ ],
311
+ "internalType": "struct IOrderEngine.QuoteParams",
312
+ "name": "quoteParams",
313
+ "type": "tuple"
314
+ },
315
+ {
316
+ "components": [
317
+ {
318
+ "internalType": "uint256",
319
+ "name": "startPrice_e18",
320
+ "type": "uint256"
321
+ },
322
+ {
323
+ "internalType": "uint256",
324
+ "name": "endPrice_e18",
325
+ "type": "uint256"
326
+ },
327
+ {
328
+ "internalType": "uint256",
329
+ "name": "auctionDuration",
330
+ "type": "uint256"
331
+ }
332
+ ],
333
+ "internalType": "struct IOrderEngine.AuctionParams",
334
+ "name": "auctionParams",
335
+ "type": "tuple"
336
+ },
337
+ {
338
+ "components": [
339
+ {
340
+ "internalType": "uint256",
341
+ "name": "amount",
342
+ "type": "uint256"
343
+ },
344
+ {
345
+ "internalType": "uint256",
346
+ "name": "price_e18",
347
+ "type": "uint256"
348
+ },
349
+ {
350
+ "internalType": "uint256",
351
+ "name": "baseTokenPriceToUsd_e4",
352
+ "type": "uint256"
353
+ },
354
+ {
355
+ "internalType": "uint256",
356
+ "name": "liquidationPrice",
357
+ "type": "uint256"
358
+ }
359
+ ],
360
+ "internalType": "struct IOrderEngine.PricingParams",
361
+ "name": "pricingParams",
362
+ "type": "tuple"
363
+ },
364
+ {
365
+ "internalType": "uint64",
366
+ "name": "updatedAt",
367
+ "type": "uint64"
368
+ },
369
+ {
370
+ "internalType": "enum IOrderEngine.OrderStatus",
371
+ "name": "status",
372
+ "type": "uint8"
373
+ }
374
+ ],
375
+ "stateMutability": "view",
376
+ "type": "function"
377
+ },
378
+ {
379
+ "inputs": [
380
+ {
381
+ "internalType": "string",
382
+ "name": "_orderId",
383
+ "type": "string"
384
+ },
385
+ {
386
+ "internalType": "uint256",
387
+ "name": "_liquidationPrice",
388
+ "type": "uint256"
389
+ }
390
+ ],
391
+ "name": "prepareLiquidateOrder",
392
+ "outputs": [],
393
+ "stateMutability": "nonpayable",
394
+ "type": "function"
395
+ },
396
+ {
397
+ "inputs": [
398
+ {
399
+ "internalType": "string",
400
+ "name": "_orderId",
401
+ "type": "string"
402
+ },
403
+ {
404
+ "internalType": "bool",
405
+ "name": "_isConfirmed",
406
+ "type": "bool"
407
+ }
408
+ ],
409
+ "name": "setOracleConfirmSolverTx",
410
+ "outputs": [],
411
+ "stateMutability": "nonpayable",
412
+ "type": "function"
413
+ },
414
+ {
415
+ "inputs": [
416
+ {
417
+ "internalType": "string",
418
+ "name": "_orderId",
419
+ "type": "string"
420
+ },
421
+ {
422
+ "internalType": "bool",
423
+ "name": "_isConfirmed",
424
+ "type": "bool"
425
+ }
426
+ ],
427
+ "name": "setOracleConfirmUserTx",
428
+ "outputs": [],
429
+ "stateMutability": "nonpayable",
430
+ "type": "function"
431
+ },
432
+ {
433
+ "inputs": [
434
+ {
435
+ "internalType": "string",
436
+ "name": "_orderId",
437
+ "type": "string"
438
+ },
439
+ {
440
+ "internalType": "string",
441
+ "name": "_solverTxHash",
442
+ "type": "string"
443
+ }
444
+ ],
445
+ "name": "setSolverTxOnQuoteChain",
446
+ "outputs": [],
447
+ "stateMutability": "nonpayable",
448
+ "type": "function"
449
+ },
450
+ {
451
+ "inputs": [
452
+ {
453
+ "internalType": "string",
454
+ "name": "_orderId",
455
+ "type": "string"
456
+ },
457
+ {
458
+ "internalType": "string",
459
+ "name": "_userTxHash",
460
+ "type": "string"
461
+ }
462
+ ],
463
+ "name": "setUserTxOnBaseChain",
464
+ "outputs": [],
465
+ "stateMutability": "nonpayable",
466
+ "type": "function"
467
+ },
468
+ {
469
+ "inputs": [
470
+ {
471
+ "internalType": "string",
472
+ "name": "_orderId",
473
+ "type": "string"
474
+ },
475
+ {
476
+ "internalType": "string",
477
+ "name": "_solverAddressOnBaseChain",
478
+ "type": "string"
479
+ }
480
+ ],
481
+ "name": "solverReact",
482
+ "outputs": [],
483
+ "stateMutability": "nonpayable",
484
+ "type": "function"
485
+ },
486
+ {
487
+ "inputs": [],
488
+ "name": "solverRegister",
489
+ "outputs": [
490
+ {
491
+ "internalType": "contract ISolverRegister",
492
+ "name": "",
493
+ "type": "address"
494
+ }
495
+ ],
496
+ "stateMutability": "view",
497
+ "type": "function"
498
+ }
499
+ ]
@@ -0,0 +1,19 @@
1
+ export interface NetworkConfig {
2
+ rpcUrl: string;
3
+ walletAddress?: string;
4
+ walletPrivateKey?: string;
5
+ }
6
+ export interface IntentsConfig {
7
+ rpcUrl: string;
8
+ orderEngineAddress: string;
9
+ oracleAggregatorAddress?: string;
10
+ oraclePrivateKey?: string;
11
+ solverPrivateKey?: string;
12
+ startBlockOffset: number;
13
+ pollingInterval: number;
14
+ maxRetries: number;
15
+ retryDelay: number;
16
+ networks: {
17
+ [key: string]: NetworkConfig;
18
+ };
19
+ }
package/dist/config.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { ethers } from 'ethers';
2
+ export declare const initOrderEngine: (orderEngineAddress: string, provider: ethers.providers.JsonRpcProvider | ethers.Signer) => ethers.Contract;
3
+ export declare const initOracleAggregator: (oracleAggregatorAddress: string, provider: ethers.providers.JsonRpcProvider | ethers.Signer) => ethers.Contract;
@@ -0,0 +1,8 @@
1
+ import { ethers } from 'ethers';
2
+ import * as fs from 'node:fs';
3
+ import * as path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
+ export const initOrderEngine = (orderEngineAddress, provider) => new ethers.Contract(orderEngineAddress, JSON.parse(fs.readFileSync(path.join(__dirname, '../abi/OrderEngine.json'), 'utf8')), provider);
7
+ export const initOracleAggregator = (oracleAggregatorAddress, provider) => new ethers.Contract(oracleAggregatorAddress, JSON.parse(fs.readFileSync(path.join(__dirname, '../abi/OracleAggregator.json'), 'utf8')), provider);
8
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,kBAA0B,EAAE,QAA0D,EAAE,EAAE,CACxH,IAAI,MAAM,CAAC,QAAQ,CACjB,kBAAkB,EAClB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,yBAAyB,CAAC,EAAE,MAAM,CAAC,CAAC,EACpF,QAAQ,CACT,CAAC;AAEJ,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,uBAA+B,EAAE,QAA0D,EAAE,EAAE,CAClI,IAAI,MAAM,CAAC,QAAQ,CACjB,uBAAuB,EACvB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,8BAA8B,CAAC,EAAE,MAAM,CAAC,CAAC,EACzF,QAAQ,CACT,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare class EventQueue<T> {
2
+ private readonly queue;
3
+ constructor();
4
+ add(event: T): void;
5
+ peek(): T | undefined;
6
+ remove(): T | undefined;
7
+ isEmpty(): boolean;
8
+ size(): number;
9
+ }
@@ -0,0 +1,21 @@
1
+ export class EventQueue {
2
+ constructor() {
3
+ this.queue = [];
4
+ }
5
+ add(event) {
6
+ this.queue.push(event);
7
+ }
8
+ peek() {
9
+ return this.queue[0];
10
+ }
11
+ remove() {
12
+ return this.queue.shift();
13
+ }
14
+ isEmpty() {
15
+ return this.queue.length === 0;
16
+ }
17
+ size() {
18
+ return this.queue.length;
19
+ }
20
+ }
21
+ //# sourceMappingURL=eventQueue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventQueue.js","sourceRoot":"","sources":["../src/eventQueue.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAU;IAIrB;QACE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IAED,GAAG,CAAC,KAAQ;QACV,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ export * from './orderIndexer.js';
2
+ export * from './orderProcessor.js';
3
+ export * from './config.js';
4
+ export * from './eventQueue.js';
5
+ export * from './contracts.js';
6
+ export * from './utils.js';
7
+ export * from './networks/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export * from './orderIndexer.js';
2
+ export * from './orderProcessor.js';
3
+ export * from './config.js';
4
+ export * from './eventQueue.js';
5
+ export * from './contracts.js';
6
+ export * from './utils.js';
7
+ export * from './networks/index.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { BigNumber } from 'ethers';
2
+ import { Network, TransactionData } from './index.js';
3
+ export declare class EvmNetwork implements Network {
4
+ private readonly rpcUrl;
5
+ private readonly provider;
6
+ private readonly confirmations;
7
+ private readonly nativeAssetDecimals;
8
+ readonly retryDelay: number;
9
+ constructor(rpcUrl: string, confirmations: number);
10
+ getDecimals(tokenAddress: string): Promise<number>;
11
+ getTxData(txHash: string, tokenAddress: string): Promise<TransactionData | undefined>;
12
+ transfer(privateKey: string, to: string, value: BigNumber, tokenAddress: string): Promise<string>;
13
+ }