You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use total balance (free + reserved) when performing liquidity checks for a new reserve (#8108)
# Description
Solves: #8099
Based on the documentation and existing code, the usable balance is
computed with the following formula:
```rs
// If Fortitude == Polite
let usable_balance = free - max(frozen - reserved, existential balance)
```
### The problem:
If an account's `free balance` is lower than `frozen balance`, no
reserves will be allowed even though the `usable balance` is enough to
cover the reserve, resulting in a `LiquidityRestrictions` error, which
should not happen.
### Visual example of how `usable/spendable` balance works:
```bash
|__total__________________________________|
|__on_hold__|_____________free____________|
|__________frozen___________|
|__on_hold__|__ed__|
|__untouchable__|__spendable__|
```
## Integration
No action is required, the changes only change existing code, it does
not add or change any API.
## Review Notes
From my understanding, the function `ensure_can_withdraw` is incorrect,
and instead of checking that the new `free` balance is higher or equal
to the `frozen` balance, it should make sure the `new free` balance is
higher or equal to the `usable` balance.
---------
Co-authored-by: Kian Paimani <[email protected]>
(cherry picked from commit 7c2642d)
0 commit comments