Skip to content

Feature/add staking apr#2

Open
0xedev wants to merge 2 commits intochejazi:mainfrom
0xedev:feature/add-staking-apr
Open

Feature/add staking apr#2
0xedev wants to merge 2 commits intochejazi:mainfrom
0xedev:feature/add-staking-apr

Conversation

@0xedev
Copy link

@0xedev 0xedev commented Nov 13, 2024

No description provided.

const YourReward = remainingReward * YourShare

// Calculate the Annual Percentage Rate (APR)
const Apr = (YourReward / parseFloat(formatUnits(userStakedWei, decimals)) ) * 100 || 0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userStakedWei and YourReward can be in different currencies. E.g. stake $REFI earn $PROXY.

I believe the current calculation assumes they are the same currency.

To fix this we'd need to fetch the USD value of the user's stake and the reward.

For normal tokens, this should be straightforward using getTokenPrices in data.ts

For LP tokens, the amount of underlying ETH and pair token needs to be read from the chain and then the prices resolved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will resolve thar

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, I actually traveled for out of my station, I'll be back on Wednesday and I'll sort this asap

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

Successfully merging this pull request may close these issues.

3 participants