Skip to content

Commit

Permalink
Merge pull request #462 from VenusProtocol/support-latest-protocol-re…
Browse files Browse the repository at this point in the history
…serve-package

fix: support breaking changes in protocol reserve deployment scripts
  • Loading branch information
coreyar authored Dec 19, 2024
2 parents abfe9c0 + d50f1c9 commit adbda19
Show file tree
Hide file tree
Showing 9 changed files with 1,429 additions and 1,320 deletions.
5 changes: 3 additions & 2 deletions deploy/009-deploy-vtokens.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import deployProtocolShareReserve from "@venusprotocol/protocol-reserve/dist/deploy/001-psr";
import timelocksDeployment from "@venusprotocol/governance-contracts/dist/deploy/001-source-timelocks";
import deployProtocolShareReserve from "@venusprotocol/protocol-reserve/dist/deploy/000-psr";
import { BigNumber, BigNumberish } from "ethers";
import { parseUnits } from "ethers/lib/utils";
import { ethers } from "hardhat";
Expand All @@ -23,7 +24,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const { isTimeBased, blocksPerYear } = getBlockOrTimestampBasedDeploymentInfo(hre.network.name);
const maxBorrowRateMantissa = getMaxBorrowRateMantissa(hre.network.name);

await timelocksDeployment(hre);
const accessControlManagerAddress = await toAddress(
preconfiguredAddresses.AccessControlManager || "AccessControlManager",
hre,
Expand Down
2 changes: 1 addition & 1 deletion deploy/014-riskfund-protocolshare.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import deployRiskFund from "@venusprotocol/protocol-reserve/dist/deploy/006-risk-fund-v2";
import deployRiskFund from "@venusprotocol/protocol-reserve/dist/deploy/001-risk-fund-v2";
import { HardhatRuntimeEnvironment } from "hardhat/types";

deployRiskFund.tags = ["RiskFund", "il"];
Expand Down
2 changes: 0 additions & 2 deletions deploy/015-funds-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import deployProtocolShareReserve from "@venusprotocol/protocol-reserve/dist/deploy/001-psr";
import { ethers } from "hardhat";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
Expand Down Expand Up @@ -43,7 +42,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
} catch (e) {
if (!hre.network.live) {
console.warn("ProtocolShareReserve contract not found. Deploying address");
await deployProtocolShareReserve(hre);
protocolShareReserveAddress = (await ethers.getContract("ProtocolShareReserve")).address;
} else {
throw e;
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@openzeppelin/contracts-upgradeable": "^4.8.3",
"@openzeppelin/hardhat-upgrades": "^1.21.0",
"@solidity-parser/parser": "^0.13.2",
"@venusprotocol/solidity-utilities": "^2.0.0",
"@venusprotocol/solidity-utilities": "2.0.3",
"ethers": "^5.7.0",
"hardhat-deploy": "^0.11.14",
"module-alias": "^2.2.2"
Expand Down Expand Up @@ -79,7 +79,7 @@
"@typescript-eslint/parser": "^5.27.1",
"@venusprotocol/governance-contracts": "2.6.0",
"@venusprotocol/oracle": "2.7.0",
"@venusprotocol/protocol-reserve": "2.4.0",
"@venusprotocol/protocol-reserve": "3.0.1",
"@venusprotocol/venus-protocol": "9.4.0",
"bignumber.js": "9.0.0",
"chai": "^4.3.6",
Expand Down Expand Up @@ -113,7 +113,8 @@
"ganache-core": "github:compound-finance/ganache-core.git#jflatow/unbreak-fork",
"solidity-parser-antlr": "https://github.com/solidity-parser/parser#0.8.2",
"@defi-wonderland/smock": "2.3.5",
"hardhat": "2.19.4"
"hardhat": "2.19.4",
"@venusprotocol/solidity-utilities": "2.0.3"
},
"publishConfig": {
"access": "public",
Expand Down
4 changes: 2 additions & 2 deletions tests/hardhat/Prime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ async function deployProtocol(): Promise<SetupProtocolFixture> {
],
{
constructorArgs: [false, blocksPerYear],
unsafeAllow: "constructor",
unsafeAllow: ["constructor", "internal-function-storage"],
},
);

Expand Down Expand Up @@ -226,7 +226,7 @@ async function deployProtocol(): Promise<SetupProtocolFixture> {
],
{
constructorArgs: [weth.address, vETH.address, 10512000, stakingPeriod, minimumXVS, maximumXVSCap, false],
unsafeAllow: "constructor",
unsafeAllow: ["constructor", "internal-function-storage"],
},
);

