Skip to content

Commit

Permalink
Rework comments
Browse files Browse the repository at this point in the history
  • Loading branch information
m-lord-renkse committed May 13, 2024
1 parent c2b3219 commit b39093c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
7 changes: 2 additions & 5 deletions crates/driver/src/domain/competition/auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Auction {
tokens: impl Iterator<Item = Token>,
deadline: time::Deadline,
eth: &Ethereum,
surplus_capturing_jit_order_owners: &HashSet<eth::Address>,
surplus_capturing_jit_order_owners: HashSet<eth::Address>,
) -> Result<Self, Error> {
let tokens = Tokens(tokens.map(|token| (token.address, token)).collect());

Expand All @@ -66,10 +66,7 @@ impl Auction {
tokens,
gas_price: eth.gas_price().await?,
deadline,
surplus_capturing_jit_order_owners: surplus_capturing_jit_order_owners
.iter()
.cloned()
.collect(),
surplus_capturing_jit_order_owners,
})
}

Expand Down
12 changes: 5 additions & 7 deletions crates/driver/src/domain/competition/solution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl Solution {
self.gas
}

fn trade_count_for_scoring(
fn trade_count_for_scorable(
&self,
trade: &Trade,
surplus_capturing_jit_order_owners: &HashSet<eth::Address>,
Expand All @@ -156,11 +156,9 @@ impl Solution {
surplus_capturing_jit_order_owners: &HashSet<eth::Address>,
) -> Result<eth::Ether, error::Scoring> {
let mut trades = Vec::with_capacity(self.trades.len());
for trade in self
.trades()
.iter()
.filter(|trade| self.trade_count_for_scoring(trade, surplus_capturing_jit_order_owners))
{
for trade in self.trades().iter().filter(|trade| {
self.trade_count_for_scorable(trade, surplus_capturing_jit_order_owners)
}) {
// Solver generated fulfillment does not include the fee in the executed amount
// for sell orders.
let executed = match trade.side() {
Expand Down Expand Up @@ -218,7 +216,7 @@ impl Solution {
!self
.trades
.iter()
.any(|trade| self.trade_count_for_scoring(trade, surplus_capturing_jit_order_owners))
.any(|trade| self.trade_count_for_scorable(trade, surplus_capturing_jit_order_owners))
}

pub fn merge(&self, other: &Self) -> Result<Self, error::Merge> {
Expand Down
2 changes: 1 addition & 1 deletion crates/driver/src/domain/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl Order {
.into_iter(),
self.deadline,
eth,
&HashSet::default(),
HashSet::default(),
)
.await
.map_err(|err| match err {
Expand Down
7 changes: 3 additions & 4 deletions crates/driver/src/infra/api/routes/solve/dto/auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ impl Auction {
}),
time::Deadline::new(self.deadline, timeouts),
eth,
&self
.surplus_capturing_jit_order_owners
.unwrap_or_default()
self.surplus_capturing_jit_order_owners
.into_iter()
.map(Into::into)
.collect::<HashSet<_>>(),
Expand Down Expand Up @@ -203,7 +201,8 @@ pub struct Auction {
tokens: Vec<Token>,
orders: Vec<Order>,
deadline: chrono::DateTime<chrono::Utc>,
surplus_capturing_jit_order_owners: Option<Vec<eth::H160>>,
#[serde(default)]
surplus_capturing_jit_order_owners: Vec<eth::H160>,
}

impl Auction {
Expand Down

0 comments on commit b39093c

Please sign in to comment.