Skip to content

fix: count a Merkl campaign once when it covers several markets - #5816

Merged
cuzz-venus merged 1 commit into
mainfrom
fix/merkl-campaign-double-counted
Sep 17, 2026
Merged

cuzz-venus merged 1 commit into
mainfrom
fix/merkl-campaign-double-counted

Conversation

@cuzz-venus

Copy link
Copy Markdown
Contributor

Jira ticket(s)

VPD-XXX

Changes

  • The Venus API lists a Merkl campaign on every market it covers, so the collateral-gated borrow campaign (Borrow U, USDT using SKHYB, NVDAB, TSLAB, SPCXB as collateral on Venus) is served on both vU and vUSDT. getMerklCampaigns keys its output by market, so that one campaign reached formatMerklRewardsPayload twice. The reducer then emitted one pendingReward per entry — each resolved from the same campaign breakdown — and formatRewardSummaryData summed them, so the claim modal advertised the real amount multiplied by the number of markets the campaign covers.
  • Deduplicate the distributions by campaign id before building the summaries, so a campaign contributes its breakdown once no matter how many markets it covers. The reward token mapping, the reward token set and the per-token reduction all derive from the same list, so this is the single place that needed to change.
  • External rewards are claimed on Merkl, not through the protocol: the Claim union has no external variant and vTokenAddressesWithPendingReward never reaches a contract call for them, so dropping the duplicate market address is inert.

Campaigns covering a single market — every Merkl campaign before this one — keep their existing behavior, which the added spec pins down alongside the multi-market case.

The Venus API lists a campaign on every market it covers, so a campaign
spanning several borrow markets appeared once per market in
merklCampaigns. formatMerklRewardsPayload emitted one pendingReward per
entry, all resolved from the same campaign breakdown, and
formatRewardSummaryData summed them — reporting a claimable amount equal
to the real one multiplied by the number of markets.

Deduplicate the distributions by campaign id before building the
summaries, so a campaign contributes its breakdown once regardless of how
many markets it covers.
@changeset-bot

changeset-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3811682

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 17, 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 17, 2026 4:26pm UTC
dapp-testnet Ready Ready Preview Sep 17, 2026 4:26pm UTC
venus.io Ready Ready Preview Sep 17, 2026 4:26pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 17, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

The behavioral fix appears sound, but the repository’s explicit function-organization requirement must be satisfied before merging.

Summary

This PR prevents a multi-market Merkl campaign from contributing the same reward more than once.

  • Deduplicates Merkl distributions by case-normalized campaign identifier.
  • Adds regression coverage for multi-market and single-market campaigns.
  • Adds an EVM package changeset.

Reviews (1) · Last reviewed commit: "fix: count a Merkl campaign once when it..."

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report for ./apps/evm

Status Category Percentage Covered / Total
🔵 Lines 81.24% 53487 / 65833
🔵 Statements 81.24% 53487 / 65833
🔵 Functions 75.29% 1646 / 2186
🔵 Branches 86.24% 7973 / 9245
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/evm/src/clients/api/queries/getPendingRewards/getMerklUserRewards/formatMerklRewardsResponse.ts 100% 94.44% 100% 100%
Generated in workflow #14251 for commit 3811682 by the Vitest Coverage Report Action

@cuzz-venus
cuzz-venus merged commit 74940b3 into main Sep 17, 2026
5 checks passed
@cuzz-venus
cuzz-venus deleted the fix/merkl-campaign-double-counted branch September 17, 2026 16:41

This branch was successfully deployed

3 active deployments
Preview – dapp-preview — 38116824 Deployed Sep 17, 2026 by vercel[bot]
Preview – dapp-testnet — 38116824 Deployed Sep 17, 2026 by vercel[bot]
Preview – venus.io — 38116824 Deployed Sep 17, 2026 by vercel[bot]
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