@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.
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.js +10 -5
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +10 -5
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +2 -2
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +10 -5
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -1204,9 +1204,9 @@ declare class EvmChain implements IChain {
|
|
|
1204
1204
|
quoteNative(request: IPostRequest | IGetRequest, fee: bigint): Promise<bigint>;
|
|
1205
1205
|
/**
|
|
1206
1206
|
* Given a desired output amount of a token, returns how much native is needed as input.
|
|
1207
|
-
* Uses the chain's Uniswap V2 router: WETH → tokenOut path.
|
|
1207
|
+
* Uses the chain's Uniswap V2 router (or `router` when provided): WETH → tokenOut path.
|
|
1208
1208
|
*/
|
|
1209
|
-
getAmountsIn(amountOut: bigint, tokenOutForQuote: HexString, chain?: string): Promise<bigint>;
|
|
1209
|
+
getAmountsIn(amountOut: bigint, tokenOutForQuote: HexString, chain?: string, router?: HexString): Promise<bigint>;
|
|
1210
1210
|
/**
|
|
1211
1211
|
* Given an input amount of native token, returns how much of the output token you get.
|
|
1212
1212
|
* Uses the chain's Uniswap V2 router: WETH → tokenOut path.
|
package/dist/browser/index.js
CHANGED
|
@@ -6825,15 +6825,20 @@ var EvmChain = class _EvmChain {
|
|
|
6825
6825
|
async quoteNative(request, fee) {
|
|
6826
6826
|
const totalFee = await this.quote(request) + fee;
|
|
6827
6827
|
const feeToken = await this.getFeeTokenWithDecimals();
|
|
6828
|
-
|
|
6828
|
+
const hostRouter = await this.publicClient.readContract({
|
|
6829
|
+
address: this.params.host,
|
|
6830
|
+
abi: evmHost_default.ABI,
|
|
6831
|
+
functionName: "uniswapV2Router"
|
|
6832
|
+
});
|
|
6833
|
+
return this.getAmountsIn(totalFee, feeToken.address, request.source, hostRouter);
|
|
6829
6834
|
}
|
|
6830
6835
|
/**
|
|
6831
6836
|
* Given a desired output amount of a token, returns how much native is needed as input.
|
|
6832
|
-
* Uses the chain's Uniswap V2 router: WETH → tokenOut path.
|
|
6837
|
+
* Uses the chain's Uniswap V2 router (or `router` when provided): WETH → tokenOut path.
|
|
6833
6838
|
*/
|
|
6834
|
-
async getAmountsIn(amountOut, tokenOutForQuote, chain) {
|
|
6839
|
+
async getAmountsIn(amountOut, tokenOutForQuote, chain, router) {
|
|
6835
6840
|
const chainId = chain ?? `EVM-${this.params.chainId}`;
|
|
6836
|
-
const v2Router = this.configService.getUniswapRouterV2Address(chainId);
|
|
6841
|
+
const v2Router = router ?? this.configService.getUniswapRouterV2Address(chainId);
|
|
6837
6842
|
const WETH = this.configService.getWrappedNativeAssetWithDecimals(chainId).asset;
|
|
6838
6843
|
const v2AmountIn = await this.publicClient.simulateContract({
|
|
6839
6844
|
address: v2Router,
|
|
@@ -17048,9 +17053,9 @@ var GasEstimator = class {
|
|
|
17048
17053
|
from: this.ctx.source.configService.getIntentGatewayAddress(destChainId),
|
|
17049
17054
|
to: this.ctx.source.configService.getIntentGatewayAddress(sourceChainId)
|
|
17050
17055
|
};
|
|
17056
|
+
postRequestFeeInDestFeeToken = postRequestFeeInDestFeeToken * 1005n / 1000n;
|
|
17051
17057
|
let protocolFeeInNativeToken = await this.ctx.dest.quoteNative(postRequest, postRequestFeeInDestFeeToken).catch(() => 0n);
|
|
17052
17058
|
protocolFeeInNativeToken = protocolFeeInNativeToken * 1005n / 1000n;
|
|
17053
|
-
postRequestFeeInDestFeeToken = postRequestFeeInDestFeeToken * 1005n / 1000n;
|
|
17054
17059
|
return { postRequestFee: postRequestFeeInDestFeeToken, protocolFee: protocolFeeInNativeToken };
|
|
17055
17060
|
}
|
|
17056
17061
|
/**
|