vfat-io / vfat-tools

Other
864 stars 1.06k forks source link

bsc_zoo.js incorrectly calculating the rewards (share of pool) #1650

Open iamrob84 opened 3 years ago

iamrob84 commented 3 years ago

Current % of the pool is calculated as ( your stake $ / total staked $ ). Zoo % of pool should be calculated as ( your stake $ / tvl $ )

I downloaded the repo and couldn't seem to find where this calculation is done in bsc_zoo.js. I couldn't find the printChefPool function which may perform this- I assume this is a database function.

Side note - the reward key contract looks to be wrong in the repo (should be https://poocoin.app/tokens/0x6652462466dcee5cb1dda95379fae3c3e57f6719) however it was mystically working for 5 mins yesterday and the repo didn't seem to be altered, however it's not working again this morning.

vfat0 commented 3 years ago

printChefPool is in ethers_helpers

iamrob84 commented 3 years ago

Many thanks. I'm not sure why I failed to find that in a search- too much noise in the results! It looks like it's not calculating the const staked_tvl correctly which implies perhaps what parsed poolInfo or poolPrices has got something missing. Back to the investigation...

vfat0 commented 3 years ago

this happens usually if there is too much of the coin on the contract, e.g. if its in 2 different pools, or if its a pool token and a reward token at the same time. we generally use balanceOf to get the staked amount

iamrob84 commented 3 years ago

Sorry I'm all new to this. So the KEY chef address was correct however the ABI on bscscan is very light and doesn't represent what's in the bsc_zoo.js. Looking at something like bsc_apeswap.js if you view the chef address then the ABI's match. Sorry to be a pain but could you enlighten me out how the KEY_CHEF_ABI got a whole lot of extra content? When I searched for 'balanceOf' it seemed to frequently appear in the _CHEF_ABI const but not in the case of bsc_zoo.js

Noted the actual KEY contract wasn't in the bsc_tokens array in bsc_helpers, which led to predicted APR and reward amount not being populated. Although now populated these seem a fraction of what is expected. Is this a by-product of what you mentioned before or have I created another issue