Skip to content

Commit

Permalink
chore: add helper for next block base fee (alloy-rs#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored and klkvr committed Apr 11, 2024
1 parent c96d6fe commit e5d0442
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions crates/eips/src/eip1559/basefee.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::eip1559::constants::{
DEFAULT_BASE_FEE_MAX_CHANGE_DENOMINATOR, DEFAULT_ELASTICITY_MULTIPLIER,
use crate::{
calc_next_block_base_fee,
eip1559::constants::{DEFAULT_BASE_FEE_MAX_CHANGE_DENOMINATOR, DEFAULT_ELASTICITY_MULTIPLIER},
};

/// BaseFeeParams contains the config parameters that control block base fee computation
Expand All @@ -22,4 +23,12 @@ impl BaseFeeParams {
elasticity_multiplier: DEFAULT_ELASTICITY_MULTIPLIER as u128,
}
}

/// Calculate the base fee for the next block based on the EIP-1559 specification.
///
/// See also [calc_next_block_base_fee]
#[inline]
pub fn next_block_base_fee(self, gas_used: u128, gas_limit: u128, base_fee: u128) -> u128 {
calc_next_block_base_fee(gas_used, gas_limit, base_fee, self)
}
}

0 comments on commit e5d0442

Please sign in to comment.