Skip to content

Commit

Permalink
Fix buy branch
Browse files Browse the repository at this point in the history
  • Loading branch information
squadgazzz committed Feb 8, 2024
1 parent 6493f9a commit a11312c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/driver/src/domain/competition/solution/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,11 @@ fn adjusted_price_improvement_amounts(
Ok((order_sell_amount, buy_amount))
}
Side::Buy => {
let scaling_factor = order_buy_amount
let scaled_sell_amount = quote_sell_amount
.checked_mul(order_buy_amount)
.ok_or(Error::Overflow)?
.checked_div(quote.buy_amount)
.ok_or(Error::DivisionByZero)?;
let scaled_sell_amount = scaling_factor
.checked_mul(quote_sell_amount)
.ok_or(Error::Overflow)?;
let sell_amount = order_sell_amount.min(scaled_sell_amount);
Ok((sell_amount, order_buy_amount))
}
Expand Down

0 comments on commit a11312c

Please sign in to comment.