Skip to content

Commit

Permalink
[EASY] Fix ceil_div in scoring (#2566)
Browse files Browse the repository at this point in the history
# Description
Fixes #2555

[Previously](#2464) we fixed
the ceil_div in SettlementEncoder, however the similar fix is needed in
scoring module.

## How to test
Added temporary unit tests just to prove the fix is right. 

8ec61b2

Two multiplication unit tests prove that there is a difference in the
sell price => difference between `21487` and `21488` when using the
problematic settlement.

Then, added scoring test for the problematic settlement which proves
that this difference causes the final score difference
`66264322342847212` and `66309509871089417`.
  • Loading branch information
sunce86 authored Mar 26, 2024
1 parent 62999f1 commit c9f3f24
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/driver/src/domain/competition/solution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use {
solver::Solver,
Simulator,
},
util::conv::u256::U256Ext,
},
futures::future::try_join_all,
itertools::Itertools,
Expand Down Expand Up @@ -156,7 +157,7 @@ impl Solution {
.0
.checked_mul(uniform_prices.sell)
.ok_or(error::Math::Overflow)?
.checked_div(uniform_prices.buy)
.checked_ceil_div(&uniform_prices.buy)
.ok_or(error::Math::DivisionByZero)?,
order::Side::Buy => trade.executed().0,
},
Expand Down

0 comments on commit c9f3f24

Please sign in to comment.