3

I would like to ask question about free balance on Kusama

when we execute the query

await api.query.system.account('some address')

then the output is this

{
  nonce: 1
  consumers: 0
  providers: 1
  sufficients: 0
  data: {
    free: 899,973,503,629,159
    reserved: 0
    miscFrozen: 0
    feeFrozen: 0
  }
}

My question is what is the true FREE balance ?

Because when the user have some frozen .. it means he/she cannot go below the frozen limit So the true FREE balance is FREE - MISCFROZEN - FEEFROZEN ?

1 Answer 1

2

Seems like you are looking to calculate the current "reducible" balance of a user, which has a function defined in the Balances Pallet:

fn reducible_balance(who: &T::AccountId, keep_alive: bool) -> Self::Balance {
    let a = Self::account(who);
    // Liquid balance is what is neither reserved nor locked/frozen.
    let liquid = a.free.saturating_sub(a.fee_frozen.max(a.misc_frozen));
    if frame_system::Pallet::<T>::can_dec_provider(who) && !keep_alive {
        liquid
    } else {
        // `must_remain_to_exist` is the part of liquid balance which must remain to keep total
        // over ED.
        let must_remain_to_exist =
            T::ExistentialDeposit::get().saturating_sub(a.total() - liquid);
        liquid.saturating_sub(must_remain_to_exist)
    }
}

So this is the logic you want to use.

It is important to note that FROZEN funds are not cummulative, so the simple calculation would be:

FREE - max(MISCFROZEN, FEEFROZEN)

as seen in the liquid calculation. But you should also take into account whether you allow the account to die or not.

2
  • Thank you for the explanation Shawn Jun 2, 2022 at 6:38
  • 1
    But in general those naming convention are I think not so good design .. if something is called FREE should be FREE .. same thing for frozen .. to substract something from free to give me the reducible balance sounds strange ... this maybe should be documented. What do you think ? Jun 2, 2022 at 7:12

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.