@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?: {
@@ -491,11 +491,13 @@ var chainConfigs = {
491
491
  WETH: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
492
492
  DAI: "0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3",
493
493
  USDC: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
494
- USDT: "0x55d398326f99059ff775485246999027b3197955"
494
+ USDT: "0x55d398326f99059ff775485246999027b3197955",
495
+ EXT: "0x7C8c11ADb8EF7cd3CFa718008Ea048445C6E7209"
495
496
  },
496
497
  tokenDecimals: {
497
498
  USDC: 18,
498
- USDT: 18
499
+ USDT: 18,
500
+ EXT: 18
499
501
  },
500
502
  tokenStorageSlots: {
501
503
  USDT: { balanceSlot: 1, allowanceSlot: 2 },
@@ -543,11 +545,13 @@ var chainConfigs = {
543
545
  WETH: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
544
546
  DAI: "0xda10009cbd5d07dd0cecc66161fc93d7c9000da1",
545
547
  USDC: "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
546
- USDT: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"
548
+ USDT: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
549
+ EXT: "0x0e668E5127087e236578893a0e01E41837A28469"
547
550
  },
548
551
  tokenDecimals: {
549
552
  USDC: 6,
550
- USDT: 6
553
+ USDT: 6,
554
+ EXT: 18
551
555
  },
552
556
  tokenStorageSlots: {
553
557
  USDT: { balanceSlot: 51, allowanceSlot: 52 },
@@ -3886,6 +3890,12 @@ var ChainConfigService = class {
3886
3890
  getCNgnDecimals(chain) {
3887
3891
  return this.getConfig(chain)?.tokenDecimals?.cNGN;
3888
3892
  }
3893
+ getExtAsset(chain) {
3894
+ return this.getConfig(chain)?.assets?.EXT;
3895
+ }
3896
+ getExtDecimals(chain) {
3897
+ return this.getConfig(chain)?.tokenDecimals?.EXT;
3898
+ }
3889
3899
  getChainId(chain) {
3890
3900
  return this.getConfig(chain)?.chainId ?? 0;
3891
3901
  }
@@ -8383,6 +8393,7 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
8383
8393
  provider: new WsProvider(wsUrl),
8384
8394
  typesBundle: {
8385
8395
  spec: {
8396
+ nexus: { hasher: keccakAsU8a },
8386
8397
  gargantua: { hasher: keccakAsU8a }
8387
8398
  }
8388
8399
  }
@@ -8432,7 +8443,8 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
8432
8443
  if (this.substratePrivateKey.includes(" ")) {
8433
8444
  return keyring.addFromMnemonic(this.substratePrivateKey);
8434
8445
  }
8435
- const seedBytes = Buffer.from(this.substratePrivateKey, "hex");
8446
+ const hex = this.substratePrivateKey.startsWith("0x") ? this.substratePrivateKey.slice(2) : this.substratePrivateKey;
8447
+ const seedBytes = Buffer.from(hex, "hex");
8436
8448
  return keyring.addFromSeed(seedBytes);
8437
8449
  }
8438
8450
  /**
@@ -15148,7 +15160,8 @@ var ERC7821_BATCH_MODE = "0x0100000000000000000000000000000000000000000000000000
15148
15160
  var BundlerMethod = {
15149
15161
  ETH_SEND_USER_OPERATION: "eth_sendUserOperation",
15150
15162
  ETH_GET_USER_OPERATION_RECEIPT: "eth_getUserOperationReceipt",
15151
- ETH_ESTIMATE_USER_OPERATION_GAS: "eth_estimateUserOperationGas"
15163
+ ETH_ESTIMATE_USER_OPERATION_GAS: "eth_estimateUserOperationGas",
15164
+ PIMLICO_GET_USER_OPERATION_GAS_PRICE: "pimlico_getUserOperationGasPrice"
15152
15165
  };
15153
15166
 
15154
15167
  // src/protocols/intentsV2/CryptoUtils.ts
@@ -15988,7 +16001,7 @@ var BidManager = class {
15988
16001
  signature
15989
16002
  };
15990
16003
  try {
15991
- await this.simulate(order, selectOptions, bidWithOptions.options, solverAddress2, intentGatewayV2Address);
16004
+ await this.simulate(bidWithOptions.bid, selectOptions, intentGatewayV2Address);
15992
16005
  selectedBid = bidWithOptions;
15993
16006
  sessionSignature = signature;
15994
16007
  break;
@@ -16125,37 +16138,24 @@ var BidManager = class {
16125
16138
  }
16126
16139
  return null;
16127
16140
  }
16128
- async simulate(order, selectOptions, fillOptions, solverAddress, intentGatewayV2Address) {
16129
- const nativeOutputValue = order.output.assets.filter((asset) => bytes32ToBytes20(asset.token) === ADDRESS_ZERO).reduce((sum, asset) => sum + asset.amount, 0n);
16130
- const totalNativeValue = nativeOutputValue + fillOptions.nativeDispatchFee;
16141
+ async simulate(bid, selectOptions, intentGatewayV2Address) {
16142
+ const solverAddress = bid.userOp.sender;
16131
16143
  const selectCalldata = encodeFunctionData({
16132
16144
  abi: ABI3,
16133
16145
  functionName: "select",
16134
16146
  args: [selectOptions]
16135
16147
  });
16136
- const fillOrderCalldata = encodeFunctionData({
16137
- abi: ABI3,
16138
- functionName: "fillOrder",
16139
- args: [transformOrderForContract(order), fillOptions]
16140
- });
16141
- const batchedCalldata = this.crypto.encodeERC7821Execute([
16142
- {
16143
- target: intentGatewayV2Address,
16144
- value: 0n,
16145
- data: selectCalldata
16146
- },
16147
- {
16148
- target: intentGatewayV2Address,
16149
- value: totalNativeValue,
16150
- data: fillOrderCalldata
16151
- }
16152
- ]);
16148
+ const calls = [
16149
+ { target: intentGatewayV2Address, value: 0n, data: selectCalldata },
16150
+ { target: solverAddress, value: 0n, data: bid.userOp.callData }
16151
+ ];
16152
+ const batchedCalldata = this.crypto.encodeERC7821Execute(calls);
16153
16153
  try {
16154
16154
  await this.ctx.dest.client.call({
16155
16155
  account: solverAddress,
16156
16156
  to: solverAddress,
16157
16157
  data: batchedCalldata,
16158
- value: totalNativeValue
16158
+ value: 0n
16159
16159
  });
16160
16160
  } catch (e) {
16161
16161
  throw new Error(`Simulation failed: ${e instanceof Error ? e.message : String(e)}`);
@@ -16422,8 +16422,8 @@ var GasEstimator = class {
16422
16422
  const gasPrice = await this.ctx.dest.client.getGasPrice();
16423
16423
  const priorityFeeBumpPercent = params.maxPriorityFeePerGasBumpPercent ?? 8;
16424
16424
  const maxFeeBumpPercent = params.maxFeePerGasBumpPercent ?? 10;
16425
- const maxPriorityFeePerGas = gasPrice + gasPrice * BigInt(priorityFeeBumpPercent) / 100n;
16426
- const maxFeePerGas = gasPrice + gasPrice * BigInt(maxFeeBumpPercent) / 100n;
16425
+ let maxPriorityFeePerGas = gasPrice + gasPrice * BigInt(priorityFeeBumpPercent) / 100n;
16426
+ let maxFeePerGas = gasPrice + gasPrice * BigInt(maxFeeBumpPercent) / 100n;
16427
16427
  const orderForEstimation = { ...order, session: solverAccountAddress };
16428
16428
  const commitment = orderV2Commitment(orderForEstimation);
16429
16429
  const fillOrderCalldata = encodeFunctionData({
@@ -16485,6 +16485,23 @@ var GasEstimator = class {
16485
16485
  callGasLimit = BigInt(gasEstimate.callGasLimit) * 105n / 100n;
16486
16486
  verificationGasLimit = BigInt(gasEstimate.verificationGasLimit) * 105n / 100n;
16487
16487
  preVerificationGas = BigInt(gasEstimate.preVerificationGas) * 105n / 100n;
16488
+ if (this.ctx.bundlerUrl?.toLowerCase().includes("pimlico.io")) {
16489
+ try {
16490
+ const pimlicoGasPrices = await this.crypto.sendBundler(
16491
+ BundlerMethod.PIMLICO_GET_USER_OPERATION_GAS_PRICE,
16492
+ []
16493
+ );
16494
+ const level = pimlicoGasPrices.fast ?? pimlicoGasPrices.standard ?? pimlicoGasPrices.slow ?? null;
16495
+ if (level) {
16496
+ const pimMaxFeePerGas = BigInt(level.maxFeePerGas);
16497
+ const pimMaxPriorityFeePerGas = BigInt(level.maxPriorityFeePerGas);
16498
+ maxFeePerGas = pimMaxFeePerGas;
16499
+ maxPriorityFeePerGas = pimMaxPriorityFeePerGas;
16500
+ }
16501
+ } catch (e) {
16502
+ console.warn("Pimlico gas price fetch failed, using default gas price:", e);
16503
+ }
16504
+ }
16488
16505
  } catch (e) {
16489
16506
  console.warn("Bundler gas estimation failed, using fallback values:", e);
16490
16507
  }
@@ -16778,13 +16795,15 @@ var IntentsV2 = class _IntentsV2 {
16778
16795
  }
16779
16796
  }
16780
16797
  async *execute(order, graffiti = DEFAULT_GRAFFITI, options) {
16798
+ let feesInWei;
16781
16799
  if (!order.fees || order.fees === 0n) {
16782
16800
  const estimate = await this.gasEstimator.estimateFillOrderV2({
16783
16801
  order,
16784
16802
  maxPriorityFeePerGasBumpPercent: options?.maxPriorityFeePerGasBumpPercent,
16785
16803
  maxFeePerGasBumpPercent: options?.maxFeePerGasBumpPercent
16786
16804
  });
16787
- order.fees = estimate.totalGasInFeeToken;
16805
+ feesInWei = estimate.totalGasCostWei + estimate.totalGasCostWei * 2n / 100n;
16806
+ order.fees = estimate.totalGasInFeeToken + estimate.totalGasInFeeToken * 1n / 100n;
16788
16807
  }
16789
16808
  const placeOrderGen = this.orderPlacer.placeOrder(order, graffiti);
16790
16809
  const placeOrderFirst = await placeOrderGen.next();
@@ -16792,7 +16811,7 @@ var IntentsV2 = class _IntentsV2 {
16792
16811
  throw new Error("placeOrder generator completed without yielding");
16793
16812
  }
16794
16813
  const { calldata, sessionPrivateKey } = placeOrderFirst.value;
16795
- const signedTransaction = yield { calldata, sessionPrivateKey };
16814
+ const signedTransaction = yield { calldata, feesInWei, sessionPrivateKey };
16796
16815
  const placeOrderSecond = await placeOrderGen.next(signedTransaction);
16797
16816
  if (placeOrderSecond.done === false) {
16798
16817
  throw new Error("placeOrder generator yielded unexpectedly after signing");