import BN from 'bn.js' ; import { MARK_PRICE_PRECISION , PEG_PRECISION , } from '../constants/numericConstants' ; export const convertToNumber = ( bigNumber , precision = MARK_PRICE_PRECISION ) => { if ( ! bigNumber ) return 0 ; return ( bigNumber . div ( precision ) . toNumber ( ) + bigNumber . mod ( precision ) . toNumber ( ) / precision . toNumber ( ) ) ; } ; export const convertBaseAssetAmountToNumber = ( baseAssetAmount ) => { return convertToNumber ( baseAssetAmount , MARK_PRICE_PRECISION . mul ( PEG_PRECISION ) ) ; } ;