Skip to content

How to calculate APY by staking Busd #3

@hyunkicho

Description

@hyunkicho

image
Hello I want to know How to calculate APY by staking Busd

I found out that I could get Egg as an reward when I stake Busd in the nest. I think I could calculate APY from accEggPerShare but I could not figure out how Can I calculate the same APY in the homepage.
Here is a code below that I tried to find out APY

var web3 = new Web3(new Web3.providers.HttpProvider(endpoint)); let contract = new web3.eth.Contract(_contractABI_Goose , _contractAddress_Goose); let PoolInfo_busd = await contract.methods.poolInfo(13).call(); let eggPerBlock = await contract.methods.eggPerBlock().call(); let totalAllocPoint = await contract.methods.totalAllocPoint().call(); let lastRewardBlock_busd = PoolInfo_busd.lastRewardBlock; console.log('lastRewardBlock_busd',lastRewardBlock_busd); let blocknumber = await web3.eth.getBlockNumber(); console.log('blocknumber',blocknumber); let getMultiplier = await contract.methods.getMultiplier(lastRewardBlock_busd,blocknumber).call(); console.log('getMultiplier',getMultiplier); console.log("totalAllocPoint",totalAllocPoint); let underliyng_busd = new web3.eth.Contract(_contractABI_busd , _contractAddress_busd); let lpSupply_busd = await underliyng_busd.methods.balanceOf(_contractAddress_Goose).call(); console.log("lpSupply_busd",lpSupply_busd); let accEggPerShare_busd = PoolInfo_busd.accEggPerShare; let allocPoint_busd = PoolInfo_busd.allocPoint; let accEggPerShare_busd_real = (accEggPerShare_busd)/(1e12); console.log(accEggPerShare_egg_real*accEggPerShare_busd_real); let eggReward_busd = ((getMultiplier*eggPerBlock*allocPoint_busd)/(totalAllocPoint)); console.log("eggReward_busd",eggReward_busd); let new_accEggPerShare_busd = (accEggPerShare_busd_real + eggReward_busd*(1e12))/(lpSupply_busd); console.log("new_accEggPerShare_busd",new_accEggPerShare_busd)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions