-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
src/apps/beefy/positions.ts
Outdated
@@ -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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const additionalApr = apyBreakdown.rewardPoolApr || 0 | |
const additionalApr = apyBreakdown.rewardPoolApr ?? 0 |
There was a problem hiding this comment.
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 😄
src/apps/beefy/api.ts
Outdated
@@ -6,6 +6,7 @@ export type BeefyVault = { | |||
id: string | |||
name: string | |||
type: string // cowcentrated, gov | |||
subType: string |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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/api.ts
Outdated
@@ -6,6 +6,7 @@ export type BeefyVault = { | |||
id: string | |||
name: string | |||
type: string // cowcentrated, gov | |||
subType: string |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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.
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.