Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I calculate APY in goose? #2

Open
hyunkicho opened this issue Mar 23, 2021 · 0 comments
Open

How can I calculate APY in goose? #2

hyunkicho opened this issue Mar 23, 2021 · 0 comments

Comments

@hyunkicho
Copy link

hyunkicho commented Mar 23, 2021

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@hyunkicho and others