1

I've been reviewing a protocol that utilizes MULTIPLIER for their calculations which increases the precision because there are no decimal numbers in solidity. That is fine, but I've seen a lot of protocols using MULTIPLIER 1e10, so 10^10.

This makes no sense to me. Everything in solidity is in wei 10^18. So if we want to calculate, let's say 2 ether times 3 ether, we want the result to be 6 ether. So logically, the multiplier should be 10^18 like this:

(2 ether * 3 ether) / 1e18 = 6 * 10^18 or 6 ether

If we use only 1e10 the result isn't correct in this case:

(2 ether * 3 ether) / 1e10 = 6 * 10^26 or 600000000 ether

This works both with multiplying and dividing numbers:

(10 ether * 1e18) / 2 ether = 5 ether or 5 * 10^18

But if we used 1e10, it wouldn't work:

(10 ether * 1e10) / 2 ether = 5 * 10^10 or 50000000000

So either I'm missing something big, or it doesn't make sense.

Thanks for the answers!

Kuly14
  • 342
  • 1
  • 11

1 Answers1

0

this should be for pairs that have 8 decimals, to increase them to 18

Eugene1111
  • 69
  • 6