thecointech / thecoin

Mono-repo for TheCoin project
https://thecoin.io
GNU Affero General Public License v3.0
3 stars 1 forks source link

ORACLE: Fix cents rounding (it seems we always round down) #524

Closed FrozenKiwi closed 2 months ago

FrozenKiwi commented 4 months ago

Demo Account is 9c under-cushioned after 9 deposits

const cushion = await shockAbsorber.getCushion(address);
cushion.fiatPrincipal.toNumber()

Conversion is calculated:

(coin * int(price) / 1e12);

to return: 17499

However, in floating point, it becomes 17499.99980264426

Probable solution: add (5 * 1e6) to conversion on-chain

FrozenKiwi commented 4 months ago

Fixed in prodtest

FrozenKiwi commented 2 months ago

Fixed in prod