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

Consistent format of asset amount #102

Open
mrq1911 opened this issue Jan 11, 2025 · 0 comments
Open

Consistent format of asset amount #102

mrq1911 opened this issue Jan 11, 2025 · 0 comments
Labels
area/sdk Related to trading router kind/enhancement Enhancement of existing functionality

Comments

@mrq1911
Copy link
Member

mrq1911 commented Jan 11, 2025

getBestSell(in, out, amount).toTx(limit) is the worst offender, where the amount is expected to be normalized (123.33), byt limit is absolute (123330000) which leads to errors in integrations which can lead to loss of funds for users

getBestSpotPrice returns the amount of 1 asset in as {amount, decimals}, so you are forced to convert it youself even more confusingly amount can have the fractional part as well

proposed fix

introduce new type Amount that can be created automatically from Number, String, whatever and implements toString, toHex, toNumber, toBigNumber, decimals and toNormalized (name TBD) that will normalize asset amount by decimals, others will return absolute amount, alternatively, we could always deal with the normalized amounts and there would be toAbsolute

it is strongly recommended to to these changes in a back-compatible way to minimize errors this will introduce in integrations

@nohaapav nohaapav added kind/enhancement Enhancement of existing functionality area/sdk Related to trading router labels Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sdk Related to trading router kind/enhancement Enhancement of existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants