1- # ethers -maths
1+ # evm -maths
22
33[ ![ npm package] [ npm-img ]] [ npm-url ]
44[ ![ Build Status] [ build-img ]] [ build-url ]
88[ ![ Commitizen Friendly] [ commitizen-img ]] [ commitizen-url ]
99[ ![ Semantic Release] [ semantic-release-img ]] [ semantic-release-url ]
1010
11- > ➗ Useful ethers-based math libraries to ease your journey through off-chain fixed-point arithmetics
11+ > ➗ Useful bigint math libraries to ease your journey through off-chain fixed-point arithmetics
1212
1313## Install
1414
1515``` bash
16- npm install ethers -maths
16+ npm install evm -maths
1717```
1818
1919``` bash
20- yarn add ethers -maths
20+ yarn add evm -maths
2121```
2222
2323---
@@ -27,7 +27,7 @@ yarn add ethers-maths
2727Just import the module and you'll benefit from an augmented, and typed, ` BigInt ` class!
2828
2929``` typescript
30- import " ethers -maths" ;
30+ import " evm -maths" ;
3131
3232const WAD = BigInt .pow10 (18 );
3333
@@ -38,9 +38,9 @@ BigInt.from(WAD * 2n).rayMul(0.5e27); // WAD
3838If you choose to avoid prototype pollution, you can always import specific utilities:
3939
4040``` typescript
41- import * as WadMath from " ethers -maths/lib/wad" ;
42- import * as RayMath from " ethers -maths/lib/ray" ;
43- import * as PercentMath from " ethers -maths/lib/percent" ;
41+ import * as WadMath from " evm -maths/lib/wad" ;
42+ import * as RayMath from " evm -maths/lib/ray" ;
43+ import * as PercentMath from " evm -maths/lib/percent" ;
4444```
4545
4646---
@@ -133,7 +133,7 @@ Returns whether the BigNumber is approximately close to the given BigNumber, wit
133133
134134``` typescript
135135// only if you want to avoid BigNumber prototype pollution
136- import { approxEqAbs } from " ethers -maths/lib/utils" ;
136+ import { approxEqAbs } from " evm -maths/lib/utils" ;
137137
138138// Returns whether the BigNumber is approximately close to the given BigNumber, within the given tolerance: true
139139approxEqAbs (0 , 1 , " 1" );
@@ -147,7 +147,7 @@ Returns the minimum between input BigNumberish, as a BigInt
147147
148148``` typescript
149149// only if you want to avoid BigInt prototype pollution
150- import { min } from " ethers -maths/lib/utils" ;
150+ import { min } from " evm -maths/lib/utils" ;
151151
152152// Returns the minimum between input BigNumberish, as a BigInt: 0
153153min (0 , 1 , " 2" , ... );
@@ -161,7 +161,7 @@ Returns the maximum between input BigNumberish, as a BigInt
161161
162162``` typescript
163163// only if you want to avoid BigInt prototype pollution
164- import { max } from " ethers -maths/lib/utils" ;
164+ import { max } from " evm -maths/lib/utils" ;
165165
166166// Returns the maximum between input BigNumberish, as a BigInt: 2
167167max (0 , 1 , " 2" , ... );
@@ -175,7 +175,7 @@ Returns the sum of input BigNumberish array, as a BigInt
175175
176176``` typescript
177177// only if you want to avoid BigInt prototype pollution
178- import { sum } from " ethers -maths/lib/utils" ;
178+ import { sum } from " evm -maths/lib/utils" ;
179179
180180// Returns the sum of input BigNumberish array, as a BigInt: 3
181181sum ([0 , 1 , " 2" ]);
@@ -212,7 +212,7 @@ Returns a 1 followed by the input number of zeros (10 raised to the power of the
212212
213213``` typescript
214214// only if you want to avoid BigInt prototype pollution
215- import { pow10 } from " ethers -maths/lib/utils" ;
215+ import { pow10 } from " evm -maths/lib/utils" ;
216216
217217// Returns a 1 followed by the input number of zeros: 100
218218pow10 (2 );
@@ -225,7 +225,7 @@ Performs a multiplication followed by a division, rounded half up
225225
226226``` typescript
227227// only if you want to avoid BigInt prototype pollution
228- import { mulDivHalfUp } from " ethers -maths/lib/utils" ;
228+ import { mulDivHalfUp } from " evm -maths/lib/utils" ;
229229
230230// 1.0 (in wad) * 1 / 1 = 1.0 (in wad)
231231mulDivHalfUp (BigInt .WAD , 1 , 1 );
@@ -238,7 +238,7 @@ Performs a multiplication followed by a division, rounded up
238238
239239``` typescript
240240// only if you want to avoid BigInt prototype pollution
241- import { mulDivUp } from " ethers -maths/lib/utils" ;
241+ import { mulDivUp } from " evm -maths/lib/utils" ;
242242
243243// 0.999999999999999999 * 1 / WAD = 1.0 (in wad, rounded up)
244244mulDivUp (BigInt .WAD - 1n , 1 , BigInt .WAD );
@@ -251,7 +251,7 @@ Performs a multiplication followed by a division, rounded down
251251
252252``` typescript
253253// only if you want to avoid BigInt prototype pollution
254- import { mulDivDown } from " ethers -maths/lib/utils" ;
254+ import { mulDivDown } from " evm -maths/lib/utils" ;
255255
256256// 1.000000000000000001 * 1 / WAD = 1.0 (in wad, rounded down)
257257mulDivDown (BigInt .WAD + 1n , 1 , BigInt .WAD );
@@ -270,7 +270,7 @@ _Most commonly used as the ERC20 token unit_
270270
271271``` typescript
272272// only if you want to avoid BigInt prototype pollution
273- import { WAD } from " ethers -maths/lib/constants" ;
273+ import { WAD } from " evm -maths/lib/constants" ;
274274
275275// Returns a 1 followed by 18 zeros: 1000000000000000000
276276WAD ;
@@ -285,7 +285,7 @@ _Most commonly used as Aave's index unit_
285285
286286``` typescript
287287// only if you want to avoid BigInt prototype pollution
288- import { RAY } from " ethers -maths/lib/constants" ;
288+ import { RAY } from " evm -maths/lib/constants" ;
289289
290290// Returns a 1 followed by 27 zeros: 1000000000000000000000000000
291291RAY ;
@@ -300,7 +300,7 @@ _Most commonly used as Aave's `PERCENTAGE_FACTOR`_
300300
301301``` typescript
302302// only if you want to avoid BigInt prototype pollution
303- import { PERCENT } from " ethers -maths/lib/constants" ;
303+ import { PERCENT } from " evm -maths/lib/constants" ;
304304
305305// Returns a 1 followed by 4 zeros: 10000
306306PERCENT ;
@@ -313,7 +313,7 @@ Returns half of the common WAD unit, which is also known as `0.5 ether` in Solid
313313
314314``` typescript
315315// only if you want to avoid BigInt prototype pollution
316- import { HALF_WAD } from " ethers -maths/lib/constants" ;
316+ import { HALF_WAD } from " evm -maths/lib/constants" ;
317317
318318// Returns a 1 followed by 18 zeros: 1000000000000000000
319319HALF_WAD ;
@@ -326,7 +326,7 @@ Returns half of the common RAY unit, which is also known as `0.5e9 ether` in Sol
326326
327327``` typescript
328328// only if you want to avoid BigInt prototype pollution
329- import { HALF_RAY } from " ethers -maths/lib/constants" ;
329+ import { HALF_RAY } from " evm -maths/lib/constants" ;
330330
331331// Returns a 1 followed by 27 zeros: 1000000000000000000000000000
332332HALF_RAY ;
@@ -341,7 +341,7 @@ _Most commonly used as Aave's `HALF_PERCENTAGE_FACTOR`_
341341
342342``` typescript
343343// only if you want to avoid BigInt prototype pollution
344- import { HALF_PERCENT } from " ethers -maths/lib/constants" ;
344+ import { HALF_PERCENT } from " evm -maths/lib/constants" ;
345345
346346// Returns a 1 followed by 4 zeros: 10000
347347HALF_PERCENT ;
@@ -836,16 +836,16 @@ Scales the percent-based BigInt up or down to the given scale defined by its num
836836BigInt .RAY .percentToDecimals (27 ); // 1 RAY
837837```
838838
839- [ build-img ] : https://github.com/Rubilmax/ethers -maths/actions/workflows/release.yml/badge.svg
840- [ build-url ] : https://github.com/Rubilmax/ethers -maths/actions/workflows/release.yml
841- [ test-img ] : https://github.com/Rubilmax/ethers -maths/actions/workflows/test.yml/badge.svg
842- [ test-url ] : https://github.com/Rubilmax/ethers -maths/actions/workflows/test.yml
843- [ downloads-img ] : https://img.shields.io/npm/dt/ethers -maths
844- [ downloads-url ] : https://www.npmtrends.com/ethers -maths
845- [ npm-img ] : https://img.shields.io/npm/v/ethers -maths
846- [ npm-url ] : https://www.npmjs.com/package/ethers -maths
847- [ issues-img ] : https://img.shields.io/github/issues/Rubilmax/ethers -maths
848- [ issues-url ] : https://github.com/Rubilmax/ethers -maths/issues
839+ [ build-img ] : https://github.com/Rubilmax/evm -maths/actions/workflows/release.yml/badge.svg
840+ [ build-url ] : https://github.com/Rubilmax/evm -maths/actions/workflows/release.yml
841+ [ test-img ] : https://github.com/Rubilmax/evm -maths/actions/workflows/test.yml/badge.svg
842+ [ test-url ] : https://github.com/Rubilmax/evm -maths/actions/workflows/test.yml
843+ [ downloads-img ] : https://img.shields.io/npm/dt/evm -maths
844+ [ downloads-url ] : https://www.npmtrends.com/evm -maths
845+ [ npm-img ] : https://img.shields.io/npm/v/evm -maths
846+ [ npm-url ] : https://www.npmjs.com/package/evm -maths
847+ [ issues-img ] : https://img.shields.io/github/issues/Rubilmax/evm -maths
848+ [ issues-url ] : https://github.com/Rubilmax/evm -maths/issues
849849[ semantic-release-img ] : https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
850850[ semantic-release-url ] : https://github.com/semantic-release/semantic-release
851851[ commitizen-img ] : https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
0 commit comments