Skip to content

feat: support abi & api#5641

Open
cuzz-venus wants to merge 35 commits into
mainfrom
feat/prime-leaderboard-api
Open

feat: support abi & api#5641
cuzz-venus wants to merge 35 commits into
mainfrom
feat/prime-leaderboard-api

Conversation

@cuzz-venus

Copy link
Copy Markdown
Contributor

Jira ticket(s)

VPD-1337

Changes

  • support contract abi
  • support api

@changeset-bot

changeset-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5e001b6

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

@cuzz-venus cuzz-venus force-pushed the feat/prime-leaderboard-api branch from bf5d385 to 4b14711 Compare June 17, 2026 02:49
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
dapp-preview Ready Ready Preview Jun 29, 2026 7:54am
dapp-testnet Ready Ready Preview Jun 29, 2026 7:54am
venus.io Ready Ready Preview Jun 29, 2026 7:54am

Request Review

@greptile-apps

greptile-apps Bot commented Jun 17, 2026

Copy link
Copy Markdown

Greptile Summary

This PR wires up the contract ABI and API layer for Prime V2 (PrimeLeaderboard + PrimeV2 contracts) and the new Prime Leaderboard backend endpoints, replacing the placeholder data in useGetPrimeRank.

  • Adds 10 new query modules (getPrimeCurrentCycle, getPrimeCycle, getPrimeCycles, getPrimeLeaderboard, getPrimeRewardsLeaderboard, getPrimeMinimumStake, getPrimeTokenLimit, getPrimeUserPendingRewards, getPrimeUserCycleRewards, getPrimeEffectiveStake, getPrimeMultiplierTiers) following the existing 3-layer API pattern.
  • Migrates getPendingRewards from the original Prime contract to the new PrimeV2 contract for fetching pending rewards; PrimeV2 and PrimeLeaderboard contract addresses are currently only configured for BSC_TESTNET (pending package publication), which silently disables prime pending rewards on all other chains including BSC_MAINNET.

Confidence Score: 4/5

Safe to merge into the feature branch for continued development, but the getPendingRewards migration from Prime to PrimeV2 must be resolved before merging toward mainnet.

The useGetPendingRewards hook now looks up the contract under the name PrimeV2, which only has an address configured for BSC_TESTNET. On every other chain that previously showed Prime pending rewards (BSC_MAINNET, ETHEREUM, SEPOLIA, Arbitrum, etc.) the address resolves to undefined and the prime reward fetch is silently skipped. All other new query modules follow established patterns correctly.

apps/evm/src/clients/api/queries/getPendingRewards/useGetPendingRewards.ts and apps/evm/src/clients/api/queries/getPendingRewards/index.ts — the switch from Prime to PrimeV2 needs mainnet addresses (or a conditional fallback to Prime) before this can ship to production chains.

Important Files Changed

Filename Overview
apps/evm/src/clients/api/queries/getPendingRewards/useGetPendingRewards.ts Switched contract lookup from Prime (multi-chain) to PrimeV2 (BSC_TESTNET only), breaking prime pending rewards on all other supported chains
apps/evm/src/clients/api/queries/getPendingRewards/index.ts Replaced all primeAbi/primeContractAddress references with primeV2Abi/primeV2ContractAddress; now silently skips prime rewards on chains where PrimeV2 has no address
apps/evm/src/libs/contracts/config/index.ts Adds PrimeV2 and PrimeLeaderboard contracts with hardcoded testnet addresses and TODO to source from packages once published; existing Prime contract retained
apps/evm/src/containers/PrimeRank/useGetPrimeRank/index.ts Replaces placeholder data with live queries; isCandidate logic, gapXvsTokens calculation, and isLoading aggregation look correct
apps/evm/src/clients/api/queries/getPrimeCycles/index.ts New query for listing Prime cycles; PrimeFinalizedCycleResponse omits status, so it is silently dropped in the mapped output
apps/evm/src/clients/api/queries/getPrimeEffectiveStake/index.ts New on-chain query fetching effectiveStake and totalStaked for a user from the PrimeLeaderboard contract; clean parallel reads with BigNumber conversion
apps/evm/src/clients/api/queries/getPrimeCurrentCycle/index.ts New REST query for the active Prime cycle and pending reward pool; correct error handling and USD-cents field renaming
apps/evm/src/constants/functionKey.ts Adds 11 new FunctionKey enum entries for Prime V2 queries; no conflicts

Reviews (2): Last reviewed commit: "fix: review comments" | Re-trigger Greptile

Comment on lines +33 to +36
queryKey: [
FunctionKey.GET_PRIME_USER_PENDING_REWARDS,
{ chainId, accountAddress: accountAddress as Address },
],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Unsafe as Address cast embeds undefined into the query key

