diff --git a/packages/api-derive/src/balances/all.ts b/packages/api-derive/src/balances/all.ts index fa69a5cc9885..a9224155ceac 100644 --- a/packages/api-derive/src/balances/all.ts +++ b/packages/api-derive/src/balances/all.ts @@ -57,9 +57,14 @@ function calcShared (api: DeriveApi, bestNumber: BlockNumber, data: DeriveBalanc let transferable = null; if (data.frameSystemAccountInfo?.frozen) { - const frozenReserveDiff = data.frameSystemAccountInfo.frozen.sub(data.reservedBalance); - - transferable = api.registry.createType('Balance', allLocked ? 0 : data?.freeBalance.sub(bnMax(frozenReserveDiff, api.consts.balances.existentialDeposit))); + const { frameSystemAccountInfo, freeBalance, reservedBalance } = data; + + transferable = api.registry.createType( + 'Balance', + allLocked + ? 0 + : freeBalance.sub(bnMax(new BN(0), frameSystemAccountInfo.frozen.sub(reservedBalance))) + ); } return objectSpread({}, data, { diff --git a/packages/api-derive/src/balances/types.ts b/packages/api-derive/src/balances/types.ts index aa28324d27b0..94605cb64872 100644 --- a/packages/api-derive/src/balances/types.ts +++ b/packages/api-derive/src/balances/types.ts @@ -41,7 +41,7 @@ export interface DeriveBalancesAllAccountData extends DeriveBalancesAccountData */ lockedBreakdown: (PalletBalancesBalanceLock | BalanceLockTo212)[]; /** - * Calculated transferable balance. This uses the formula: free - max(frozen - reserve, ed) + * Calculated transferable balance. This uses the formula: free - max(0, frozen - reserve) * This is only correct when the return type of `api.query.system.account` is `FrameSystemAccountInfo`. * Which is the most up to date calulcation for transferrable balances. *