Skip to content

Commit

Permalink
rename gas fee estimation fn like in eip1559 terms
Browse files Browse the repository at this point in the history
  • Loading branch information
dimxy committed Mar 8, 2024
1 parent 61a80a9 commit 46ceacc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions mm2src/coins/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4752,8 +4752,8 @@ impl EthCoin {
Box::new(fut.boxed().compat())
}

/// Get base gas fee and suggest priority tip fees for the next block (see EIP1559)
pub async fn get_eip1559_gas_price(&self) -> Result<FeePerGasEstimated, MmError<Web3RpcError>> {
/// Get gas base fee and suggest priority tip fees for the next block (see EIP-1559)
pub async fn get_eip1559_gas_fee(&self) -> Result<FeePerGasEstimated, MmError<Web3RpcError>> {
let coin = self.clone();
let fee_history_namespace: EthFeeHistoryNamespace<_> = coin.web3.api();
let history_estimator_fut = FeePerGasSimpleEstimator::estimate_fee_by_history(fee_history_namespace);
Expand Down
9 changes: 5 additions & 4 deletions mm2src/coins/rpc_command/get_estimated_fees.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! RPCs to start/stop gas price estimator and get estimated base and priority fee per gas
//! RPCs to start/stop gas fee estimator and get estimated base and priority fee per gas
use crate::eth::{EthCoin, FeePerGasEstimated};
use crate::AsyncMutex;
Expand All @@ -11,7 +11,8 @@ use mm2_err_handle::prelude::*;
use std::sync::Arc;

const FEE_ESTIMATOR_NAME: &str = "eth_fee_estimator_loop";
const ETH_SUPPORTED_CHAIN_ID: u64 = 1; // only eth mainnet is suppported. To support other chains add a FeeEstimatorContext for each chain
const ETH_SUPPORTED_CHAIN_ID: u64 = 1; // only eth mainnet is suppported (Blocknative gas platform currently supports Ethereum and Polygon/Matic mainnets.)
// To support fee estimations for other chains add a FeeEstimatorContext for a new chain

#[derive(Debug, Display, Serialize, SerializeErrorType)]
#[serde(tag = "error_type", content = "error_data")]
Expand Down Expand Up @@ -133,7 +134,7 @@ impl FeeEstimatorContext {

/// Loop polling gas fee estimator
///
/// This loop periodically calls get_eip1559_gas_price which fetches fee per gas estimations from a gas api provider or calculates them internally
/// This loop periodically calls get_eip1559_gas_fee which fetches fee per gas estimations from a gas api provider or calculates them internally
/// The retrieved data are stored in the fee estimator context
/// To connect to the chain and gas api provider the web3 instances are used from an EthCoin coin passed in the start rpc param,
/// so this coin must be enabled first.
Expand All @@ -143,7 +144,7 @@ impl FeeEstimatorContext {
async fn fee_estimator_loop(estimated_fees: Arc<AsyncMutex<FeePerGasEstimated>>, coin: EthCoin) {
loop {
let started = common::now_float();
*estimated_fees.lock().await = coin.get_eip1559_gas_price().await.unwrap_or_default();
*estimated_fees.lock().await = coin.get_eip1559_gas_fee().await.unwrap_or_default();

let elapsed = common::now_float() - started;
debug!(
Expand Down

0 comments on commit 46ceacc

Please sign in to comment.