import { BigNumber , utils } from 'ethers' ; export function formatAndRoundBigNumber ( value ) { if ( BigNumber . isBigNumber ( value ) ) { return Number ( utils . formatEther ( value ) ) . toLocaleString ( undefined , { maximumFractionDigits : 0 , } ) ; } return `Invalid val: ${ value }` ; } export function bigNumberToNumber ( value ) { if ( BigNumber . isBigNumber ( value ) ) { return Number ( utils . formatEther ( value ) ) ; } return 0 ; } export function numberToBigNumber ( value ) { if ( typeof value === 'number' ) { return BigNumber . from ( String ( value ) ) ; } return BigNumber . from ( '0' ) ; } export function scaleNumberToBigNumber ( value ) { if ( typeof value === 'number' ) { return utils . parseEther ( String ( value ) ) ; } return utils . parseEther ( "0" ) ; }