Currency units
Methods that take numerical values as input can also take instances of token classes that the library provides. These are useful for managing precision, keeping track of units, and passing in wei values. Most methods that return numerical values return them wrapped in one of these classes. There are two types:
currency units, which represent an amount of a type of currency
price units, aka currency ratios, which represent an exchange rate between two currencies.
The classes that begin with USD
are price units; e.g. USD_ETH
represents the price of ETH in USD. Useful instance methods:
toNumber: return the raw JavaScript value. This may fail for very large numbers.
toBigNumber: return the raw value as a BigNumber.
isEqual: compare the values and symbols of two different instances.
toString: show the value in human-readable form, e.g. "500 USD/ETH".
If you would like to use these helper classes outside of Dai.js, check out @makerdao/currency.
Last updated