Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ impl RunLoop {
.map(|(index, bid)| SolverSettlement {
solver: bid.driver().name.clone(),
solver_address: bid.solution().solver(),
score: Some(Score::Solver(bid.score().get().0)),
score: Some(Score::Protocol(bid.score().get().0)),
ranking: index + 1,
orders: bid
.solution()
Expand Down
4 changes: 1 addition & 3 deletions crates/driver/src/domain/competition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,9 @@ impl Competition {
let scored: Vec<(Solved, Settlement)> = scores
.into_iter()
.sorted_by_key(|(score, _)| Reverse(*score))
.map(|(score, settlement)| {
.map(|(_, settlement)| {
let solved = Solved {
id: settlement.solution().clone(),
score,
trades: settlement.orders(),
prices: settlement.prices(),
gas: Some(settlement.gas.estimate),
Expand Down Expand Up @@ -1009,7 +1008,6 @@ fn merge(
#[derive(Debug)]
pub struct Solved {
pub id: solution::Id,
pub score: eth::Ether,
pub trades: HashMap<order::Uid, Amounts>,
pub prices: HashMap<eth::TokenAddress, eth::TokenAmount>,
pub gas: Option<eth::Gas>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ impl Solution {
pub fn new(solution_id: u64, solved: competition::Solved, solver: &Solver) -> Self {
Self {
solution_id,
score: solved.score.0,
submission_address: solver.address(),
orders: solved
.trades
Expand Down Expand Up @@ -72,8 +71,6 @@ pub struct Solution {
/// in subsequent requests (reveal, settle).
solution_id: u64,
submission_address: eth::Address,
#[serde_as(as = "serde_ext::U256")]
score: eth::U256,
#[serde_as(as = "HashMap<serde_ext::Hex, _>")]
orders: HashMap<OrderId, TradedOrder>,
#[serde_as(as = "HashMap<_, serde_ext::U256>")]
Expand Down
40 changes: 0 additions & 40 deletions crates/driver/src/tests/cases/haircut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ async fn order_haircut_reduces_score() {
.await;

let solve_no_haircut = test_no_haircut.solve().await.ok();
let score_no_haircut = solve_no_haircut.score();

// Now test with 500 bps (5%) haircut
let test_with_haircut = tests::setup()
Expand All @@ -71,22 +70,6 @@ async fn order_haircut_reduces_score() {
.await;

let solve_with_haircut = test_with_haircut.solve().await.ok();
let score_with_haircut = solve_with_haircut.score();

// With 500 bps (5%) haircut, the score should be reduced by approximately 5%.
// Compute the actual percentage: (score_with_haircut * 100) / score_no_haircut
// Should be approximately 95 (allowing 94-96 range for tolerance).
let percentage: u64 = ((score_with_haircut * eth::U256::from(100)) / score_no_haircut)
.try_into()
.unwrap();

assert!(
(94..=96).contains(&percentage),
"Haircut score {} should be ~95% of baseline {}, but was {}%",
score_with_haircut,
score_no_haircut,
percentage
);

// Extract executedBuy from baseline (no haircut)
let solution_no_haircut = solve_no_haircut.solution();
Expand Down Expand Up @@ -192,7 +175,6 @@ async fn buy_order_haircut() {
.await;

let solve_no_haircut = test_no_haircut.solve().await.ok();
let score_no_haircut = solve_no_haircut.score();

let test_with_haircut = tests::setup()
.name("Buy order haircut - with 500 bps")
Expand All @@ -211,28 +193,6 @@ async fn buy_order_haircut() {
.await;

let solve_with_haircut = test_with_haircut.solve().await.ok();
let score_with_haircut = solve_with_haircut.score();

// For buy orders, the haircut is applied to the executed buy amount and then
// converted to sell token. The impact on score depends on the price ratio.
// With 500 bps (5%) haircut on a 2 ETH buy amount, the haircut is 0.1 ETH in
// buy token. When converted to sell token at the pool's price ratio, this
// results in a smaller percentage impact on the score compared to sell
// orders. Expected: score reduction of ~1% (percentage ~99%) rather than
// 5%.
let percentage: u64 = ((score_with_haircut * eth::U256::from(100)) / score_no_haircut)
.try_into()
.unwrap();

// For buy orders with this setup, expect ~99% (1% reduction) due to price
// conversion
assert!(
(98..=100).contains(&percentage) && score_with_haircut < score_no_haircut,
"Haircut score {} should be ~99% of baseline {} (reduced by ~1%), but was {}%",
score_with_haircut,
score_no_haircut,
percentage
);

// Extract executedSell from baseline (no haircut)
let solution_no_haircut = solve_no_haircut.solution();
Expand Down
10 changes: 0 additions & 10 deletions crates/driver/src/tests/cases/jit_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ struct JitOrder {

struct Solution {
jit_order: JitOrder,
expected_score: eth::U256,
}

struct TestCase {
Expand All @@ -55,8 +54,6 @@ struct TestCase {

#[cfg(test)]
async fn protocol_fee_test_case(test_case: TestCase) {
use number::testing::ApproxEq;

let test_name = format!("JIT Order: {:?}", test_case.solution.jit_order.order.side);
// Adjust liquidity pools so that the order is executable at the amounts
// expected from the solver.
Expand Down Expand Up @@ -116,11 +113,6 @@ async fn protocol_fee_test_case(test_case: TestCase) {
.await;

let result = test.solve().await.ok();
assert!(
result
.score()
.is_approx_eq(&test_case.solution.expected_score, None),
);
result.jit_orders(&[jit_order]);
}

Expand Down Expand Up @@ -156,7 +148,6 @@ async fn surplus_protocol_fee_jit_order_from_surplus_capturing_owner_not_capped(
},
// Surplus is 40 ETH worth of sell tokens, converted to buy tokens using the order's
// limit price (50 / 60 = 80%) this leaves us with a score of 32 ETH.
expected_score: 32.ether().into_wei(),
},
};

Expand Down Expand Up @@ -195,7 +186,6 @@ async fn surplus_protocol_fee_jit_order_not_capped() {
},
// Surplus is 20 ETH worth of sell tokens, converted to buy tokens using the order's
// limit price (40 / 50 = 80%) this leaves us with a score of 16 ETH.
expected_score: 16.ether().into_wei(),
},
};

Expand Down
Loading
Loading