@@ -35,6 +35,14 @@ BigInt.from(1).wadMul(WAD); // 1
3535BigInt .from (WAD * 2n ).rayMul (0.5e27 ); // WAD
3636```
3737
38+ If you choose to avoid prototype pollution, you can always import specific utilities:
39+
40+ ``` 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" ;
44+ ```
45+
3846---
3947
4048## Book
@@ -125,7 +133,7 @@ Returns whether the BigNumber is approximately close to the given BigNumber, wit
125133
126134``` typescript
127135// only if you want to avoid BigNumber prototype pollution
128- import { approxEqAbs } from " ethers-maths/utils" ;
136+ import { approxEqAbs } from " ethers-maths/lib/ utils" ;
129137
130138// Returns whether the BigNumber is approximately close to the given BigNumber, within the given tolerance: true
131139approxEqAbs (0 , 1 , " 1" );
@@ -139,7 +147,7 @@ Returns the minimum between input BigNumberish, as a BigInt
139147
140148``` typescript
141149// only if you want to avoid BigInt prototype pollution
142- import { min } from " ethers-maths/utils" ;
150+ import { min } from " ethers-maths/lib/ utils" ;
143151
144152// Returns the minimum between input BigNumberish, as a BigInt: 0
145153min (0 , 1 , " 2" , ... );
@@ -153,7 +161,7 @@ Returns the maximum between input BigNumberish, as a BigInt
153161
154162``` typescript
155163// only if you want to avoid BigInt prototype pollution
156- import { max } from " ethers-maths/utils" ;
164+ import { max } from " ethers-maths/lib/ utils" ;
157165
158166// Returns the maximum between input BigNumberish, as a BigInt: 2
159167max (0 , 1 , " 2" , ... );
@@ -167,7 +175,7 @@ Returns the sum of input BigNumberish array, as a BigInt
167175
168176``` typescript
169177// only if you want to avoid BigInt prototype pollution
170- import { sum } from " ethers-maths/utils" ;
178+ import { sum } from " ethers-maths/lib/ utils" ;
171179
172180// Returns the sum of input BigNumberish array, as a BigInt: 3
173181sum ([0 , 1 , " 2" ]);
@@ -204,7 +212,7 @@ Returns a 1 followed by the input number of zeros (10 raised to the power of the
204212
205213``` typescript
206214// only if you want to avoid BigInt prototype pollution
207- import { pow10 } from " ethers-maths/utils" ;
215+ import { pow10 } from " ethers-maths/lib/ utils" ;
208216
209217// Returns a 1 followed by the input number of zeros: 100
210218pow10 (2 );
@@ -217,7 +225,7 @@ Performs a multiplication followed by a division, rounded half up
217225
218226``` typescript
219227// only if you want to avoid BigInt prototype pollution
220- import { mulDivHalfUp } from " ethers-maths/utils" ;
228+ import { mulDivHalfUp } from " ethers-maths/lib/ utils" ;
221229
222230// 1.0 (in wad) * 1 / 1 = 1.0 (in wad)
223231mulDivHalfUp (BigInt .WAD , 1 , 1 );
@@ -230,7 +238,7 @@ Performs a multiplication followed by a division, rounded up
230238
231239``` typescript
232240// only if you want to avoid BigInt prototype pollution
233- import { mulDivUp } from " ethers-maths/utils" ;
241+ import { mulDivUp } from " ethers-maths/lib/ utils" ;
234242
235243// 0.999999999999999999 * 1 / WAD = 1.0 (in wad, rounded up)
236244mulDivUp (BigInt .WAD - 1n , 1 , BigInt .WAD );
@@ -243,7 +251,7 @@ Performs a multiplication followed by a division, rounded down
243251
244252``` typescript
245253// only if you want to avoid BigInt prototype pollution
246- import { mulDivDown } from " ethers-maths/utils" ;
254+ import { mulDivDown } from " ethers-maths/lib/ utils" ;
247255
248256// 1.000000000000000001 * 1 / WAD = 1.0 (in wad, rounded down)
249257mulDivDown (BigInt .WAD + 1n , 1 , BigInt .WAD );
@@ -262,7 +270,7 @@ _Most commonly used as the ERC20 token unit_
262270
263271``` typescript
264272// only if you want to avoid BigInt prototype pollution
265- import { WAD } from " ethers-maths/constants" ;
273+ import { WAD } from " ethers-maths/lib/ constants" ;
266274
267275// Returns a 1 followed by 18 zeros: 1000000000000000000
268276WAD ;
@@ -277,7 +285,7 @@ _Most commonly used as Aave's index unit_
277285
278286``` typescript
279287// only if you want to avoid BigInt prototype pollution
280- import { RAY } from " ethers-maths/constants" ;
288+ import { RAY } from " ethers-maths/lib/ constants" ;
281289
282290// Returns a 1 followed by 27 zeros: 1000000000000000000000000000
283291RAY ;
@@ -292,7 +300,7 @@ _Most commonly used as Aave's `PERCENTAGE_FACTOR`_
292300
293301``` typescript
294302// only if you want to avoid BigInt prototype pollution
295- import { PERCENT } from " ethers-maths/constants" ;
303+ import { PERCENT } from " ethers-maths/lib/ constants" ;
296304
297305// Returns a 1 followed by 4 zeros: 10000
298306PERCENT ;
@@ -305,7 +313,7 @@ Returns half of the common WAD unit, which is also known as `0.5 ether` in Solid
305313
306314``` typescript
307315// only if you want to avoid BigInt prototype pollution
308- import { HALF_WAD } from " ethers-maths/constants" ;
316+ import { HALF_WAD } from " ethers-maths/lib/ constants" ;
309317
310318// Returns a 1 followed by 18 zeros: 1000000000000000000
311319HALF_WAD ;
@@ -318,7 +326,7 @@ Returns half of the common RAY unit, which is also known as `0.5e9 ether` in Sol
318326
319327``` typescript
320328// only if you want to avoid BigInt prototype pollution
321- import { HALF_RAY } from " ethers-maths/constants" ;
329+ import { HALF_RAY } from " ethers-maths/lib/ constants" ;
322330
323331// Returns a 1 followed by 27 zeros: 1000000000000000000000000000
324332HALF_RAY ;
@@ -333,7 +341,7 @@ _Most commonly used as Aave's `HALF_PERCENTAGE_FACTOR`_
333341
334342``` typescript
335343// only if you want to avoid BigInt prototype pollution
336- import { HALF_PERCENT } from " ethers-maths/constants" ;
344+ import { HALF_PERCENT } from " ethers-maths/lib/ constants" ;
337345
338346// Returns a 1 followed by 4 zeros: 10000
339347HALF_PERCENT ;
0 commit comments