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

Make an easy function for converting token balance integers to decimal token values [APE-1114] #30

Open
fubuloubu opened this issue Jun 20, 2023 · 0 comments

Comments

@fubuloubu
Copy link
Member

Overview

It would be nice to render a token value back to a human-readable amount

Specification

from ape_tokens import tokens

weth = tokens["WETH"]

# Look up conversion factor by symbol
assert tokens.render(weth.balanceOf(acct), "WETH") == "1.27 WETH"
# OR allow using any token contract (which has `.symbol()` and `.decimals()` methods)
assert tokens.render(weth.balanceOf(acct), weth) == "1.27 WETH"
@vany365 vany365 changed the title Make an easy function for converting token balance integers to decimal token values Make an easy function for converting token balance integers to decimal token values [APE-1114] Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant