Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions programs/drift/src/instructions/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ pub fn handle_initialize_user<'c: 'info, 'info>(
)?;
}

if ctx.accounts.authority.key() != ctx.accounts.payer.key() {
validate!(
WHITELISTED_EXTERNAL_DEPOSITORS.contains(&ctx.accounts.payer.key()),
ErrorCode::DefaultError,
"Authority is not the payer"
)?;
}

Ok(())
}

Expand Down Expand Up @@ -274,6 +282,14 @@ pub fn handle_initialize_user_stats<'c: 'info, 'info>(
ErrorCode::MaxNumberOfUsers
)?;

if ctx.accounts.authority.key() != ctx.accounts.payer.key() {
validate!(
WHITELISTED_EXTERNAL_DEPOSITORS.contains(&ctx.accounts.payer.key()),
ErrorCode::DefaultError,
"Authority is not the payer"
)?;
}

Ok(())
}

Expand Down Expand Up @@ -4179,7 +4195,8 @@ pub struct InitializeUser<'info> {
pub user_stats: AccountLoader<'info, UserStats>,
#[account(mut)]
pub state: Box<Account<'info, State>>,
pub authority: Signer<'info>,
/// CHECK: Just a normal authority account
pub authority: AccountInfo<'info>,
#[account(mut)]
pub payer: Signer<'info>,
pub rent: Sysvar<'info, Rent>,
Expand All @@ -4198,7 +4215,8 @@ pub struct InitializeUserStats<'info> {
pub user_stats: AccountLoader<'info, UserStats>,
#[account(mut)]
pub state: Box<Account<'info, State>>,
pub authority: Signer<'info>,
/// CHECK: Just a normal authority account
pub authority: AccountInfo<'info>,
#[account(mut)]
pub payer: Signer<'info>,
pub rent: Sysvar<'info, Rent>,
Expand Down
13 changes: 9 additions & 4 deletions sdk/src/idl/drift.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.150.0",
"version": "2.152.0",
"name": "drift",
"instructions": [
{
Expand All @@ -23,7 +23,7 @@
{
"name": "authority",
"isMut": false,
"isSigner": true
"isSigner": false
},
{
"name": "payer",
Expand Down Expand Up @@ -73,7 +73,7 @@
{
"name": "authority",
"isMut": false,
"isSigner": true
"isSigner": false
},
{
"name": "payer",
Expand Down Expand Up @@ -11584,7 +11584,7 @@
},
{
"name": "disableUpdatePerpBidAskTwap",
"type": "bool"
"type": "u8"
},
{
"name": "pausedOperations",
Expand Down Expand Up @@ -16903,6 +16903,11 @@
"defined": "SpotBankruptcyRecord"
},
"index": false
},
{
"name": "bitFlags",
"type": "u8",
"index": false
}
]
},
Expand Down
Loading