2

I read the answer of Shawn about locked and reserved balances. What is the difference between Free Balance, Reserved Balance, Locked Balance, Vesting Balance, etc...?

He pointed out, that locked funds (WithdrawReasons::TRANSFER) can still be reserved.

So if an account has a lock for 100 units with WithdrawReasons::Transfer, it cannot make a transfer which brings its free balance lower than 100 units. However, this account will be able to perform another operation like reserve taking its free balance below 100 units.

I tried this, but pallet_balances returns the LiquidityRestrictions error when I try to reserve locked funds.

https://crates.parity.io/src/pallet_balances/lib.rs.html#1445

Shouldn't be a reserve allowed while having it locked at the same time or is it correct as it is?

I mean the free_balance after a lock is still untouched. This could indicate that a reserve can happen.

1 Answer 1

0

I didn't found 'you can reserve the lock funds' from the link you provide.

I'm not the author of pallet-balances. So, I don't know why it is designed like this.

But I can answer why you can not do this.

First, let's look at the AccountData struct.

The free balance does not include the reserved balance. They are separated parts.

Then, the set_lock and update_locks. Apparently, it doesn't care about the amount, just set a lock on the account.

And when you want to spend the fund, you will enter the ensure_can_withdraw and frozen. That's the point, it only interacts with free balance. It doesn't work with reserve.

For the reserve. You can see it also call the ensure_can_withdraw. So, you can not call reserve after lock.

Finally, we get:

free + reserved = total
free - lock     = usable

sometimes, the lock might be greater than the total

so, this pallet allows you to write your own logic like

set a lock depending on your reserve amount, and it might looks
like your locked funds were in reseved?
1
  • I meant this sentence of Shawn: However, this account will be able to perform another operation like reserve taking its free balance below 100 units.
    – Chralt
    Jul 22, 2022 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.