getNaiveEstimatedGasBySwapCount
This module provides a utility function for calculating estimated gas costs based on the number of swaps in a transaction.
Methods
getNaiveEstimatedGasBySwapCount
getNaiveEstimatedGasBySwapCount(singleSwap: bigint, swapsCount: number): bigint
Parameters
singleSwap: bigint- The gas limit for a single swap operationswapsCount: number- The number of swaps to be performed
Calculates the naive estimated gas cost by multiplying the single swap gas limit by the number of swaps. This provides a simple linear estimation of gas requirements for multiple swap operations.
import { getNaiveEstimatedGasBySwapCount } from "@gmx-ui/sdk/utils/fees";
// Calculate gas for 3 swaps with single swap gas limit of 500000
const singleSwapGas = 500000n;
const swapCount = 3;
const estimatedGas = getNaiveEstimatedGasBySwapCount(singleSwapGas, swapCount);
console.log(estimatedGas); // 1500000n
// Calculate gas for a single swap
const singleSwapEstimate = getNaiveEstimatedGasBySwapCount(300000n, 1);
console.log(singleSwapEstimate); // 300000n