@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.
@@ -4,10 +4,10 @@ import { baseSepolia, optimismSepolia, arbitrumSepolia, soneium, gnosis, optimis
4
4
  import { TronWeb } from 'tronweb';
5
5
  import { flatten, zip, capitalize, maxBy, isNil } from 'lodash-es';
6
6
  import { match } from 'ts-pattern';
7
- import { WsProvider, ApiPromise, HttpProvider, Keyring } from '@polkadot/api';
7
+ import { WsProvider, ApiPromise, Keyring, HttpProvider } from '@polkadot/api';
8
8
  import { Struct, Vector, u8, Bytes, Enum, Tuple, _void, u64, u32, Option, bool, u128 } from 'scale-ts';
9
- import { keccakAsU8a, decodeAddress, keccakAsHex, xxhashAsU8a, blake2AsU8a } from '@polkadot/util-crypto';
10
- import { hexToU8a, u8aToHex, u8aConcat, stringToU8a, isHex as isHex$1, u8aToString } from '@polkadot/util';
9
+ import { xxhashAsU8a, keccakAsU8a, decodeAddress, keccakAsHex, blake2AsU8a } from '@polkadot/util-crypto';
10
+ import { u8aToHex, u8aConcat, hexToU8a, stringToU8a, isHex as isHex$1, u8aToString } from '@polkadot/util';
11
11
  import PQueue from 'p-queue';
12
12
  import { hasWindow, isNode, env } from 'std-env';
13
13
  import mergeRace from '@async-generator/merge-race';
@@ -2761,7 +2761,7 @@ var chainConfigs = {
2761
2761
  },
2762
2762
  addresses: {
2763
2763
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2764
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
2764
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
2765
2765
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2766
2766
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2767
2767
  UniswapRouter02: "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
@@ -2828,7 +2828,7 @@ var chainConfigs = {
2828
2828
  },
2829
2829
  addresses: {
2830
2830
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2831
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
2831
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
2832
2832
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2833
2833
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2834
2834
  UniswapRouter02: "0x10ED43C718714eb63d5aA57B78B54704E256024E",
@@ -2889,7 +2889,7 @@ var chainConfigs = {
2889
2889
  },
2890
2890
  addresses: {
2891
2891
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2892
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
2892
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
2893
2893
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2894
2894
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2895
2895
  UniswapRouter02: "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",
@@ -2963,7 +2963,7 @@ var chainConfigs = {
2963
2963
  },
2964
2964
  addresses: {
2965
2965
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2966
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
2966
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
2967
2967
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2968
2968
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2969
2969
  UniswapRouter02: "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",
@@ -3038,7 +3038,7 @@ var chainConfigs = {
3038
3038
  },
3039
3039
  addresses: {
3040
3040
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
3041
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
3041
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
3042
3042
  TokenGateway: "0x8b536105b6Fae2aE9199f5146D3C57Dfe53b614E",
3043
3043
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
3044
3044
  UniswapRouter02: "0xd2f9496824951D5237cC71245D659E48d0d5f9E8",
@@ -3154,7 +3154,7 @@ var chainConfigs = {
3154
3154
  },
3155
3155
  addresses: {
3156
3156
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
3157
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
3157
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
3158
3158
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
3159
3159
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
3160
3160
  UniswapRouter02: "0x4A7b5Da61326A6379179b40d00F57E5bbDC962c2",
@@ -3189,7 +3189,7 @@ var chainConfigs = {
3189
3189
  },
3190
3190
  addresses: {
3191
3191
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
3192
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
3192
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
3193
3193
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
3194
3194
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
3195
3195
  UniswapRouter02: "0xB2e26652e4BAd1e56055A051f922E06760cA0BFE",
@@ -3345,7 +3345,7 @@ var chainConfigs = {
3345
3345
  },
3346
3346
  addresses: {
3347
3347
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
3348
- SolverAccount: "0xfCd233b937D7622AAc63ced3C9A1A12F4a6B64E3",
3348
+ SolverAccount: "0x7cb55539d1144F62422099c3FA3405092022c88C",
3349
3349
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
3350
3350
  Calldispatcher: "0xE2C7e576E26E0bE7aC97c6fE925bcDAbD87c4bEd"
3351
3351
  },
@@ -3392,7 +3392,7 @@ var ABI3 = [
3392
3392
  type: "constructor",
3393
3393
  inputs: [
3394
3394
  {
3395
- name: "admin",
3395
+ name: "owner",
3396
3396
  type: "address",
3397
3397
  internalType: "address"
3398
3398
  }
@@ -3467,25 +3467,6 @@ var ABI3 = [
3467
3467
  ],
3468
3468
  stateMutability: "view"
3469
3469
  },
3470
- {
3471
- type: "function",
3472
- name: "_instances",
3473
- inputs: [
3474
- {
3475
- name: "",
3476
- type: "bytes32",
3477
- internalType: "bytes32"
3478
- }
3479
- ],
3480
- outputs: [
3481
- {
3482
- name: "",
3483
- type: "address",
3484
- internalType: "address"
3485
- }
3486
- ],
3487
- stateMutability: "view"
3488
- },
3489
3470
  {
3490
3471
  type: "function",
3491
3472
  name: "_nonce",
@@ -3523,6 +3504,19 @@ var ABI3 = [
3523
3504
  ],
3524
3505
  stateMutability: "view"
3525
3506
  },
3507
+ {
3508
+ type: "function",
3509
+ name: "_owner",
3510
+ inputs: [],
3511
+ outputs: [
3512
+ {
3513
+ name: "",
3514
+ type: "address",
3515
+ internalType: "address"
3516
+ }
3517
+ ],
3518
+ stateMutability: "view"
3519
+ },
3526
3520
  {
3527
3521
  type: "function",
3528
3522
  name: "_partialFills",
@@ -3897,6 +3891,11 @@ var ABI3 = [
3897
3891
  type: "uint256",
3898
3892
  internalType: "uint256"
3899
3893
  },
3894
+ {
3895
+ name: "validUntil",
3896
+ type: "uint256",
3897
+ internalType: "uint256"
3898
+ },
3900
3899
  {
3901
3900
  name: "outputs",
3902
3901
  type: "tuple[]",
@@ -3933,6 +3932,61 @@ var ABI3 = [
3933
3932
  ],
3934
3933
  stateMutability: "view"
3935
3934
  },
3935
+ {
3936
+ type: "function",
3937
+ name: "initialize",
3938
+ inputs: [
3939
+ {
3940
+ name: "p",
3941
+ type: "tuple",
3942
+ internalType: "struct Params",
3943
+ components: [
3944
+ {
3945
+ name: "host",
3946
+ type: "address",
3947
+ internalType: "address"
3948
+ },
3949
+ {
3950
+ name: "dispatcher",
3951
+ type: "address",
3952
+ internalType: "address"
3953
+ },
3954
+ {
3955
+ name: "solverSelection",
3956
+ type: "bool",
3957
+ internalType: "bool"
3958
+ },
3959
+ {
3960
+ name: "surplusShareBps",
3961
+ type: "uint256",
3962
+ internalType: "uint256"
3963
+ },
3964
+ {
3965
+ name: "protocolFeeBps",
3966
+ type: "uint256",
3967
+ internalType: "uint256"
3968
+ },
3969
+ {
3970
+ name: "priceOracle",
3971
+ type: "address",
3972
+ internalType: "address"
3973
+ }
3974
+ ]
3975
+ },
3976
+ {
3977
+ name: "peerChains",
3978
+ type: "bytes[]",
3979
+ internalType: "bytes[]"
3980
+ },
3981
+ {
3982
+ name: "relayer",
3983
+ type: "address",
3984
+ internalType: "address"
3985
+ }
3986
+ ],
3987
+ outputs: [],
3988
+ stateMutability: "nonpayable"
3989
+ },
3936
3990
  {
3937
3991
  type: "function",
3938
3992
  name: "instance",
@@ -3952,6 +4006,19 @@ var ABI3 = [
3952
4006
  ],
3953
4007
  stateMutability: "view"
3954
4008
  },
4009
+ {
4010
+ type: "function",
4011
+ name: "migrate",
4012
+ inputs: [
4013
+ {
4014
+ name: "relayer",
4015
+ type: "address",
4016
+ internalType: "address"
4017
+ }
4018
+ ],
4019
+ outputs: [],
4020
+ stateMutability: "nonpayable"
4021
+ },
3955
4022
  {
3956
4023
  type: "function",
3957
4024
  name: "onAccept",
@@ -4463,7 +4530,7 @@ var ABI3 = [
4463
4530
  internalType: "uint256"
4464
4531
  }
4465
4532
  ],
4466
- stateMutability: "view"
4533
+ stateMutability: "nonpayable"
4467
4534
  },
4468
4535
  {
4469
4536
  type: "function",
@@ -4519,6 +4586,19 @@ var ABI3 = [
4519
4586
  internalType: "uint256"
4520
4587
  }
4521
4588
  ],
4589
+ stateMutability: "nonpayable"
4590
+ },
4591
+ {
4592
+ type: "function",
4593
+ name: "relayer",
4594
+ inputs: [],
4595
+ outputs: [
4596
+ {
4597
+ name: "",
4598
+ type: "address",
4599
+ internalType: "address"
4600
+ }
4601
+ ],
4522
4602
  stateMutability: "view"
4523
4603
  },
4524
4604
  {
@@ -4559,66 +4639,67 @@ var ABI3 = [
4559
4639
  },
4560
4640
  {
4561
4641
  type: "function",
4562
- name: "init",
4642
+ name: "setRelayer",
4563
4643
  inputs: [
4564
4644
  {
4565
- name: "p",
4566
- type: "tuple",
4567
- internalType: "struct Params",
4568
- components: [
4569
- {
4570
- name: "host",
4571
- type: "address",
4572
- internalType: "address"
4573
- },
4574
- {
4575
- name: "dispatcher",
4576
- type: "address",
4577
- internalType: "address"
4578
- },
4579
- {
4580
- name: "solverSelection",
4581
- type: "bool",
4582
- internalType: "bool"
4583
- },
4584
- {
4585
- name: "surplusShareBps",
4586
- type: "uint256",
4587
- internalType: "uint256"
4588
- },
4589
- {
4590
- name: "protocolFeeBps",
4591
- type: "uint256",
4592
- internalType: "uint256"
4593
- },
4594
- {
4595
- name: "priceOracle",
4596
- type: "address",
4597
- internalType: "address"
4598
- }
4599
- ]
4645
+ name: "relayer",
4646
+ type: "address",
4647
+ internalType: "address"
4648
+ }
4649
+ ],
4650
+ outputs: [],
4651
+ stateMutability: "nonpayable"
4652
+ },
4653
+ {
4654
+ type: "function",
4655
+ name: "upgradeToAndCall",
4656
+ inputs: [
4657
+ {
4658
+ name: "newImplementation",
4659
+ type: "address",
4660
+ internalType: "address"
4600
4661
  },
4601
4662
  {
4602
- name: "deployments",
4603
- type: "tuple[]",
4604
- internalType: "struct Deployment[]",
4605
- components: [
4606
- {
4607
- name: "chain",
4608
- type: "bytes",
4609
- internalType: "bytes"
4610
- },
4611
- {
4612
- name: "gateway",
4613
- type: "address",
4614
- internalType: "address"
4615
- }
4616
- ]
4663
+ name: "data",
4664
+ type: "bytes",
4665
+ internalType: "bytes"
4617
4666
  }
4618
4667
  ],
4619
4668
  outputs: [],
4620
4669
  stateMutability: "nonpayable"
4621
4670
  },
4671
+ {
4672
+ type: "function",
4673
+ name: "version",
4674
+ inputs: [],
4675
+ outputs: [
4676
+ {
4677
+ name: "",
4678
+ type: "uint64",
4679
+ internalType: "uint64"
4680
+ }
4681
+ ],
4682
+ stateMutability: "view"
4683
+ },
4684
+ {
4685
+ type: "event",
4686
+ name: "DeploymentAdded",
4687
+ inputs: [
4688
+ {
4689
+ name: "chain",
4690
+ type: "string",
4691
+ indexed: false,
4692
+ internalType: "string"
4693
+ },
4694
+ {
4695
+ name: "gateway",
4696
+ type: "address",
4697
+ indexed: false,
4698
+ internalType: "address"
4699
+ }
4700
+ ],
4701
+ anonymous: false
4702
+ },
4622
4703
  {
4623
4704
  type: "event",
4624
4705
  name: "DestinationProtocolFeeUpdated",
@@ -4752,16 +4833,29 @@ var ABI3 = [
4752
4833
  },
4753
4834
  {
4754
4835
  type: "event",
4755
- name: "DeploymentAdded",
4836
+ name: "Initialized",
4756
4837
  inputs: [
4757
4838
  {
4758
- name: "chain",
4759
- type: "string",
4839
+ name: "version",
4840
+ type: "uint64",
4760
4841
  indexed: false,
4761
- internalType: "string"
4842
+ internalType: "uint64"
4843
+ }
4844
+ ],
4845
+ anonymous: false
4846
+ },
4847
+ {
4848
+ type: "event",
4849
+ name: "OrderCancelled",
4850
+ inputs: [
4851
+ {
4852
+ name: "commitment",
4853
+ type: "bytes32",
4854
+ indexed: true,
4855
+ internalType: "bytes32"
4762
4856
  },
4763
4857
  {
4764
- name: "gateway",
4858
+ name: "canceller",
4765
4859
  type: "address",
4766
4860
  indexed: false,
4767
4861
  internalType: "address"
@@ -5089,14 +5183,52 @@ var ABI3 = [
5089
5183
  ],
5090
5184
  anonymous: false
5091
5185
  },
5186
+ {
5187
+ type: "event",
5188
+ name: "RelayerUpdated",
5189
+ inputs: [
5190
+ {
5191
+ name: "previous",
5192
+ type: "address",
5193
+ indexed: false,
5194
+ internalType: "address"
5195
+ },
5196
+ {
5197
+ name: "current",
5198
+ type: "address",
5199
+ indexed: false,
5200
+ internalType: "address"
5201
+ }
5202
+ ],
5203
+ anonymous: false
5204
+ },
5205
+ {
5206
+ type: "event",
5207
+ name: "Upgraded",
5208
+ inputs: [
5209
+ {
5210
+ name: "implementation",
5211
+ type: "address",
5212
+ indexed: true,
5213
+ internalType: "address"
5214
+ }
5215
+ ],
5216
+ anonymous: false
5217
+ },
5092
5218
  {
5093
5219
  type: "error",
5094
- name: "Cancelled",
5095
- inputs: []
5220
+ name: "AddressEmptyCode",
5221
+ inputs: [
5222
+ {
5223
+ name: "target",
5224
+ type: "address",
5225
+ internalType: "address"
5226
+ }
5227
+ ]
5096
5228
  },
5097
5229
  {
5098
5230
  type: "error",
5099
- name: "UnknownInstance",
5231
+ name: "Cancelled",
5100
5232
  inputs: []
5101
5233
  },
5102
5234
  {
@@ -5117,18 +5249,44 @@ var ABI3 = [
5117
5249
  },
5118
5250
  {
5119
5251
  type: "error",
5120
- name: "ECDSAInvalidSignatureS",
5121
- inputs: [
5122
- {
5123
- name: "s",
5124
- type: "bytes32",
5125
- internalType: "bytes32"
5126
- }
5127
- ]
5252
+ name: "ECDSAInvalidSignatureS",
5253
+ inputs: [
5254
+ {
5255
+ name: "s",
5256
+ type: "bytes32",
5257
+ internalType: "bytes32"
5258
+ }
5259
+ ]
5260
+ },
5261
+ {
5262
+ type: "error",
5263
+ name: "ERC1967InvalidImplementation",
5264
+ inputs: [
5265
+ {
5266
+ name: "implementation",
5267
+ type: "address",
5268
+ internalType: "address"
5269
+ }
5270
+ ]
5271
+ },
5272
+ {
5273
+ type: "error",
5274
+ name: "ERC1967NonPayable",
5275
+ inputs: []
5276
+ },
5277
+ {
5278
+ type: "error",
5279
+ name: "Expired",
5280
+ inputs: []
5281
+ },
5282
+ {
5283
+ type: "error",
5284
+ name: "FailedCall",
5285
+ inputs: []
5128
5286
  },
5129
5287
  {
5130
5288
  type: "error",
5131
- name: "Expired",
5289
+ name: "FillExpired",
5132
5290
  inputs: []
5133
5291
  },
5134
5292
  {
@@ -5141,6 +5299,11 @@ var ABI3 = [
5141
5299
  name: "InsufficientNativeToken",
5142
5300
  inputs: []
5143
5301
  },
5302
+ {
5303
+ type: "error",
5304
+ name: "InvalidInitialization",
5305
+ inputs: []
5306
+ },
5144
5307
  {
5145
5308
  type: "error",
5146
5309
  name: "InvalidInput",
@@ -5156,6 +5319,21 @@ var ABI3 = [
5156
5319
  name: "NotExpired",
5157
5320
  inputs: []
5158
5321
  },
5322
+ {
5323
+ type: "error",
5324
+ name: "NotInitializing",
5325
+ inputs: []
5326
+ },
5327
+ {
5328
+ type: "error",
5329
+ name: "PartialFillNotAllowed",
5330
+ inputs: []
5331
+ },
5332
+ {
5333
+ type: "error",
5334
+ name: "ReentrancyGuardReentrantCall",
5335
+ inputs: []
5336
+ },
5159
5337
  {
5160
5338
  type: "error",
5161
5339
  name: "SafeERC20FailedOperation",
@@ -5193,6 +5371,11 @@ var ABI3 = [
5193
5371
  name: "UnexpectedCall",
5194
5372
  inputs: []
5195
5373
  },
5374
+ {
5375
+ type: "error",
5376
+ name: "UnknownInstance",
5377
+ inputs: []
5378
+ },
5196
5379
  {
5197
5380
  type: "error",
5198
5381
  name: "UnknownOrder",
@@ -7864,6 +8047,255 @@ function encodeISMPMessage(message) {
7864
8047
  throw new Error("Failed to encode ISMP message", { cause: error });
7865
8048
  }
7866
8049
  }
8050
+
8051
+ // src/utils/rateLimiter.ts
8052
+ var TokenBucket = class {
8053
+ /**
8054
+ * @param ratePerSecond - sustained requests per second.
8055
+ * @param burst - how many requests may go out back-to-back before pacing starts. Defaults to
8056
+ * one second's worth, which is the shape most limiters police.
8057
+ */
8058
+ constructor(ratePerSecond, burst = ratePerSecond) {
8059
+ this.ratePerSecond = ratePerSecond;
8060
+ this.burst = burst;
8061
+ if (ratePerSecond <= 0) throw new Error(`TokenBucket rate must be positive, got ${ratePerSecond}`);
8062
+ this.tokens = burst;
8063
+ this.lastRefill = Date.now();
8064
+ }
8065
+ ratePerSecond;
8066
+ burst;
8067
+ /** Fractional on purpose: a partial token is real capacity, just not yet a whole request. */
8068
+ tokens;
8069
+ lastRefill;
8070
+ waiting = [];
8071
+ drainTimer = null;
8072
+ /** Resolves once this caller may send. */
8073
+ async acquire() {
8074
+ if (this.waiting.length === 0 && this.take()) return;
8075
+ return new Promise((resolve) => {
8076
+ this.waiting.push(resolve);
8077
+ this.scheduleDrain();
8078
+ });
8079
+ }
8080
+ /** Requests currently waiting on a token. Exposed for tests and diagnostics. */
8081
+ get queued() {
8082
+ return this.waiting.length;
8083
+ }
8084
+ refill() {
8085
+ const now = Date.now();
8086
+ const elapsed = now - this.lastRefill;
8087
+ if (elapsed <= 0) {
8088
+ if (elapsed < 0) this.lastRefill = now;
8089
+ return;
8090
+ }
8091
+ this.tokens = Math.min(this.burst, this.tokens + elapsed * this.ratePerSecond / 1e3);
8092
+ this.lastRefill = now;
8093
+ }
8094
+ take() {
8095
+ this.refill();
8096
+ if (this.tokens < 1) return false;
8097
+ this.tokens -= 1;
8098
+ return true;
8099
+ }
8100
+ scheduleDrain() {
8101
+ if (this.drainTimer) return;
8102
+ this.refill();
8103
+ const deficit = 1 - this.tokens;
8104
+ const waitMs = deficit <= 0 ? 0 : Math.ceil(deficit * 1e3 / this.ratePerSecond);
8105
+ const timer = setTimeout(() => {
8106
+ this.drainTimer = null;
8107
+ this.drain();
8108
+ }, waitMs);
8109
+ timer.unref?.();
8110
+ this.drainTimer = timer;
8111
+ }
8112
+ drain() {
8113
+ while (this.waiting.length > 0 && this.take()) {
8114
+ this.waiting.shift()?.();
8115
+ }
8116
+ if (this.waiting.length > 0) this.scheduleDrain();
8117
+ }
8118
+ };
8119
+ var BATCHES_NOT_SUPPORTED_CODE = -32005;
8120
+ var TOO_BIG_BATCH_REQUEST_CODE = -32010;
8121
+ var DEFAULT_MAX_BATCH_SIZE = 32;
8122
+ function rpcError({ code, message, data }) {
8123
+ const suffix = data === void 0 ? "" : `: ${typeof data === "string" ? data : JSON.stringify(data)}`;
8124
+ const error = new Error(`${code}: ${message}${suffix}`);
8125
+ error.code = code;
8126
+ error.data = data;
8127
+ return error;
8128
+ }
8129
+ var BatchingHttpProvider = class _BatchingHttpProvider extends HttpProvider {
8130
+ #endpoint;
8131
+ #headers;
8132
+ #limiter;
8133
+ #maxBatchSize;
8134
+ #batchingSupported = true;
8135
+ #pending = [];
8136
+ #flushTimer = null;
8137
+ #flushing = false;
8138
+ #nextId = 1;
8139
+ constructor(endpoint, headers, limiter, maxBatchSize = DEFAULT_MAX_BATCH_SIZE) {
8140
+ super(endpoint, headers, 0);
8141
+ this.#endpoint = endpoint;
8142
+ this.#headers = headers;
8143
+ this.#limiter = limiter;
8144
+ this.#maxBatchSize = maxBatchSize;
8145
+ }
8146
+ /**
8147
+ * `isCacheable` is accepted for interface compatibility and ignored: this provider has no
8148
+ * response cache, which is deliberate — see the note in `IntentsCoprocessor.http`.
8149
+ */
8150
+ async send(method, params, _isCacheable) {
8151
+ return new Promise((resolve, reject) => {
8152
+ this.#pending.push({
8153
+ id: this.#nextId++,
8154
+ method,
8155
+ params,
8156
+ resolve,
8157
+ reject
8158
+ });
8159
+ if (this.#pending.length >= this.#maxBatchSize) this.#flushNow();
8160
+ else this.#scheduleFlush();
8161
+ });
8162
+ }
8163
+ clone() {
8164
+ return new _BatchingHttpProvider(this.#endpoint, this.#headers, this.#limiter, this.#maxBatchSize);
8165
+ }
8166
+ /** Calls waiting for a flush. Exposed for tests and diagnostics. */
8167
+ get queued() {
8168
+ return this.#pending.length;
8169
+ }
8170
+ /**
8171
+ * Collect for the rest of this macrotask, then send.
8172
+ *
8173
+ * A macrotask rather than a microtask because the bursts worth catching are not synchronous:
8174
+ * `Promise.all` over a set of reads starts them in one synchronous run, but each then advances
8175
+ * through several microtask turns of its own before reaching the provider. A microtask flush
8176
+ * would fire between those turns and split one burst across several requests.
8177
+ */
8178
+ #scheduleFlush() {
8179
+ if (this.#flushTimer || this.#flushing) return;
8180
+ const timer = setTimeout(() => {
8181
+ this.#flushTimer = null;
8182
+ void this.#flush();
8183
+ }, 0);
8184
+ timer.unref?.();
8185
+ this.#flushTimer = timer;
8186
+ }
8187
+ #flushNow() {
8188
+ if (this.#flushing) return;
8189
+ if (this.#flushTimer) {
8190
+ clearTimeout(this.#flushTimer);
8191
+ this.#flushTimer = null;
8192
+ }
8193
+ void this.#flush();
8194
+ }
8195
+ async #flush() {
8196
+ if (this.#flushing) return;
8197
+ const calls = this.#pending.splice(0, this.#maxBatchSize);
8198
+ if (calls.length === 0) return;
8199
+ this.#flushing = true;
8200
+ try {
8201
+ await this.#limiter.acquire();
8202
+ await this.#post(calls);
8203
+ } finally {
8204
+ this.#flushing = false;
8205
+ if (this.#pending.length > 0) this.#scheduleFlush();
8206
+ }
8207
+ }
8208
+ async #post(calls) {
8209
+ const single = calls.length === 1;
8210
+ const payload = calls.map(({ id, method, params }) => ({ id, jsonrpc: "2.0", method, params }));
8211
+ const body = JSON.stringify(single ? payload[0] : payload);
8212
+ let parsed;
8213
+ try {
8214
+ const response = await fetch(this.#endpoint, {
8215
+ body,
8216
+ headers: {
8217
+ Accept: "application/json",
8218
+ "Content-Type": "application/json",
8219
+ ...this.#headers
8220
+ },
8221
+ method: "POST"
8222
+ });
8223
+ if (!response.ok) throw new Error(`[${response.status}]: ${response.statusText}`);
8224
+ parsed = JSON.parse(await response.text());
8225
+ } catch (err) {
8226
+ const error = err instanceof Error ? err : new Error(String(err));
8227
+ error.message = `${error.message}
8228
+ Failed HTTP Request: ${JSON.stringify(
8229
+ calls.map(({ method, params }) => ({ method, params }))
8230
+ )}`;
8231
+ for (const call of calls) call.reject(error);
8232
+ return;
8233
+ }
8234
+ if (Array.isArray(parsed)) {
8235
+ this.#settleBatch(calls, parsed);
8236
+ return;
8237
+ }
8238
+ if (!single) {
8239
+ this.#handleBatchRefusal(calls, parsed);
8240
+ return;
8241
+ }
8242
+ this.#settle(calls[0], parsed);
8243
+ }
8244
+ #settleBatch(calls, responses) {
8245
+ const byId = /* @__PURE__ */ new Map();
8246
+ for (const response of responses) {
8247
+ if (typeof response?.id === "number") byId.set(response.id, response);
8248
+ }
8249
+ for (const call of calls) {
8250
+ const response = byId.get(call.id);
8251
+ if (response) this.#settle(call, response);
8252
+ else call.reject(new Error(`No response for ${call.method} in batch reply`));
8253
+ }
8254
+ }
8255
+ #settle(call, response) {
8256
+ if (response?.error) {
8257
+ call.reject(rpcError(response.error));
8258
+ return;
8259
+ }
8260
+ if (!response || response.result === void 0) {
8261
+ call.reject(new Error("No result found in jsonrpc response"));
8262
+ return;
8263
+ }
8264
+ call.resolve(response.result);
8265
+ }
8266
+ /**
8267
+ * The server rejected the batch itself rather than any call in it. Both forms are recoverable
8268
+ * without losing a call, and neither should ever surface to a caller as a failure.
8269
+ */
8270
+ #handleBatchRefusal(calls, response) {
8271
+ const code = response?.error?.code;
8272
+ if (code === BATCHES_NOT_SUPPORTED_CODE) {
8273
+ this.#batchingSupported = false;
8274
+ this.#maxBatchSize = 1;
8275
+ this.#requeue(calls);
8276
+ return;
8277
+ }
8278
+ if (code === TOO_BIG_BATCH_REQUEST_CODE) {
8279
+ this.#maxBatchSize = Math.max(1, Math.floor(this.#maxBatchSize / 2));
8280
+ this.#requeue(calls);
8281
+ return;
8282
+ }
8283
+ const error = response?.error ? rpcError(response.error) : new Error("Malformed batch reply: neither an array nor an error");
8284
+ for (const call of calls) call.reject(error);
8285
+ }
8286
+ /** Puts calls back at the head of the queue, so a refused batch keeps its place in line. */
8287
+ #requeue(calls) {
8288
+ this.#pending.unshift(...calls);
8289
+ this.#scheduleFlush();
8290
+ }
8291
+ /** Whether batches are still being attempted. Exposed for tests and diagnostics. */
8292
+ get batchingSupported() {
8293
+ return this.#batchingSupported;
8294
+ }
8295
+ };
8296
+
8297
+ // src/chains/intentsCoprocessor.ts
8298
+ var SYSTEM_EVENTS_KEY = u8aToHex(u8aConcat(xxhashAsU8a("System", 128), xxhashAsU8a("Events", 128)));
7867
8299
  var OFFCHAIN_BID_PREFIX = new TextEncoder().encode("intents::bid::");
7868
8300
  var OFFCHAIN_PHANTOM_PREFIX = new TextEncoder().encode("intents::phantom::order::");
7869
8301
  var HYPERBRIDGE_TYPES_BUNDLE = {
@@ -7877,6 +8309,63 @@ var HTTP_CONNECT_TIMEOUT_MS = 2e4;
7877
8309
  var INCLUSION_TIMEOUT_MS = 2e4;
7878
8310
  var PHANTOM_POLL_INTERVAL_MS = 15e3;
7879
8311
  var GARGANTUA_PHANTOM_POLL_INTERVAL_MS = 6e3;
8312
+ var DEFAULT_RPC_MAX_RPS = 8;
8313
+ var DEFAULT_MAX_BLOCKS_PER_POLL = 10;
8314
+ var MAX_RATE_LIMIT_BACKOFF_TICKS = 8;
8315
+ var rpcLimiters = /* @__PURE__ */ new Map();
8316
+ function limiterFor(httpUrl) {
8317
+ const key = new URL(httpUrl).origin;
8318
+ let limiter = rpcLimiters.get(key);
8319
+ if (!limiter) {
8320
+ limiter = new TokenBucket(configuredRpcMaxRps());
8321
+ rpcLimiters.set(key, limiter);
8322
+ }
8323
+ return limiter;
8324
+ }
8325
+ function configuredRpcMaxRps() {
8326
+ const raw = typeof process !== "undefined" ? process.env?.HYPERBRIDGE_RPC_MAX_RPS : void 0;
8327
+ const parsed = raw === void 0 ? Number.NaN : Number(raw);
8328
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_RPC_MAX_RPS;
8329
+ }
8330
+ function isRateLimited(err) {
8331
+ const message = err instanceof Error ? err.message : String(err);
8332
+ return message.includes("[429]") || /too many requests/i.test(message);
8333
+ }
8334
+ function isMethodUnavailable(err) {
8335
+ const message = err instanceof Error ? err.message : String(err);
8336
+ const code = err?.code;
8337
+ return code === -32601 || /method not found|unsafe to be called externally/i.test(message);
8338
+ }
8339
+ var EventDecodeError = class extends Error {
8340
+ };
8341
+ function phantomOrdersFrom(records) {
8342
+ if (records == null || typeof records[Symbol.iterator] !== "function") {
8343
+ throw new EventDecodeError(`Expected a decoded event vector, got ${typeof records}`);
8344
+ }
8345
+ const orders = [];
8346
+ for (const record of records) {
8347
+ if (typeof record !== "object" || record === null || !("event" in record)) {
8348
+ throw new EventDecodeError(
8349
+ "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"
8350
+ );
8351
+ }
8352
+ const { event } = record;
8353
+ if (event.section !== "intentsCoprocessor" || event.method !== "PhantomOrderRegistered") continue;
8354
+ const [commitment, chain, createdAt, legs] = event.data;
8355
+ orders.push({
8356
+ commitment: commitment.toHex(),
8357
+ chain: new TextDecoder().decode(hexToU8a(chain.toHex())),
8358
+ createdAt: createdAt.toNumber(),
8359
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8360
+ legs: legs.map((leg) => ({
8361
+ tokenA: leg.tokenA.toHex(),
8362
+ tokenB: leg.tokenB.toHex(),
8363
+ standardAmount: BigInt(leg.standardAmount.toString())
8364
+ }))
8365
+ });
8366
+ }
8367
+ return orders;
8368
+ }
7880
8369
  function rejectAfter(ms, message) {
7881
8370
  return new Promise((_resolve, reject) => {
7882
8371
  const timer = setTimeout(() => reject(new Error(message)), ms);
@@ -7948,8 +8437,14 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
7948
8437
  ownsConnection;
7949
8438
  /** Cached result of whether the node exposes intents_* RPC methods */
7950
8439
  hasIntentsRpc = null;
8440
+ /** The pallet's phantom timings, read once. Cleared on failure so the read retries. */
8441
+ phantomTimingsRead = null;
7951
8442
  /** The HTTP-backed api, connected on first use. Cleared after a failed attempt so it retries. */
7952
8443
  httpApi = null;
8444
+ /** Last runtime version read from the node, for {@link confirmedRuntimeVersion} to compare against. */
8445
+ lastRuntimeVersion;
8446
+ /** Set once the node refuses `state_queryStorage`, so the poll stops asking for it. */
8447
+ rangeQueryUnavailable = false;
7953
8448
  // Serialises every extrinsic submission on this instance's substrate account. All submit/retract
7954
8449
  // methods funnel through signAndSendExtrinsic, each using the API's auto-nonce; fired in parallel
7955
8450
  // (bids for orders on different chains, or several phantom orders in one interval) they would grab
@@ -8049,7 +8544,11 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
8049
8544
  // replayed from memory on every tick, faster than the TTL could lapse, and the node never
8050
8545
  // saw a second request. The cache bought nothing here anyway: the poll reads each block
8051
8546
  // once, and `api.at(hash)` reuses registries at the api layer regardless.
8052
- provider: new HttpProvider(httpUrl, {}, 0),
8547
+ // Concurrent calls are coalesced into one JSON-RPC batch request, and every request
8548
+ // to this endpoint is paced by a bucket shared with any other coprocessor in this
8549
+ // process pointed at the same host — the limit is the server's, and it counts
8550
+ // requests per address rather than per connection.
8551
+ provider: new BatchingHttpProvider(httpUrl, {}, limiterFor(httpUrl)),
8053
8552
  typesBundle: HYPERBRIDGE_TYPES_BUNDLE,
8054
8553
  // A second connection to the node the ws api already reported on; its init warnings
8055
8554
  // would just be duplicates.
@@ -8617,29 +9116,77 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
8617
9116
  }
8618
9117
  /**
8619
9118
  * Reads the PhantomOrderRegistered events emitted in a single block.
9119
+ *
9120
+ * Costs two RPCs per block when `knownVersion` is supplied and four without it, which is why the
9121
+ * poll goes to the trouble of establishing one. `api.at(hash)` has to work out which metadata to
9122
+ * decode the block against, and with nothing to go on it fetches the header and then the runtime
9123
+ * version at its parent — every block, forever. Its cheaper paths are a registry already pinned
9124
+ * to this exact hash (only ever the previous block's) or one matching a version the caller
9125
+ * names, so naming the version is the only way out. See `getBlockRegistry` in
9126
+ * `@polkadot/api/base/Init`; the `getUpgradeVersion` shortcut that would otherwise skip the
9127
+ * lookup only covers chains hardcoded in `@polkadot/types-known`, which Hyperbridge is not.
9128
+ *
9129
+ * @param knownVersion - the runtime version this block is known to run, if the caller has
9130
+ * established one. Passing a version the block does not actually run decodes it against the
9131
+ * wrong metadata, so this is for callers that have checked, not a place to pass a guess.
8620
9132
  */
8621
- async getPhantomOrdersInBlock(blockNumber) {
9133
+ async getPhantomOrdersInBlock(blockNumber, knownVersion) {
8622
9134
  const api = await this.http();
8623
9135
  const blockHash = await api.rpc.chain.getBlockHash(blockNumber);
8624
- const apiAt = await api.at(blockHash);
8625
- const records = await apiAt.query.system.events();
8626
- const orders = [];
8627
- for (const { event } of records) {
8628
- if (event.section !== "intentsCoprocessor" || event.method !== "PhantomOrderRegistered") continue;
8629
- const [commitment, chain, createdAt, legs] = event.data;
8630
- orders.push({
8631
- commitment: commitment.toHex(),
8632
- chain: new TextDecoder().decode(hexToU8a(chain.toHex())),
8633
- createdAt: createdAt.toNumber(),
8634
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8635
- legs: legs.map((leg) => ({
8636
- tokenA: leg.tokenA.toHex(),
8637
- tokenB: leg.tokenB.toHex(),
8638
- standardAmount: BigInt(leg.standardAmount.toString())
8639
- }))
8640
- });
8641
- }
8642
- return orders;
9136
+ return await this.getPhantomOrdersAtHash(blockHash.toHex(), knownVersion);
9137
+ }
9138
+ /**
9139
+ * The same read, for a caller that already holds the block's hash.
9140
+ *
9141
+ * Split out so the poll can fetch a whole range's hashes in one concurrent wave — which the
9142
+ * provider coalesces into a single batched request — and then read each block's events knowing
9143
+ * its hash. `chain_getBlockHash` is the half of the pair that parallelises safely: it takes no
9144
+ * historic block hash, so it never triggers polkadot-js's per-hash registry resolution, and
9145
+ * concurrent calls cannot race each other's registry state.
9146
+ */
9147
+ async getPhantomOrdersAtHash(blockHash, knownVersion) {
9148
+ const api = await this.http();
9149
+ const apiAt = await api.at(blockHash, knownVersion);
9150
+ return phantomOrdersFrom(await apiAt.query.system.events());
9151
+ }
9152
+ /**
9153
+ * Every block's phantom orders across a whole range, in one `state_queryStorage` call.
9154
+ *
9155
+ * This is the cheap path: the request cost of a scan stops depending on how many blocks it
9156
+ * covers. The events key is the only key queried, and both bounds are block hashes the caller
9157
+ * already holds.
9158
+ *
9159
+ * Two properties of the RPC shape the result.
9160
+ *
9161
+ * It returns *diffs*: `query_storage_unfiltered` in `sc-rpc` pushes a change set for a block only
9162
+ * when the value differs from the previous block in the range (`has_changed`, and the set is
9163
+ * dropped when empty), so a block whose events encode byte-for-byte identically to its
9164
+ * predecessor's is simply absent. That happens on a quiet chain, where consecutive blocks carry
9165
+ * nothing but the timestamp inherent's `ExtrinsicSuccess`. It is safe here because an absent
9166
+ * block provably carries no phantom orders: a `PhantomOrderRegistered` commitment is derived from
9167
+ * the block number (`phantom_order_commitment`), so a block that registered orders can never
9168
+ * encode identically to any other block. Absent therefore means "same as the previous block",
9169
+ * and the previous block having orders would contradict that.
9170
+ *
9171
+ * And it is gated by `--rpc-methods` (`check_if_safe` in `sc-rpc`), which answers a denied call
9172
+ * with `Method not found`. The node this reads from must already run unsafe RPC to serve
9173
+ * `offchain_localStorageGet` for the orders themselves, so this is normally available; the poll
9174
+ * falls back to reading block by block when it is not.
9175
+ *
9176
+ * @returns one entry per block the node reported a change for, in ascending block order.
9177
+ */
9178
+ async getPhantomOrdersInRange(fromBlockHash, toBlockHash) {
9179
+ const api = await this.http();
9180
+ const changeSets = await api.rpc.state.queryStorage.raw(
9181
+ [SYSTEM_EVENTS_KEY],
9182
+ fromBlockHash,
9183
+ toBlockHash
9184
+ );
9185
+ return changeSets.map((changeSet) => {
9186
+ const value = changeSet?.changes?.find(([key]) => key === SYSTEM_EVENTS_KEY)?.[1];
9187
+ if (!value) return [];
9188
+ return phantomOrdersFrom(api.registry.createType("Vec<EventRecord>", value));
9189
+ });
8643
9190
  }
8644
9191
  /**
8645
9192
  * Polls for newly registered phantom orders, invoking the callback once per block that carries
@@ -8667,30 +9214,85 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
8667
9214
  * socket that looks alive while delivering nothing. It also means a websocket outage does not
8668
9215
  * pause phantom bidding at all — the two transports fail independently.
8669
9216
  *
9217
+ * What the cadence does *not* describe is the request rate, which is what rate limiters police.
9218
+ * A tick costs four requests whatever the range covers — the head, the runtime version, the two
9219
+ * bounding block hashes as one batched request, and one `state_queryStorage` for every block's
9220
+ * events — and they go out back-to-back, so an interval well under any per-second limit could
9221
+ * still arrive as a burst over it. Three things keep that in bounds: the provider coalesces
9222
+ * concurrent calls into one request and paces requests through the endpoint's token bucket (see
9223
+ * `http`), and `maxBlocksPerPoll` bounds the range. A 429 that gets through anyway backs the
9224
+ * poll off for a doubling number of ticks, so a limiter that is already shedding load is not
9225
+ * handed the next window's budget in rejections too.
9226
+ *
9227
+ * Where the node will not serve `state_queryStorage` the poll reads block by block instead, at
9228
+ * three requests plus one per block; see {@link scanRangeAtOnce}.
9229
+ *
8670
9230
  * Returns a function that stops polling.
8671
9231
  */
8672
9232
  pollPhantomOrders(callback, options = {}) {
8673
- const { intervalMs, maxBlocksPerPoll = 500, lookbackBlocks = 0, onError } = options;
9233
+ const {
9234
+ intervalMs,
9235
+ maxBlocksPerPoll = DEFAULT_MAX_BLOCKS_PER_POLL,
9236
+ onError,
9237
+ onSkip
9238
+ } = options;
8674
9239
  let cursor = null;
8675
9240
  let inFlight = false;
8676
9241
  let stopped = false;
9242
+ let backoffTicks = 0;
9243
+ let backoffLength = 0;
8677
9244
  const tick = async () => {
8678
9245
  if (inFlight || stopped) return;
9246
+ if (backoffTicks > 0) {
9247
+ backoffTicks -= 1;
9248
+ return;
9249
+ }
8679
9250
  inFlight = true;
8680
9251
  try {
8681
- const head = (await (await this.http()).rpc.chain.getHeader()).number.toNumber();
9252
+ const api = await this.http();
9253
+ const head = (await api.rpc.chain.getHeader()).number.toNumber();
8682
9254
  if (cursor === null) {
8683
- cursor = Math.max(head - 1 - lookbackBlocks, -1);
9255
+ cursor = Math.max(head - 1, -1);
9256
+ } else {
9257
+ const { bidWindowBlocks, intervalBlocks } = await this.phantomTimings();
9258
+ if (head - cursor > bidWindowBlocks + Math.max(intervalBlocks, bidWindowBlocks)) {
9259
+ const from = cursor + 1;
9260
+ cursor = Math.max(head - 1 - bidWindowBlocks, -1);
9261
+ onSkip?.({ from, to: cursor, head });
9262
+ }
8684
9263
  }
8685
9264
  if (head <= cursor) return;
9265
+ const knownVersion = await this.confirmedRuntimeVersion();
8686
9266
  const to = Math.min(head, cursor + maxBlocksPerPoll);
8687
- for (let blockNumber = cursor + 1; blockNumber <= to; blockNumber++) {
9267
+ const ranged = await this.scanRangeAtOnce(api, cursor + 1, to, knownVersion, onError);
9268
+ if (ranged) {
9269
+ for (const orders of ranged) {
9270
+ if (stopped) return;
9271
+ if (orders.length > 0) callback(orders);
9272
+ }
9273
+ cursor = to;
9274
+ backoffLength = 0;
9275
+ return;
9276
+ }
9277
+ const numbers = [];
9278
+ for (let blockNumber = cursor + 1; blockNumber <= to; blockNumber++) numbers.push(blockNumber);
9279
+ const hashes = await Promise.allSettled(
9280
+ numbers.map((blockNumber) => api.rpc.chain.getBlockHash(blockNumber))
9281
+ );
9282
+ for (let index = 0; index < numbers.length; index++) {
8688
9283
  if (stopped) return;
8689
- const orders = await this.getPhantomOrdersInBlock(blockNumber);
9284
+ const hash = hashes[index];
9285
+ if (hash.status === "rejected") throw hash.reason;
9286
+ const orders = await this.getPhantomOrdersAtHash(hash.value.toHex(), knownVersion);
8690
9287
  if (orders.length > 0) callback(orders);
8691
- cursor = blockNumber;
9288
+ cursor = numbers[index];
8692
9289
  }
9290
+ backoffLength = 0;
8693
9291
  } catch (err) {
9292
+ if (isRateLimited(err)) {
9293
+ backoffLength = Math.min(backoffLength === 0 ? 1 : backoffLength * 2, MAX_RATE_LIMIT_BACKOFF_TICKS);
9294
+ backoffTicks = backoffLength;
9295
+ }
8694
9296
  onError?.(err);
8695
9297
  } finally {
8696
9298
  inFlight = false;
@@ -8709,6 +9311,125 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
8709
9311
  if (timer) clearInterval(timer);
8710
9312
  };
8711
9313
  }
9314
+ /**
9315
+ * The Hyperbridge head, over HTTP like every other read here.
9316
+ *
9317
+ * Exposed for callers that have to know how old something is: a phantom order carries the block
9318
+ * it was registered at, and only against the head does that become "still biddable" or "long
9319
+ * expired".
9320
+ */
9321
+ async latestBlockNumber() {
9322
+ const api = await this.http();
9323
+ return (await api.rpc.chain.getHeader()).number.toNumber();
9324
+ }
9325
+ /**
9326
+ * The pallet's phantom timings, read from chain state.
9327
+ *
9328
+ * Both are governance-settable and neither is derivable: on Nexus today the window is 15 while
9329
+ * the runtime constant behind it is 25, so anything hard-coded is wrong in one direction or the
9330
+ * other — too tight and live orders are dropped, too loose and bids are sent into a closed
9331
+ * window for the pallet to reject.
9332
+ *
9333
+ * Read once per instance and cached, because a governance change to either is rare and a read
9334
+ * per poll tick would be a request per tick forever. The cost is that a change is picked up on
9335
+ * the next restart rather than immediately. A failed read is not cached, so it retries.
9336
+ */
9337
+ async phantomTimings() {
9338
+ if (!this.phantomTimingsRead) {
9339
+ this.phantomTimingsRead = this.readPhantomTimings().catch((err) => {
9340
+ this.phantomTimingsRead = null;
9341
+ throw err;
9342
+ });
9343
+ }
9344
+ return this.phantomTimingsRead;
9345
+ }
9346
+ async readPhantomTimings() {
9347
+ const api = await this.http();
9348
+ const [window, interval] = await Promise.all([
9349
+ api.query.intentsCoprocessor.phantomBidWindow(),
9350
+ api.query.intentsCoprocessor.phantomOrderInterval()
9351
+ ]);
9352
+ const stored = Number(window.toString());
9353
+ return {
9354
+ bidWindowBlocks: stored === 0 ? Number(api.consts.intentsCoprocessor.phantomOrderBidWindowBlocks.toString()) : stored,
9355
+ intervalBlocks: Number(interval.toString())
9356
+ };
9357
+ }
9358
+ /**
9359
+ * A whole range of blocks in one `state_queryStorage` call, or `null` when that is not available
9360
+ * and the caller should read block by block.
9361
+ *
9362
+ * Two conditions have to hold, and both are about decoding rather than the range itself.
9363
+ *
9364
+ * The version must be confirmed for this tick — an upgrade inside the range means blocks decode
9365
+ * against different metadata, and one call cannot do that.
9366
+ *
9367
+ * And that confirmed version must still be the one the api's own registry was built for.
9368
+ * `state_queryStorage` declares no historic block hash, so rpc-core skips its registry swap and
9369
+ * decodes the reply against the default registry — fixed at connect, with no
9370
+ * `subscribeRuntimeVersion` on an HTTP api to refresh it. After an upgrade the two diverge, and
9371
+ * the per-block path takes over for good: `api.at(hash, version)` resolves, and builds, the right
9372
+ * registry. That costs a restart to get the cheap path back, which is the correct direction to
9373
+ * fail in.
9374
+ */
9375
+ async scanRangeAtOnce(api, from, to, knownVersion, onError) {
9376
+ if (this.rangeQueryUnavailable || !knownVersion) return null;
9377
+ const registryVersion = api.runtimeVersion?.specVersion;
9378
+ if (!registryVersion || !knownVersion.specVersion.eq(registryVersion)) return null;
9379
+ 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)]);
9380
+ try {
9381
+ return await this.getPhantomOrdersInRange(fromHash.toHex(), toHash.toHex());
9382
+ } catch (err) {
9383
+ if (isMethodUnavailable(err)) {
9384
+ this.rangeQueryUnavailable = true;
9385
+ return null;
9386
+ }
9387
+ if (err instanceof EventDecodeError) {
9388
+ this.rangeQueryUnavailable = true;
9389
+ onError?.(err);
9390
+ return null;
9391
+ }
9392
+ throw err;
9393
+ }
9394
+ }
9395
+ /**
9396
+ * The runtime version this tick's blocks may be decoded against, or `undefined` when that cannot
9397
+ * be established and each block must resolve its own.
9398
+ *
9399
+ * Naming a version to `api.at` is what removes two of the four RPCs a block scan costs, and it
9400
+ * is only sound while the version is actually the block's. Getting that wrong is not a loud
9401
+ * failure: events decoded against the wrong metadata come back as a shape the scan does not
9402
+ * recognise, so the block reads as carrying no phantom orders and the cursor advances past it —
9403
+ * exactly the silent miss the block cursor exists to rule out.
9404
+ *
9405
+ * So the version is read fresh each tick and only used when it matches the previous reading.
9406
+ * `specVersion` only ever increases, and this read happens *after* the head read, so two equal
9407
+ * readings mean no upgrade landed anywhere in between — and therefore none in the range about to
9408
+ * be scanned. A reading that differs means an upgrade landed inside the range: that tick falls
9409
+ * back to per-block resolution, which is exact, and the version is used from the next tick on
9410
+ * once it has been seen twice.
9411
+ *
9412
+ * The gap this leaves is a backlog reaching back past an upgrade, whose oldest blocks predate
9413
+ * even the previous reading. Recovering from an outage that long means those bid windows closed
9414
+ * many upgrades ago, so nothing is lost that was still winnable.
9415
+ *
9416
+ * A version that cannot be read at all yields `undefined` rather than an error: the scan is
9417
+ * about to make the same request against the same endpoint and is the better place to report it.
9418
+ */
9419
+ async confirmedRuntimeVersion() {
9420
+ let api;
9421
+ let current;
9422
+ try {
9423
+ api = await this.http();
9424
+ current = await api.rpc.state.getRuntimeVersion();
9425
+ } catch {
9426
+ return void 0;
9427
+ }
9428
+ const previous = this.lastRuntimeVersion ?? api.runtimeVersion;
9429
+ this.lastRuntimeVersion = current;
9430
+ if (!previous?.specVersion || !previous?.specName) return void 0;
9431
+ return current.specVersion.eq(previous.specVersion) && current.specName.eq(previous.specName) ? current : void 0;
9432
+ }
8712
9433
  /**
8713
9434
  * The poll cadence for the runtime this instance is connected to: Gargantua polls every block,
8714
9435
  * everything else every 15s. Falls back to the slower cadence if the runtime cannot be read,
@@ -17096,6 +17817,115 @@ var OrderCanceller = class _OrderCanceller {
17096
17817
  return feeInDestFeeToken * 1005n / 1000n;
17097
17818
  }
17098
17819
  };
17820
+ var FILL_ORDER_V1_ABI = [
17821
+ {
17822
+ type: "function",
17823
+ name: "fillOrder",
17824
+ stateMutability: "payable",
17825
+ outputs: [],
17826
+ inputs: [
17827
+ ABI3.find((e) => e.type === "function" && e.name === "fillOrder").inputs[0],
17828
+ {
17829
+ name: "options",
17830
+ type: "tuple",
17831
+ internalType: "struct FillOptions",
17832
+ components: [
17833
+ { name: "relayerFee", type: "uint256", internalType: "uint256" },
17834
+ { name: "nativeDispatchFee", type: "uint256", internalType: "uint256" },
17835
+ {
17836
+ name: "outputs",
17837
+ type: "tuple[]",
17838
+ internalType: "struct TokenInfo[]",
17839
+ components: [
17840
+ { name: "token", type: "bytes32", internalType: "bytes32" },
17841
+ { name: "amount", type: "uint256", internalType: "uint256" }
17842
+ ]
17843
+ }
17844
+ ]
17845
+ }
17846
+ ]
17847
+ }
17848
+ ];
17849
+ var ERC1967_IMPLEMENTATION_SLOT = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
17850
+ var LEGACY_FILL_OPTIONS_IMPLEMENTATIONS = /* @__PURE__ */ new Set([
17851
+ // The pre-validUntil IntentGatewayV2 implementation. One entry covers every chain: the
17852
+ // protocol contracts are CREATE2-deployed, so this is the implementation address on all
17853
+ // of them (confirmed with the maintainers).
17854
+ "0x976b268b06f545c4a2bf44866aa2465bd8b3c67d"
17855
+ ]);
17856
+ var CHAINS_WITHOUT_VALID_UNTIL = /* @__PURE__ */ new Set([
17857
+ 97,
17858
+ // BNB testnet
17859
+ 10200,
17860
+ // Gnosis Chiado
17861
+ 80002,
17862
+ // Polygon Amoy
17863
+ 84532,
17864
+ // Base Sepolia
17865
+ 421614,
17866
+ // Arbitrum Sepolia
17867
+ 688689,
17868
+ // Pharos testnet
17869
+ 11155111,
17870
+ // Sepolia
17871
+ 11155420,
17872
+ // Optimism Sepolia
17873
+ 420420417
17874
+ // Polkadot Hub Paseo
17875
+ ]);
17876
+ var knownV2Gateways = /* @__PURE__ */ new Set();
17877
+ function resetFillOptionsVersionCache() {
17878
+ knownV2Gateways.clear();
17879
+ }
17880
+ async function resolveImplementation(client, gateway) {
17881
+ const slot = await client.getStorageAt({ address: gateway, slot: ERC1967_IMPLEMENTATION_SLOT });
17882
+ if (!slot || slot.length < 66) return gateway;
17883
+ const addr = `0x${slot.slice(-40)}`;
17884
+ return /^0x0{40}$/.test(addr) ? gateway : addr;
17885
+ }
17886
+ async function getFillOptionsVersion(client, gateway) {
17887
+ const chainId = client.chain?.id;
17888
+ if (chainId !== void 0 && CHAINS_WITHOUT_VALID_UNTIL.has(chainId)) return 1;
17889
+ const key = gateway.toLowerCase();
17890
+ if (knownV2Gateways.has(key)) return 2;
17891
+ const implementation = await resolveImplementation(client, gateway);
17892
+ if (LEGACY_FILL_OPTIONS_IMPLEMENTATIONS.has(implementation.toLowerCase())) return 1;
17893
+ knownV2Gateways.add(key);
17894
+ return 2;
17895
+ }
17896
+ function encodeFillOrder(order, options, version) {
17897
+ if (version === 2) {
17898
+ return encodeFunctionData({
17899
+ abi: ABI3,
17900
+ functionName: "fillOrder",
17901
+ args: [order, options]
17902
+ });
17903
+ }
17904
+ const { relayerFee, nativeDispatchFee, outputs } = options;
17905
+ return encodeFunctionData({
17906
+ abi: FILL_ORDER_V1_ABI,
17907
+ functionName: "fillOrder",
17908
+ args: [order, { relayerFee, nativeDispatchFee, outputs }]
17909
+ });
17910
+ }
17911
+ function decodeFillOrder(data) {
17912
+ try {
17913
+ const decoded = decodeFunctionData({ abi: ABI3, data });
17914
+ if (decoded.functionName === "fillOrder" && decoded.args && decoded.args.length >= 2) {
17915
+ return { order: decoded.args[0], options: decoded.args[1] };
17916
+ }
17917
+ } catch {
17918
+ }
17919
+ try {
17920
+ const decoded = decodeFunctionData({ abi: FILL_ORDER_V1_ABI, data });
17921
+ if (decoded.functionName === "fillOrder" && decoded.args && decoded.args.length >= 2) {
17922
+ const legacy = decoded.args[1];
17923
+ return { order: decoded.args[0], options: { ...legacy, validUntil: 0n } };
17924
+ }
17925
+ } catch {
17926
+ }
17927
+ return null;
17928
+ }
17099
17929
  var BidImpl = class {
17100
17930
  solverAddress;
17101
17931
  outputs;
@@ -17526,19 +18356,9 @@ var BidManager = class {
17526
18356
  const innerCalls = this.crypto.decodeERC7821Execute(bid.userOp.callData);
17527
18357
  if (!innerCalls || innerCalls.length === 0) return null;
17528
18358
  for (const call of innerCalls) {
17529
- try {
17530
- const decoded = decodeFunctionData({
17531
- abi: ABI3,
17532
- data: call.data
17533
- });
17534
- if (decoded?.functionName === "fillOrder" && decoded.args && decoded.args.length >= 2) {
17535
- const fillOptions = decoded.args[1];
17536
- if (fillOptions?.outputs?.length > 0) {
17537
- return fillOptions;
17538
- }
17539
- }
17540
- } catch {
17541
- continue;
18359
+ const decoded = decodeFillOrder(call.data);
18360
+ if (decoded && decoded.options?.outputs?.length > 0) {
18361
+ return decoded.options;
17542
18362
  }
17543
18363
  }
17544
18364
  } catch {
@@ -17916,6 +18736,10 @@ var GasEstimator = class {
17916
18736
  relayerFee: crossChainFees.postRequestFee,
17917
18737
  // Always dispatch with the fee token (see the method docs).
17918
18738
  nativeDispatchFee: 0n,
18739
+ // Unbounded for estimation: this call is simulated, never submitted, and a real
18740
+ // bound here would only risk the estimate reverting on a slow bundler round trip.
18741
+ // The caller sets the real one on the options it actually signs.
18742
+ validUntil: 0n,
17919
18743
  outputs: order.output.assets.map((asset) => ({
17920
18744
  ...asset,
17921
18745
  token: normalizeAddressForEvmBytes32(asset.token)
@@ -17928,11 +18752,12 @@ var GasEstimator = class {
17928
18752
  let maxFeePerGas = gasPrice + gasPrice * BigInt(maxFeeBumpPercent) / 100n;
17929
18753
  const orderForEstimation = { ...order, session: solverAccountAddress };
17930
18754
  const commitment = orderCommitment(orderForEstimation);
17931
- const fillOrderCalldata = encodeFunctionData({
17932
- abi: ABI3,
17933
- functionName: "fillOrder",
17934
- args: [transformOrderForContract(orderForEstimation), fillOptions]
17935
- });
18755
+ const fillOptionsVersion = await getFillOptionsVersion(this.ctx.dest.client, intentGatewayV2Address);
18756
+ const fillOrderCalldata = encodeFillOrder(
18757
+ transformOrderForContract(orderForEstimation),
18758
+ fillOptions,
18759
+ fillOptionsVersion
18760
+ );
17936
18761
  let callGasLimit = 500000n;
17937
18762
  let verificationGasLimit = 100000n;
17938
18763
  let preVerificationGas = 100000n;
@@ -19020,7 +19845,18 @@ function buildResult(tradeType, amountIn, amountOut, selectedRate, rates, protoc
19020
19845
  }
19021
19846
 
19022
19847
  // src/protocols/intents/IntentGateway.ts
19023
- var CROSS_CHAIN_ORDER_FEE_GAS_PRICE_BUMP_PERCENT = 10n;
19848
+ var ORDER_FEE_GAS_PRICE_BUMP_POLICY = {
19849
+ defaultPercent: 10n,
19850
+ bySourceStateMachineId: {
19851
+ ["EVM-1" /* MAINNET */]: 50n
19852
+ }
19853
+ };
19854
+ function resolveOrderFeeGasPriceBump(sourceStateMachineId, isSameChain) {
19855
+ if (isSameChain) {
19856
+ return 0n;
19857
+ }
19858
+ return ORDER_FEE_GAS_PRICE_BUMP_POLICY.bySourceStateMachineId[sourceStateMachineId] ?? ORDER_FEE_GAS_PRICE_BUMP_POLICY.defaultPercent;
19859
+ }
19024
19860
  var IntentGateway = class _IntentGateway {
19025
19861
  /** EVM chain on which orders are placed and escrowed. */
19026
19862
  source;
@@ -19239,8 +20075,9 @@ var IntentGateway = class _IntentGateway {
19239
20075
  * **Yield/receive protocol:**
19240
20076
  * 1. If `order.fees` is unset or zero, prices the fee on an internal copy
19241
20077
  * via {@link quoteOrderFees}: same-chain fees are twice the fill-gas
19242
- * estimate without a gas-price bump; cross-chain gas is priced 10% above
19243
- * the live price before attaching (fill gas + the settlement relayer fee)
20078
+ * estimate without a gas-price bump; cross-chain order fees originating on
20079
+ * Ethereum price gas 50% above the live price, while other source chains use
20080
+ * 10%, before attaching (fill gas + the settlement relayer fee)
19244
20081
  * with a further 5% buffer over the whole sum — strictly above the solver's
19245
20082
  * unpadded requirement. Direct solver estimates remain unbumped. The wei
19246
20083
  * cost used for the `value` field receives a 2% buffer.
@@ -19610,7 +20447,8 @@ var IntentGateway = class _IntentGateway {
19610
20447
  * transaction (check the native balance).
19611
20448
  *
19612
20449
  * @param order - The order to quote. `order.fees` is ignored and not mutated.
19613
- * Gas prices used to derive cross-chain `fees` receive 10% SDK-only headroom.
20450
+ * Gas prices used to derive cross-chain `fees` receive 50% SDK-only headroom
20451
+ * when the source chain is Ethereum mainnet and 10% for other source chains.
19614
20452
  * Same-chain quotes and direct calls to {@link estimateFillOrder}, including
19615
20453
  * Simplex solver estimates, remain unbumped.
19616
20454
  *
@@ -19621,15 +20459,14 @@ var IntentGateway = class _IntentGateway {
19621
20459
  */
19622
20460
  async quoteOrderFees(order, options) {
19623
20461
  const isSameChain = this.source.config.stateMachineId === this.dest.config.stateMachineId;
20462
+ const orderFeeGasPriceBumpPercent = resolveOrderFeeGasPriceBump(this.source.config.stateMachineId, isSameChain);
19624
20463
  const estimate = await this.gasEstimator.estimateFillOrder(
19625
20464
  {
19626
20465
  order,
19627
20466
  maxPriorityFeePerGasBumpPercent: options?.maxPriorityFeePerGasBumpPercent,
19628
20467
  maxFeePerGasBumpPercent: options?.maxFeePerGasBumpPercent
19629
20468
  },
19630
- {
19631
- orderFeeGasPriceBumpPercent: isSameChain ? 0n : CROSS_CHAIN_ORDER_FEE_GAS_PRICE_BUMP_PERCENT
19632
- }
20469
+ { orderFeeGasPriceBumpPercent }
19633
20470
  );
19634
20471
  if (estimate.totalGasCostWei === 0n || estimate.totalGasInFeeToken === 0n) {
19635
20472
  throw new Error("Gas estimation failed");
@@ -19858,9 +20695,16 @@ function encodeAcceptedSourceChains(chains2) {
19858
20695
  function decodeAcceptedSourceChains(paymasterAndData) {
19859
20696
  return decodePhantomBidDeclaration(paymasterAndData).acceptedSources;
19860
20697
  }
19861
- var UNISWAP_QUOTE_HAIRCUT_BPS = 30n;
20698
+ var UNISWAP_QUOTE_HAIRCUT_BPS = 10n;
20699
+ var PHANTOM_QUOTE_HAIRCUT_BPS = 5n;
20700
+ function haircut(amount, bps) {
20701
+ return amount * (10000n - bps) / 10000n;
20702
+ }
19862
20703
  function applyUniswapQuoteHaircut(amount) {
19863
- return amount * (10000n - UNISWAP_QUOTE_HAIRCUT_BPS) / 10000n;
20704
+ return haircut(amount, UNISWAP_QUOTE_HAIRCUT_BPS);
20705
+ }
20706
+ function applyPhantomQuoteHaircut(amount) {
20707
+ return haircut(amount, PHANTOM_QUOTE_HAIRCUT_BPS);
19864
20708
  }
19865
20709
  FILL_ORDER_ABI.find(
19866
20710
  (item) => item?.type === "function" && item?.name === "fillOrder"
@@ -24335,6 +25179,6 @@ async function teleportDot(param_) {
24335
25179
  return stream;
24336
25180
  }
24337
25181
 
24338
- 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 };
25182
+ 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 };
24339
25183
  //# sourceMappingURL=index.js.map
24340
25184
  //# sourceMappingURL=index.js.map