estimate_gas_fees

Documentation for eth_defi.gas.estimate_gas_fees function.

estimate_gas_fees(web3, method=None, gas_price_buffer_multiplier=1.12, min_priority_fee=None)

Get a good gas price for a transaction.

Applies a safety buffer to maxFeePerGas to absorb base fee fluctuations between estimation and transaction submission. See GAS_PRICE_BUFFER_MULTIPLIER for details.

On EIP-1559 chains, the RPC suggested priority fee is floored to a per-chain minimum so transactions do not get stuck in the mempool with an effectively zero tip. See MIN_PRIORITY_FEE_PER_CHAIN for details.

Parameters
  • web3 (web3.main.Web3) – Web3 instance connected to a node.

  • method – Force a specific gas pricing method. If None, auto-detect based on whether the chain supports EIP-1559.

  • gas_price_buffer_multiplier (float) – Multiplier applied to maxFeePerGas to absorb base fee fluctuations. Defaults to GAS_PRICE_BUFFER_MULTIPLIER (1.12 = 12% buffer). Set to 1.0 to disable the buffer.

  • min_priority_fee (Optional[int]) –

    Minimum maxPriorityFeePerGas in wei for EIP-1559 chains.

    The RPC suggested priority fee is raised to at least this value. If None, the per-chain default from MIN_PRIORITY_FEE_PER_CHAIN is used, with no floor applied for chains not listed there. Set to 0 to always use the raw RPC suggestion.

Return type

eth_defi.gas.GasPriceSuggestion