Skip to content

Commit

Permalink
Store all orders in order_execution table (#2305)
Browse files Browse the repository at this point in the history
# Description
This PR addresses the issue identified in Sepolia where `total_surplus`
was not computed correctly due to missing `order_uids` in the
`order_execution` table. This miscomputation was a consequence of
[recent changes](#2190) in
the workings of the `order_execution` table. The identified problem
impacted the `/api/v1/users/{address}/total_surplus` endpoint, leading
to lower-than-expected surplus values. This fix aims to ensure accurate
surplus computation by addressing the data retrieval process in the
database.

# Changes
After thorough consideration, it was decided to go with the option of
reverting the change and saving `order_executions` for all trades. The
alternative of building a complicated subquery was deemed overly complex
and unnecessary, especially given the context of moving towards a system
where all orders are limit orders. This simplification aligns with the
future direction and maintains system efficiency.

## How to test

#2267

## Related Issues

Fixes #2289
  • Loading branch information
squadgazzz authored Jan 19, 2024
1 parent f599246 commit 78aab0a
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions crates/autopilot/src/on_settlement_event_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,7 @@ impl OnSettlementEventUpdater {
// executed fees for each order execution
let order_executions = all_fees
.into_iter()
.zip(order_fees.iter())
.filter_map(|(fee, (_, order_fee))| match order_fee {
// filter out orders with order_fee
// since their fee can already be fetched from the database table
// `orders` so no point in storing the same
// value twice, in another table
Some(_) => None,
None => Some((fee.order, fee.sell)),
})
.map(|fee| (fee.order, fee.sell))
.collect();
(fee, order_executions)
};
Expand Down

0 comments on commit 78aab0a

Please sign in to comment.