ITT icon indicating copy to clipboard operation
ITT copied to clipboard

Ether price value and decimal-places of Token

Open bezalel opened this issue 8 years ago • 4 comments

If Token issuer make Token with decimal places 18 (many real tokens such as Golem GNT use same decimal places with Ether, 18), ether prices used in trade should be multiple of 1 ether (1,2,3,4 ether, ... but not 0.1 ether for 1.000000000000000000 Token exchange)

So I suggest ether price in contract code should be "ether price per 1 base unit of target Token" 1 base unit of target token = 1*10^(decimals) tokens (1.000000000000000000 token)

bezalel avatar Dec 07 '16 09:12 bezalel

then, MAXNUM value constraint ("use only 128 bits of uint to prevent mul overflows.") should be reconsidered for integer multiplication and division error.

bezalel avatar Dec 07 '16 09:12 bezalel

The base unit is uint 1 and the decimalPlaces is only utilised by the client. It's up to the client to handle the fractional maths. No divisions are used in the contract at all to avoid rounding errors.

o0ragman0o avatar Dec 07 '16 09:12 o0ragman0o

But I think safe division can be performed by restricting token amount and ether price parameter. (restricting that ether price and token aboumt value should have trailing decimal (decimalplaces/2) zeros for example, If decimal-places is 18, token amount value and ether price value should have 9 trailing decimal zeros..

And I hope decimal places of Token might be fixed to constant(=18) same as Ether.

bezalel avatar Dec 07 '16 09:12 bezalel

There's simply no need to use fixed-point maths when you have no divides.

o0ragman0o avatar Dec 07 '16 09:12 o0ragman0o