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

Take token decimals into account for price conversions in treasury buyout #460

Closed
ebma opened this issue May 7, 2024 · 2 comments · Fixed by #461
Closed

Take token decimals into account for price conversions in treasury buyout #460

ebma opened this issue May 7, 2024 · 2 comments · Fixed by #461
Assignees
Labels
priority:high Do it now type:bug Something isn't working

Comments

@ebma
Copy link
Member

ebma commented May 7, 2024

Context

The buyout possibly involves tokens with different decimals. We have to take that difference into account during the price calculation, otherwise the resulting exchange rates shift a lot.

TODO

Take the asset decimals into account when calculating the respective amounts in calc_amount_to_exchange and calc_buyout_amount.

We can do this in two ways:

  • Add a coupling to the asset registry pallet where the decimals are stored in the metadata of each asset
  • Use the DecimalsLookup trait defined in Spacewalk and either use one of the existing implementations for each runtime (eg. Pendulum) or implement that trait anew so that it tries to get the decimals from the asset registry metadata.

I think the approach to use the DecimalsLookup trait but implementing it so that it accesses the asset registry is the best approach.

The implementation for the price conversion can look similar to this one.

@ebma ebma added priority:high Do it now type:bug Something isn't working labels May 7, 2024
@ebma
Copy link
Member Author

ebma commented May 7, 2024

@pendulum-chain/product I created a new ticket and @bogdanS98 will start working on it right away as it's very important.

@prayagd
Copy link
Collaborator

prayagd commented May 7, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:high Do it now type:bug Something isn't working
Projects
None yet
3 participants