mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-01-15 01:17:57 -05:00
14 lines
469 B
TypeScript
14 lines
469 B
TypeScript
import { ethers } from 'ethers';
|
|
|
|
// true if the number is a power of 2
|
|
export const isPow2 = (int: number): boolean =>
|
|
int > 0 && (int & (int - 1)) === 0;
|
|
|
|
// Round a WEI number to 2 decimal points
|
|
export const roundNumber = (number: string) =>
|
|
(Math.round(+ethers.utils.formatEther(number) * 100) / 100).toFixed(2);
|
|
|
|
// Format a WEI number to normal number ex 1e18 = 1.0
|
|
export const humanizeNumber = (number: number) =>
|
|
`${+ethers.utils.formatEther(number)}`;
|