Skip to content

Commit

Permalink
program: only let referrer set if number_of_sub_accounts_created is 0 (
Browse files Browse the repository at this point in the history
…#1083)

* program: only let referrer set if number_of_sub_accounts_created is 0

* CHANGELOG
  • Loading branch information
crispheaney committed Jul 15, 2024
1 parent 88de56c commit fa862dc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- program: account for serum already having open order account ([#1077](https://github.com/drift-labs/protocol-v2/pull/1077))
- program: avoid truncated cast ([#1078](https://github.com/drift-labs/protocol-v2/pull/1078))
- program: check whitelist token amount ([#1076](https://github.com/drift-labs/protocol-v2/pull/1076))
- program: program: only let referrer set if number_of_sub_accounts_created is 0 ([#1083](https://github.com/drift-labs/protocol-v2/pull/1083))

### Breaking

Expand Down
2 changes: 1 addition & 1 deletion programs/drift/src/instructions/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub fn handle_initialize_user<'c: 'info, 'info>(
user_stats.number_of_sub_accounts = user_stats.number_of_sub_accounts.safe_add(1)?;

// Only try to add referrer if it is the first user
if user_stats.number_of_sub_accounts == 1 {
if user_stats.number_of_sub_accounts_created == 0 {
let (referrer, referrer_stats) = get_referrer_and_referrer_stats(remaining_accounts_iter)?;
let referrer = if let (Some(referrer), Some(referrer_stats)) = (referrer, referrer_stats) {
let referrer = load!(referrer)?;
Expand Down

0 comments on commit fa862dc

Please sign in to comment.