@hyperbridge/sdk 2.3.1 → 2.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.
@@ -175,9 +175,9 @@ declare class EvmChain implements IChain {
175
175
  quoteNative(request: IPostRequest | IGetRequest, fee: bigint): Promise<bigint>;
176
176
  /**
177
177
  * Given a desired output amount of a token, returns how much native is needed as input.
178
- * Uses the chain's Uniswap V2 router: WETH → tokenOut path.
178
+ * Uses the chain's Uniswap V2 router (or `router` when provided): WETH → tokenOut path.
179
179
  */
180
- getAmountsIn(amountOut: bigint, tokenOutForQuote: HexString, chain?: string): Promise<bigint>;
180
+ getAmountsIn(amountOut: bigint, tokenOutForQuote: HexString, chain?: string, router?: HexString): Promise<bigint>;
181
181
  /**
182
182
  * Given an input amount of native token, returns how much of the output token you get.
183
183
  * Uses the chain's Uniswap V2 router: WETH → tokenOut path.
@@ -175,9 +175,9 @@ declare class EvmChain implements IChain {
175
175
  quoteNative(request: IPostRequest | IGetRequest, fee: bigint): Promise<bigint>;
176
176
  /**
177
177
  * Given a desired output amount of a token, returns how much native is needed as input.
178
- * Uses the chain's Uniswap V2 router: WETH → tokenOut path.
178
+ * Uses the chain's Uniswap V2 router (or `router` when provided): WETH → tokenOut path.
179
179
  */
180
- getAmountsIn(amountOut: bigint, tokenOutForQuote: HexString, chain?: string): Promise<bigint>;
180
+ getAmountsIn(amountOut: bigint, tokenOutForQuote: HexString, chain?: string, router?: HexString): Promise<bigint>;
181
181
  /**
182
182
  * Given an input amount of native token, returns how much of the output token you get.
183
183
  * Uses the chain's Uniswap V2 router: WETH → tokenOut path.
@@ -6775,15 +6775,20 @@ var EvmChain = class _EvmChain {
6775
6775
  async quoteNative(request, fee) {
6776
6776
  const totalFee = await this.quote(request) + fee;
6777
6777
  const feeToken = await this.getFeeTokenWithDecimals();
6778
- return this.getAmountsIn(totalFee, feeToken.address, request.source);
6778
+ const hostRouter = await this.publicClient.readContract({
6779
+ address: this.params.host,
6780
+ abi: evmHost_default.ABI,
6781
+ functionName: "uniswapV2Router"
6782
+ });
6783
+ return this.getAmountsIn(totalFee, feeToken.address, request.source, hostRouter);
6779
6784
  }
6780
6785
  /**
6781
6786
  * Given a desired output amount of a token, returns how much native is needed as input.
6782
- * Uses the chain's Uniswap V2 router: WETH → tokenOut path.
6787
+ * Uses the chain's Uniswap V2 router (or `router` when provided): WETH → tokenOut path.
6783
6788
  */
6784
- async getAmountsIn(amountOut, tokenOutForQuote, chain) {
6789
+ async getAmountsIn(amountOut, tokenOutForQuote, chain, router) {
6785
6790
  const chainId = chain ?? `EVM-${this.params.chainId}`;
6786
- const v2Router = this.configService.getUniswapRouterV2Address(chainId);
6791
+ const v2Router = router ?? this.configService.getUniswapRouterV2Address(chainId);
6787
6792
  const WETH = this.configService.getWrappedNativeAssetWithDecimals(chainId).asset;
6788
6793
  const v2AmountIn = await this.publicClient.simulateContract({
6789
6794
  address: v2Router,
@@ -16988,9 +16993,9 @@ var GasEstimator = class {
16988
16993
  from: this.ctx.source.configService.getIntentGatewayAddress(destChainId),
16989
16994
  to: this.ctx.source.configService.getIntentGatewayAddress(sourceChainId)
16990
16995
  };
16996
+ postRequestFeeInDestFeeToken = postRequestFeeInDestFeeToken * 1005n / 1000n;
16991
16997
  let protocolFeeInNativeToken = await this.ctx.dest.quoteNative(postRequest, postRequestFeeInDestFeeToken).catch(() => 0n);
16992
16998
  protocolFeeInNativeToken = protocolFeeInNativeToken * 1005n / 1000n;
16993
- postRequestFeeInDestFeeToken = postRequestFeeInDestFeeToken * 1005n / 1000n;
16994
16999
  return { postRequestFee: postRequestFeeInDestFeeToken, protocolFee: protocolFeeInNativeToken };
16995
17000
  }
16996
17001
  /**