@hyperbridge/sdk 1.8.6 → 1.8.8
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 +22 -2
- package/dist/browser/index.js +93 -37
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.d.ts +22 -2
- package/dist/node/index.js +93 -37
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -617,11 +617,15 @@ declare class ChainConfigService {
|
|
|
617
617
|
getHyperbridgeChainId(): number;
|
|
618
618
|
getRpcUrl(chain: string): string;
|
|
619
619
|
getUniswapRouterV2Address(chain: string): HexString;
|
|
620
|
+
getAerodromeRouterAddress(chain: string): HexString;
|
|
620
621
|
getUniswapV2FactoryAddress(chain: string): HexString;
|
|
621
622
|
getUniswapV3FactoryAddress(chain: string): HexString;
|
|
622
623
|
getUniversalRouterAddress(chain: string): HexString;
|
|
623
624
|
getUniswapV3QuoterAddress(chain: string): HexString;
|
|
624
625
|
getUniswapV4QuoterAddress(chain: string): HexString;
|
|
626
|
+
getUniswapV4PositionManagerAddress(chain: string): HexString;
|
|
627
|
+
getUniswapV4PoolManagerAddress(chain: string): HexString;
|
|
628
|
+
getUniswapV4StateViewAddress(chain: string): HexString;
|
|
625
629
|
getPermit2Address(chain: string): HexString;
|
|
626
630
|
getSolverAccountAddress(chain: string): HexString | undefined;
|
|
627
631
|
getCoingeckoId(chain: string): string | undefined;
|
|
@@ -2803,6 +2807,12 @@ interface SubmitBidOptions {
|
|
|
2803
2807
|
}
|
|
2804
2808
|
interface EstimateFillOrderParams {
|
|
2805
2809
|
order: Order;
|
|
2810
|
+
/**
|
|
2811
|
+
* Optional ERC-7821 calls to prepend before the fillOrder call in the
|
|
2812
|
+
* simulated UserOp. Used for funding calls (e.g. LP withdrawal) so the
|
|
2813
|
+
* bundler estimates gas for the complete atomic batch.
|
|
2814
|
+
*/
|
|
2815
|
+
prependCalls?: ERC7821Call[];
|
|
2806
2816
|
/**
|
|
2807
2817
|
* Optional percentage to bump maxPriorityFeePerGas.
|
|
2808
2818
|
* This is added on top of the base gasPrice.
|
|
@@ -2893,7 +2903,7 @@ declare const IntentOrderStatus: Readonly<{
|
|
|
2893
2903
|
USEROP_SUBMITTED: "USEROP_SUBMITTED";
|
|
2894
2904
|
FILLED: "FILLED";
|
|
2895
2905
|
PARTIAL_FILL: "PARTIAL_FILL";
|
|
2896
|
-
|
|
2906
|
+
EXPIRED: "EXPIRED";
|
|
2897
2907
|
FAILED: "FAILED";
|
|
2898
2908
|
}>;
|
|
2899
2909
|
type IntentOrderStatus = typeof IntentOrderStatus;
|
|
@@ -2949,7 +2959,7 @@ type IntentOrderStatusUpdate = {
|
|
|
2949
2959
|
totalFilledAssets: TokenInfo[];
|
|
2950
2960
|
remainingAssets: TokenInfo[];
|
|
2951
2961
|
} | {
|
|
2952
|
-
status: "
|
|
2962
|
+
status: "EXPIRED";
|
|
2953
2963
|
commitment: HexString;
|
|
2954
2964
|
totalFilledAssets?: TokenInfo[];
|
|
2955
2965
|
remainingAssets?: TokenInfo[];
|
|
@@ -3762,6 +3772,8 @@ declare const BundlerMethod: {
|
|
|
3762
3772
|
readonly ETH_ESTIMATE_USER_OPERATION_GAS: "eth_estimateUserOperationGas";
|
|
3763
3773
|
/** Pimlico-specific method to fetch recommended EIP-1559 gas prices for UserOperations. */
|
|
3764
3774
|
readonly PIMLICO_GET_USER_OPERATION_GAS_PRICE: "pimlico_getUserOperationGasPrice";
|
|
3775
|
+
/** Alchemy (Rundler) method to fetch recommended priority fee for UserOperations. */
|
|
3776
|
+
readonly RUNDLER_MAX_PRIORITY_FEE_PER_GAS: "rundler_maxPriorityFeePerGas";
|
|
3765
3777
|
};
|
|
3766
3778
|
/** Union of all valid bundler RPC method name strings. */
|
|
3767
3779
|
type BundlerMethod = (typeof BundlerMethod)[keyof typeof BundlerMethod];
|
|
@@ -8096,6 +8108,14 @@ interface ChainConfigData {
|
|
|
8096
8108
|
Usdt0Oft?: `0x${string}`;
|
|
8097
8109
|
/** SolverAccount contract address used for EIP-7702 delegation */
|
|
8098
8110
|
SolverAccount?: `0x${string}`;
|
|
8111
|
+
/** Aerodrome (Solidly-style) router for LP removal / swaps on chains where Aerodrome is deployed */
|
|
8112
|
+
AerodromeRouter?: `0x${string}`;
|
|
8113
|
+
/** Uniswap V4 PositionManager (canonical CREATE2 address) for LP position management */
|
|
8114
|
+
UniswapV4PositionManager?: `0x${string}`;
|
|
8115
|
+
/** Uniswap V4 PoolManager (canonical CREATE2 address) for pool state reads via extsload */
|
|
8116
|
+
UniswapV4PoolManager?: `0x${string}`;
|
|
8117
|
+
/** Uniswap V4 StateView (canonical CREATE2 address) for pool state reads via extsload */
|
|
8118
|
+
UniswapV4StateView?: `0x${string}`;
|
|
8099
8119
|
};
|
|
8100
8120
|
rpcEnvKey?: string;
|
|
8101
8121
|
defaultRpcUrl?: string;
|
package/dist/browser/index.js
CHANGED
|
@@ -609,7 +609,7 @@ var IntentOrderStatus = Object.freeze({
|
|
|
609
609
|
USEROP_SUBMITTED: "USEROP_SUBMITTED",
|
|
610
610
|
FILLED: "FILLED",
|
|
611
611
|
PARTIAL_FILL: "PARTIAL_FILL",
|
|
612
|
-
|
|
612
|
+
EXPIRED: "EXPIRED",
|
|
613
613
|
FAILED: "FAILED"
|
|
614
614
|
});
|
|
615
615
|
|
|
@@ -3837,6 +3837,9 @@ var chainConfigs = {
|
|
|
3837
3837
|
UniversalRouter: "0x66a9893cc07d91d95644aedd05d03f95e1dba8af",
|
|
3838
3838
|
UniswapV3Quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
3839
3839
|
UniswapV4Quoter: "0x52f0e24d1c21c8a0cb1e5a5dd6198556bd9e1203",
|
|
3840
|
+
UniswapV4PositionManager: "0xbd216513d74c8cf14cf4747e6aaa6420ff64ee9e",
|
|
3841
|
+
UniswapV4PoolManager: "0x000000000004444c5dc75cB358380D2e3dE08A90",
|
|
3842
|
+
UniswapV4StateView: "0x7ffe42c4a5deea5b0fec41c94c136cf115597227",
|
|
3840
3843
|
Calldispatcher: "0xc71251c8b3e7b02697a84363eef6dce8dfbdf333",
|
|
3841
3844
|
Permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
3842
3845
|
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
|
|
@@ -3889,6 +3892,9 @@ var chainConfigs = {
|
|
|
3889
3892
|
UniversalRouter: "0xd9C500DfF816a1Da21A48A732d3498Bf09dc9AEB",
|
|
3890
3893
|
UniswapV3Quoter: "0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997",
|
|
3891
3894
|
UniswapV4Quoter: "0xd0737C9762912dD34c3271197E362Aa736Df0926",
|
|
3895
|
+
UniswapV4PositionManager: "0x7a4a5c919ae2541aed11041a1aeee68f1287f95b",
|
|
3896
|
+
UniswapV4PoolManager: "0x28e2ea090877bf75740558f6bfb36a5ffee9e9df",
|
|
3897
|
+
UniswapV4StateView: "0xd13dd3d6e93f276fafc9db9e6bb47c1180aee0c4",
|
|
3892
3898
|
Calldispatcher: "0xc71251c8b3e7b02697a84363eef6dce8dfbdf333",
|
|
3893
3899
|
Permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
3894
3900
|
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108"
|
|
@@ -3943,6 +3949,9 @@ var chainConfigs = {
|
|
|
3943
3949
|
UniversalRouter: "0xa51afafe0263b40edaef0df8781ea9aa03e381a3",
|
|
3944
3950
|
UniswapV3Quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
3945
3951
|
UniswapV4Quoter: "0x3972c00f7ed4885e145823eb7c655375d275a1c5",
|
|
3952
|
+
UniswapV4PositionManager: "0xd88f38f930b7952f2db2432cb002e7abbf3dd869",
|
|
3953
|
+
UniswapV4PoolManager: "0x360e68faccca8ca495c1b759fd9eee466db9fb32",
|
|
3954
|
+
UniswapV4StateView: "0x76fd297e2d437cd7f76d50f01afe6160f86e9990",
|
|
3946
3955
|
Calldispatcher: "0xc71251c8b3e7b02697a84363eef6dce8dfbdf333",
|
|
3947
3956
|
Permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
3948
3957
|
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
|
|
@@ -3999,7 +4008,11 @@ var chainConfigs = {
|
|
|
3999
4008
|
UniswapV4Quoter: "0x0d5e0f971ed27fbff6c2837bf31316121532048d",
|
|
4000
4009
|
Calldispatcher: "0xc71251c8b3e7b02697a84363eef6dce8dfbdf333",
|
|
4001
4010
|
Permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
4002
|
-
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108"
|
|
4011
|
+
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
|
|
4012
|
+
AerodromeRouter: "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43",
|
|
4013
|
+
UniswapV4PositionManager: "0x7c5f5a4bbd8fd63184577525326123b519429bdc",
|
|
4014
|
+
UniswapV4PoolManager: "0x498581ff718922c3f8e6a244956af099b2652b2b",
|
|
4015
|
+
UniswapV4StateView: "0xa3c0c9b65bad0b08107aa264b0f3db444b867a71"
|
|
4003
4016
|
// Usdt0Oft: Not available on Base
|
|
4004
4017
|
},
|
|
4005
4018
|
rpcEnvKey: "BASE_MAINNET",
|
|
@@ -4051,6 +4064,9 @@ var chainConfigs = {
|
|
|
4051
4064
|
UniversalRouter: "0x1095692a6237d83c6a72f3f5efedb9a670c49223",
|
|
4052
4065
|
UniswapV3Quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
4053
4066
|
UniswapV4Quoter: "0xb3d5c3dfc3a7aebff71895a7191796bffc2c81b9",
|
|
4067
|
+
UniswapV4PositionManager: "0x1ec2ebf4f37e7363fdfe3551602425af0b3ceef9",
|
|
4068
|
+
UniswapV4PoolManager: "0x67366782805870060151383f4bbff9dab53e5cd6",
|
|
4069
|
+
UniswapV4StateView: "0x5ea1bd7974c8a611cbab0bdcafcb1d9cc9b3ba5a",
|
|
4054
4070
|
Calldispatcher: "0xc71251c8b3e7b02697a84363eef6dce8dfbdf333",
|
|
4055
4071
|
Permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
4056
4072
|
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
|
|
@@ -4095,6 +4111,9 @@ var chainConfigs = {
|
|
|
4095
4111
|
UniversalRouter: "0xef740bf23acae26f6492b10de645d6b98dc8eaf3",
|
|
4096
4112
|
UniswapV3Quoter: "0x385a5cf5f83e99f7bb2852b6a19c3538b9fa7658",
|
|
4097
4113
|
UniswapV4Quoter: "0x52f0e24d1c21c8a0cb1e5a5dd6198556bd9e1203",
|
|
4114
|
+
UniswapV4PositionManager: "0x4529a01c7a0410167c5740c487a8de60232617bf",
|
|
4115
|
+
UniswapV4PoolManager: "0x1f98400000000000000000000000000000000004",
|
|
4116
|
+
UniswapV4StateView: "0x86e8631a016f9068c3f085faf484ee3f5fdee8f2",
|
|
4098
4117
|
Calldispatcher: "0xc71251c8b3e7b02697a84363eef6dce8dfbdf333",
|
|
4099
4118
|
Permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
4100
4119
|
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
|
|
@@ -4200,7 +4219,9 @@ var chainConfigs = {
|
|
|
4200
4219
|
UniswapV3Factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984",
|
|
4201
4220
|
Calldispatcher: "0xC71251c8b3e7B02697A84363Eef6DcE8DfBdF333",
|
|
4202
4221
|
Permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
4203
|
-
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108"
|
|
4222
|
+
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
|
|
4223
|
+
UniswapV4PositionManager: "0x3c3ea4b57a46241e54610e5f022e5c45859a1017",
|
|
4224
|
+
UniswapV4PoolManager: "0x9a13f98cb987694c9f086b1f5eb990eea8264ec3"
|
|
4204
4225
|
},
|
|
4205
4226
|
defaultRpcUrl: "https://mainnet.optimism.io",
|
|
4206
4227
|
consensusStateId: "ETH0",
|
|
@@ -4256,7 +4277,9 @@ var chainConfigs = {
|
|
|
4256
4277
|
addresses: {
|
|
4257
4278
|
TokenGateway: "0xCe304770236f39F9911BfCC51afBdfF3b8635718",
|
|
4258
4279
|
Host: "0x7F0165140D0f3251c8f6465e94E9d12C7FD40711",
|
|
4259
|
-
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108"
|
|
4280
|
+
EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
|
|
4281
|
+
UniswapV4PositionManager: "0x1b35d13a2e2528f192637f14b05f0dc0e7deb566",
|
|
4282
|
+
UniswapV4PoolManager: "0x360e68faccca8ca495c1b759fd9eee466db9fb32"
|
|
4260
4283
|
},
|
|
4261
4284
|
defaultRpcUrl: "https://rpc.soneium.org",
|
|
4262
4285
|
consensusStateId: "ETH0",
|
|
@@ -4450,6 +4473,9 @@ var ChainConfigService = class {
|
|
|
4450
4473
|
getUniswapRouterV2Address(chain) {
|
|
4451
4474
|
return this.getConfig(chain)?.addresses.UniswapRouter02 ?? "0x";
|
|
4452
4475
|
}
|
|
4476
|
+
getAerodromeRouterAddress(chain) {
|
|
4477
|
+
return this.getConfig(chain)?.addresses.AerodromeRouter ?? "0x";
|
|
4478
|
+
}
|
|
4453
4479
|
getUniswapV2FactoryAddress(chain) {
|
|
4454
4480
|
return this.getConfig(chain)?.addresses.UniswapV2Factory ?? "0x";
|
|
4455
4481
|
}
|
|
@@ -4465,6 +4491,15 @@ var ChainConfigService = class {
|
|
|
4465
4491
|
getUniswapV4QuoterAddress(chain) {
|
|
4466
4492
|
return this.getConfig(chain)?.addresses.UniswapV4Quoter ?? "0x";
|
|
4467
4493
|
}
|
|
4494
|
+
getUniswapV4PositionManagerAddress(chain) {
|
|
4495
|
+
return this.getConfig(chain)?.addresses.UniswapV4PositionManager ?? "0x";
|
|
4496
|
+
}
|
|
4497
|
+
getUniswapV4PoolManagerAddress(chain) {
|
|
4498
|
+
return this.getConfig(chain)?.addresses.UniswapV4PoolManager ?? "0x";
|
|
4499
|
+
}
|
|
4500
|
+
getUniswapV4StateViewAddress(chain) {
|
|
4501
|
+
return this.getConfig(chain)?.addresses.UniswapV4StateView ?? "0x";
|
|
4502
|
+
}
|
|
4468
4503
|
getPermit2Address(chain) {
|
|
4469
4504
|
return this.getConfig(chain)?.addresses.Permit2 ?? "0x";
|
|
4470
4505
|
}
|
|
@@ -12631,7 +12666,9 @@ var BundlerMethod = {
|
|
|
12631
12666
|
/** Estimates gas limits for a UserOperation before submission. */
|
|
12632
12667
|
ETH_ESTIMATE_USER_OPERATION_GAS: "eth_estimateUserOperationGas",
|
|
12633
12668
|
/** Pimlico-specific method to fetch recommended EIP-1559 gas prices for UserOperations. */
|
|
12634
|
-
PIMLICO_GET_USER_OPERATION_GAS_PRICE: "pimlico_getUserOperationGasPrice"
|
|
12669
|
+
PIMLICO_GET_USER_OPERATION_GAS_PRICE: "pimlico_getUserOperationGasPrice",
|
|
12670
|
+
/** Alchemy (Rundler) method to fetch recommended priority fee for UserOperations. */
|
|
12671
|
+
RUNDLER_MAX_PRIORITY_FEE_PER_GAS: "rundler_maxPriorityFeePerGas"
|
|
12635
12672
|
};
|
|
12636
12673
|
|
|
12637
12674
|
// src/protocols/intents/CryptoUtils.ts
|
|
@@ -15292,10 +15329,11 @@ var OrderExecutor = class {
|
|
|
15292
15329
|
*
|
|
15293
15330
|
* **Status progression (same-chain orders):**
|
|
15294
15331
|
* `AWAITING_BIDS` → `BIDS_RECEIVED` → `BID_SELECTED` → `USEROP_SUBMITTED`
|
|
15295
|
-
* → (`FILLED` | `PARTIAL_FILL`)* → (`FILLED` | `
|
|
15332
|
+
* → (`FILLED` | `PARTIAL_FILL`)* → (`FILLED` | `EXPIRED`)
|
|
15296
15333
|
*
|
|
15297
|
-
* **Error statuses:** `FAILED` (
|
|
15298
|
-
* (deadline reached or no new bids
|
|
15334
|
+
* **Error statuses:** `FAILED` (retryable error during bid selection/submission,
|
|
15335
|
+
* triggers automatic retry) or `EXPIRED` (deadline reached or no new bids —
|
|
15336
|
+
* terminal, no further retries).
|
|
15299
15337
|
*
|
|
15300
15338
|
* @param options - Execution parameters including the placed order, its
|
|
15301
15339
|
* session private key, bid collection settings, and poll interval.
|
|
@@ -15348,19 +15386,14 @@ var OrderExecutor = class {
|
|
|
15348
15386
|
while (true) {
|
|
15349
15387
|
const currentBlock = await this.ctx.dest.client.getBlockNumber();
|
|
15350
15388
|
if (currentBlock >= order.deadline) {
|
|
15351
|
-
const isPartiallyFilled = totalFilledAssets.some((a) => a.amount > 0n);
|
|
15352
15389
|
const deadlineError = `Order deadline reached (block ${currentBlock} >= ${order.deadline})`;
|
|
15353
|
-
|
|
15354
|
-
|
|
15355
|
-
|
|
15356
|
-
|
|
15357
|
-
|
|
15358
|
-
|
|
15359
|
-
|
|
15360
|
-
};
|
|
15361
|
-
} else {
|
|
15362
|
-
yield { status: "FAILED", commitment, error: deadlineError };
|
|
15363
|
-
}
|
|
15390
|
+
yield {
|
|
15391
|
+
status: "EXPIRED",
|
|
15392
|
+
commitment,
|
|
15393
|
+
totalFilledAssets,
|
|
15394
|
+
remainingAssets,
|
|
15395
|
+
error: deadlineError
|
|
15396
|
+
};
|
|
15364
15397
|
return;
|
|
15365
15398
|
}
|
|
15366
15399
|
yield { status: "AWAITING_BIDS", commitment, totalFilledAssets, remainingAssets };
|
|
@@ -15390,20 +15423,16 @@ var OrderExecutor = class {
|
|
|
15390
15423
|
return !usedUserOps.has(key);
|
|
15391
15424
|
});
|
|
15392
15425
|
if (freshBids.length === 0) {
|
|
15393
|
-
const isPartiallyFilled = totalFilledAssets.some((a) => a.amount > 0n);
|
|
15394
15426
|
const solverClause = solver && !solverLockExpired ? ` for requested solver ${solver.address}` : "";
|
|
15427
|
+
const isPartiallyFilled = totalFilledAssets.some((a) => a.amount > 0n);
|
|
15395
15428
|
const noBidsError = isPartiallyFilled ? `No new bids${solverClause} after partial fill` : `No new bids${solverClause} available within ${bidTimeoutMs}ms timeout`;
|
|
15396
|
-
|
|
15397
|
-
|
|
15398
|
-
|
|
15399
|
-
|
|
15400
|
-
|
|
15401
|
-
|
|
15402
|
-
|
|
15403
|
-
};
|
|
15404
|
-
} else {
|
|
15405
|
-
yield { status: "FAILED", commitment, error: noBidsError };
|
|
15406
|
-
}
|
|
15429
|
+
yield {
|
|
15430
|
+
status: "EXPIRED",
|
|
15431
|
+
commitment,
|
|
15432
|
+
totalFilledAssets,
|
|
15433
|
+
remainingAssets,
|
|
15434
|
+
error: noBidsError
|
|
15435
|
+
};
|
|
15407
15436
|
return;
|
|
15408
15437
|
}
|
|
15409
15438
|
yield { status: "BIDS_RECEIVED", commitment, bidCount: freshBids.length, bids: freshBids };
|
|
@@ -15418,7 +15447,8 @@ var OrderExecutor = class {
|
|
|
15418
15447
|
remainingAssets,
|
|
15419
15448
|
error: `Failed to select bid and submit: ${err instanceof Error ? err.message : String(err)}`
|
|
15420
15449
|
};
|
|
15421
|
-
|
|
15450
|
+
await sleep(pollIntervalMs);
|
|
15451
|
+
continue;
|
|
15422
15452
|
}
|
|
15423
15453
|
const usedKey = userOpHashKey(result.userOp);
|
|
15424
15454
|
usedUserOps.add(usedKey);
|
|
@@ -15463,7 +15493,10 @@ var OrderExecutor = class {
|
|
|
15463
15493
|
remainingAssets = targetAssets.map((target) => {
|
|
15464
15494
|
const filled = totalFilledAssets.find((a) => a.token === target.token);
|
|
15465
15495
|
const filledAmt = filled?.amount ?? 0n;
|
|
15466
|
-
return {
|
|
15496
|
+
return {
|
|
15497
|
+
token: target.token,
|
|
15498
|
+
amount: filledAmt >= target.amount ? 0n : target.amount - filledAmt
|
|
15499
|
+
};
|
|
15467
15500
|
});
|
|
15468
15501
|
const fullyFilled = remainingAssets.every((a) => a.amount === 0n);
|
|
15469
15502
|
if (fullyFilled) {
|
|
@@ -18089,11 +18122,13 @@ var GasEstimator = class {
|
|
|
18089
18122
|
const entryPointAddress = this.ctx.dest.configService.getEntryPointV08Address(destStateMachineId);
|
|
18090
18123
|
const chainId = BigInt(Number.parseInt(destStateMachineId.split("-")[1]));
|
|
18091
18124
|
const totalEthValue = order.output.assets.filter((output) => bytes32ToBytes20(output.token) === ADDRESS_ZERO2).reduce((sum, output) => sum + output.amount, 0n);
|
|
18092
|
-
const [sourceFeeToken, destFeeToken, gasPrice] = await Promise.all([
|
|
18125
|
+
const [sourceFeeToken, destFeeToken, gasPrice, latestBlock] = await Promise.all([
|
|
18093
18126
|
getFeeToken(this.ctx, this.ctx.source.config.stateMachineId, this.ctx.source),
|
|
18094
18127
|
getFeeToken(this.ctx, this.ctx.dest.config.stateMachineId, this.ctx.dest),
|
|
18095
|
-
this.ctx.dest.client.getGasPrice()
|
|
18128
|
+
this.ctx.dest.client.getGasPrice(),
|
|
18129
|
+
this.ctx.dest.client.getBlock({ blockTag: "latest" })
|
|
18096
18130
|
]);
|
|
18131
|
+
const baseFeePerGas = latestBlock.baseFeePerGas ?? gasPrice;
|
|
18097
18132
|
const feeTokenAsBytes32 = bytes20ToBytes32(destFeeToken.address);
|
|
18098
18133
|
const assetsForOverrides = [...order.output.assets];
|
|
18099
18134
|
if (!assetsForOverrides.some((asset) => asset.token.toLowerCase() === feeTokenAsBytes32.toLowerCase())) {
|
|
@@ -18141,6 +18176,7 @@ var GasEstimator = class {
|
|
|
18141
18176
|
if (this.ctx.bundlerUrl) {
|
|
18142
18177
|
try {
|
|
18143
18178
|
const callData = this.crypto.encodeERC7821Execute([
|
|
18179
|
+
...params.prependCalls ?? [],
|
|
18144
18180
|
{ target: intentGatewayV2Address, value: totalNativeValue, data: fillOrderCalldata }
|
|
18145
18181
|
]);
|
|
18146
18182
|
const accountGasLimits = this.crypto.packGasLimits(100000n, callGasLimit);
|
|
@@ -18182,7 +18218,9 @@ var GasEstimator = class {
|
|
|
18182
18218
|
sessionSignature
|
|
18183
18219
|
]);
|
|
18184
18220
|
const bundlerUserOp = this.crypto.prepareBundlerCall(preliminaryUserOp);
|
|
18185
|
-
const
|
|
18221
|
+
const bundlerUrlLower = this.ctx.bundlerUrl.toLowerCase();
|
|
18222
|
+
const isPimlico = bundlerUrlLower.includes("pimlico.io");
|
|
18223
|
+
const isAlchemy = bundlerUrlLower.includes("alchemy.com");
|
|
18186
18224
|
const bundlerRequests = [
|
|
18187
18225
|
{
|
|
18188
18226
|
method: BundlerMethod.ETH_ESTIMATE_USER_OPERATION_GAS,
|
|
@@ -18195,14 +18233,24 @@ var GasEstimator = class {
|
|
|
18195
18233
|
params: []
|
|
18196
18234
|
});
|
|
18197
18235
|
}
|
|
18236
|
+
if (isAlchemy) {
|
|
18237
|
+
bundlerRequests.push({
|
|
18238
|
+
method: BundlerMethod.RUNDLER_MAX_PRIORITY_FEE_PER_GAS,
|
|
18239
|
+
params: []
|
|
18240
|
+
});
|
|
18241
|
+
}
|
|
18198
18242
|
let gasEstimate;
|
|
18199
18243
|
let pimlicoGasPrices = null;
|
|
18244
|
+
let alchemyMaxPriorityFee = null;
|
|
18200
18245
|
try {
|
|
18201
18246
|
const batchResults = await this.crypto.sendBundlerBatch(bundlerRequests);
|
|
18202
18247
|
gasEstimate = batchResults[0];
|
|
18203
18248
|
if (isPimlico && batchResults.length > 1) {
|
|
18204
18249
|
pimlicoGasPrices = batchResults[1];
|
|
18205
18250
|
}
|
|
18251
|
+
if (isAlchemy && batchResults.length > 1) {
|
|
18252
|
+
alchemyMaxPriorityFee = batchResults[1];
|
|
18253
|
+
}
|
|
18206
18254
|
} catch {
|
|
18207
18255
|
gasEstimate = await this.crypto.sendBundler(
|
|
18208
18256
|
BundlerMethod.ETH_ESTIMATE_USER_OPERATION_GAS,
|
|
@@ -18221,6 +18269,14 @@ var GasEstimator = class {
|
|
|
18221
18269
|
maxPriorityFeePerGas = pimMaxPriorityFeePerGas + pimMaxPriorityFeePerGas * BigInt(priorityFeeBumpPercent) / 100n;
|
|
18222
18270
|
}
|
|
18223
18271
|
}
|
|
18272
|
+
if (alchemyMaxPriorityFee) {
|
|
18273
|
+
const rundlerPriorityFee = BigInt(alchemyMaxPriorityFee);
|
|
18274
|
+
const isArbitrum = chainId === 42161n;
|
|
18275
|
+
const alchemyPrioBump = isArbitrum ? 0n : 25n;
|
|
18276
|
+
maxPriorityFeePerGas = rundlerPriorityFee + rundlerPriorityFee * alchemyPrioBump / 100n;
|
|
18277
|
+
const bufferedBaseFee = baseFeePerGas + baseFeePerGas * 50n / 100n;
|
|
18278
|
+
maxFeePerGas = bufferedBaseFee + maxPriorityFeePerGas;
|
|
18279
|
+
}
|
|
18224
18280
|
} catch (e) {
|
|
18225
18281
|
console.warn("Bundler gas estimation failed, using fallback values:", e);
|
|
18226
18282
|
}
|