import { FixedPointNumber as FN } from '@acala-network/sdk-core' ; export function getExchangeRate ( totalStaking , totalLiquid , defaultExchangeRate = new FN ( 0.1 , 18 ) ) { if ( totalStaking . isZero ( ) ) return defaultExchangeRate ; try { return FN . fromRational ( totalStaking , totalLiquid ) ; } catch ( e ) { return defaultExchangeRate ; } } export function convertLiquidToStaking ( exchangeRate , liquidAmount ) { return exchangeRate . mul ( liquidAmount ) ; } export function convertStakingToLiquid ( exchangeRate , stakingAmount ) { return stakingAmount . div ( exchangeRate ) ; }