openzeppelin_relayer::domain

Module price_calculator

Source
Expand description

Gas price calculation module for Ethereum transactions.

This module provides functionality for calculating gas prices for different types of Ethereum transactions:

  • Legacy transactions (using gas_price)
  • EIP1559 transactions (using max_fee_per_gas and max_priority_fee_per_gas)
  • Speed-based transactions (automatically choosing between legacy and EIP1559 based on network support)

The module implements various pricing strategies and safety mechanisms:

  • Gas price caps to protect against excessive fees
  • Dynamic base fee calculations for EIP1559 transactions
  • Speed-based multipliers for different transaction priorities (SafeLow, Average, Fast, Fastest)
  • Network-specific block time considerations for fee estimations

§Example

let price_params = PriceCalculator::get_transaction_price_params(
    tx_data,
    relayer,
    gas_price_service,
    provider
).await?;

The module uses EIP1559-specific constants for calculating appropriate gas fees:

  • Base fee increase factor: 12.5% per block
  • Maximum base fee multiplier: 10x
  • Time window for fee calculation: 90 seconds

Structs§

Traits§