-
Notifications
You must be signed in to change notification settings - Fork 423
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
Display external incentive APR #886
Conversation
@srph is attempting to deploy a commit to the OsmoLabs Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I'd def appreciate it if you could implement this, as my plate has been quite full as of recently. I've started work on calculating external incentive here: osmosis-frontend/packages/stores/src/queries/pool-incentives/incentivized-pools.ts Line 258 in 23ecb4e
You could continue my work there. I'd like for it to be a callable function that we could then use anywhere. |
Hey @jonator thanks for advice. I have 2 questions:
|
I have another question: So, we have a variable called allowedGauges which is an array that displays the "external incentives" (in our case STRD) which is this: Which we'll use to add to the APRs: What I did was pretty simple - add What about when there are more than allowedGauges? |
@jonator Hey, thanks for the discussion earlier! I've updated the PR based on the direction I understood we were taking. It's likely I missed something - let me know if there's anything to change or improve. Here's how the UI looks now for pool 803: |
} | ||
|
||
const amount = externalGauge.rewardAmount.moveDecimalPointLeft( | ||
mintCurrency.coinDecimals |
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.
Diving the value by 1_000_000
gives me the value I expect, but I figured hard-coding doesn't make sense. So I took this from computeAPYForDuration
. Let me know I should be getting this value elsewhere.
for pool 803, I believe the 1 day and 7 day gauges should be 0% since there's no incentives for those gauges. The only gauge I expect to see an APR for external incentives is the 14 day gauge. |
@@ -118,6 +118,52 @@ export class ObservableQueryIncentivizedPools extends ObservableChainQuery<Incen | |||
} | |||
); | |||
|
|||
readonly computeAPYWithExternalIncentives = computedFn( |
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.
As Aidan and I agreed in the meeting, IMO we should calculate APR for a duration for external gauges separately from internal gauges.
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.
Then, we add them in the view layer.
This way, we would be able to separately display the APR for just external gauges of a certain duration.
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.
Then, we add them in the view layer.
@jonator Hmm, I'm not sure I'm able to follow. Can you help me recall this bit?
- Are we looking to add another gauge UI below the internal incentives?
- Are we looking to do add something similar to superfluidApr? Like 0.2% + 18% + 5%?
- Or instead do we simply want to refactor so we're calling this new function in the pool page like so:
queryOsmosis.queryIncentivizedPools.computeAPY(...).add(
queryOsmosis.queryIncentivizedPools.computeExternalIncentiveForDuration(...)
)
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.
Yeah we can use that code snippet for our current needs, but we'd also have those bullet points available as an option.
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.
Reminder: we're currently redesigning the pool detail page in a major way, so flexibility in our APIs is extra critical.
I know for a fact we will be displaying external incentive APRs in a different way.
@jonator Thanks for the notes. I've updated the PR again based on what I understood. Let me know if we're headed in the right direction or if there's anything else to improve. |
This is exciting! |
@JeremyParish69 Yea, I think that should be the effect when this PR is merged. This is the effect at least for pool 803:
Given that it only has one external incentive: I could update it to do something similar to superfluid pools and show something like |
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.
@srph It appears there's build errors in [id].tsx
@jonator Should be fixed now; I verified it by running |
What was the rationale for how you calculated the APR? Seems like a clever approach. |
@jonator I don't think I have a solid rationale about it. Last time I tried without notes, (existing APR from I figured Also to be honest, I'm not too familiar with CoinPretty/RatePretty in practice. If there's a better way to do this, let me know! |
This is the code Keplr uses to compute stake APR. May be a helpful reference. I know it helped my fix an issue with calculating swap fee APR. |
packages/stores/src/queries/pool-incentives/incentivized-pools.ts
Outdated
Show resolved
Hide resolved
@jonator Oops, good catch. Should be fixed now. I left the formula as comment for the time being - I think it makes sense to have it there. Should I remove it as well? |
…o srph/add-incentives
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.
LGTM
This is for the pool gauges in the pool page (
/pool/[id]
):For Stride, we'd like to display the sum of external and internal incentives.
This is how it looks like with the mentioned changes:
Relevant changes I've introduced are in
packages/web/pages/pool/[id].tsx
. In addition, I thought not every pool might like this change, so I've thought of putting this configuration behind a flag.I'd like to kindly ask for some pointers on how to implement this properly. Apparently, I've hard-coded some values (like dividing the values by 1m); and I'm not very familiar with
Keplr
'sDec
andRatePretty
as well.If there are variables or files I should take note of - that would be helpful.
I'll mark this as a draft PR once I have more idea on how to implement this properly