Skip to content

Commit

Permalink
Zero surplus fee for market orders (#2306)
Browse files Browse the repository at this point in the history
# Description
Follow up for #2305

My oversight where I suggested to just remove the filter. What we
actually want to do here is to still have all order executions to be
saved to db table `order_executions` (to have properly calculation of
`/api/v1/users/{address}/total_surplus`) but also, save the surplus_fee
of 0 for market orders because they don't have the surplus fee.
  • Loading branch information
sunce86 authored Jan 19, 2024
1 parent 78aab0a commit 83cea49
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/autopilot/src/on_settlement_event_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ impl OnSettlementEventUpdater {
// executed fees for each order execution
let order_executions = all_fees
.into_iter()
.map(|fee| (fee.order, fee.sell))
.zip(order_fees.iter())
.map(|(fee, (_, order_fee))| match order_fee {
// market orders have no surplus fee
Some(_) => (fee.order, 0.into()),
None => (fee.order, fee.sell),
})
.collect();
(fee, order_executions)
};
Expand Down

0 comments on commit 83cea49

Please sign in to comment.