@hyperbridge/sdk 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.d.ts +62 -22
- package/dist/browser/index.js +223 -100
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.d.ts +62 -22
- package/dist/node/index.js +223 -100
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
- package/plugins/vite.js +52 -39
package/dist/node/index.js
CHANGED
|
@@ -3806,6 +3806,7 @@ var DEFAULT_POLL_INTERVAL = 5e3;
|
|
|
3806
3806
|
var ADDRESS_ZERO = "0x0000000000000000000000000000000000000000";
|
|
3807
3807
|
var MOCK_ADDRESS = "0x1234567890123456789012345678901234567890";
|
|
3808
3808
|
var DUMMY_PRIVATE_KEY = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
3809
|
+
var DEFAULT_GRAFFITI = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
3809
3810
|
function sleep(ms) {
|
|
3810
3811
|
return new Promise((resolve) => setTimeout(resolve, ms || DEFAULT_POLL_INTERVAL));
|
|
3811
3812
|
}
|
|
@@ -4256,6 +4257,8 @@ var Chains = /* @__PURE__ */ ((Chains2) => {
|
|
|
4256
4257
|
Chains2["SEPOLIA"] = "EVM-11155111";
|
|
4257
4258
|
Chains2["MAINNET"] = "EVM-1";
|
|
4258
4259
|
Chains2["BSC_MAINNET"] = "EVM-56";
|
|
4260
|
+
Chains2["ARBITRUM_MAINNET"] = "EVM-42161";
|
|
4261
|
+
Chains2["BASE_MAINNET"] = "EVM-8453";
|
|
4259
4262
|
return Chains2;
|
|
4260
4263
|
})(Chains || {});
|
|
4261
4264
|
var chainIds = {
|
|
@@ -4264,21 +4267,27 @@ var chainIds = {
|
|
|
4264
4267
|
["KUSAMA-4009" /* HYPERBRIDGE_GARGANTUA */]: 4009,
|
|
4265
4268
|
["EVM-11155111" /* SEPOLIA */]: 11155111,
|
|
4266
4269
|
["EVM-1" /* MAINNET */]: 1,
|
|
4267
|
-
["EVM-56" /* BSC_MAINNET */]: 56
|
|
4270
|
+
["EVM-56" /* BSC_MAINNET */]: 56,
|
|
4271
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: 42161,
|
|
4272
|
+
["EVM-8453" /* BASE_MAINNET */]: 8453
|
|
4268
4273
|
};
|
|
4269
4274
|
var viemChains = {
|
|
4270
4275
|
"97": bscTestnet,
|
|
4271
4276
|
"10200": gnosisChiado,
|
|
4272
4277
|
"11155111": sepolia,
|
|
4273
4278
|
"1": mainnet,
|
|
4274
|
-
"56": bsc
|
|
4279
|
+
"56": bsc,
|
|
4280
|
+
"42161": arbitrum,
|
|
4281
|
+
"8453": base
|
|
4275
4282
|
};
|
|
4276
4283
|
var WrappedNativeDecimals = {
|
|
4277
4284
|
["EVM-97" /* BSC_CHAPEL */]: 18,
|
|
4278
4285
|
["EVM-10200" /* GNOSIS_CHIADO */]: 18,
|
|
4279
4286
|
["EVM-11155111" /* SEPOLIA */]: 18,
|
|
4280
4287
|
["EVM-1" /* MAINNET */]: 18,
|
|
4281
|
-
["EVM-56" /* BSC_MAINNET */]: 18
|
|
4288
|
+
["EVM-56" /* BSC_MAINNET */]: 18,
|
|
4289
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: 18,
|
|
4290
|
+
["EVM-8453" /* BASE_MAINNET */]: 18
|
|
4282
4291
|
};
|
|
4283
4292
|
var assets = {
|
|
4284
4293
|
["EVM-97" /* BSC_CHAPEL */]: {
|
|
@@ -4310,71 +4319,105 @@ var assets = {
|
|
|
4310
4319
|
DAI: "0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3".toLowerCase(),
|
|
4311
4320
|
USDC: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d".toLowerCase(),
|
|
4312
4321
|
USDT: "0x55d398326f99059fF775485246999027B3197955".toLowerCase()
|
|
4322
|
+
},
|
|
4323
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: {
|
|
4324
|
+
WETH: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1".toLowerCase(),
|
|
4325
|
+
DAI: "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1".toLowerCase(),
|
|
4326
|
+
USDC: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831".toLowerCase(),
|
|
4327
|
+
USDT: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9".toLowerCase()
|
|
4328
|
+
},
|
|
4329
|
+
["EVM-8453" /* BASE_MAINNET */]: {
|
|
4330
|
+
WETH: "0x4200000000000000000000000000000000000006".toLowerCase(),
|
|
4331
|
+
DAI: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb".toLowerCase(),
|
|
4332
|
+
USDC: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913".toLowerCase(),
|
|
4333
|
+
USDT: "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2".toLowerCase()
|
|
4313
4334
|
}
|
|
4314
4335
|
};
|
|
4315
4336
|
var addresses = {
|
|
4316
4337
|
IntentGateway: {
|
|
4317
|
-
["EVM-97" /* BSC_CHAPEL */]: "
|
|
4318
|
-
["EVM-10200" /* GNOSIS_CHIADO */]: "
|
|
4338
|
+
["EVM-97" /* BSC_CHAPEL */]: "0x016b6ffC9f890d1e28f9Fdb9eaDA776b02F89509",
|
|
4339
|
+
["EVM-10200" /* GNOSIS_CHIADO */]: "0x016b6ffC9f890d1e28f9Fdb9eaDA776b02F89509",
|
|
4319
4340
|
["EVM-11155111" /* SEPOLIA */]: "0x0000000000000000000000000000000000000000",
|
|
4320
4341
|
["EVM-1" /* MAINNET */]: "0xd54165e45926720b062C192a5bacEC64d5bB08DA",
|
|
4321
|
-
["EVM-56" /* BSC_MAINNET */]: "0xd54165e45926720b062C192a5bacEC64d5bB08DA"
|
|
4342
|
+
["EVM-56" /* BSC_MAINNET */]: "0xd54165e45926720b062C192a5bacEC64d5bB08DA",
|
|
4343
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0xd54165e45926720b062C192a5bacEC64d5bB08DA",
|
|
4344
|
+
["EVM-8453" /* BASE_MAINNET */]: "0xd54165e45926720b062C192a5bacEC64d5bB08DA"
|
|
4322
4345
|
},
|
|
4323
4346
|
Host: {
|
|
4324
4347
|
["EVM-97" /* BSC_CHAPEL */]: "0x8Aa0Dea6D675d785A882967Bf38183f6117C09b7",
|
|
4325
4348
|
["EVM-10200" /* GNOSIS_CHIADO */]: "0x58a41b89f4871725e5d898d98ef4bf917601c5eb",
|
|
4326
4349
|
["EVM-11155111" /* SEPOLIA */]: "0x2EdB74C269948b60ec1000040E104cef0eABaae8",
|
|
4327
4350
|
["EVM-1" /* MAINNET */]: "0x792A6236AF69787C40cF76b69B4c8c7B28c4cA20",
|
|
4328
|
-
["EVM-56" /* BSC_MAINNET */]: "0x24B5d421Ec373FcA57325dd2F0C074009Af021F7"
|
|
4351
|
+
["EVM-56" /* BSC_MAINNET */]: "0x24B5d421Ec373FcA57325dd2F0C074009Af021F7",
|
|
4352
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0xE05AFD4Eb2ce6d65c40e1048381BD0Ef8b4B299e",
|
|
4353
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x6FFe92e4d7a9D589549644544780e6725E84b248"
|
|
4329
4354
|
},
|
|
4330
4355
|
UniswapRouter02: {
|
|
4331
4356
|
["EVM-97" /* BSC_CHAPEL */]: "0x9639379819420704457B07A0C33B678D9E0F8Df0",
|
|
4332
4357
|
["EVM-10200" /* GNOSIS_CHIADO */]: "0x0000000000000000000000000000000000000000",
|
|
4333
4358
|
["EVM-11155111" /* SEPOLIA */]: "0x0000000000000000000000000000000000000000",
|
|
4334
4359
|
["EVM-1" /* MAINNET */]: "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
|
|
4335
|
-
["EVM-56" /* BSC_MAINNET */]: "
|
|
4360
|
+
["EVM-56" /* BSC_MAINNET */]: "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",
|
|
4361
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4362
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4336
4363
|
},
|
|
4337
4364
|
UniswapV2Factory: {
|
|
4338
4365
|
["EVM-97" /* BSC_CHAPEL */]: "0x12e036669DA18F4A2777853d6e2136b32AceEC86",
|
|
4339
4366
|
["EVM-10200" /* GNOSIS_CHIADO */]: "0x0000000000000000000000000000000000000000",
|
|
4340
4367
|
["EVM-11155111" /* SEPOLIA */]: "0x0000000000000000000000000000000000000000",
|
|
4341
4368
|
["EVM-1" /* MAINNET */]: "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
|
|
4342
|
-
["EVM-56" /* BSC_MAINNET */]: "
|
|
4369
|
+
["EVM-56" /* BSC_MAINNET */]: "0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6",
|
|
4370
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4371
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4343
4372
|
},
|
|
4344
4373
|
BatchExecutor: {
|
|
4345
4374
|
["EVM-97" /* BSC_CHAPEL */]: "0x4CC58B5D8FBf838d062E4b21F75C327835B5F0ef",
|
|
4346
4375
|
["EVM-1" /* MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4347
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4376
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4377
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4378
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4348
4379
|
},
|
|
4349
4380
|
UniversalRouter: {
|
|
4350
4381
|
["EVM-97" /* BSC_CHAPEL */]: "0xcc6d5ece3d4a57245bf5a2f64f3ed9179b81f714",
|
|
4351
4382
|
["EVM-1" /* MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4352
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4383
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4384
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4385
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4353
4386
|
},
|
|
4354
4387
|
UniswapV3Router: {
|
|
4355
4388
|
["EVM-97" /* BSC_CHAPEL */]: "0x0000000000000000000000000000000000000000",
|
|
4356
4389
|
["EVM-1" /* MAINNET */]: "0x1F98431c8aD98523631AE4a59f267346ea31F984",
|
|
4357
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4390
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4391
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4392
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4358
4393
|
},
|
|
4359
4394
|
UniswapV3Factory: {
|
|
4360
4395
|
["EVM-97" /* BSC_CHAPEL */]: "0x0000000000000000000000000000000000000000",
|
|
4361
4396
|
["EVM-1" /* MAINNET */]: "0x1F98431c8aD98523631AE4a59f267346ea31F984",
|
|
4362
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4397
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4398
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4399
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4363
4400
|
},
|
|
4364
4401
|
UniswapV3Quoter: {
|
|
4365
4402
|
["EVM-97" /* BSC_CHAPEL */]: "0x0000000000000000000000000000000000000000",
|
|
4366
4403
|
["EVM-1" /* MAINNET */]: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
4367
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4404
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4405
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4406
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4368
4407
|
},
|
|
4369
4408
|
UniswapV4PoolManager: {
|
|
4370
4409
|
["EVM-97" /* BSC_CHAPEL */]: "0x0000000000000000000000000000000000000000",
|
|
4371
4410
|
["EVM-1" /* MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4372
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4411
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4412
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4413
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4373
4414
|
},
|
|
4374
4415
|
UniswapV4Quoter: {
|
|
4375
4416
|
["EVM-97" /* BSC_CHAPEL */]: "0x0000000000000000000000000000000000000000",
|
|
4376
4417
|
["EVM-1" /* MAINNET */]: "0x52f0e24d1c21c8a0cb1e5a5dd6198556bd9e1203",
|
|
4377
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4418
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4419
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4420
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4378
4421
|
},
|
|
4379
4422
|
Calldispatcher: {
|
|
4380
4423
|
["EVM-11155111" /* SEPOLIA */]: "0xC7f13b6D03A0A7F3239d38897503E90553ABe155"
|
|
@@ -4386,7 +4429,9 @@ var createRpcUrls = (env2) => ({
|
|
|
4386
4429
|
["KUSAMA-4009" /* HYPERBRIDGE_GARGANTUA */]: env2.HYPERBRIDGE_GARGANTUA || "",
|
|
4387
4430
|
["EVM-11155111" /* SEPOLIA */]: env2.SEPOLIA || "https://1rpc.io/sepolia",
|
|
4388
4431
|
["EVM-1" /* MAINNET */]: env2.ETH_MAINNET || "https://eth-mainnet.g.alchemy.com/v2/demo",
|
|
4389
|
-
["EVM-56" /* BSC_MAINNET */]: env2.BSC_MAINNET || "https://binance.llamarpc.com"
|
|
4432
|
+
["EVM-56" /* BSC_MAINNET */]: env2.BSC_MAINNET || "https://binance.llamarpc.com",
|
|
4433
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: env2.ARBITRUM_MAINNET || "https://arbitrum-one.public.blastapi.io",
|
|
4434
|
+
["EVM-8453" /* BASE_MAINNET */]: env2.BASE_MAINNET || "https://base-mainnet.public.blastapi.io"
|
|
4390
4435
|
});
|
|
4391
4436
|
var consensusStateIds = {
|
|
4392
4437
|
["EVM-97" /* BSC_CHAPEL */]: "BSC0",
|
|
@@ -4394,7 +4439,9 @@ var consensusStateIds = {
|
|
|
4394
4439
|
["KUSAMA-4009" /* HYPERBRIDGE_GARGANTUA */]: "PAS0",
|
|
4395
4440
|
["EVM-11155111" /* SEPOLIA */]: "ETH0",
|
|
4396
4441
|
["EVM-1" /* MAINNET */]: "ETH0",
|
|
4397
|
-
["EVM-56" /* BSC_MAINNET */]: "BSC0"
|
|
4442
|
+
["EVM-56" /* BSC_MAINNET */]: "BSC0",
|
|
4443
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "ETH0",
|
|
4444
|
+
["EVM-8453" /* BASE_MAINNET */]: "ETH0"
|
|
4398
4445
|
};
|
|
4399
4446
|
|
|
4400
4447
|
// src/configs/ChainConfigService.ts
|
|
@@ -4806,7 +4853,7 @@ var EvmChain = class {
|
|
|
4806
4853
|
*
|
|
4807
4854
|
* @param request - The post request to estimate gas for
|
|
4808
4855
|
* @param paraId - The ID of the parachain (Hyperbridge) that will process the request
|
|
4809
|
-
* @returns The estimated gas amount in gas units
|
|
4856
|
+
* @returns The estimated gas amount in gas units and the generated calldata
|
|
4810
4857
|
*/
|
|
4811
4858
|
async estimateGas(request) {
|
|
4812
4859
|
const hostParams = await this.publicClient.readContract({
|
|
@@ -4833,27 +4880,34 @@ var EvmChain = class {
|
|
|
4833
4880
|
multiproof: proof,
|
|
4834
4881
|
leafCount: treeSize
|
|
4835
4882
|
};
|
|
4883
|
+
const formattedRequest = {
|
|
4884
|
+
...request,
|
|
4885
|
+
source: toHex(request.source),
|
|
4886
|
+
dest: toHex(request.dest)
|
|
4887
|
+
};
|
|
4888
|
+
const contractArgs = [
|
|
4889
|
+
this.params.host,
|
|
4890
|
+
{
|
|
4891
|
+
proof: postParams,
|
|
4892
|
+
requests: [
|
|
4893
|
+
{
|
|
4894
|
+
request: formattedRequest,
|
|
4895
|
+
index,
|
|
4896
|
+
kIndex
|
|
4897
|
+
}
|
|
4898
|
+
]
|
|
4899
|
+
}
|
|
4900
|
+
];
|
|
4901
|
+
const postRequestCalldata = encodeFunctionData({
|
|
4902
|
+
abi: handler_default.ABI,
|
|
4903
|
+
functionName: "handlePostRequests",
|
|
4904
|
+
args: contractArgs
|
|
4905
|
+
});
|
|
4836
4906
|
const gas = await this.publicClient.estimateContractGas({
|
|
4837
4907
|
address: hostParams.handler,
|
|
4838
4908
|
abi: handler_default.ABI,
|
|
4839
4909
|
functionName: "handlePostRequests",
|
|
4840
|
-
args:
|
|
4841
|
-
this.params.host,
|
|
4842
|
-
{
|
|
4843
|
-
proof: postParams,
|
|
4844
|
-
requests: [
|
|
4845
|
-
{
|
|
4846
|
-
request: {
|
|
4847
|
-
...request,
|
|
4848
|
-
source: toHex(request.source),
|
|
4849
|
-
dest: toHex(request.dest)
|
|
4850
|
-
},
|
|
4851
|
-
index,
|
|
4852
|
-
kIndex
|
|
4853
|
-
}
|
|
4854
|
-
]
|
|
4855
|
-
}
|
|
4856
|
-
],
|
|
4910
|
+
args: contractArgs,
|
|
4857
4911
|
stateOverride: [
|
|
4858
4912
|
{
|
|
4859
4913
|
address: this.params.host,
|
|
@@ -4866,7 +4920,7 @@ var EvmChain = class {
|
|
|
4866
4920
|
}
|
|
4867
4921
|
]
|
|
4868
4922
|
});
|
|
4869
|
-
return gas;
|
|
4923
|
+
return { gas, postRequestCalldata };
|
|
4870
4924
|
}
|
|
4871
4925
|
/**
|
|
4872
4926
|
* Gets the fee token address and decimals for the chain.
|
|
@@ -8021,6 +8075,11 @@ var ABI3 = [
|
|
|
8021
8075
|
internalType: "struct Order",
|
|
8022
8076
|
name: "order",
|
|
8023
8077
|
type: "tuple"
|
|
8078
|
+
},
|
|
8079
|
+
{
|
|
8080
|
+
internalType: "bytes32",
|
|
8081
|
+
name: "graffiti",
|
|
8082
|
+
type: "bytes32"
|
|
8024
8083
|
}
|
|
8025
8084
|
],
|
|
8026
8085
|
name: "placeOrder",
|
|
@@ -11347,7 +11406,7 @@ var IntentGateway = class {
|
|
|
11347
11406
|
* protocol fees, and swap operations.
|
|
11348
11407
|
*
|
|
11349
11408
|
* @param order - The order to estimate fill costs for
|
|
11350
|
-
* @returns
|
|
11409
|
+
* @returns An object containing the estimated cost in both fee token and native token, plus the post request calldata
|
|
11351
11410
|
*/
|
|
11352
11411
|
async estimateFillOrder(order) {
|
|
11353
11412
|
const postRequest = {
|
|
@@ -11359,9 +11418,9 @@ var IntentGateway = class {
|
|
|
11359
11418
|
from: this.source.config.getIntentGatewayAddress(order.destChain),
|
|
11360
11419
|
to: this.source.config.getIntentGatewayAddress(order.sourceChain)
|
|
11361
11420
|
};
|
|
11362
|
-
const { decimals: sourceChainFeeTokenDecimals } = await this.source.getFeeTokenWithDecimals();
|
|
11421
|
+
const { decimals: sourceChainFeeTokenDecimals, address: sourceChainFeeTokenAddress } = await this.source.getFeeTokenWithDecimals();
|
|
11363
11422
|
const { address: destChainFeeTokenAddress, decimals: destChainFeeTokenDecimals } = await this.dest.getFeeTokenWithDecimals();
|
|
11364
|
-
const postGasEstimate = await this.source.estimateGas(postRequest);
|
|
11423
|
+
const { gas: postGasEstimate, postRequestCalldata } = await this.source.estimateGas(postRequest);
|
|
11365
11424
|
const postGasEstimateInSourceFeeToken = await this.convertGasToFeeToken(
|
|
11366
11425
|
postGasEstimate,
|
|
11367
11426
|
this.source.client,
|
|
@@ -11409,27 +11468,7 @@ var IntentGateway = class {
|
|
|
11409
11468
|
}
|
|
11410
11469
|
})
|
|
11411
11470
|
).then((results) => results.filter(Boolean));
|
|
11412
|
-
|
|
11413
|
-
const destFeeTokenBalanceSlot = await getStorageSlot(
|
|
11414
|
-
this.dest.client,
|
|
11415
|
-
destChainFeeTokenAddress,
|
|
11416
|
-
destFeeTokenBalanceData
|
|
11417
|
-
);
|
|
11418
|
-
const destFeeTokenAllowanceData = "0xdd62ed3e" /* ALLOWANCE */ + bytes20ToBytes32(MOCK_ADDRESS).slice(2) + bytes20ToBytes32(intentGatewayAddress).slice(2);
|
|
11419
|
-
const destFeeTokenAllowanceSlot = await getStorageSlot(
|
|
11420
|
-
this.dest.client,
|
|
11421
|
-
destChainFeeTokenAddress,
|
|
11422
|
-
destFeeTokenAllowanceData
|
|
11423
|
-
);
|
|
11424
|
-
const feeTokenStateDiffs = [
|
|
11425
|
-
{ slot: destFeeTokenBalanceSlot, value: testValue },
|
|
11426
|
-
{ slot: destFeeTokenAllowanceSlot, value: testValue }
|
|
11427
|
-
];
|
|
11428
|
-
orderOverrides.push({
|
|
11429
|
-
address: destChainFeeTokenAddress,
|
|
11430
|
-
stateDiff: feeTokenStateDiffs
|
|
11431
|
-
});
|
|
11432
|
-
const stateOverride = [
|
|
11471
|
+
let stateOverrides = [
|
|
11433
11472
|
// Mock address with ETH balance so that any chain estimation runs
|
|
11434
11473
|
// even when the address doesn't hold any native token in that chain
|
|
11435
11474
|
{
|
|
@@ -11441,15 +11480,52 @@ var IntentGateway = class {
|
|
|
11441
11480
|
stateDiff: override.stateDiff
|
|
11442
11481
|
}))
|
|
11443
11482
|
];
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11483
|
+
let destChainFillGas = 0n;
|
|
11484
|
+
try {
|
|
11485
|
+
const protocolFeeInNativeToken = await this.quoteNative(postRequest, relayerFeeInDestFeeToken);
|
|
11486
|
+
destChainFillGas = await this.dest.client.estimateContractGas({
|
|
11487
|
+
abi: IntentGateway_default.ABI,
|
|
11488
|
+
address: intentGatewayAddress,
|
|
11489
|
+
functionName: "fillOrder",
|
|
11490
|
+
args: [transformOrderForContract(order), fillOptions],
|
|
11491
|
+
account: MOCK_ADDRESS,
|
|
11492
|
+
value: totalEthValue + protocolFeeInNativeToken,
|
|
11493
|
+
stateOverride: stateOverrides
|
|
11494
|
+
});
|
|
11495
|
+
} catch {
|
|
11496
|
+
console.warn(
|
|
11497
|
+
`Could not estimate gas for fill order with native token as fees for chain ${order.destChain}, now trying with fee token as fees`
|
|
11498
|
+
);
|
|
11499
|
+
const destFeeTokenBalanceData = "0x70a08231" /* BALANCE_OF */ + bytes20ToBytes32(MOCK_ADDRESS).slice(2);
|
|
11500
|
+
const destFeeTokenBalanceSlot = await getStorageSlot(
|
|
11501
|
+
this.dest.client,
|
|
11502
|
+
destChainFeeTokenAddress,
|
|
11503
|
+
destFeeTokenBalanceData
|
|
11504
|
+
);
|
|
11505
|
+
const destFeeTokenAllowanceData = "0xdd62ed3e" /* ALLOWANCE */ + bytes20ToBytes32(MOCK_ADDRESS).slice(2) + bytes20ToBytes32(intentGatewayAddress).slice(2);
|
|
11506
|
+
const destFeeTokenAllowanceSlot = await getStorageSlot(
|
|
11507
|
+
this.dest.client,
|
|
11508
|
+
destChainFeeTokenAddress,
|
|
11509
|
+
destFeeTokenAllowanceData
|
|
11510
|
+
);
|
|
11511
|
+
const feeTokenStateDiffs = [
|
|
11512
|
+
{ slot: destFeeTokenBalanceSlot, value: testValue },
|
|
11513
|
+
{ slot: destFeeTokenAllowanceSlot, value: testValue }
|
|
11514
|
+
];
|
|
11515
|
+
stateOverrides.push({
|
|
11516
|
+
address: destChainFeeTokenAddress,
|
|
11517
|
+
stateDiff: feeTokenStateDiffs
|
|
11518
|
+
});
|
|
11519
|
+
destChainFillGas = await this.dest.client.estimateContractGas({
|
|
11520
|
+
abi: IntentGateway_default.ABI,
|
|
11521
|
+
address: intentGatewayAddress,
|
|
11522
|
+
functionName: "fillOrder",
|
|
11523
|
+
args: [transformOrderForContract(order), fillOptions],
|
|
11524
|
+
account: MOCK_ADDRESS,
|
|
11525
|
+
value: totalEthValue,
|
|
11526
|
+
stateOverride: stateOverrides
|
|
11527
|
+
});
|
|
11528
|
+
}
|
|
11453
11529
|
const fillGasInSourceFeeToken = await this.convertGasToFeeToken(
|
|
11454
11530
|
destChainFillGas,
|
|
11455
11531
|
this.dest.client,
|
|
@@ -11464,17 +11540,88 @@ var IntentGateway = class {
|
|
|
11464
11540
|
const totalEstimate = fillGasInSourceFeeToken + protocolFeeInSourceFeeToken + relayerFeeInSourceFeeToken;
|
|
11465
11541
|
const SWAP_OPERATIONS_BPS = 2500n;
|
|
11466
11542
|
const swapOperationsInFeeToken = totalEstimate * SWAP_OPERATIONS_BPS / 10000n;
|
|
11467
|
-
|
|
11543
|
+
const totalFeeTokenAmount = totalEstimate + swapOperationsInFeeToken;
|
|
11544
|
+
const totalNativeTokenAmount = await this.convertFeeTokenToNative(
|
|
11545
|
+
totalFeeTokenAmount,
|
|
11546
|
+
this.source.client,
|
|
11547
|
+
sourceChainFeeTokenDecimals
|
|
11548
|
+
);
|
|
11549
|
+
return {
|
|
11550
|
+
feeTokenAmount: totalFeeTokenAmount,
|
|
11551
|
+
nativeTokenAmount: totalNativeTokenAmount,
|
|
11552
|
+
postRequestCalldata
|
|
11553
|
+
};
|
|
11554
|
+
}
|
|
11555
|
+
/**
|
|
11556
|
+
* Converts fee token amounts back to the equivalent amount in native token.
|
|
11557
|
+
* Uses USD pricing to convert between fee token amounts and native token costs.
|
|
11558
|
+
*
|
|
11559
|
+
* @param feeTokenAmount - The amount in fee token (DAI)
|
|
11560
|
+
* @param publicClient - The client for the chain to get native token info
|
|
11561
|
+
* @param feeTokenDecimals - The decimal places of the fee token
|
|
11562
|
+
* @returns The fee token amount converted to native token amount
|
|
11563
|
+
* @private
|
|
11564
|
+
*/
|
|
11565
|
+
async convertFeeTokenToNative(feeTokenAmount, publicClient, feeTokenDecimals) {
|
|
11566
|
+
const nativeToken = publicClient.chain?.nativeCurrency;
|
|
11567
|
+
if (!nativeToken?.symbol || !nativeToken?.decimals) {
|
|
11568
|
+
throw new Error("Chain native currency information not available");
|
|
11569
|
+
}
|
|
11570
|
+
const feeTokenAmountNumber = Number(feeTokenAmount) / Math.pow(10, feeTokenDecimals);
|
|
11571
|
+
const nativeTokenPriceUsd = await fetchTokenUsdPrice(nativeToken.symbol);
|
|
11572
|
+
const totalCostInNativeToken = feeTokenAmountNumber / nativeTokenPriceUsd;
|
|
11573
|
+
return BigInt(Math.floor(totalCostInNativeToken * Math.pow(10, nativeToken.decimals)));
|
|
11468
11574
|
}
|
|
11469
11575
|
/**
|
|
11470
|
-
*
|
|
11576
|
+
* Converts gas costs to the equivalent amount in the fee token (DAI).
|
|
11577
|
+
* Uses USD pricing to convert between native token gas costs and fee token amounts.
|
|
11578
|
+
*
|
|
11579
|
+
* @param gasEstimate - The estimated gas units
|
|
11580
|
+
* @param publicClient - The client for the chain to get gas prices
|
|
11581
|
+
* @param targetDecimals - The decimal places of the target fee token
|
|
11582
|
+
* @returns The gas cost converted to fee token amount
|
|
11583
|
+
* @private
|
|
11584
|
+
*/
|
|
11585
|
+
async convertGasToFeeToken(gasEstimate, publicClient, targetDecimals) {
|
|
11586
|
+
const gasPrice = await publicClient.getGasPrice();
|
|
11587
|
+
const gasCostInWei = gasEstimate * gasPrice;
|
|
11588
|
+
const nativeToken = publicClient.chain?.nativeCurrency;
|
|
11589
|
+
if (!nativeToken?.symbol || !nativeToken?.decimals) {
|
|
11590
|
+
throw new Error("Chain native currency information not available");
|
|
11591
|
+
}
|
|
11592
|
+
const gasCostInToken = Number(gasCostInWei) / Math.pow(10, nativeToken.decimals);
|
|
11593
|
+
const tokenPriceUsd = await fetchTokenUsdPrice(nativeToken.symbol);
|
|
11594
|
+
const gasCostUsd = gasCostInToken * tokenPriceUsd;
|
|
11595
|
+
const feeTokenPriceUsd = await fetchTokenUsdPrice("DAI");
|
|
11596
|
+
const gasCostInFeeToken = gasCostUsd / feeTokenPriceUsd;
|
|
11597
|
+
return BigInt(Math.floor(gasCostInFeeToken * Math.pow(10, targetDecimals)));
|
|
11598
|
+
}
|
|
11599
|
+
async quoteNative(postRequest, fee) {
|
|
11600
|
+
const dispatchPost = {
|
|
11601
|
+
dest: toHex(postRequest.dest),
|
|
11602
|
+
to: postRequest.to,
|
|
11603
|
+
body: postRequest.body,
|
|
11604
|
+
timeout: postRequest.timeoutTimestamp,
|
|
11605
|
+
fee,
|
|
11606
|
+
payer: postRequest.from
|
|
11607
|
+
};
|
|
11608
|
+
const quoteNative = await this.dest.client.readContract({
|
|
11609
|
+
address: this.dest.config.getIntentGatewayAddress(postRequest.dest),
|
|
11610
|
+
abi: IntentGateway_default.ABI,
|
|
11611
|
+
functionName: "quoteNative",
|
|
11612
|
+
args: [dispatchPost]
|
|
11613
|
+
});
|
|
11614
|
+
return quoteNative;
|
|
11615
|
+
}
|
|
11616
|
+
/**
|
|
11617
|
+
* Finds the best Uniswap protocol (V2, V3, or V4) for swapping tokens given a desired output amount.
|
|
11471
11618
|
* Compares liquidity and pricing across different protocols and fee tiers.
|
|
11472
11619
|
*
|
|
11473
11620
|
* @param chain - The chain identifier where the swap will occur
|
|
11474
11621
|
* @param tokenIn - The address of the input token
|
|
11475
11622
|
* @param tokenOut - The address of the output token
|
|
11476
11623
|
* @param amountOut - The desired output amount
|
|
11477
|
-
* @returns Object containing the best protocol, required input amount, and fee tier (for V3)
|
|
11624
|
+
* @returns Object containing the best protocol, required input amount, and fee tier (for V3/V4)
|
|
11478
11625
|
*/
|
|
11479
11626
|
async findBestProtocolWithAmountOut(chain, tokenIn, tokenOut, amountOut) {
|
|
11480
11627
|
const destClient = this.dest.client;
|
|
@@ -11631,14 +11778,14 @@ var IntentGateway = class {
|
|
|
11631
11778
|
}
|
|
11632
11779
|
}
|
|
11633
11780
|
/**
|
|
11634
|
-
* Finds the best Uniswap protocol (V2 or
|
|
11781
|
+
* Finds the best Uniswap protocol (V2, V3, or V4) for swapping tokens given an input amount.
|
|
11635
11782
|
* Compares liquidity and pricing across different protocols and fee tiers.
|
|
11636
11783
|
*
|
|
11637
11784
|
* @param chain - The chain identifier where the swap will occur
|
|
11638
11785
|
* @param tokenIn - The address of the input token
|
|
11639
11786
|
* @param tokenOut - The address of the output token
|
|
11640
11787
|
* @param amountIn - The input amount to swap
|
|
11641
|
-
* @returns Object containing the best protocol, expected output amount, and fee tier (for V3)
|
|
11788
|
+
* @returns Object containing the best protocol, expected output amount, and fee tier (for V3/V4)
|
|
11642
11789
|
*/
|
|
11643
11790
|
async findBestProtocolWithAmountIn(chain, tokenIn, tokenOut, amountIn) {
|
|
11644
11791
|
const destClient = this.dest.client;
|
|
@@ -11794,30 +11941,6 @@ var IntentGateway = class {
|
|
|
11794
11941
|
};
|
|
11795
11942
|
}
|
|
11796
11943
|
}
|
|
11797
|
-
/**
|
|
11798
|
-
* Converts gas costs to the equivalent amount in the fee token (DAI).
|
|
11799
|
-
* Uses USD pricing to convert between native token gas costs and fee token amounts.
|
|
11800
|
-
*
|
|
11801
|
-
* @param gasEstimate - The estimated gas units
|
|
11802
|
-
* @param publicClient - The client for the chain to get gas prices
|
|
11803
|
-
* @param targetDecimals - The decimal places of the target fee token
|
|
11804
|
-
* @returns The gas cost converted to fee token amount
|
|
11805
|
-
* @private
|
|
11806
|
-
*/
|
|
11807
|
-
async convertGasToFeeToken(gasEstimate, publicClient, targetDecimals) {
|
|
11808
|
-
const gasPrice = await publicClient.getGasPrice();
|
|
11809
|
-
const gasCostInWei = gasEstimate * gasPrice;
|
|
11810
|
-
const nativeToken = publicClient.chain?.nativeCurrency;
|
|
11811
|
-
if (!nativeToken?.symbol || !nativeToken?.decimals) {
|
|
11812
|
-
throw new Error("Chain native currency information not available");
|
|
11813
|
-
}
|
|
11814
|
-
const gasCostInToken = Number(gasCostInWei) / Math.pow(10, nativeToken.decimals);
|
|
11815
|
-
const tokenPriceUsd = await fetchTokenUsdPrice(nativeToken.symbol);
|
|
11816
|
-
const gasCostUsd = gasCostInToken * tokenPriceUsd;
|
|
11817
|
-
const feeTokenPriceUsd = await fetchTokenUsdPrice("DAI");
|
|
11818
|
-
const gasCostInFeeToken = gasCostUsd / feeTokenPriceUsd;
|
|
11819
|
-
return BigInt(Math.floor(gasCostInFeeToken * Math.pow(10, targetDecimals)));
|
|
11820
|
-
}
|
|
11821
11944
|
/**
|
|
11822
11945
|
* Checks if an order has been filled by verifying the commitment status on-chain.
|
|
11823
11946
|
* Reads the storage slot corresponding to the order's commitment hash.
|
|
@@ -12182,6 +12305,6 @@ async function teleportDot(param_) {
|
|
|
12182
12305
|
return stream;
|
|
12183
12306
|
}
|
|
12184
12307
|
|
|
12185
|
-
export { ADDRESS_ZERO, ChainConfigService, Chains, DEFAULT_ADDRESS, DUMMY_PRIVATE_KEY, ERC20Method, EvmChain, HyperClientStatus, IndexerClient, IntentGateway, OrderStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, STATE_COMMITMENTS_SLOT, SubstrateChain, TeleportStatus, TimeoutStatus, WrappedNativeDecimals, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchTokenUsdPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, orderCommitment, postRequestCommitment, queryGetRequest, queryPostRequest, teleport, teleportDot, viemChains };
|
|
12308
|
+
export { ADDRESS_ZERO, ChainConfigService, Chains, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, ERC20Method, EvmChain, HyperClientStatus, IndexerClient, IntentGateway, OrderStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, STATE_COMMITMENTS_SLOT, SubstrateChain, TeleportStatus, TimeoutStatus, WrappedNativeDecimals, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchTokenUsdPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, orderCommitment, postRequestCommitment, queryGetRequest, queryPostRequest, teleport, teleportDot, viemChains };
|
|
12186
12309
|
//# sourceMappingURL=index.js.map
|
|
12187
12310
|
//# sourceMappingURL=index.js.map
|