accountAddress is Address | undefined, but the cast to Address makes the query key's TypeScript type claim it is always a valid address. When the hook is disabled (because accountAddress is undefined), the key is { ..., accountAddress: undefined } even though the type says Address. This can cause silent cache-key mismatches if downstream code ever inspects or matches these keys. The same pattern appears in useGetPrimeUserCycleRewards.ts. A safe fallback avoids the assertion entirely.

Suggested change
queryKey: [
FunctionKey.GET_PRIME_USER_PENDING_REWARDS,
{ chainId, accountAddress: accountAddress as Address },
],
queryKey: [
FunctionKey.GET_PRIME_USER_PENDING_REWARDS,
{ chainId, accountAddress: accountAddress ?? ('' as Address) },
],

return useQuery({
queryKey: [
FunctionKey.GET_PRIME_USER_CYCLE_REWARDS,
{ chainId, cycleIndex, accountAddress: accountAddress as Address },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Same unsafe as Address cast in query key

accountAddress can be undefined here too (it is typed Address | undefined in the hook input), yet it is cast to Address in the query key. When the hook is disabled, the serialised key silently contains undefined while the type asserts Address.

Suggested change
{ chainId, cycleIndex, accountAddress: accountAddress as Address },
{ chainId, cycleIndex, accountAddress: accountAddress ?? ('' as Address) },

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for ./apps/evm

Status Category Percentage Covered / Total
🔵 Lines 82.4% 50289 / 61027
🔵 Statements 82.4% 50289 / 61027
🔵 Functions 62.48% 678 / 1085
🔵 Branches 73.22% 5706 / 7792
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/evm/src/App/Routes/index.tsx 0% 0% 0% 0% 1-309
apps/evm/src/clients/api/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/mutations/useClaimRewards/index.ts 98.8% 85.71% 100% 98.8% 1
apps/evm/src/clients/api/mutations/useClaimRewards/formatToCalls/index.ts 98.79% 75% 100% 98.79% 1
apps/evm/src/clients/api/queries/getHypotheticalPrimeApys/index.ts 96.72% 0% 100% 96.72% 1, 55
apps/evm/src/clients/api/queries/getHypotheticalPrimeApys/useGetHypotheticalPrimeApys.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getIsUserPrimeV2/index.ts 93.75% 0% 100% 93.75% 3
apps/evm/src/clients/api/queries/getIsUserPrimeV2/useGetIsUserPrimeV2/index.ts 97.29% 40% 100% 97.29% 1
apps/evm/src/clients/api/queries/getPendingRewards/index.ts 97.17% 62.85% 100% 97.17% 2, 45-48, 200, 219
apps/evm/src/clients/api/queries/getPendingRewards/useGetPendingRewards.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPendingRewards/formatOutput/formatToPrimePendingRewardGroup.ts 92.98% 28.57% 100% 92.98% 1, 35, 42, 49
apps/evm/src/clients/api/queries/getPendingRewards/formatOutput/index.ts 99.29% 68.75% 100% 99.29% 1
apps/evm/src/clients/api/queries/getPrimeCurrentCycle/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeCurrentCycle/useGetPrimeCurrentCycle.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeCycle/index.ts 75% 100% 0% 75% 62-74
apps/evm/src/clients/api/queries/getPrimeCycle/useGetPrimeCycle.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeCycles/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeCycles/useGetPrimeCycles.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeDeposits/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeDeposits/useGetPrimeDeposits.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeDistributionForMarket/index.ts 88.88% 0% 100% 88.88% 1, 27
apps/evm/src/clients/api/queries/getPrimeDistributionForMarket/useGetPrimeDistributionForMarket.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeEffectiveStake/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeEffectiveStake/useGetPrimeEffectiveStake.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeLeaderboard/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeLeaderboard/useGetPrimeLeaderboard.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeMinimumStake/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeMinimumStake/useGetPrimeMinimumStake.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeMultiplierTiers/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeMultiplierTiers/useGetPrimeMultiplierTiers.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeRewardsLeaderboard/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeRewardsLeaderboard/useGetPrimeRewardsLeaderboard.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeTokenLimit/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeTokenLimit/useGetPrimeTokenLimit.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeUserCycleRewards/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeUserCycleRewards/useGetPrimeUserCycleRewards.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeUserPendingRewards/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeUserPendingRewards/useGetPrimeUserPendingRewards.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPrimeVaultConfig/index.ts 96.66% 0% 100% 96.66% 1
apps/evm/src/clients/api/queries/getPrimeVaultConfig/useGetPrimeVaultConfig/index.ts 92.85% 57.14% 100% 92.85% 1, 49
apps/evm/src/clients/api/queries/getSimulatedPool/index.ts 99.5% 90.69% 100% 99.5% 1
apps/evm/src/clients/api/queries/getSimulatedPool/addUserPrimeApys/index.ts 98.48% 91.66% 100% 98.48% 4
apps/evm/src/clients/api/queries/getSimulatedPool/useGetSimulatedPool/index.ts 95.45% 66.66% 100% 95.45% 1, 50
apps/evm/src/clients/api/queries/useGetPools/useGetPoolsQuery/index.ts 93.05% 37.5% 100% 93.05% 1, 109-112
apps/evm/src/clients/api/queries/useGetPools/useGetPoolsQuery/getPools/index.ts 99.51% 92.3% 100% 99.51% 4
apps/evm/src/clients/api/queries/useGetPools/useGetPoolsQuery/getPools/appendPrimeSimulationDistributions/index.ts 98.88% 92.3% 100% 98.88% 1
apps/evm/src/clients/api/queries/useGetPools/useGetPoolsQuery/getPools/getUserPrimeApys/index.ts 96.66% 57.14% 100% 96.66% 1
apps/evm/src/components/Icon/icons/index.ts 100% 100% 100% 100%
apps/evm/src/components/Icon/icons/medal.tsx 17.64% 100% 0% 17.64% 5-19
apps/evm/src/components/Icon/icons/trophy.tsx 21.42% 100% 0% 21.42% 5-16
apps/evm/src/components/Pagination/index.tsx 93.05% 77.77% 20% 93.05% 56-57, 86-89
apps/evm/src/components/Pagination/usePagination.ts 85.24% 84.61% 0% 85.24% 1, 70-79
apps/evm/src/components/Table/index.tsx 94.97% 94.11% 33.33% 94.97% 63-67, 72-77
apps/evm/src/components/Table/Head/index.tsx 100% 94.73% 50% 100%
apps/evm/src/components/Table/TableCards/index.tsx 89.81% 100% 33.33% 89.81% 60-71, 119
apps/evm/src/components/Tabs/index.tsx 88.46% 92.3% 0% 88.46% 35-46, 69
apps/evm/src/constants/functionKey.ts 100% 50% 100% 100%
apps/evm/src/constants/prime.ts 99.07% 0% 100% 99.07% 1
apps/evm/src/containers/Layout/NavBar/ClaimRewardsButton/useGetGroups.ts 98.76% 91.89% 100% 98.76% 1, 121
apps/evm/src/containers/Layout/NavBar/ConnectButton/index.tsx 88.6% 91.66% 0% 88.6% 31-37, 41-42
apps/evm/src/containers/PrimeRank/EligibilityStatus/index.tsx 100% 92.3% 100% 100%
apps/evm/src/containers/PrimeRank/Footer/index.tsx 100% 50% 100% 100%
apps/evm/src/containers/PrimeRank/calculateStakeToReachTop/index.ts 69.23% 25% 33.33% 69.23% 1, 36-42, 45-54
apps/evm/src/containers/PrimeRank/getRankLabels/index.ts 91.66% 66.66% 100% 91.66% 1
apps/evm/src/containers/PrimeRank/useGetPrimeRank/index.ts 98.27% 87.5% 100% 98.27% 1
apps/evm/src/containers/PrimeRank/useGetPrimeRankLimit/index.ts 83.33% 50% 100% 83.33% 1
apps/evm/src/containers/PrimeStatusBanner/index.tsx 96.03% 93.54% 33.33% 96.03% 69-72, 182, 189-195, 286
apps/evm/src/containers/VaultCard/index.tsx 76.99% 68.18% 0% 76.99% 54-58, 61-63, 67, 96-98, 122-141, 212-229, 260-265, 271-274
apps/evm/src/containers/VaultCard/PrimeEligibilityInlineContent/index.tsx 100% 80% 0% 100%
apps/evm/src/containers/VenusVaultModal/Footer/index.tsx 100% 94.73% 100% 100%
apps/evm/src/containers/VenusVaultModal/WithdrawTab/WithdrawFromVestingVaultForm/RequestWithdrawalForm/index.tsx 97.94% 84.61% 100% 97.94% 59-60, 74-75
apps/evm/src/hooks/useIsFeatureEnabled/index.tsx 99.33% 0% 100% 99.33% 1
apps/evm/src/hooks/useIsUserPrime/index.ts 96.42% 85.71% 100% 96.42% 1
apps/evm/src/hooks/usePrimeVersion/index.tsx 90.9% 66.66% 100% 90.9% 1
apps/evm/src/hooks/useSimulateBalanceMutations/index.ts 98.07% 0% 100% 98.07% 1
apps/evm/src/libs/contracts/config/index.ts 0% 100% 100% 0% 3-938
apps/evm/src/pages/PrimeLeaderboard/index.tsx 87.65% 71.42% 100% 87.65% 81-92
apps/evm/src/pages/PrimeLeaderboard/EndOfCycle/index.tsx 96.1% 81.81% 100% 96.1% 47-50
apps/evm/src/pages/PrimeLeaderboard/Hero/index.tsx 100% 0% 100% 100%
apps/evm/src/pages/PrimeLeaderboard/LastCycleSummaryModal/index.tsx 100% 50% 100% 100%
apps/evm/src/pages/PrimeLeaderboard/LastCycleSummaryModal/UserRankCard/index.tsx 97.56% 50% 100% 97.56% 24
apps/evm/src/pages/PrimeLeaderboard/LastCycleSummaryModal/useGetPrimeLastCycleSummary/index.ts 88.23% 81.25% 100% 88.23% 1, 62-66
apps/evm/src/pages/PrimeLeaderboard/MarketActionsButton/index.tsx 100% 50% 50% 100%
apps/evm/src/pages/PrimeLeaderboard/MarketRewardRow/index.tsx 100% 84.61% 100% 100%
apps/evm/src/pages/PrimeLeaderboard/PrimeLeaderboardTable/index.tsx 100% 0% 100% 100%
apps/evm/src/pages/PrimeLeaderboard/RankCard/index.tsx 100% 80% 100% 100%
apps/evm/src/pages/PrimeLeaderboard/RankSection/index.tsx 100% 0% 0% 100%
apps/evm/src/pages/PrimeLeaderboard/RankTable/index.tsx 95.4% 69.23% 75% 95.4% 92-96
apps/evm/src/pages/PrimeLeaderboard/RankingPanel/index.tsx 100% 0% 100% 100%
apps/evm/src/pages/PrimeLeaderboard/RefreshNote/index.tsx 100% 50% 100% 100%
apps/evm/src/pages/PrimeLeaderboard/RewardTable/index.tsx 92.1% 76.19% 80% 92.1% 116-125
apps/evm/src/pages/PrimeLeaderboard/RewardsPanel/index.tsx 100% 66.66% 100% 100%
apps/evm/src/pages/PrimeLeaderboard/RulesModal/index.tsx 100% 50% 100% 100%
apps/evm/src/pages/PrimeLeaderboard/TotalRewardsCard/index.tsx 100% 66.66% 100% 100%
apps/evm/src/pages/PrimeLeaderboard/TotalRewardsSection/index.tsx 100% 0% 100% 100%
apps/evm/src/pages/PrimeLeaderboard/UserRewardsCard/index.tsx 100% 93.75% 100% 100%
apps/evm/src/pages/PrimeLeaderboard/UserRewardsSection/index.tsx 82.92% 20% 100% 82.92% 27-32, 40
apps/evm/src/pages/PrimeLeaderboard/buildPrimeMarketRewards/index.ts 96.15% 66.66% 100% 96.15% 4
apps/evm/src/pages/PrimeLeaderboard/calculatePrimeRewardCents/index.ts 94.44% 33.33% 100% 94.44% 1
apps/evm/src/pages/PrimeLeaderboard/resolvePrimeTotalRewardCents/index.ts 100% 50% 100% 100%
apps/evm/src/pages/PrimeLeaderboard/useGetPrimeRankScore/index.ts 96.42% 83.33% 100% 96.42% 1
apps/evm/src/pages/PrimeLeaderboard/useGetPrimeTotalRewards/index.ts 95.45% 77.77% 100% 95.45% 1
apps/evm/src/pages/PrimeLeaderboard/useGetPrimeUserRewards/index.ts 79.06% 73.33% 100% 79.06% 1, 36-38, 42-47
apps/evm/src/pages/Vai/Borrow/index.tsx 95.08% 83.72% 100% 95.08% 62, 84-85, 100, 110, 198-202, 219-220
apps/evm/src/types/index.ts 100% 100% 100% 100%
Generated in workflow #13735 for commit 9ae9878 by the Vitest Coverage Report Action

Comment thread apps/evm/src/clients/api/queries/getPrimeCurrentCycle/index.ts Outdated
Comment thread apps/evm/src/clients/api/queries/getPrimeCurrentCycle/index.ts Outdated
Comment thread apps/evm/src/clients/api/queries/getPrimeCurrentCycle/index.ts Outdated
Comment thread apps/evm/src/clients/api/queries/getPrimeCycles/index.ts Outdated
Comment thread apps/evm/src/clients/api/queries/getPrimeCurrentCycle/index.ts Outdated
Comment thread apps/evm/src/clients/api/queries/getPrimePastCycle/index.ts Outdated
Comment thread apps/evm/src/clients/api/queries/getPrimePastCycle/index.ts Outdated
Comment thread apps/evm/src/clients/api/queries/getPrimePastCycle/useGetPrimePastCycle.ts Outdated
Comment thread apps/evm/src/containers/PrimeRank/EligibilityStatus/index.tsx Outdated
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.

2 participants