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

Don't assume decimals for pDAI conversion #246

Open
vrde opened this issue Aug 12, 2019 · 1 comment
Open

Don't assume decimals for pDAI conversion #246

vrde opened this issue Aug 12, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@vrde
Copy link
Collaborator

vrde commented Aug 12, 2019

The amount of decimals for an ERC20 token depends on the value stored in the smart contract. In the burner wallet we just assume that any ERC20 token has the same amount of decimals as Ether.

xdaiBalance = this.state.xdaiweb3.utils.fromWei(""+xdaiBalance,'ether')

@TimDaub TimDaub added the bug Something isn't working label Aug 12, 2019
@TimDaub
Copy link
Collaborator

TimDaub commented Aug 14, 2019

Slightly off-topic as your issue is about the code assuming similarity of ERC20 token and ETH in terms of decimals but I think if web3 was differently build, we could change this easily:

I looked into the web3 documentation of fromWei but unfortunately it just allows conversion based on Ethereum unit names "szabo", "wei", etc., while a conversion based on the decimal number would make much more sense to me personally.

I wish there was a function like fromWei(<num>, 18)...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants