Skip to content

Commit 65eea5c

Browse files
committed
Fix support multi vesting configs
1 parent 98fbba2 commit 65eea5c

File tree

2 files changed

+174
-34
lines changed

2 files changed

+174
-34
lines changed

solana/programs/staking/src/lib.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,18 @@ pub mod staking {
201201
VestingError::InvalidVestingBalancePDA
202202
);
203203

204-
vesting_balance.stake_account_metadata = stake_account_metadata.key();
205-
stake_account_metadata
206-
.update_recorded_vesting_balance(vesting_balance.total_vesting_balance);
204+
if vesting_balance.stake_account_metadata == Pubkey::default() {
205+
vesting_balance.stake_account_metadata = stake_account_metadata.key();
206+
207+
let new_recorded_vesting_balance = stake_account_metadata
208+
.recorded_vesting_balance
209+
.checked_add(vesting_balance.total_vesting_balance)
210+
.ok_or(VestingError::Overflow)?;
211+
212+
// Update the recorded vesting balance
213+
stake_account_metadata
214+
.update_recorded_vesting_balance(new_recorded_vesting_balance);
215+
}
207216
}
208217
}
209218
}

0 commit comments

Comments
 (0)