import { BigNumber , utils } from 'ethers' ; import { expect } from 'chai' ; export const expectToEqualWithThreshold = ( { value , to , threshold , } ) : void => { value = toBN ( value ) ; to = toBN ( to ) ; threshold = toBN ( threshold ) ; expect ( to . sub ( threshold ) . lte ( value ) && to . add ( threshold ) . gte ( value ) , `Expected ${ value . toString ( ) } to be between ${ to . sub ( threshold ) . toString ( ) } and ${ to . add ( threshold ) . toString ( ) }` ) . to . be . true ; } ; export const toBN = ( value ) : BigNumber => { return BigNumber . isBigNumber ( value ) ? value : BigNumber . from ( value ) ; } ; export const toUnit = ( value ) : BigNumber => { return utils . parseUnits ( value . toString ( ) ) ; } ;