import BN from "bignumber.js" ; export const plus = ( a , b ) : string => new BN ( a || 0 ) . plus ( b || 0 ) . toString ( ) ; export const minus = ( a , b ) : string => new BN ( a || 0 ) . minus ( b || 0 ) . toString ( ) ; export const times = ( a , b ) : string => new BN ( a || 0 ) . times ( b || 0 ) . toString ( ) ; export const div = ( a , b ) : string => new BN ( a || 0 ) . div ( b || 1 ) . toString ( ) ; export const sum = ( array ) : string => BN . sum . apply ( null , array . filter ( isFinite ) ) . toString ( ) ; export const min = ( array ) : string => BN . min . apply ( null , array . filter ( isFinite ) ) . toString ( ) ; export const ceil = ( n ) : string => new BN ( n ) . integerValue ( BN . ROUND_CEIL ) . toString ( ) ; export const floor = ( n ) : string => new BN ( n ) . integerValue ( BN . ROUND_FLOOR ) . toString ( ) ; export const percent = ( n , f = 2 ) : string => new BN ( times ( n , 100 ) ) . toFixed ( f ) + "%" ; export const gt = ( a , b ) : boolean => new BN ( a ) . gt ( b ) ; export const lt = ( a , b ) : boolean => new BN ( a ) . lt ( b ) ; export const gte = ( a , b ) : boolean => new BN ( a ) . gte ( b ) ; export const lte = ( a , b ) : boolean => new BN ( a ) . lte ( b ) ; export const isFinite = ( n ) : boolean => new BN ( n ) . isFinite ( ) ; export const isInteger = ( n ) : boolean => new BN ( n ) . isInteger ( ) ;