Skip to content

Commit

Permalink
fix: reversed balance should be returned on unstake
Browse files Browse the repository at this point in the history
  • Loading branch information
shekohex committed Dec 24, 2024
1 parent 03a1fa3 commit a5210c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pallets/multi-asset-delegation/src/functions/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ impl<T: Config> Pallet<T> {
.checked_sub(&request.amount)
.ok_or(Error::<T>::UnstakeAmountTooLarge)?;

// Unreserve the unstaked amount and clear the request
T::Currency::unreserve(who, request.amount);

operator.request = None;
Operators::<T>::insert(who, operator);

Expand Down
3 changes: 3 additions & 0 deletions pallets/multi-asset-delegation/src/tests/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,18 @@ fn execute_operator_unstake_success() {
// Set the current round to simulate passage of time
<CurrentRound<Runtime>>::put(15);

let reserved_balance = Balances::reserved_balance(Alice.to_account_id());
// Execute unstake
assert_ok!(MultiAssetDelegation::execute_operator_unstake(RuntimeOrigin::signed(
Alice.to_account_id()
)));

let reserved_balance_after = Balances::reserved_balance(Alice.to_account_id());
// Verify operator metadata
let operator_info = MultiAssetDelegation::operator_info(Alice.to_account_id()).unwrap();
assert_eq!(operator_info.stake, bond_amount - unstake_amount);
assert_eq!(operator_info.request, None);
assert_eq!(reserved_balance - reserved_balance_after, unstake_amount);

// Verify event
System::assert_has_event(RuntimeEvent::MultiAssetDelegation(
Expand Down

0 comments on commit a5210c7

Please sign in to comment.