From ae08e979728f665632098d76d8f2a216a732febd Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Wed, 20 Nov 2024 01:02:07 +0000 Subject: [PATCH 1/8] allow pruning of anyones orders in force-closed markets --- programs/mango-v4/src/accounts_ix/mod.rs | 2 ++ .../src/accounts_ix/perp_prune_orders.rs | 27 +++++++++++++++++++ programs/mango-v4/src/instructions/mod.rs | 2 ++ .../src/instructions/perp_prune_orders.rs | 25 +++++++++++++++++ programs/mango-v4/src/lib.rs | 6 +++++ 5 files changed, 62 insertions(+) create mode 100644 programs/mango-v4/src/accounts_ix/perp_prune_orders.rs create mode 100644 programs/mango-v4/src/instructions/perp_prune_orders.rs diff --git a/programs/mango-v4/src/accounts_ix/mod.rs b/programs/mango-v4/src/accounts_ix/mod.rs index 9da159875..5e4d3d35a 100644 --- a/programs/mango-v4/src/accounts_ix/mod.rs +++ b/programs/mango-v4/src/accounts_ix/mod.rs @@ -44,6 +44,7 @@ pub use perp_liq_base_or_positive_pnl::*; pub use perp_liq_force_cancel_orders::*; pub use perp_liq_negative_pnl_or_bankruptcy::*; pub use perp_place_order::*; +pub use perp_prune_orders::*; pub use perp_settle_fees::*; pub use perp_settle_pnl::*; pub use perp_update_funding::*; @@ -125,6 +126,7 @@ mod perp_liq_base_or_positive_pnl; mod perp_liq_force_cancel_orders; mod perp_liq_negative_pnl_or_bankruptcy; mod perp_place_order; +mod perp_prune_orders; mod perp_settle_fees; mod perp_settle_pnl; mod perp_update_funding; diff --git a/programs/mango-v4/src/accounts_ix/perp_prune_orders.rs b/programs/mango-v4/src/accounts_ix/perp_prune_orders.rs new file mode 100644 index 000000000..d0052d75a --- /dev/null +++ b/programs/mango-v4/src/accounts_ix/perp_prune_orders.rs @@ -0,0 +1,27 @@ +use crate::state::{BookSide, Group, PerpMarket}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +pub struct PerpPruneOrders<'info> { + #[account()] + pub group: AccountLoader<'info, Group>, + + #[account( + mut, + has_one = group, + // owner is checked at #1 + )] + pub account: AccountLoader<'info, MangoAccountFixed>, + + #[account( + mut, + has_one = group, + has_one = bids, + has_one = asks, + )] + pub perp_market: AccountLoader<'info, PerpMarket>, + #[account(mut)] + pub bids: AccountLoader<'info, BookSide>, + #[account(mut)] + pub asks: AccountLoader<'info, BookSide>, +} diff --git a/programs/mango-v4/src/instructions/mod.rs b/programs/mango-v4/src/instructions/mod.rs index 68b8e9b4c..a2ae43b6b 100644 --- a/programs/mango-v4/src/instructions/mod.rs +++ b/programs/mango-v4/src/instructions/mod.rs @@ -34,6 +34,7 @@ pub use perp_liq_base_or_positive_pnl::*; pub use perp_liq_force_cancel_orders::*; pub use perp_liq_negative_pnl_or_bankruptcy::*; pub use perp_place_order::*; +pub use perp_prune_orders::*; pub use perp_settle_fees::*; pub use perp_settle_pnl::*; pub use perp_update_funding::*; @@ -106,6 +107,7 @@ mod perp_liq_base_or_positive_pnl; mod perp_liq_force_cancel_orders; mod perp_liq_negative_pnl_or_bankruptcy; mod perp_place_order; +mod perp_prune_orders; mod perp_settle_fees; mod perp_settle_pnl; mod perp_update_funding; diff --git a/programs/mango-v4/src/instructions/perp_prune_orders.rs b/programs/mango-v4/src/instructions/perp_prune_orders.rs new file mode 100644 index 000000000..7a7574991 --- /dev/null +++ b/programs/mango-v4/src/instructions/perp_prune_orders.rs @@ -0,0 +1,25 @@ +use anchor_lang::prelude::*; + +use crate::accounts_ix::*; +use crate::error::MangoError; +use crate::state::*; + +pub fn perp_prune_orders(ctx: Context, limit: u8) -> Result<()> { + let mut perp_market: PerpMarket = ctx.accounts.perp_market.load_mut()?; + // only allow pruning orders when market is in force-close + require!(perp_market.is_force_close(), MangoError::SomeError); + + let mut account = ctx.accounts.account.load_full_mut()?; + let mut book = Orderbook { + bids: ctx.accounts.bids.load_mut()?, + asks: ctx.accounts.asks.load_mut()?, + }; + + book.cancel_all_orders( + account, + &ctx.accounts.account.key(), + &mut perp_market, + limit, + None, + ) +} diff --git a/programs/mango-v4/src/lib.rs b/programs/mango-v4/src/lib.rs index 32fec2077..acf859791 100644 --- a/programs/mango-v4/src/lib.rs +++ b/programs/mango-v4/src/lib.rs @@ -1320,6 +1320,12 @@ pub mod mango_v4 { Ok(()) } + pub fn perp_prune_orders(ctx: Context, limit: u8) -> Result<()> { + #[cfg(feature = "enable-gpl")] + instructions::perp_prune_orders(ctx, limit)?; + Ok(()) + } + pub fn perp_consume_events(ctx: Context, limit: usize) -> Result<()> { #[cfg(feature = "enable-gpl")] instructions::perp_consume_events(ctx, limit)?; From 7516300bf026f9d2e711d1a2b686aaaa65694af4 Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Wed, 20 Nov 2024 01:04:32 +0000 Subject: [PATCH 2/8] add clarifying comment --- programs/mango-v4/src/accounts_ix/perp_prune_orders.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/mango-v4/src/accounts_ix/perp_prune_orders.rs b/programs/mango-v4/src/accounts_ix/perp_prune_orders.rs index d0052d75a..b67ee9420 100644 --- a/programs/mango-v4/src/accounts_ix/perp_prune_orders.rs +++ b/programs/mango-v4/src/accounts_ix/perp_prune_orders.rs @@ -9,7 +9,7 @@ pub struct PerpPruneOrders<'info> { #[account( mut, has_one = group, - // owner is checked at #1 + // owner is not checked on purpose )] pub account: AccountLoader<'info, MangoAccountFixed>, From 059e58926c78efc69e7fd0caa092229788a29dad Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Wed, 20 Nov 2024 02:00:36 +0000 Subject: [PATCH 3/8] ci fixes --- lib/client/src/client.rs | 3 +-- programs/mango-v4/src/accounts_ix/perp_prune_orders.rs | 2 +- programs/mango-v4/src/instructions/perp_prune_orders.rs | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/client/src/client.rs b/lib/client/src/client.rs index 7e1bc7a83..6fa8bb8e7 100644 --- a/lib/client/src/client.rs +++ b/lib/client/src/client.rs @@ -2599,8 +2599,7 @@ impl TransactionBuilder { } pub fn append(&mut self, prepared_instructions: PreparedInstructions) { - self.instructions - .extend(prepared_instructions.instructions); + self.instructions.extend(prepared_instructions.instructions); } } diff --git a/programs/mango-v4/src/accounts_ix/perp_prune_orders.rs b/programs/mango-v4/src/accounts_ix/perp_prune_orders.rs index b67ee9420..249827567 100644 --- a/programs/mango-v4/src/accounts_ix/perp_prune_orders.rs +++ b/programs/mango-v4/src/accounts_ix/perp_prune_orders.rs @@ -1,4 +1,4 @@ -use crate::state::{BookSide, Group, PerpMarket}; +use crate::state::{BookSide, Group, MangoAccountFixed, PerpMarket}; use anchor_lang::prelude::*; #[derive(Accounts)] diff --git a/programs/mango-v4/src/instructions/perp_prune_orders.rs b/programs/mango-v4/src/instructions/perp_prune_orders.rs index 7a7574991..1ffcb7f30 100644 --- a/programs/mango-v4/src/instructions/perp_prune_orders.rs +++ b/programs/mango-v4/src/instructions/perp_prune_orders.rs @@ -5,7 +5,7 @@ use crate::error::MangoError; use crate::state::*; pub fn perp_prune_orders(ctx: Context, limit: u8) -> Result<()> { - let mut perp_market: PerpMarket = ctx.accounts.perp_market.load_mut()?; + let mut perp_market = ctx.accounts.perp_market.load_mut()?; // only allow pruning orders when market is in force-close require!(perp_market.is_force_close(), MangoError::SomeError); From 3f3eca0bc99685f5827f979a3205249594d0ffaf Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Wed, 20 Nov 2024 02:14:21 +0000 Subject: [PATCH 4/8] fix clippy issuess --- programs/mango-v4/src/instructions/perp_prune_orders.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/mango-v4/src/instructions/perp_prune_orders.rs b/programs/mango-v4/src/instructions/perp_prune_orders.rs index 1ffcb7f30..6219eb105 100644 --- a/programs/mango-v4/src/instructions/perp_prune_orders.rs +++ b/programs/mango-v4/src/instructions/perp_prune_orders.rs @@ -16,8 +16,8 @@ pub fn perp_prune_orders(ctx: Context, limit: u8) -> Result<()> }; book.cancel_all_orders( - account, - &ctx.accounts.account.key(), + &mut account.borrow_mut(), + ctx.accounts.account.as_ref().key, &mut perp_market, limit, None, From 243e51a024e228d92a323b36259d7b98e15ffeaf Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Thu, 21 Nov 2024 18:19:22 +0000 Subject: [PATCH 5/8] implement perp purge position --- programs/mango-v4/src/accounts_ix/mod.rs | 2 + .../src/accounts_ix/perp_purge_position.rs | 27 ++++++ programs/mango-v4/src/instructions/mod.rs | 2 + .../src/instructions/perp_purge_position.rs | 93 +++++++++++++++++++ programs/mango-v4/src/lib.rs | 6 ++ 5 files changed, 130 insertions(+) create mode 100644 programs/mango-v4/src/accounts_ix/perp_purge_position.rs create mode 100644 programs/mango-v4/src/instructions/perp_purge_position.rs diff --git a/programs/mango-v4/src/accounts_ix/mod.rs b/programs/mango-v4/src/accounts_ix/mod.rs index 5e4d3d35a..f4b2d6f28 100644 --- a/programs/mango-v4/src/accounts_ix/mod.rs +++ b/programs/mango-v4/src/accounts_ix/mod.rs @@ -45,6 +45,7 @@ pub use perp_liq_force_cancel_orders::*; pub use perp_liq_negative_pnl_or_bankruptcy::*; pub use perp_place_order::*; pub use perp_prune_orders::*; +pub use perp_purge_position::*; pub use perp_settle_fees::*; pub use perp_settle_pnl::*; pub use perp_update_funding::*; @@ -127,6 +128,7 @@ mod perp_liq_force_cancel_orders; mod perp_liq_negative_pnl_or_bankruptcy; mod perp_place_order; mod perp_prune_orders; +mod perp_purge_position; mod perp_settle_fees; mod perp_settle_pnl; mod perp_update_funding; diff --git a/programs/mango-v4/src/accounts_ix/perp_purge_position.rs b/programs/mango-v4/src/accounts_ix/perp_purge_position.rs new file mode 100644 index 000000000..ffc4982ce --- /dev/null +++ b/programs/mango-v4/src/accounts_ix/perp_purge_position.rs @@ -0,0 +1,27 @@ +use anchor_lang::prelude::*; + +use crate::error::*; +use crate::state::*; + +#[derive(Accounts)] +pub struct PerpPurgePosition<'info> { + #[account()] + pub group: AccountLoader<'info, Group>, + + #[account( + mut, + has_one = group, + // owner is not checked on purpose + )] + pub account: AccountLoader<'info, MangoAccountFixed>, + + #[account(has_one = group)] + pub perp_market: AccountLoader<'info, PerpMarket>, + + #[account(mut, has_one = group)] + pub settle_bank: AccountLoader<'info, Bank>, + + /// CHECK: Oracle can have different account types + #[account(address = settle_bank.load()?.oracle)] + pub settle_oracle: UncheckedAccount<'info>, +} diff --git a/programs/mango-v4/src/instructions/mod.rs b/programs/mango-v4/src/instructions/mod.rs index a2ae43b6b..18d4f04bc 100644 --- a/programs/mango-v4/src/instructions/mod.rs +++ b/programs/mango-v4/src/instructions/mod.rs @@ -35,6 +35,7 @@ pub use perp_liq_force_cancel_orders::*; pub use perp_liq_negative_pnl_or_bankruptcy::*; pub use perp_place_order::*; pub use perp_prune_orders::*; +pub use perp_purge_position::*; pub use perp_settle_fees::*; pub use perp_settle_pnl::*; pub use perp_update_funding::*; @@ -108,6 +109,7 @@ mod perp_liq_force_cancel_orders; mod perp_liq_negative_pnl_or_bankruptcy; mod perp_place_order; mod perp_prune_orders; +mod perp_purge_position; mod perp_settle_fees; mod perp_settle_pnl; mod perp_update_funding; diff --git a/programs/mango-v4/src/instructions/perp_purge_position.rs b/programs/mango-v4/src/instructions/perp_purge_position.rs new file mode 100644 index 000000000..08ca98ccc --- /dev/null +++ b/programs/mango-v4/src/instructions/perp_purge_position.rs @@ -0,0 +1,93 @@ +use anchor_lang::prelude::*; +use fixed::types::I80F48; + +use crate::accounts_ix::*; +use crate::error::*; +use crate::logs::emit_perp_balances; +use crate::logs::emit_stack; +use crate::logs::TokenBalanceLog; +use crate::require_msg; +use crate::state::*; + +pub fn perp_purge_position(ctx: Context) -> Result<()> { + let perp_market = ctx.accounts.perp_market.load()?; + // only allow purging positions when market is in force-close + require!(perp_market.is_force_close(), MangoError::SomeError); + + let mut settle_bank = ctx.accounts.settle_bank.load_mut()?; + // Verify that the bank is the quote currency bank + require!( + settle_bank.token_index == perp_market.settle_token_index, + MangoError::InvalidBank + ); + + let mut account = ctx.accounts.account.load_full_mut()?; + let perp_position = account.perp_position_mut(perp_market.perp_market_index)?; + + // Base position needs to be zero'd out already and all orders closed + require_msg!( + perp_position.base_position_lots() == 0, + "perp position still has base lots" + ); + require_msg!( + perp_position.bids_base_lots == 0 && perp_position.asks_base_lots == 0, + "perp position still has open orders" + ); + require_msg!( + perp_position.taker_base_lots == 0 && perp_position.taker_quote_lots == 0, + "perp position still has events on event queue" + ); + + // Flush funding so that all remaining quote position is accounted for + perp_position.settle_funding(&perp_market); + let settlement = -perp_position.quote_position_native(); + + // only if there's negative pnl we settle directly with bank + // note: the positive pnl case is not implemented + if settlement != 0 { + require_msg!( + settlement > I80F48::ZERO, + "can only purge negative quote positions" + ); + + // Set perp quote to 0 + perp_position.record_settle(settlement, &perp_market); + emit_perp_balances( + ctx.accounts.group.key(), + ctx.accounts.account.key(), + perp_position, + &perp_market, + ); + + // Update the accounts' perp_spot_transfer statistics. + let settlement_i64 = settlement.round_to_zero().to_num::(); + perp_position.perp_spot_transfers += settlement_i64; + drop(perp_position); + account.fixed.perp_spot_transfers += settlement_i64; + + // Settle quote token balance + let token_position = account + .token_position_mut(perp_market.settle_token_index)? + .0; + let now_ts: u64 = Clock::get()?.unix_timestamp.try_into().unwrap(); + settle_bank.withdraw_without_fee(token_position, settlement, now_ts)?; + + emit_stack(TokenBalanceLog { + mango_group: ctx.accounts.group.key(), + mango_account: ctx.accounts.account.key(), + token_index: perp_market.settle_token_index, + indexed_position: token_position.indexed_position.to_bits(), + deposit_index: settle_bank.deposit_index.to_bits(), + borrow_index: settle_bank.borrow_index.to_bits(), + }); + } + + // clean up perp position to free up oracles for users and allow closing market + account.deactivate_perp_position_and_log( + perp_market.perp_market_index, + perp_market.settle_token_index, + ctx.accounts.account.key(), + )?; + + Ok(()) +} diff --git a/programs/mango-v4/src/lib.rs b/programs/mango-v4/src/lib.rs index acf859791..930dae84a 100644 --- a/programs/mango-v4/src/lib.rs +++ b/programs/mango-v4/src/lib.rs @@ -1015,6 +1015,12 @@ pub mod mango_v4 { Ok(()) } + pub fn perp_purge_position(ctx: Context) -> Result<()> { + #[cfg(feature = "enable-gpl")] + instructions::perp_purge_position(ctx)?; + Ok(()) + } + #[allow(clippy::too_many_arguments)] pub fn perp_place_order( ctx: Context, From 8ee331aad4d90efbb146213308633188595adf6d Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Thu, 21 Nov 2024 18:19:51 +0000 Subject: [PATCH 6/8] rename prune -> purge --- programs/mango-v4/src/accounts_ix/mod.rs | 4 ++-- .../{perp_prune_orders.rs => perp_purge_orders.rs} | 2 +- programs/mango-v4/src/instructions/mod.rs | 4 ++-- .../{perp_prune_orders.rs => perp_purge_orders.rs} | 2 +- programs/mango-v4/src/lib.rs | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) rename programs/mango-v4/src/accounts_ix/{perp_prune_orders.rs => perp_purge_orders.rs} (94%) rename programs/mango-v4/src/instructions/{perp_prune_orders.rs => perp_purge_orders.rs} (91%) diff --git a/programs/mango-v4/src/accounts_ix/mod.rs b/programs/mango-v4/src/accounts_ix/mod.rs index f4b2d6f28..1cd1b2a4e 100644 --- a/programs/mango-v4/src/accounts_ix/mod.rs +++ b/programs/mango-v4/src/accounts_ix/mod.rs @@ -44,7 +44,7 @@ pub use perp_liq_base_or_positive_pnl::*; pub use perp_liq_force_cancel_orders::*; pub use perp_liq_negative_pnl_or_bankruptcy::*; pub use perp_place_order::*; -pub use perp_prune_orders::*; +pub use perp_purge_orders::*; pub use perp_purge_position::*; pub use perp_settle_fees::*; pub use perp_settle_pnl::*; @@ -127,7 +127,7 @@ mod perp_liq_base_or_positive_pnl; mod perp_liq_force_cancel_orders; mod perp_liq_negative_pnl_or_bankruptcy; mod perp_place_order; -mod perp_prune_orders; +mod perp_purge_orders; mod perp_purge_position; mod perp_settle_fees; mod perp_settle_pnl; diff --git a/programs/mango-v4/src/accounts_ix/perp_prune_orders.rs b/programs/mango-v4/src/accounts_ix/perp_purge_orders.rs similarity index 94% rename from programs/mango-v4/src/accounts_ix/perp_prune_orders.rs rename to programs/mango-v4/src/accounts_ix/perp_purge_orders.rs index 249827567..0248848e7 100644 --- a/programs/mango-v4/src/accounts_ix/perp_prune_orders.rs +++ b/programs/mango-v4/src/accounts_ix/perp_purge_orders.rs @@ -2,7 +2,7 @@ use crate::state::{BookSide, Group, MangoAccountFixed, PerpMarket}; use anchor_lang::prelude::*; #[derive(Accounts)] -pub struct PerpPruneOrders<'info> { +pub struct PerpPurgeOrders<'info> { #[account()] pub group: AccountLoader<'info, Group>, diff --git a/programs/mango-v4/src/instructions/mod.rs b/programs/mango-v4/src/instructions/mod.rs index 18d4f04bc..0ecc0225f 100644 --- a/programs/mango-v4/src/instructions/mod.rs +++ b/programs/mango-v4/src/instructions/mod.rs @@ -34,7 +34,7 @@ pub use perp_liq_base_or_positive_pnl::*; pub use perp_liq_force_cancel_orders::*; pub use perp_liq_negative_pnl_or_bankruptcy::*; pub use perp_place_order::*; -pub use perp_prune_orders::*; +pub use perp_purge_orders::*; pub use perp_purge_position::*; pub use perp_settle_fees::*; pub use perp_settle_pnl::*; @@ -108,7 +108,7 @@ mod perp_liq_base_or_positive_pnl; mod perp_liq_force_cancel_orders; mod perp_liq_negative_pnl_or_bankruptcy; mod perp_place_order; -mod perp_prune_orders; +mod perp_purge_orders; mod perp_purge_position; mod perp_settle_fees; mod perp_settle_pnl; diff --git a/programs/mango-v4/src/instructions/perp_prune_orders.rs b/programs/mango-v4/src/instructions/perp_purge_orders.rs similarity index 91% rename from programs/mango-v4/src/instructions/perp_prune_orders.rs rename to programs/mango-v4/src/instructions/perp_purge_orders.rs index 6219eb105..11d1d8cbf 100644 --- a/programs/mango-v4/src/instructions/perp_prune_orders.rs +++ b/programs/mango-v4/src/instructions/perp_purge_orders.rs @@ -4,7 +4,7 @@ use crate::accounts_ix::*; use crate::error::MangoError; use crate::state::*; -pub fn perp_prune_orders(ctx: Context, limit: u8) -> Result<()> { +pub fn perp_purge_orders(ctx: Context, limit: u8) -> Result<()> { let mut perp_market = ctx.accounts.perp_market.load_mut()?; // only allow pruning orders when market is in force-close require!(perp_market.is_force_close(), MangoError::SomeError); diff --git a/programs/mango-v4/src/lib.rs b/programs/mango-v4/src/lib.rs index 930dae84a..8a4f7bffc 100644 --- a/programs/mango-v4/src/lib.rs +++ b/programs/mango-v4/src/lib.rs @@ -1326,9 +1326,9 @@ pub mod mango_v4 { Ok(()) } - pub fn perp_prune_orders(ctx: Context, limit: u8) -> Result<()> { + pub fn perp_purge_orders(ctx: Context, limit: u8) -> Result<()> { #[cfg(feature = "enable-gpl")] - instructions::perp_prune_orders(ctx, limit)?; + instructions::perp_purge_orders(ctx, limit)?; Ok(()) } From 03feed04bb8627465307b07aa68b26a691192a30 Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Thu, 21 Nov 2024 23:59:25 +0000 Subject: [PATCH 7/8] linter fixes --- programs/mango-v4/src/accounts_ix/perp_purge_position.rs | 1 - programs/mango-v4/src/instructions/perp_purge_position.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/programs/mango-v4/src/accounts_ix/perp_purge_position.rs b/programs/mango-v4/src/accounts_ix/perp_purge_position.rs index ffc4982ce..a4122cd71 100644 --- a/programs/mango-v4/src/accounts_ix/perp_purge_position.rs +++ b/programs/mango-v4/src/accounts_ix/perp_purge_position.rs @@ -1,6 +1,5 @@ use anchor_lang::prelude::*; -use crate::error::*; use crate::state::*; #[derive(Accounts)] diff --git a/programs/mango-v4/src/instructions/perp_purge_position.rs b/programs/mango-v4/src/instructions/perp_purge_position.rs index 08ca98ccc..ebcd5210a 100644 --- a/programs/mango-v4/src/instructions/perp_purge_position.rs +++ b/programs/mango-v4/src/instructions/perp_purge_position.rs @@ -62,7 +62,7 @@ pub fn perp_purge_position(ctx: Context) -> Result<()> { // Update the accounts' perp_spot_transfer statistics. let settlement_i64 = settlement.round_to_zero().to_num::(); perp_position.perp_spot_transfers += settlement_i64; - drop(perp_position); + drop(*perp_position); account.fixed.perp_spot_transfers += settlement_i64; // Settle quote token balance From 8e8d91d22a0a38d7c4bb58dadbd823dae601b345 Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Fri, 22 Nov 2024 23:20:06 +0000 Subject: [PATCH 8/8] remove unneeded drop --- programs/mango-v4/src/instructions/perp_purge_position.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/programs/mango-v4/src/instructions/perp_purge_position.rs b/programs/mango-v4/src/instructions/perp_purge_position.rs index ebcd5210a..a8cac19a7 100644 --- a/programs/mango-v4/src/instructions/perp_purge_position.rs +++ b/programs/mango-v4/src/instructions/perp_purge_position.rs @@ -62,7 +62,6 @@ pub fn perp_purge_position(ctx: Context) -> Result<()> { // Update the accounts' perp_spot_transfer statistics. let settlement_i64 = settlement.round_to_zero().to_num::(); perp_position.perp_spot_transfers += settlement_i64; - drop(*perp_position); account.fixed.perp_spot_transfers += settlement_i64; // Settle quote token balance