@hyperbridge/sdk 1.2.0 → 1.3.0-canary-000001

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.
@@ -1,10 +1,591 @@
1
1
  import { ConsolaInstance } from 'consola';
2
2
  import { GraphQLClient } from 'graphql-request';
3
- import { Hex, Log, PublicClient } from 'viem';
3
+ import { Hex, ContractFunctionArgs, Log, PublicClient } from 'viem';
4
4
  import { ApiPromise } from '@polkadot/api';
5
5
  import { SignerOptions } from '@polkadot/api/types';
6
6
  import { Chain } from 'viem/chains';
7
7
 
8
+ declare const _default: {
9
+ ABI: readonly [{
10
+ readonly inputs: readonly [];
11
+ readonly name: "ChallengePeriodNotElapsed";
12
+ readonly type: "error";
13
+ }, {
14
+ readonly inputs: readonly [];
15
+ readonly name: "ConsensusClientExpired";
16
+ readonly type: "error";
17
+ }, {
18
+ readonly inputs: readonly [];
19
+ readonly name: "DuplicateMessage";
20
+ readonly type: "error";
21
+ }, {
22
+ readonly inputs: readonly [];
23
+ readonly name: "HostFrozen";
24
+ readonly type: "error";
25
+ }, {
26
+ readonly inputs: readonly [];
27
+ readonly name: "InvalidMessageDestination";
28
+ readonly type: "error";
29
+ }, {
30
+ readonly inputs: readonly [];
31
+ readonly name: "InvalidProof";
32
+ readonly type: "error";
33
+ }, {
34
+ readonly inputs: readonly [];
35
+ readonly name: "MessageNotTimedOut";
36
+ readonly type: "error";
37
+ }, {
38
+ readonly inputs: readonly [];
39
+ readonly name: "MessageTimedOut";
40
+ readonly type: "error";
41
+ }, {
42
+ readonly inputs: readonly [];
43
+ readonly name: "StateCommitmentNotFound";
44
+ readonly type: "error";
45
+ }, {
46
+ readonly inputs: readonly [];
47
+ readonly name: "UnknownMessage";
48
+ readonly type: "error";
49
+ }, {
50
+ readonly inputs: readonly [{
51
+ readonly internalType: "contract IIsmpHost";
52
+ readonly name: "host";
53
+ readonly type: "address";
54
+ }, {
55
+ readonly internalType: "bytes";
56
+ readonly name: "proof";
57
+ readonly type: "bytes";
58
+ }];
59
+ readonly name: "handleConsensus";
60
+ readonly outputs: readonly [];
61
+ readonly stateMutability: "nonpayable";
62
+ readonly type: "function";
63
+ }, {
64
+ readonly inputs: readonly [{
65
+ readonly internalType: "contract IIsmpHost";
66
+ readonly name: "host";
67
+ readonly type: "address";
68
+ }, {
69
+ readonly components: readonly [{
70
+ readonly components: readonly [{
71
+ readonly internalType: "bytes";
72
+ readonly name: "source";
73
+ readonly type: "bytes";
74
+ }, {
75
+ readonly internalType: "bytes";
76
+ readonly name: "dest";
77
+ readonly type: "bytes";
78
+ }, {
79
+ readonly internalType: "uint64";
80
+ readonly name: "nonce";
81
+ readonly type: "uint64";
82
+ }, {
83
+ readonly internalType: "address";
84
+ readonly name: "from";
85
+ readonly type: "address";
86
+ }, {
87
+ readonly internalType: "uint64";
88
+ readonly name: "timeoutTimestamp";
89
+ readonly type: "uint64";
90
+ }, {
91
+ readonly internalType: "bytes[]";
92
+ readonly name: "keys";
93
+ readonly type: "bytes[]";
94
+ }, {
95
+ readonly internalType: "uint64";
96
+ readonly name: "height";
97
+ readonly type: "uint64";
98
+ }, {
99
+ readonly internalType: "bytes";
100
+ readonly name: "context";
101
+ readonly type: "bytes";
102
+ }];
103
+ readonly internalType: "struct GetRequest[]";
104
+ readonly name: "timeouts";
105
+ readonly type: "tuple[]";
106
+ }, {
107
+ readonly components: readonly [{
108
+ readonly internalType: "uint256";
109
+ readonly name: "stateMachineId";
110
+ readonly type: "uint256";
111
+ }, {
112
+ readonly internalType: "uint256";
113
+ readonly name: "height";
114
+ readonly type: "uint256";
115
+ }];
116
+ readonly internalType: "struct StateMachineHeight";
117
+ readonly name: "height";
118
+ readonly type: "tuple";
119
+ }, {
120
+ readonly internalType: "bytes[]";
121
+ readonly name: "proof";
122
+ readonly type: "bytes[]";
123
+ }];
124
+ readonly internalType: "struct GetTimeoutMessage";
125
+ readonly name: "message";
126
+ readonly type: "tuple";
127
+ }];
128
+ readonly name: "handleGetRequestTimeouts";
129
+ readonly outputs: readonly [];
130
+ readonly stateMutability: "nonpayable";
131
+ readonly type: "function";
132
+ }, {
133
+ readonly inputs: readonly [{
134
+ readonly internalType: "contract IIsmpHost";
135
+ readonly name: "host";
136
+ readonly type: "address";
137
+ }, {
138
+ readonly components: readonly [{
139
+ readonly components: readonly [{
140
+ readonly components: readonly [{
141
+ readonly internalType: "uint256";
142
+ readonly name: "stateMachineId";
143
+ readonly type: "uint256";
144
+ }, {
145
+ readonly internalType: "uint256";
146
+ readonly name: "height";
147
+ readonly type: "uint256";
148
+ }];
149
+ readonly internalType: "struct StateMachineHeight";
150
+ readonly name: "height";
151
+ readonly type: "tuple";
152
+ }, {
153
+ readonly internalType: "bytes32[]";
154
+ readonly name: "multiproof";
155
+ readonly type: "bytes32[]";
156
+ }, {
157
+ readonly internalType: "uint256";
158
+ readonly name: "leafCount";
159
+ readonly type: "uint256";
160
+ }];
161
+ readonly internalType: "struct Proof";
162
+ readonly name: "proof";
163
+ readonly type: "tuple";
164
+ }, {
165
+ readonly components: readonly [{
166
+ readonly components: readonly [{
167
+ readonly components: readonly [{
168
+ readonly internalType: "bytes";
169
+ readonly name: "source";
170
+ readonly type: "bytes";
171
+ }, {
172
+ readonly internalType: "bytes";
173
+ readonly name: "dest";
174
+ readonly type: "bytes";
175
+ }, {
176
+ readonly internalType: "uint64";
177
+ readonly name: "nonce";
178
+ readonly type: "uint64";
179
+ }, {
180
+ readonly internalType: "address";
181
+ readonly name: "from";
182
+ readonly type: "address";
183
+ }, {
184
+ readonly internalType: "uint64";
185
+ readonly name: "timeoutTimestamp";
186
+ readonly type: "uint64";
187
+ }, {
188
+ readonly internalType: "bytes[]";
189
+ readonly name: "keys";
190
+ readonly type: "bytes[]";
191
+ }, {
192
+ readonly internalType: "uint64";
193
+ readonly name: "height";
194
+ readonly type: "uint64";
195
+ }, {
196
+ readonly internalType: "bytes";
197
+ readonly name: "context";
198
+ readonly type: "bytes";
199
+ }];
200
+ readonly internalType: "struct GetRequest";
201
+ readonly name: "request";
202
+ readonly type: "tuple";
203
+ }, {
204
+ readonly components: readonly [{
205
+ readonly internalType: "bytes";
206
+ readonly name: "key";
207
+ readonly type: "bytes";
208
+ }, {
209
+ readonly internalType: "bytes";
210
+ readonly name: "value";
211
+ readonly type: "bytes";
212
+ }];
213
+ readonly internalType: "struct StorageValue[]";
214
+ readonly name: "values";
215
+ readonly type: "tuple[]";
216
+ }];
217
+ readonly internalType: "struct GetResponse";
218
+ readonly name: "response";
219
+ readonly type: "tuple";
220
+ }, {
221
+ readonly internalType: "uint256";
222
+ readonly name: "index";
223
+ readonly type: "uint256";
224
+ }, {
225
+ readonly internalType: "uint256";
226
+ readonly name: "kIndex";
227
+ readonly type: "uint256";
228
+ }];
229
+ readonly internalType: "struct GetResponseLeaf[]";
230
+ readonly name: "responses";
231
+ readonly type: "tuple[]";
232
+ }];
233
+ readonly internalType: "struct GetResponseMessage";
234
+ readonly name: "message";
235
+ readonly type: "tuple";
236
+ }];
237
+ readonly name: "handleGetResponses";
238
+ readonly outputs: readonly [];
239
+ readonly stateMutability: "nonpayable";
240
+ readonly type: "function";
241
+ }, {
242
+ readonly inputs: readonly [{
243
+ readonly internalType: "contract IIsmpHost";
244
+ readonly name: "host";
245
+ readonly type: "address";
246
+ }, {
247
+ readonly components: readonly [{
248
+ readonly components: readonly [{
249
+ readonly internalType: "bytes";
250
+ readonly name: "source";
251
+ readonly type: "bytes";
252
+ }, {
253
+ readonly internalType: "bytes";
254
+ readonly name: "dest";
255
+ readonly type: "bytes";
256
+ }, {
257
+ readonly internalType: "uint64";
258
+ readonly name: "nonce";
259
+ readonly type: "uint64";
260
+ }, {
261
+ readonly internalType: "bytes";
262
+ readonly name: "from";
263
+ readonly type: "bytes";
264
+ }, {
265
+ readonly internalType: "bytes";
266
+ readonly name: "to";
267
+ readonly type: "bytes";
268
+ }, {
269
+ readonly internalType: "uint64";
270
+ readonly name: "timeoutTimestamp";
271
+ readonly type: "uint64";
272
+ }, {
273
+ readonly internalType: "bytes";
274
+ readonly name: "body";
275
+ readonly type: "bytes";
276
+ }];
277
+ readonly internalType: "struct PostRequest[]";
278
+ readonly name: "timeouts";
279
+ readonly type: "tuple[]";
280
+ }, {
281
+ readonly components: readonly [{
282
+ readonly internalType: "uint256";
283
+ readonly name: "stateMachineId";
284
+ readonly type: "uint256";
285
+ }, {
286
+ readonly internalType: "uint256";
287
+ readonly name: "height";
288
+ readonly type: "uint256";
289
+ }];
290
+ readonly internalType: "struct StateMachineHeight";
291
+ readonly name: "height";
292
+ readonly type: "tuple";
293
+ }, {
294
+ readonly internalType: "bytes[]";
295
+ readonly name: "proof";
296
+ readonly type: "bytes[]";
297
+ }];
298
+ readonly internalType: "struct PostRequestTimeoutMessage";
299
+ readonly name: "message";
300
+ readonly type: "tuple";
301
+ }];
302
+ readonly name: "handlePostRequestTimeouts";
303
+ readonly outputs: readonly [];
304
+ readonly stateMutability: "nonpayable";
305
+ readonly type: "function";
306
+ }, {
307
+ readonly inputs: readonly [{
308
+ readonly internalType: "contract IIsmpHost";
309
+ readonly name: "host";
310
+ readonly type: "address";
311
+ }, {
312
+ readonly components: readonly [{
313
+ readonly components: readonly [{
314
+ readonly components: readonly [{
315
+ readonly internalType: "uint256";
316
+ readonly name: "stateMachineId";
317
+ readonly type: "uint256";
318
+ }, {
319
+ readonly internalType: "uint256";
320
+ readonly name: "height";
321
+ readonly type: "uint256";
322
+ }];
323
+ readonly internalType: "struct StateMachineHeight";
324
+ readonly name: "height";
325
+ readonly type: "tuple";
326
+ }, {
327
+ readonly internalType: "bytes32[]";
328
+ readonly name: "multiproof";
329
+ readonly type: "bytes32[]";
330
+ }, {
331
+ readonly internalType: "uint256";
332
+ readonly name: "leafCount";
333
+ readonly type: "uint256";
334
+ }];
335
+ readonly internalType: "struct Proof";
336
+ readonly name: "proof";
337
+ readonly type: "tuple";
338
+ }, {
339
+ readonly components: readonly [{
340
+ readonly components: readonly [{
341
+ readonly internalType: "bytes";
342
+ readonly name: "source";
343
+ readonly type: "bytes";
344
+ }, {
345
+ readonly internalType: "bytes";
346
+ readonly name: "dest";
347
+ readonly type: "bytes";
348
+ }, {
349
+ readonly internalType: "uint64";
350
+ readonly name: "nonce";
351
+ readonly type: "uint64";
352
+ }, {
353
+ readonly internalType: "bytes";
354
+ readonly name: "from";
355
+ readonly type: "bytes";
356
+ }, {
357
+ readonly internalType: "bytes";
358
+ readonly name: "to";
359
+ readonly type: "bytes";
360
+ }, {
361
+ readonly internalType: "uint64";
362
+ readonly name: "timeoutTimestamp";
363
+ readonly type: "uint64";
364
+ }, {
365
+ readonly internalType: "bytes";
366
+ readonly name: "body";
367
+ readonly type: "bytes";
368
+ }];
369
+ readonly internalType: "struct PostRequest";
370
+ readonly name: "request";
371
+ readonly type: "tuple";
372
+ }, {
373
+ readonly internalType: "uint256";
374
+ readonly name: "index";
375
+ readonly type: "uint256";
376
+ }, {
377
+ readonly internalType: "uint256";
378
+ readonly name: "kIndex";
379
+ readonly type: "uint256";
380
+ }];
381
+ readonly internalType: "struct PostRequestLeaf[]";
382
+ readonly name: "requests";
383
+ readonly type: "tuple[]";
384
+ }];
385
+ readonly internalType: "struct PostRequestMessage";
386
+ readonly name: "request";
387
+ readonly type: "tuple";
388
+ }];
389
+ readonly name: "handlePostRequests";
390
+ readonly outputs: readonly [];
391
+ readonly stateMutability: "nonpayable";
392
+ readonly type: "function";
393
+ }, {
394
+ readonly inputs: readonly [{
395
+ readonly internalType: "contract IIsmpHost";
396
+ readonly name: "host";
397
+ readonly type: "address";
398
+ }, {
399
+ readonly components: readonly [{
400
+ readonly components: readonly [{
401
+ readonly components: readonly [{
402
+ readonly internalType: "bytes";
403
+ readonly name: "source";
404
+ readonly type: "bytes";
405
+ }, {
406
+ readonly internalType: "bytes";
407
+ readonly name: "dest";
408
+ readonly type: "bytes";
409
+ }, {
410
+ readonly internalType: "uint64";
411
+ readonly name: "nonce";
412
+ readonly type: "uint64";
413
+ }, {
414
+ readonly internalType: "bytes";
415
+ readonly name: "from";
416
+ readonly type: "bytes";
417
+ }, {
418
+ readonly internalType: "bytes";
419
+ readonly name: "to";
420
+ readonly type: "bytes";
421
+ }, {
422
+ readonly internalType: "uint64";
423
+ readonly name: "timeoutTimestamp";
424
+ readonly type: "uint64";
425
+ }, {
426
+ readonly internalType: "bytes";
427
+ readonly name: "body";
428
+ readonly type: "bytes";
429
+ }];
430
+ readonly internalType: "struct PostRequest";
431
+ readonly name: "request";
432
+ readonly type: "tuple";
433
+ }, {
434
+ readonly internalType: "bytes";
435
+ readonly name: "response";
436
+ readonly type: "bytes";
437
+ }, {
438
+ readonly internalType: "uint64";
439
+ readonly name: "timeoutTimestamp";
440
+ readonly type: "uint64";
441
+ }];
442
+ readonly internalType: "struct PostResponse[]";
443
+ readonly name: "timeouts";
444
+ readonly type: "tuple[]";
445
+ }, {
446
+ readonly components: readonly [{
447
+ readonly internalType: "uint256";
448
+ readonly name: "stateMachineId";
449
+ readonly type: "uint256";
450
+ }, {
451
+ readonly internalType: "uint256";
452
+ readonly name: "height";
453
+ readonly type: "uint256";
454
+ }];
455
+ readonly internalType: "struct StateMachineHeight";
456
+ readonly name: "height";
457
+ readonly type: "tuple";
458
+ }, {
459
+ readonly internalType: "bytes[]";
460
+ readonly name: "proof";
461
+ readonly type: "bytes[]";
462
+ }];
463
+ readonly internalType: "struct PostResponseTimeoutMessage";
464
+ readonly name: "message";
465
+ readonly type: "tuple";
466
+ }];
467
+ readonly name: "handlePostResponseTimeouts";
468
+ readonly outputs: readonly [];
469
+ readonly stateMutability: "nonpayable";
470
+ readonly type: "function";
471
+ }, {
472
+ readonly inputs: readonly [{
473
+ readonly internalType: "contract IIsmpHost";
474
+ readonly name: "host";
475
+ readonly type: "address";
476
+ }, {
477
+ readonly components: readonly [{
478
+ readonly components: readonly [{
479
+ readonly components: readonly [{
480
+ readonly internalType: "uint256";
481
+ readonly name: "stateMachineId";
482
+ readonly type: "uint256";
483
+ }, {
484
+ readonly internalType: "uint256";
485
+ readonly name: "height";
486
+ readonly type: "uint256";
487
+ }];
488
+ readonly internalType: "struct StateMachineHeight";
489
+ readonly name: "height";
490
+ readonly type: "tuple";
491
+ }, {
492
+ readonly internalType: "bytes32[]";
493
+ readonly name: "multiproof";
494
+ readonly type: "bytes32[]";
495
+ }, {
496
+ readonly internalType: "uint256";
497
+ readonly name: "leafCount";
498
+ readonly type: "uint256";
499
+ }];
500
+ readonly internalType: "struct Proof";
501
+ readonly name: "proof";
502
+ readonly type: "tuple";
503
+ }, {
504
+ readonly components: readonly [{
505
+ readonly components: readonly [{
506
+ readonly components: readonly [{
507
+ readonly internalType: "bytes";
508
+ readonly name: "source";
509
+ readonly type: "bytes";
510
+ }, {
511
+ readonly internalType: "bytes";
512
+ readonly name: "dest";
513
+ readonly type: "bytes";
514
+ }, {
515
+ readonly internalType: "uint64";
516
+ readonly name: "nonce";
517
+ readonly type: "uint64";
518
+ }, {
519
+ readonly internalType: "bytes";
520
+ readonly name: "from";
521
+ readonly type: "bytes";
522
+ }, {
523
+ readonly internalType: "bytes";
524
+ readonly name: "to";
525
+ readonly type: "bytes";
526
+ }, {
527
+ readonly internalType: "uint64";
528
+ readonly name: "timeoutTimestamp";
529
+ readonly type: "uint64";
530
+ }, {
531
+ readonly internalType: "bytes";
532
+ readonly name: "body";
533
+ readonly type: "bytes";
534
+ }];
535
+ readonly internalType: "struct PostRequest";
536
+ readonly name: "request";
537
+ readonly type: "tuple";
538
+ }, {
539
+ readonly internalType: "bytes";
540
+ readonly name: "response";
541
+ readonly type: "bytes";
542
+ }, {
543
+ readonly internalType: "uint64";
544
+ readonly name: "timeoutTimestamp";
545
+ readonly type: "uint64";
546
+ }];
547
+ readonly internalType: "struct PostResponse";
548
+ readonly name: "response";
549
+ readonly type: "tuple";
550
+ }, {
551
+ readonly internalType: "uint256";
552
+ readonly name: "index";
553
+ readonly type: "uint256";
554
+ }, {
555
+ readonly internalType: "uint256";
556
+ readonly name: "kIndex";
557
+ readonly type: "uint256";
558
+ }];
559
+ readonly internalType: "struct PostResponseLeaf[]";
560
+ readonly name: "responses";
561
+ readonly type: "tuple[]";
562
+ }];
563
+ readonly internalType: "struct PostResponseMessage";
564
+ readonly name: "response";
565
+ readonly type: "tuple";
566
+ }];
567
+ readonly name: "handlePostResponses";
568
+ readonly outputs: readonly [];
569
+ readonly stateMutability: "nonpayable";
570
+ readonly type: "function";
571
+ }, {
572
+ readonly inputs: readonly [{
573
+ readonly internalType: "bytes4";
574
+ readonly name: "interfaceId";
575
+ readonly type: "bytes4";
576
+ }];
577
+ readonly name: "supportsInterface";
578
+ readonly outputs: readonly [{
579
+ readonly internalType: "bool";
580
+ readonly name: "";
581
+ readonly type: "bool";
582
+ }];
583
+ readonly stateMutability: "view";
584
+ readonly type: "function";
585
+ }];
586
+ };
587
+
588
+ type EstimateGasCallData = ContractFunctionArgs<typeof _default.ABI, "nonpayable" | "payable", "handlePostRequests">;
8
589
  type HexString = `0x${string}`;
9
590
  interface IConfig {
10
591
  source: IEvmConfig | ISubstrateConfig;
@@ -73,6 +654,9 @@ interface ClientConfig {
73
654
  }
74
655
  interface RetryConfig {
75
656
  maxRetries: number;
657
+ /**
658
+ * @description The initial backoff time in milliseconds before the first retry attempt.
659
+ */
76
660
  backoffMs: number;
77
661
  logMessage?: string;
78
662
  logger?: ConsolaInstance;
@@ -939,9 +1523,46 @@ interface OrderResponse {
939
1523
  }>;
940
1524
  };
941
1525
  }
942
- declare class AbortSignalInternal extends Error {
943
- constructor(message: string);
944
- static isError(error: unknown): error is AbortSignalInternal;
1526
+ interface TokenPrice {
1527
+ symbol: string;
1528
+ address?: string;
1529
+ currency: string;
1530
+ price: string;
1531
+ lastUpdatedAt: bigint;
1532
+ }
1533
+ interface TokenPricesResponse {
1534
+ tokenPrices: {
1535
+ nodes: Array<{
1536
+ id: string;
1537
+ symbol: string;
1538
+ address: string;
1539
+ currency: string;
1540
+ price: string;
1541
+ lastUpdatedAt: bigint;
1542
+ }>;
1543
+ };
1544
+ }
1545
+ interface TokenRegistry {
1546
+ id: string;
1547
+ name: string;
1548
+ symbol: string;
1549
+ address?: string;
1550
+ updateFrequencySeconds: number;
1551
+ lastUpdatedAt: bigint;
1552
+ createdAt: Date;
1553
+ }
1554
+ interface TokenRegistryResponse {
1555
+ tokenRegistries: {
1556
+ nodes: Array<{
1557
+ id: string;
1558
+ name: string;
1559
+ symbol: string;
1560
+ address: string;
1561
+ updateFrequencySeconds: number;
1562
+ lastUpdatedAt: bigint;
1563
+ createdAt: string;
1564
+ }>;
1565
+ };
945
1566
  }
946
1567
 
947
1568
  declare class ChainConfigService {
@@ -968,6 +1589,8 @@ declare class ChainConfigService {
968
1589
  getUniswapV3RouterAddress(chain: string): HexString;
969
1590
  getUniswapV3FactoryAddress(chain: string): HexString;
970
1591
  getUniswapV3QuoterAddress(chain: string): HexString;
1592
+ getUniswapV4PoolManagerAddress(chain: string): HexString;
1593
+ getUniswapV4QuoterAddress(chain: string): HexString;
971
1594
  }
972
1595
 
973
1596
  /**
@@ -1076,9 +1699,12 @@ declare class EvmChain implements IChain {
1076
1699
  *
1077
1700
  * @param request - The post request to estimate gas for
1078
1701
  * @param paraId - The ID of the parachain (Hyperbridge) that will process the request
1079
- * @returns The estimated gas amount in gas units
1702
+ * @returns The estimated gas amount in gas units and the generated calldata
1080
1703
  */
1081
- estimateGas(request: IPostRequest): Promise<bigint>;
1704
+ estimateGas(request: IPostRequest): Promise<{
1705
+ gas: bigint;
1706
+ postRequestCalldata: HexString;
1707
+ }>;
1082
1708
  /**
1083
1709
  * Gets the fee token address and decimals for the chain.
1084
1710
  * This function gets the fee token address and decimals for the chain.
@@ -1214,7 +1840,10 @@ declare function estimateGasForPost(params: {
1214
1840
  sourceClient: PublicClient;
1215
1841
  hostLatestStateMachineHeight: bigint;
1216
1842
  hostAddress: HexString;
1217
- }): Promise<bigint>;
1843
+ }): Promise<{
1844
+ gas_fee: bigint;
1845
+ call_data: EstimateGasCallData;
1846
+ }>;
1218
1847
  /**
1219
1848
  * Constructs the request body for a redeem escrow operation.
1220
1849
  * This function encodes the order commitment, beneficiary address, and token inputs
@@ -1228,6 +1857,15 @@ declare function constructRedeemEscrowRequestBody(order: Order, beneficiary: Hex
1228
1857
  * @returns The USD price of the token as a number (preserves decimals)
1229
1858
  */
1230
1859
  declare function fetchTokenUsdPrice(identifier: string): Promise<number>;
1860
+ /**
1861
+ * ERC20 method signatures used for storage slot detection
1862
+ */
1863
+ declare enum ERC20Method {
1864
+ /** ERC20 balanceOf(address) method signature */
1865
+ BALANCE_OF = "0x70a08231",
1866
+ /** ERC20 allowance(address,address) method signature */
1867
+ ALLOWANCE = "0xdd62ed3e"
1868
+ }
1231
1869
  /**
1232
1870
  * Retrieves the storage slot for a contract call using debug_traceCall
1233
1871
  *
@@ -1266,6 +1904,16 @@ declare function fetchTokenUsdPrice(identifier: string): Promise<number>;
1266
1904
  * ```
1267
1905
  */
1268
1906
  declare function getStorageSlot(client: PublicClient, contractAddress: HexString, data: HexString): Promise<string>;
1907
+ /**
1908
+ * Adjusts fee amounts between different decimal precisions.
1909
+ * Handles scaling up or down based on the decimal difference.
1910
+ *
1911
+ * @param feeInFeeToken - The fee amount to adjust
1912
+ * @param fromDecimals - The current decimal precision
1913
+ * @param toDecimals - The target decimal precision
1914
+ * @returns The adjusted fee amount with the target decimal precision
1915
+ */
1916
+ declare function adjustFeeDecimals(feeInFeeToken: bigint, fromDecimals: number, toDecimals: number): bigint;
1269
1917
 
1270
1918
  interface SubstrateChainParams {
1271
1919
  ws: string;
@@ -1345,7 +1993,7 @@ declare class SubstrateChain implements IChain {
1345
1993
  latestStateMachineHeight(stateMachineId: StateMachineIdParams): Promise<bigint>;
1346
1994
  /**
1347
1995
  * Get the state machine update time for a given state machine height.
1348
- * @param {StateMachineHeight} stateMachineheight - The state machine height.
1996
+ * @param {StateMachineHeight} stateMachineHeight - The state machine height.
1349
1997
  * @returns {Promise<bigint>} The statemachine update time in seconds.
1350
1998
  */
1351
1999
  stateMachineUpdateTime(stateMachineHeight: StateMachineHeight): Promise<bigint>;
@@ -1912,62 +2560,66 @@ declare class IntentGateway {
1912
2560
  * protocol fees, and swap operations.
1913
2561
  *
1914
2562
  * @param order - The order to estimate fill costs for
1915
- * @returns The estimated total cost in the source chain's fee token
2563
+ * @returns An object containing the estimated cost in both fee token and native token, plus the post request calldata
1916
2564
  */
1917
- estimateFillOrder(order: Order): Promise<bigint>;
2565
+ estimateFillOrder(order: Order): Promise<{
2566
+ feeTokenAmount: bigint;
2567
+ nativeTokenAmount: bigint;
2568
+ postRequestCalldata: HexString;
2569
+ }>;
1918
2570
  /**
1919
- * Finds the best Uniswap protocol (V2 or V3) for swapping tokens given a desired output amount.
2571
+ * Converts fee token amounts back to the equivalent amount in native token.
2572
+ * Uses USD pricing to convert between fee token amounts and native token costs.
2573
+ *
2574
+ * @param feeTokenAmount - The amount in fee token (DAI)
2575
+ * @param publicClient - The client for the chain to get native token info
2576
+ * @param feeTokenDecimals - The decimal places of the fee token
2577
+ * @returns The fee token amount converted to native token amount
2578
+ * @private
2579
+ */
2580
+ private convertFeeTokenToNative;
2581
+ /**
2582
+ * Converts gas costs to the equivalent amount in the fee token (DAI).
2583
+ * Uses USD pricing to convert between native token gas costs and fee token amounts.
2584
+ *
2585
+ * @param gasEstimate - The estimated gas units
2586
+ * @param publicClient - The client for the chain to get gas prices
2587
+ * @param targetDecimals - The decimal places of the target fee token
2588
+ * @returns The gas cost converted to fee token amount
2589
+ * @private
2590
+ */
2591
+ private convertGasToFeeToken;
2592
+ quoteNative(postRequest: IPostRequest, fee: bigint): Promise<bigint>;
2593
+ /**
2594
+ * Finds the best Uniswap protocol (V2, V3, or V4) for swapping tokens given a desired output amount.
1920
2595
  * Compares liquidity and pricing across different protocols and fee tiers.
1921
2596
  *
1922
2597
  * @param chain - The chain identifier where the swap will occur
1923
2598
  * @param tokenIn - The address of the input token
1924
2599
  * @param tokenOut - The address of the output token
1925
2600
  * @param amountOut - The desired output amount
1926
- * @returns Object containing the best protocol, required input amount, fee tier (for V3), and gas estimate
2601
+ * @returns Object containing the best protocol, required input amount, and fee tier (for V3/V4)
1927
2602
  */
1928
2603
  findBestProtocolWithAmountOut(chain: string, tokenIn: HexString, tokenOut: HexString, amountOut: bigint): Promise<{
1929
- protocol: "v2" | "v3" | null;
2604
+ protocol: "v2" | "v3" | "v4" | null;
1930
2605
  amountIn: bigint;
1931
2606
  fee?: number;
1932
- gasEstimate?: bigint;
1933
2607
  }>;
1934
2608
  /**
1935
- * Finds the best Uniswap protocol (V2 or V3) for swapping tokens given an input amount.
2609
+ * Finds the best Uniswap protocol (V2, V3, or V4) for swapping tokens given an input amount.
1936
2610
  * Compares liquidity and pricing across different protocols and fee tiers.
1937
2611
  *
1938
2612
  * @param chain - The chain identifier where the swap will occur
1939
2613
  * @param tokenIn - The address of the input token
1940
2614
  * @param tokenOut - The address of the output token
1941
2615
  * @param amountIn - The input amount to swap
1942
- * @returns Object containing the best protocol, expected output amount, fee tier (for V3), and gas estimate
2616
+ * @returns Object containing the best protocol, expected output amount, and fee tier (for V3/V4)
1943
2617
  */
1944
2618
  findBestProtocolWithAmountIn(chain: string, tokenIn: HexString, tokenOut: HexString, amountIn: bigint): Promise<{
1945
- protocol: "v2" | "v3" | null;
2619
+ protocol: "v2" | "v3" | "v4" | null;
1946
2620
  amountOut: bigint;
1947
2621
  fee?: number;
1948
- gasEstimate?: bigint;
1949
2622
  }>;
1950
- /**
1951
- * Converts gas costs to the equivalent amount in the fee token (DAI).
1952
- * Uses USD pricing to convert between native token gas costs and fee token amounts.
1953
- *
1954
- * @param gasEstimate - The estimated gas units
1955
- * @param publicClient - The client for the chain to get gas prices
1956
- * @param targetDecimals - The decimal places of the target fee token
1957
- * @returns The gas cost converted to fee token amount
1958
- * @private
1959
- */
1960
- private convertGasToFeeToken;
1961
- /**
1962
- * Adjusts fee amounts between different decimal precisions.
1963
- * Handles scaling up or down based on the decimal difference.
1964
- *
1965
- * @param feeInFeeToken - The fee amount to adjust
1966
- * @param fromDecimals - The current decimal precision
1967
- * @param toDecimals - The target decimal precision
1968
- * @returns The adjusted fee amount with the target decimal precision
1969
- */
1970
- adjustFeeDecimals(feeInFeeToken: bigint, fromDecimals: number, toDecimals: number): bigint;
1971
2623
  /**
1972
2624
  * Checks if an order has been filled by verifying the commitment status on-chain.
1973
2625
  * Reads the storage slot corresponding to the order's commitment hash.
@@ -1976,6 +2628,20 @@ declare class IntentGateway {
1976
2628
  * @returns True if the order has been filled, false otherwise
1977
2629
  */
1978
2630
  isOrderFilled(order: Order): Promise<boolean>;
2631
+ /**
2632
+ * Returns the tick spacing for a given fee tier in Uniswap V4
2633
+ * @param fee - The fee tier in basis points
2634
+ * @returns The tick spacing value
2635
+ */
2636
+ private getTickSpacing;
2637
+ /**
2638
+ * Returns true if candidate <= reference * (1 + thresholdBps/10000)
2639
+ * @param candidate - The candidate amount to compare
2640
+ * @param reference - The reference amount
2641
+ * @param thresholdBps - The threshold in basis points
2642
+ * @returns True if candidate is within threshold of reference
2643
+ */
2644
+ private isWithinThreshold;
1979
2645
  }
1980
2646
 
1981
2647
  type HyperbridgeTxEvents = {
@@ -2137,7 +2803,9 @@ declare enum Chains {
2137
2803
  BSC_CHAPEL = "EVM-97",
2138
2804
  GNOSIS_CHIADO = "EVM-10200",
2139
2805
  HYPERBRIDGE_GARGANTUA = "KUSAMA-4009",
2140
- SEPOLIA = "EVM-11155111"
2806
+ SEPOLIA = "EVM-11155111",
2807
+ MAINNET = "EVM-1",
2808
+ BSC_MAINNET = "EVM-56"
2141
2809
  }
2142
2810
  type AddressMap = {
2143
2811
  [key: string]: {
@@ -2150,6 +2818,8 @@ declare const chainIds: {
2150
2818
  readonly "EVM-10200": 10200;
2151
2819
  readonly "KUSAMA-4009": 4009;
2152
2820
  readonly "EVM-11155111": 11155111;
2821
+ readonly "EVM-1": 1;
2822
+ readonly "EVM-56": 56;
2153
2823
  };
2154
2824
  type ChainId = typeof chainIds;
2155
2825
  declare const viemChains: Record<string, Chain>;
@@ -2157,6 +2827,8 @@ declare const WrappedNativeDecimals: {
2157
2827
  "EVM-97": number;
2158
2828
  "EVM-10200": number;
2159
2829
  "EVM-11155111": number;
2830
+ "EVM-1": number;
2831
+ "EVM-56": number;
2160
2832
  };
2161
2833
  declare const assets: {
2162
2834
  "EVM-97": {
@@ -2177,6 +2849,18 @@ declare const assets: {
2177
2849
  USDT: string;
2178
2850
  DAI: string;
2179
2851
  };
2852
+ "EVM-1": {
2853
+ WETH: string;
2854
+ DAI: string;
2855
+ USDC: string;
2856
+ USDT: string;
2857
+ };
2858
+ "EVM-56": {
2859
+ WETH: string;
2860
+ DAI: string;
2861
+ USDC: string;
2862
+ USDT: string;
2863
+ };
2180
2864
  };
2181
2865
  declare const addresses: AddressMap;
2182
2866
  declare const createRpcUrls: (env: NodeJS.ProcessEnv) => RpcMap;
@@ -2185,6 +2869,8 @@ declare const consensusStateIds: {
2185
2869
  "EVM-10200": string;
2186
2870
  "KUSAMA-4009": string;
2187
2871
  "EVM-11155111": string;
2872
+ "EVM-1": string;
2873
+ "EVM-56": string;
2188
2874
  };
2189
2875
 
2190
- export { ADDRESS_ZERO, AbortSignalInternal, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, ChainConfigService, type ChainId, Chains, type ClientConfig, DEFAULT_ADDRESS, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DispatchGet, type DispatchPost, EvmChain, type EvmChainParams, type ExecutionResult, type FillOptions, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, type IsmpRequest, type NewDeployment, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderWithStatus, type Params, type PaymentInfo, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type RetryConfig, STATE_COMMITMENTS_SLOT, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, SubstrateChain, type SubstrateChainParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, WrappedNativeDecimals, type XcmGatewayParams, __test, addresses, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchTokenUsdPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, orderCommitment, postRequestCommitment, queryGetRequest, queryPostRequest, teleport, teleportDot, viemChains };
2876
+ export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, ChainConfigService, type ChainId, Chains, type ClientConfig, DEFAULT_ADDRESS, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DispatchGet, type DispatchPost, ERC20Method, type EstimateGasCallData, EvmChain, type EvmChainParams, type ExecutionResult, type FillOptions, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, type IsmpRequest, type NewDeployment, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderWithStatus, type Params, type PaymentInfo, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type RetryConfig, STATE_COMMITMENTS_SLOT, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, SubstrateChain, type SubstrateChainParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, WrappedNativeDecimals, type XcmGatewayParams, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchTokenUsdPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, orderCommitment, postRequestCommitment, queryGetRequest, queryPostRequest, teleport, teleportDot, viemChains };