export interface CalculateEth2RewardsParams { slotTimeInSec ? : number ; slotsInEpoch ? : number ; baseRewardFactor ? : number ; totalAtStake ? : number ; averageNetworkPctOnline ? : number ; vaildatorUptime ? : number ; validatorDeposit ? : number ; effectiveBalanceIncrement ? : number ; weightDenominator ? : number ; proposerWeight ? : number ; } const calculateEth2Rewards = ( { slotTimeInSec = 12 , slotsInEpoch = 32 , baseRewardFactor = 64 , totalAtStake = 1000000 , averageNetworkPctOnline = 0.95 , vaildatorUptime = 0.99 , validatorDeposit = 32 , effectiveBalanceIncrement = 1000000000 , weightDenominator = 64 , proposerWeight = 8 , } ) : number => { const avgSecInYear = 31556908.8 ; const epochPerYear = avgSecInYear / ( slotTimeInSec * slotsInEpoch ) ; const baseRewardPerIncrement = ( effectiveBalanceIncrement * baseRewardFactor ) / ( totalAtStake * 10e8 ) ** 0.5 ; const baseGweiRewardFullValidator = ( ( validatorDeposit * 10e8 ) / effectiveBalanceIncrement ) * baseRewardPerIncrement ; const offlineEpochGweiPentalty = baseGweiRewardFullValidator * ( ( weightDenominator - proposerWeight ) / weightDenominator ) ; const onlineEpochGweiReward = baseGweiRewardFullValidator * averageNetworkPctOnline ; const reward = onlineEpochGweiReward * vaildatorUptime ; const penalty = offlineEpochGweiPentalty * ( 1 - vaildatorUptime ) ; const netRewardPerYear = epochPerYear * ( reward - penalty ) ; return netRewardPerYear / 10e8 / validatorDeposit ; } ; export default calculateEth2Rewards ;