ourzora / zdk

MIT License
107 stars 42 forks source link

[feature] update Decimal class to accept string value and precision #44

Closed sporkspatula closed 3 years ago

sporkspatula commented 3 years ago

Previously the decimal class only accepted number values and did not allow for precision to be passed in.

Javascript handles numbers with large precision pretty funkily. Allowing for values to be passed as string can help avoid javascript weirdness.

Some ERC20 contracts do not use 18 decimals of precision (ex. USDC, WBTC). In order to be able to use the decimal class to get BigNumbers, it must support different levels of precision. This PR adds an optional precision parameter to be specified. It must be 0 <= p <= 18.