Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Feature: Add an "amountFromReadable" method to BaseCurrency / CurrencyAmount #56

Open
NoUJoe opened this issue Jun 6, 2023 · 4 comments

Comments

@NoUJoe
Copy link

NoUJoe commented Jun 6, 2023

Unless I've missed it, but I have looked, there doesn't seem to be any built in method to convert a "display"/"readable" currency value to it's "atomic" amount. e.g 1.234ETH = 1234000000000000000

Is there any reason why not? Seems like a very common action to perform, as for the most part, user inputs are going to be in readable units, which need to be converted for use in contracts etc.

Strangely, in the "routing a trade" example (https://docs.uniswap.org/sdk/v3/guides/routing), it contains a function "fromReadableAmount":

https://github.com/Uniswap/examples/blob/0071bb5883fba6f4cc39a5f1644ac941e4f24822/v3-sdk/routing/src/libs/conversion.ts#L3

But this is in an example, and not part of the SDK. (also having amount: number is a bad idea imo but im nit-picking an example here...)

Just thought this makes sense. I don't think I'm missing it, as this is why I went to the example to see what was done in there.

Edit: Makes more sense for it to be in CurrencyAmount than BaseCurrency on second thought.

@NoUJoe NoUJoe changed the title Feature: Add a "amountFromReadable" method to BaseCurrency Feature: Add an "amountFromReadable" method to BaseCurrency Jun 6, 2023
@NoUJoe NoUJoe changed the title Feature: Add an "amountFromReadable" method to BaseCurrency Feature: Add an "amountFromReadable" method to BaseCurrency / CurrencyAmount Jun 7, 2023
@ashutosh887
Copy link

I would like to work on this @NoUJoe

@NoUJoe
Copy link
Author

NoUJoe commented Jun 11, 2023

@ashutosh887 not that I have any authority here, but go for it my guy!

@ashutosh887
Copy link

IDK who's the maintainer here @NoUJoe
Let's see

@NoUJoe
Copy link
Author

NoUJoe commented Jun 11, 2023

@ashutosh887 seems like no one! You could probably claim the role as yours!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants