@hyperbridge/sdk 2.8.8 → 2.8.11

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.
@@ -7,10 +7,10 @@ import { baseSepolia, optimismSepolia, arbitrumSepolia, soneium, gnosis, optimis
7
7
  import { TronWeb } from 'tronweb';
8
8
  import { flatten, zip, capitalize, maxBy, isNil } from 'lodash-es';
9
9
  import { match } from 'ts-pattern';
10
- import { WsProvider, ApiPromise, HttpProvider, Keyring } from '@polkadot/api';
10
+ import { WsProvider, ApiPromise, Keyring, HttpProvider } from '@polkadot/api';
11
11
  import { Struct, Vector, u8, Bytes, Enum, Tuple, _void, u64, u32, Option, bool, u128 } from 'scale-ts';
12
- import { keccakAsU8a, decodeAddress, keccakAsHex, xxhashAsU8a, blake2AsU8a } from '@polkadot/util-crypto';
13
- import { hexToU8a, u8aToHex, u8aConcat, stringToU8a, isHex as isHex$1, u8aToString } from '@polkadot/util';
12
+ import { xxhashAsU8a, keccakAsU8a, decodeAddress, keccakAsHex, blake2AsU8a } from '@polkadot/util-crypto';
13
+ import { u8aToHex, u8aConcat, hexToU8a, stringToU8a, isHex as isHex$1, u8aToString } from '@polkadot/util';
14
14
  import PQueue from 'p-queue';
15
15
  import { hasWindow, isNode, env } from 'std-env';
16
16
  import mergeRace from '@async-generator/merge-race';
@@ -2711,7 +2711,7 @@ var chainConfigs = {
2711
2711
  },
2712
2712
  addresses: {
2713
2713
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2714
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
2714
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
2715
2715
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2716
2716
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2717
2717
  UniswapRouter02: "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
@@ -2778,7 +2778,7 @@ var chainConfigs = {
2778
2778
  },
2779
2779
  addresses: {
2780
2780
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2781
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
2781
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
2782
2782
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2783
2783
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2784
2784
  UniswapRouter02: "0x10ED43C718714eb63d5aA57B78B54704E256024E",
@@ -2839,7 +2839,7 @@ var chainConfigs = {
2839
2839
  },
2840
2840
  addresses: {
2841
2841
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2842
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
2842
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
2843
2843
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2844
2844
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2845
2845
  UniswapRouter02: "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",
@@ -2913,7 +2913,7 @@ var chainConfigs = {
2913
2913
  },
2914
2914
  addresses: {
2915
2915
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2916
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
2916
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
2917
2917
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2918
2918
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2919
2919
  UniswapRouter02: "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",
@@ -2988,7 +2988,7 @@ var chainConfigs = {
2988
2988
  },
2989
2989
  addresses: {
2990
2990
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2991
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
2991
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
2992
2992
  TokenGateway: "0x8b536105b6Fae2aE9199f5146D3C57Dfe53b614E",
2993
2993
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2994
2994
  UniswapRouter02: "0xd2f9496824951D5237cC71245D659E48d0d5f9E8",
@@ -3104,7 +3104,7 @@ var chainConfigs = {
3104
3104
  },
3105
3105
  addresses: {
3106
3106
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
3107
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
3107
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
3108
3108
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
3109
3109
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
3110
3110
  UniswapRouter02: "0x4A7b5Da61326A6379179b40d00F57E5bbDC962c2",
@@ -3139,7 +3139,7 @@ var chainConfigs = {
3139
3139
  },
3140
3140
  addresses: {
3141
3141
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
3142
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
3142
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
3143
3143
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
3144
3144
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
3145
3145
  UniswapRouter02: "0xB2e26652e4BAd1e56055A051f922E06760cA0BFE",
@@ -3295,7 +3295,7 @@ var chainConfigs = {
3295
3295
  },
3296
3296
  addresses: {
3297
3297
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
3298
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
3298
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
3299
3299
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
3300
3300
  Calldispatcher: "0xE2C7e576E26E0bE7aC97c6fE925bcDAbD87c4bEd"
3301
3301
  },
@@ -3342,7 +3342,7 @@ var ABI3 = [
3342
3342
  type: "constructor",
3343
3343
  inputs: [
3344
3344
  {
3345
- name: "admin",
3345
+ name: "owner",
3346
3346
  type: "address",
3347
3347
  internalType: "address"
3348
3348
  }
@@ -3417,25 +3417,6 @@ var ABI3 = [
3417
3417
  ],
3418
3418
  stateMutability: "view"
3419
3419
  },
3420
- {
3421
- type: "function",
3422
- name: "_instances",
3423
- inputs: [
3424
- {
3425
- name: "",
3426
- type: "bytes32",
3427
- internalType: "bytes32"
3428
- }
3429
- ],
3430
- outputs: [
3431
- {
3432
- name: "",
3433
- type: "address",
3434
- internalType: "address"
3435
- }
3436
- ],
3437
- stateMutability: "view"
3438
- },
3439
3420
  {
3440
3421
  type: "function",
3441
3422
  name: "_nonce",
@@ -3473,6 +3454,19 @@ var ABI3 = [
3473
3454
  ],
3474
3455
  stateMutability: "view"
3475
3456
  },
3457
+ {
3458
+ type: "function",
3459
+ name: "_owner",
3460
+ inputs: [],
3461
+ outputs: [
3462
+ {
3463
+ name: "",
3464
+ type: "address",
3465
+ internalType: "address"
3466
+ }
3467
+ ],
3468
+ stateMutability: "view"
3469
+ },
3476
3470
  {
3477
3471
  type: "function",
3478
3472
  name: "_partialFills",
@@ -3847,6 +3841,11 @@ var ABI3 = [
3847
3841
  type: "uint256",
3848
3842
  internalType: "uint256"
3849
3843
  },
3844
+ {
3845
+ name: "validUntil",
3846
+ type: "uint256",
3847
+ internalType: "uint256"
3848
+ },
3850
3849
  {
3851
3850
  name: "outputs",
3852
3851
  type: "tuple[]",
@@ -3883,6 +3882,61 @@ var ABI3 = [
3883
3882
  ],
3884
3883
  stateMutability: "view"
3885
3884
  },
3885
+ {
3886
+ type: "function",
3887
+ name: "initialize",
3888
+ inputs: [
3889
+ {
3890
+ name: "p",
3891
+ type: "tuple",
3892
+ internalType: "struct Params",
3893
+ components: [
3894
+ {
3895
+ name: "host",
3896
+ type: "address",
3897
+ internalType: "address"
3898
+ },
3899
+ {
3900
+ name: "dispatcher",
3901
+ type: "address",
3902
+ internalType: "address"
3903
+ },
3904
+ {
3905
+ name: "solverSelection",
3906
+ type: "bool",
3907
+ internalType: "bool"
3908
+ },
3909
+ {
3910
+ name: "surplusShareBps",
3911
+ type: "uint256",
3912
+ internalType: "uint256"
3913
+ },
3914
+ {
3915
+ name: "protocolFeeBps",
3916
+ type: "uint256",
3917
+ internalType: "uint256"
3918
+ },
3919
+ {
3920
+ name: "priceOracle",
3921
+ type: "address",
3922
+ internalType: "address"
3923
+ }
3924
+ ]
3925
+ },
3926
+ {
3927
+ name: "peerChains",
3928
+ type: "bytes[]",
3929
+ internalType: "bytes[]"
3930
+ },
3931
+ {
3932
+ name: "relayer",
3933
+ type: "address",
3934
+ internalType: "address"
3935
+ }
3936
+ ],
3937
+ outputs: [],
3938
+ stateMutability: "nonpayable"
3939
+ },
3886
3940
  {
3887
3941
  type: "function",
3888
3942
  name: "instance",
@@ -3902,6 +3956,19 @@ var ABI3 = [
3902
3956
  ],
3903
3957
  stateMutability: "view"
3904
3958
  },
3959
+ {
3960
+ type: "function",
3961
+ name: "migrate",
3962
+ inputs: [
3963
+ {
3964
+ name: "relayer",
3965
+ type: "address",
3966
+ internalType: "address"
3967
+ }
3968
+ ],
3969
+ outputs: [],
3970
+ stateMutability: "nonpayable"
3971
+ },
3905
3972
  {
3906
3973
  type: "function",
3907
3974
  name: "onAccept",
@@ -4413,7 +4480,7 @@ var ABI3 = [
4413
4480
  internalType: "uint256"
4414
4481
  }
4415
4482
  ],
4416
- stateMutability: "view"
4483
+ stateMutability: "nonpayable"
4417
4484
  },
4418
4485
  {
4419
4486
  type: "function",
@@ -4469,6 +4536,19 @@ var ABI3 = [
4469
4536
  internalType: "uint256"
4470
4537
  }
4471
4538
  ],
4539
+ stateMutability: "nonpayable"
4540
+ },
4541
+ {
4542
+ type: "function",
4543
+ name: "relayer",
4544
+ inputs: [],
4545
+ outputs: [
4546
+ {
4547
+ name: "",
4548
+ type: "address",
4549
+ internalType: "address"
4550
+ }
4551
+ ],
4472
4552
  stateMutability: "view"
4473
4553
  },
4474
4554
  {
@@ -4509,66 +4589,67 @@ var ABI3 = [
4509
4589
  },
4510
4590
  {
4511
4591
  type: "function",
4512
- name: "init",
4592
+ name: "setRelayer",
4513
4593
  inputs: [
4514
4594
  {
4515
- name: "p",
4516
- type: "tuple",
4517
- internalType: "struct Params",
4518
- components: [
4519
- {
4520
- name: "host",
4521
- type: "address",
4522
- internalType: "address"
4523
- },
4524
- {
4525
- name: "dispatcher",
4526
- type: "address",
4527
- internalType: "address"
4528
- },
4529
- {
4530
- name: "solverSelection",
4531
- type: "bool",
4532
- internalType: "bool"
4533
- },
4534
- {
4535
- name: "surplusShareBps",
4536
- type: "uint256",
4537
- internalType: "uint256"
4538
- },
4539
- {
4540
- name: "protocolFeeBps",
4541
- type: "uint256",
4542
- internalType: "uint256"
4543
- },
4544
- {
4545
- name: "priceOracle",
4546
- type: "address",
4547
- internalType: "address"
4548
- }
4549
- ]
4595
+ name: "relayer",
4596
+ type: "address",
4597
+ internalType: "address"
4598
+ }
4599
+ ],
4600
+ outputs: [],
4601
+ stateMutability: "nonpayable"
4602
+ },
4603
+ {
4604
+ type: "function",
4605
+ name: "upgradeToAndCall",
4606
+ inputs: [
4607
+ {
4608
+ name: "newImplementation",
4609
+ type: "address",
4610
+ internalType: "address"
4550
4611
  },
4551
4612
  {
4552
- name: "deployments",
4553
- type: "tuple[]",
4554
- internalType: "struct Deployment[]",
4555
- components: [
4556
- {
4557
- name: "chain",
4558
- type: "bytes",
4559
- internalType: "bytes"
4560
- },
4561
- {
4562
- name: "gateway",
4563
- type: "address",
4564
- internalType: "address"
4565
- }
4566
- ]
4613
+ name: "data",
4614
+ type: "bytes",
4615
+ internalType: "bytes"
4567
4616
  }
4568
4617
  ],
4569
4618
  outputs: [],
4570
4619
  stateMutability: "nonpayable"
4571
4620
  },
4621
+ {
4622
+ type: "function",
4623
+ name: "version",
4624
+ inputs: [],
4625
+ outputs: [
4626
+ {
4627
+ name: "",
4628
+ type: "uint64",
4629
+ internalType: "uint64"
4630
+ }
4631
+ ],
4632
+ stateMutability: "view"
4633
+ },
4634
+ {
4635
+ type: "event",
4636
+ name: "DeploymentAdded",
4637
+ inputs: [
4638
+ {
4639
+ name: "chain",
4640
+ type: "string",
4641
+ indexed: false,
4642
+ internalType: "string"
4643
+ },
4644
+ {
4645
+ name: "gateway",
4646
+ type: "address",
4647
+ indexed: false,
4648
+ internalType: "address"
4649
+ }
4650
+ ],
4651
+ anonymous: false
4652
+ },
4572
4653
  {
4573
4654
  type: "event",
4574
4655
  name: "DestinationProtocolFeeUpdated",
@@ -4702,16 +4783,29 @@ var ABI3 = [
4702
4783
  },
4703
4784
  {
4704
4785
  type: "event",
4705
- name: "DeploymentAdded",
4786
+ name: "Initialized",
4706
4787
  inputs: [
4707
4788
  {
4708
- name: "chain",
4709
- type: "string",
4789
+ name: "version",
4790
+ type: "uint64",
4710
4791
  indexed: false,
4711
- internalType: "string"
4792
+ internalType: "uint64"
4793
+ }
4794
+ ],
4795
+ anonymous: false
4796
+ },
4797
+ {
4798
+ type: "event",
4799
+ name: "OrderCancelled",
4800
+ inputs: [
4801
+ {
4802
+ name: "commitment",
4803
+ type: "bytes32",
4804
+ indexed: true,
4805
+ internalType: "bytes32"
4712
4806
  },
4713
4807
  {
4714
- name: "gateway",
4808
+ name: "canceller",
4715
4809
  type: "address",
4716
4810
  indexed: false,
4717
4811
  internalType: "address"
@@ -5039,14 +5133,52 @@ var ABI3 = [
5039
5133
  ],
5040
5134
  anonymous: false
5041
5135
  },
5136
+ {
5137
+ type: "event",
5138
+ name: "RelayerUpdated",
5139
+ inputs: [
5140
+ {
5141
+ name: "previous",
5142
+ type: "address",
5143
+ indexed: false,
5144
+ internalType: "address"
5145
+ },
5146
+ {
5147
+ name: "current",
5148
+ type: "address",
5149
+ indexed: false,
5150
+ internalType: "address"
5151
+ }
5152
+ ],
5153
+ anonymous: false
5154
+ },
5155
+ {
5156
+ type: "event",
5157
+ name: "Upgraded",
5158
+ inputs: [
5159
+ {
5160
+ name: "implementation",
5161
+ type: "address",
5162
+ indexed: true,
5163
+ internalType: "address"
5164
+ }
5165
+ ],
5166
+ anonymous: false
5167
+ },
5042
5168
  {
5043
5169
  type: "error",
5044
- name: "Cancelled",
5045
- inputs: []
5170
+ name: "AddressEmptyCode",
5171
+ inputs: [
5172
+ {
5173
+ name: "target",
5174
+ type: "address",
5175
+ internalType: "address"
5176
+ }
5177
+ ]
5046
5178
  },
5047
5179
  {
5048
5180
  type: "error",
5049
- name: "UnknownInstance",
5181
+ name: "Cancelled",
5050
5182
  inputs: []
5051
5183
  },
5052
5184
  {
@@ -5067,18 +5199,44 @@ var ABI3 = [
5067
5199
  },
5068
5200
  {
5069
5201
  type: "error",
5070
- name: "ECDSAInvalidSignatureS",
5071
- inputs: [
5072
- {
5073
- name: "s",
5074
- type: "bytes32",
5075
- internalType: "bytes32"
5076
- }
5077
- ]
5202
+ name: "ECDSAInvalidSignatureS",
5203
+ inputs: [
5204
+ {
5205
+ name: "s",
5206
+ type: "bytes32",
5207
+ internalType: "bytes32"
5208
+ }
5209
+ ]
5210
+ },
5211
+ {
5212
+ type: "error",
5213
+ name: "ERC1967InvalidImplementation",
5214
+ inputs: [
5215
+ {
5216
+ name: "implementation",
5217
+ type: "address",
5218
+ internalType: "address"
5219
+ }
5220
+ ]
5221
+ },
5222
+ {
5223
+ type: "error",
5224
+ name: "ERC1967NonPayable",
5225
+ inputs: []
5226
+ },
5227
+ {
5228
+ type: "error",
5229
+ name: "Expired",
5230
+ inputs: []
5231
+ },
5232
+ {
5233
+ type: "error",
5234
+ name: "FailedCall",
5235
+ inputs: []
5078
5236
  },
5079
5237
  {
5080
5238
  type: "error",
5081
- name: "Expired",
5239
+ name: "FillExpired",
5082
5240
  inputs: []
5083
5241
  },
5084
5242
  {
@@ -5091,6 +5249,11 @@ var ABI3 = [
5091
5249
  name: "InsufficientNativeToken",
5092
5250
  inputs: []
5093
5251
  },
5252
+ {
5253
+ type: "error",
5254
+ name: "InvalidInitialization",
5255
+ inputs: []
5256
+ },
5094
5257
  {
5095
5258
  type: "error",
5096
5259
  name: "InvalidInput",
@@ -5106,6 +5269,21 @@ var ABI3 = [
5106
5269
  name: "NotExpired",
5107
5270
  inputs: []
5108
5271
  },
5272
+ {
5273
+ type: "error",
5274
+ name: "NotInitializing",
5275
+ inputs: []
5276
+ },
5277
+ {
5278
+ type: "error",
5279
+ name: "PartialFillNotAllowed",
5280
+ inputs: []
5281
+ },
5282
+ {
5283
+ type: "error",
5284
+ name: "ReentrancyGuardReentrantCall",
5285
+ inputs: []
5286
+ },
5109
5287
  {
5110
5288
  type: "error",
5111
5289
  name: "SafeERC20FailedOperation",
@@ -5143,6 +5321,11 @@ var ABI3 = [
5143
5321
  name: "UnexpectedCall",
5144
5322
  inputs: []
5145
5323
  },
5324
+ {
5325
+ type: "error",
5326
+ name: "UnknownInstance",
5327
+ inputs: []
5328
+ },
5146
5329
  {
5147
5330
  type: "error",
5148
5331
  name: "UnknownOrder",
@@ -7814,6 +7997,255 @@ function encodeISMPMessage(message) {
7814
7997
  throw new Error("Failed to encode ISMP message", { cause: error });
7815
7998
  }
7816
7999
  }
8000
+
8001
+ // src/utils/rateLimiter.ts
8002
+ var TokenBucket = class {
8003
+ /**
8004
+ * @param ratePerSecond - sustained requests per second.
8005
+ * @param burst - how many requests may go out back-to-back before pacing starts. Defaults to
8006
+ * one second's worth, which is the shape most limiters police.
8007
+ */
8008
+ constructor(ratePerSecond, burst = ratePerSecond) {
8009
+ this.ratePerSecond = ratePerSecond;
8010
+ this.burst = burst;
8011
+ if (ratePerSecond <= 0) throw new Error(`TokenBucket rate must be positive, got ${ratePerSecond}`);
8012
+ this.tokens = burst;
8013
+ this.lastRefill = Date.now();
8014
+ }
8015
+ ratePerSecond;
8016
+ burst;
8017
+ /** Fractional on purpose: a partial token is real capacity, just not yet a whole request. */
8018
+ tokens;
8019
+ lastRefill;
8020
+ waiting = [];
8021
+ drainTimer = null;
8022
+ /** Resolves once this caller may send. */
8023
+ async acquire() {
8024
+ if (this.waiting.length === 0 && this.take()) return;
8025
+ return new Promise((resolve) => {
8026
+ this.waiting.push(resolve);
8027
+ this.scheduleDrain();
8028
+ });
8029
+ }
8030
+ /** Requests currently waiting on a token. Exposed for tests and diagnostics. */
8031
+ get queued() {
8032
+ return this.waiting.length;
8033
+ }
8034
+ refill() {
8035
+ const now = Date.now();
8036
+ const elapsed = now - this.lastRefill;
8037
+ if (elapsed <= 0) {
8038
+ if (elapsed < 0) this.lastRefill = now;
8039
+ return;
8040
+ }
8041
+ this.tokens = Math.min(this.burst, this.tokens + elapsed * this.ratePerSecond / 1e3);
8042
+ this.lastRefill = now;
8043
+ }
8044
+ take() {
8045
+ this.refill();
8046
+ if (this.tokens < 1) return false;
8047
+ this.tokens -= 1;
8048
+ return true;
8049
+ }
8050
+ scheduleDrain() {
8051
+ if (this.drainTimer) return;
8052
+ this.refill();
8053
+ const deficit = 1 - this.tokens;
8054
+ const waitMs = deficit <= 0 ? 0 : Math.ceil(deficit * 1e3 / this.ratePerSecond);
8055
+ const timer = setTimeout(() => {
8056
+ this.drainTimer = null;
8057
+ this.drain();
8058
+ }, waitMs);
8059
+ timer.unref?.();
8060
+ this.drainTimer = timer;
8061
+ }
8062
+ drain() {
8063
+ while (this.waiting.length > 0 && this.take()) {
8064
+ this.waiting.shift()?.();
8065
+ }
8066
+ if (this.waiting.length > 0) this.scheduleDrain();
8067
+ }
8068
+ };
8069
+ var BATCHES_NOT_SUPPORTED_CODE = -32005;
8070
+ var TOO_BIG_BATCH_REQUEST_CODE = -32010;
8071
+ var DEFAULT_MAX_BATCH_SIZE = 32;
8072
+ function rpcError({ code, message, data }) {
8073
+ const suffix = data === void 0 ? "" : `: ${typeof data === "string" ? data : JSON.stringify(data)}`;
8074
+ const error = new Error(`${code}: ${message}${suffix}`);
8075
+ error.code = code;
8076
+ error.data = data;
8077
+ return error;
8078
+ }
8079
+ var BatchingHttpProvider = class _BatchingHttpProvider extends HttpProvider {
8080
+ #endpoint;
8081
+ #headers;
8082
+ #limiter;
8083
+ #maxBatchSize;
8084
+ #batchingSupported = true;
8085
+ #pending = [];
8086
+ #flushTimer = null;
8087
+ #flushing = false;
8088
+ #nextId = 1;
8089
+ constructor(endpoint, headers, limiter, maxBatchSize = DEFAULT_MAX_BATCH_SIZE) {
8090
+ super(endpoint, headers, 0);
8091
+ this.#endpoint = endpoint;
8092
+ this.#headers = headers;
8093
+ this.#limiter = limiter;
8094
+ this.#maxBatchSize = maxBatchSize;
8095
+ }
8096
+ /**
8097
+ * `isCacheable` is accepted for interface compatibility and ignored: this provider has no
8098
+ * response cache, which is deliberate — see the note in `IntentsCoprocessor.http`.
8099
+ */
8100
+ async send(method, params, _isCacheable) {
8101
+ return new Promise((resolve, reject) => {
8102
+ this.#pending.push({
8103
+ id: this.#nextId++,
8104
+ method,
8105
+ params,
8106
+ resolve,
8107
+ reject
8108
+ });
8109
+ if (this.#pending.length >= this.#maxBatchSize) this.#flushNow();
8110
+ else this.#scheduleFlush();
8111
+ });
8112
+ }
8113
+ clone() {
8114
+ return new _BatchingHttpProvider(this.#endpoint, this.#headers, this.#limiter, this.#maxBatchSize);
8115
+ }
8116
+ /** Calls waiting for a flush. Exposed for tests and diagnostics. */
8117
+ get queued() {
8118
+ return this.#pending.length;
8119
+ }
8120
+ /**
8121
+ * Collect for the rest of this macrotask, then send.
8122
+ *
8123
+ * A macrotask rather than a microtask because the bursts worth catching are not synchronous:
8124
+ * `Promise.all` over a set of reads starts them in one synchronous run, but each then advances
8125
+ * through several microtask turns of its own before reaching the provider. A microtask flush
8126
+ * would fire between those turns and split one burst across several requests.
8127
+ */
8128
+ #scheduleFlush() {
8129
+ if (this.#flushTimer || this.#flushing) return;
8130
+ const timer = setTimeout(() => {
8131
+ this.#flushTimer = null;
8132
+ void this.#flush();
8133
+ }, 0);
8134
+ timer.unref?.();
8135
+ this.#flushTimer = timer;
8136
+ }
8137
+ #flushNow() {
8138
+ if (this.#flushing) return;
8139
+ if (this.#flushTimer) {
8140
+ clearTimeout(this.#flushTimer);
8141
+ this.#flushTimer = null;
8142
+ }
8143
+ void this.#flush();
8144
+ }
8145
+ async #flush() {
8146
+ if (this.#flushing) return;
8147
+ const calls = this.#pending.splice(0, this.#maxBatchSize);
8148
+ if (calls.length === 0) return;
8149
+ this.#flushing = true;
8150
+ try {
8151
+ await this.#limiter.acquire();
8152
+ await this.#post(calls);
8153
+ } finally {
8154
+ this.#flushing = false;
8155
+ if (this.#pending.length > 0) this.#scheduleFlush();
8156
+ }
8157
+ }
8158
+ async #post(calls) {
8159
+ const single = calls.length === 1;
8160
+ const payload = calls.map(({ id, method, params }) => ({ id, jsonrpc: "2.0", method, params }));
8161
+ const body = JSON.stringify(single ? payload[0] : payload);
8162
+ let parsed;
8163
+ try {
8164
+ const response = await fetch(this.#endpoint, {
8165
+ body,
8166
+ headers: {
8167
+ Accept: "application/json",
8168
+ "Content-Type": "application/json",
8169
+ ...this.#headers
8170
+ },
8171
+ method: "POST"
8172
+ });
8173
+ if (!response.ok) throw new Error(`[${response.status}]: ${response.statusText}`);
8174
+ parsed = JSON.parse(await response.text());
8175
+ } catch (err) {
8176
+ const error = err instanceof Error ? err : new Error(String(err));
8177
+ error.message = `${error.message}
8178
+ Failed HTTP Request: ${JSON.stringify(
8179
+ calls.map(({ method, params }) => ({ method, params }))
8180
+ )}`;
8181
+ for (const call of calls) call.reject(error);
8182
+ return;
8183
+ }
8184
+ if (Array.isArray(parsed)) {
8185
+ this.#settleBatch(calls, parsed);
8186
+ return;
8187
+ }
8188
+ if (!single) {
8189
+ this.#handleBatchRefusal(calls, parsed);
8190
+ return;
8191
+ }
8192
+ this.#settle(calls[0], parsed);
8193
+ }
8194
+ #settleBatch(calls, responses) {
8195
+ const byId = /* @__PURE__ */ new Map();
8196
+ for (const response of responses) {
8197
+ if (typeof response?.id === "number") byId.set(response.id, response);
8198
+ }
8199
+ for (const call of calls) {
8200
+ const response = byId.get(call.id);
8201
+ if (response) this.#settle(call, response);
8202
+ else call.reject(new Error(`No response for ${call.method} in batch reply`));
8203
+ }
8204
+ }
8205
+ #settle(call, response) {
8206
+ if (response?.error) {
8207
+ call.reject(rpcError(response.error));
8208
+ return;
8209
+ }
8210
+ if (!response || response.result === void 0) {
8211
+ call.reject(new Error("No result found in jsonrpc response"));
8212
+ return;
8213
+ }
8214
+ call.resolve(response.result);
8215
+ }
8216
+ /**
8217
+ * The server rejected the batch itself rather than any call in it. Both forms are recoverable
8218
+ * without losing a call, and neither should ever surface to a caller as a failure.
8219
+ */
8220
+ #handleBatchRefusal(calls, response) {
8221
+ const code = response?.error?.code;
8222
+ if (code === BATCHES_NOT_SUPPORTED_CODE) {
8223
+ this.#batchingSupported = false;
8224
+ this.#maxBatchSize = 1;
8225
+ this.#requeue(calls);
8226
+ return;
8227
+ }
8228
+ if (code === TOO_BIG_BATCH_REQUEST_CODE) {
8229
+ this.#maxBatchSize = Math.max(1, Math.floor(this.#maxBatchSize / 2));
8230
+ this.#requeue(calls);
8231
+ return;
8232
+ }
8233
+ const error = response?.error ? rpcError(response.error) : new Error("Malformed batch reply: neither an array nor an error");
8234
+ for (const call of calls) call.reject(error);
8235
+ }
8236
+ /** Puts calls back at the head of the queue, so a refused batch keeps its place in line. */
8237
+ #requeue(calls) {
8238
+ this.#pending.unshift(...calls);
8239
+ this.#scheduleFlush();
8240
+ }
8241
+ /** Whether batches are still being attempted. Exposed for tests and diagnostics. */
8242
+ get batchingSupported() {
8243
+ return this.#batchingSupported;
8244
+ }
8245
+ };
8246
+
8247
+ // src/chains/intentsCoprocessor.ts
8248
+ var SYSTEM_EVENTS_KEY = u8aToHex(u8aConcat(xxhashAsU8a("System", 128), xxhashAsU8a("Events", 128)));
7817
8249
  var OFFCHAIN_BID_PREFIX = new TextEncoder().encode("intents::bid::");
7818
8250
  var OFFCHAIN_PHANTOM_PREFIX = new TextEncoder().encode("intents::phantom::order::");
7819
8251
  var HYPERBRIDGE_TYPES_BUNDLE = {
@@ -7827,6 +8259,63 @@ var HTTP_CONNECT_TIMEOUT_MS = 2e4;
7827
8259
  var INCLUSION_TIMEOUT_MS = 2e4;
7828
8260
  var PHANTOM_POLL_INTERVAL_MS = 15e3;
7829
8261
  var GARGANTUA_PHANTOM_POLL_INTERVAL_MS = 6e3;
8262
+ var DEFAULT_RPC_MAX_RPS = 8;
8263
+ var DEFAULT_MAX_BLOCKS_PER_POLL = 10;
8264
+ var MAX_RATE_LIMIT_BACKOFF_TICKS = 8;
8265
+ var rpcLimiters = /* @__PURE__ */ new Map();
8266
+ function limiterFor(httpUrl) {
8267
+ const key = new URL(httpUrl).origin;
8268
+ let limiter = rpcLimiters.get(key);
8269
+ if (!limiter) {
8270
+ limiter = new TokenBucket(configuredRpcMaxRps());
8271
+ rpcLimiters.set(key, limiter);
8272
+ }
8273
+ return limiter;
8274
+ }
8275
+ function configuredRpcMaxRps() {
8276
+ const raw = typeof process !== "undefined" ? process.env?.HYPERBRIDGE_RPC_MAX_RPS : void 0;
8277
+ const parsed = raw === void 0 ? Number.NaN : Number(raw);
8278
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_RPC_MAX_RPS;
8279
+ }
8280
+ function isRateLimited(err) {
8281
+ const message = err instanceof Error ? err.message : String(err);
8282
+ return message.includes("[429]") || /too many requests/i.test(message);
8283
+ }
8284
+ function isMethodUnavailable(err) {
8285
+ const message = err instanceof Error ? err.message : String(err);
8286
+ const code = err?.code;
8287
+ return code === -32601 || /method not found|unsafe to be called externally/i.test(message);
8288
+ }
8289
+ var EventDecodeError = class extends Error {
8290
+ };
8291
+ function phantomOrdersFrom(records) {
8292
+ if (records == null || typeof records[Symbol.iterator] !== "function") {
8293
+ throw new EventDecodeError(`Expected a decoded event vector, got ${typeof records}`);
8294
+ }
8295
+ const orders = [];
8296
+ for (const record of records) {
8297
+ if (typeof record !== "object" || record === null || !("event" in record)) {
8298
+ throw new EventDecodeError(
8299
+ "system.events did not decode to event records \u2014 the storage entry's metadata was probably not carried through, leaving the value as raw bytes"
8300
+ );
8301
+ }
8302
+ const { event } = record;
8303
+ if (event.section !== "intentsCoprocessor" || event.method !== "PhantomOrderRegistered") continue;
8304
+ const [commitment, chain, createdAt, legs] = event.data;
8305
+ orders.push({
8306
+ commitment: commitment.toHex(),
8307
+ chain: new TextDecoder().decode(hexToU8a(chain.toHex())),
8308
+ createdAt: createdAt.toNumber(),
8309
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8310
+ legs: legs.map((leg) => ({
8311
+ tokenA: leg.tokenA.toHex(),
8312
+ tokenB: leg.tokenB.toHex(),
8313
+ standardAmount: BigInt(leg.standardAmount.toString())
8314
+ }))
8315
+ });
8316
+ }
8317
+ return orders;
8318
+ }
7830
8319
  function rejectAfter(ms, message) {
7831
8320
  return new Promise((_resolve, reject) => {
7832
8321
  const timer = setTimeout(() => reject(new Error(message)), ms);
@@ -7898,8 +8387,14 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
7898
8387
  ownsConnection;
7899
8388
  /** Cached result of whether the node exposes intents_* RPC methods */
7900
8389
  hasIntentsRpc = null;
8390
+ /** The pallet's phantom timings, read once. Cleared on failure so the read retries. */
8391
+ phantomTimingsRead = null;
7901
8392
  /** The HTTP-backed api, connected on first use. Cleared after a failed attempt so it retries. */
7902
8393
  httpApi = null;
8394
+ /** Last runtime version read from the node, for {@link confirmedRuntimeVersion} to compare against. */
8395
+ lastRuntimeVersion;
8396
+ /** Set once the node refuses `state_queryStorage`, so the poll stops asking for it. */
8397
+ rangeQueryUnavailable = false;
7903
8398
  // Serialises every extrinsic submission on this instance's substrate account. All submit/retract
7904
8399
  // methods funnel through signAndSendExtrinsic, each using the API's auto-nonce; fired in parallel
7905
8400
  // (bids for orders on different chains, or several phantom orders in one interval) they would grab
@@ -7999,7 +8494,11 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
7999
8494
  // replayed from memory on every tick, faster than the TTL could lapse, and the node never
8000
8495
  // saw a second request. The cache bought nothing here anyway: the poll reads each block
8001
8496
  // once, and `api.at(hash)` reuses registries at the api layer regardless.
8002
- provider: new HttpProvider(httpUrl, {}, 0),
8497
+ // Concurrent calls are coalesced into one JSON-RPC batch request, and every request
8498
+ // to this endpoint is paced by a bucket shared with any other coprocessor in this
8499
+ // process pointed at the same host — the limit is the server's, and it counts
8500
+ // requests per address rather than per connection.
8501
+ provider: new BatchingHttpProvider(httpUrl, {}, limiterFor(httpUrl)),
8003
8502
  typesBundle: HYPERBRIDGE_TYPES_BUNDLE,
8004
8503
  // A second connection to the node the ws api already reported on; its init warnings
8005
8504
  // would just be duplicates.
@@ -8567,29 +9066,77 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
8567
9066
  }
8568
9067
  /**
8569
9068
  * Reads the PhantomOrderRegistered events emitted in a single block.
9069
+ *
9070
+ * Costs two RPCs per block when `knownVersion` is supplied and four without it, which is why the
9071
+ * poll goes to the trouble of establishing one. `api.at(hash)` has to work out which metadata to
9072
+ * decode the block against, and with nothing to go on it fetches the header and then the runtime
9073
+ * version at its parent — every block, forever. Its cheaper paths are a registry already pinned
9074
+ * to this exact hash (only ever the previous block's) or one matching a version the caller
9075
+ * names, so naming the version is the only way out. See `getBlockRegistry` in
9076
+ * `@polkadot/api/base/Init`; the `getUpgradeVersion` shortcut that would otherwise skip the
9077
+ * lookup only covers chains hardcoded in `@polkadot/types-known`, which Hyperbridge is not.
9078
+ *
9079
+ * @param knownVersion - the runtime version this block is known to run, if the caller has
9080
+ * established one. Passing a version the block does not actually run decodes it against the
9081
+ * wrong metadata, so this is for callers that have checked, not a place to pass a guess.
8570
9082
  */
8571
- async getPhantomOrdersInBlock(blockNumber) {
9083
+ async getPhantomOrdersInBlock(blockNumber, knownVersion) {
8572
9084
  const api = await this.http();
8573
9085
  const blockHash = await api.rpc.chain.getBlockHash(blockNumber);
8574
- const apiAt = await api.at(blockHash);
8575
- const records = await apiAt.query.system.events();
8576
- const orders = [];
8577
- for (const { event } of records) {
8578
- if (event.section !== "intentsCoprocessor" || event.method !== "PhantomOrderRegistered") continue;
8579
- const [commitment, chain, createdAt, legs] = event.data;
8580
- orders.push({
8581
- commitment: commitment.toHex(),
8582
- chain: new TextDecoder().decode(hexToU8a(chain.toHex())),
8583
- createdAt: createdAt.toNumber(),
8584
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8585
- legs: legs.map((leg) => ({
8586
- tokenA: leg.tokenA.toHex(),
8587
- tokenB: leg.tokenB.toHex(),
8588
- standardAmount: BigInt(leg.standardAmount.toString())
8589
- }))
8590
- });
8591
- }
8592
- return orders;
9086
+ return await this.getPhantomOrdersAtHash(blockHash.toHex(), knownVersion);
9087
+ }
9088
+ /**
9089
+ * The same read, for a caller that already holds the block's hash.
9090
+ *
9091
+ * Split out so the poll can fetch a whole range's hashes in one concurrent wave — which the
9092
+ * provider coalesces into a single batched request — and then read each block's events knowing
9093
+ * its hash. `chain_getBlockHash` is the half of the pair that parallelises safely: it takes no
9094
+ * historic block hash, so it never triggers polkadot-js's per-hash registry resolution, and
9095
+ * concurrent calls cannot race each other's registry state.
9096
+ */
9097
+ async getPhantomOrdersAtHash(blockHash, knownVersion) {
9098
+ const api = await this.http();
9099
+ const apiAt = await api.at(blockHash, knownVersion);
9100
+ return phantomOrdersFrom(await apiAt.query.system.events());
9101
+ }
9102
+ /**
9103
+ * Every block's phantom orders across a whole range, in one `state_queryStorage` call.
9104
+ *
9105
+ * This is the cheap path: the request cost of a scan stops depending on how many blocks it
9106
+ * covers. The events key is the only key queried, and both bounds are block hashes the caller
9107
+ * already holds.
9108
+ *
9109
+ * Two properties of the RPC shape the result.
9110
+ *
9111
+ * It returns *diffs*: `query_storage_unfiltered` in `sc-rpc` pushes a change set for a block only
9112
+ * when the value differs from the previous block in the range (`has_changed`, and the set is
9113
+ * dropped when empty), so a block whose events encode byte-for-byte identically to its
9114
+ * predecessor's is simply absent. That happens on a quiet chain, where consecutive blocks carry
9115
+ * nothing but the timestamp inherent's `ExtrinsicSuccess`. It is safe here because an absent
9116
+ * block provably carries no phantom orders: a `PhantomOrderRegistered` commitment is derived from
9117
+ * the block number (`phantom_order_commitment`), so a block that registered orders can never
9118
+ * encode identically to any other block. Absent therefore means "same as the previous block",
9119
+ * and the previous block having orders would contradict that.
9120
+ *
9121
+ * And it is gated by `--rpc-methods` (`check_if_safe` in `sc-rpc`), which answers a denied call
9122
+ * with `Method not found`. The node this reads from must already run unsafe RPC to serve
9123
+ * `offchain_localStorageGet` for the orders themselves, so this is normally available; the poll
9124
+ * falls back to reading block by block when it is not.
9125
+ *
9126
+ * @returns one entry per block the node reported a change for, in ascending block order.
9127
+ */
9128
+ async getPhantomOrdersInRange(fromBlockHash, toBlockHash) {
9129
+ const api = await this.http();
9130
+ const changeSets = await api.rpc.state.queryStorage.raw(
9131
+ [SYSTEM_EVENTS_KEY],
9132
+ fromBlockHash,
9133
+ toBlockHash
9134
+ );
9135
+ return changeSets.map((changeSet) => {
9136
+ const value = changeSet?.changes?.find(([key]) => key === SYSTEM_EVENTS_KEY)?.[1];
9137
+ if (!value) return [];
9138
+ return phantomOrdersFrom(api.registry.createType("Vec<EventRecord>", value));
9139
+ });
8593
9140
  }
8594
9141
  /**
8595
9142
  * Polls for newly registered phantom orders, invoking the callback once per block that carries
@@ -8617,30 +9164,85 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
8617
9164
  * socket that looks alive while delivering nothing. It also means a websocket outage does not
8618
9165
  * pause phantom bidding at all — the two transports fail independently.
8619
9166
  *
9167
+ * What the cadence does *not* describe is the request rate, which is what rate limiters police.
9168
+ * A tick costs four requests whatever the range covers — the head, the runtime version, the two
9169
+ * bounding block hashes as one batched request, and one `state_queryStorage` for every block's
9170
+ * events — and they go out back-to-back, so an interval well under any per-second limit could
9171
+ * still arrive as a burst over it. Three things keep that in bounds: the provider coalesces
9172
+ * concurrent calls into one request and paces requests through the endpoint's token bucket (see
9173
+ * `http`), and `maxBlocksPerPoll` bounds the range. A 429 that gets through anyway backs the
9174
+ * poll off for a doubling number of ticks, so a limiter that is already shedding load is not
9175
+ * handed the next window's budget in rejections too.
9176
+ *
9177
+ * Where the node will not serve `state_queryStorage` the poll reads block by block instead, at
9178
+ * three requests plus one per block; see {@link scanRangeAtOnce}.
9179
+ *
8620
9180
  * Returns a function that stops polling.
8621
9181
  */
8622
9182
  pollPhantomOrders(callback, options = {}) {
8623
- const { intervalMs, maxBlocksPerPoll = 500, lookbackBlocks = 0, onError } = options;
9183
+ const {
9184
+ intervalMs,
9185
+ maxBlocksPerPoll = DEFAULT_MAX_BLOCKS_PER_POLL,
9186
+ onError,
9187
+ onSkip
9188
+ } = options;
8624
9189
  let cursor = null;
8625
9190
  let inFlight = false;
8626
9191
  let stopped = false;
9192
+ let backoffTicks = 0;
9193
+ let backoffLength = 0;
8627
9194
  const tick = async () => {
8628
9195
  if (inFlight || stopped) return;
9196
+ if (backoffTicks > 0) {
9197
+ backoffTicks -= 1;
9198
+ return;
9199
+ }
8629
9200
  inFlight = true;
8630
9201
  try {
8631
- const head = (await (await this.http()).rpc.chain.getHeader()).number.toNumber();
9202
+ const api = await this.http();
9203
+ const head = (await api.rpc.chain.getHeader()).number.toNumber();
8632
9204
  if (cursor === null) {
8633
- cursor = Math.max(head - 1 - lookbackBlocks, -1);
9205
+ cursor = Math.max(head - 1, -1);
9206
+ } else {
9207
+ const { bidWindowBlocks, intervalBlocks } = await this.phantomTimings();
9208
+ if (head - cursor > bidWindowBlocks + Math.max(intervalBlocks, bidWindowBlocks)) {
9209
+ const from = cursor + 1;
9210
+ cursor = Math.max(head - 1 - bidWindowBlocks, -1);
9211
+ onSkip?.({ from, to: cursor, head });
9212
+ }
8634
9213
  }
8635
9214
  if (head <= cursor) return;
9215
+ const knownVersion = await this.confirmedRuntimeVersion();
8636
9216
  const to = Math.min(head, cursor + maxBlocksPerPoll);
8637
- for (let blockNumber = cursor + 1; blockNumber <= to; blockNumber++) {
9217
+ const ranged = await this.scanRangeAtOnce(api, cursor + 1, to, knownVersion, onError);
9218
+ if (ranged) {
9219
+ for (const orders of ranged) {
9220
+ if (stopped) return;
9221
+ if (orders.length > 0) callback(orders);
9222
+ }
9223
+ cursor = to;
9224
+ backoffLength = 0;
9225
+ return;
9226
+ }
9227
+ const numbers = [];
9228
+ for (let blockNumber = cursor + 1; blockNumber <= to; blockNumber++) numbers.push(blockNumber);
9229
+ const hashes = await Promise.allSettled(
9230
+ numbers.map((blockNumber) => api.rpc.chain.getBlockHash(blockNumber))
9231
+ );
9232
+ for (let index = 0; index < numbers.length; index++) {
8638
9233
  if (stopped) return;
8639
- const orders = await this.getPhantomOrdersInBlock(blockNumber);
9234
+ const hash = hashes[index];
9235
+ if (hash.status === "rejected") throw hash.reason;
9236
+ const orders = await this.getPhantomOrdersAtHash(hash.value.toHex(), knownVersion);
8640
9237
  if (orders.length > 0) callback(orders);
8641
- cursor = blockNumber;
9238
+ cursor = numbers[index];
8642
9239
  }
9240
+ backoffLength = 0;
8643
9241
  } catch (err) {
9242
+ if (isRateLimited(err)) {
9243
+ backoffLength = Math.min(backoffLength === 0 ? 1 : backoffLength * 2, MAX_RATE_LIMIT_BACKOFF_TICKS);
9244
+ backoffTicks = backoffLength;
9245
+ }
8644
9246
  onError?.(err);
8645
9247
  } finally {
8646
9248
  inFlight = false;
@@ -8659,6 +9261,125 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
8659
9261
  if (timer) clearInterval(timer);
8660
9262
  };
8661
9263
  }
9264
+ /**
9265
+ * The Hyperbridge head, over HTTP like every other read here.
9266
+ *
9267
+ * Exposed for callers that have to know how old something is: a phantom order carries the block
9268
+ * it was registered at, and only against the head does that become "still biddable" or "long
9269
+ * expired".
9270
+ */
9271
+ async latestBlockNumber() {
9272
+ const api = await this.http();
9273
+ return (await api.rpc.chain.getHeader()).number.toNumber();
9274
+ }
9275
+ /**
9276
+ * The pallet's phantom timings, read from chain state.
9277
+ *
9278
+ * Both are governance-settable and neither is derivable: on Nexus today the window is 15 while
9279
+ * the runtime constant behind it is 25, so anything hard-coded is wrong in one direction or the
9280
+ * other — too tight and live orders are dropped, too loose and bids are sent into a closed
9281
+ * window for the pallet to reject.
9282
+ *
9283
+ * Read once per instance and cached, because a governance change to either is rare and a read
9284
+ * per poll tick would be a request per tick forever. The cost is that a change is picked up on
9285
+ * the next restart rather than immediately. A failed read is not cached, so it retries.
9286
+ */
9287
+ async phantomTimings() {
9288
+ if (!this.phantomTimingsRead) {
9289
+ this.phantomTimingsRead = this.readPhantomTimings().catch((err) => {
9290
+ this.phantomTimingsRead = null;
9291
+ throw err;
9292
+ });
9293
+ }
9294
+ return this.phantomTimingsRead;
9295
+ }
9296
+ async readPhantomTimings() {
9297
+ const api = await this.http();
9298
+ const [window, interval] = await Promise.all([
9299
+ api.query.intentsCoprocessor.phantomBidWindow(),
9300
+ api.query.intentsCoprocessor.phantomOrderInterval()
9301
+ ]);
9302
+ const stored = Number(window.toString());
9303
+ return {
9304
+ bidWindowBlocks: stored === 0 ? Number(api.consts.intentsCoprocessor.phantomOrderBidWindowBlocks.toString()) : stored,
9305
+ intervalBlocks: Number(interval.toString())
9306
+ };
9307
+ }
9308
+ /**
9309
+ * A whole range of blocks in one `state_queryStorage` call, or `null` when that is not available
9310
+ * and the caller should read block by block.
9311
+ *
9312
+ * Two conditions have to hold, and both are about decoding rather than the range itself.
9313
+ *
9314
+ * The version must be confirmed for this tick — an upgrade inside the range means blocks decode
9315
+ * against different metadata, and one call cannot do that.
9316
+ *
9317
+ * And that confirmed version must still be the one the api's own registry was built for.
9318
+ * `state_queryStorage` declares no historic block hash, so rpc-core skips its registry swap and
9319
+ * decodes the reply against the default registry — fixed at connect, with no
9320
+ * `subscribeRuntimeVersion` on an HTTP api to refresh it. After an upgrade the two diverge, and
9321
+ * the per-block path takes over for good: `api.at(hash, version)` resolves, and builds, the right
9322
+ * registry. That costs a restart to get the cheap path back, which is the correct direction to
9323
+ * fail in.
9324
+ */
9325
+ async scanRangeAtOnce(api, from, to, knownVersion, onError) {
9326
+ if (this.rangeQueryUnavailable || !knownVersion) return null;
9327
+ const registryVersion = api.runtimeVersion?.specVersion;
9328
+ if (!registryVersion || !knownVersion.specVersion.eq(registryVersion)) return null;
9329
+ const [fromHash, toHash] = from === to ? await Promise.all([api.rpc.chain.getBlockHash(from)]).then(([only]) => [only, only]) : await Promise.all([api.rpc.chain.getBlockHash(from), api.rpc.chain.getBlockHash(to)]);
9330
+ try {
9331
+ return await this.getPhantomOrdersInRange(fromHash.toHex(), toHash.toHex());
9332
+ } catch (err) {
9333
+ if (isMethodUnavailable(err)) {
9334
+ this.rangeQueryUnavailable = true;
9335
+ return null;
9336
+ }
9337
+ if (err instanceof EventDecodeError) {
9338
+ this.rangeQueryUnavailable = true;
9339
+ onError?.(err);
9340
+ return null;
9341
+ }
9342
+ throw err;
9343
+ }
9344
+ }
9345
+ /**
9346
+ * The runtime version this tick's blocks may be decoded against, or `undefined` when that cannot
9347
+ * be established and each block must resolve its own.
9348
+ *
9349
+ * Naming a version to `api.at` is what removes two of the four RPCs a block scan costs, and it
9350
+ * is only sound while the version is actually the block's. Getting that wrong is not a loud
9351
+ * failure: events decoded against the wrong metadata come back as a shape the scan does not
9352
+ * recognise, so the block reads as carrying no phantom orders and the cursor advances past it —
9353
+ * exactly the silent miss the block cursor exists to rule out.
9354
+ *
9355
+ * So the version is read fresh each tick and only used when it matches the previous reading.
9356
+ * `specVersion` only ever increases, and this read happens *after* the head read, so two equal
9357
+ * readings mean no upgrade landed anywhere in between — and therefore none in the range about to
9358
+ * be scanned. A reading that differs means an upgrade landed inside the range: that tick falls
9359
+ * back to per-block resolution, which is exact, and the version is used from the next tick on
9360
+ * once it has been seen twice.
9361
+ *
9362
+ * The gap this leaves is a backlog reaching back past an upgrade, whose oldest blocks predate
9363
+ * even the previous reading. Recovering from an outage that long means those bid windows closed
9364
+ * many upgrades ago, so nothing is lost that was still winnable.
9365
+ *
9366
+ * A version that cannot be read at all yields `undefined` rather than an error: the scan is
9367
+ * about to make the same request against the same endpoint and is the better place to report it.
9368
+ */
9369
+ async confirmedRuntimeVersion() {
9370
+ let api;
9371
+ let current;
9372
+ try {
9373
+ api = await this.http();
9374
+ current = await api.rpc.state.getRuntimeVersion();
9375
+ } catch {
9376
+ return void 0;
9377
+ }
9378
+ const previous = this.lastRuntimeVersion ?? api.runtimeVersion;
9379
+ this.lastRuntimeVersion = current;
9380
+ if (!previous?.specVersion || !previous?.specName) return void 0;
9381
+ return current.specVersion.eq(previous.specVersion) && current.specName.eq(previous.specName) ? current : void 0;
9382
+ }
8662
9383
  /**
8663
9384
  * The poll cadence for the runtime this instance is connected to: Gargantua polls every block,
8664
9385
  * everything else every 15s. Falls back to the slower cadence if the runtime cannot be read,
@@ -17036,6 +17757,115 @@ var OrderCanceller = class _OrderCanceller {
17036
17757
  return feeInDestFeeToken * 1005n / 1000n;
17037
17758
  }
17038
17759
  };
17760
+ var FILL_ORDER_V1_ABI = [
17761
+ {
17762
+ type: "function",
17763
+ name: "fillOrder",
17764
+ stateMutability: "payable",
17765
+ outputs: [],
17766
+ inputs: [
17767
+ ABI3.find((e) => e.type === "function" && e.name === "fillOrder").inputs[0],
17768
+ {
17769
+ name: "options",
17770
+ type: "tuple",
17771
+ internalType: "struct FillOptions",
17772
+ components: [
17773
+ { name: "relayerFee", type: "uint256", internalType: "uint256" },
17774
+ { name: "nativeDispatchFee", type: "uint256", internalType: "uint256" },
17775
+ {
17776
+ name: "outputs",
17777
+ type: "tuple[]",
17778
+ internalType: "struct TokenInfo[]",
17779
+ components: [
17780
+ { name: "token", type: "bytes32", internalType: "bytes32" },
17781
+ { name: "amount", type: "uint256", internalType: "uint256" }
17782
+ ]
17783
+ }
17784
+ ]
17785
+ }
17786
+ ]
17787
+ }
17788
+ ];
17789
+ var ERC1967_IMPLEMENTATION_SLOT = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
17790
+ var LEGACY_FILL_OPTIONS_IMPLEMENTATIONS = /* @__PURE__ */ new Set([
17791
+ // The pre-validUntil IntentGatewayV2 implementation. One entry covers every chain: the
17792
+ // protocol contracts are CREATE2-deployed, so this is the implementation address on all
17793
+ // of them (confirmed with the maintainers).
17794
+ "0x976b268b06f545c4a2bf44866aa2465bd8b3c67d"
17795
+ ]);
17796
+ var CHAINS_WITHOUT_VALID_UNTIL = /* @__PURE__ */ new Set([
17797
+ 97,
17798
+ // BNB testnet
17799
+ 10200,
17800
+ // Gnosis Chiado
17801
+ 80002,
17802
+ // Polygon Amoy
17803
+ 84532,
17804
+ // Base Sepolia
17805
+ 421614,
17806
+ // Arbitrum Sepolia
17807
+ 688689,
17808
+ // Pharos testnet
17809
+ 11155111,
17810
+ // Sepolia
17811
+ 11155420,
17812
+ // Optimism Sepolia
17813
+ 420420417
17814
+ // Polkadot Hub Paseo
17815
+ ]);
17816
+ var knownV2Gateways = /* @__PURE__ */ new Set();
17817
+ function resetFillOptionsVersionCache() {
17818
+ knownV2Gateways.clear();
17819
+ }
17820
+ async function resolveImplementation(client, gateway) {
17821
+ const slot = await client.getStorageAt({ address: gateway, slot: ERC1967_IMPLEMENTATION_SLOT });
17822
+ if (!slot || slot.length < 66) return gateway;
17823
+ const addr = `0x${slot.slice(-40)}`;
17824
+ return /^0x0{40}$/.test(addr) ? gateway : addr;
17825
+ }
17826
+ async function getFillOptionsVersion(client, gateway) {
17827
+ const chainId = client.chain?.id;
17828
+ if (chainId !== void 0 && CHAINS_WITHOUT_VALID_UNTIL.has(chainId)) return 1;
17829
+ const key = gateway.toLowerCase();
17830
+ if (knownV2Gateways.has(key)) return 2;
17831
+ const implementation = await resolveImplementation(client, gateway);
17832
+ if (LEGACY_FILL_OPTIONS_IMPLEMENTATIONS.has(implementation.toLowerCase())) return 1;
17833
+ knownV2Gateways.add(key);
17834
+ return 2;
17835
+ }
17836
+ function encodeFillOrder(order, options, version) {
17837
+ if (version === 2) {
17838
+ return encodeFunctionData({
17839
+ abi: ABI3,
17840
+ functionName: "fillOrder",
17841
+ args: [order, options]
17842
+ });
17843
+ }
17844
+ const { relayerFee, nativeDispatchFee, outputs } = options;
17845
+ return encodeFunctionData({
17846
+ abi: FILL_ORDER_V1_ABI,
17847
+ functionName: "fillOrder",
17848
+ args: [order, { relayerFee, nativeDispatchFee, outputs }]
17849
+ });
17850
+ }
17851
+ function decodeFillOrder(data) {
17852
+ try {
17853
+ const decoded = decodeFunctionData({ abi: ABI3, data });
17854
+ if (decoded.functionName === "fillOrder" && decoded.args && decoded.args.length >= 2) {
17855
+ return { order: decoded.args[0], options: decoded.args[1] };
17856
+ }
17857
+ } catch {
17858
+ }
17859
+ try {
17860
+ const decoded = decodeFunctionData({ abi: FILL_ORDER_V1_ABI, data });
17861
+ if (decoded.functionName === "fillOrder" && decoded.args && decoded.args.length >= 2) {
17862
+ const legacy = decoded.args[1];
17863
+ return { order: decoded.args[0], options: { ...legacy, validUntil: 0n } };
17864
+ }
17865
+ } catch {
17866
+ }
17867
+ return null;
17868
+ }
17039
17869
  var BidImpl = class {
17040
17870
  solverAddress;
17041
17871
  outputs;
@@ -17466,19 +18296,9 @@ var BidManager = class {
17466
18296
  const innerCalls = this.crypto.decodeERC7821Execute(bid.userOp.callData);
17467
18297
  if (!innerCalls || innerCalls.length === 0) return null;
17468
18298
  for (const call of innerCalls) {
17469
- try {
17470
- const decoded = decodeFunctionData({
17471
- abi: ABI3,
17472
- data: call.data
17473
- });
17474
- if (decoded?.functionName === "fillOrder" && decoded.args && decoded.args.length >= 2) {
17475
- const fillOptions = decoded.args[1];
17476
- if (fillOptions?.outputs?.length > 0) {
17477
- return fillOptions;
17478
- }
17479
- }
17480
- } catch {
17481
- continue;
18299
+ const decoded = decodeFillOrder(call.data);
18300
+ if (decoded && decoded.options?.outputs?.length > 0) {
18301
+ return decoded.options;
17482
18302
  }
17483
18303
  }
17484
18304
  } catch {
@@ -17856,6 +18676,10 @@ var GasEstimator = class {
17856
18676
  relayerFee: crossChainFees.postRequestFee,
17857
18677
  // Always dispatch with the fee token (see the method docs).
17858
18678
  nativeDispatchFee: 0n,
18679
+ // Unbounded for estimation: this call is simulated, never submitted, and a real
18680
+ // bound here would only risk the estimate reverting on a slow bundler round trip.
18681
+ // The caller sets the real one on the options it actually signs.
18682
+ validUntil: 0n,
17859
18683
  outputs: order.output.assets.map((asset) => ({
17860
18684
  ...asset,
17861
18685
  token: normalizeAddressForEvmBytes32(asset.token)
@@ -17868,11 +18692,12 @@ var GasEstimator = class {
17868
18692
  let maxFeePerGas = gasPrice + gasPrice * BigInt(maxFeeBumpPercent) / 100n;
17869
18693
  const orderForEstimation = { ...order, session: solverAccountAddress };
17870
18694
  const commitment = orderCommitment(orderForEstimation);
17871
- const fillOrderCalldata = encodeFunctionData({
17872
- abi: ABI3,
17873
- functionName: "fillOrder",
17874
- args: [transformOrderForContract(orderForEstimation), fillOptions]
17875
- });
18695
+ const fillOptionsVersion = await getFillOptionsVersion(this.ctx.dest.client, intentGatewayV2Address);
18696
+ const fillOrderCalldata = encodeFillOrder(
18697
+ transformOrderForContract(orderForEstimation),
18698
+ fillOptions,
18699
+ fillOptionsVersion
18700
+ );
17876
18701
  let callGasLimit = 500000n;
17877
18702
  let verificationGasLimit = 100000n;
17878
18703
  let preVerificationGas = 100000n;
@@ -18960,7 +19785,18 @@ function buildResult(tradeType, amountIn, amountOut, selectedRate, rates, protoc
18960
19785
  }
18961
19786
 
18962
19787
  // src/protocols/intents/IntentGateway.ts
18963
- var CROSS_CHAIN_ORDER_FEE_GAS_PRICE_BUMP_PERCENT = 10n;
19788
+ var ORDER_FEE_GAS_PRICE_BUMP_POLICY = {
19789
+ defaultPercent: 10n,
19790
+ bySourceStateMachineId: {
19791
+ ["EVM-1" /* MAINNET */]: 50n
19792
+ }
19793
+ };
19794
+ function resolveOrderFeeGasPriceBump(sourceStateMachineId, isSameChain) {
19795
+ if (isSameChain) {
19796
+ return 0n;
19797
+ }
19798
+ return ORDER_FEE_GAS_PRICE_BUMP_POLICY.bySourceStateMachineId[sourceStateMachineId] ?? ORDER_FEE_GAS_PRICE_BUMP_POLICY.defaultPercent;
19799
+ }
18964
19800
  var IntentGateway = class _IntentGateway {
18965
19801
  /** EVM chain on which orders are placed and escrowed. */
18966
19802
  source;
@@ -19179,8 +20015,9 @@ var IntentGateway = class _IntentGateway {
19179
20015
  * **Yield/receive protocol:**
19180
20016
  * 1. If `order.fees` is unset or zero, prices the fee on an internal copy
19181
20017
  * via {@link quoteOrderFees}: same-chain fees are twice the fill-gas
19182
- * estimate without a gas-price bump; cross-chain gas is priced 10% above
19183
- * the live price before attaching (fill gas + the settlement relayer fee)
20018
+ * estimate without a gas-price bump; cross-chain order fees originating on
20019
+ * Ethereum price gas 50% above the live price, while other source chains use
20020
+ * 10%, before attaching (fill gas + the settlement relayer fee)
19184
20021
  * with a further 5% buffer over the whole sum — strictly above the solver's
19185
20022
  * unpadded requirement. Direct solver estimates remain unbumped. The wei
19186
20023
  * cost used for the `value` field receives a 2% buffer.
@@ -19550,7 +20387,8 @@ var IntentGateway = class _IntentGateway {
19550
20387
  * transaction (check the native balance).
19551
20388
  *
19552
20389
  * @param order - The order to quote. `order.fees` is ignored and not mutated.
19553
- * Gas prices used to derive cross-chain `fees` receive 10% SDK-only headroom.
20390
+ * Gas prices used to derive cross-chain `fees` receive 50% SDK-only headroom
20391
+ * when the source chain is Ethereum mainnet and 10% for other source chains.
19554
20392
  * Same-chain quotes and direct calls to {@link estimateFillOrder}, including
19555
20393
  * Simplex solver estimates, remain unbumped.
19556
20394
  *
@@ -19561,15 +20399,14 @@ var IntentGateway = class _IntentGateway {
19561
20399
  */
19562
20400
  async quoteOrderFees(order, options) {
19563
20401
  const isSameChain = this.source.config.stateMachineId === this.dest.config.stateMachineId;
20402
+ const orderFeeGasPriceBumpPercent = resolveOrderFeeGasPriceBump(this.source.config.stateMachineId, isSameChain);
19564
20403
  const estimate = await this.gasEstimator.estimateFillOrder(
19565
20404
  {
19566
20405
  order,
19567
20406
  maxPriorityFeePerGasBumpPercent: options?.maxPriorityFeePerGasBumpPercent,
19568
20407
  maxFeePerGasBumpPercent: options?.maxFeePerGasBumpPercent
19569
20408
  },
19570
- {
19571
- orderFeeGasPriceBumpPercent: isSameChain ? 0n : CROSS_CHAIN_ORDER_FEE_GAS_PRICE_BUMP_PERCENT
19572
- }
20409
+ { orderFeeGasPriceBumpPercent }
19573
20410
  );
19574
20411
  if (estimate.totalGasCostWei === 0n || estimate.totalGasInFeeToken === 0n) {
19575
20412
  throw new Error("Gas estimation failed");
@@ -19798,9 +20635,16 @@ function encodeAcceptedSourceChains(chains2) {
19798
20635
  function decodeAcceptedSourceChains(paymasterAndData) {
19799
20636
  return decodePhantomBidDeclaration(paymasterAndData).acceptedSources;
19800
20637
  }
19801
- var UNISWAP_QUOTE_HAIRCUT_BPS = 30n;
20638
+ var UNISWAP_QUOTE_HAIRCUT_BPS = 10n;
20639
+ var PHANTOM_QUOTE_HAIRCUT_BPS = 5n;
20640
+ function haircut(amount, bps) {
20641
+ return amount * (10000n - bps) / 10000n;
20642
+ }
19802
20643
  function applyUniswapQuoteHaircut(amount) {
19803
- return amount * (10000n - UNISWAP_QUOTE_HAIRCUT_BPS) / 10000n;
20644
+ return haircut(amount, UNISWAP_QUOTE_HAIRCUT_BPS);
20645
+ }
20646
+ function applyPhantomQuoteHaircut(amount) {
20647
+ return haircut(amount, PHANTOM_QUOTE_HAIRCUT_BPS);
19804
20648
  }
19805
20649
  FILL_ORDER_ABI.find(
19806
20650
  (item) => item?.type === "function" && item?.name === "fillOrder"
@@ -24275,6 +25119,6 @@ async function teleportDot(param_) {
24275
25119
  return stream;
24276
25120
  }
24277
25121
 
24278
- export { ADDRESS_ZERO2 as ADDRESS_ZERO, BundlerMethod, ChainConfigService, Chains, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, ABI as EvmHostABI, EvmLanguage, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, INCLUSION_TIMEOUT_MS, IndexedRateUnavailableError, IntentGateway, ABI3 as IntentGatewayABI, IntentOrderStatus, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, OrderStatusChecker, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, PhantomSnapshotUnavailableError, PharosChain, PolkadotHubChain, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SubstrateChain, Swap, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, TokenGateway, TronChain, UNISWAP_QUOTE_HAIRCUT_BPS, USE_ETHERSCAN_CHAINS, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, __test, adjustDecimals, applyUniswapQuoteHaircut, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodePhantomBidDeclaration, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeISMPMessage, encodePhantomBidDeclaration, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, poolSlug, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, sortPoolSymbols, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
25122
+ export { ADDRESS_ZERO2 as ADDRESS_ZERO, BundlerMethod, CHAINS_WITHOUT_VALID_UNTIL, ChainConfigService, Chains, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, ABI as EvmHostABI, EvmLanguage, FILL_ORDER_V1_ABI, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, INCLUSION_TIMEOUT_MS, IndexedRateUnavailableError, IntentGateway, ABI3 as IntentGatewayABI, IntentOrderStatus, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, OrderStatusChecker, PACKED_USEROP_TYPEHASH, PHANTOM_QUOTE_HAIRCUT_BPS, PLACE_ORDER_SELECTOR, PhantomSnapshotUnavailableError, PharosChain, PolkadotHubChain, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SubstrateChain, Swap, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, TokenGateway, TronChain, UNISWAP_QUOTE_HAIRCUT_BPS, USE_ETHERSCAN_CHAINS, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, __test, adjustDecimals, applyPhantomQuoteHaircut, applyUniswapQuoteHaircut, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodeFillOrder, decodePhantomBidDeclaration, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeFillOrder, encodeISMPMessage, encodePhantomBidDeclaration, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getFillOptionsVersion, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, poolSlug, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, resetFillOptionsVersionCache, responseCommitmentKey, retryPromise, sortPoolSymbols, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
24279
25123
  //# sourceMappingURL=index.js.map
24280
25124
  //# sourceMappingURL=index.js.map