Skip to content

Commit

Permalink
forbid staking more than stakable amount
Browse files Browse the repository at this point in the history
  • Loading branch information
saraswatpuneet committed Nov 21, 2024
1 parent deac3bf commit 6ef5f8b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pallets/capacity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,12 @@ impl<T: Config> Pallet<T> {
) -> BalanceOf<T> {
let account_balance =
T::Currency::reducible_balance(&staker, Preservation::Preserve, Fortitude::Polite);
account_balance
.saturating_sub(T::MinimumTokenBalance::get())
.min(proposed_amount)
let stakable_amount = account_balance.saturating_sub(T::MinimumTokenBalance::get());
if stakable_amount > proposed_amount {
proposed_amount
} else {
Zero::zero()
}
}

pub(crate) fn do_withdraw_unstaked(
Expand Down

0 comments on commit 6ef5f8b

Please sign in to comment.