import { ChainType } from '../../types' ; const ESTIMATE_BLOCK_TIME = { [ ChainType . ACALA ] : 6 * 1000 , [ ChainType . KARURA ] : 6 * 1000 , [ ChainType . MANDALA ] : 6 * 1000 } ; const YEAR = 365 * 24 * 60 * 60 * 1000 ; export function getAPY ( rewardRate , commissionRate , eraFrequency , chain ? ) { if ( ! chain ) return 0 ; if ( ! ESTIMATE_BLOCK_TIME [ chain ] ) return 0 ; const eraCountOneYear = Math . floor ( YEAR / ( ESTIMATE_BLOCK_TIME [ chain ] || 0 ) / eraFrequency ) ; return Math . pow ( rewardRate * ( 1 - commissionRate ) + 1 , eraCountOneYear ) - 1 ; }