Skip to content

Commit

Permalink
Remove rank by surplus config
Browse files Browse the repository at this point in the history
  • Loading branch information
sunce86 committed Mar 29, 2024
1 parent 2a6b916 commit 5ae444c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 58 deletions.
1 change: 0 additions & 1 deletion crates/driver/src/infra/config/file/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ pub async fn load(chain: eth::ChainId, path: &Path) -> infra::Config {
.unwrap(),
},
request_headers: config.request_headers,
rank_by_surplus_date: config.rank_by_surplus_date,
fee_handler: config.fee_handler,
}
}))
Expand Down
3 changes: 0 additions & 3 deletions crates/driver/src/infra/config/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ struct SolverConfig {
#[serde(default)]
request_headers: HashMap<String, String>,

/// Datetime when the CIP38 rank by surplus rules should be activated.
rank_by_surplus_date: Option<chrono::DateTime<chrono::Utc>>,

/// Determines whether the `solver` or the `driver` handles the fees
#[serde(default)]
fee_handler: FeeHandler,
Expand Down
18 changes: 2 additions & 16 deletions crates/driver/src/infra/solver/dto/solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,7 @@ impl Solutions {
})
.try_collect()?,
solver.clone(),
match solver_config
.rank_by_surplus_date
.is_some_and(|date| auction.deadline().driver() > date)
{
true => competition::solution::SolverScore::Surplus,
false => match solution.score {
Score::Solver { score } => {
competition::solution::SolverScore::Solver(score)
}
Score::RiskAdjusted {
success_probability,
} => competition::solution::SolverScore::RiskAdjusted(
success_probability,
),
},
},
competition::solution::SolverScore::Surplus,
weth,
solution.gas.map(|gas| eth::Gas(gas.into())),
solver_config.fee_handler,
Expand Down Expand Up @@ -238,6 +223,7 @@ pub struct Solution {
prices: HashMap<eth::H160, eth::U256>,
trades: Vec<Trade>,
interactions: Vec<Interaction>,
#[allow(dead_code)]
score: Score,
gas: Option<u64>,
}
Expand Down
2 changes: 0 additions & 2 deletions crates/driver/src/infra/solver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ pub struct Config {
pub timeouts: Timeouts,
/// HTTP headers that should be added to every request.
pub request_headers: HashMap<String, String>,
/// Datetime when the CIP38 rank by surplus rules should be activated.
pub rank_by_surplus_date: Option<chrono::DateTime<chrono::Utc>>,
/// Determines whether the `solver` or the `driver` handles the fees
pub fee_handler: FeeHandler,
}
Expand Down
37 changes: 16 additions & 21 deletions crates/driver/src/tests/cases/protocol_fees.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
use {
crate::{
domain::{competition::order, eth},
infra::config::file::FeeHandler,
tests::{
self,
cases::EtherExt,
setup::{
ab_adjusted_pool,
ab_liquidity_quote,
ab_order,
ab_solution,
fee::{Policy, Quote},
test_solver,
ExpectedOrderAmounts,
Test,
},
use crate::{
domain::{competition::order, eth},
infra::config::file::FeeHandler,
tests::{
self,
cases::EtherExt,
setup::{
ab_adjusted_pool,
ab_liquidity_quote,
ab_order,
ab_solution,
fee::{Policy, Quote},
test_solver,
ExpectedOrderAmounts,
Test,
},
},
chrono::{DateTime, Utc},
};

struct Amounts {
Expand Down Expand Up @@ -102,9 +99,7 @@ async fn protocol_fee_test_case(test_case: TestCase) {
.pool(pool)
.order(order.clone())
.solution(ab_solution())
.solvers(vec![test_solver()
.rank_by_surplus_date(DateTime::<Utc>::MIN_UTC)
.fee_handler(test_case.fee_handler)])
.solvers(vec![test_solver().fee_handler(test_case.fee_handler)])
.done()
.await;

Expand Down
5 changes: 0 additions & 5 deletions crates/driver/src/tests/setup/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ async fn create_config_file(
solving-share-of-deadline = {}
http-time-buffer = "{}ms"
fee-handler = {}
{}
"#,
solver.name,
addr,
Expand All @@ -234,10 +233,6 @@ async fn create_config_file(
solver.timeouts.solving_share_of_deadline.get(),
solver.timeouts.http_delay.num_milliseconds(),
serde_json::to_string(&solver.fee_handler).unwrap(),
solver.rank_by_surplus_date.map_or_else(
|| "".to_string(),
|timestamp| format!("rank-by-surplus-date = \"{}\"", timestamp.to_rfc3339())
),
)
.unwrap();
}
Expand Down
10 changes: 0 additions & 10 deletions crates/driver/src/tests/setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ pub struct Solver {
slippage: infra::solver::Slippage,
/// The fraction of time used for solving
timeouts: infra::solver::Timeouts,
/// Datetime when the CIP38 rank by surplus rules should be activated.
rank_by_surplus_date: Option<chrono::DateTime<chrono::Utc>>,
/// Determines whether the `solver` or the `driver` handles the fees
fee_handler: FeeHandler,
}
Expand All @@ -342,7 +340,6 @@ pub fn test_solver() -> Solver {
http_delay: chrono::Duration::from_std(default_http_time_buffer()).unwrap(),
solving_share_of_deadline: default_solving_share_of_deadline().try_into().unwrap(),
},
rank_by_surplus_date: None,
fee_handler: FeeHandler::default(),
}
}
Expand Down Expand Up @@ -373,13 +370,6 @@ impl Solver {
Self { balance, ..self }
}

pub fn rank_by_surplus_date(self, rank_by_surplus_date: chrono::DateTime<chrono::Utc>) -> Self {
Self {
rank_by_surplus_date: Some(rank_by_surplus_date),
..self
}
}

pub fn fee_handler(mut self, fee_handler: FeeHandler) -> Self {
self.fee_handler = fee_handler;
self
Expand Down

0 comments on commit 5ae444c

Please sign in to comment.