pendulum-chain / pendulum

GNU General Public License v3.0
43 stars 14 forks source link

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

Closed ebma closed 6 months ago

ebma commented 6 months ago

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:

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 commented 6 months ago

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

prayagd commented 6 months ago

Hey team! Please add your planning poker estimate with Zenhub @b-yap @bogdanS98 @ebma @gianfra-t @TorstenStueber