sushiswap / sushi-data

A utility to query for data on SushiSwap.
MIT License
81 stars 115 forks source link

Update to Work Recent Subgraph Changes #7

Closed jiro-ono closed 3 years ago

jiro-ono commented 3 years ago

To calculate APY

First you will need hardcode these values

Then calculate sushiPerBlock (after reduction): +sushiData.masterchef.pool({ poolId: "45" }) to get allocPoint for REDUCE pool. +sushiData.masterchef.info() to get totalAllocPoint for all pools.

100 - 100 * (pool45_allocPoint / totalAllocPoint)

*I'll try to add a better way to get this through sushi-data, in a future PR.

Finally using sushi-data you can get the rest of the data like so:

+sushiData.sushi.info(): to get derivedETH price for SUSHI. +sushiData.masterchef.stakedValue({ lpToken: "<desired_pool_lpToken_address>" }) to get totalValueETH, and totalSupply for desired pool. +sushiData.masterchef.pool({ poolId: "<desired_poolId>" }) to get allocPoint and slpBalance for desired pool. +sushiData.masterchef.info() to get totalAllocPoint for all pools.

After retrieving all the data from the sushi-data queries you can calculate APY like so:

// yearly APY Including 2/3rds Lockup
(derivedETH * blocksPerDay * sushiPerBlock * 3 * 365 * (allocPoint / totalAllocPoint)) / (totalValueETH * (slpBalance / totalSupply))

// Not Including 2/3rds Lockup
(derivedETH * blocksPerDay * sushiPerBlock * 365 * (allocPoint / totalAllocPoint)) / (totalValueETH * (slpBalance / totalSupply))

// to calculate APY for monthly replace 365 with 30
// to calculate APY for daily replace 365 with 1
sunnyRK commented 3 years ago

Hi, What will be the formula for past sushi reward calculation for particular pool(like eth-usdt) like if i want to calculate, what was the sushi token reward roi for last 1 month back for eth-usdt pool......using subgraph or anything else Can you guide me.. thanks:)