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

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

@NoUJoe

Description

@NoUJoe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions