Skip to content

feat: add campaign apy - #5803

Open
cuzz-venus wants to merge 2 commits into
mainfrom
feat/collateral-gated-borrow-rewards
Open

feat: add campaign apy#5803
cuzz-venus wants to merge 2 commits into
mainfrom
feat/collateral-gated-borrow-rewards

Conversation

@cuzz-venus

@cuzz-venus cuzz-venus commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Jira ticket(s)

VPD-1960

Changes

  • add borrow apy for campaign

@changeset-bot

changeset-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 25081e7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@venusprotocol/evm Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
dapp-preview Ready Ready Preview Sep 2, 2026 9:49am UTC
dapp-testnet Ready Ready Preview Sep 2, 2026 9:49am UTC
venus.io Ready Ready Preview Sep 2, 2026 9:49am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 2, 2026

Copy link
Copy Markdown

Greptile Summary

Adds per-user APY calculation and UI treatment for collateral-gated Merkl borrow campaigns.

  • Parses campaign APR and eligible collateral/borrow-market metadata from API reward distributors.
  • Computes account-specific eligibility and prorated campaign APY.
  • Adds Merkl badge, tooltip, APY breakdown, translations, tests, and borrow-reward sign formatting.
  • Transaction simulations currently retain pre-transaction Merkl gate values, and multi-campaign badges account for only one campaign.

Confidence Score: 3/5

The PR should not merge until transaction simulations recompute Merkl campaign eligibility and prospective badges account for every gated campaign.

Account-dependent Merkl distributions are copied unchanged into post-transaction previews, and markets with multiple gated campaigns receive a prospective APY based on only one campaign.

Files Needing Attention: apps/evm/src/clients/api/queries/useGetPools/useGetPoolsQuery/getPools/index.ts, apps/evm/src/clients/api/queries/getSimulatedPool/index.ts, apps/evm/src/components/Apy/index.tsx

Important Files Changed

Filename Overview
apps/evm/src/clients/api/queries/useGetPools/useGetPoolsQuery/getPools/appendMerklCollateralGates/index.ts Computes campaign eligibility and prorated APY correctly for current pool state, but its account-dependent output is not recomputed during transaction simulation.
apps/evm/src/clients/api/queries/useGetPools/useGetPoolsQuery/getPools/index.ts Integrates Merkl gate resolution into fetched pool construction, leaving simulated pools with stale derived values.
apps/evm/src/components/Apy/index.tsx Adds the Merkl prospective-APY badge but retains only the last ineligible campaign when multiple campaigns coexist.
apps/evm/src/components/Apy/DistributionList/index.tsx Centralizes reward rows and gated-campaign messaging, while violating the repository's one-function-per-file organization rule.
apps/evm/src/components/ApyBreakdown/formatRows/index.tsx Displays borrow rewards with the correct sign and exposes unavailable campaign maximums, but consumes potentially stale simulated gate values.

Reviews (1): Last reviewed commit: "feat: add campaign apy" | Re-trigger Greptile

Comment on lines +218 to +219
// Resolve per-user reward APYs of collateral-gated Merkl campaigns
appendMerklCollateralGates({ pools });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Simulations retain stale Merkl gates

When a transaction preview changes participating collateral, collateral status, or eligible debt, getSimulatedPool copies the Merkl gate and prorated APY computed for the current pool instead of recalculating them. The form therefore shows stale eligibility, reward APY, and total post-transaction APY—for example, withdrawing the qualifying collateral can leave the reward displayed as active.

Knowledge Base Used: Lending transaction flows

Comment on lines +55 to +59
} else if (
distribution.type === 'merkl' &&
distribution.collateralGate?.isUserEligible === false
) {
gatedMerklDistribution = distribution;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge drops additional gated campaigns

When a borrow market has multiple active gated Merkl campaigns for which the user is ineligible, this assignment retains only the last campaign and the badge subtracts only its maximum APY. The tooltip still lists every campaign, so the prospective APY shown on the badge omits rewards included in its breakdown.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for ./apps/evm

Status Category Percentage Covered / Total
🔵 Lines 80.81% 53049 / 65640
🔵 Statements 80.81% 53049 / 65640
🔵 Functions 74.72% 1623 / 2172
🔵 Branches 85.94% 7833 / 9114
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/evm/src/clients/api/queries/getSimulatedPool/index.ts 99.5% 93.02% 100% 99.5% 267
apps/evm/src/clients/api/queries/useGetPools/useGetPoolsQuery/getPools/index.ts 98.57% 93.22% 100% 98.57% 96, 103, 153
apps/evm/src/clients/api/queries/useGetPools/useGetPoolsQuery/getPools/withMerklCollateralGates/index.ts 100% 100% 100% 100%
apps/evm/src/components/Apy/index.tsx 100% 100% 100% 100%
apps/evm/src/components/Apy/BoostTooltip/index.tsx 100% 100% 100% 100%
apps/evm/src/components/Apy/DistributionList/index.tsx 3.54% 100% 0% 3.54% 19-183
apps/evm/src/components/Apy/MerklBadge/index.tsx 100% 100% 100% 100%
apps/evm/src/components/Apy/MerklBadge/MerklIcon/index.tsx 100% 100% 100% 100%
apps/evm/src/components/ApyBreakdown/formatRows/index.tsx 63.33% 66.66% 100% 63.33% 51-55, 58-59, 62-63, 66-67, 70-71, 91-94, 98-115, 128-129, 132-133, 136-137, 140-141, 144-147
apps/evm/src/types/index.ts 100% 100% 100% 100%
apps/evm/src/utilities/index.ts 100% 100% 100% 100%
apps/evm/src/utilities/formatApiRewardDistributors/index.ts 97.36% 83.33% 100% 97.36% 60-61
apps/evm/src/utilities/formatApiRewardDistributors/formatRewardTokenDistribution/index.ts 100% 100% 100% 100%
apps/evm/src/utilities/formatApiRewardDistributors/formatRewardTokenDistribution/formatRewardDistribution/index.ts 100% 100% 100% 100%
apps/evm/src/utilities/formatDistributionApyToReadableValue/index.ts 100% 100% 100% 100%
Generated in workflow #14204 for commit 25081e7 by the Vitest Coverage Report Action

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.

1 participant