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

Commit

Permalink
Closes AP-752,AP-779: Use cli types in tasks (#392)
Browse files Browse the repository at this point in the history
* Fix enums comment

* Add FeeTypes type check to manage:registrar:setFeeSettings > feeTypes field

* Remove empty string '' default value for manage:registrar:setStratApproval > name

* Add cli type check to manage:registrar:setStratApproval > approvalState

* Use getEnumValuesAsString in manage:registrar:setFeeSettings

* Remove empty string '' default value for manage:registrar:setStratParams > name

* Remove unused imports from dummyIntegration

* Set keeper as nullable in deploy:GiftCard

* Set available chainName values in manage:registrar:setAccountsChainAndAddress

* Remove unused bps cli param from manage:registrar:setAllFeeSettings

* Fix types.int fields

* Set manage:registrar:setGasByToken > tokenAddress to have no default value

* Add cliType for StratConfig

* Fix task params

* Add cliTypes.address where appropriate

* Update manage:registrar:setVaultOperatorStatus > status->approval

* Add type safety to manage:createEndowment > endowType

* Update manage:registrar:updateConfig param descriptions

* Use cliTypes.array.address in manage:updateRegistrar

* Refactor cliTypes

* Fix cliTypes.stratConfig

* Fix type checks in manage:addMultisigOwners

* Update upgrade:facets > facets params to be a regular param
  • Loading branch information
Nenad Misic authored Sep 27, 2023
1 parent 9197b37 commit ceb24e1
Show file tree
Hide file tree
Showing 45 changed files with 439 additions and 315 deletions.
8 changes: 7 additions & 1 deletion tasks/deploy/deployAPTeamMultiSig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {deployAPTeamMultiSig} from "contracts/multisigs/scripts/deploy";
import {task} from "hardhat/config";
import {cliTypes} from "tasks/types";
import {confirmAction, getAddresses, getSigners, isLocalNetwork, logger, verify} from "utils";

type TaskArgs = {
Expand All @@ -12,7 +13,12 @@ type TaskArgs = {
task("deploy:APTeamMultiSig", "Will deploy APTeamMultiSig contract")
.addFlag("skipVerify", "Skip contract verification")
.addFlag("yes", "Automatic yes to prompt.")
.addOptionalParam("admin", "override for proxy admin wallet, default: proxyAdminMultisig")
.addOptionalParam(
"admin",
"override for proxy admin wallet, default: proxyAdminMultisig",
undefined,
cliTypes.address
)
.addOptionalParam(
"apTeamSignerPkey",
"If running on prod, provide a pkey for a valid APTeam Multisig Owner."
Expand Down
9 changes: 7 additions & 2 deletions tasks/deploy/deployAccountsDiamond.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {deployAccountsDiamond} from "contracts/core/accounts/scripts/deploy";
import {task} from "hardhat/config";
import {cliTypes} from "tasks/types";
import {confirmAction, getAddresses, getSigners, isLocalNetwork, logger, verify} from "utils";

type TaskArgs = {
Expand All @@ -14,11 +15,15 @@ type TaskArgs = {
task("deploy:accounts", "It will deploy accounts diamond contracts")
.addOptionalParam(
"apTeamMultisig",
"APTeamMultiSig contract address. Will do a local lookup from contract-address.json if none is provided."
"APTeamMultiSig contract address. Will do a local lookup from contract-address.json if none is provided.",
undefined,
cliTypes.address
)
.addOptionalParam(
"registrar",
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided."
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided.",
undefined,
cliTypes.address
)
.addOptionalParam(
"apTeamSignerPkey",
Expand Down
5 changes: 4 additions & 1 deletion tasks/deploy/deployCharityApplications.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {deployCharityApplications} from "contracts/multisigs/scripts/deployCharityApplications";
import {task} from "hardhat/config";
import {cliTypes} from "tasks/types";
import {confirmAction, getAddresses, getSigners, isLocalNetwork, logger, verify} from "utils";

type TaskArgs = {
Expand All @@ -13,7 +14,9 @@ type TaskArgs = {
task("deploy:CharityApplications", "Will deploy CharityApplication contract")
.addOptionalParam(
"accountsDiamond",
"Accounts Diamond contract address. Will do a local lookup from contract-address.json if none is provided."
"Accounts Diamond contract address. Will do a local lookup from contract-address.json if none is provided.",
undefined,
cliTypes.address
)
.addOptionalParam(
"apTeamSignerPkey",
Expand Down
7 changes: 5 additions & 2 deletions tasks/deploy/deployGiftcard.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {CONFIG} from "config";
import {deployGiftCard} from "contracts/accessory/gift-cards/scripts/deploy";
import {task} from "hardhat/config";
import {cliTypes} from "tasks/types";
import {getAddresses, isLocalNetwork, logger} from "utils";

type TaskArgs = {
keeper: string;
keeper?: string;
registrar?: string;
skipVerify: boolean;
};
Expand All @@ -16,7 +17,9 @@ task("deploy:GiftCard", "Will deploy GiftCardContracts contract")
)
.addOptionalParam(
"registrar",
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided."
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided.",
undefined,
cliTypes.address
)
.addFlag("skipVerify", "Skip contract verification")
.setAction(async (taskArgs: TaskArgs, hre) => {
Expand Down
5 changes: 4 additions & 1 deletion tasks/deploy/deployHaloImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ import {deployCommunity} from "contracts/halo/community/scripts/deploy";
import {deployGov} from "contracts/halo/gov/scripts/deploy";
import {deployStaking} from "contracts/halo/staking/scripts/deploy";
import {deployVesting} from "contracts/halo/vesting/scripts/deploy";
import {cliTypes} from "tasks/types";

task("deploy:HaloImplementation", "Will deploy HaloImplementation contract")
.addFlag("skipVerify", "Skip contract verification")
.addOptionalParam(
"registrar",
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided."
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided.",
undefined,
cliTypes.address
)
.setAction(async (taskArgs, hre) => {
try {
Expand Down
9 changes: 7 additions & 2 deletions tasks/deploy/deployIndexFund.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {deployIndexFund} from "contracts/core/index-fund/scripts/deploy";
import {task} from "hardhat/config";
import {cliTypes} from "tasks/types";
import {confirmAction, getAddresses, getSigners, isLocalNetwork, logger, verify} from "utils";

type TaskArgs = {
Expand All @@ -13,11 +14,15 @@ type TaskArgs = {
task("deploy:IndexFund", "Will deploy IndexFund contract")
.addOptionalParam(
"owner",
"Address of the owner. By default set to AP team multisig proxy saved in contract-address.json."
"Address of the owner. By default set to AP team multisig proxy saved in contract-address.json.",
undefined,
cliTypes.address
)
.addOptionalParam(
"registrar",
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided."
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided.",
undefined,
cliTypes.address
)
.addOptionalParam(
"apTeamSignerPkey",
Expand Down
8 changes: 7 additions & 1 deletion tasks/deploy/deployLocalRegistrar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {deployLocalRegistrar} from "contracts/core/registrar/scripts/deploy";
import {deployRouter} from "contracts/core/router/scripts/deploy";
import {task} from "hardhat/config";
import {cliTypes} from "tasks/types";
import {LocalRegistrarLib} from "typechain-types/contracts/core/registrar/LocalRegistrar";
import {confirmAction, getAddresses, getSigners, isLocalNetwork, logger, verify} from "utils";

Expand All @@ -12,7 +13,12 @@ type TaskArgs = {
};

task("deploy:LocalRegistrarAndRouter", "Will deploy the Local Registrar contract and Router.")
.addOptionalParam("owner", "The owner wallet for both router and registrar")
.addOptionalParam(
"owner",
"The owner wallet for both router and registrar. By default set to AP team multisig proxy saved in contract-address.json.",
undefined,
cliTypes.address
)
.addOptionalParam(
"apTeamSignerPkey",
"If running on prod, provide a pkey for a valid APTeam Multisig Owner."
Expand Down
9 changes: 7 additions & 2 deletions tasks/deploy/deployRegistrar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {CONFIG} from "config";
import {deployRegistrar} from "contracts/core/registrar/scripts/deploy";
import {task} from "hardhat/config";
import {cliTypes} from "tasks/types";
import {confirmAction, getAddresses, getSigners, isLocalNetwork, logger, verify} from "utils";

type TaskArgs = {
Expand All @@ -17,11 +18,15 @@ task(
)
.addOptionalParam(
"apTeamMultisig",
"APTeamMultiSig contract address. Will do a local lookup from contract-address.json if none is provided."
"APTeamMultiSig contract address. Will do a local lookup from contract-address.json if none is provided.",
undefined,
cliTypes.address
)
.addOptionalParam(
"router",
"Router contract address. Will do a local lookup from contract-address.json if none is provided."
"Router contract address. Will do a local lookup from contract-address.json if none is provided.",
undefined,
cliTypes.address
)
.addOptionalParam(
"apTeamSignerPkey",
Expand Down
5 changes: 4 additions & 1 deletion tasks/deploy/deployRouter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {deployRouter} from "contracts/core/router/scripts/deploy";
import {task} from "hardhat/config";
import {cliTypes} from "tasks/types";
import {confirmAction, getAddresses, getSigners, isLocalNetwork, logger, verify} from "utils";

type TaskArgs = {
Expand All @@ -12,7 +13,9 @@ type TaskArgs = {
task("deploy:Router", "Will deploy Router contract")
.addOptionalParam(
"registrar",
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided."
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided.",
undefined,
cliTypes.address
)
.addOptionalParam(
"apTeamSignerPkey",
Expand Down
78 changes: 39 additions & 39 deletions tasks/deploy/integrations/dummyIntegration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import {allStrategyConfigs} from "contracts/integrations/stratConfig";
import {task} from "hardhat/config";
import {APVault_V1__factory, VaultEmitter__factory, DummyERC20__factory, GoerliDummy__factory} from "typechain-types";
import {cliTypes} from "tasks/types";
import {
APVault_V1__factory,
DummyERC20__factory,
GoerliDummy__factory,
VaultEmitter__factory,
} from "typechain-types";
import {VaultType} from "types";
import {
StratConfig,
Expand All @@ -8,25 +15,22 @@ import {
getSigners,
logger,
writeStrategyAddresses,
getVaultAddress,
getStrategyAddress,
getAPTeamOwner
} from "utils";
import {allStrategyConfigs} from "../../../contracts/integrations/stratConfig";
import {submitMultiSigTx} from "tasks/helpers";

type TaskArgs = {
name: string;
stratConfig: StratConfig;
admin: string;
skipVerify: boolean;
};

task("Deploy:dummyIntegration", "Will deploy a set of vaults and a dummy strategy")
.addParam(
"name",
"stratConfig",
`The name of the strategy according to StratConfig, possible values: ${Object.keys(
allStrategyConfigs
).join(", ")}`
).join(", ")}`,
undefined,
cliTypes.stratConfig
)
.addOptionalParam(
"admin",
Expand All @@ -35,7 +39,10 @@ task("Deploy:dummyIntegration", "Will deploy a set of vaults and a dummy strateg
.addFlag("skipVerify", "Skip contract verification")
.setAction(async (taskArgs: TaskArgs, hre) => {
try {
const config: StratConfig = allStrategyConfigs[taskArgs.name];
logger.divider();
logger.out("Deploying a set of vaults and a dummy strategy...");

const config: StratConfig = taskArgs.stratConfig;
const {deployer} = await getSigners(hre);
let network = await hre.ethers.provider.getNetwork();
if (network.chainId != config.chainId) {
Expand Down Expand Up @@ -86,44 +93,37 @@ task("Deploy:dummyIntegration", "Will deploy a set of vaults and a dummy strateg
};
let liqVault = await Vault.deploy(liquidConfig, addresses.vaultEmitter.proxy, admin);
logger.pad(30, "Liquid Vault deployed to", liqVault.address);

const emitter = VaultEmitter__factory.connect(addresses.vaultEmitter.proxy, deployer);

await emitter.vaultCreated(
lockVault.address,
{
vaultType: VaultType.LOCKED,
strategyId: config.id,
strategy: strategy.address,
registrar: addresses.registrar.proxy,
baseToken: addresses.tokens.usdc,
yieldToken: yieldToken.address,
apTokenName: "LockedTestVault",
apTokenSymbol: "LockTV",
}
)
await emitter.vaultCreated(
liqVault.address,
{
vaultType: VaultType.LIQUID,
strategyId: config.id,
strategy: strategy.address,
registrar: addresses.registrar.proxy,
baseToken: addresses.tokens.usdc,
yieldToken: "0x2811747e3336aa28caf71c51454766e1b95f56e8",
apTokenName: "LiquidTestVault",
apTokenSymbol: "LiqTV",
const emitter = VaultEmitter__factory.connect(addresses.vaultEmitter.proxy, deployer);

}
)
await emitter.vaultCreated(lockVault.address, {
vaultType: VaultType.LOCKED,
strategyId: config.id,
strategy: strategy.address,
registrar: addresses.registrar.proxy,
baseToken: addresses.tokens.usdc,
yieldToken: yieldToken.address,
apTokenName: "LockedTestVault",
apTokenSymbol: "LockTV",
});
await emitter.vaultCreated(liqVault.address, {
vaultType: VaultType.LIQUID,
strategyId: config.id,
strategy: strategy.address,
registrar: addresses.registrar.proxy,
baseToken: addresses.tokens.usdc,
yieldToken: "0x2811747e3336aa28caf71c51454766e1b95f56e8",
apTokenName: "LiquidTestVault",
apTokenSymbol: "LiqTV",
});

const data: StrategyObject = {
strategy: strategy.address,
locked: lockVault.address,
liquid: liqVault.address,
};

writeStrategyAddresses(taskArgs.name, data);
writeStrategyAddresses(taskArgs.stratConfig.name, data);
} catch (error) {
logger.out(error, logger.Level.Error);
}
Expand Down
5 changes: 4 additions & 1 deletion tasks/manage/accounts/updateConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {task} from "hardhat/config";
import {submitMultiSigTx} from "tasks/helpers";
import {cliTypes} from "tasks/types";
import {AccountsQueryEndowments__factory, AccountsUpdate__factory} from "typechain-types";
import {confirmAction, getAPTeamOwner, getAddresses, logger, structToObject} from "utils";

Expand All @@ -12,7 +13,9 @@ type TaskArgs = {
task("manage:accounts:updateConfig", "Will update Accounts Diamond config")
.addOptionalParam(
"registrarContract",
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided."
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided.",
undefined,
cliTypes.address
)
.addOptionalParam(
"apTeamSignerPkey",
Expand Down
5 changes: 4 additions & 1 deletion tasks/manage/accounts/updateOwner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {task} from "hardhat/config";
import {submitMultiSigTx} from "tasks/helpers";
import {cliTypes} from "tasks/types";
import {AccountsQueryEndowments__factory, AccountsUpdate__factory} from "typechain-types";
import {confirmAction, getAPTeamOwner, getAddresses, logger} from "utils";

Expand All @@ -8,7 +9,9 @@ type TaskArgs = {to: string; apTeamSignerPkey?: string; yes: boolean};
task("manage:AccountsDiamond:updateOwner", "Will update the owner of the Accounts Diamond")
.addOptionalParam(
"to",
"Address of the new owner. Ensure at least one of `apTeamMultisigOwners` is the controller of this address. Will default to `contract-address.json > multiSig.apTeam.proxy` if none is provided."
"Address of the new owner. Ensure at least one of `apTeamMultisigOwners` is the controller of this address. Will default to `contract-address.json > multiSig.apTeam.proxy` if none is provided.",
undefined,
cliTypes.address
)
.addOptionalParam(
"apTeamSignerPkey",
Expand Down
17 changes: 8 additions & 9 deletions tasks/manage/addMultisigOwners.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {task} from "hardhat/config";
import {submitMultiSigTx} from "tasks/helpers";
import {cliTypes} from "tasks/types";
import {MultiSigGeneric__factory} from "typechain-types";
import {confirmAction, connectSignerFromPkey, logger} from "utils";

Expand All @@ -11,27 +12,25 @@ type TaskArgs = {
};

task("manage:addMultisigOwners", "Will add the specified address to the multisig as an owner")
.addParam("multisig", "Address of multisig")
.addVariadicPositionalParam("owners", "Addresses of new owners")
.addParam("multisig", "Address of multisig", undefined, cliTypes.address)
.addParam("owners", "Addresses of new owners", undefined, cliTypes.array.address)
.addParam("multisigOwnerPkey", "Private Key for a valid Multisig Owner.")
.addFlag("yes", "Automatic yes to prompt.")
.setAction(async (taskArguments: TaskArgs, hre) => {
try {
logger.divider();
logger.out(`Adding new owners to ${taskArguments.multisig}:`);
logger.out(taskArguments.owners);

const msOwner = await connectSignerFromPkey(taskArguments.multisigOwnerPkey, hre);

const isConfirmed =
taskArguments.yes ||
(await confirmAction(`Adding new owner: ${await msOwner.getAddress()}`));
const isConfirmed = taskArguments.yes || (await confirmAction());
if (!isConfirmed) {
return logger.out("Confirmation denied.", logger.Level.Warn);
}

const msOwner = await connectSignerFromPkey(taskArguments.multisigOwnerPkey, hre);

const multisig = MultiSigGeneric__factory.connect(taskArguments.multisig, msOwner);

logger.out("Adding new owners:");
logger.out(taskArguments.owners);
const addOwnerData = multisig.interface.encodeFunctionData("addOwners", [
taskArguments.owners,
]);
Expand Down
Loading

0 comments on commit ceb24e1

Please sign in to comment.