import { BigNumber } from 'bignumber.js' ; export class RaydiumTokenAmount { public wei : BigNumber ; public decimals : number ; public _decimals : BigNumber ; constructor ( wei , decimals = 0 , isWei = true ) { this . decimals = decimals ; this . _decimals = new BigNumber ( 10 ) . exponentiatedBy ( decimals ) ; this . wei = isWei ? new BigNumber ( wei ) : new BigNumber ( wei ) . multipliedBy ( this . _decimals ) ; } toEther ( ) { return this . wei . dividedBy ( this . _decimals ) ; } toWei ( ) { return this . wei ; } format ( ) { const vaule = this . wei . dividedBy ( this . _decimals ) ; return vaule . toFormat ( vaule . isInteger ( ) ? 0 : this . decimals ) ; } fixed ( ) { return this . wei . dividedBy ( this . _decimals ) . toFixed ( this . decimals ) ; } isNullOrZero ( ) { return this . wei . isNaN ( ) || this . wei . isZero ( ) ; } }