Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
Refactor manage:registrar:setStratParams to read StratConfig during r…
Browse files Browse the repository at this point in the history
…untime
  • Loading branch information
0xNeshi committed Oct 2, 2023
1 parent 541313c commit 48bcff3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 33 deletions.
5 changes: 3 additions & 2 deletions tasks/deploy/integrations/helpers/fullStrategy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {ContractFactory} from "ethers";
import {Deployment, StrategyApprovalState} from "types";
import {
AllStratConfigs,
deploy,
getAddresses,
getChainId,
Expand All @@ -15,7 +16,7 @@ import {deployVaultPair} from "contracts/core/vault/scripts/deployVaultPair";
import {HardhatRuntimeEnvironment} from "hardhat/types";

export async function deployStrategySet(
strategyName: string,
strategyName: keyof AllStratConfigs,
factory: ContractFactory,
signerPkey: string,
hre: HardhatRuntimeEnvironment
Expand Down Expand Up @@ -65,7 +66,7 @@ export async function deployStrategySet(

// establish registrar config on primary chain and this chain
await hre.run("manage:registrar:setStratParams", {
stratName: strategyName,
strategyName: strategyName,
modifyExisting: true,
apTeamSignerPkey: signerPkey,
});
Expand Down
57 changes: 26 additions & 31 deletions tasks/manage/registrar/setStratParams.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import {allStrategyConfigs} from "contracts/integrations/stratConfig";
import {subtask, task, types} from "hardhat/config";
import {subtask, task} from "hardhat/config";
import {submitMultiSigTx} from "tasks/helpers";
import {cliTypes} from "tasks/types";
import {Registrar__factory} from "typechain-types";
import {ChainID} from "types";
import {StratConfig, getAPTeamOwner, getAddressesByNetworkId, isProdNetwork, logger} from "utils";
import {
AllStratConfigs,
StratConfig,
getAPTeamOwner,
getAddressesByNetworkId,
getPrimaryChainId,
logger,
} from "utils";

type TaskArgs = {
stratConfig: StratConfig;
strategyName: keyof AllStratConfigs;
modifyExisting: boolean;
apTeamSignerPkey?: string;
};

task("manage:registrar:setStratParams")
.addParam(
"stratConfig",
`The name of the strategy according to StratConfig, possible values: ${Object.keys(
allStrategyConfigs
).join(", ")}`,
"strategyName",
`The name of the strategy, possible values: ${Object.keys(allStrategyConfigs).join(", ")}`,
undefined,
cliTypes.stratConfig
)
Expand All @@ -27,36 +32,26 @@ task("manage:registrar:setStratParams")
"If running on prod, provide a pkey for a valid APTeam Multisig Owner."
)
.setAction(async function (taskArguments: TaskArgs, hre) {
if (await isProdNetwork(hre)) {
await hre.run("manage:registrar:setStratParams:on-network", {
...taskArguments,
chainId: ChainID.polygon,
});
await hre.run("manage:registrar:setStratParams:on-network", {
...taskArguments,
chainId: taskArguments.stratConfig.chainId,
});
} else {
await hre.run("manage:registrar:setStratParams:on-network", {
...taskArguments,
chainId: ChainID.mumbai,
});
await hre.run("manage:registrar:setStratParams:on-network", {
...taskArguments,
chainId: taskArguments.stratConfig.chainId,
});
}
const mainChainId = await getPrimaryChainId(hre);
const stratChainId = allStrategyConfigs[taskArguments.strategyName].chainId;

await hre.run("manage:registrar:setStratParams:on-network", {
...taskArguments,
chainId: mainChainId,
});
await hre.run("manage:registrar:setStratParams:on-network", {
...taskArguments,
chainId: stratChainId,
});
});

subtask(
"manage:registrar:setStratParams:on-network",
"Updates strat params on the network specified by the 'chainId' param"
)
.addParam(
"stratName",
`The name of the strategy according to StratConfig, possible values: ${Object.keys(
allStrategyConfigs
).join(", ")}`,
"strategyName",
`The name of the strategy, possible values: ${Object.keys(allStrategyConfigs).join(", ")}`,
undefined,
cliTypes.stratConfig
)
Expand Down Expand Up @@ -85,7 +80,7 @@ subtask(

logger.divider();
logger.out("Checking current strategy params at specified selector");
const config: StratConfig = taskArguments.stratConfig;
const config: StratConfig = allStrategyConfigs[taskArguments.strategyName];
let currentStratParams = await registrar.getStrategyParamsById(config.id);
if (
currentStratParams.liquidVaultAddr == hre.ethers.constants.AddressZero &&
Expand Down

0 comments on commit 48bcff3

Please sign in to comment.