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

feat(earn): Add dailyYieldRatePercentage to beefy dataProps response #620

Merged
merged 7 commits into from
Oct 16, 2024

Conversation

jh2oman
Copy link
Contributor

@jh2oman jh2oman commented Oct 14, 2024

Code based on: https://github.com/beefyfinance/beefy-v2/blob/main/src/features/data/actions/apy.ts#L46

https://linear.app/valora/issue/ACT-1406/daily-rate

Tested

Ran the Beefy UI locally and console.logged the exact totalDaily value from the UI. Verified that it matched the calculation here.

@@ -74,7 +74,7 @@ const beefyAppTokenDefinition = ({
vault.tokenAddress?.toLowerCase() ??
networkIdToNativeAssetAddress[networkId]
const tvl = tvls[vault.id]
const apy = apys[vault.id]
const apy = apyBreakdown[vault.id].totalApy
Copy link
Contributor

Choose a reason for hiding this comment

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

I see five or so *-earnings vaults that do not have earnings defined do these need a fallback?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea! I can be a bit more defensive on a few things here

// [Old gov pools had their apr in the vaultApr field]
if (vault.type === 'gov' && vault.subType === 'cowcentrated') {
// anything in 'rewardPoolApr' (i.e. not in 'rewardPoolTradingApr') is considered a soft-boost on the pool
const additionalApr = apyBreakdown.rewardPoolApr || 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const additionalApr = apyBreakdown.rewardPoolApr || 0
const additionalApr = apyBreakdown.rewardPoolApr ?? 0

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you did the opposite change 😄

@@ -6,6 +6,7 @@ export type BeefyVault = {
id: string
name: string
type: string // cowcentrated, gov
subType: string
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a set of values that this can contain? Maybe we can use specific types for type and subType.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It appears there are, they are not all located in one place throughout the code in beefy. What would be the value in adding them in right now though?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was hoping it would be something like type above. Definitely not worth it reading through the code. Also is it optional? I don't see it here for example https://api.beefy.finance/gov-vaults/arbitrum


// Presence of rewardPoolApr indicates new api calc that has correct totals
// [Old gov pools had their apr in the vaultApr field]
if (vault.type === 'gov' && vault.subType === 'cowcentrated') {
Copy link
Contributor

Choose a reason for hiding this comment

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

vault.type itself can be cowcentrated right? could we document what a pool with type=='gov' and subType=='cowncentrated' is? Is that Old gov pools? if so can we make it explicit in the comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

my comment (and the one about subtype values) was mainly because I was confused why something would have type=gov and subtype=cowcentrated when type can also be cowcentrated. And I also didn't find any vault like that in the vaults response for arbitrum. If this was just copied from beefy as is, probably fine to leave as is.

src/apps/beefy/positions.ts Outdated Show resolved Hide resolved
src/types/positions.ts Outdated Show resolved Hide resolved
@@ -6,6 +6,7 @@ export type BeefyVault = {
id: string
name: string
type: string // cowcentrated, gov
subType: string
Copy link
Contributor

Choose a reason for hiding this comment

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

I was hoping it would be something like type above. Definitely not worth it reading through the code. Also is it optional? I don't see it here for example https://api.beefy.finance/gov-vaults/arbitrum

// [Old gov pools had their apr in the vaultApr field]
if (vault.type === 'gov' && vault.subType === 'cowcentrated') {
// anything in 'rewardPoolApr' (i.e. not in 'rewardPoolTradingApr') is considered a soft-boost on the pool
const additionalApr = apyBreakdown.rewardPoolApr || 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you did the opposite change 😄


// Presence of rewardPoolApr indicates new api calc that has correct totals
// [Old gov pools had their apr in the vaultApr field]
if (vault.type === 'gov' && vault.subType === 'cowcentrated') {
Copy link
Contributor

Choose a reason for hiding this comment

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

my comment (and the one about subtype values) was mainly because I was confused why something would have type=gov and subtype=cowcentrated when type can also be cowcentrated. And I also didn't find any vault like that in the vaults response for arbitrum. If this was just copied from beefy as is, probably fine to leave as is.

@jh2oman jh2oman enabled auto-merge (squash) October 16, 2024 18:34
@jh2oman jh2oman merged commit 42e3d60 into main Oct 16, 2024
5 checks passed
@jh2oman jh2oman deleted the daily-yield-rate branch October 16, 2024 18:37
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