Serum: No health check needed after settle_funds
It just moves free funds from open_orders to the user account.
This commit is contained in:
parent
9fb16f3906
commit
63050c3661
|
@ -149,12 +149,12 @@ pub struct Serum3PlaceOrder<'info> {
|
|||
// TODO: Can we reduce the number of accounts by requiring the banks
|
||||
// to be in the remainingAccounts (where they need to be anyway, for
|
||||
// health checks - but they need to be mut)
|
||||
// Validated inline
|
||||
#[account(mut)]
|
||||
// token_index and bank.vault == vault is validated inline
|
||||
#[account(mut, has_one = group)]
|
||||
pub quote_bank: AccountLoader<'info, Bank>,
|
||||
#[account(mut)]
|
||||
pub quote_vault: Box<Account<'info, TokenAccount>>,
|
||||
#[account(mut)]
|
||||
#[account(mut, has_one = group)]
|
||||
pub base_bank: AccountLoader<'info, Bank>,
|
||||
#[account(mut)]
|
||||
pub base_vault: Box<Account<'info, TokenAccount>>,
|
||||
|
|
|
@ -39,17 +39,12 @@ pub struct Serum3SettleFunds<'info> {
|
|||
// needed for the automatic settle_funds call
|
||||
pub market_vault_signer: UncheckedAccount<'info>,
|
||||
|
||||
// TODO: do we need to pass both, or just payer?
|
||||
// TODO: if we potentially settle immediately, they all need to be mut?
|
||||
// TODO: Can we reduce the number of accounts by requiring the banks
|
||||
// to be in the remainingAccounts (where they need to be anyway, for
|
||||
// health checks - but they need to be mut)
|
||||
// Validated inline
|
||||
#[account(mut)]
|
||||
// token_index and bank.vault == vault is validated inline
|
||||
#[account(mut, has_one = group)]
|
||||
pub quote_bank: AccountLoader<'info, Bank>,
|
||||
#[account(mut)]
|
||||
pub quote_vault: Box<Account<'info, TokenAccount>>,
|
||||
#[account(mut)]
|
||||
#[account(mut, has_one = group)]
|
||||
pub base_bank: AccountLoader<'info, Bank>,
|
||||
#[account(mut)]
|
||||
pub base_vault: Box<Account<'info, TokenAccount>>,
|
||||
|
@ -109,8 +104,6 @@ pub fn serum3_settle_funds(ctx: Context<Serum3SettleFunds>) -> Result<()> {
|
|||
let before_base_vault = ctx.accounts.base_vault.amount;
|
||||
let before_quote_vault = ctx.accounts.quote_vault.amount;
|
||||
|
||||
// TODO: pre-health check
|
||||
|
||||
//
|
||||
// Settle
|
||||
//
|
||||
|
@ -140,15 +133,6 @@ pub fn serum3_settle_funds(ctx: Context<Serum3SettleFunds>) -> Result<()> {
|
|||
)?;
|
||||
}
|
||||
|
||||
//
|
||||
// Health check
|
||||
//
|
||||
let account = ctx.accounts.account.load()?;
|
||||
let health = compute_health(&account, &ctx.remaining_accounts)?;
|
||||
msg!("health: {}", health);
|
||||
// TODO: settle_funds should always succeed - check here if the health impact
|
||||
// brings a user back over the liquidation threshold?
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -900,10 +900,6 @@ impl<'keypair> ClientInstruction for Serum3SettleFundsInstruction<'keypair> {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
let health_check_metas =
|
||||
derive_health_check_remaining_account_metas(&account_loader, &account, None, false)
|
||||
.await;
|
||||
|
||||
let accounts = Self::Accounts {
|
||||
group: account.group,
|
||||
account: self.account,
|
||||
|
@ -922,9 +918,7 @@ impl<'keypair> ClientInstruction for Serum3SettleFundsInstruction<'keypair> {
|
|||
token_program: Token::id(),
|
||||
};
|
||||
|
||||
let mut instruction = make_instruction(program_id, &accounts, instruction);
|
||||
instruction.accounts.extend(health_check_metas.into_iter());
|
||||
|
||||
let instruction = make_instruction(program_id, &accounts, instruction);
|
||||
(accounts, instruction)
|
||||
}
|
||||
|
||||
|
@ -932,6 +926,7 @@ impl<'keypair> ClientInstruction for Serum3SettleFundsInstruction<'keypair> {
|
|||
vec![self.owner]
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CreatePerpMarketInstruction<'keypair> {
|
||||
pub group: Pubkey,
|
||||
pub mint: Pubkey,
|
||||
|
|
Loading…
Reference in New Issue