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
|
@ -147,14 +147,14 @@ pub struct Serum3PlaceOrder<'info> {
|
||||||
// TODO: do we need to pass both, or just payer?
|
// TODO: do we need to pass both, or just payer?
|
||||||
// TODO: if we potentially settle immediately, they all need to be mut?
|
// TODO: if we potentially settle immediately, they all need to be mut?
|
||||||
// TODO: Can we reduce the number of accounts by requiring the banks
|
// TODO: Can we reduce the number of accounts by requiring the banks
|
||||||
// to be in the remainingAccounts (where they need to be anyway, for
|
// to be in the remainingAccounts (where they need to be anyway, for
|
||||||
// health checks - but they need to be mut)
|
// health checks - but they need to be mut)
|
||||||
// Validated inline
|
// token_index and bank.vault == vault is validated inline
|
||||||
#[account(mut)]
|
#[account(mut, has_one = group)]
|
||||||
pub quote_bank: AccountLoader<'info, Bank>,
|
pub quote_bank: AccountLoader<'info, Bank>,
|
||||||
#[account(mut)]
|
#[account(mut)]
|
||||||
pub quote_vault: Box<Account<'info, TokenAccount>>,
|
pub quote_vault: Box<Account<'info, TokenAccount>>,
|
||||||
#[account(mut)]
|
#[account(mut, has_one = group)]
|
||||||
pub base_bank: AccountLoader<'info, Bank>,
|
pub base_bank: AccountLoader<'info, Bank>,
|
||||||
#[account(mut)]
|
#[account(mut)]
|
||||||
pub base_vault: Box<Account<'info, TokenAccount>>,
|
pub base_vault: Box<Account<'info, TokenAccount>>,
|
||||||
|
|
|
@ -39,17 +39,12 @@ pub struct Serum3SettleFunds<'info> {
|
||||||
// needed for the automatic settle_funds call
|
// needed for the automatic settle_funds call
|
||||||
pub market_vault_signer: UncheckedAccount<'info>,
|
pub market_vault_signer: UncheckedAccount<'info>,
|
||||||
|
|
||||||
// TODO: do we need to pass both, or just payer?
|
// token_index and bank.vault == vault is validated inline
|
||||||
// TODO: if we potentially settle immediately, they all need to be mut?
|
#[account(mut, has_one = group)]
|
||||||
// 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)]
|
|
||||||
pub quote_bank: AccountLoader<'info, Bank>,
|
pub quote_bank: AccountLoader<'info, Bank>,
|
||||||
#[account(mut)]
|
#[account(mut)]
|
||||||
pub quote_vault: Box<Account<'info, TokenAccount>>,
|
pub quote_vault: Box<Account<'info, TokenAccount>>,
|
||||||
#[account(mut)]
|
#[account(mut, has_one = group)]
|
||||||
pub base_bank: AccountLoader<'info, Bank>,
|
pub base_bank: AccountLoader<'info, Bank>,
|
||||||
#[account(mut)]
|
#[account(mut)]
|
||||||
pub base_vault: Box<Account<'info, TokenAccount>>,
|
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_base_vault = ctx.accounts.base_vault.amount;
|
||||||
let before_quote_vault = ctx.accounts.quote_vault.amount;
|
let before_quote_vault = ctx.accounts.quote_vault.amount;
|
||||||
|
|
||||||
// TODO: pre-health check
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Settle
|
// 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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -900,10 +900,6 @@ impl<'keypair> ClientInstruction for Serum3SettleFundsInstruction<'keypair> {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let health_check_metas =
|
|
||||||
derive_health_check_remaining_account_metas(&account_loader, &account, None, false)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let accounts = Self::Accounts {
|
let accounts = Self::Accounts {
|
||||||
group: account.group,
|
group: account.group,
|
||||||
account: self.account,
|
account: self.account,
|
||||||
|
@ -922,9 +918,7 @@ impl<'keypair> ClientInstruction for Serum3SettleFundsInstruction<'keypair> {
|
||||||
token_program: Token::id(),
|
token_program: Token::id(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut instruction = make_instruction(program_id, &accounts, instruction);
|
let instruction = make_instruction(program_id, &accounts, instruction);
|
||||||
instruction.accounts.extend(health_check_metas.into_iter());
|
|
||||||
|
|
||||||
(accounts, instruction)
|
(accounts, instruction)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -932,6 +926,7 @@ impl<'keypair> ClientInstruction for Serum3SettleFundsInstruction<'keypair> {
|
||||||
vec![self.owner]
|
vec![self.owner]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CreatePerpMarketInstruction<'keypair> {
|
pub struct CreatePerpMarketInstruction<'keypair> {
|
||||||
pub group: Pubkey,
|
pub group: Pubkey,
|
||||||
pub mint: Pubkey,
|
pub mint: Pubkey,
|
||||||
|
|
Loading…
Reference in New Issue