Conversation
docs/learn/learn-account-balances.md
Outdated
| governance etc. but is not necessarily spendable (or transferrable) | ||
| - **Frozen** is the free balance locked for [staking](./learn-staking.md), | ||
| [governance](./learn-polkadot-opengov.md), and [vesting](./learn-transactions.md#vested-transfers) | ||
| - **Free** is the balance that can be used for on-chain activity like participating in |
There was a problem hiding this comment.
This is complex to explain, but here is how I would explain it. I would still like to get more eyes on this to verify @filippoweb3 @DrW3RK
-
Free Balance: Balance that can be used for any on-chain activity (staking, governance, deposits) as long as your total balance (free + reserved) remains above the maximum of frozen balance and existential deposit.
-
Frozen Balance (also called locks): This is a balance that overlaps across pallets . Example: If governance freezes 100 DOT and vesting freezes 120 DOT, total frozen = 120 DOT (not 220 DOT).
-
Reserved Balance (also called holds): Balance removed from free and doesn't overlap. Used by Nomination Pools, Staking, etc. Can still be used for governance voting but not for transfers or fees.
-
Spendable Balance: Portion of free balance available for transaction fees and creating new holds.
There was a problem hiding this comment.
I am on it, I need to verify a couple of things but there is already PR in place to update the balances page.
There was a problem hiding this comment.
@filippoweb3 Let me know if you would like to incorporate the changes reviewed by Ankan into your PR, and I can close mine. Otherwise, I am happy to add them to this PR.
docs/learn/learn-account-balances.md
Outdated
| @@ -12,16 +12,10 @@ remain frozen and unused due to an on-chain requirement. | |||
|
|
|||
| There are 5 types of account balances: | |||
| - **Reserved** (also called holds) is the balance removed from free and doesn't overlap. Used by nomination pools, [staking](./learn-staking.md), etc. Can still be used for governance voting but not for transfers or fees. | ||
| - **Spendable** is the portion of free balance available for transaction fees and creating new holds. | ||
|
|
||
| The spendable balance is calculated as follows: |
There was a problem hiding this comment.
This needs to be updated as part of this PR. E.g. on_hold is no longer defined. Does the formula need an update? @Ank4n
There was a problem hiding this comment.
I updated the formula in this commit. If there are any objections from Ankan I will edit again.
There was a problem hiding this comment.
Formula looks good.
Also aligns with https://github.com/w3f/polkadot-wiki/pull/6793/files#r2231235271
There was a problem hiding this comment.
I think this is sadly not correct, since a reserved balance creates a provider ref which makes the ED spendable. I will check again how it is exactly, but more complicated than the formula currently.
There was a problem hiding this comment.
IMO it should be something like this. It is also not 100% correct though, see the NOTE. So not sure how to easily explain this. In practice its not easy.
untouchable = frozen - on_hold.min(frozen);
// NOTE: The `(on_hold > 0 || frozen > 0)` is an *approximation* for
// `(consumers != 0 && providers <= 1)`, which is the condition that actually matters.
if free > 0 && (on_hold > 0 || frozen > 0) {
untouchable = untouchable.max(ed);
}
spendable = free - untouchable.min(free);There was a problem hiding this comment.
We have a test case here demonstrating that when a hold exists, the ED is not spendable.
Here’s the AccountInfo for 11 from that test (not printed in the test output, but retrieved by running it locally):
AccountInfo {
nonce: 0,
consumers: 1,
providers: 1,
sufficients: 0,
data: AccountData {
free: 1,
reserved: 1000,
frozen: 0,
flags: ...
}
}
joepetrowski
left a comment
There was a problem hiding this comment.
There are still changes below (spendable calculation, examples) that need to be made.
|
|
@Imod7 I will have a look by EoW, will update the figures as well. I will push my edits, ask for review by @michalisFr and merge. Thank you so much for starting this PR! |
- new figures + description - updated text
docs/learn/learn-account-balances.md
Outdated
| Frozen (locked): 50 DOT | ||
| Reserved (held): 80 DOT | ||
| Spendable: 19 DOT (Free - ED) | ||
| Untouchable: 51 DOT (ED) |
There was a problem hiding this comment.
A vested transfer increases the total balance as well. At the end of the day when all locks and reserves are removed you should have 150 DOT transferable. Also, in this example you suddenly have more frozen than free, so you lose access to the 20 DOT you had before.
What would happen here is this:
Free: 70
Frozen: 50
Reserved: 80
Spendable: 69
Untouchable: 1
However, since Frozen overlaps with Reserved, as you can see you have that 50 extra DOT as spendable from day 1. But at the end of the day that's not a problem since if you remove all reserves and the governance lock, you'll still have 50 DOT frozen that will become spendable according to the vesting schedule.
But again I'd like @joepetrowski or @Ank4n to confirm.
There was a problem hiding this comment.
added an example for a second gov lock as vesting can be a further example.
There was a problem hiding this comment.
I did not read through the context here, but i had this in my notes. Will compare against it:
|__total__________________________________|
|__on_hold__|_____________free____________|
|__________frozen___________|
|__on_hold__|__ed__|
|__untouchable__|__spendable__|
untouchable = max(ed, frozen - on_hold)
from here.
Ank4n
left a comment
There was a problem hiding this comment.
I added a few suggestions, but overall, great job.
|
|
||
| - **Free Balance** is a portion of an account's total balance that is not held (see below). It is the balance that can be used for any on-chain activity ([staking](./learn-staking.md), [governance](./learn-polkadot-opengov.md), and deposits) as long as the total balance (free + reserved) remains above the maximum of frozen balance and existential deposit. | ||
|
|
||
| - **Reserved Balance** (also called holds, or held balance) is the balance removed from free and does not overlay. It can be slashed, but only after all the free balance has been slashed. Reserved balance is used for: |
There was a problem hiding this comment.
...but only after all the free balance has been slashed
Not sure what this means - shouldn’t only the reserved funds be subject to slashing? Why would the free balance be slashed?
There was a problem hiding this comment.
There was a problem hiding this comment.
Thanks for pointing out. This is not correct anymore. I think the original text was correct when staking was using locks, and it was part of free balance.
(I will make a fix in the fungible rustdoc)
There was a problem hiding this comment.
@filippoweb3 This text should be fixed too. Totally misleading as it is now. You can refer the text here.
| On hold: 0 DOT | ||
| Frozen (locked): 0 DOT | ||
| Reserved (held): 0 DOT | ||
| Spendable: 99 DOT |
There was a problem hiding this comment.
A subtle nuance to explain is that the spendable balance is 99 DOT if you intend to keep the account alive. However, if you’re fine with the account being reaped, you can transfer up to the full 100 DOT (minus transaction fees).
|
I had a question today about voting locks, and it wasn’t clear to the person asking — and probably not to many others either — that governance votes use the total balance, including non-staking holds (like proxy deposits). Might be worth calling this out explicitly in the docs as well: Also, I think we should go ahead and merge this (post handing current open comments). It’s not perfect, but already a clear improvement over what’s currently in the docs. We can continue to iterate on it from here. |
- consumer and provider refs - Oliver's feedback - minor last edits
|
@filippoweb3 Regarding the balance examples, how are they currently being cross-verified? Should we add dedicated unit tests in the SDK to match each example one-to-one? Or any other idea? |
|
@Ank4n we validate with Polkadot JS and the support team :) I would wait to build unit tests until those figures and examples are final, as the Wiki content is subject to changes, and this would add additional work to update test dependencies. Thanks! |
## Changes - Updated the `Held Balance` definition to reflect the current behavior. The previous explanation was accurate when staking used locks (which were part of the free balance), but since [staking now uses holds](#5501), the old definition is misleading. This issue was originally pointed out by @michalisFr [here](w3f/polkadot-wiki#6793 (comment)). - Fixed a broken reference in the deprecated doc for `ExposureOf`, which was (ironically) pointing to a non-existent type named `ExistenceOf`. This slipped in during our [mega async staking PR](#8127).
## Changes - Updated the `Held Balance` definition to reflect the current behavior. The previous explanation was accurate when staking used locks (which were part of the free balance), but since [staking now uses holds](#5501), the old definition is misleading. This issue was originally pointed out by @michalisFr [here](w3f/polkadot-wiki#6793 (comment)). - Fixed a broken reference in the deprecated doc for `ExposureOf`, which was (ironically) pointing to a non-existent type named `ExistenceOf`. This slipped in during our [mega async staking PR](#8127).
Description
Related to this issue #6787
Review
Review from @Ank4n would be very helpful! Thank you very much in advance!