Skip to content

Commit

Permalink
small fixes logic in extend_stake
Browse files Browse the repository at this point in the history
  • Loading branch information
kstepanovdev committed Jul 9, 2024
1 parent b62b8d3 commit 70efb46
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions programs/voter-stake-registry/src/instructions/extend_stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ pub fn extend_stake(
additional_amount,
VsrError::InsufficientUnlockedTokens
);

require!(
target.lockup.period != LockupPeriod::None && target.lockup.kind != LockupKind::None,
VsrError::ExtendDepositIsNotAllowed
);

let start_ts = target.lockup.start_ts;
let curr_ts = clock_unix_timestamp();
let target_basic_amount = target.amount_deposited_native;
let current_lockup_period = if target.lockup.expired(curr_ts) {
LockupPeriod::Flex
Expand All @@ -57,12 +56,10 @@ pub fn extend_stake(

// different type of deposit is only allowed if
// the current deposit has expired
if current_lockup_period != LockupPeriod::Flex {
require!(
new_lockup_period >= current_lockup_period,
VsrError::ExtendDepositIsNotAllowed
);
}
require!(
new_lockup_period >= current_lockup_period,
VsrError::ExtendDepositIsNotAllowed
);

// Check target compatibility
require_eq!(
Expand Down

0 comments on commit 70efb46

Please sign in to comment.