Skip to content

Commit

Permalink
fix: pool_orders rpc filters empty orders
Browse files Browse the repository at this point in the history
  • Loading branch information
AlastairHolmes committed Jan 2, 2024
1 parent ac6e256 commit 96251b6
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions state-chain/pallets/cf-pools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1819,18 +1819,22 @@ impl<T: Config> Pallet<T> {
.get(lp)
.into_iter()
.flat_map(|limit_orders| {
limit_orders.iter().map(|(id, tick)| {
limit_orders.iter().filter_map(|(id, tick)| {
let (collected, position_info) = pool
.pool_state
.limit_order(&(lp.clone(), *id), asset.sell_order(), *tick)
.unwrap();
LimitOrder {
lp: lp.clone(),
id: (*id).into(),
tick: *tick,
sell_amount: position_info.amount,
fees_earned: collected.accumulative_fees,
original_sell_amount: collected.original_amount,
if position_info.amount.is_zero() {
None
} else {
Some(LimitOrder {
lp: lp.clone(),
id: (*id).into(),
tick: *tick,
sell_amount: position_info.amount,
fees_earned: collected.accumulative_fees,
original_sell_amount: collected.original_amount,
})
}
})
})
Expand Down

0 comments on commit 96251b6

Please sign in to comment.