Skip to content

Commit

Permalink
Use same OrderConverter for solvers and AuctionConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinquaXD committed Aug 9, 2022
1 parent caa25db commit cb029c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
21 changes: 10 additions & 11 deletions crates/driver/src/auction_converter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use anyhow::{Context, Result};
use contracts::WETH9;
use gas_estimation::GasPriceEstimating;
use model::auction::Auction as AuctionModel;
use primitive_types::H160;
Expand Down Expand Up @@ -27,7 +26,7 @@ pub trait AuctionConverting: Send + Sync {
}

pub struct AuctionConverter {
pub order_converter: OrderConverter,
pub order_converter: Arc<OrderConverter>,
pub gas_price_estimator: Arc<dyn GasPriceEstimating>,
pub native_token: H160,
pub run: AtomicU64,
Expand All @@ -36,20 +35,16 @@ pub struct AuctionConverter {

impl AuctionConverter {
pub fn new(
native_token: WETH9,
gas_price_estimator: Arc<dyn GasPriceEstimating>,
fee_objective_scaling_factor: f64,
liquidity_collector: Box<dyn LiquidityCollecting>,
order_converter: Arc<OrderConverter>,
) -> Self {
Self {
order_converter: OrderConverter {
native_token: native_token.clone(),
fee_objective_scaling_factor,
},
gas_price_estimator,
native_token: native_token.address(),
native_token: order_converter.native_token.address(),
run: AtomicU64::default(),
liquidity_collector,
order_converter,
}
}
}
Expand Down Expand Up @@ -121,6 +116,7 @@ impl AuctionConverting for AuctionConverter {
#[cfg(test)]
mod tests {
use super::*;
use contracts::WETH9;
use gas_estimation::GasPrice1559;
use maplit::btreemap;
use model::{
Expand Down Expand Up @@ -195,11 +191,14 @@ mod tests {
settlement_handling: Arc::new(DummySettlementHandler),
})])
});
let order_converter = Arc::new(OrderConverter {
native_token: native_token.clone(),
fee_objective_scaling_factor: 2.,
});
let converter = AuctionConverter::new(
native_token.clone(),
gas_estimator,
2.,
Box::new(liquidity_collector),
order_converter,
);
let mut model = AuctionModel {
block: 1,
Expand Down
3 changes: 1 addition & 2 deletions crates/driver/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,9 @@ async fn build_auction_converter(
uniswap_v3_liquidity,
});
Ok(Arc::new(AuctionConverter::new(
common.native_token_contract.clone(),
common.gas_price_estimator.clone(),
args.fee_objective_scaling_factor,
liquidity_collector,
common.order_converter.clone(),
)))
}

Expand Down

0 comments on commit cb029c5

Please sign in to comment.