[VPD-1313] PrimeV2 deployments for BSC#677
Conversation
Wiring gated to hardhat (live wires via VIP), add impl verification, and drop the 'Prime' dependency to avoid re-triggering 012's proxy upgrade that reverts under Timelock ownership.
Deployment artifacts from deploying PrimeLeaderboard and PrimeV2 to bsctestnet. Contracts are unwired; setPrimeV2/setPrimeLeaderboard wiring lands via VIP.
…scripts Fold the Timelock ownership transfer into each deploy script so it runs with the deploy tag (the standalone PrimeLeaderboard deploy had no configure step). Removes the now-redundant 015-configure-prime-v2.
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
c73c8ff to
c3e0866
Compare
Standalone tagged hardhat-deploy script for deploying a new PrimeV2 implementation against a Timelock-owned proxy; the impl is left unwired so a governance VIP can call ProxyAdmin.upgrade to point the proxy at it. Includes the resulting bsctestnet implementation artifact.
… from primev2-testnet
Standalone view-only contract that reads PrimeV2 state via its public mappings. Replaces V1's removed 'calculateAPR' / 'estimateAPR' / 'incomeDistributionYearly' helpers without growing PrimeV2 past the 24KB EVM size limit. Adds 'APRInfo' and 'Capital' structs to 'IPrimeV2'.
| borrowAPR = totalBorrow == 0 ? 0 : ((userBorrowIncomeYearly * MAXIMUM_BPS) / totalBorrow); | ||
| } | ||
|
|
||
| function _getUnderlying(address vToken) internal view returns (address) { |
There was a problem hiding this comment.
we need handle the native token case, same with prime v2
function _getUnderlying(address vToken) internal view returns (address) {
if (vToken == primeV2.NATIVE_MARKET()) {
return primeV2.WRAPPED_NATIVE_TOKEN();
}
return IVToken(vToken).underlying();
}
| address market, | ||
| address user | ||
| ) external view returns (uint256 accrued, uint256 score, uint256 rewardIndex, uint256 lifetimeAccrued); | ||
|
|
There was a problem hiding this comment.
function NATIVE_MARKET() external view returns (address);
function WRAPPED_NATIVE_TOKEN() external view returns (address);
add this two to read from Prime v2
Resolve vBNB→WBNB in PrimeLens._getUnderlying so APR queries on the native market hit PLP correctly. Add hardhat-deploy script for PrimeLens, fork test, and a bsctestnet chain hardhat hardfork-history entry so the lens fork suite can run.
Summary
PrimeLens— a standalone view-only contract that reads PrimeV2's public mappings and reconstructs the V1 APR helpers (calculateAPR,estimateAPR,incomeDistributionYearly) for off-chain consumers. Lives in a separate deployment so PrimeV2 stays under the 24,576-byte EVM contract-size limit.Changes
Contracts
PrimeLens.sol— new stateless view contract. Reads PrimeV2's public getters viaIPrimeV2WithStorage; computes per-(market, user) APR figures off-chain. PrimeV2 itself unchanged → no link-time dependency, no contract-size pressure.IPrimeV2.sol— addedAPRInfoandCapitalstructs consumed by the lens.Deploy scripts
deploy/014-deploy-prime-leaderboard.ts— split out from the original combined script.deploy/014-deploy-prime-v2.ts— focused on PrimeV2 proxy + initialize, with ACM-permission grants for the local hardhat network and ownership transfer to the network'sNormalTimelockon live chains.deploy/015-deploy-prime-v2-impl.ts— impl-only redeploy path (no proxy / initialize); used when shipping a new PrimeV2 implementation for upgrade.deploy/016-deploy-prime-lens.ts— deploys the lens with the existing PrimeV2 proxy address as constructor arg.deploy/015-configure-prime-v2.ts— wiring now lives inside the per-contract scripts; on live networks the cross-contract setters run via VIP, not deploy.Deployments
0xeC22366d2572e52BCB29B50C905b945BA421B9b2), PrimeLeaderboard, PrimeLens, with implementations + proxies.0x4f5fd115Df31CC48De880a988D74aaD931851628), PrimeLeaderboard, PrimeLens (0x43e768EFa1bC365bfd0965A490a41d87c6Dea526), with implementations + proxies + solcInputs.Tests
tests/hardhat/PrimeV2/PrimeLens.ts— unit suite for the lens. Constructor edge cases; exact-equality assertions against PrimeV2 stored state; APR formula identity check; zero-distribution and no-totalScore branches; estimate's "subtract user score then re-add" invariant.tests/hardhat/Fork/PrimeLensForkTest.ts— bsctestnet fork test. Deploys fresh PrimeV2 + Leaderboard + Lens against real Comptroller/Oracle/XVSVault/PLP/ACM; verifies all three view helpers behave correctly against on-chain state.tests/hardhat/Fork/PrimeV2TestnetWbnbRewardForkTest.ts— fork test covering the native-market (WBNB) reward path on bsctestnet.Config
hardhat.config.ts— added chain 97 (bsctestnet) hardfork history toisFork()so testnet fork tests can execute historical blocks.