pub fn calc_effective_gas_price(
max_fee_per_gas: u128,
max_priority_fee_per_gas: u128,
base_fee: Option<u64>,
) -> u128Expand description
Calculates the effective gas price for a dynamic fee transaction.
This is a utility function for EIP-1559 and similar transactions that use dynamic fees.
For EIP-1559 transactions, the effective gas price is calculated as:
- If no base fee: returns
max_fee_per_gas - If base fee exists: returns
min(max_fee_per_gas, max_priority_fee_per_gas + base_fee)
This ensures that the total fee doesn’t exceed the maximum fee per gas, while also ensuring that the priority fee doesn’t exceed the maximum priority fee per gas.