Skip to content

Commit

Permalink
Allow delegate to close spot open orders accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
riordanp committed Aug 31, 2022
1 parent dcfe4cd commit d499667
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ impl Processor {
let [
mango_group_ai, // read
mango_account_ai, // write
owner_ai, // write, signer can be liqor if market in ForceCloseOnly ***
owner_ai, // write, can also be delegate, signer can be liqor if market in ForceCloseOnly, must sign if not
dex_prog_ai, // read
open_orders_ai, // write
spot_market_ai, // read
Expand All @@ -1610,7 +1610,10 @@ impl Processor {

let mut mango_account =
MangoAccount::load_mut_checked(mango_account_ai, program_id, &mango_group_ai.key)?;
check_eq!(&mango_account.owner, owner_ai.key, MangoErrorCode::InvalidOwner)?;
check!(
&mango_account.owner == owner_ai.key || &mango_account.delegate == owner_ai.key,
MangoErrorCode::InvalidOwner
)?;

// Owner signature not necessary if market is in ForceCloseOnly or SwappingSpotMarket
let mode = mango_group.tokens[market_index].spot_market_mode;
Expand Down

0 comments on commit d499667

Please sign in to comment.