Skip to content

Commit

Permalink
fix(polygon): remove conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfourzerofour committed Sep 19, 2023
1 parent 8629688 commit 9c7a83f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
14 changes: 1 addition & 13 deletions crates/sim/src/gas/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,7 @@ impl<P: Provider> FeeEstimator<P> {
if POLYGON_CHAIN_IDS.contains(&self.chain_id) {
let gas_oracle = Polygon::new(Arc::clone(&self.provider)).category(GasCategory::Fast);

let fees = gas_oracle
.estimate_eip1559_fees()
.await
.context("failed to query polygon gasstation")?;
let fees = gas_oracle.estimate_eip1559_fees().await?;
Ok(fees.1)
} else if self.use_bundle_priority_fee {
self.provider.get_max_priority_fee().await
Expand All @@ -286,15 +283,6 @@ impl<P: Provider> FeeEstimator<P> {
}
}

<<<<<<< HEAD:crates/sim/src/gas/gas.rs
const GWEI_TO_WEI: u64 = 1_000_000_000;

pub(crate) fn from_gwei_f64(gwei: f64) -> U256 {
U256::from((gwei * GWEI_TO_WEI as f64).ceil() as u64)
}

=======
>>>>>>> c69836c (feat(polygon): remove type conversion code):crates/rundler/src/common/gas.rs
const NON_EIP_1559_CHAIN_IDS: &[u64] = &[
Chain::Arbitrum as u64,
Chain::ArbitrumNova as u64,
Expand Down
14 changes: 7 additions & 7 deletions crates/sim/src/gas/polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ use rundler_provider::Provider;
use serde::Deserialize;

#[derive(Debug)]
pub struct Polygon<P> {
pub(crate) struct Polygon<P> {
provider: Arc<P>,
gas_category: GasCategory,
}

#[derive(Clone, Copy, Deserialize, PartialEq)]
pub struct GasEstimate {
pub max_priority_fee: f64,
pub max_fee: f64,
pub(crate) struct GasEstimate {
pub(crate) max_priority_fee: f64,
pub(crate) max_fee: f64,
}

impl<P> Polygon<P>
where
P: Provider,
{
pub fn new(provider: Arc<P>) -> Self {
pub(crate) fn new(provider: Arc<P>) -> Self {
Self {
provider,
gas_category: GasCategory::Standard,
Expand All @@ -38,15 +38,15 @@ where
}

/// Estimates max and priority gas and converts to U256
pub async fn estimate_eip1559_fees(&self) -> Result<(U256, U256), ProviderError> {
pub(crate) async fn estimate_eip1559_fees(&self) -> Result<(U256, U256), ProviderError> {
let estimate = self.calculate_fees().await?;
let max = U256::from(estimate.max_fee.ceil() as u64);
let prio = U256::from(estimate.max_priority_fee.ceil() as u64);
Ok((max, prio))
}

/// Perform a request to the gas price API and deserialize the response.
pub async fn calculate_fees(&self) -> Result<GasEstimate, ProviderError> {
pub(crate) async fn calculate_fees(&self) -> Result<GasEstimate, ProviderError> {
let fee_history = self
.provider
.fee_history(15, BlockNumber::Latest, &[10.0, 25.0, 50.0])
Expand Down

0 comments on commit 9c7a83f

Please sign in to comment.