Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use reducible_balance instead free_balance #420

Merged

Conversation

tgmichel
Copy link
Contributor

@tgmichel tgmichel commented Jul 8, 2021

Rel #291

Follow up on Add a usable_balance_for function to the Currency trait.

Once we update frontier branch we should be able of using https://crates.parity.io/frame_support/traits/tokens/fungible/trait.Inspect.html#tymethod.reducible_balance, that returns the balance that is neither reserved nor locked/frozen.

@sorpaas in the EVM context, usable balance should take into account ExistentialDeposit? That is, should allow to go below it?

@JoshOrndorff
Copy link
Contributor

JoshOrndorff commented Jul 8, 2021

in the EVM context, usable balance should take into account ExistentialDeposit? That is, should allow to go below it?

At first I thought having the reducible balance not include the ED would be a great way to have the benefits of a non-zero ED and still keep eth compatibility. But now I think that's wrong because of a bad token transfer experience.

Consider a chain with a ED = 1 token and the reducible balance does not include the ED. Imagine Alice has a total of 10 tokens, so from the EVM it looks like she has 9. Imagine Alice transfers 5 tokens to Bob. Because Bob also has a 1 token ED it appears that he only got 4 tokens.

EDIT: This would only be true if bob's account is new.

@sorpaas
Copy link
Member

sorpaas commented Jul 9, 2021

I'll do a final round of partial release for whatever crate is still possible. Then let's finally move Substrate to master and wait for paritytech/substrate#9140

@tgmichel
Copy link
Contributor Author

@sorpaas just a reminder that this and #403 are stale waiting for Substrate's frontier branch :)

@sorpaas
Copy link
Member

sorpaas commented Aug 23, 2021

This is now merge-able. Please pull master.

@sorpaas
Copy link
Member

sorpaas commented Aug 23, 2021

Please fix tests and lints.

@sorpaas sorpaas marked this pull request as ready for review August 23, 2021 20:44
@sorpaas sorpaas self-requested a review as a code owner August 23, 2021 20:44
@sorpaas sorpaas merged commit 8139beb into polkadot-evm:master Aug 23, 2021
@tgmichel tgmichel deleted the tgm-reducible-balance branch April 1, 2022 09:54
abhijeetbhagat pushed a commit to web3labs/frontier that referenced this pull request Jan 11, 2023
* Use `tokens::fungible::Inspect::reducible_balance`

* Integration test

* cargo fmt

* integration tests

* recipient's balance is also subject to ed

Co-authored-by: Joshy Orndorff <admin@joshyorndorff.com>
Co-authored-by: Joshy Orndorff <JoshOrndorff@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants