Add separate function for scale gas price
@@ -272,6 +272,13 @@ impl<API: FeeTickerAPI, INFO: FeeTickerInfo, WATCHER: TokenWatcher> FeeTicker<AP
}
}
+ /// Increases the gas price by a constant coefficient.
+ /// Due to the high volatility of gas prices, we are include the risk
+ /// in the fee in order not to go into negative territory.
+ fn risk_gas_price_estimate(gas_price: BigUint) -> BigUint {
+ gas_price * BigUint::from(130u32) / BigUint::from(100u32)
+ }
+
async fn run(mut self) {
while let Some(request) = self.requests.next().await {
let start = Instant::now();
@@ -401,7 +408,7 @@ impl<API: FeeTickerAPI, INFO: FeeTickerInfo, WATCHER: TokenWatcher> FeeTicker<AP
}
};
let gas_price_wei = self.api.get_gas_price_wei().await?;
- let scale_gas_price = gas_price_wei.clone() * BigUint::from(130u32) / BigUint::from(100u32);
+ let scale_gas_price = Self::risk_gas_price_estimate(gas_price_wei.clone());
let wei_price_usd = self.api.get_last_quote(TokenLike::Id(0)).await?.usd_price
/ BigUint::from(10u32).pow(18u32);
