polkadot-js / api

Promise and RxJS APIs around Polkadot and Substrate based chains via RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata.
Apache License 2.0
1.07k stars 354 forks source link

Fix transferable balance in `api.derive.balances.all` with new formula #5856

Closed TarikGul closed 2 months ago

TarikGul commented 7 months ago

Currently the following code snippet shows that we are using an outdated balance formula for retrieving the transferable balance. Related issue: https://github.com/polkadot-js/apps/issues/9988 (Please see the issue for more detail).

https://github.com/polkadot-js/api/blob/6415eb6515e8dee0944fb162a2af30da395b0a1e/packages/api-derive/src/balances/all.ts#L32-L53

https://github.com/polkadot-js/api/blob/6415eb6515e8dee0944fb162a2af30da395b0a1e/packages/api-derive/src/balances/all.ts#L55-L64

The curent implementation needs to take into account:

https://github.com/paritytech/polkadot-sdk/blob/3069b0af398e5a0374802c31201637e97f4a530a/substrate/frame/balances/src/impl_fungible.rs#L44-L70

TarikGul commented 7 months ago

rel: https://github.com/paritytech/polkadot-sdk/issues/1833

TarikGul commented 7 months ago

This is currently what I am working with: max(free - (frozen - on_hold), free - ED)

polkadot-js-bot commented 2 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.