From 9fb16f3906a0b5302d59d4e7e56dcd81c8c29892 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Sat, 19 Mar 2022 08:53:20 +0100 Subject: [PATCH] Add comments --- programs/mango-v4/src/instructions/serum3_settle_funds.rs | 8 +++++++- programs/mango-v4/src/state/mango_account.rs | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/programs/mango-v4/src/instructions/serum3_settle_funds.rs b/programs/mango-v4/src/instructions/serum3_settle_funds.rs index 4a9d9b412..9006be1f5 100644 --- a/programs/mango-v4/src/instructions/serum3_settle_funds.rs +++ b/programs/mango-v4/src/instructions/serum3_settle_funds.rs @@ -57,6 +57,11 @@ pub struct Serum3SettleFunds<'info> { pub token_program: Program<'info, Token>, } +/// Settling means moving free funds from the serum3 open orders account +/// back into the mango account wallet. +/// +/// There will be free funds on open_orders when an order was triggered. +/// pub fn serum3_settle_funds(ctx: Context) -> Result<()> { // // Validation @@ -141,7 +146,8 @@ pub fn serum3_settle_funds(ctx: Context) -> Result<()> { let account = ctx.accounts.account.load()?; let health = compute_health(&account, &ctx.remaining_accounts)?; msg!("health: {}", health); - require!(health >= 0, MangoError::SomeError); + // TODO: settle_funds should always succeed - check here if the health impact + // brings a user back over the liquidation threshold? Ok(()) } diff --git a/programs/mango-v4/src/state/mango_account.rs b/programs/mango-v4/src/state/mango_account.rs index cdb093884..883c3ebf7 100644 --- a/programs/mango-v4/src/state/mango_account.rs +++ b/programs/mango-v4/src/state/mango_account.rs @@ -10,6 +10,8 @@ use crate::state::*; // more perp markets open at the same time etc // In particular if perp markets don't require the base token to be active on the account, // we could probably support 1 token (quote currency) + 15 active perp markets at the same time +// It's a tradeoff between allowing users to trade on many markets with one account, +// MangoAccount size and health compute needs. const MAX_INDEXED_POSITIONS: usize = 16; const MAX_SERUM_OPEN_ORDERS: usize = 8;