diff --git a/programs/openbook-v2/src/accounts_ix/settle_funds.rs b/programs/openbook-v2/src/accounts_ix/settle_funds.rs index 467c9b615..50eb5ecc3 100644 --- a/programs/openbook-v2/src/accounts_ix/settle_funds.rs +++ b/programs/openbook-v2/src/accounts_ix/settle_funds.rs @@ -1,3 +1,4 @@ +use crate::error::OpenBookError; use crate::state::*; use anchor_lang::prelude::*; use anchor_spl::token::{Token, TokenAccount}; @@ -11,8 +12,8 @@ pub struct SettleFunds<'info> { #[account( mut, - has_one = owner, has_one = market, + constraint = open_orders_account.load()?.is_owner_or_delegate(owner.key()) @ OpenBookError::NoOwnerOrDelegate )] pub open_orders_account: AccountLoader<'info, OpenOrdersAccount>, #[account( @@ -30,12 +31,14 @@ pub struct SettleFunds<'info> { pub market_quote_vault: Account<'info, TokenAccount>, #[account( mut, - token::mint = market_base_vault.mint + token::mint = market_base_vault.mint, + constraint = user_base_account.owner == open_orders_account.load()?.owner )] pub user_base_account: Account<'info, TokenAccount>, #[account( mut, - token::mint = market_quote_vault.mint + token::mint = market_quote_vault.mint, + constraint = user_quote_account.owner == open_orders_account.load()?.owner )] pub user_quote_account: Account<'info, TokenAccount>, #[account( diff --git a/programs/openbook-v2/src/accounts_ix/settle_funds_expired.rs b/programs/openbook-v2/src/accounts_ix/settle_funds_expired.rs index 0181f0228..23f712547 100644 --- a/programs/openbook-v2/src/accounts_ix/settle_funds_expired.rs +++ b/programs/openbook-v2/src/accounts_ix/settle_funds_expired.rs @@ -40,7 +40,7 @@ pub struct SettleFundsExpired<'info> { #[account( mut, token::mint = market_quote_vault.mint, - constraint = user_base_account.owner == open_orders_account.load()?.owner + constraint = user_quote_account.owner == open_orders_account.load()?.owner )] pub user_quote_account: Account<'info, TokenAccount>, #[account(