From d3db44e7ba063f736718eca4123420d071b0185d Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Fri, 9 Dec 2022 16:16:14 +0100 Subject: [PATCH] Client: Fix liq health accounts: no duplicate perp markets --- client/src/context.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/client/src/context.rs b/client/src/context.rs index bfa507210..8e9bd4094 100644 --- a/client/src/context.rs +++ b/client/src/context.rs @@ -293,14 +293,18 @@ impl MangoGroupContext { .active_serum3_orders() .chain(account1.active_serum3_orders()) .map(|&s| s.open_orders); - let perp_markets = account2 + let perp_market_indexes = account2 .active_perp_positions() .chain(account1.active_perp_positions()) - .map(|&pa| self.perp_market_address(pa.market_index)); - let perp_oracles = account2 - .active_perp_positions() - .chain(account1.active_perp_positions()) - .map(|&pa| self.perp(pa.market_index).market.oracle); + .map(|&pa| pa.market_index) + .unique() + .collect::>(); + let perp_markets = perp_market_indexes + .iter() + .map(|&index| self.perp_market_address(index)); + let perp_oracles = perp_market_indexes + .iter() + .map(|&index| self.perp(index).market.oracle); let to_account_meta = |pubkey| AccountMeta { pubkey,