feat: refactored to use new endpoint SavingsGhoIncentive#2963
feat: refactored to use new endpoint SavingsGhoIncentive#2963AGMASO wants to merge 1 commit intoSDK-779-interface-incentivesfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR refactors sGHO-related APR/APY fetching and UI to use the new savingsGhoIncentive GraphQL endpoint, and wires that data into the various sGHO/staking surfaces and incentive tooltips.
Changes:
- Added
useSavingsGhoIncentivehook to query the newsavingsGhoIncentiveGraphQL endpoint. - Replaced sGHO incentive displays/tooltips to use
SavingsGhoIncentivesButton(backed by the new hook). - Removed legacy
useStakeTokenAPRand relaxed filtering inuseMeritIncentives.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/modules/staking/StakingPanelNoWallet.tsx | Switches staking incentives button to the new sGHO incentives source. |
| src/modules/staking/GhoStakingPanel.tsx | Switches staking incentives button to the new sGHO incentives source. |
| src/modules/sGho/SGhoHeader.tsx | Replaces legacy APR hook usage with useSavingsGhoIncentive for header APY display and user estimates. |
| src/modules/sGho/SGhoDepositPanel.tsx | Updates “Current APY” calculation and tooltip button to use the new endpoint. |
| src/modules/reserve-overview/Gho/SavingsGho.tsx | Uses useSavingsGhoIncentive and new incentives button for Savings GHO panel. |
| src/modules/markets/Gho/GhoBanner.tsx | Updates Savings GHO banner APY display to use the new endpoint. |
| src/hooks/useStakeTokenAPR.ts | Removes the legacy adapter hook (no longer used). |
| src/hooks/useSavingsGhoIncentive.ts | Introduces the new GraphQL hook for savingsGhoIncentive. |
| src/hooks/useMeritIncentives.ts | Removes actionKey/protocolAction allowlist filtering from Merit incentives selection. |
| src/components/transactions/SavingsGho/SavingsGhoModalDepositContent.tsx | Replaces merit incentives APR sourcing with the new endpoint for modal details. |
| src/components/incentives/IncentivesButton.tsx | Adds SavingsGhoIncentivesButton and refactors Merit button rendering to reuse shared content. |
Comments suppressed due to low confidence (1)
src/hooks/useMeritIncentives.ts:166
- Removing the
actionKey→protocolActionallowlist means stake-scoped Merit campaigns (e.g.ethereum-sgho,ethereum-stkgho) can now be returned for generic supply/borrow contexts whereveruseMeritIncentivesis used (markets/dashboard/tooltips). Consider restoring this filtering (or an equivalent backend-side filter) to avoid showing stake-only campaigns in the wrong protocol context.
for (const m of merits) {
let apr = 0;
const enriched = m as unknown as EnrichedMerit;
const rewardTokenAddress = enriched.rewardTokenAddress ?? '';
const rewardTokenSymbol = enriched.rewardTokenSymbol ?? '';
if (m.__typename === 'MeritSupplyIncentive') {
apr = parseFloat(m.extraSupplyApr.formatted);
} else if (m.__typename === 'MeritBorrowIncentive') {
apr = parseFloat(m.borrowAprDiscount.formatted);
} else if (m.__typename === 'MeritBorrowAndSupplyIncentiveCondition') {
apr = parseFloat(m.extraApr.formatted);
}
if (!Number.isFinite(apr) || apr <= 0) continue;
totalMeritAPR += apr;
const actionKey = enriched.actionKey ?? '';
if (actionKey) {
activeActions.push(actionKey);
actionMessages[actionKey] = {
customMessage: enriched.customMessage ?? undefined,
customForumLink: enriched.customForumLink ?? undefined,
};
if (!firstAction) firstAction = actionKey;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| title={ | ||
| <Box display="flex" alignItems="center"> | ||
| <Trans>APR</Trans> | ||
| </Box> | ||
| } | ||
| > | ||
| <MeritIncentivesButton | ||
| symbol="GHO" | ||
| market={currentMarketData.market} | ||
| protocolAction={ProtocolAction.stake} | ||
| /> | ||
| <SavingsGhoIncentivesButton /> | ||
| </PanelItem> |
There was a problem hiding this comment.
This panel is titled “APR” but renders SavingsGhoIncentivesButton, which supplies a value derived from convertAprToApy(...) (i.e., an APY-style rate). Update the title (and any related labels) to match the value being displayed, or change the value to an actual APR.
| value={meritIncentives?.incentiveAPR || '0'} | ||
| percent | ||
| /> | ||
| <DetailsNumberLine description={<Trans>APR</Trans>} value={savingsGhoAPY} percent /> |
There was a problem hiding this comment.
savingsGhoAPY is computed as an APY (APR converted to APY), but the modal details line is labeled “APR”. Update the label to “APY” or change the calculation to display the raw APR so the UI is consistent.
| <DetailsNumberLine description={<Trans>APR</Trans>} value={savingsGhoAPY} percent /> | |
| <DetailsNumberLine description={<Trans>APY</Trans>} value={savingsGhoAPY} percent /> |
| const apr = meritIncentives?.incentiveAPR || '0'; | ||
| const aprFormatted = (+apr * 100).toFixed(2); | ||
| const { data: savingsGhoIncentive } = useSavingsGhoIncentive(); | ||
| const aprFormatted = savingsGhoIncentive?.aprDecimal |
There was a problem hiding this comment.
aprFormatted is derived by converting an APR to APY (convertAprToApy(...) * 100), but it’s named/formatted as an APR value. This is easy to misapply in UI copy (and can result in “APR” labels showing an APY). Consider renaming to apyFormatted (and/or removing the APR→APY conversion if the intent is to display APR).
| const aprFormatted = savingsGhoIncentive?.aprDecimal | |
| const apyFormatted = savingsGhoIncentive?.aprDecimal |
General Changes
Developer Notes
Add any notes here that may be helpful for reviewers.
Reviewer Checklist
Please ensure you, as the reviewer(s), have gone through this checklist to ensure that the code changes are ready to ship safely and to help mitigate any downstream issues that may occur.
.env.examplefile as well as the pertinant.github/actions/*files