Expand Down
10 changes: 5 additions & 5 deletions tests/hardhat/Rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ async function rewardsFixture(isTimeBased: boolean) {
rewardsDistributor = (await upgrades.deployProxy(
RewardsDistributor,
[comptrollerProxy.address, xvs.address, maxLoopsLimit, fakeAccessControlManager.address],
{ constructorArgs: [isTimeBased, blocksPerYear] },
{ constructorArgs: [isTimeBased, blocksPerYear], unsafeAllow: ["internal-function-storage"] },
)) as RewardsDistributor;

const rewardsDistributor2 = await upgrades.deployProxy(
RewardsDistributor,
[comptrollerProxy.address, mockDAI.address, maxLoopsLimit, fakeAccessControlManager.address],
{ constructorArgs: [isTimeBased, blocksPerYear] },
{ constructorArgs: [isTimeBased, blocksPerYear], unsafeAllow: ["internal-function-storage"] },
);
const initialXvs = convertToUnit(1000000, 18);
await xvs.faucet(initialXvs);
Expand Down Expand Up @@ -296,7 +296,7 @@ for (const isTimeBased of [false, true]) {
rewardsDistributor = (await upgrades.deployProxy(
RewardsDistributor,
[comptrollerProxy.address, xvs.address, maxLoopsLimit, fakeAccessControlManager.address],
{ constructorArgs: [isTimeBased, blocksPerYear] },
{ constructorArgs: [isTimeBased, blocksPerYear], unsafeAllow: ["internal-function-storage"] },
)) as RewardsDistributor;

await expect(comptrollerProxy.addRewardsDistributor(rewardsDistributor.address))
Expand All @@ -309,7 +309,7 @@ for (const isTimeBased of [false, true]) {
rewardsDistributor = (await upgrades.deployProxy(
RewardsDistributor,
[comptrollerProxy.address, mockWBTC.address, maxLoopsLimit, fakeAccessControlManager.address],
{ constructorArgs: [isTimeBased, blocksPerYear] },
{ constructorArgs: [isTimeBased, blocksPerYear], unsafeAllow: ["internal-function-storage"] },
)) as RewardsDistributor;

await expect(comptrollerProxy.addRewardsDistributor(rewardsDistributor.address))
Expand Down Expand Up @@ -370,7 +370,7 @@ for (const isTimeBased of [false, true]) {
const newRewardsDistributor = (await upgrades.deployProxy(
RewardsDistributor,
[comptrollerProxy.address, xvs.address, maxLoopsLimit, fakeAccessControlManager.address],
{ constructorArgs: [isTimeBased, blocksPerYear] },
{ constructorArgs: [isTimeBased, blocksPerYear], unsafeAllow: ["internal-function-storage"] },
)) as RewardsDistributor;

await comptrollerProxy.addRewardsDistributor(newRewardsDistributor.address);
Expand Down
6 changes: 5 additions & 1 deletion tests/hardhat/Shortfall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ async function shortfallFixture() {
shortfall = await upgrades.deployProxy(
Shortfall,
[fakeRiskFund.address, parseUnits(minimumPoolBadDebt, "18"), accessControlManager.address],
{ constructorArgs: [isTimeBased, blocksPerYear, nextBidderBlockOrTimestampLimit, waitForFirstBidder] },
{
constructorArgs: [isTimeBased, blocksPerYear, nextBidderBlockOrTimestampLimit, waitForFirstBidder],
unsafeAllow: ["internal-function-storage"],
},
);

[owner, someone, bidder1, bidder2] = await ethers.getSigners();
Expand Down Expand Up @@ -207,6 +210,7 @@ async function timeBasedhortfallFixture() {
[fakeRiskFund.address, parseUnits(minimumPoolBadDebt, "18"), accessControlManager.address],
{
constructorArgs: [isTimeBased, blocksPerYear, nextBidderBlockOrTimestampLimit, waitForFirstBidder],
unsafeAllow: ["internal-function-storage"],
},
);
[owner, someone, bidder1, bidder2] = await ethers.getSigners();
Expand Down
1 change: 1 addition & 0 deletions tests/hardhat/util/TokenTestHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const deployVTokenBeacon = async <VTokenFactory extends AnyVTokenFactory
const VToken = await ethers.getContractFactory<VTokenFactory>(kind);
const vTokenBeacon = (await upgrades.deployBeacon(VToken, {
constructorArgs: [isTimeBased, blocksPerYear, maxBorrowRateMantissa],
unsafeAllow: ["internal-function-storage"],
})) as UpgradeableBeacon;
return vTokenBeacon;
};
Expand Down
Loading

0 comments on commit adbda19

Please sign in to comment.