Skip to content
Open
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
5 changes: 0 additions & 5 deletions crates/autopilot/src/domain/competition/winner_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ impl From<&Solution> for winsel::Solution<winsel::Unscored> {
.iter()
.map(|(uid, order)| to_winsel_order(*uid, order))
.collect(),
solution
.prices()
.iter()
.map(|(token, price)| (Address::from(*token), price.get().0))
.collect(),
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/autopilot/src/domain/settlement/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ mod tests {
.collect(),
native_prices: prices.clone(),
};
let solution = ws::Solution::new(0, ws::Address::ZERO, vec![order], prices);
let solution = ws::Solution::new(0, ws::Address::ZERO, vec![order]);
let arbitrator = ws::Arbitrator {
max_winners: 1,
weth: ws::Address::ZERO,
Expand Down
9 changes: 3 additions & 6 deletions crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,9 @@ impl RunLoop {
buy_amount: order.executed_buy.0,
})
.collect(),
clearing_prices: bid
.solution()
.prices()
.iter()
.map(|(token, price)| (Address::from(*token), price.get().0))
.collect(),
// Always empty — kept to avoid breaking the solver competition
// API (`/api/v1/solver_competition`).
clearing_prices: Default::default(),
is_winner: bid.is_winner(),
filtered_out: bid.is_filtered_out(),
})
Expand Down
18 changes: 2 additions & 16 deletions crates/winner-selection/src/arbitrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl Arbitrator {
continue;
}

let score = self.compute_order_score(order, solution, context)?;
let score = self.compute_order_score(order, context)?;

let token_pair = DirectedTokenPair {
sell: order.sell_token,
Expand All @@ -202,26 +202,12 @@ impl Arbitrator {
/// Follows CIP-38 as the base of the score computation.
///
/// Denominated in NATIVE token.
fn compute_order_score<T>(
&self,
order: &Order,
solution: &Solution<T>,
context: &AuctionContext,
) -> Result<U256> {
fn compute_order_score(&self, order: &Order, context: &AuctionContext) -> Result<U256> {
let native_price_buy = context
.native_prices
.get(&order.buy_token)
.context("missing native price for buy token")?;

let _uniform_sell_price = solution
.prices()
.get(&order.sell_token)
.context("missing uniform clearing price for sell token")?;
let _uniform_buy_price = solution
.prices()
.get(&order.buy_token)
.context("missing uniform clearing price for buy token")?;

let custom_prices = self.calculate_custom_prices_from_executed(order);

// Calculate surplus in surplus token (buy token for sell orders, sell token for
Expand Down
22 changes: 1 addition & 21 deletions crates/winner-selection/src/solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use {
state,
},
alloy_primitives::{Address, U256},
std::collections::HashMap,
};
pub type Scored = state::Scored<U256>;
pub type Ranked = state::Ranked<U256>;
Expand All @@ -30,13 +29,6 @@ pub struct Solution<State> {
/// Orders executed in this solution.
orders: Vec<Order>,

/// Uniform clearing prices for all tokens in the solution.
///
/// Maps token address to its price in the native token.
/// These are the prices at which all orders trading these tokens are
/// settled.
prices: HashMap<Address, U256>,

/// State marker (score and ranking information).
state: State,
}
Expand All @@ -56,11 +48,6 @@ impl<T> Solution<T> {
pub fn orders(&self) -> &[Order] {
&self.orders
}

/// Get the clearing prices.
pub fn prices(&self) -> &HashMap<Address, U256> {
&self.prices
}
}

impl<State> state::HasState for Solution<State> {
Expand All @@ -72,7 +59,6 @@ impl<State> state::HasState for Solution<State> {
id: self.id,
solver: self.solver,
orders: self.orders,
prices: self.prices,
state,
}
}
Expand All @@ -84,17 +70,11 @@ impl<State> state::HasState for Solution<State> {

impl Solution<Unscored> {
/// Create a new unscored solution.
pub fn new(
id: u64,
solver: Address,
orders: Vec<Order>,
prices: HashMap<Address, U256>,
) -> Self {
pub fn new(id: u64, solver: Address, orders: Vec<Order>) -> Self {
Self {
id,
solver,
orders,
prices,
state: Unscored,
}
}
Expand Down
Loading