|
1 | 1 | # @usedapp/core |
2 | 2 |
|
| 3 | +## 0.2.0 |
| 4 | + |
| 5 | +### Minor Changes |
| 6 | + |
| 7 | +- ## 4ba5235: Currency |
| 8 | + |
| 9 | + Update the `Currency` class. It is now tasked with representing the individual currencies as well as handling formatting. |
| 10 | + |
| 11 | + The base `Currency` class is constructed with the following parameters: |
| 12 | + |
| 13 | + - `name` - name of the currency |
| 14 | + - `ticker` - e.g. USD, EUR, BTC |
| 15 | + - `decimals` - number of decimal places (e.g. 2 for USD, 18 for ETH) |
| 16 | + - `formattingOptions` - define how the currency values are formatted |
| 17 | + |
| 18 | + The following formatting options are supported: |
| 19 | + |
| 20 | + - `decimals` - Defaults to the decimals of the currency. |
| 21 | + - `thousandSeparator` - Defaults to ','. Used for separating thousands. |
| 22 | + - `decimalSeparator` - Defaults to '.'. Used for separating the integer part from the decimal part. |
| 23 | + - `significantDigits` - Defaults to Infinity. Can limit the number of digits on the decimal part, such that either the total number of displayed digits is equal to this parameter or more digits are displayed, but the decimal part is missing. |
| 24 | + - `useFixedPrecision` - Defaults to false. Switches from using significant digits to fixed precision digits. |
| 25 | + - `fixedPrecisionDigits` - Defaults to 0. Can specify the number of digits on the decimal part. |
| 26 | + - `prefix` - Defaults to ''. Prepended to the result. |
| 27 | + - `suffix` - Defaults to ''. Appended to the result. |
| 28 | + |
| 29 | + Other variants of `Currency` include `FiatCurrency`, `NativeCurrency` and `Token`. |
| 30 | + |
| 31 | + `FiatCurrency` takes the same parameters as `Currency` but uses fixed precision digits by default. |
| 32 | + |
| 33 | + `NativeCurrency` additionally takes a `chainId` parameter. The format function is configured with the ticker prefix and 6 significant digits by default. |
| 34 | + |
| 35 | + `Token` additionally takes a `chainId` parameter as well as an `address` parameter. The format function is configured with the ticker prefix and 6 significant digits by default. |
| 36 | + |
| 37 | + ## CurrencyValue |
| 38 | + |
| 39 | + Introduces the `CurrencyValue` class. This class represents a value tied to a currency. The methods include: |
| 40 | + |
| 41 | + - `static fromString(currency, value)` - creates a new CurrencyValue from string. |
| 42 | + - `static zero(currency)` - creates a new CurrencyValue equal to 0. |
| 43 | + - `toString()` - returns the value of the CurrencyValue as a decimal string with no formatting. |
| 44 | + - `format(overrideOptions?)` - formats the value according to the currency. The caller can override the formatting options. |
| 45 | + - `map(fn)` - returns a new CurrencyValue with value transformed by the callback. |
| 46 | + - `add(other)` - returns a new CurrencyValue with value being the sum of this value and other value. The argument must be a CurrencyValue with the same Currency. |
| 47 | + - `sub(other)` - returns a new CurrencyValue with value being the difference of this value and other value. The argument must be a CurrencyValue with the same Currency. |
| 48 | + - `mul(value)` - returns a new CurrencyValue with value multiplied by the argument. |
| 49 | + - `div(value)` - returns a new CurrencyValue with value divided by the argument. |
| 50 | + - `mod(value)` - returns a new CurrencyValue with value modulo the argument. |
| 51 | + - `equals(other)` - performs an equality check on the currencies and the values of both objects. |
| 52 | + - `lt(other)` - checks if this value is less than the other value. The argument must be a CurrencyValue with the same Currency. |
| 53 | + - `lte(other)` - checks if this value is less than or equal to the other value. The argument must be a CurrencyValue with the same Currency. |
| 54 | + - `gt(other)` - checks if this value is greater than the other value. The argument must be a CurrencyValue with the same Currency. |
| 55 | + - `gte(other)` - checks if this value is greater than or equal to the other value. The argument must be a CurrencyValue with the same Currency. |
| 56 | + - `isZero()` - returns true if the value is zero. |
| 57 | + |
| 58 | +### Patch Changes |
| 59 | + |
| 60 | +- a9768c8: Add more tests |
| 61 | + |
| 62 | + - Add tests for useTokenBalance |
| 63 | + |
| 64 | + - Add tests for multicall |
| 65 | + |
| 66 | + - Fix front running in renderWeb3Hook |
| 67 | + |
3 | 68 | ## 0.1.7 |
4 | 69 |
|
5 | 70 | ### Patch Changes |
|
0 commit comments