diff --git a/src/libs/AxelarQueryAPI.ts b/src/libs/AxelarQueryAPI.ts index 9afcdae1..291efb5d 100644 --- a/src/libs/AxelarQueryAPI.ts +++ b/src/libs/AxelarQueryAPI.ts @@ -568,55 +568,6 @@ export class AxelarQueryAPI { } } - /** - * Estimates the fee for an Amplifier transaction by splitting it into two hops: - * 1. Source chain to Axelar - * 2. Axelar to destination chain - * - * @param params Parameters for the end-to-end transfer - * @param options Optional parameters for fee estimation - * @returns Promise containing the estimated fees - * @throws {Error} If config loading fails or required parameters are missing - */ - public async estimateAmplifierFee( - params: HopParams, - options?: EstimateMultihopFeeOptions - ): Promise { - const config = await importS3Config(this.environment); - const axelarChainId = config["axelar"]?.axelarId || "axelar"; - - const hops = [ - { - sourceChain: params.sourceChain, - destinationChain: axelarChainId, - gasLimit: params.gasLimit, - sourceTokenSymbol: params.sourceTokenSymbol, - sourceTokenAddress: params.sourceTokenAddress, - sourceContractAddress: params.sourceContractAddress, - }, - { - sourceChain: axelarChainId, - destinationChain: params.destinationChain, - gasLimit: params.gasLimit, - symbol: params.symbol, - minGasPrice: params.minGasPrice, - executeData: params.executeData, - destinationContractAddress: params.destinationContractAddress, - amountInUnits: params.amountInUnits, - }, - ]; - - // Clean up undefined values to make it easier for validation - const cleanHop = (hop: HopParams): HopParams => { - return Object.fromEntries( - Object.entries(hop).filter(([_, value]) => value !== undefined) - ) as HopParams; - }; - - // Estimate fees for both hops - return this.estimateMultihopFee(hops.map(cleanHop), options); - } - /** * Get the denom for an asset given its symbol on a chain * @param symbol diff --git a/src/libs/test/AxelarQueryAPI.spec.ts b/src/libs/test/AxelarQueryAPI.spec.ts index e7f061bf..73a8e108 100644 --- a/src/libs/test/AxelarQueryAPI.spec.ts +++ b/src/libs/test/AxelarQueryAPI.spec.ts @@ -342,143 +342,6 @@ describe("AxelarQueryAPI", () => { }); }); - describe("estimateAmplifierFee", () => { - let amplifierApi: AxelarQueryAPI; - let mockImportS3Config: SpyInstance; - let mockEstimateMultihopFee: SpyInstance; - - beforeEach(async () => { - amplifierApi = new AxelarQueryAPI({ - environment: Environment.DEVNET, - }); - - mockImportS3Config = vi - .spyOn(await import("../../chains"), "importS3Config") - .mockResolvedValueOnce({ - axelar: { - axelarId: "axelar-test", - }, - }); - - // Mock estimateMultihopFee to avoid duplication of its tests - mockEstimateMultihopFee = vi - .spyOn(amplifierApi, "estimateMultihopFee") - .mockResolvedValue("1"); - }); - - afterEach(() => { - vi.resetAllMocks(); - }); - - test("should correctly split into two hops using config axelarId", async () => { - const params = { - sourceChain: "ethereum", - destinationChain: "avalanche", - gasLimit: "700000", - sourceTokenSymbol: "axlUSDC", - }; - - await amplifierApi.estimateAmplifierFee(params); - - expect(mockEstimateMultihopFee).toHaveBeenCalledWith( - [ - { - sourceChain: params.sourceChain, - destinationChain: "axelar-test", - gasLimit: params.gasLimit, - sourceTokenSymbol: params.sourceTokenSymbol, - }, - { - sourceChain: "axelar-test", - destinationChain: params.destinationChain, - gasLimit: "700000", - }, - ], - undefined - ); - }); - - test("should use default axelarId when not in config", async () => { - mockImportS3Config.mockResolvedValueOnce({}); - - const params = { - sourceChain: "ethereum", - destinationChain: "avalanche", - gasLimit: "700000", - }; - - await amplifierApi.estimateAmplifierFee(params); - - expect(mockEstimateMultihopFee).toHaveBeenCalledWith( - [ - { - sourceChain: params.sourceChain, - destinationChain: "axelar-test", - gasLimit: params.gasLimit, - }, - { - sourceChain: "axelar-test", - destinationChain: params.destinationChain, - gasLimit: params.gasLimit, - }, - ], - undefined - ); - }); - - test("should pass through all relevant parameters to correct hops", async () => { - const params = { - sourceChain: "ethereum", - destinationChain: "avalanche", - gasLimit: "700000", - sourceTokenSymbol: "axlUSDC", - sourceContractAddress: "0xsource", - destinationContractAddress: "0xdest", - executeData: "0xdata", - amountInUnits: "1000000", - }; - - await amplifierApi.estimateAmplifierFee(params); - - expect(mockEstimateMultihopFee).toHaveBeenCalledWith( - [ - { - sourceChain: "ethereum", - destinationChain: "axelar-test", - gasLimit: "700000", - sourceTokenSymbol: "axlUSDC", - sourceContractAddress: "0xsource", - }, - { - sourceChain: "axelar-test", - destinationChain: "avalanche", - gasLimit: "700000", - destinationContractAddress: "0xdest", - executeData: "0xdata", - amountInUnits: "1000000", - }, - ], - undefined - ); - }); - - test("should pass through showDetailedFees option", async () => { - const params = { - sourceChain: "ethereum", - destinationChain: "avalanche", - gasLimit: "700000", - }; - - await amplifierApi.estimateAmplifierFee(params, { - showDetailedFees: true, - }); - - expect(mockEstimateMultihopFee).toHaveBeenCalledWith(expect.any(Array), { - showDetailedFees: true, - }); - }); - }); - describe("estimateGasFee", () => { test("It should return estimated gas amount that makes sense for USDC", async () => { const gasAmount = await api.estimateGasFee(