diff --git a/programs/drift/src/instructions/admin.rs b/programs/drift/src/instructions/admin.rs index a4ecc2f8d1..cfdca1810a 100644 --- a/programs/drift/src/instructions/admin.rs +++ b/programs/drift/src/instructions/admin.rs @@ -4764,6 +4764,7 @@ pub fn handle_admin_deposit<'c: 'info, 'info>( market_index, explanation: DepositExplanation::Reward, transfer_user: None, + signer: Some(ctx.accounts.admin.key()), }; emit!(deposit_record); diff --git a/programs/drift/src/instructions/user.rs b/programs/drift/src/instructions/user.rs index e6d13d6fec..ac60cb0d26 100644 --- a/programs/drift/src/instructions/user.rs +++ b/programs/drift/src/instructions/user.rs @@ -653,6 +653,11 @@ pub fn handle_deposit<'c: 'info, 'info>( } else { DepositExplanation::None }; + let signer = if ctx.accounts.authority.key() != user.authority { + Some(ctx.accounts.authority.key()) + } else { + None + }; let deposit_record = DepositRecord { ts: now, deposit_record_id, @@ -670,6 +675,7 @@ pub fn handle_deposit<'c: 'info, 'info>( market_index, explanation, transfer_user: None, + signer, }; emit!(deposit_record); @@ -825,6 +831,7 @@ pub fn handle_withdraw<'c: 'info, 'info>( total_withdraws_after: user.total_withdraws, explanation: deposit_explanation, transfer_user: None, + signer: None, }; emit!(deposit_record); @@ -995,6 +1002,7 @@ pub fn handle_transfer_deposit<'c: 'info, 'info>( total_withdraws_after: from_user.total_withdraws, explanation: DepositExplanation::Transfer, transfer_user: Some(to_user_key), + signer: None, }; emit!(deposit_record); } @@ -1059,6 +1067,7 @@ pub fn handle_transfer_deposit<'c: 'info, 'info>( total_withdraws_after, explanation: DepositExplanation::Transfer, transfer_user: Some(from_user_key), + signer: None, }; emit!(deposit_record); } @@ -1271,6 +1280,7 @@ pub fn handle_transfer_pools<'c: 'info, 'info>( total_withdraws_after: from_user.total_withdraws, explanation: DepositExplanation::Transfer, transfer_user: Some(to_user_key), + signer: None, }; emit!(deposit_record); @@ -1305,6 +1315,7 @@ pub fn handle_transfer_pools<'c: 'info, 'info>( total_withdraws_after: to_user.total_withdraws, explanation: DepositExplanation::Transfer, transfer_user: Some(from_user_key), + signer: None, }; emit!(deposit_record); } @@ -1371,6 +1382,7 @@ pub fn handle_transfer_pools<'c: 'info, 'info>( total_withdraws_after: from_user.total_withdraws, explanation: DepositExplanation::Transfer, transfer_user: Some(to_user_key), + signer: None, }; emit!(deposit_record); @@ -1405,6 +1417,7 @@ pub fn handle_transfer_pools<'c: 'info, 'info>( total_withdraws_after: to_user.total_withdraws, explanation: DepositExplanation::Transfer, transfer_user: Some(from_user_key), + signer: None, }; emit!(deposit_record); } @@ -4139,10 +4152,7 @@ pub struct InitializeReferrerName<'info> { #[instruction(market_index: u16,)] pub struct Deposit<'info> { pub state: Box>, - #[account( - mut, - constraint = can_sign_for_user(&user, &authority)? - )] + #[account(mut)] pub user: AccountLoader<'info, User>, #[account( mut, diff --git a/programs/drift/src/state/events.rs b/programs/drift/src/state/events.rs index f4806fa5be..d193e17c83 100644 --- a/programs/drift/src/state/events.rs +++ b/programs/drift/src/state/events.rs @@ -51,6 +51,7 @@ pub struct DepositRecord { pub total_withdraws_after: u64, pub explanation: DepositExplanation, pub transfer_user: Option, + pub signer: Option, } #[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Eq, Default)]