@hyperbridge/sdk 1.6.3 → 1.6.5

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.
@@ -1069,6 +1069,8 @@ declare class ChainConfigService {
1069
1069
  getUsdtDecimals(chain: string): number;
1070
1070
  getCNgnAsset(chain: string): HexString | undefined;
1071
1071
  getCNgnDecimals(chain: string): number | undefined;
1072
+ getExtAsset(chain: string): HexString | undefined;
1073
+ getExtDecimals(chain: string): number | undefined;
1072
1074
  getChainId(chain: string): number;
1073
1075
  getConsensusStateId(chain: string): HexString;
1074
1076
  getHyperbridgeChainId(): number;
@@ -2329,12 +2331,6 @@ declare enum RequestKind {
2329
2331
  * Configuration for the IntentFiller
2330
2332
  */
2331
2333
  interface FillerConfig {
2332
- /**
2333
- * Policy for determining confirmation requirements
2334
- */
2335
- confirmationPolicy: {
2336
- getConfirmationBlocks: (chainId: number, amountUsd: number) => number;
2337
- };
2338
2334
  /**
2339
2335
  * Maximum number of orders to process concurrently
2340
2336
  */
@@ -3878,6 +3874,7 @@ declare const BundlerMethod: {
3878
3874
  readonly ETH_SEND_USER_OPERATION: "eth_sendUserOperation";
3879
3875
  readonly ETH_GET_USER_OPERATION_RECEIPT: "eth_getUserOperationReceipt";
3880
3876
  readonly ETH_ESTIMATE_USER_OPERATION_GAS: "eth_estimateUserOperationGas";
3877
+ readonly PIMLICO_GET_USER_OPERATION_GAS_PRICE: "pimlico_getUserOperationGasPrice";
3881
3878
  };
3882
3879
  type BundlerMethod = (typeof BundlerMethod)[keyof typeof BundlerMethod];
3883
3880
  /** Response from bundler's eth_estimateUserOperationGas */
@@ -3974,6 +3971,7 @@ declare class IntentsV2 {
3974
3971
  pollIntervalMs?: number;
3975
3972
  }): AsyncGenerator<{
3976
3973
  calldata: HexString;
3974
+ feesInWei?: bigint;
3977
3975
  sessionPrivateKey: HexString;
3978
3976
  } | IntentOrderStatusUpdate, void, HexString>;
3979
3977
  placeOrder(order: OrderV2, graffiti?: HexString): AsyncGenerator<{
@@ -4433,11 +4431,13 @@ interface ChainConfigData {
4433
4431
  USDC: string;
4434
4432
  USDT: string;
4435
4433
  cNGN?: string;
4434
+ EXT?: string;
4436
4435
  };
4437
4436
  tokenDecimals?: {
4438
4437
  USDC: number;
4439
4438
  USDT: number;
4440
4439
  cNGN?: number;
4440
+ EXT?: number;
4441
4441
  };
4442
4442
  tokenStorageSlots?: {
4443
4443
  USDT?: {
@@ -441,11 +441,13 @@ var chainConfigs = {
441
441
  WETH: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
442
442
  DAI: "0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3",
443
443
  USDC: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
444
- USDT: "0x55d398326f99059ff775485246999027b3197955"
444
+ USDT: "0x55d398326f99059ff775485246999027b3197955",
445
+ EXT: "0x7C8c11ADb8EF7cd3CFa718008Ea048445C6E7209"
445
446
  },
446
447
  tokenDecimals: {
447
448
  USDC: 18,
448
- USDT: 18
449
+ USDT: 18,
450
+ EXT: 18
449
451
  },
450
452
  tokenStorageSlots: {
451
453
  USDT: { balanceSlot: 1, allowanceSlot: 2 },
@@ -493,11 +495,13 @@ var chainConfigs = {
493
495
  WETH: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
494
496
  DAI: "0xda10009cbd5d07dd0cecc66161fc93d7c9000da1",
495
497
  USDC: "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
496
- USDT: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"
498
+ USDT: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
499
+ EXT: "0x0e668E5127087e236578893a0e01E41837A28469"
497
500
  },
498
501
  tokenDecimals: {
499
502
  USDC: 6,
500
- USDT: 6
503
+ USDT: 6,
504
+ EXT: 18
501
505
  },
502
506
  tokenStorageSlots: {
503
507
  USDT: { balanceSlot: 51, allowanceSlot: 52 },
@@ -3836,6 +3840,12 @@ var ChainConfigService = class {
3836
3840
  getCNgnDecimals(chain) {
3837
3841
  return this.getConfig(chain)?.tokenDecimals?.cNGN;
3838
3842
  }
3843
+ getExtAsset(chain) {
3844
+ return this.getConfig(chain)?.assets?.EXT;
3845
+ }
3846
+ getExtDecimals(chain) {
3847
+ return this.getConfig(chain)?.tokenDecimals?.EXT;
3848
+ }
3839
3849
  getChainId(chain) {
3840
3850
  return this.getConfig(chain)?.chainId ?? 0;
3841
3851
  }
@@ -8333,6 +8343,7 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
8333
8343
  provider: new WsProvider(wsUrl),
8334
8344
  typesBundle: {
8335
8345
  spec: {
8346
+ nexus: { hasher: keccakAsU8a },
8336
8347
  gargantua: { hasher: keccakAsU8a }
8337
8348
  }
8338
8349
  }
@@ -8382,7 +8393,8 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
8382
8393
  if (this.substratePrivateKey.includes(" ")) {
8383
8394
  return keyring.addFromMnemonic(this.substratePrivateKey);
8384
8395
  }
8385
- const seedBytes = Buffer.from(this.substratePrivateKey, "hex");
8396
+ const hex = this.substratePrivateKey.startsWith("0x") ? this.substratePrivateKey.slice(2) : this.substratePrivateKey;
8397
+ const seedBytes = Buffer.from(hex, "hex");
8386
8398
  return keyring.addFromSeed(seedBytes);
8387
8399
  }
8388
8400
  /**
@@ -15088,7 +15100,8 @@ var ERC7821_BATCH_MODE = "0x0100000000000000000000000000000000000000000000000000
15088
15100
  var BundlerMethod = {
15089
15101
  ETH_SEND_USER_OPERATION: "eth_sendUserOperation",
15090
15102
  ETH_GET_USER_OPERATION_RECEIPT: "eth_getUserOperationReceipt",
15091
- ETH_ESTIMATE_USER_OPERATION_GAS: "eth_estimateUserOperationGas"
15103
+ ETH_ESTIMATE_USER_OPERATION_GAS: "eth_estimateUserOperationGas",
15104
+ PIMLICO_GET_USER_OPERATION_GAS_PRICE: "pimlico_getUserOperationGasPrice"
15092
15105
  };
15093
15106
 
15094
15107
  // src/protocols/intentsV2/CryptoUtils.ts
@@ -15928,7 +15941,7 @@ var BidManager = class {
15928
15941
  signature
15929
15942
  };
15930
15943
  try {
15931
- await this.simulate(order, selectOptions, bidWithOptions.options, solverAddress2, intentGatewayV2Address);
15944
+ await this.simulate(bidWithOptions.bid, selectOptions, intentGatewayV2Address);
15932
15945
  selectedBid = bidWithOptions;
15933
15946
  sessionSignature = signature;
15934
15947
  break;
@@ -16065,37 +16078,24 @@ var BidManager = class {
16065
16078
  }
16066
16079
  return null;
16067
16080
  }
16068
- async simulate(order, selectOptions, fillOptions, solverAddress, intentGatewayV2Address) {
16069
- const nativeOutputValue = order.output.assets.filter((asset) => bytes32ToBytes20(asset.token) === ADDRESS_ZERO).reduce((sum, asset) => sum + asset.amount, 0n);
16070
- const totalNativeValue = nativeOutputValue + fillOptions.nativeDispatchFee;
16081
+ async simulate(bid, selectOptions, intentGatewayV2Address) {
16082
+ const solverAddress = bid.userOp.sender;
16071
16083
  const selectCalldata = encodeFunctionData({
16072
16084
  abi: ABI3,
16073
16085
  functionName: "select",
16074
16086
  args: [selectOptions]
16075
16087
  });
16076
- const fillOrderCalldata = encodeFunctionData({
16077
- abi: ABI3,
16078
- functionName: "fillOrder",
16079
- args: [transformOrderForContract(order), fillOptions]
16080
- });
16081
- const batchedCalldata = this.crypto.encodeERC7821Execute([
16082
- {
16083
- target: intentGatewayV2Address,
16084
- value: 0n,
16085
- data: selectCalldata
16086
- },
16087
- {
16088
- target: intentGatewayV2Address,
16089
- value: totalNativeValue,
16090
- data: fillOrderCalldata
16091
- }
16092
- ]);
16088
+ const calls = [
16089
+ { target: intentGatewayV2Address, value: 0n, data: selectCalldata },
16090
+ { target: solverAddress, value: 0n, data: bid.userOp.callData }
16091
+ ];
16092
+ const batchedCalldata = this.crypto.encodeERC7821Execute(calls);
16093
16093
  try {
16094
16094
  await this.ctx.dest.client.call({
16095
16095
  account: solverAddress,
16096
16096
  to: solverAddress,
16097
16097
  data: batchedCalldata,
16098
- value: totalNativeValue
16098
+ value: 0n
16099
16099
  });
16100
16100
  } catch (e) {
16101
16101
  throw new Error(`Simulation failed: ${e instanceof Error ? e.message : String(e)}`);
@@ -16362,8 +16362,8 @@ var GasEstimator = class {
16362
16362
  const gasPrice = await this.ctx.dest.client.getGasPrice();
16363
16363
  const priorityFeeBumpPercent = params.maxPriorityFeePerGasBumpPercent ?? 8;
16364
16364
  const maxFeeBumpPercent = params.maxFeePerGasBumpPercent ?? 10;
16365
- const maxPriorityFeePerGas = gasPrice + gasPrice * BigInt(priorityFeeBumpPercent) / 100n;
16366
- const maxFeePerGas = gasPrice + gasPrice * BigInt(maxFeeBumpPercent) / 100n;
16365
+ let maxPriorityFeePerGas = gasPrice + gasPrice * BigInt(priorityFeeBumpPercent) / 100n;
16366
+ let maxFeePerGas = gasPrice + gasPrice * BigInt(maxFeeBumpPercent) / 100n;
16367
16367
  const orderForEstimation = { ...order, session: solverAccountAddress };
16368
16368
  const commitment = orderV2Commitment(orderForEstimation);
16369
16369
  const fillOrderCalldata = encodeFunctionData({
@@ -16425,6 +16425,23 @@ var GasEstimator = class {
16425
16425
  callGasLimit = BigInt(gasEstimate.callGasLimit) * 105n / 100n;
16426
16426
  verificationGasLimit = BigInt(gasEstimate.verificationGasLimit) * 105n / 100n;
16427
16427
  preVerificationGas = BigInt(gasEstimate.preVerificationGas) * 105n / 100n;
16428
+ if (this.ctx.bundlerUrl?.toLowerCase().includes("pimlico.io")) {
16429
+ try {
16430
+ const pimlicoGasPrices = await this.crypto.sendBundler(
16431
+ BundlerMethod.PIMLICO_GET_USER_OPERATION_GAS_PRICE,
16432
+ []
16433
+ );
16434
+ const level = pimlicoGasPrices.fast ?? pimlicoGasPrices.standard ?? pimlicoGasPrices.slow ?? null;
16435
+ if (level) {
16436
+ const pimMaxFeePerGas = BigInt(level.maxFeePerGas);
16437
+ const pimMaxPriorityFeePerGas = BigInt(level.maxPriorityFeePerGas);
16438
+ maxFeePerGas = pimMaxFeePerGas;
16439
+ maxPriorityFeePerGas = pimMaxPriorityFeePerGas;
16440
+ }
16441
+ } catch (e) {
16442
+ console.warn("Pimlico gas price fetch failed, using default gas price:", e);
16443
+ }
16444
+ }
16428
16445
  } catch (e) {
16429
16446
  console.warn("Bundler gas estimation failed, using fallback values:", e);
16430
16447
  }
@@ -16718,13 +16735,15 @@ var IntentsV2 = class _IntentsV2 {
16718
16735
  }
16719
16736
  }
16720
16737
  async *execute(order, graffiti = DEFAULT_GRAFFITI, options) {
16738
+ let feesInWei;
16721
16739
  if (!order.fees || order.fees === 0n) {
16722
16740
  const estimate = await this.gasEstimator.estimateFillOrderV2({
16723
16741
  order,
16724
16742
  maxPriorityFeePerGasBumpPercent: options?.maxPriorityFeePerGasBumpPercent,
16725
16743
  maxFeePerGasBumpPercent: options?.maxFeePerGasBumpPercent
16726
16744
  });
16727
- order.fees = estimate.totalGasInFeeToken;
16745
+ feesInWei = estimate.totalGasCostWei + estimate.totalGasCostWei * 2n / 100n;
16746
+ order.fees = estimate.totalGasInFeeToken + estimate.totalGasInFeeToken * 1n / 100n;
16728
16747
  }
16729
16748
  const placeOrderGen = this.orderPlacer.placeOrder(order, graffiti);
16730
16749
  const placeOrderFirst = await placeOrderGen.next();
@@ -16732,7 +16751,7 @@ var IntentsV2 = class _IntentsV2 {
16732
16751
  throw new Error("placeOrder generator completed without yielding");
16733
16752
  }
16734
16753
  const { calldata, sessionPrivateKey } = placeOrderFirst.value;
16735
- const signedTransaction = yield { calldata, sessionPrivateKey };
16754
+ const signedTransaction = yield { calldata, feesInWei, sessionPrivateKey };
16736
16755
  const placeOrderSecond = await placeOrderGen.next(signedTransaction);
16737
16756
  if (placeOrderSecond.done === false) {
16738
16757
  throw new Error("placeOrder generator yielded unexpectedly after signing");