diff --git a/simulations/vip-diamond-cut-param-add/abi/VenusLens.json b/simulations/vip-diamond-cut-param-add/abi/VenusLens.json new file mode 100644 index 000000000..a7fff9593 --- /dev/null +++ b/simulations/vip-diamond-cut-param-add/abi/VenusLens.json @@ -0,0 +1,839 @@ +[ + { + "constant": true, + "inputs": [], + "name": "BLOCKS_PER_DAY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract ComptrollerInterface", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAccountLimits", + "outputs": [ + { + "components": [ + { + "internalType": "contract VToken[]", + "name": "markets", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "shortfall", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.AccountLimits", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address payable", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "comptrollerAddress", + "type": "address" + } + ], + "name": "getDailyXVS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovProposals", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "eta", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "signatures", + "type": "string[]" + }, + { + "internalType": "bytes[]", + "name": "calldatas", + "type": "bytes[]" + }, + { + "internalType": "uint256", + "name": "startBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "forVotes", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "againstVotes", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "canceled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "executed", + "type": "bool" + } + ], + "internalType": "struct VenusLens.GovProposal[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "address", + "name": "voter", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovReceipts", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "hasVoted", + "type": "bool" + }, + { + "internalType": "bool", + "name": "support", + "type": "bool" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "internalType": "struct VenusLens.GovReceipt[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract XVS", + "name": "xvs", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint32[]", + "name": "blockNumbers", + "type": "uint32[]" + } + ], + "name": "getVenusVotes", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VenusVotes[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract XVS", + "name": "xvs", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getXVSBalanceMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + }, + { + "internalType": "address", + "name": "delegate", + "type": "address" + } + ], + "internalType": "struct VenusLens.XVSBalanceMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract XVS", + "name": "xvs", + "type": "address" + }, + { + "internalType": "contract ComptrollerInterface", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getXVSBalanceMetadataExt", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + }, + { + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allocated", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.XVSBalanceMetadataExt", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "holder", + "type": "address" + }, + { + "internalType": "contract ComptrollerInterface", + "name": "comptroller", + "type": "address" + } + ], + "name": "pendingRewards", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "distributorAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardTokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "totalRewards", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "vTokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.PendingReward[]", + "name": "pendingRewards", + "type": "tuple[]" + } + ], + "internalType": "struct VenusLens.RewardSummary", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "vTokenBalances", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VTokenBalances", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VToken[]", + "name": "vTokens", + "type": "address[]" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "vTokenBalancesAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VTokenBalances[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + } + ], + "name": "vTokenMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "vTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "venusSupplySpeed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "venusBorrowSpeed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dailySupplyXvs", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dailyBorrowXvs", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VTokenMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VToken[]", + "name": "vTokens", + "type": "address[]" + } + ], + "name": "vTokenMetadataAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "vTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "venusSupplySpeed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "venusBorrowSpeed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dailySupplyXvs", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dailyBorrowXvs", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VTokenMetadata[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + } + ], + "name": "vTokenUnderlyingPrice", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VTokenUnderlyingPrice", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract VToken[]", + "name": "vTokens", + "type": "address[]" + } + ], + "name": "vTokenUnderlyingPriceAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VTokenUnderlyingPrice[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts index 2210b6627..f1d698764 100644 --- a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts +++ b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts @@ -10,25 +10,34 @@ import { vipCutParamAdd } from "../../../vips/vip-diamond-cut-param-add/vip-para import Comptroller from "../abi/Comptroller.json"; import IERC20Upgradeable from "../abi/IERC20UpgradableAbi.json"; import VBEP20_DELEGATE_ABI from "../abi/VBep20DelegateAbi.json"; +import VENUS_LENS_ABI from "../abi/VenusLens.json"; const UNITROLLER = "0xfD36E2c2a6789Db23113685031d7F16329158384"; +const VENUS_LENS = "0xfB0f09dB330dC842a6637BfB959209424BbFE8C7"; const Owner = "0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396"; const VBUSD = "0x95c78222B3D6e262426483D42CfA53685A67Ab9D"; const VUSDT = "0xfD5840Cd36d94D7229439859C0112a4185BC0255"; +const USER = "0x8894E0a0c962CB723c1976a4421c95949bE2D4E3"; // Added function signature for venusInitialIndex to market facet as cut param to diamond proxy // This fork block contains tests for venusInitialIndex only. forking(32159070, async () => { let diamondUnitroller: ethers.Contract; + let venusLens: ethers.Contract; before(async () => { diamondUnitroller = new ethers.Contract(UNITROLLER, Comptroller, ethers.provider); + venusLens = new ethers.Contract(VENUS_LENS, VENUS_LENS_ABI, ethers.provider); }); describe("Before execution of VIP", async () => { it("Fetching of VenusInitialIndex should revert", async () => { await expect(diamondUnitroller.venusInitialIndex()).to.be.reverted; }); + + it("Calculation of pending rewards should revert", async () => { + await expect(venusLens.pendingRewards(USER, UNITROLLER)).to.be.reverted; + }); }); testVip("VIP-Diamond cut param add", vipCutParamAdd()); @@ -37,6 +46,12 @@ forking(32159070, async () => { it("Fetching of VenusInitialIndex should return value", async () => { expect(await diamondUnitroller.venusInitialIndex()).to.be.equal(parseUnits("1", 36)); }); + + it("Calculation of pending rewards should return value", async () => { + const rewards = await venusLens.pendingRewards(USER, UNITROLLER); + expect(rewards.length).to.be.greaterThan(0); + expect(rewards[3][0].amount).to.be.equal(0); + }); }); }); diff --git a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts index f01e89916..19b0eb89a 100644 --- a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts +++ b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts @@ -10,25 +10,34 @@ import { vipCutParamAdd } from "../../../vips/vip-diamond-cut-param-add/vip-para import Comptroller from "../abi/Comptroller.json"; import IERC20Upgradeable from "../abi/IERC20UpgradableAbi.json"; import VBEP20_DELEGATE_ABI from "../abi/VBep20DelegateAbi.json"; +import VENUS_LENS_ABI from "../abi/VenusLens.json"; const UNITROLLER = "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D"; +const VENUS_LENS = "0x36B434654bD5fb010f8A68e190428dc4789E1b24"; const Owner = "0xce10739590001705F7FF231611ba4A48B2820327"; const VBUSD = "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4"; const VUSDT = "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A"; +const USER = "0xC825AD791A6046991e3706b6342970f6d87e4888"; // Added function signature for venusInitialIndex to market facet as cut param to diamond proxy // This fork block contains tests for venusInitialIndex only. -forking(33757000, async () => { +forking(33763885, async () => { let diamondUnitroller: ethers.Contract; + let venusLens: ethers.Contract; before(async () => { diamondUnitroller = new ethers.Contract(UNITROLLER, Comptroller, ethers.provider); + venusLens = new ethers.Contract(VENUS_LENS, VENUS_LENS_ABI, ethers.provider); }); describe("Before execution of VIP", async () => { it("Fetching of VenusInitialIndex should revert", async () => { await expect(diamondUnitroller.venusInitialIndex()).to.be.reverted; }); + + it("Calculation of pending rewards should revert", async () => { + await expect(venusLens.pendingRewards(USER, UNITROLLER)).to.be.reverted; + }); }); testVip("VIP-Diamond cut param add", vipCutParamAdd()); @@ -37,13 +46,19 @@ forking(33757000, async () => { it("Fetching of VenusInitialIndex should return value", async () => { expect(await diamondUnitroller.venusInitialIndex()).to.be.equal(parseUnits("1", 36)); }); + + it("Calculation of pending rewards should return value", async () => { + const rewards = await venusLens.pendingRewards(USER, UNITROLLER); + expect(rewards.length).to.be.greaterThan(0); + expect(rewards[3][0].amount).to.be.equal(0); + }); }); }); // As this vip is updating diamond proxy for the first time after it's implementation, // therefore adding additional tests to verify all storage values before and after executing this vip, // setter functions and core functionalities are working properly -forking(33757000, async () => { +forking(33763885, async () => { let owner: Signer, unitroller: Contract, // layout variables @@ -345,7 +360,7 @@ forking(33757000, async () => { }); }); -forking(33757000, async () => { +forking(33763885, async () => { let owner, unitroller; let USDT: Contract; let usdtHolder: Signer;