@mstable/protocol
Version:
mStable Contracts
116 lines • 7.68 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("ts-node/register");
require("tsconfig-paths/register");
const constants_1 = require("@utils/constants");
const config_1 = require("hardhat/config");
const generated_1 = require("types/generated");
const SavingsContractImusdPolygon22__factory_1 = require("types/generated/factories/SavingsContractImusdPolygon22__factory");
// Mainnet imBTC Contract
const SavingsContractImbtcMainnet22__factory_1 = require("types/generated/factories/SavingsContractImbtcMainnet22__factory");
// Mainnet imUSD Contract
const SavingsContractImusdMainnet22__factory_1 = require("types/generated/factories/SavingsContractImusdMainnet22__factory");
const deploy_utils_1 = require("./utils/deploy-utils");
const signerFactory_1 = require("./utils/signerFactory");
const networkAddressFactory_1 = require("./utils/networkAddressFactory");
const tokens_1 = require("./utils/tokens");
const etherscan_1 = require("./utils/etherscan");
config_1.task("upgrade-imusd-polygon", "Upgrade Polygon imUSD save contract imUSD")
.addOptionalParam("speed", "Defender Relayer speed param: 'safeLow' | 'average' | 'fast' | 'fastest'", "fast", config_1.types.string)
.setAction(async (taskArgs, hre) => {
const signer = await signerFactory_1.getSigner(hre, taskArgs.speed);
const chain = networkAddressFactory_1.getChain(hre);
if (chain !== tokens_1.Chain.polygon)
throw Error("Task can only run against polygon or a polygon fork");
const musdAddress = networkAddressFactory_1.resolveAddress("mUSD", chain);
const imusdAddress = networkAddressFactory_1.resolveAddress("mUSD", chain, "savings");
const delayedAdminAddress = networkAddressFactory_1.getChainAddress("DelayedProxyAdmin", chain);
const nexusAddress = networkAddressFactory_1.getChainAddress("Nexus", chain);
const unwrapperAddress = networkAddressFactory_1.getChainAddress("Unwrapper", chain);
const constructorArguments = [nexusAddress, musdAddress, unwrapperAddress];
// Deploy step 1 - Save Vault
const saveContractImpl = await deploy_utils_1.deployContract(new SavingsContractImusdPolygon22__factory_1.SavingsContractImusdPolygon22__factory(signer), "mStable: mUSD Savings Contract (imUSD)", constructorArguments);
await etherscan_1.verifyEtherscan(hre, {
address: saveContractImpl.address,
contract: "contracts/legacy-upgraded/imusd-polygon-22.sol:SavingsContract_imusd_polygon_22",
constructorArguments,
});
// Deploy step 2 - Propose upgrade
// Update the Save Contract proxy to point to the new implementation using the delayed proxy admin
const delayedProxyAdmin = generated_1.DelayedProxyAdmin__factory.connect(delayedAdminAddress, signer);
// Update the proxy to point to the new implementation using the delayed proxy admin
const upgradeData = [];
const proposeUpgradeData = delayedProxyAdmin.interface.encodeFunctionData("proposeUpgrade", [
imusdAddress,
saveContractImpl.address,
upgradeData,
]);
console.log(`\ndelayedProxyAdmin.proposeUpgrade to ${delayedAdminAddress}, data:\n${proposeUpgradeData}`);
});
config_1.task("upgrade-imusd-mainnet", "Upgrade Mainnet imUSD save contract imUSD")
.addOptionalParam("speed", "Defender Relayer speed param: 'safeLow' | 'average' | 'fast' | 'fastest'", "fast", config_1.types.string)
.setAction(async (taskArgs, hre) => {
const signer = await signerFactory_1.getSigner(hre, taskArgs.speed);
const chain = networkAddressFactory_1.getChain(hre);
if (chain !== tokens_1.Chain.mainnet)
throw Error("Task can only run against mainnet or a mainnet fork");
const imusdAddress = networkAddressFactory_1.resolveAddress("mUSD", chain, "savings");
const delayedAdminAddress = networkAddressFactory_1.getChainAddress("DelayedProxyAdmin", chain);
const unwrapperAddress = networkAddressFactory_1.getChainAddress("Unwrapper", chain);
const constructorArguments = [];
// Deploy step 1 - Save Contract
const saveContractImpl = await deploy_utils_1.deployContract(new SavingsContractImusdMainnet22__factory_1.SavingsContractImusdMainnet22__factory(signer), "mStable: mUSD Savings Contract (imUSD)", constructorArguments);
// Validate the unwrapper is set as constant on the save contract
if ((await saveContractImpl.unwrapper()) !== unwrapperAddress || unwrapperAddress === constants_1.DEAD_ADDRESS)
throw Error("Unwrapper address not set on save contract");
await etherscan_1.verifyEtherscan(hre, {
address: saveContractImpl.address,
contract: "contracts/legacy-upgraded/imusd-mainnet-22.sol:SavingsContract_imusd_mainnet_22",
constructorArguments,
});
// Deploy step 2 - Propose upgrade
// Update the Save Contract proxy to point to the new implementation using the delayed proxy admin
const delayedProxyAdmin = generated_1.DelayedProxyAdmin__factory.connect(delayedAdminAddress, signer);
// Update the proxy to point to the new implementation using the delayed proxy admin
const upgradeData = [];
const proposeUpgradeData = delayedProxyAdmin.interface.encodeFunctionData("proposeUpgrade", [
imusdAddress,
saveContractImpl.address,
upgradeData,
]);
console.log(`\ndelayedProxyAdmin.proposeUpgrade to ${delayedAdminAddress}, data:\n${proposeUpgradeData}`);
});
config_1.task("upgrade-imbtc-mainnet", "Upgrade Mainnet imBTC save contract imBTC")
.addOptionalParam("speed", "Defender Relayer speed param: 'safeLow' | 'average' | 'fast' | 'fastest'", "fast", config_1.types.string)
.setAction(async (taskArgs, hre) => {
const signer = await signerFactory_1.getSigner(hre, taskArgs.speed);
const chain = networkAddressFactory_1.getChain(hre);
if (chain !== tokens_1.Chain.mainnet)
throw Error("Task can only run against mainnet or a mainnet fork");
const mbtcAddress = networkAddressFactory_1.resolveAddress("mBTC", chain);
const imbtcAddress = networkAddressFactory_1.resolveAddress("mBTC", chain, "savings");
const delayedAdminAddress = networkAddressFactory_1.getChainAddress("DelayedProxyAdmin", chain);
const nexusAddress = networkAddressFactory_1.getChainAddress("Nexus", chain);
const unwrapperAddress = networkAddressFactory_1.getChainAddress("Unwrapper", chain);
const constructorArguments = [nexusAddress, mbtcAddress, unwrapperAddress];
// Deploy step 1 - Save Contract
const saveContractImpl = await deploy_utils_1.deployContract(new SavingsContractImbtcMainnet22__factory_1.SavingsContractImbtcMainnet22__factory(signer), "mStable: mBTC Savings Contract (imBTC)", constructorArguments);
await etherscan_1.verifyEtherscan(hre, {
address: saveContractImpl.address,
contract: "contracts/legacy-upgraded/imbtc-mainnet-22.sol:SavingsContract_imbtc_mainnet_22",
constructorArguments,
});
// Deploy step 2 - Propose upgrade
// Update the Save Contract proxy to point to the new implementation using the delayed proxy admin
const delayedProxyAdmin = generated_1.DelayedProxyAdmin__factory.connect(delayedAdminAddress, signer);
// Update the proxy to point to the new implementation using the delayed proxy admin
const upgradeData = [];
const proposeUpgradeData = delayedProxyAdmin.interface.encodeFunctionData("proposeUpgrade", [
imbtcAddress,
saveContractImpl.address,
upgradeData,
]);
console.log(`\ndelayedProxyAdmin.proposeUpgrade to ${delayedAdminAddress}, data:\n${proposeUpgradeData}`);
});
module.exports = {};
//# sourceMappingURL=deploySavingsContract4626.js.map