Created
October 11, 2021 15:59
-
-
Save korrio/516330275583b7c230c3855b8aa162af to your computer and use it in GitHub Desktop.
apr-fee.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const aprToApy = (apr, frequency = BLOCKS_IN_A_YEAR) => ((1 + apr / 100 / frequency) ** frequency - 1) * 100 | |
| const feeApyPerYear = aprToApy((((((pairVolumeUSD - (pair1wVolumeUSD ?? 0)) * 0.0025) / 7) * 365) / pairReserveUSD) * 100, 3650) / 100 | |
| const feeApyPerMonth = feeApyPerYear / 12 | |
| const feeApyPerDay = feeApyPerMonth / 30 | |
| const feeApyPerHour = feeApyPerDay / blocksPerHour | |
| const sushiPerBlock = pool?.owner?.sushiPerBlock / 1e18 || | |
| (pool?.owner?.sushiPerSecond / 1e18) * averageBlockTime || | |
| masterChefV1SushiPerBlock | |
| const baseRewardPerBlock = (pool.allocPoint / pool.owner.totalAllocPoint) * sushiPerBlock | |
| const rewardPerBlock = isMasterChefV1BonusActive ? baseRewardPerBlock * (masterChefV1BonusMultiplier ?? 1) : baseRewardPerBlock | |
| const defaultReward = { | |
| token: 'xVUSD', | |
| icon: 'https://x.vonderswap.finance/xVUSD.png', | |
| rewardPerBlock, | |
| rewardPerDay: rewardPerBlock * blocksPerDay, | |
| rewardPrice: 1, | |
| } | |
| const roiPerBlock = | |
| rewards.reduce((previousValue, currentValue) => { | |
| return previousValue + currentValue.rewardPerBlock * currentValue.rewardPrice | |
| }, 0) / tvl | |
| const rewardAprPerHour = roiPerBlock * blocksPerHour | |
| const rewardAprPerDay = rewardAprPerHour * 24 | |
| const rewardAprPerMonth = rewardAprPerDay * 30 | |
| const rewardAprPerYear = rewardAprPerMonth * 12 | |
| const roiPerHour = rewardAprPerHour + feeApyPerHour | |
| const roiPerMonth = rewardAprPerMonth + feeApyPerMonth | |
| const roiPerDay = rewardAprPerDay + feeApyPerDay | |
| const roiPerYear = rewardAprPerYear + feeApyPerYear |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment