taproot-assets icon indicating copy to clipboard operation
taproot-assets copied to clipboard

[bug]: Decimals cause the Price Oracle to have significant price deviations or failures.

Open lukegao209 opened this issue 1 year ago • 3 comments

When Assets have decimals, for example, USDT with 5 decimals, and BTC/USDT = 60,000, then 1 unit of USDT = (1 BTC Sat) * 1,000 (msat) / (Price * decimal)

1 unit USDT = 100,000,000 * 1000 / (6000 * 100000) = 16.667 mSat.

Since the PriceOracle cannot return values below 1/1000 sat, after rounding, the result will be 17 mSat, the resulting price deviation can be quite significant.

For assets with more decimals or lower prices, it may no longer be possible to return 1 mSat.

if AssetA = 0.01 USDT , So 1 unit AssetA = 0.16667 mSat.

As a solution, since subject_asset_max_amount is already provided in the QueryRateTickRequest, could the Price Oracle return the total value instead of the unit price for the asset, thereby avoiding the issue described above?

lukegao209 avatar Aug 21 '24 13:08 lukegao209

This will be addressed by https://github.com/lightninglabs/taproot-assets/pull/1059 (and the changes following from it).

guggero avatar Aug 21 '24 14:08 guggero

Will reopen issue and close once #1059 is merged

dstadulis avatar Aug 21 '24 22:08 dstadulis

I think let's keep this open until https://github.com/lightninglabs/taproot-assets/pull/1117 (or the updated version of it) is merged.

Roasbeef avatar Sep 16 '24 19:09 Roasbeef

Fixed now with the latest RFQ revamp which will be release alongside v0.4.2.

Roasbeef avatar Oct 22 '24 18:10 Roasbeef