Add comments

This commit is contained in:
Christian Kamm 2022-03-19 08:53:20 +01:00
parent 9475d9545c
commit 9fb16f3906
2 changed files with 9 additions and 1 deletions

View File

@ -57,6 +57,11 @@ pub struct Serum3SettleFunds<'info> {
pub token_program: Program<'info, Token>, 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<Serum3SettleFunds>) -> Result<()> { pub fn serum3_settle_funds(ctx: Context<Serum3SettleFunds>) -> Result<()> {
// //
// Validation // Validation
@ -141,7 +146,8 @@ pub fn serum3_settle_funds(ctx: Context<Serum3SettleFunds>) -> Result<()> {
let account = ctx.accounts.account.load()?; let account = ctx.accounts.account.load()?;
let health = compute_health(&account, &ctx.remaining_accounts)?; let health = compute_health(&account, &ctx.remaining_accounts)?;
msg!("health: {}", health); 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(()) Ok(())
} }

View File

@ -10,6 +10,8 @@ use crate::state::*;
// more perp markets open at the same time etc // 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, // 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 // 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_INDEXED_POSITIONS: usize = 16;
const MAX_SERUM_OPEN_ORDERS: usize = 8; const MAX_SERUM_OPEN_ORDERS: usize = 8;