Skip to content

Commit

Permalink
add hot-deploy support for another contract
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrowDom committed Dec 6, 2023
1 parent bbc2160 commit 47b9c0b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
4 changes: 4 additions & 0 deletions contracts/test/fixture/_fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,10 @@ async function balancerFrxETHwstETHeETHFixture(
config = { defaultStrategy: true }
) {
const fixture = await defaultFixture();
await hotDeployOption(fixture, "balancerFrxETHwstETHeETHFixture", {
isOethFixture: true,
});

const {
oethVault,
timelock,
Expand Down
40 changes: 36 additions & 4 deletions contracts/test/fixture/_hot-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,38 @@ const { impersonateAndFund } = require("../../utils/signers");

const log = require("../../utils/logger")("test:fixtures:hot-deploy");

// based on a contract name create new implementation
async function constructNewContract(fixture, implContractName) {
/* based on a contract name create new implementation
*/
async function constructNewContract(
fixture,
implContractName,
fixtureStrategyVarName
) {
const { deploy } = deployments;

const getConstructorArguments = () => {
if (
implContractName === "BalancerComposablePoolStrategy" &&
fixtureStrategyVarName === "balancerSfrxWstRETHStrategy"
) {
return [
[
addresses.mainnet.wstETH_sfrxETH_rETH_BPT,
addresses.mainnet.OETHVaultProxy,
],
[
addresses.mainnet.rETH,
addresses.mainnet.stETH,
addresses.mainnet.wstETH,
addresses.mainnet.frxETH,
addresses.mainnet.sfrxETH,
addresses.mainnet.balancerVault, // Address of the Balancer vault
balancer_wstETH_sfrxETH_rETH_PID, // Pool ID of the Balancer pool
],
addresses.mainnet.wstETH_sfrxETH_rETH_AuraRewards, // Address of the Aura rewards contract
0, // position of BPT token within the sfrxETH-rETH-wstETH Balancer pool
];
} else if (
["BalancerMetaPoolTestStrategy", "BalancerMetaPoolStrategy"].includes(
implContractName
)
Expand Down Expand Up @@ -140,7 +166,6 @@ async function hotDeployOption(
if (implAddress === "0xAaA1d497fdff9a88048743Db31d3173a2E442A3D") {
log(`Caching rate providers and pool assets`);
await fixture[strategyVarName].connect(fixture.josh).cachePoolAssets();

await fixture[strategyVarName].connect(fixture.josh).cacheRateProviders();
} else {
throw new Error(
Expand Down Expand Up @@ -184,6 +209,12 @@ async function hotDeployOption(
);

await cacheAssetsAndProviders("balancerREthStrategy");
} else if (fixtureName === "balancerFrxETHwstETHeETHFixture") {
await hotDeployFixture(
fixture, // fixture
"balancerSfrxWstRETHStrategy", // fixtureStrategyVarName
"BalancerComposablePoolStrategy" // implContractName
);
} else if (
fixtureName === "balancerSfrxETHRETHWstETHBrokenWithdrawalFixture"
) {
Expand Down Expand Up @@ -380,7 +411,8 @@ async function hotDeployFixture(

const newlyCompiledImplContract = await constructNewContract(
fixture,
implContractName
implContractName,
fixtureStrategyVarName
);
log(`New contract deployed at ${newlyCompiledImplContract.address}`);

Expand Down
5 changes: 4 additions & 1 deletion contracts/test/vault/harvester.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const { createFixtureLoader, harvesterFixture } = require("./../fixture/_fixture");
const {
createFixtureLoader,
harvesterFixture,
} = require("./../fixture/_fixture");
const { shouldBehaveLikeHarvester } = require("../behaviour/harvester");

const loadFixture = createFixtureLoader(harvesterFixture);
Expand Down

0 comments on commit 47b9c0b

Please sign in to comment.