@hyperbridge/sdk 1.3.0 → 1.3.1
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/dist/browser/index.js
CHANGED
|
@@ -3855,6 +3855,7 @@ var DEFAULT_POLL_INTERVAL = 5e3;
|
|
|
3855
3855
|
var ADDRESS_ZERO = "0x0000000000000000000000000000000000000000";
|
|
3856
3856
|
var MOCK_ADDRESS = "0x1234567890123456789012345678901234567890";
|
|
3857
3857
|
var DUMMY_PRIVATE_KEY = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
3858
|
+
var DEFAULT_GRAFFITI = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
3858
3859
|
function sleep(ms) {
|
|
3859
3860
|
return new Promise((resolve) => setTimeout(resolve, ms || DEFAULT_POLL_INTERVAL));
|
|
3860
3861
|
}
|
|
@@ -4305,6 +4306,8 @@ var Chains = /* @__PURE__ */ ((Chains2) => {
|
|
|
4305
4306
|
Chains2["SEPOLIA"] = "EVM-11155111";
|
|
4306
4307
|
Chains2["MAINNET"] = "EVM-1";
|
|
4307
4308
|
Chains2["BSC_MAINNET"] = "EVM-56";
|
|
4309
|
+
Chains2["ARBITRUM_MAINNET"] = "EVM-42161";
|
|
4310
|
+
Chains2["BASE_MAINNET"] = "EVM-8453";
|
|
4308
4311
|
return Chains2;
|
|
4309
4312
|
})(Chains || {});
|
|
4310
4313
|
var chainIds = {
|
|
@@ -4313,21 +4316,27 @@ var chainIds = {
|
|
|
4313
4316
|
["KUSAMA-4009" /* HYPERBRIDGE_GARGANTUA */]: 4009,
|
|
4314
4317
|
["EVM-11155111" /* SEPOLIA */]: 11155111,
|
|
4315
4318
|
["EVM-1" /* MAINNET */]: 1,
|
|
4316
|
-
["EVM-56" /* BSC_MAINNET */]: 56
|
|
4319
|
+
["EVM-56" /* BSC_MAINNET */]: 56,
|
|
4320
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: 42161,
|
|
4321
|
+
["EVM-8453" /* BASE_MAINNET */]: 8453
|
|
4317
4322
|
};
|
|
4318
4323
|
var viemChains = {
|
|
4319
4324
|
"97": bscTestnet,
|
|
4320
4325
|
"10200": gnosisChiado,
|
|
4321
4326
|
"11155111": sepolia,
|
|
4322
4327
|
"1": mainnet,
|
|
4323
|
-
"56": bsc
|
|
4328
|
+
"56": bsc,
|
|
4329
|
+
"42161": arbitrum,
|
|
4330
|
+
"8453": base
|
|
4324
4331
|
};
|
|
4325
4332
|
var WrappedNativeDecimals = {
|
|
4326
4333
|
["EVM-97" /* BSC_CHAPEL */]: 18,
|
|
4327
4334
|
["EVM-10200" /* GNOSIS_CHIADO */]: 18,
|
|
4328
4335
|
["EVM-11155111" /* SEPOLIA */]: 18,
|
|
4329
4336
|
["EVM-1" /* MAINNET */]: 18,
|
|
4330
|
-
["EVM-56" /* BSC_MAINNET */]: 18
|
|
4337
|
+
["EVM-56" /* BSC_MAINNET */]: 18,
|
|
4338
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: 18,
|
|
4339
|
+
["EVM-8453" /* BASE_MAINNET */]: 18
|
|
4331
4340
|
};
|
|
4332
4341
|
var assets = {
|
|
4333
4342
|
["EVM-97" /* BSC_CHAPEL */]: {
|
|
@@ -4359,71 +4368,105 @@ var assets = {
|
|
|
4359
4368
|
DAI: "0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3".toLowerCase(),
|
|
4360
4369
|
USDC: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d".toLowerCase(),
|
|
4361
4370
|
USDT: "0x55d398326f99059fF775485246999027B3197955".toLowerCase()
|
|
4371
|
+
},
|
|
4372
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: {
|
|
4373
|
+
WETH: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1".toLowerCase(),
|
|
4374
|
+
DAI: "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1".toLowerCase(),
|
|
4375
|
+
USDC: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831".toLowerCase(),
|
|
4376
|
+
USDT: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9".toLowerCase()
|
|
4377
|
+
},
|
|
4378
|
+
["EVM-8453" /* BASE_MAINNET */]: {
|
|
4379
|
+
WETH: "0x4200000000000000000000000000000000000006".toLowerCase(),
|
|
4380
|
+
DAI: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb".toLowerCase(),
|
|
4381
|
+
USDC: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913".toLowerCase(),
|
|
4382
|
+
USDT: "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2".toLowerCase()
|
|
4362
4383
|
}
|
|
4363
4384
|
};
|
|
4364
4385
|
var addresses = {
|
|
4365
4386
|
IntentGateway: {
|
|
4366
|
-
["EVM-97" /* BSC_CHAPEL */]: "
|
|
4367
|
-
["EVM-10200" /* GNOSIS_CHIADO */]: "
|
|
4387
|
+
["EVM-97" /* BSC_CHAPEL */]: "0x016b6ffC9f890d1e28f9Fdb9eaDA776b02F89509",
|
|
4388
|
+
["EVM-10200" /* GNOSIS_CHIADO */]: "0x016b6ffC9f890d1e28f9Fdb9eaDA776b02F89509",
|
|
4368
4389
|
["EVM-11155111" /* SEPOLIA */]: "0x0000000000000000000000000000000000000000",
|
|
4369
4390
|
["EVM-1" /* MAINNET */]: "0xd54165e45926720b062C192a5bacEC64d5bB08DA",
|
|
4370
|
-
["EVM-56" /* BSC_MAINNET */]: "0xd54165e45926720b062C192a5bacEC64d5bB08DA"
|
|
4391
|
+
["EVM-56" /* BSC_MAINNET */]: "0xd54165e45926720b062C192a5bacEC64d5bB08DA",
|
|
4392
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0xd54165e45926720b062C192a5bacEC64d5bB08DA",
|
|
4393
|
+
["EVM-8453" /* BASE_MAINNET */]: "0xd54165e45926720b062C192a5bacEC64d5bB08DA"
|
|
4371
4394
|
},
|
|
4372
4395
|
Host: {
|
|
4373
4396
|
["EVM-97" /* BSC_CHAPEL */]: "0x8Aa0Dea6D675d785A882967Bf38183f6117C09b7",
|
|
4374
4397
|
["EVM-10200" /* GNOSIS_CHIADO */]: "0x58a41b89f4871725e5d898d98ef4bf917601c5eb",
|
|
4375
4398
|
["EVM-11155111" /* SEPOLIA */]: "0x2EdB74C269948b60ec1000040E104cef0eABaae8",
|
|
4376
4399
|
["EVM-1" /* MAINNET */]: "0x792A6236AF69787C40cF76b69B4c8c7B28c4cA20",
|
|
4377
|
-
["EVM-56" /* BSC_MAINNET */]: "0x24B5d421Ec373FcA57325dd2F0C074009Af021F7"
|
|
4400
|
+
["EVM-56" /* BSC_MAINNET */]: "0x24B5d421Ec373FcA57325dd2F0C074009Af021F7",
|
|
4401
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0xE05AFD4Eb2ce6d65c40e1048381BD0Ef8b4B299e",
|
|
4402
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x6FFe92e4d7a9D589549644544780e6725E84b248"
|
|
4378
4403
|
},
|
|
4379
4404
|
UniswapRouter02: {
|
|
4380
4405
|
["EVM-97" /* BSC_CHAPEL */]: "0x9639379819420704457B07A0C33B678D9E0F8Df0",
|
|
4381
4406
|
["EVM-10200" /* GNOSIS_CHIADO */]: "0x0000000000000000000000000000000000000000",
|
|
4382
4407
|
["EVM-11155111" /* SEPOLIA */]: "0x0000000000000000000000000000000000000000",
|
|
4383
4408
|
["EVM-1" /* MAINNET */]: "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
|
|
4384
|
-
["EVM-56" /* BSC_MAINNET */]: "
|
|
4409
|
+
["EVM-56" /* BSC_MAINNET */]: "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",
|
|
4410
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4411
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4385
4412
|
},
|
|
4386
4413
|
UniswapV2Factory: {
|
|
4387
4414
|
["EVM-97" /* BSC_CHAPEL */]: "0x12e036669DA18F4A2777853d6e2136b32AceEC86",
|
|
4388
4415
|
["EVM-10200" /* GNOSIS_CHIADO */]: "0x0000000000000000000000000000000000000000",
|
|
4389
4416
|
["EVM-11155111" /* SEPOLIA */]: "0x0000000000000000000000000000000000000000",
|
|
4390
4417
|
["EVM-1" /* MAINNET */]: "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
|
|
4391
|
-
["EVM-56" /* BSC_MAINNET */]: "
|
|
4418
|
+
["EVM-56" /* BSC_MAINNET */]: "0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6",
|
|
4419
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4420
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4392
4421
|
},
|
|
4393
4422
|
BatchExecutor: {
|
|
4394
4423
|
["EVM-97" /* BSC_CHAPEL */]: "0x4CC58B5D8FBf838d062E4b21F75C327835B5F0ef",
|
|
4395
4424
|
["EVM-1" /* MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4396
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4425
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4426
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4427
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4397
4428
|
},
|
|
4398
4429
|
UniversalRouter: {
|
|
4399
4430
|
["EVM-97" /* BSC_CHAPEL */]: "0xcc6d5ece3d4a57245bf5a2f64f3ed9179b81f714",
|
|
4400
4431
|
["EVM-1" /* MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4401
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4432
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4433
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4434
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4402
4435
|
},
|
|
4403
4436
|
UniswapV3Router: {
|
|
4404
4437
|
["EVM-97" /* BSC_CHAPEL */]: "0x0000000000000000000000000000000000000000",
|
|
4405
4438
|
["EVM-1" /* MAINNET */]: "0x1F98431c8aD98523631AE4a59f267346ea31F984",
|
|
4406
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4439
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4440
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4441
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4407
4442
|
},
|
|
4408
4443
|
UniswapV3Factory: {
|
|
4409
4444
|
["EVM-97" /* BSC_CHAPEL */]: "0x0000000000000000000000000000000000000000",
|
|
4410
4445
|
["EVM-1" /* MAINNET */]: "0x1F98431c8aD98523631AE4a59f267346ea31F984",
|
|
4411
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4446
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4447
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4448
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4412
4449
|
},
|
|
4413
4450
|
UniswapV3Quoter: {
|
|
4414
4451
|
["EVM-97" /* BSC_CHAPEL */]: "0x0000000000000000000000000000000000000000",
|
|
4415
4452
|
["EVM-1" /* MAINNET */]: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
4416
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4453
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4454
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4455
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4417
4456
|
},
|
|
4418
4457
|
UniswapV4PoolManager: {
|
|
4419
4458
|
["EVM-97" /* BSC_CHAPEL */]: "0x0000000000000000000000000000000000000000",
|
|
4420
4459
|
["EVM-1" /* MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4421
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4460
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4461
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4462
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4422
4463
|
},
|
|
4423
4464
|
UniswapV4Quoter: {
|
|
4424
4465
|
["EVM-97" /* BSC_CHAPEL */]: "0x0000000000000000000000000000000000000000",
|
|
4425
4466
|
["EVM-1" /* MAINNET */]: "0x52f0e24d1c21c8a0cb1e5a5dd6198556bd9e1203",
|
|
4426
|
-
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4467
|
+
["EVM-56" /* BSC_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4468
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "0x0000000000000000000000000000000000000000",
|
|
4469
|
+
["EVM-8453" /* BASE_MAINNET */]: "0x0000000000000000000000000000000000000000"
|
|
4427
4470
|
},
|
|
4428
4471
|
Calldispatcher: {
|
|
4429
4472
|
["EVM-11155111" /* SEPOLIA */]: "0xC7f13b6D03A0A7F3239d38897503E90553ABe155"
|
|
@@ -4435,7 +4478,9 @@ var createRpcUrls = (env2) => ({
|
|
|
4435
4478
|
["KUSAMA-4009" /* HYPERBRIDGE_GARGANTUA */]: env2.HYPERBRIDGE_GARGANTUA || "",
|
|
4436
4479
|
["EVM-11155111" /* SEPOLIA */]: env2.SEPOLIA || "https://1rpc.io/sepolia",
|
|
4437
4480
|
["EVM-1" /* MAINNET */]: env2.ETH_MAINNET || "https://eth-mainnet.g.alchemy.com/v2/demo",
|
|
4438
|
-
["EVM-56" /* BSC_MAINNET */]: env2.BSC_MAINNET || "https://binance.llamarpc.com"
|
|
4481
|
+
["EVM-56" /* BSC_MAINNET */]: env2.BSC_MAINNET || "https://binance.llamarpc.com",
|
|
4482
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: env2.ARBITRUM_MAINNET || "https://arbitrum-one.public.blastapi.io",
|
|
4483
|
+
["EVM-8453" /* BASE_MAINNET */]: env2.BASE_MAINNET || "https://base-mainnet.public.blastapi.io"
|
|
4439
4484
|
});
|
|
4440
4485
|
var consensusStateIds = {
|
|
4441
4486
|
["EVM-97" /* BSC_CHAPEL */]: "BSC0",
|
|
@@ -4443,7 +4488,9 @@ var consensusStateIds = {
|
|
|
4443
4488
|
["KUSAMA-4009" /* HYPERBRIDGE_GARGANTUA */]: "PAS0",
|
|
4444
4489
|
["EVM-11155111" /* SEPOLIA */]: "ETH0",
|
|
4445
4490
|
["EVM-1" /* MAINNET */]: "ETH0",
|
|
4446
|
-
["EVM-56" /* BSC_MAINNET */]: "BSC0"
|
|
4491
|
+
["EVM-56" /* BSC_MAINNET */]: "BSC0",
|
|
4492
|
+
["EVM-42161" /* ARBITRUM_MAINNET */]: "ETH0",
|
|
4493
|
+
["EVM-8453" /* BASE_MAINNET */]: "ETH0"
|
|
4447
4494
|
};
|
|
4448
4495
|
|
|
4449
4496
|
// src/configs/ChainConfigService.ts
|
|
@@ -4855,7 +4902,7 @@ var EvmChain = class {
|
|
|
4855
4902
|
*
|
|
4856
4903
|
* @param request - The post request to estimate gas for
|
|
4857
4904
|
* @param paraId - The ID of the parachain (Hyperbridge) that will process the request
|
|
4858
|
-
* @returns The estimated gas amount in gas units
|
|
4905
|
+
* @returns The estimated gas amount in gas units and the generated calldata
|
|
4859
4906
|
*/
|
|
4860
4907
|
async estimateGas(request) {
|
|
4861
4908
|
const hostParams = await this.publicClient.readContract({
|
|
@@ -4882,27 +4929,34 @@ var EvmChain = class {
|
|
|
4882
4929
|
multiproof: proof,
|
|
4883
4930
|
leafCount: treeSize
|
|
4884
4931
|
};
|
|
4932
|
+
const formattedRequest = {
|
|
4933
|
+
...request,
|
|
4934
|
+
source: toHex(request.source),
|
|
4935
|
+
dest: toHex(request.dest)
|
|
4936
|
+
};
|
|
4937
|
+
const contractArgs = [
|
|
4938
|
+
this.params.host,
|
|
4939
|
+
{
|
|
4940
|
+
proof: postParams,
|
|
4941
|
+
requests: [
|
|
4942
|
+
{
|
|
4943
|
+
request: formattedRequest,
|
|
4944
|
+
index,
|
|
4945
|
+
kIndex
|
|
4946
|
+
}
|
|
4947
|
+
]
|
|
4948
|
+
}
|
|
4949
|
+
];
|
|
4950
|
+
const postRequestCalldata = encodeFunctionData({
|
|
4951
|
+
abi: handler_default.ABI,
|
|
4952
|
+
functionName: "handlePostRequests",
|
|
4953
|
+
args: contractArgs
|
|
4954
|
+
});
|
|
4885
4955
|
const gas = await this.publicClient.estimateContractGas({
|
|
4886
4956
|
address: hostParams.handler,
|
|
4887
4957
|
abi: handler_default.ABI,
|
|
4888
4958
|
functionName: "handlePostRequests",
|
|
4889
|
-
args:
|
|
4890
|
-
this.params.host,
|
|
4891
|
-
{
|
|
4892
|
-
proof: postParams,
|
|
4893
|
-
requests: [
|
|
4894
|
-
{
|
|
4895
|
-
request: {
|
|
4896
|
-
...request,
|
|
4897
|
-
source: toHex(request.source),
|
|
4898
|
-
dest: toHex(request.dest)
|
|
4899
|
-
},
|
|
4900
|
-
index,
|
|
4901
|
-
kIndex
|
|
4902
|
-
}
|
|
4903
|
-
]
|
|
4904
|
-
}
|
|
4905
|
-
],
|
|
4959
|
+
args: contractArgs,
|
|
4906
4960
|
stateOverride: [
|
|
4907
4961
|
{
|
|
4908
4962
|
address: this.params.host,
|
|
@@ -4915,7 +4969,7 @@ var EvmChain = class {
|
|
|
4915
4969
|
}
|
|
4916
4970
|
]
|
|
4917
4971
|
});
|
|
4918
|
-
return gas;
|
|
4972
|
+
return { gas, postRequestCalldata };
|
|
4919
4973
|
}
|
|
4920
4974
|
/**
|
|
4921
4975
|
* Gets the fee token address and decimals for the chain.
|
|
@@ -8070,6 +8124,11 @@ var ABI3 = [
|
|
|
8070
8124
|
internalType: "struct Order",
|
|
8071
8125
|
name: "order",
|
|
8072
8126
|
type: "tuple"
|
|
8127
|
+
},
|
|
8128
|
+
{
|
|
8129
|
+
internalType: "bytes32",
|
|
8130
|
+
name: "graffiti",
|
|
8131
|
+
type: "bytes32"
|
|
8073
8132
|
}
|
|
8074
8133
|
],
|
|
8075
8134
|
name: "placeOrder",
|
|
@@ -11396,7 +11455,7 @@ var IntentGateway = class {
|
|
|
11396
11455
|
* protocol fees, and swap operations.
|
|
11397
11456
|
*
|
|
11398
11457
|
* @param order - The order to estimate fill costs for
|
|
11399
|
-
* @returns
|
|
11458
|
+
* @returns An object containing the estimated cost in both fee token and native token, plus the post request calldata
|
|
11400
11459
|
*/
|
|
11401
11460
|
async estimateFillOrder(order) {
|
|
11402
11461
|
const postRequest = {
|
|
@@ -11408,9 +11467,9 @@ var IntentGateway = class {
|
|
|
11408
11467
|
from: this.source.config.getIntentGatewayAddress(order.destChain),
|
|
11409
11468
|
to: this.source.config.getIntentGatewayAddress(order.sourceChain)
|
|
11410
11469
|
};
|
|
11411
|
-
const { decimals: sourceChainFeeTokenDecimals } = await this.source.getFeeTokenWithDecimals();
|
|
11470
|
+
const { decimals: sourceChainFeeTokenDecimals, address: sourceChainFeeTokenAddress } = await this.source.getFeeTokenWithDecimals();
|
|
11412
11471
|
const { address: destChainFeeTokenAddress, decimals: destChainFeeTokenDecimals } = await this.dest.getFeeTokenWithDecimals();
|
|
11413
|
-
const postGasEstimate = await this.source.estimateGas(postRequest);
|
|
11472
|
+
const { gas: postGasEstimate, postRequestCalldata } = await this.source.estimateGas(postRequest);
|
|
11414
11473
|
const postGasEstimateInSourceFeeToken = await this.convertGasToFeeToken(
|
|
11415
11474
|
postGasEstimate,
|
|
11416
11475
|
this.source.client,
|
|
@@ -11458,27 +11517,7 @@ var IntentGateway = class {
|
|
|
11458
11517
|
}
|
|
11459
11518
|
})
|
|
11460
11519
|
).then((results) => results.filter(Boolean));
|
|
11461
|
-
|
|
11462
|
-
const destFeeTokenBalanceSlot = await getStorageSlot(
|
|
11463
|
-
this.dest.client,
|
|
11464
|
-
destChainFeeTokenAddress,
|
|
11465
|
-
destFeeTokenBalanceData
|
|
11466
|
-
);
|
|
11467
|
-
const destFeeTokenAllowanceData = "0xdd62ed3e" /* ALLOWANCE */ + bytes20ToBytes32(MOCK_ADDRESS).slice(2) + bytes20ToBytes32(intentGatewayAddress).slice(2);
|
|
11468
|
-
const destFeeTokenAllowanceSlot = await getStorageSlot(
|
|
11469
|
-
this.dest.client,
|
|
11470
|
-
destChainFeeTokenAddress,
|
|
11471
|
-
destFeeTokenAllowanceData
|
|
11472
|
-
);
|
|
11473
|
-
const feeTokenStateDiffs = [
|
|
11474
|
-
{ slot: destFeeTokenBalanceSlot, value: testValue },
|
|
11475
|
-
{ slot: destFeeTokenAllowanceSlot, value: testValue }
|
|
11476
|
-
];
|
|
11477
|
-
orderOverrides.push({
|
|
11478
|
-
address: destChainFeeTokenAddress,
|
|
11479
|
-
stateDiff: feeTokenStateDiffs
|
|
11480
|
-
});
|
|
11481
|
-
const stateOverride = [
|
|
11520
|
+
let stateOverrides = [
|
|
11482
11521
|
// Mock address with ETH balance so that any chain estimation runs
|
|
11483
11522
|
// even when the address doesn't hold any native token in that chain
|
|
11484
11523
|
{
|
|
@@ -11490,15 +11529,52 @@ var IntentGateway = class {
|
|
|
11490
11529
|
stateDiff: override.stateDiff
|
|
11491
11530
|
}))
|
|
11492
11531
|
];
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11532
|
+
let destChainFillGas = 0n;
|
|
11533
|
+
try {
|
|
11534
|
+
const protocolFeeInNativeToken = await this.quoteNative(postRequest, relayerFeeInDestFeeToken);
|
|
11535
|
+
destChainFillGas = await this.dest.client.estimateContractGas({
|
|
11536
|
+
abi: IntentGateway_default.ABI,
|
|
11537
|
+
address: intentGatewayAddress,
|
|
11538
|
+
functionName: "fillOrder",
|
|
11539
|
+
args: [transformOrderForContract(order), fillOptions],
|
|
11540
|
+
account: MOCK_ADDRESS,
|
|
11541
|
+
value: totalEthValue + protocolFeeInNativeToken,
|
|
11542
|
+
stateOverride: stateOverrides
|
|
11543
|
+
});
|
|
11544
|
+
} catch {
|
|
11545
|
+
console.warn(
|
|
11546
|
+
`Could not estimate gas for fill order with native token as fees for chain ${order.destChain}, now trying with fee token as fees`
|
|
11547
|
+
);
|
|
11548
|
+
const destFeeTokenBalanceData = "0x70a08231" /* BALANCE_OF */ + bytes20ToBytes32(MOCK_ADDRESS).slice(2);
|
|
11549
|
+
const destFeeTokenBalanceSlot = await getStorageSlot(
|
|
11550
|
+
this.dest.client,
|
|
11551
|
+
destChainFeeTokenAddress,
|
|
11552
|
+
destFeeTokenBalanceData
|
|
11553
|
+
);
|
|
11554
|
+
const destFeeTokenAllowanceData = "0xdd62ed3e" /* ALLOWANCE */ + bytes20ToBytes32(MOCK_ADDRESS).slice(2) + bytes20ToBytes32(intentGatewayAddress).slice(2);
|
|
11555
|
+
const destFeeTokenAllowanceSlot = await getStorageSlot(
|
|
11556
|
+
this.dest.client,
|
|
11557
|
+
destChainFeeTokenAddress,
|
|
11558
|
+
destFeeTokenAllowanceData
|
|
11559
|
+
);
|
|
11560
|
+
const feeTokenStateDiffs = [
|
|
11561
|
+
{ slot: destFeeTokenBalanceSlot, value: testValue },
|
|
11562
|
+
{ slot: destFeeTokenAllowanceSlot, value: testValue }
|
|
11563
|
+
];
|
|
11564
|
+
stateOverrides.push({
|
|
11565
|
+
address: destChainFeeTokenAddress,
|
|
11566
|
+
stateDiff: feeTokenStateDiffs
|
|
11567
|
+
});
|
|
11568
|
+
destChainFillGas = await this.dest.client.estimateContractGas({
|
|
11569
|
+
abi: IntentGateway_default.ABI,
|
|
11570
|
+
address: intentGatewayAddress,
|
|
11571
|
+
functionName: "fillOrder",
|
|
11572
|
+
args: [transformOrderForContract(order), fillOptions],
|
|
11573
|
+
account: MOCK_ADDRESS,
|
|
11574
|
+
value: totalEthValue,
|
|
11575
|
+
stateOverride: stateOverrides
|
|
11576
|
+
});
|
|
11577
|
+
}
|
|
11502
11578
|
const fillGasInSourceFeeToken = await this.convertGasToFeeToken(
|
|
11503
11579
|
destChainFillGas,
|
|
11504
11580
|
this.dest.client,
|
|
@@ -11513,17 +11589,88 @@ var IntentGateway = class {
|
|
|
11513
11589
|
const totalEstimate = fillGasInSourceFeeToken + protocolFeeInSourceFeeToken + relayerFeeInSourceFeeToken;
|
|
11514
11590
|
const SWAP_OPERATIONS_BPS = 2500n;
|
|
11515
11591
|
const swapOperationsInFeeToken = totalEstimate * SWAP_OPERATIONS_BPS / 10000n;
|
|
11516
|
-
|
|
11592
|
+
const totalFeeTokenAmount = totalEstimate + swapOperationsInFeeToken;
|
|
11593
|
+
const totalNativeTokenAmount = await this.convertFeeTokenToNative(
|
|
11594
|
+
totalFeeTokenAmount,
|
|
11595
|
+
this.source.client,
|
|
11596
|
+
sourceChainFeeTokenDecimals
|
|
11597
|
+
);
|
|
11598
|
+
return {
|
|
11599
|
+
feeTokenAmount: totalFeeTokenAmount,
|
|
11600
|
+
nativeTokenAmount: totalNativeTokenAmount,
|
|
11601
|
+
postRequestCalldata
|
|
11602
|
+
};
|
|
11603
|
+
}
|
|
11604
|
+
/**
|
|
11605
|
+
* Converts fee token amounts back to the equivalent amount in native token.
|
|
11606
|
+
* Uses USD pricing to convert between fee token amounts and native token costs.
|
|
11607
|
+
*
|
|
11608
|
+
* @param feeTokenAmount - The amount in fee token (DAI)
|
|
11609
|
+
* @param publicClient - The client for the chain to get native token info
|
|
11610
|
+
* @param feeTokenDecimals - The decimal places of the fee token
|
|
11611
|
+
* @returns The fee token amount converted to native token amount
|
|
11612
|
+
* @private
|
|
11613
|
+
*/
|
|
11614
|
+
async convertFeeTokenToNative(feeTokenAmount, publicClient, feeTokenDecimals) {
|
|
11615
|
+
const nativeToken = publicClient.chain?.nativeCurrency;
|
|
11616
|
+
if (!nativeToken?.symbol || !nativeToken?.decimals) {
|
|
11617
|
+
throw new Error("Chain native currency information not available");
|
|
11618
|
+
}
|
|
11619
|
+
const feeTokenAmountNumber = Number(feeTokenAmount) / Math.pow(10, feeTokenDecimals);
|
|
11620
|
+
const nativeTokenPriceUsd = await fetchTokenUsdPrice(nativeToken.symbol);
|
|
11621
|
+
const totalCostInNativeToken = feeTokenAmountNumber / nativeTokenPriceUsd;
|
|
11622
|
+
return BigInt(Math.floor(totalCostInNativeToken * Math.pow(10, nativeToken.decimals)));
|
|
11517
11623
|
}
|
|
11518
11624
|
/**
|
|
11519
|
-
*
|
|
11625
|
+
* Converts gas costs to the equivalent amount in the fee token (DAI).
|
|
11626
|
+
* Uses USD pricing to convert between native token gas costs and fee token amounts.
|
|
11627
|
+
*
|
|
11628
|
+
* @param gasEstimate - The estimated gas units
|
|
11629
|
+
* @param publicClient - The client for the chain to get gas prices
|
|
11630
|
+
* @param targetDecimals - The decimal places of the target fee token
|
|
11631
|
+
* @returns The gas cost converted to fee token amount
|
|
11632
|
+
* @private
|
|
11633
|
+
*/
|
|
11634
|
+
async convertGasToFeeToken(gasEstimate, publicClient, targetDecimals) {
|
|
11635
|
+
const gasPrice = await publicClient.getGasPrice();
|
|
11636
|
+
const gasCostInWei = gasEstimate * gasPrice;
|
|
11637
|
+
const nativeToken = publicClient.chain?.nativeCurrency;
|
|
11638
|
+
if (!nativeToken?.symbol || !nativeToken?.decimals) {
|
|
11639
|
+
throw new Error("Chain native currency information not available");
|
|
11640
|
+
}
|
|
11641
|
+
const gasCostInToken = Number(gasCostInWei) / Math.pow(10, nativeToken.decimals);
|
|
11642
|
+
const tokenPriceUsd = await fetchTokenUsdPrice(nativeToken.symbol);
|
|
11643
|
+
const gasCostUsd = gasCostInToken * tokenPriceUsd;
|
|
11644
|
+
const feeTokenPriceUsd = await fetchTokenUsdPrice("DAI");
|
|
11645
|
+
const gasCostInFeeToken = gasCostUsd / feeTokenPriceUsd;
|
|
11646
|
+
return BigInt(Math.floor(gasCostInFeeToken * Math.pow(10, targetDecimals)));
|
|
11647
|
+
}
|
|
11648
|
+
async quoteNative(postRequest, fee) {
|
|
11649
|
+
const dispatchPost = {
|
|
11650
|
+
dest: toHex(postRequest.dest),
|
|
11651
|
+
to: postRequest.to,
|
|
11652
|
+
body: postRequest.body,
|
|
11653
|
+
timeout: postRequest.timeoutTimestamp,
|
|
11654
|
+
fee,
|
|
11655
|
+
payer: postRequest.from
|
|
11656
|
+
};
|
|
11657
|
+
const quoteNative = await this.dest.client.readContract({
|
|
11658
|
+
address: this.dest.config.getIntentGatewayAddress(postRequest.dest),
|
|
11659
|
+
abi: IntentGateway_default.ABI,
|
|
11660
|
+
functionName: "quoteNative",
|
|
11661
|
+
args: [dispatchPost]
|
|
11662
|
+
});
|
|
11663
|
+
return quoteNative;
|
|
11664
|
+
}
|
|
11665
|
+
/**
|
|
11666
|
+
* Finds the best Uniswap protocol (V2, V3, or V4) for swapping tokens given a desired output amount.
|
|
11520
11667
|
* Compares liquidity and pricing across different protocols and fee tiers.
|
|
11521
11668
|
*
|
|
11522
11669
|
* @param chain - The chain identifier where the swap will occur
|
|
11523
11670
|
* @param tokenIn - The address of the input token
|
|
11524
11671
|
* @param tokenOut - The address of the output token
|
|
11525
11672
|
* @param amountOut - The desired output amount
|
|
11526
|
-
* @returns Object containing the best protocol, required input amount, and fee tier (for V3)
|
|
11673
|
+
* @returns Object containing the best protocol, required input amount, and fee tier (for V3/V4)
|
|
11527
11674
|
*/
|
|
11528
11675
|
async findBestProtocolWithAmountOut(chain, tokenIn, tokenOut, amountOut) {
|
|
11529
11676
|
const destClient = this.dest.client;
|
|
@@ -11680,14 +11827,14 @@ var IntentGateway = class {
|
|
|
11680
11827
|
}
|
|
11681
11828
|
}
|
|
11682
11829
|
/**
|
|
11683
|
-
* Finds the best Uniswap protocol (V2 or
|
|
11830
|
+
* Finds the best Uniswap protocol (V2, V3, or V4) for swapping tokens given an input amount.
|
|
11684
11831
|
* Compares liquidity and pricing across different protocols and fee tiers.
|
|
11685
11832
|
*
|
|
11686
11833
|
* @param chain - The chain identifier where the swap will occur
|
|
11687
11834
|
* @param tokenIn - The address of the input token
|
|
11688
11835
|
* @param tokenOut - The address of the output token
|
|
11689
11836
|
* @param amountIn - The input amount to swap
|
|
11690
|
-
* @returns Object containing the best protocol, expected output amount, and fee tier (for V3)
|
|
11837
|
+
* @returns Object containing the best protocol, expected output amount, and fee tier (for V3/V4)
|
|
11691
11838
|
*/
|
|
11692
11839
|
async findBestProtocolWithAmountIn(chain, tokenIn, tokenOut, amountIn) {
|
|
11693
11840
|
const destClient = this.dest.client;
|
|
@@ -11843,30 +11990,6 @@ var IntentGateway = class {
|
|
|
11843
11990
|
};
|
|
11844
11991
|
}
|
|
11845
11992
|
}
|
|
11846
|
-
/**
|
|
11847
|
-
* Converts gas costs to the equivalent amount in the fee token (DAI).
|
|
11848
|
-
* Uses USD pricing to convert between native token gas costs and fee token amounts.
|
|
11849
|
-
*
|
|
11850
|
-
* @param gasEstimate - The estimated gas units
|
|
11851
|
-
* @param publicClient - The client for the chain to get gas prices
|
|
11852
|
-
* @param targetDecimals - The decimal places of the target fee token
|
|
11853
|
-
* @returns The gas cost converted to fee token amount
|
|
11854
|
-
* @private
|
|
11855
|
-
*/
|
|
11856
|
-
async convertGasToFeeToken(gasEstimate, publicClient, targetDecimals) {
|
|
11857
|
-
const gasPrice = await publicClient.getGasPrice();
|
|
11858
|
-
const gasCostInWei = gasEstimate * gasPrice;
|
|
11859
|
-
const nativeToken = publicClient.chain?.nativeCurrency;
|
|
11860
|
-
if (!nativeToken?.symbol || !nativeToken?.decimals) {
|
|
11861
|
-
throw new Error("Chain native currency information not available");
|
|
11862
|
-
}
|
|
11863
|
-
const gasCostInToken = Number(gasCostInWei) / Math.pow(10, nativeToken.decimals);
|
|
11864
|
-
const tokenPriceUsd = await fetchTokenUsdPrice(nativeToken.symbol);
|
|
11865
|
-
const gasCostUsd = gasCostInToken * tokenPriceUsd;
|
|
11866
|
-
const feeTokenPriceUsd = await fetchTokenUsdPrice("DAI");
|
|
11867
|
-
const gasCostInFeeToken = gasCostUsd / feeTokenPriceUsd;
|
|
11868
|
-
return BigInt(Math.floor(gasCostInFeeToken * Math.pow(10, targetDecimals)));
|
|
11869
|
-
}
|
|
11870
11993
|
/**
|
|
11871
11994
|
* Checks if an order has been filled by verifying the commitment status on-chain.
|
|
11872
11995
|
* Reads the storage slot corresponding to the order's commitment hash.
|
|
@@ -12231,6 +12354,6 @@ async function teleportDot(param_) {
|
|
|
12231
12354
|
return stream;
|
|
12232
12355
|
}
|
|
12233
12356
|
|
|
12234
|
-
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 };
|
|
12357
|
+
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 };
|
|
12235
12358
|
//# sourceMappingURL=index.js.map
|
|
12236
12359
|
//# sourceMappingURL=index.js.map
|