diff --git a/packages/sdk/chainDeploy/helpers/dynamicFlywheels.ts b/packages/sdk/chainDeploy/helpers/dynamicFlywheels.ts index dd5860511..2a5ea65b7 100644 --- a/packages/sdk/chainDeploy/helpers/dynamicFlywheels.ts +++ b/packages/sdk/chainDeploy/helpers/dynamicFlywheels.ts @@ -9,7 +9,7 @@ export const deployFlywheelWithDynamicRewards = async ({ deployments, deployConfig, }: FuseFlywheelDeployFnParams): Promise> => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, extrasAdmin } = await getNamedAccounts(); const dynamicFlywheels = []; @@ -18,19 +18,19 @@ export const deployFlywheelWithDynamicRewards = async ({ console.log( `Deploying MidasReplacingFlywheel & ReplacingFlywheelDynamicRewards for ${config.rewardToken} reward token` ); - const flywheelBooster = await ethers.getContract("LooplessFlywheelBooster", deployer); + const flywheelBooster = await ethers.getContract("LooplessFlywheelBooster", upgradesAdmin); const flywheelToReplace = config.flywheelToReplace ? config.flywheelToReplace : constants.AddressZero; //// MidasFlywheelCore with Dynamic Rewards const fwc = await deployments.deploy(`MidasFlywheel_${config.name}`, { contract: "MidasReplacingFlywheel", - from: deployer, + from: upgradesAdmin, log: true, proxy: { execute: { init: { methodName: "initialize", - args: [config.rewardToken, constants.AddressZero, flywheelBooster.address, deployer], + args: [config.rewardToken, constants.AddressZero, flywheelBooster.address, extrasAdmin], }, onUpgrade: { methodName: "reinitialize", @@ -38,7 +38,7 @@ export const deployFlywheelWithDynamicRewards = async ({ }, }, proxyContract: "OpenZeppelinTransparentProxy", - owner: deployer, + owner: upgradesAdmin, }, waitConfirmations: 1, }); @@ -49,7 +49,7 @@ export const deployFlywheelWithDynamicRewards = async ({ const fdr = await deployments.deploy(`ReplacingFlywheelDynamicRewards_${config.name}`, { contract: "ReplacingFlywheelDynamicRewards", - from: deployer, + from: upgradesAdmin, args: [flywheelToReplace, fwc.address, config.cycleLength], log: true, waitConfirmations: 1, @@ -59,7 +59,7 @@ export const deployFlywheelWithDynamicRewards = async ({ } console.log("ReplacingFlywheelDynamicRewards: ", fdr.address); - const flywheelCore = (await ethers.getContract(`MidasFlywheel_${config.name}`, deployer)) as MidasFlywheel; + const flywheelCore = (await ethers.getContract(`MidasFlywheel_${config.name}`, extrasAdmin)) as MidasFlywheel; const currentRewards = await flywheelCore.callStatic.flywheelRewards(); if (currentRewards != fdr.address) { const tx = await flywheelCore.setFlywheelRewards(fdr.address); diff --git a/packages/sdk/chainDeploy/helpers/irms.ts b/packages/sdk/chainDeploy/helpers/irms.ts index 70c88db18..6bb0062e7 100644 --- a/packages/sdk/chainDeploy/helpers/irms.ts +++ b/packages/sdk/chainDeploy/helpers/irms.ts @@ -6,10 +6,10 @@ export const deployIRMs = async ({ deployments, deployConfig, }: IrmDeployFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin } = await getNamedAccounts(); //// IRM MODELS| const jrm = await deployments.deploy("JumpRateModel", { - from: deployer, + from: upgradesAdmin, args: [ deployConfig.blocksPerYear, ethers.utils.parseEther("0").toString(), // baseRatePerYear 0 @@ -25,7 +25,7 @@ export const deployIRMs = async ({ // taken from WhitePaperInterestRateModel used for cETH // https://etherscan.io/address/0x0c3f8df27e1a00b47653fde878d68d35f00714c0#code const wprm = await deployments.deploy("WhitePaperInterestRateModel", { - from: deployer, + from: upgradesAdmin, args: [ deployConfig.blocksPerYear, ethers.utils.parseEther("0.02").toString(), // baseRatePerYear diff --git a/packages/sdk/chainDeploy/helpers/liquidators/fuseSafeLiquidator.ts b/packages/sdk/chainDeploy/helpers/liquidators/fuseSafeLiquidator.ts index 1f4ebda11..e56318bbb 100644 --- a/packages/sdk/chainDeploy/helpers/liquidators/fuseSafeLiquidator.ts +++ b/packages/sdk/chainDeploy/helpers/liquidators/fuseSafeLiquidator.ts @@ -12,9 +12,9 @@ export const deployFuseSafeLiquidator = async ({ deployments, deployConfig, }: LiquidatorDeployFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, liquidator } = await getNamedAccounts(); const fsl = await deployments.deploy("FuseSafeLiquidator", { - from: deployer, + from: upgradesAdmin, log: true, proxy: { execute: { @@ -35,13 +35,13 @@ export const deployFuseSafeLiquidator = async ({ }, }, proxyContract: "OpenZeppelinTransparentProxy", - owner: deployer, + owner: upgradesAdmin, }, }); if (fsl.transactionHash) await ethers.provider.waitForTransaction(fsl.transactionHash); console.log("FuseSafeLiquidator: ", fsl.address); - const fuseSafeLiquidator = (await ethers.getContract("FuseSafeLiquidator", deployer)) as FuseSafeLiquidator; + const fuseSafeLiquidator = (await ethers.getContract("FuseSafeLiquidator", liquidator)) as FuseSafeLiquidator; const fslOwner = await fuseSafeLiquidator.callStatic.owner(); console.log(`FuseSafeLiquidator owner is ${fslOwner}`); }; @@ -51,15 +51,15 @@ export const configureFuseSafeLiquidator = async ({ getNamedAccounts, chainId, }: LiquidatorConfigFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { liquidator } = await getNamedAccounts(); const strategies: string[] = []; const arrayOfTrue: boolean[] = []; - const fuseSafeLiquidator = (await ethers.getContract("FuseSafeLiquidator", deployer)) as FuseSafeLiquidator; + const fuseSafeLiquidator = (await ethers.getContract("FuseSafeLiquidator", liquidator)) as FuseSafeLiquidator; for (const address in chainIdToConfig[chainId].redemptionStrategies) { const [redemptionStrategyType] = chainIdToConfig[chainId].redemptionStrategies[address]; - const redemptionStrategy = await ethers.getContract(redemptionStrategyType, deployer); + const redemptionStrategy = await ethers.getContract(redemptionStrategyType); const whitelistedAlready = await fuseSafeLiquidator.callStatic.redemptionStrategiesWhitelist( redemptionStrategy.address @@ -72,7 +72,7 @@ export const configureFuseSafeLiquidator = async ({ for (const address in chainIdToConfig[chainId].fundingStrategies) { const [fundingStrategyType] = chainIdToConfig[chainId].fundingStrategies[address]; - const fundingStrategy = await ethers.getContract(fundingStrategyType, deployer); + const fundingStrategy = await ethers.getContract(fundingStrategyType); const whitelistedAlready = await fuseSafeLiquidator.callStatic.redemptionStrategiesWhitelist( fundingStrategy.address @@ -97,11 +97,11 @@ export const configureAddressesProviderStrategies = async ({ getNamedAccounts, chainId, }: LiquidatorConfigFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { testConfigAdmin } = await getNamedAccounts(); const chainConfig = chainIdToConfig[chainId]; const redemptionStrategiesToUpdate: [string, string, string, string][] = []; - const ap = (await ethers.getContract("AddressesProvider", deployer)) as AddressesProvider; + const ap = (await ethers.getContract("AddressesProvider", testConfigAdmin)) as AddressesProvider; // configure the redemption strategies in the AddressesProvider for (const assetAddress in chainConfig.redemptionStrategies) { diff --git a/packages/sdk/chainDeploy/helpers/oracles/aXXXc.ts b/packages/sdk/chainDeploy/helpers/oracles/aXXXc.ts index 115d35dff..df3e44e19 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/aXXXc.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/aXXXc.ts @@ -10,14 +10,14 @@ export const deployAnkrCertificateTokenPriceOracle = async ({ assets, certificateAssetSymbol, }: aXXXcDeployParams): Promise<{ ankrCertificateTokenPriceOracle: any }> => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); const aXXXc = underlying(assets, certificateAssetSymbol); const ankrCertificateTokenPriceOracle = await deployments.deploy("AnkrCertificateTokenPriceOracle", { - from: deployer, + from: upgradesAdmin, proxy: { execute: { init: { @@ -26,7 +26,7 @@ export const deployAnkrCertificateTokenPriceOracle = async ({ }, }, proxyContract: "OpenZeppelinTransparentProxy", - owner: deployer, + owner: upgradesAdmin, }, log: true, waitConfirmations: 1, diff --git a/packages/sdk/chainDeploy/helpers/oracles/adrastia.ts b/packages/sdk/chainDeploy/helpers/oracles/adrastia.ts index c983c866c..29687f160 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/adrastia.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/adrastia.ts @@ -10,14 +10,14 @@ export const deployAdrastiaOracle = async ({ adrastiaAssets, nativeUsdFeed, }: AdrastiaDeployFnParams): Promise<{ adrastiaPriceOracle: AdrastiaPriceOracle }> => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); let tx: providers.TransactionResponse; - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); //// Adrastia Oracle const adrastia = await deployments.deploy("AdrastiaPriceOracle", { - from: deployer, + from: upgradesAdmin, args: [], log: true, proxy: { @@ -27,7 +27,7 @@ export const deployAdrastiaOracle = async ({ args: [nativeUsdFeed], }, }, - owner: deployer, + owner: upgradesAdmin, proxyContract: "OpenZeppelinTransparentProxy", }, }); @@ -35,7 +35,7 @@ export const deployAdrastiaOracle = async ({ if (adrastia.transactionHash) await ethers.provider.waitForTransaction(adrastia.transactionHash); console.log("AdrastiaPriceOracle: ", adrastia.address); - const adrastiaPriceOracle = (await ethers.getContract("AdrastiaPriceOracle", deployer)) as AdrastiaPriceOracle; + const adrastiaPriceOracle = (await ethers.getContract("AdrastiaPriceOracle", oraclesAdmin)) as AdrastiaPriceOracle; tx = await adrastiaPriceOracle.setPriceFeeds( adrastiaAssets.map((f) => f.underlying), adrastiaAssets.map((f) => f.feed) diff --git a/packages/sdk/chainDeploy/helpers/oracles/balancerLp.ts b/packages/sdk/chainDeploy/helpers/oracles/balancerLp.ts index 970734c80..070cd8b85 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/balancerLp.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/balancerLp.ts @@ -8,12 +8,12 @@ export const deployBalancerLpPriceOracle = async ({ deployments, balancerLpAssets, }: BalancerLpFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); const blpo = await deployments.deploy("BalancerLpTokenPriceOracle", { - from: deployer, + from: upgradesAdmin, args: [], log: true, proxy: { @@ -23,7 +23,7 @@ export const deployBalancerLpPriceOracle = async ({ args: [mpo.address], }, }, - owner: deployer, + owner: upgradesAdmin, proxyContract: "OpenZeppelinTransparentProxy", }, }); diff --git a/packages/sdk/chainDeploy/helpers/oracles/chainlink.ts b/packages/sdk/chainDeploy/helpers/oracles/chainlink.ts index 68283e322..b3a16c8f4 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/chainlink.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/chainlink.ts @@ -12,13 +12,13 @@ export const deployChainlinkOracle = async ({ assets, chainlinkAssets, }: ChainlinkDeployFnParams): Promise<{ cpo: any; chainLinkv2: any }> => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin, testConfigAdmin } = await getNamedAccounts(); let tx: providers.TransactionResponse; //// Chainlink Oracle const cpo = await deployments.deploy("ChainlinkPriceOracleV2", { - from: deployer, - args: [deployer, true, deployConfig.wtoken, deployConfig.nativeTokenUsdChainlinkFeed], + from: upgradesAdmin, + args: [oraclesAdmin, true, deployConfig.wtoken, deployConfig.nativeTokenUsdChainlinkFeed], log: true, }); if (cpo.transactionHash) await ethers.provider.waitForTransaction(cpo.transactionHash); @@ -27,7 +27,7 @@ export const deployChainlinkOracle = async ({ const usdBasedFeeds = chainlinkAssets.filter((asset) => asset.feedBaseCurrency === ChainlinkFeedBaseCurrency.USD); const ethBasedFeeds = chainlinkAssets.filter((asset) => asset.feedBaseCurrency === ChainlinkFeedBaseCurrency.ETH); - const chainLinkv2 = await ethers.getContract("ChainlinkPriceOracleV2", deployer); + const chainLinkv2 = await ethers.getContract("ChainlinkPriceOracleV2", oraclesAdmin); if (usdBasedFeeds.length > 0) { const feedCurrency = ChainlinkFeedBaseCurrency.USD; tx = await chainLinkv2.setPriceFeeds( @@ -54,13 +54,13 @@ export const deployChainlinkOracle = async ({ const underlyings = chainlinkAssets.map((c) => underlying(assets, c.symbol)); const oracles = Array(chainlinkAssets.length).fill(chainLinkv2.address); - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); tx = await mpo.add(underlyings, oracles); await tx.wait(); console.log(`Master Price Oracle updated for tokens ${underlyings.join(", ")}`); - const addressesProvider = (await ethers.getContract("AddressesProvider", deployer)) as AddressesProvider; + const addressesProvider = (await ethers.getContract("AddressesProvider", testConfigAdmin)) as AddressesProvider; const chainLinkv2Address = await addressesProvider.callStatic.getAddress("ChainlinkPriceOracleV2"); if (chainLinkv2Address !== chainLinkv2.address) { tx = await addressesProvider.setAddress("ChainlinkPriceOracleV2", chainLinkv2.address); diff --git a/packages/sdk/chainDeploy/helpers/oracles/curveLp.ts b/packages/sdk/chainDeploy/helpers/oracles/curveLp.ts index 5d152d0d0..1ad89768e 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/curveLp.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/curveLp.ts @@ -8,13 +8,13 @@ export const deployCurveLpOracle = async ({ deployments, curvePools, }: CurveLpFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); let tx: providers.TransactionResponse; let receipt: providers.TransactionReceipt; //// CurveLpTokenPriceOracleNoRegistry const cpo = await deployments.deploy("CurveLpTokenPriceOracleNoRegistry", { - from: deployer, + from: upgradesAdmin, args: [], log: true, proxy: { @@ -28,14 +28,14 @@ export const deployCurveLpOracle = async ({ args: [curvePools.map((c) => c.lpToken)], }, }, - owner: deployer, + owner: upgradesAdmin, proxyContract: "OpenZeppelinTransparentProxy", }, }); if (cpo.transactionHash) await ethers.provider.waitForTransaction(cpo.transactionHash); console.log("CurveLpTokenPriceOracleNoRegistry: ", cpo.address); - const curveOracle = await ethers.getContract("CurveLpTokenPriceOracleNoRegistry", deployer); + const curveOracle = await ethers.getContract("CurveLpTokenPriceOracleNoRegistry", oraclesAdmin); for (const pool of curvePools) { const registered = await curveOracle.poolOf(pool.lpToken); @@ -54,7 +54,7 @@ export const deployCurveLpOracle = async ({ const underlyings = curvePools.map((c) => c.lpToken); const oracles = Array(curvePools.length).fill(curveOracle.address); - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); tx = await mpo.add(underlyings, oracles); await tx.wait(); @@ -67,15 +67,15 @@ export const deployCurveV2LpOracle = async ({ deployments, curveV2Pools, }: CurveV2LpFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); let tx: providers.TransactionResponse; let receipt: providers.TransactionReceipt; - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); //// CurveLpTokenPriceOracleNoRegistry const cpo = await deployments.deploy("CurveV2LpTokenPriceOracleNoRegistry", { - from: deployer, + from: upgradesAdmin, args: [], log: true, proxy: { @@ -89,14 +89,14 @@ export const deployCurveV2LpOracle = async ({ args: [curveV2Pools.map((c) => c.lpToken)], }, }, - owner: deployer, + owner: upgradesAdmin, proxyContract: "OpenZeppelinTransparentProxy", }, }); if (cpo.transactionHash) await ethers.provider.waitForTransaction(cpo.transactionHash); console.log("CurveV2LpTokenPriceOracleNoRegistry: ", cpo.address); - const curveOracle = await ethers.getContract("CurveV2LpTokenPriceOracleNoRegistry", deployer); + const curveOracle = await ethers.getContract("CurveV2LpTokenPriceOracleNoRegistry", oraclesAdmin); for (const pool of curveV2Pools) { const registered = await curveOracle.poolOf(pool.lpToken); diff --git a/packages/sdk/chainDeploy/helpers/oracles/dia.ts b/packages/sdk/chainDeploy/helpers/oracles/dia.ts index a0c3ea0ab..4d947243a 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/dia.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/dia.ts @@ -11,16 +11,16 @@ export const deployDiaOracle = async ({ diaAssets, diaNativeFeed, }: DiaDeployFnParams): Promise<{ diaOracle: DiaPriceOracle }> => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); let tx: providers.TransactionResponse; - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); //// Dia Oracle const dia = await deployments.deploy("DiaPriceOracle", { - from: deployer, + from: upgradesAdmin, args: [ - deployer, + oraclesAdmin, true, deployConfig.wtoken, diaNativeFeed.feed, @@ -33,7 +33,7 @@ export const deployDiaOracle = async ({ if (dia.transactionHash) await ethers.provider.waitForTransaction(dia.transactionHash); console.log("DiaPriceOracle: ", dia.address); - const diaOracle = (await ethers.getContract("DiaPriceOracle", deployer)) as DiaPriceOracle; + const diaOracle = (await ethers.getContract("DiaPriceOracle", oraclesAdmin)) as DiaPriceOracle; tx = await diaOracle.setPriceFeeds( diaAssets.map((d) => d.underlying), diaAssets.map((d) => d.feed), diff --git a/packages/sdk/chainDeploy/helpers/oracles/diaWstDot.ts b/packages/sdk/chainDeploy/helpers/oracles/diaWstDot.ts index f44ed4fc9..79ac09156 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/diaWstDot.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/diaWstDot.ts @@ -10,16 +10,16 @@ export const deployDiaWstDotPriceOracle = async ({ deployments, deployConfig, }: DiaStDotFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); const stDot = underlying(moonbeam.assets, assetSymbols.stDOT); const wstDot = underlying(moonbeam.assets, assetSymbols.wstDOT); const diaOracleAddress = "0xFEfe38321199e016c8d5e734A40eCCC0DBeC3711"; const dspo = await deployments.deploy("DiaStDotPriceOracle", { - from: deployer, + from: upgradesAdmin, args: [], log: true, proxy: { @@ -29,7 +29,7 @@ export const deployDiaWstDotPriceOracle = async ({ args: [mpo.address, diaOracleAddress, deployConfig.stableToken], }, }, - owner: deployer, + owner: upgradesAdmin, proxyContract: "OpenZeppelinTransparentProxy", }, }); diff --git a/packages/sdk/chainDeploy/helpers/oracles/flux.ts b/packages/sdk/chainDeploy/helpers/oracles/flux.ts index 094811373..ed53cb614 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/flux.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/flux.ts @@ -10,14 +10,14 @@ export const deployFluxOracle = async ({ fluxAssets, nativeUsdFeed, }: FluxDeployFnParams): Promise<{ fluxOracle: FluxPriceOracle }> => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); let tx: providers.TransactionResponse; - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); //// Flux Oracle const flux = await deployments.deploy("FluxPriceOracle", { - from: deployer, + from: upgradesAdmin, args: [], log: true, proxy: { @@ -27,7 +27,7 @@ export const deployFluxOracle = async ({ args: [nativeUsdFeed], }, }, - owner: deployer, + owner: upgradesAdmin, proxyContract: "OpenZeppelinTransparentProxy", }, }); @@ -35,7 +35,7 @@ export const deployFluxOracle = async ({ if (flux.transactionHash) await ethers.provider.waitForTransaction(flux.transactionHash); console.log("FluxPriceOracle: ", flux.address); - const fluxOracle = (await ethers.getContract("FluxPriceOracle", deployer)) as FluxPriceOracle; + const fluxOracle = (await ethers.getContract("FluxPriceOracle", oraclesAdmin)) as FluxPriceOracle; tx = await fluxOracle.setPriceFeeds( fluxAssets.map((f) => f.underlying), fluxAssets.map((f) => f.feed) diff --git a/packages/sdk/chainDeploy/helpers/oracles/gelato.ts b/packages/sdk/chainDeploy/helpers/oracles/gelato.ts index 8187cadbb..1d9073f7f 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/gelato.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/gelato.ts @@ -10,13 +10,13 @@ export const deployGelatoGUniPriceOracle = async ({ deployConfig, gelatoAssets, }: gelatoGUniPriceOracleDeployParams): Promise<{ gUniOracle: GelatoGUniPriceOracle }> => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); //// Gelato GUni Price Oracle const gelatoGUniPriceOracle = await deployments.deploy("GelatoGUniPriceOracle", { - from: deployer, + from: upgradesAdmin, args: [deployConfig.wtoken], log: true, }); @@ -26,7 +26,7 @@ export const deployGelatoGUniPriceOracle = async ({ console.log("GelatoGUniPriceOracle: ", gelatoGUniPriceOracle.address); - const gUniOracle = (await ethers.getContract("GelatoGUniPriceOracle", deployer)) as GelatoGUniPriceOracle; + const gUniOracle = (await ethers.getContract("GelatoGUniPriceOracle")) as GelatoGUniPriceOracle; const underlyings = gelatoAssets.map((d) => d.vaultAddress); const oracles = Array(gelatoAssets.length).fill(gUniOracle.address); diff --git a/packages/sdk/chainDeploy/helpers/oracles/nativeUsd.ts b/packages/sdk/chainDeploy/helpers/oracles/nativeUsd.ts index 66a2243a9..4c18994fc 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/nativeUsd.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/nativeUsd.ts @@ -8,11 +8,11 @@ export const deployNativeUsdPriceFeed = async ({ nativeUsdOracleAddress, quoteAddress, }: NativeUsdDeployFnParams): Promise<{ nativeUsdPriceOracle: NativeUSDPriceOracle }> => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); //// NativeUSDPriceOracle const nativeUsd = await deployments.deploy("NativeUSDPriceOracle", { - from: deployer, + from: upgradesAdmin, args: [], log: true, proxy: { @@ -22,7 +22,7 @@ export const deployNativeUsdPriceFeed = async ({ args: [nativeUsdOracleAddress, quoteAddress], }, }, - owner: deployer, + owner: upgradesAdmin, proxyContract: "OpenZeppelinTransparentProxy", }, }); @@ -30,6 +30,6 @@ export const deployNativeUsdPriceFeed = async ({ if (nativeUsd.transactionHash) await ethers.provider.waitForTransaction(nativeUsd.transactionHash); console.log("NativeUSDPriceOracle: ", nativeUsd.address); - const nativeUsdPriceOracle = (await ethers.getContract("NativeUSDPriceOracle", deployer)) as NativeUSDPriceOracle; + const nativeUsdPriceOracle = (await ethers.getContract("NativeUSDPriceOracle", oraclesAdmin)) as NativeUSDPriceOracle; return { nativeUsdPriceOracle }; }; diff --git a/packages/sdk/chainDeploy/helpers/oracles/saddleLp.ts b/packages/sdk/chainDeploy/helpers/oracles/saddleLp.ts index 0d3e022a3..46986fd00 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/saddleLp.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/saddleLp.ts @@ -8,13 +8,13 @@ export const deploySaddleLpOracle = async ({ deployments, saddlePools, }: SaddleLpFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); let tx: providers.TransactionResponse; let receipt: providers.TransactionReceipt; //// SaddleLpPriceOracle const spo = await deployments.deploy("SaddleLpPriceOracle", { - from: deployer, + from: upgradesAdmin, args: [], log: true, proxy: { @@ -24,14 +24,14 @@ export const deploySaddleLpOracle = async ({ args: [[], [], []], }, }, - owner: deployer, + owner: upgradesAdmin, proxyContract: "OpenZeppelinTransparentProxy", }, }); if (spo.transactionHash) await ethers.provider.waitForTransaction(spo.transactionHash); console.log("SaddleLpPriceOracle: ", spo.address); - const saddleLpOracle = await ethers.getContract("SaddleLpPriceOracle", deployer); + const saddleLpOracle = await ethers.getContract("SaddleLpPriceOracle", oraclesAdmin); for (const pool of saddlePools) { const registered = await saddleLpOracle.poolOf(pool.lpToken); @@ -50,7 +50,7 @@ export const deploySaddleLpOracle = async ({ const underlyings = saddlePools.map((c) => c.lpToken); const oracles = Array(saddlePools.length).fill(saddleLpOracle.address); - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); tx = await mpo.add(underlyings, oracles); await tx.wait(); diff --git a/packages/sdk/chainDeploy/helpers/oracles/stkBNBOracle.ts b/packages/sdk/chainDeploy/helpers/oracles/stkBNBOracle.ts index bfba39ff7..65b49f468 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/stkBNBOracle.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/stkBNBOracle.ts @@ -9,14 +9,14 @@ export const deployStkBNBOracle = async ({ deployments, assets, }: stkBNBOracleDeployParams): Promise<{ stkBNBOracle: any }> => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); const stkBNB = underlying(assets, assetSymbols.stkBNB); const stkBNBOracle = await deployments.deploy("StkBNBPriceOracle", { - from: deployer, + from: upgradesAdmin, args: [], log: true, proxy: { @@ -26,7 +26,7 @@ export const deployStkBNBOracle = async ({ args: [], }, }, - owner: deployer, + owner: upgradesAdmin, proxyContract: "OpenZeppelinTransparentProxy", }, }); diff --git a/packages/sdk/chainDeploy/helpers/oracles/uniswap.ts b/packages/sdk/chainDeploy/helpers/oracles/uniswap.ts index 8ab4287ae..b4885890e 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/uniswap.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/uniswap.ts @@ -10,13 +10,13 @@ export const deployUniswapOracle = async ({ deployments, deployConfig, }: UniswapDeployFnParams): Promise => { - const { deployer } = await getNamedAccounts(); - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const { upgradesAdmin, oraclesAdmin, testConfigAdmin } = await getNamedAccounts(); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); const updateOracles = [], updateUnderlyings = []; //// Uniswap Oracle const utpo = await deployments.deploy("UniswapTwapPriceOracleV2", { - from: deployer, + from: upgradesAdmin, args: [], log: true, }); @@ -24,7 +24,7 @@ export const deployUniswapOracle = async ({ console.log("UniswapTwapPriceOracleV2: ", utpo.address); const utpor = await deployments.deploy("UniswapTwapPriceOracleV2Root", { - from: deployer, + from: upgradesAdmin, args: [deployConfig.wtoken], log: true, }); @@ -32,7 +32,7 @@ export const deployUniswapOracle = async ({ console.log("UniswapTwapPriceOracleV2Root: ", utpor.address); const utpof = await deployments.deploy("UniswapTwapPriceOracleV2Factory", { - from: deployer, + from: upgradesAdmin, args: [utpor.address, utpo.address, deployConfig.wtoken], log: true, }); @@ -42,7 +42,7 @@ export const deployUniswapOracle = async ({ //// deploy uniswap twap price oracle v2 resolver const twapPriceOracleResolver = await deployments.deploy("UniswapTwapPriceOracleV2Resolver", { - from: deployer, + from: upgradesAdmin, args: [[], utpor.address], log: true, waitConfirmations: 1, @@ -52,7 +52,7 @@ export const deployUniswapOracle = async ({ } console.log("UniswapTwapPriceOracleV2Resolver: ", twapPriceOracleResolver.address); - const resolverContract = await ethers.getContract("UniswapTwapPriceOracleV2Resolver", deployer); + const resolverContract = await ethers.getContract("UniswapTwapPriceOracleV2Resolver", oraclesAdmin); const oldPairs = await resolverContract.getPairs(); @@ -80,7 +80,7 @@ export const deployUniswapOracle = async ({ const uniTwapOracleFactory = (await ethers.getContract( "UniswapTwapPriceOracleV2Factory", - deployer + oraclesAdmin )) as UniswapTwapPriceOracleV2Factory; const existingOracle = await uniTwapOracleFactory.callStatic.oracles( @@ -128,7 +128,7 @@ export const deployUniswapOracle = async ({ ); } - const addressesProvider = (await ethers.getContract("AddressesProvider", deployer)) as AddressesProvider; + const addressesProvider = (await ethers.getContract("AddressesProvider", testConfigAdmin)) as AddressesProvider; const uniTwapOracleFactoryAddress = await addressesProvider.callStatic.getAddress("UniswapTwapPriceOracleV2Factory"); const uniTwapOracleV2ResolverAddress = await addressesProvider.callStatic.getAddress( "UniswapTwapPriceOracleV2Resolver" diff --git a/packages/sdk/chainDeploy/helpers/oracles/uniswapLp.ts b/packages/sdk/chainDeploy/helpers/oracles/uniswapLp.ts index 73f17554a..24a5fd2b0 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/uniswapLp.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/uniswapLp.ts @@ -9,16 +9,16 @@ export const deployUniswapLpOracle = async ({ deployments, deployConfig, }: UniswapDeployFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); const lpTokenPriceOralce = await deployments.deploy("UniswapLpTokenPriceOracle", { - from: deployer, + from: upgradesAdmin, args: [deployConfig.wtoken], log: true, waitConfirmations: 1, }); console.log("UniswapLpTokenPriceOracle: ", lpTokenPriceOralce.address); - const mpo = (await ethers.getContract("MasterPriceOracle", deployer)) as MasterPriceOracle; + const mpo = (await ethers.getContract("MasterPriceOracle", oraclesAdmin)) as MasterPriceOracle; const oracles = []; const underlyings = []; for (const lpToken of deployConfig.uniswap.uniswapOracleLpTokens) { diff --git a/packages/sdk/chainDeploy/helpers/oracles/uniswapv3.ts b/packages/sdk/chainDeploy/helpers/oracles/uniswapv3.ts index 9b9792dcb..75790b854 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/uniswapv3.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/uniswapv3.ts @@ -9,13 +9,12 @@ export const deployUniswapV3Oracle = async ({ deployments, deployConfig, }: UniswaV3DeployFnParams): Promise => { - const { deployer } = await getNamedAccounts(); - const mpo = (await ethers.getContract("MasterPriceOracle", deployer)) as MasterPriceOracle; + const { upgradesAdmin, oraclesAdmin, testConfigAdmin } = await getNamedAccounts(); + const mpo = (await ethers.getContract("MasterPriceOracle", oraclesAdmin)) as MasterPriceOracle; //// Uniswap Oracle const utpo = await deployments.deploy("UniswapV3PriceOracle", { - from: deployer, - args: [], + from: upgradesAdmin, log: true, proxy: { execute: { @@ -24,7 +23,7 @@ export const deployUniswapV3Oracle = async ({ args: [deployConfig.wtoken, deployConfig.stableToken], }, }, - owner: deployer, + owner: upgradesAdmin, proxyContract: "OpenZeppelinTransparentProxy", }, }); @@ -32,7 +31,7 @@ export const deployUniswapV3Oracle = async ({ if (utpo.transactionHash) await ethers.provider.waitForTransaction(utpo.transactionHash); console.log("UniswapV3PriceOracle: ", utpo.address); - const uniswapV3Oracle = (await ethers.getContract("UniswapV3PriceOracle", deployer)) as UniswapV3PriceOracle; + const uniswapV3Oracle = (await ethers.getContract("UniswapV3PriceOracle", oraclesAdmin)) as UniswapV3PriceOracle; const assetsToAdd = []; for (const assetConfig of deployConfig.uniswap.uniswapV3OracleTokens) { @@ -68,7 +67,7 @@ export const deployUniswapV3Oracle = async ({ await tx.wait(); console.log(`Master Price Oracle updated for tokens: ${underlyings.join(",")}`); - const addressesProvider = (await ethers.getContract("AddressesProvider", deployer)) as AddressesProvider; + const addressesProvider = (await ethers.getContract("AddressesProvider", testConfigAdmin)) as AddressesProvider; const uniswapV3PriceOracleAddress = await addressesProvider.callStatic.getAddress("UniswapV3PriceOracle"); if (uniswapV3PriceOracleAddress !== uniswapV3Oracle.address) { const tx = await addressesProvider.setAddress("UniswapV3PriceOracle", uniswapV3Oracle.address); diff --git a/packages/sdk/chainDeploy/helpers/oracles/wombatLp.ts b/packages/sdk/chainDeploy/helpers/oracles/wombatLp.ts index 5f8cc5ecf..2c4fe4262 100644 --- a/packages/sdk/chainDeploy/helpers/oracles/wombatLp.ts +++ b/packages/sdk/chainDeploy/helpers/oracles/wombatLp.ts @@ -9,13 +9,13 @@ export const deployWombatOracle = async ({ deployments, wombatAssets, }: WombatDeployFnParams): Promise<{ wombatOracle: WombatLpTokenPriceOracle }> => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); ///// Wombat Lp Token Price Oracle const wombat = await deployments.deploy("WombatLpTokenPriceOracle", { - from: deployer, + from: upgradesAdmin, args: [], log: true, }); diff --git a/packages/sdk/chainDeploy/mainnets/arbitrum.ts b/packages/sdk/chainDeploy/mainnets/arbitrum.ts index f8e3c2782..e5673ebec 100644 --- a/packages/sdk/chainDeploy/mainnets/arbitrum.ts +++ b/packages/sdk/chainDeploy/mainnets/arbitrum.ts @@ -153,7 +153,7 @@ const saddlePools: CurvePoolConfig[] = [ ]; export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: ChainDeployFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin } = await getNamedAccounts(); //// deploy uniswap v3 price oracle await deployUniswapV3Oracle({ @@ -204,7 +204,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha // Quoter const quoter = await deployments.deploy("Quoter", { - from: deployer, + from: upgradesAdmin, args: [deployConfig.uniswap.uniswapV3FactoryAddress], log: true, waitConfirmations: 1, @@ -215,7 +215,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// CurveLPLiquidator const curveLpTokenLiquidatorNoRegistry = await deployments.deploy("CurveLpTokenLiquidatorNoRegistry", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -237,7 +237,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha // CurveSwapLiquidator const curveSwapLiquidator = await deployments.deploy("CurveSwapLiquidator", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -248,7 +248,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// Uniswap Lp token liquidator const uniswapLpTokenLiquidator = await deployments.deploy("UniswapLpTokenLiquidator", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -257,7 +257,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// Uniswap V3 Liquidator Funder const uniswapV3LiquidatorFunder = await deployments.deploy("UniswapV3LiquidatorFunder", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, diff --git a/packages/sdk/chainDeploy/mainnets/bsc.ts b/packages/sdk/chainDeploy/mainnets/bsc.ts index 4ae00bb6a..7cb0a9b46 100644 --- a/packages/sdk/chainDeploy/mainnets/bsc.ts +++ b/packages/sdk/chainDeploy/mainnets/bsc.ts @@ -315,7 +315,7 @@ const wombatAssets: WombatAsset[] = [ ]; export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: ChainDeployFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, oraclesAdmin, testConfigAdmin } = await getNamedAccounts(); //// //// ORACLES //// Uniswap Oracle @@ -328,12 +328,12 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha }); // set Native BNB price - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); const nativeBnb = underlying(assets, assetSymbols.BNB); const existingOracle = await mpo.callStatic.oracles(nativeBnb); if (existingOracle === ethers.constants.AddressZero) { - const fpo = await ethers.getContract("FixedNativePriceOracle", deployer); + const fpo = await ethers.getContract("FixedNativePriceOracle"); const tx = await mpo.add([nativeBnb], [fpo.address]); await tx.wait(); } @@ -420,7 +420,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// Liquidator Redemption Strategies const uniswapLpTokenLiquidator = await deployments.deploy("UniswapLpTokenLiquidator", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -434,7 +434,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// custom uniswap v2 redemptions and funding const uniswapV2LiquidatorFunder = await deployments.deploy("UniswapV2LiquidatorFunder", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -446,7 +446,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha /// xBOMB<>BOMB const xbombLiquidatorFunder = await deployments.deploy("XBombLiquidatorFunder", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -457,7 +457,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// JarvisLiquidatorFunder const jarvisLiquidatorFunder = await deployments.deploy("JarvisLiquidatorFunder", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -468,7 +468,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha /// curve LP tokens const curveLpTokenLiquidatorNoRegistry = await deployments.deploy("CurveLpTokenLiquidatorNoRegistry", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -479,7 +479,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha // curve swap underlying tokens const curveSwapLiquidator = await deployments.deploy("CurveSwapLiquidator", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -490,7 +490,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha // curve swap liquidator funder - TODO replace the CurveSwapLiquidator above const curveSwapLiquidatorFunder = await deployments.deploy("CurveSwapLiquidatorFunder", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -501,7 +501,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha // wombat Lp token liquidator const wombatLpTokenLiquidator = await deployments.deploy("WombatLpTokenLiquidator", { - from: deployer, + from: upgradesAdmin, args: [], log: true, }); @@ -511,7 +511,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// deploy ankr bnb interest rate model const abirm = await deployments.deploy("AnkrBNBInterestRateModel", { - from: deployer, + from: upgradesAdmin, args: [ deployConfig.blocksPerYear, "5000000000000000", @@ -537,7 +537,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha console.log("deployed dynamicFlywheels: ", dynamicFlywheels); /// Addresses Provider - set bUSD - const addressesProvider = (await ethers.getContract("AddressesProvider", deployer)) as AddressesProvider; + const addressesProvider = (await ethers.getContract("AddressesProvider", testConfigAdmin)) as AddressesProvider; const busdAddress = underlying(assets, assetSymbols.BUSD); const busdAddressAp = await addressesProvider.callStatic.getAddress("bUSD"); if (busdAddressAp != busdAddress) { diff --git a/packages/sdk/chainDeploy/mainnets/evmos.ts b/packages/sdk/chainDeploy/mainnets/evmos.ts index e7eb30a43..f0c54dc18 100644 --- a/packages/sdk/chainDeploy/mainnets/evmos.ts +++ b/packages/sdk/chainDeploy/mainnets/evmos.ts @@ -151,7 +151,6 @@ const saddlePools: CurvePoolConfig[] = [ ]; export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: ChainDeployFnParams): Promise => { - const { deployer } = await getNamedAccounts(); const { nativeUsdPriceOracle } = await deployNativeUsdPriceFeed({ run, ethers, diff --git a/packages/sdk/chainDeploy/mainnets/fantom.ts b/packages/sdk/chainDeploy/mainnets/fantom.ts index 1273be66a..6c7f6402a 100644 --- a/packages/sdk/chainDeploy/mainnets/fantom.ts +++ b/packages/sdk/chainDeploy/mainnets/fantom.ts @@ -122,7 +122,7 @@ const curvePools: CurvePoolConfig[] = [ ]; export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: ChainDeployFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin } = await getNamedAccounts(); //// ChainLinkV2 Oracle await deployChainlinkOracle({ run, @@ -187,7 +187,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// //// deploy ankr certificate interest rate model const afirm = await deployments.deploy("AnkrFTMInterestRateModel", { - from: deployer, + from: upgradesAdmin, args: [ deployConfig.blocksPerYear, "5000000000000000", diff --git a/packages/sdk/chainDeploy/mainnets/moonbeam.ts b/packages/sdk/chainDeploy/mainnets/moonbeam.ts index 75debdd26..020c89ee8 100644 --- a/packages/sdk/chainDeploy/mainnets/moonbeam.ts +++ b/packages/sdk/chainDeploy/mainnets/moonbeam.ts @@ -204,7 +204,7 @@ const saddlePools: CurvePoolConfig[] = [ ]; export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: ChainDeployFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin } = await getNamedAccounts(); //// ORACLES //// Uniswap Oracle @@ -266,7 +266,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// CurveLPLiquidator const curveLpTokenLiquidatorNoRegistry = await deployments.deploy("CurveLpTokenLiquidatorNoRegistry", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -277,7 +277,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha // CurveSwapLiquidator const curveSwapLiquidator = await deployments.deploy("CurveSwapLiquidator", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -288,7 +288,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// Uniswap Lp token liquidator const uniswapLpTokenLiquidator = await deployments.deploy("UniswapLpTokenLiquidator", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, diff --git a/packages/sdk/chainDeploy/mainnets/polygon.ts b/packages/sdk/chainDeploy/mainnets/polygon.ts index 30fe50013..51dfcf07d 100644 --- a/packages/sdk/chainDeploy/mainnets/polygon.ts +++ b/packages/sdk/chainDeploy/mainnets/polygon.ts @@ -467,7 +467,7 @@ const balancerLpAssets: BalancerLpAsset[] = [ ]; export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: ChainDeployFnParams): Promise => { - const { deployer } = await getNamedAccounts(); + const { upgradesAdmin, testConfigAdmin } = await getNamedAccounts(); //// //// ORACLES @@ -556,7 +556,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha // Quoter const quoter = await deployments.deploy("Quoter", { - from: deployer, + from: upgradesAdmin, args: [deployConfig.uniswap.uniswapV3FactoryAddress], log: true, waitConfirmations: 1, @@ -565,7 +565,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// UniswapLpTokenLiquidator const uniswapLpTokenLiquidator = await deployments.deploy("UniswapLpTokenLiquidator", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -588,7 +588,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// CurveLPLiquidator const curveLpTokenLiquidatorNoRegistry = await deployments.deploy("CurveLpTokenLiquidatorNoRegistry", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -599,7 +599,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha // CurveSwapLiquidator const curveSwapLiquidator = await deployments.deploy("CurveSwapLiquidator", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -610,7 +610,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha // curve swap liquidator funder - TODO replace the CurveSwapLiquidator above const curveSwapLiquidatorFunder = await deployments.deploy("CurveSwapLiquidatorFunder", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -631,7 +631,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// Gelato GUNI Liquidator const gelatoGUniLiquidator = await deployments.deploy("GelatoGUniLiquidator", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -643,7 +643,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// JarvisLiquidatorFunder const jarvisLiquidatorFunder = await deployments.deploy("JarvisLiquidatorFunder", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -654,7 +654,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// Uniswap V3 Liquidator Funder const uniswapV3LiquidatorFunder = await deployments.deploy("UniswapV3LiquidatorFunder", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -663,7 +663,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha //// custom uniswap v2 redemptions and funding const uniswapV2LiquidatorFunder = await deployments.deploy("UniswapV2LiquidatorFunder", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -674,8 +674,8 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha console.log("UniswapV2LiquidatorFunder: ", uniswapV2LiquidatorFunder.address); /// Addresses Provider - /// set bUSD - const addressesProvider = (await ethers.getContract("AddressesProvider", deployer)) as AddressesProvider; + /// Addresses Provider - set bUSD + const addressesProvider = (await ethers.getContract("AddressesProvider", testConfigAdmin)) as AddressesProvider; const busdAddress = underlying(assets, assetSymbols.BUSD); const busdAddressAp = await addressesProvider.callStatic.getAddress("bUSD"); if (busdAddressAp !== busdAddress) { @@ -684,7 +684,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: Cha console.log("setAddress bUSD: ", tx.hash); } /// set BalancerLpStablePoolPriceOracle - const balancerLpStablePoolPriceOracle = await ethers.getContractOrNull("BalancerLpStablePoolPriceOracle", deployer); + const balancerLpStablePoolPriceOracle = await ethers.getContractOrNull("BalancerLpStablePoolPriceOracle"); const balancerLpStablePoolPriceOracleAp = await addressesProvider.callStatic.getAddress( "BalancerLpStablePoolPriceOracle" ); diff --git a/packages/sdk/chainDeploy/testnets/chapel.ts b/packages/sdk/chainDeploy/testnets/chapel.ts index 9dd650734..515bc9c74 100644 --- a/packages/sdk/chainDeploy/testnets/chapel.ts +++ b/packages/sdk/chainDeploy/testnets/chapel.ts @@ -9,7 +9,7 @@ import { deployUniswapLpOracle, deployUniswapOracle, } from "../helpers"; -import { ChainlinkAsset } from "../helpers/types"; +import { ChainDeployFnParams, ChainlinkAsset } from "../helpers/types"; const assets = chapel.assets; @@ -45,8 +45,8 @@ export const deployConfig: ChainDeployConfig = { cgId: chapel.specificParams.cgId, }; -export const deploy = async ({ run, ethers, getNamedAccounts, deployments }): Promise => { - const { deployer } = await getNamedAccounts(); +export const deploy = async ({ run, ethers, getNamedAccounts, deployments }: ChainDeployFnParams): Promise => { + const { upgradesAdmin } = await getNamedAccounts(); //// //// ORACLES const chainlinkAssets: ChainlinkAsset[] = [ @@ -99,7 +99,7 @@ export const deploy = async ({ run, ethers, getNamedAccounts, deployments }): Pr //// Liquidator Redemption Strategies const uniswapLpTokenLiquidator = await deployments.deploy("UniswapLpTokenLiquidator", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, diff --git a/packages/sdk/chainDeploy/testnets/neondevnet.ts b/packages/sdk/chainDeploy/testnets/neondevnet.ts index d5702a8cd..7976e5c92 100644 --- a/packages/sdk/chainDeploy/testnets/neondevnet.ts +++ b/packages/sdk/chainDeploy/testnets/neondevnet.ts @@ -3,6 +3,7 @@ import { assetSymbols, underlying } from "@midas-capital/types"; import { ethers } from "ethers"; import { ChainDeployConfig } from "../helpers"; +import { ChainDeployFnParams } from "../helpers/types"; const assets = neondevnet.assets; const BN = ethers.utils.parseEther("1"); @@ -28,11 +29,11 @@ export const deployConfig: ChainDeployConfig = { cgId: neondevnet.specificParams.cgId, }; -export const deploy = async ({ ethers, getNamedAccounts, deployments }): Promise => { - const { deployer } = await getNamedAccounts(); +export const deploy = async ({ ethers, getNamedAccounts, deployments }: ChainDeployFnParams): Promise => { + const { upgradesAdmin, oraclesAdmin } = await getNamedAccounts(); const pyth = await deployments.deploy("Pyth", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -41,8 +42,8 @@ export const deploy = async ({ ethers, getNamedAccounts, deployments }): Promise const _assets = assets.filter((a) => a.symbol !== assetSymbols.WNEON); - const masterPriceOracle = await ethers.getContract("MasterPriceOracle", deployer); - const simplePriceOracle = await ethers.getContract("SimplePriceOracle", deployer); + const masterPriceOracle = await ethers.getContract("MasterPriceOracle", oraclesAdmin); + const simplePriceOracle = await ethers.getContract("SimplePriceOracle", oraclesAdmin); let tx; for (const a of _assets) { diff --git a/packages/sdk/deploy/deploy.ts b/packages/sdk/deploy/deploy.ts index 0e94a71b8..bbcc75bec 100644 --- a/packages/sdk/deploy/deploy.ts +++ b/packages/sdk/deploy/deploy.ts @@ -17,10 +17,19 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments const chainId = parseInt(await getChainId()); console.log("chainId: ", chainId); const MIN_BORROW_USD = chainId === 97 || chainId === 245022926 ? 0 : 100; - const { deployer } = await getNamedAccounts(); - console.log("deployer: ", deployer); - const balance = await ethers.provider.getBalance(deployer); - console.log("balance: ", balance.toString()); + const { upgradesAdmin, liquidator, poolsSuperAdmin, oraclesAdmin, extrasAdmin, testConfigAdmin } = + await getNamedAccounts(); + console.log("upgradesAdmin: ", upgradesAdmin); + console.log("accounts", { + upgradesAdmin, + liquidator, + poolsSuperAdmin, + testConfigAdmin, + oraclesAdmin, + extrasAdmin, + }); + const balance = await ethers.provider.getBalance(upgradesAdmin); + console.log("upgradesAdmin balance: ", balance.toString()); const price = await ethers.provider.getGasPrice(); console.log("gas price: ", ethers.utils.formatUnits(price, "gwei")); @@ -36,7 +45,7 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments let tx: providers.TransactionResponse; const ffd = await deployments.deploy("FuseFeeDistributor", { - from: deployer, + from: upgradesAdmin, log: true, proxy: { proxyContract: "OpenZeppelinTransparentProxy", @@ -46,13 +55,13 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments args: [ethers.utils.parseEther("0.1")], }, }, - owner: deployer, + owner: upgradesAdmin, }, }); if (ffd.transactionHash) await ethers.provider.waitForTransaction(ffd.transactionHash); console.log("FuseFeeDistributor: ", ffd.address); - const fuseFeeDistributor = (await ethers.getContract("FuseFeeDistributor", deployer)) as FuseFeeDistributor; + const fuseFeeDistributor = (await ethers.getContract("FuseFeeDistributor", poolsSuperAdmin)) as FuseFeeDistributor; const ffdFee = await fuseFeeDistributor.callStatic.defaultInterestFeeRate(); console.log(`ffd fee ${ffdFee}`); @@ -93,16 +102,17 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments const comp = await deployments.deploy("Comptroller", { contract: "Comptroller.sol:Comptroller", - from: deployer, + from: upgradesAdmin, args: [ffd.address], log: true, }); if (comp.transactionHash) await ethers.provider.waitForTransaction(comp.transactionHash); - console.log("Comptroller ", comp.address); + const comptrollerAddress = comp.address; + console.log("Comptroller ", comptrollerAddress); const compFirstExtension = await deployments.deploy("ComptrollerFirstExtension", { contract: "ComptrollerFirstExtension", - from: deployer, + from: upgradesAdmin, args: [], log: true, }); @@ -115,7 +125,7 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments const cTokenFirstExtension = await deployments.deploy("CTokenFirstExtension", { contract: "CTokenFirstExtension", - from: deployer, + from: upgradesAdmin, args: [], log: true, }); @@ -124,7 +134,7 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments console.log("CTokenFirstExtension", cTokenFirstExtension.address); const erc20Del = await deployments.deploy("CErc20Delegate", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -133,7 +143,7 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments console.log("CErc20Delegate: ", erc20Del.address); const erc20PluginDel = await deployments.deploy("CErc20PluginDelegate", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -141,7 +151,7 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments console.log("CErc20PluginDelegate: ", erc20PluginDel.address); const erc20PluginRewardsDel = await deployments.deploy("CErc20PluginRewardsDelegate", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -150,7 +160,7 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments //// //// FUSE CORE CONTRACTS const fpd = await deployments.deploy("FusePoolDirectory", { - from: deployer, + from: upgradesAdmin, log: true, proxy: { proxyContract: "OpenZeppelinTransparentProxy", @@ -160,21 +170,20 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments args: [false, []], }, }, - owner: deployer, + owner: upgradesAdmin, }, waitConfirmations: 1, }); if (fpd.transactionHash) await ethers.provider.waitForTransaction(fpd.transactionHash); console.log("FusePoolDirectory: ", fpd.address); - const fusePoolDirectory = await ethers.getContract("FusePoolDirectory", deployer); + const fusePoolDirectory = await ethers.getContract("FusePoolDirectory", poolsSuperAdmin); - const comptroller = await ethers.getContract("Comptroller", deployer); const oldComptrollerImplementations = [constants.AddressZero]; - const newComptrollerImplementations = [comptroller.address]; + const newComptrollerImplementations = [comptrollerAddress]; const comptrollerArrayOfTrue = [true]; if (oldComptroller && oldComptroller.address != comptroller.address) { oldComptrollerImplementations.push(oldComptroller.address); - newComptrollerImplementations.push(comptroller.address); + newComptrollerImplementations.push(comptrollerAddress); comptrollerArrayOfTrue.push(true); } @@ -210,21 +219,21 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments ); if ( latestComptrollerImplementation === constants.AddressZero || - latestComptrollerImplementation !== comptroller.address + latestComptrollerImplementation !== comptrollerAddress ) { - tx = await fuseFeeDistributor._setLatestComptrollerImplementation(oldComptroller.address, comptroller.address); + tx = await fuseFeeDistributor._setLatestComptrollerImplementation(oldComptroller.address, comptrollerAddress); await tx.wait(); - console.log(`Set the latest Comptroller implementation for ${oldComptroller.address} to ${comptroller.address}`); + console.log(`Set the latest Comptroller implementation for ${oldComptroller.address} to ${comptrollerAddress}`); } else { - console.log(`No change in the latest Comptroller implementation ${comptroller.address}`); + console.log(`No change in the latest Comptroller implementation ${comptrollerAddress}`); } } - const comptrollerExtensions = await fuseFeeDistributor.callStatic.getComptrollerExtensions(comptroller.address); + const comptrollerExtensions = await fuseFeeDistributor.callStatic.getComptrollerExtensions(comptrollerAddress); if (comptrollerExtensions.length != 1 || comptrollerExtensions[0] != compFirstExtension.address) { - tx = await fuseFeeDistributor._setComptrollerExtensions(comptroller.address, [compFirstExtension.address]); + tx = await fuseFeeDistributor._setComptrollerExtensions(comptrollerAddress, [compFirstExtension.address]); await tx.wait(); - console.log(`configured the extensions for comptroller ${comptroller.address}`); + console.log(`configured the extensions for comptroller ${comptrollerAddress}`); } else { console.log(`comptroller extensions already configured`); } @@ -332,14 +341,14 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments } const fplDeployment = await deployments.deploy("FusePoolLens", { - from: deployer, + from: upgradesAdmin, log: true, waitConfirmations: 1, }); if (fplDeployment.transactionHash) await ethers.provider.waitForTransaction(fplDeployment.transactionHash); console.log("FusePoolLens: ", fplDeployment.address); - const fusePoolLens = await ethers.getContract("FusePoolLens", deployer); + const fusePoolLens = await ethers.getContract("FusePoolLens", upgradesAdmin); let directory = await fusePoolLens.directory(); if (directory === constants.AddressZero) { tx = await fusePoolLens.initialize( @@ -360,7 +369,7 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments } const fpls = await deployments.deploy("FusePoolLensSecondary", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -368,7 +377,7 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments if (fpls.transactionHash) await ethers.provider.waitForTransaction(fpls.transactionHash); console.log("FusePoolLensSecondary: ", fpls.address); - const fusePoolLensSecondary = await ethers.getContract("FusePoolLensSecondary", deployer); + const fusePoolLensSecondary = await ethers.getContract("FusePoolLensSecondary", upgradesAdmin); directory = await fusePoolLensSecondary.directory(); if (directory === constants.AddressZero) { tx = await fusePoolLensSecondary.initialize(fusePoolDirectory.address); @@ -379,7 +388,7 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments } const mflrReceipt = await deployments.deploy("MidasFlywheelLensRouter", { - from: deployer, + from: upgradesAdmin, args: [], log: true, waitConfirmations: 1, @@ -388,7 +397,7 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments console.log("MidasFlywheelLensRouter: ", mflrReceipt.address); const booster = await deployments.deploy("LooplessFlywheelBooster", { - from: deployer, + from: upgradesAdmin, log: true, args: [], waitConfirmations: 1, @@ -396,9 +405,10 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments if (booster.transactionHash) await ethers.provider.waitForTransaction(booster.transactionHash); console.log("LooplessFlywheelBooster: ", booster.address); - const erc20Delegate = await ethers.getContract("CErc20Delegate", deployer); - const erc20PluginDelegate = await ethers.getContract("CErc20PluginDelegate", deployer); - const erc20PluginRewardsDelegate = await ethers.getContract("CErc20PluginRewardsDelegate", deployer); + await tx.wait(); + const erc20Delegate = await ethers.getContract("CErc20Delegate"); + const erc20PluginDelegate = await ethers.getContract("CErc20PluginDelegate"); + const erc20PluginRewardsDelegate = await ethers.getContract("CErc20PluginRewardsDelegate"); const oldImplementations = [constants.AddressZero, constants.AddressZero, constants.AddressZero]; const newImplementations = [erc20Delegate.address, erc20PluginDelegate.address, erc20PluginRewardsDelegate.address]; @@ -450,14 +460,14 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments //// //// ORACLES const fixedNativePO = await deployments.deploy("FixedNativePriceOracle", { - from: deployer, + from: upgradesAdmin, args: [], log: true, }); console.log("FixedNativePriceOracle: ", fixedNativePO.address); const simplePO = await deployments.deploy("SimplePriceOracle", { - from: deployer, + from: upgradesAdmin, args: [], log: true, proxy: { @@ -468,7 +478,7 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments }, }, proxyContract: "OpenZeppelinTransparentProxy", - owner: deployer, + owner: upgradesAdmin, }, waitConfirmations: 1, }); @@ -476,7 +486,7 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments console.log("SimplePriceOracle: ", simplePO.address); const masterPO = await deployments.deploy("MasterPriceOracle", { - from: deployer, + from: upgradesAdmin, log: true, proxy: { execute: { @@ -486,14 +496,14 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments [constants.AddressZero, chainDeployParams.wtoken], [fixedNativePO.address, fixedNativePO.address], constants.AddressZero, - deployer, + oraclesAdmin, true, chainDeployParams.wtoken, ], }, }, proxyContract: "OpenZeppelinTransparentProxy", - owner: deployer, + owner: upgradesAdmin, }, waitConfirmations: 1, }); @@ -504,17 +514,17 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments //// //// HELPERS - ADDRESSES PROVIDER await deployments.deploy("AddressesProvider", { - from: deployer, + from: upgradesAdmin, log: true, proxy: { execute: { init: { methodName: "initialize", - args: [deployer], + args: [testConfigAdmin], }, }, proxyContract: "OpenZeppelinTransparentProxy", - owner: deployer, + owner: upgradesAdmin, }, waitConfirmations: 1, }); @@ -550,7 +560,7 @@ const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments }); /// - const addressesProvider = (await ethers.getContract("AddressesProvider", deployer)) as AddressesProvider; + const addressesProvider = (await ethers.getContract("AddressesProvider", testConfigAdmin)) as AddressesProvider; /// EXTERNAL ADDRESSES const uniswapV2FactoryAddress = await addressesProvider.callStatic.getAddress("IUniswapV2Factory"); diff --git a/packages/sdk/deploy/fork.ts b/packages/sdk/deploy/fork.ts index fe02e5282..5a4068b55 100644 --- a/packages/sdk/deploy/fork.ts +++ b/packages/sdk/deploy/fork.ts @@ -20,15 +20,14 @@ const forkMainnet: DeployFunction = async (hre): Promise => { whale = (await hre.getNamedAccounts())["alice"]; } console.log("whale: ", whale); - - const { deployer } = await hre.getNamedAccounts(); + const { upgradesAdmin } = await hre.getNamedAccounts(); // in case hardhat_impersonateAccount is failing, make sure to be running `hardhat node` instead of deploy await hre.network.provider.send("evm_setAutomine", [true]); - await hre.ethers.provider.send("hardhat_impersonateAccount", [deployer]); + await hre.ethers.provider.send("hardhat_impersonateAccount", [whale]); - const signer = hre.ethers.provider.getSigner(deployer); - await signer.sendTransaction({ to: deployer, value: fundingValue }); + const signer = hre.ethers.provider.getSigner(whale); + await signer.sendTransaction({ to: upgradesAdmin, value: fundingValue }); await func(hre); }; forkMainnet.tags = ["simulate", "fork", "local"]; diff --git a/packages/sdk/hardhat.config.ts b/packages/sdk/hardhat.config.ts index 85f1b5a76..2ea4ad877 100644 --- a/packages/sdk/hardhat.config.ts +++ b/packages/sdk/hardhat.config.ts @@ -72,7 +72,13 @@ const config: HardhatUserConfig = { }, namedAccounts: { - deployer: { default: 0 }, + upgradesAdmin: { default: 0 }, + liquidator: { default: 0 }, + poolsSuperAdmin: { default: 0 }, + oraclesAdmin: { default: 0 }, + extrasAdmin: { default: 0 }, + testConfigAdmin: { default: 0 }, + deployer: { hardhat: 0 }, alice: { default: 1 }, bob: { default: 2 }, rando: { default: 3 }, diff --git a/packages/sdk/tasks/admin/edit-deployers.ts b/packages/sdk/tasks/admin/edit-deployers.ts index 013dd83f1..42f4e0364 100644 --- a/packages/sdk/tasks/admin/edit-deployers.ts +++ b/packages/sdk/tasks/admin/edit-deployers.ts @@ -8,9 +8,9 @@ export default task("edit-deployers", "Edit deployers") console.log("status: ", status); const deployers = _deployers.split(","); console.log("deployers: ", deployers); - const { deployer } = await getNamedAccounts(); + const { poolsSuperAdmin } = await getNamedAccounts(); - const fpd = await ethers.getContract("FusePoolDirectory", deployer); + const fpd = await ethers.getContract("FusePoolDirectory", poolsSuperAdmin); const tx = await fpd._editDeployerWhitelist(deployers, status); console.log("_editDeployerWhitelist tx: ", tx); @@ -22,9 +22,9 @@ task("edit-deployer-whitelist-enforcement", "Edit deployer whitelist enforcement .addParam("enforce", "Enforce whitelist?") .setAction(async ({ enforce: _enforce }, { getNamedAccounts, ethers }) => { const enforce = _enforce === "true"; - const { deployer } = await getNamedAccounts(); + const { poolsSuperAdmin } = await getNamedAccounts(); - const fpd = await ethers.getContract("FusePoolDirectory", deployer); + const fpd = await ethers.getContract("FusePoolDirectory", poolsSuperAdmin); const current = await fpd.enforceDeployerWhitelist(); console.log("current: ", current); if (current === enforce) { diff --git a/packages/sdk/tasks/admin/replace-deployer.ts b/packages/sdk/tasks/admin/replace-deployer.ts index 9d40eef76..05bd2020f 100644 --- a/packages/sdk/tasks/admin/replace-deployer.ts +++ b/packages/sdk/tasks/admin/replace-deployer.ts @@ -2,8 +2,8 @@ import { providers } from "ethers"; import { task, types } from "hardhat/config"; import { AddressesProvider } from "../../typechain/AddressesProvider"; +import { AdrastiaPriceOracle } from "../../typechain/AdrastiaPriceOracle"; import { CErc20PluginDelegate } from "../../typechain/CErc20PluginDelegate"; -import { Comptroller } from "../../typechain/Comptroller"; import { ComptrollerFirstExtension } from "../../typechain/ComptrollerFirstExtension"; import { DiaPriceOracle } from "../../typechain/DiaPriceOracle"; import { FusePoolDirectory } from "../../typechain/FusePoolDirectory"; @@ -12,6 +12,7 @@ import { MidasERC4626 } from "../../typechain/MidasERC4626"; import { MidasFlywheelCore } from "../../typechain/MidasFlywheelCore"; import { Ownable } from "../../typechain/Ownable"; import { OwnableUpgradeable } from "../../typechain/OwnableUpgradeable"; +import { SaddleLpPriceOracle } from "../../typechain/SaddleLpPriceOracle"; import { SafeOwnableUpgradeable } from "../../typechain/SafeOwnableUpgradeable"; import { Unitroller } from "../../typechain/Unitroller"; @@ -431,3 +432,250 @@ task("system:admin:accept", "Accepts the pending admin/owner roles as the new ad } } }); + +task("system:admins:split", "Split the contracts admin to different roles") + .addParam("currentDeployer", "The address of the current deployer", undefined, types.string) + .addParam("newDeployer", "The address of the new deployer", undefined, types.string) + .setAction(async ({ currentDeployer }, { ethers, getNamedAccounts }) => { + let tx: providers.TransactionResponse; + + const deployer = await ethers.getSigner(currentDeployer); + + // TODO probably hardcode these + const { upgradesAdmin, liquidator, poolsSuperAdmin, testConfigAdmin, oraclesAdmin, extrasAdmin } = + await getNamedAccounts(); + + // OwnableUpgradeable - transferOwnership(newDeployer) + const fsl = (await ethers.getContract("FuseSafeLiquidator", deployer)) as OwnableUpgradeable; + const currentOwnerFSL = await fsl.callStatic.owner(); + console.log(`current FSL owner ${currentOwnerFSL}`); + + if (currentOwnerFSL == currentDeployer) { + tx = await fsl.transferOwnership(liquidator); + await tx.wait(); + console.log(`fsl.transferOwnership tx mined ${tx.hash}`); + } else if (currentOwnerFSL != liquidator) { + console.error(`unknown owner ${currentOwnerFSL}`); + } + + const saddleLpOracle = (await ethers.getContractOrNull("SaddleLpPriceOracle", deployer)) as SafeOwnableUpgradeable; + if (saddleLpOracle) { + const currentOwner = await saddleLpOracle.callStatic.owner(); + if (currentOwner == currentDeployer) { + const currentPendingOwner = await saddleLpOracle.callStatic.pendingOwner(); + console.log(`current pending owner ${currentPendingOwner}`); + if (currentPendingOwner != oraclesAdmin) { + tx = await saddleLpOracle._setPendingOwner(oraclesAdmin); + await tx.wait(); + console.log(`saddleLpOracle._setPendingOwner tx mined ${tx.hash}`); + } + } else if (currentOwner != oraclesAdmin) { + console.error(`unknown owner ${currentOwner}`); + } + } + + const adrastiaPriceOracle = (await ethers.getContractOrNull( + "AdrastiaPriceOracle", + deployer + )) as SafeOwnableUpgradeable; + if (adrastiaPriceOracle) { + const currentOwner = await adrastiaPriceOracle.callStatic.owner(); + if (currentOwner == currentDeployer) { + const currentPendingOwner = await adrastiaPriceOracle.callStatic.pendingOwner(); + console.log(`current pending owner ${currentPendingOwner}`); + if (currentPendingOwner != oraclesAdmin) { + tx = await adrastiaPriceOracle._setPendingOwner(oraclesAdmin); + await tx.wait(); + console.log(`adrastiaPriceOracle._setPendingOwner tx mined ${tx.hash}`); + } + } else if (currentOwner != oraclesAdmin) { + console.error(`unknown owner ${currentOwner}`); + } + } + + const ankrCertificateTokenPriceOracle = (await ethers.getContractOrNull( + "AnkrCertificateTokenPriceOracle", + deployer + )) as SafeOwnableUpgradeable; + if (ankrCertificateTokenPriceOracle) { + const currentOwner = await ankrCertificateTokenPriceOracle.callStatic.owner(); + if (currentOwner == currentDeployer) { + const currentPendingOwner = await ankrCertificateTokenPriceOracle.callStatic.pendingOwner(); + console.log(`current pending owner ${currentPendingOwner}`); + if (currentPendingOwner != oraclesAdmin) { + tx = await ankrCertificateTokenPriceOracle._setPendingOwner(oraclesAdmin); + await tx.wait(); + console.log(`ankrCertificateTokenPriceOracle._setPendingOwner tx mined ${tx.hash}`); + } + } else if (currentOwner != oraclesAdmin) { + console.error(`unknown owner ${currentOwner}`); + } + } + + const blpo = (await ethers.getContractOrNull("BalancerLpTokenPriceOracle", deployer)) as SafeOwnableUpgradeable; + if (blpo) { + const currentOwner = await blpo.callStatic.owner(); + if (currentOwner == currentDeployer) { + const currentPendingOwner = await blpo.callStatic.pendingOwner(); + console.log(`current pending owner ${currentPendingOwner}`); + if (currentPendingOwner != oraclesAdmin) { + tx = await blpo._setPendingOwner(oraclesAdmin); + await tx.wait(); + console.log(`blpo._setPendingOwner tx mined ${tx.hash}`); + } + } else if (currentOwner != oraclesAdmin) { + console.error(`unknown owner ${currentOwner}`); + } + } + + const curveOracle = (await ethers.getContractOrNull( + "CurveLpTokenPriceOracleNoRegistry", + oraclesAdmin + )) as SafeOwnableUpgradeable; + if (curveOracle) { + const currentOwner = await curveOracle.callStatic.owner(); + if (currentOwner == currentDeployer) { + const currentPendingOwner = await curveOracle.callStatic.pendingOwner(); + console.log(`current pending owner ${currentPendingOwner}`); + if (currentPendingOwner != oraclesAdmin) { + tx = await curveOracle._setPendingOwner(oraclesAdmin); + await tx.wait(); + console.log(`curveOracle._setPendingOwner tx mined ${tx.hash}`); + } + } else if (currentOwner != oraclesAdmin) { + console.error(`unknown owner ${currentOwner}`); + } + } + + const curveV2Oracle = (await ethers.getContractOrNull( + "CurveV2LpTokenPriceOracleNoRegistry", + deployer + )) as SafeOwnableUpgradeable; + if (curveV2Oracle) { + const currentOwner = await curveV2Oracle.callStatic.owner(); + if (currentOwner == currentDeployer) { + const currentPendingOwner = await curveV2Oracle.callStatic.pendingOwner(); + console.log(`current pending owner ${currentPendingOwner}`); + if (currentPendingOwner != oraclesAdmin) { + tx = await curveV2Oracle._setPendingOwner(oraclesAdmin); + await tx.wait(); + console.log(`curveV2Oracle._setPendingOwner tx mined ${tx.hash}`); + } + } else if (currentOwner != oraclesAdmin) { + console.error(`unknown owner ${currentOwner}`); + } + } + + const diaPriceOracle = (await ethers.getContractOrNull("DiaPriceOracle", deployer)) as DiaPriceOracle; + if (diaPriceOracle) { + const currentAdmin = await diaPriceOracle.callStatic.admin(); + if (currentAdmin == oraclesAdmin) { + tx = await diaPriceOracle.changeAdmin(oraclesAdmin); + await tx.wait(); + console.log(`diaPriceOracle.changeAdmin tx mined ${tx.hash}`); + } else if (currentAdmin != oraclesAdmin) { + console.error(`unknown owner ${currentAdmin}`); + } + } + + const dspo = (await ethers.getContractOrNull("DiaStDotPriceOracle", deployer)) as SafeOwnableUpgradeable; + if (dspo) { + const currentOwner = await dspo.callStatic.owner(); + if (currentOwner == currentDeployer) { + const currentPendingOwner = await dspo.callStatic.pendingOwner(); + console.log(`current pending owner ${currentPendingOwner}`); + if (currentPendingOwner != oraclesAdmin) { + tx = await dspo._setPendingOwner(oraclesAdmin); + await tx.wait(); + console.log(`dspo._setPendingOwner tx mined ${tx.hash}`); + } + } else if (currentOwner != oraclesAdmin) { + console.error(`unknown owner ${currentOwner}`); + } + } + + const flux = (await ethers.getContractOrNull("FluxPriceOracle", deployer)) as SafeOwnableUpgradeable; + if (flux) { + const currentOwner = await flux.callStatic.owner(); + if (currentOwner == currentDeployer) { + const currentPendingOwner = await flux.callStatic.pendingOwner(); + console.log(`current pending owner ${currentPendingOwner}`); + if (currentPendingOwner != oraclesAdmin) { + tx = await flux._setPendingOwner(oraclesAdmin); + await tx.wait(); + console.log(`flux._setPendingOwner tx mined ${tx.hash}`); + } + } else if (currentOwner != oraclesAdmin) { + console.error(`unknown owner ${currentOwner}`); + } + } + + const nativeUsdPriceOracle = (await ethers.getContractOrNull( + "NativeUSDPriceOracle", + deployer + )) as SafeOwnableUpgradeable; + if (nativeUsdPriceOracle) { + const currentOwner = await nativeUsdPriceOracle.callStatic.owner(); + if (currentOwner == currentDeployer) { + const currentPendingOwner = await nativeUsdPriceOracle.callStatic.pendingOwner(); + console.log(`current pending owner ${currentPendingOwner}`); + if (currentPendingOwner != oraclesAdmin) { + tx = await nativeUsdPriceOracle._setPendingOwner(oraclesAdmin); + await tx.wait(); + console.log(`nativeUsdPriceOracle._setPendingOwner tx mined ${tx.hash}`); + } + } else if (currentOwner != oraclesAdmin) { + console.error(`unknown owner ${currentOwner}`); + } + } + + const stkBNBOracle = (await ethers.getContractOrNull("StkBNBPriceOracle", deployer)) as SafeOwnableUpgradeable; + if (stkBNBOracle) { + const currentOwner = await stkBNBOracle.callStatic.owner(); + if (currentOwner == currentDeployer) { + const currentPendingOwner = await stkBNBOracle.callStatic.pendingOwner(); + console.log(`current pending owner ${currentPendingOwner}`); + if (currentPendingOwner != oraclesAdmin) { + tx = await stkBNBOracle._setPendingOwner(oraclesAdmin); + await tx.wait(); + console.log(`stkBNBOracle._setPendingOwner tx mined ${tx.hash}`); + } + } else if (currentOwner != oraclesAdmin) { + console.error(`unknown owner ${currentOwner}`); + } + } + + const twapPriceOracleResolver = (await ethers.getContractOrNull( + "UniswapTwapPriceOracleV2Resolver", + deployer + )) as Ownable; + if (twapPriceOracleResolver) { + const currentOwner = await twapPriceOracleResolver.callStatic.owner(); + if (currentOwner == currentDeployer) { + tx = await twapPriceOracleResolver.transferOwnership(oraclesAdmin); + await tx.wait(); + console.log(`twapPriceOracleResolver._setPendingOwner tx mined ${tx.hash}`); + } else if (currentOwner != oraclesAdmin) { + console.error(`unknown owner ${currentOwner}`); + } + } + + const midasSafeLiquidator = (await ethers.getContractOrNull( + "MidasSafeLiquidator", + deployer + )) as SafeOwnableUpgradeable; + if (midasSafeLiquidator) { + const currentOwner = await midasSafeLiquidator.callStatic.owner(); + if (currentOwner == currentDeployer) { + const currentPendingOwner = await midasSafeLiquidator.callStatic.pendingOwner(); + console.log(`current pending owner ${currentPendingOwner}`); + if (currentPendingOwner != oraclesAdmin) { + tx = await midasSafeLiquidator._setPendingOwner(oraclesAdmin); + await tx.wait(); + console.log(`midasSafeLiquidator._setPendingOwner tx mined ${tx.hash}`); + } + } else if (currentOwner != oraclesAdmin) { + console.error(`unknown owner ${currentOwner}`); + } + } + }); diff --git a/packages/sdk/tasks/admin/revenue.ts b/packages/sdk/tasks/admin/revenue.ts index e6c1067a5..546357f7d 100644 --- a/packages/sdk/tasks/admin/revenue.ts +++ b/packages/sdk/tasks/admin/revenue.ts @@ -11,10 +11,10 @@ import { MidasERC4626 } from "../../typechain/MidasERC4626"; const LOG = process.env.LOG ? true : false; async function setUpFeeCalculation(hre: HardhatRuntimeEnvironment) { - const { deployer } = await hre.ethers.getNamedSigners(); + const { poolsSuperAdmin, oraclesAdmin } = await hre.ethers.getNamedSigners(); // @ts-ignore - const fpd = (await hre.ethers.getContract("FusePoolDirectory", deployer)) as FusePoolDirectory; - const mpo = await hre.ethers.getContract("MasterPriceOracle", deployer); + const fpd = (await hre.ethers.getContract("FusePoolDirectory", poolsSuperAdmin)) as FusePoolDirectory; + const mpo = await hre.ethers.getContract("MasterPriceOracle", oraclesAdmin); const [, pools] = await fpd.callStatic.getActivePools(); return { pools, fpd, mpo }; } @@ -43,7 +43,7 @@ async function createComptroller( export default task("revenue:admin:calculate", "Calculate the fees accrued from 4626 Performance Fees").setAction( async (taskArgs, hre) => { - const { deployer } = await hre.ethers.getNamedSigners(); + const { poolsSuperAdmin } = await hre.ethers.getNamedSigners(); // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); const sdk = await midasSdkModule.getOrCreateMidas(); @@ -60,7 +60,7 @@ export default task("revenue:admin:calculate", "Calculate the fees accrued from let poolFuseFeesTotal = BigNumber.from(0); for (const market of markets) { - const cToken = sdk.createCTokenWithExtensions(market, deployer); + const cToken = sdk.createCTokenWithExtensions(market); const underlying = await cToken.callStatic.underlying(); const underlyingPrice = await mpo.callStatic.getUnderlyingPrice(market); @@ -95,7 +95,6 @@ export default task("revenue:admin:calculate", "Calculate the fees accrued from task("revenue:4626:calculate", "Calculate the fees accrued from 4626 Performance Fees").setAction( async (taskArgs, hre) => { - const { deployer } = await hre.ethers.getNamedSigners(); // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); const sdk = await midasSdkModule.getOrCreateMidas(); @@ -112,7 +111,7 @@ task("revenue:4626:calculate", "Calculate the fees accrued from 4626 Performance let pluginFeesPool = BigNumber.from(0); for (const market of markets) { - const cToken = sdk.createCErc20PluginRewardsDelegate(market, deployer); + const cToken = sdk.createCErc20PluginRewardsDelegate(market); const underlying = await cToken.callStatic.underlying(); const underlyingDecimals = await cToken.callStatic.decimals(); @@ -163,7 +162,6 @@ task("revenue:4626:calculate", "Calculate the fees accrued from 4626 Performance task("revenue:flywheels:calculate", "Calculate the fees accrued from 4626 Performance Fees").setAction( async (taskArgs, hre) => { - const { deployer } = await hre.ethers.getNamedSigners(); // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); const sdk = await midasSdkModule.getOrCreateMidas(); @@ -180,7 +178,7 @@ task("revenue:flywheels:calculate", "Calculate the fees accrued from 4626 Perfor let flywheelFeesPool = BigNumber.from(0); for (const flywheel of flywheels) { - const flywheelContract = sdk.createMidasFlywheel(flywheel, deployer); + const flywheelContract = sdk.createMidasFlywheel(flywheel); try { await flywheelContract.callStatic.performanceFee(); @@ -194,7 +192,7 @@ task("revenue:flywheels:calculate", "Calculate the fees accrued from 4626 Perfor const performanceFeeRewardTokens = await flywheelContract.callStatic.rewardsAccrued( await flywheelContract.callStatic.feeRecipient() ); - const rewardToken = new Contract(await flywheelContract.callStatic.rewardToken(), ERC20Abi, deployer); + const rewardToken = new Contract(await flywheelContract.callStatic.rewardToken(), ERC20Abi); const rewardTokenPrice = await mpo.callStatic.price(rewardToken.address); const nativeFee = performanceFeeRewardTokens diff --git a/packages/sdk/tasks/flywheel/deploy.ts b/packages/sdk/tasks/flywheel/deploy.ts index 34c2b39fb..f1cd04fee 100644 --- a/packages/sdk/tasks/flywheel/deploy.ts +++ b/packages/sdk/tasks/flywheel/deploy.ts @@ -1,39 +1,42 @@ import { task, types } from "hardhat/config"; task("flywheel:deploy-static-rewards-fw", "Deploy static rewards flywheel for LM rewards") - .addParam("signer", "Named account to use fo tx", "deployer", types.string) .addParam("name", "String to append to the flywheel contract name", undefined, types.string) .addParam("rewardToken", "Reward token of flywheel", undefined, types.string) .addParam("strategies", "address of strategy for which to enable the flywheel", undefined, types.string) .addParam("pool", "comptroller to which to add the flywheel", undefined, types.string) - .setAction(async ({ signer, name, rewardToken, strategies, pool }, { ethers, deployments, run }) => { - const deployer = await ethers.getNamedSigner(signer); + .setAction(async ({ name, rewardToken, strategies, pool }, { ethers, deployments, run }) => { + const { extrasAdmin } = await ethers.getNamedSigners(); // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); - const sdk = await midasSdkModule.getOrCreateMidas(deployer); + const sdk = await midasSdkModule.getOrCreateMidas(extrasAdmin); - const flywheelBooster = await ethers.getContract("LooplessFlywheelBooster", deployer); + const flywheelBooster = await ethers.getContract("LooplessFlywheelBooster"); - console.log({ signer, name, rewardToken, strategies, pool }); + console.log({ extrasAdmin, name, rewardToken, strategies, pool }); const flywheel = await deployments.deploy(`MidasFlywheel_${name}`, { contract: "MidasFlywheel", - from: deployer.address, + from: extrasAdmin.address, log: true, proxy: { proxyContract: "OpenZeppelinTransparentProxy", execute: { init: { methodName: "initialize", - args: [rewardToken, ethers.constants.AddressZero, flywheelBooster.address, deployer.address], + args: [rewardToken, ethers.constants.AddressZero, flywheelBooster.address, extrasAdmin.address], }, }, - owner: deployer.address, + owner: extrasAdmin.address, }, waitConfirmations: 1, }); console.log(`Deployed flywheel: ${flywheel.address}`); - const rewards = await run("flywheel:deploy-static-rewards", { flywheel: flywheel.address, signer, name }); + const rewards = await run("flywheel:deploy-static-rewards", { + flywheel: flywheel.address, + signer: extrasAdmin.address, + name, + }); console.log(`Deployed rewards: ${rewards.address}`); const tx = await sdk.setFlywheelRewards(flywheel.address, rewards.address); await tx.wait(); @@ -50,25 +53,24 @@ task("flywheel:deploy-static-rewards-fw", "Deploy static rewards flywheel for LM }); task("flywheel:deploy-static-rewards", "Deploy static rewards flywheel for LM rewards") - .addParam("signer", "Named account to use fo tx", "deployer", types.string) .addParam("name", "String to append to the flywheel contract name", undefined, types.string) .addParam("flywheel", "flywheel to which to add the rewards contract", undefined, types.string) - .setAction(async ({ signer, name, flywheel }, { ethers, deployments }) => { - const deployer = await ethers.getNamedSigner(signer); + .setAction(async ({ name, flywheel }, { ethers, deployments }) => { + const { extrasAdmin } = await ethers.getNamedSigners(); const rewards = await deployments.deploy(`WithdrawableFlywheelStaticRewards_${name}`, { contract: "WithdrawableFlywheelStaticRewards", - from: deployer.address, + from: extrasAdmin.address, log: true, args: [ flywheel, // flywheel - deployer.address, // owner + extrasAdmin.address, // owner ethers.constants.AddressZero, // Authority ], waitConfirmations: 1, }); // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); - const sdk = await midasSdkModule.getOrCreateMidas(deployer); + const sdk = await midasSdkModule.getOrCreateMidas(extrasAdmin); const tx = await sdk.setFlywheelRewards(flywheel, rewards.address); await tx.wait(); @@ -76,11 +78,10 @@ task("flywheel:deploy-static-rewards", "Deploy static rewards flywheel for LM re }); task("flywheel:add-strategy-for-rewards", "Create pool if does not exist") - .addParam("signer", "Named account to use fo tx", "deployer", types.string) .addParam("flywheel", "address of flywheel", undefined, types.string) .addParam("strategy", "address of strategy", undefined, types.string) .setAction(async (taskArgs, hre) => { - const deployer = await hre.ethers.getNamedSigner(taskArgs.signer); + const { extrasAdmin } = await hre.ethers.getNamedSigners(); let flywheelAddress, strategyAddress; @@ -98,7 +99,7 @@ task("flywheel:add-strategy-for-rewards", "Create pool if does not exist") // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); - const sdk = await midasSdkModule.getOrCreateMidas(deployer); + const sdk = await midasSdkModule.getOrCreateMidas(extrasAdmin); const addTx = await sdk.addStrategyForRewardsToFlywheelCore(flywheelAddress, strategyAddress); const receipt = await addTx.wait(); @@ -106,11 +107,11 @@ task("flywheel:add-strategy-for-rewards", "Create pool if does not exist") }); task("flywheel:add-to-pool", "Create pool if does not exist") - .addParam("signer", "Named account to use fo tx", "deployer", types.string) .addParam("flywheel", "address of flywheel", undefined, types.string) .addParam("pool", "address of comptroller", undefined, types.string) .setAction(async (taskArgs, hre) => { - const deployer = await hre.ethers.getNamedSigner(taskArgs.signer); + const { extrasAdmin } = await hre.ethers.getNamedSigners(); + let flywheelAddress, poolAddress; try { @@ -127,7 +128,7 @@ task("flywheel:add-to-pool", "Create pool if does not exist") // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); - const sdk = await midasSdkModule.getOrCreateMidas(deployer); + const sdk = await midasSdkModule.getOrCreateMidas(extrasAdmin); const addTx = await sdk.addFlywheelCoreToComptroller(flywheelAddress, poolAddress); console.log({ addTx }); diff --git a/packages/sdk/tasks/flywheel/retire.ts b/packages/sdk/tasks/flywheel/retire.ts index 2e6b2d8d7..3c35929ef 100644 --- a/packages/sdk/tasks/flywheel/retire.ts +++ b/packages/sdk/tasks/flywheel/retire.ts @@ -4,16 +4,15 @@ import { ComptrollerFirstExtension } from "../../typechain/ComptrollerFirstExten import { MidasFlywheel } from "../../typechain/MidasFlywheel"; export default task("flyhwheel:nonaccruing", "Sets a flywheel as non-accruing in the comptroller") - .addParam("signer", "Named account to use fo tx", "deployer", types.string) .addParam("flywheel", "address of flywheel", undefined, types.string) .addParam("pool", "address of comptroller", undefined, types.string) .setAction(async (taskArgs, hre) => { - const deployer = await hre.ethers.getNamedSigner(taskArgs.signer); + const { extrasAdmin } = await hre.ethers.getNamedSigners(); const comptroller = (await hre.ethers.getContractAt( "ComptrollerFirstExtension", taskArgs.pool, - deployer + extrasAdmin )) as ComptrollerFirstExtension; const tx = await comptroller.addNonAccruingFlywheel(taskArgs.flywheel); @@ -22,22 +21,21 @@ export default task("flyhwheel:nonaccruing", "Sets a flywheel as non-accruing in }); task("flywheel:remove", "remove a rewards distributor from a pool") - .addParam("signer", "Named account to use fo tx", "deployer", types.string) .addParam("flywheel", "address of flywheel", undefined, types.string) .addParam("pool", "address of comptroller", undefined, types.string) .setAction(async (taskArgs, hre) => { - const deployer = await hre.ethers.getNamedSigner(taskArgs.signer); + const { poolsSuperAdmin, extrasAdmin } = await hre.ethers.getNamedSigners(); - // extract the leftover rewards to the deployer - const flywheel = (await hre.ethers.getContractAt("MidasFlywheel", taskArgs.flywheel, deployer)) as MidasFlywheel; - let tx = await flywheel.setFlywheelRewards(deployer.address); + // extract the leftover rewards to the extrasAdmin + const flywheel = (await hre.ethers.getContractAt("MidasFlywheel", taskArgs.flywheel, extrasAdmin)) as MidasFlywheel; + let tx = await flywheel.setFlywheelRewards(extrasAdmin.address); await tx.wait(); console.log("setFlywheelRewards: ", tx.hash); const asComptrollerExtension = (await hre.ethers.getContractAt( "ComptrollerFirstExtension", taskArgs.pool, - deployer + poolsSuperAdmin )) as ComptrollerFirstExtension; tx = await asComptrollerExtension._removeFlywheel(taskArgs.flywheel); diff --git a/packages/sdk/tasks/irm/admin.ts b/packages/sdk/tasks/irm/admin.ts index f767ffc48..10ecd127e 100644 --- a/packages/sdk/tasks/irm/admin.ts +++ b/packages/sdk/tasks/irm/admin.ts @@ -6,7 +6,7 @@ export default task("irm:set", "Set new IRM to ctoken") .addParam("ctokens", "cToken for which to set the IRM", undefined, types.string) .addParam("irmAddress", "Irm address to use ", undefined, types.string) .setAction(async ({ ctokens: _ctokens, irmAddress: _irmAddress }, { ethers }) => { - const { deployer } = await ethers.getNamedSigners(); + const { poolsSuperAdmin } = await ethers.getNamedSigners(); // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); @@ -15,7 +15,7 @@ export default task("irm:set", "Set new IRM to ctoken") const ctokens = _ctokens.split(","); for (const cTokenAddress of ctokens) { - const cToken = sdk.createCTokenWithExtensions(cTokenAddress, deployer); + const cToken = sdk.createCTokenWithExtensions(cTokenAddress, poolsSuperAdmin); const tx = await cToken._setInterestRateModel(_irmAddress); await tx.wait(); console.log(`Set IRM of ${await cToken.callStatic.underlying()} to ${_irmAddress}`); diff --git a/packages/sdk/tasks/irm/jrm.ts b/packages/sdk/tasks/irm/jrm.ts index 88680d85f..58082fa06 100644 --- a/packages/sdk/tasks/irm/jrm.ts +++ b/packages/sdk/tasks/irm/jrm.ts @@ -6,7 +6,7 @@ export default task("irm:deploy:custom-jrm", "deploys custom JRM") .addParam("postfix", "Postfix to use for the deployment name", undefined, types.string) .addParam("args", "args to use", undefined, types.string) .setAction(async ({ irm: _irm, args: _args, postfix: _postfix }, { deployments, ethers }) => { - const { deployer } = await ethers.getNamedSigners(); + const { upgradesAdmin } = await ethers.getNamedSigners(); // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); @@ -54,7 +54,7 @@ export default task("irm:deploy:custom-jrm", "deploys custom JRM") const deployment = await deployments.deploy(_irm + "_" + _postfix, { contract: _irm, - from: deployer.address, + from: upgradesAdmin, args: args, log: true, }); @@ -68,12 +68,12 @@ task("irm:edit:adjustable-jrm-params", "Edit adjustable JRM parameters") .addParam("irmAddress", "IRM address to adjust", undefined, types.string) .addParam("args", "args to use", undefined, types.string) .setAction(async ({ irmAddress: _irm, args: _args }, { ethers }) => { - const { deployer } = await ethers.getNamedSigners(); + const { poolsSuperAdmin } = await ethers.getNamedSigners(); // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); const sdk = await midasSdkModule.getOrCreateMidas(); - const irm = await ethers.getContractAt("AdjustableJumpRateModel", _irm, deployer); + const irm = await ethers.getContractAt("AdjustableJumpRateModel", _irm, poolsSuperAdmin); let promises: Array>; let blocksPerYear; diff --git a/packages/sdk/tasks/one-time/liquidate-take-bad-debt.ts b/packages/sdk/tasks/one-time/liquidate-take-bad-debt.ts index 2b351a7c4..e8ec97873 100644 --- a/packages/sdk/tasks/one-time/liquidate-take-bad-debt.ts +++ b/packages/sdk/tasks/one-time/liquidate-take-bad-debt.ts @@ -20,7 +20,7 @@ task("liquidate:take-bad-debt", "liquidate a debt position by borrowing the same { debtMarket, collateralMarket, stableCollateralMarket, repayAmount, borrower }, { deployments, ethers, getChainId } ) => { - const deployer = await ethers.getNamedSigner("deployer"); + const { upgradesAdmin, liquidator, oraclesAdmin } = await ethers.getNamedSigners(); const chainId = parseInt(await getChainId()); @@ -31,13 +31,13 @@ task("liquidate:take-bad-debt", "liquidate a debt position by borrowing the same console.log("chainDeployParams: ", chainDeployParams); const msl = await deployments.deploy("MidasSafeLiquidator", { - from: deployer.address, + from: upgradesAdmin.address, contract: "MidasSafeLiquidator", log: true, waitConfirmations: 1, proxy: { proxyContract: "OpenZeppelinTransparentProxy", - owner: deployer.address, + owner: upgradesAdmin.address, execute: { init: { methodName: "initialize", @@ -57,12 +57,12 @@ task("liquidate:take-bad-debt", "liquidate a debt position by borrowing the same if (msl.transactionHash) await ethers.provider.waitForTransaction(msl.transactionHash); console.log("MidasSafeLiquidator: ", msl.address); - const midasSafeLiquidator = (await ethers.getContract("MidasSafeLiquidator", deployer)) as MidasSafeLiquidator; + const midasSafeLiquidator = (await ethers.getContract("MidasSafeLiquidator", liquidator)) as MidasSafeLiquidator; const fslOwner = await midasSafeLiquidator.callStatic.owner(); console.log(`MidasSafeLiquidator owner is ${fslOwner}`); const univ2Liquidator = await deployments.deploy("UniswapV2Liquidator", { - from: deployer.address, + from: upgradesAdmin.address, log: true, args: [], waitConfirmations: 1, @@ -71,7 +71,7 @@ task("liquidate:take-bad-debt", "liquidate a debt position by borrowing the same if (univ2Liquidator.transactionHash) await ethers.provider.waitForTransaction(univ2Liquidator.transactionHash); console.log("UniswapV2Liquidator: ", univ2Liquidator.address); - const redemptionStrategy = await ethers.getContractAt("UniswapV2Liquidator", univ2Liquidator.address, deployer); + const redemptionStrategy = await ethers.getContractAt("UniswapV2Liquidator", univ2Liquidator.address); const whitelisted = await midasSafeLiquidator.callStatic.redemptionStrategiesWhitelist( redemptionStrategy.address @@ -89,7 +89,7 @@ task("liquidate:take-bad-debt", "liquidate a debt position by borrowing the same const repayAmountBN = BigNumber.from(repayAmount); // estimate funding amount - const mpo = (await ethers.getContract("MasterPriceOracle", deployer)) as MasterPriceOracle; + const mpo = (await ethers.getContract("MasterPriceOracle", oraclesAdmin)) as MasterPriceOracle; const debtAssetPrice = await mpo.getUnderlyingPrice(debtMarket); const stableCollateralAssetPrice = await mpo.getUnderlyingPrice(stableCollateralMarket); @@ -103,29 +103,22 @@ task("liquidate:take-bad-debt", "liquidate a debt position by borrowing the same const stableCollateralCTokenExtension = (await ethers.getContractAt( "CTokenFirstExtension", - stableCollateralMarket, - deployer + stableCollateralMarket )) as CTokenFirstExtension; - const collateralCToken = (await ethers.getContractAt("CErc20", collateralMarket, deployer)) as CErc20; + const collateralCToken = (await ethers.getContractAt("CErc20", collateralMarket)) as CErc20; - const stableCollateralCToken = (await ethers.getContractAt("CErc20", stableCollateralMarket, deployer)) as CErc20; + const stableCollateralCToken = (await ethers.getContractAt("CErc20", stableCollateralMarket)) as CErc20; const stableCollateralAssetAddress = await stableCollateralCToken.callStatic.underlying(); - const stableCollateralAsset = (await ethers.getContractAt( - "ERC20", - stableCollateralAssetAddress, - deployer - )) as ERC20; - const currentStableCollateral = await stableCollateralCTokenExtension.callStatic.balanceOfUnderlying( midasSafeLiquidator.address ); if (currentStableCollateral < additionalCollateralRequired) { - const wNative = (await ethers.getContractAt("WETH", stableCollateralAsset.address, deployer)) as WETH; + const wNative = (await ethers.getContractAt("WETH", stableCollateralAssetAddress, liquidator)) as WETH; - const currentWNativeBalance = await wNative.callStatic.balanceOf(deployer.address); + const currentWNativeBalance = await wNative.callStatic.balanceOf(liquidator.address); const diffNeeded = additionalCollateralRequired.sub(currentStableCollateral); @@ -159,8 +152,7 @@ task("liquidate:take-bad-debt", "liquidate a debt position by borrowing the same const factory = (await ethers.getContractAt( "IUniswapV2Factory", - chainDeployParams.uniswap.uniswapV2FactoryAddress, - deployer + chainDeployParams.uniswap.uniswapV2FactoryAddress )) as IUniswapV2Factory; const flashSwapPair = await factory.callStatic.getPair(stableCollateralAssetAddress, usdc); diff --git a/packages/sdk/tasks/one-time/loopless-booster.ts b/packages/sdk/tasks/one-time/loopless-booster.ts index b87834f88..4e5520fa5 100644 --- a/packages/sdk/tasks/one-time/loopless-booster.ts +++ b/packages/sdk/tasks/one-time/loopless-booster.ts @@ -9,13 +9,13 @@ import { MidasFlywheelCore } from "../../typechain/MidasFlywheelCore"; task("loopless-booster", "deploy and a loopless booster for a flywheel") .addParam("flywheelAddress", "Address of the flywheel to set the booster to", undefined, types.string) .setAction(async ({ flywheelAddress }, { ethers, deployments, getChainId }) => { - const deployer = await ethers.getNamedSigner("deployer"); + const { upgradesAdmin, extrasAdmin } = await ethers.getNamedSigners(); const chainid = await getChainId(); if (flywheelAddress == "0xUseThisToVerify") { const flywheel = (await ethers.getContractAt( "MidasFlywheelCore", flywheelAddress, - deployer + extrasAdmin )) as MidasFlywheelCore; const currentBoosterAddress = await flywheel.callStatic.flywheelBooster(); let oldBooster; @@ -26,7 +26,7 @@ task("loopless-booster", "deploy and a loopless booster for a flywheel") } if (currentBoosterAddress == oldBooster) { const booster = await deployments.deploy("LooplessFlywheelBooster", { - from: deployer.address, + from: upgradesAdmin.address, log: true, args: [], }); @@ -49,21 +49,23 @@ task("replace-flywheel-with-upgradable", "").setAction(async ({}, { ethers, depl const fxcDOTMarketAddress = "0xa9736bA05de1213145F688e4619E5A7e0dcf4C72"; //const fwstDOTMarketAddress = "0xb3D83F2CAb787adcB99d4c768f1Eb42c8734b563"; - const deployer = await ethers.getNamedSigner("deployer"); + const { upgradesAdmin, poolsSuperAdmin, extrasAdmin } = await ethers.getNamedSigners(); + + // const deployer = await ethers.getNamedSigner("deployer"); const chainid = await getChainId(); if (chainid == "1284") { const asComptrollerExtension = (await ethers.getContractAt( "ComptrollerFirstExtension", poolAddress, - deployer + poolsSuperAdmin )) as ComptrollerFirstExtension; - const asComptroller = (await ethers.getContractAt("Comptroller", poolAddress, deployer)) as Comptroller; + const asComptroller = (await ethers.getContractAt("Comptroller", poolAddress, poolsSuperAdmin)) as Comptroller; const brokenFlywheel = (await ethers.getContractAt( "MidasFlywheelCore", brokenFlywheelAddress, - deployer + extrasAdmin )) as MidasFlywheelCore; const rewardToken = await brokenFlywheel.callStatic.rewardToken(); @@ -73,7 +75,7 @@ task("replace-flywheel-with-upgradable", "").setAction(async ({}, { ethers, depl const oldStaticRewards = (await ethers.getContractAt( "FlywheelStaticRewards", oldStaticRewardsAddress, - deployer + extrasAdmin )) as FlywheelStaticRewards; let tx = await oldStaticRewards.setRewardsInfo(fxcDOTMarketAddress, { @@ -92,17 +94,17 @@ task("replace-flywheel-with-upgradable", "").setAction(async ({}, { ethers, depl const replacingFlywheel = await deployments.deploy("MidasFlywheel", { contract: "MidasFlywheel", - from: deployer.address, + from: upgradesAdmin.address, log: true, proxy: { proxyContract: "OpenZeppelinTransparentProxy", execute: { init: { methodName: "initialize", - args: [rewardToken, constants.AddressZero, flywheelBooster, deployer.address], + args: [rewardToken, constants.AddressZero, flywheelBooster, extrasAdmin.address], }, }, - owner: deployer.address, + owner: upgradesAdmin.address, }, waitConfirmations: 1, }); @@ -110,11 +112,11 @@ task("replace-flywheel-with-upgradable", "").setAction(async ({}, { ethers, depl // the replacing rewards contract is needed because on creation it makes an infinite approve to the flywheel const replacingRewards = await deployments.deploy("FlywheelStaticRewards", { contract: "FlywheelStaticRewards", - from: deployer.address, + from: upgradesAdmin.address, log: true, args: [ replacingFlywheel.address, // flywheel - deployer.address, // owner + extrasAdmin.address, // owner constants.AddressZero, // Authority ], waitConfirmations: 1, @@ -141,7 +143,7 @@ task("replace-flywheel-with-upgradable", "").setAction(async ({}, { ethers, depl const newFlywheel = (await ethers.getContractAt( "MidasFlywheelCore", replacingFlywheel.address, - deployer + extrasAdmin )) as MidasFlywheelCore; // the flywheel was initialized with address(0) for the rewards, so set it up diff --git a/packages/sdk/tasks/oracle/add-apeswap-oracle.ts b/packages/sdk/tasks/oracle/add-apeswap-oracle.ts index dcc3219a8..fd97fd3a9 100644 --- a/packages/sdk/tasks/oracle/add-apeswap-oracle.ts +++ b/packages/sdk/tasks/oracle/add-apeswap-oracle.ts @@ -8,13 +8,13 @@ const wtoken = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"; const busd = "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56"; task("oracle:deploy-apeswap-oracle").setAction(async (taskArgs, hre) => { - const { deployer } = await hre.ethers.getNamedSigners(); + const { oraclesAdmin } = await hre.ethers.getNamedSigners(); - const mpo = await hre.ethers.getContract("MasterPriceOracle", deployer); + const mpo = await hre.ethers.getContract("MasterPriceOracle", oraclesAdmin); const uniTwapOracleFactory = (await hre.ethers.getContract( "UniswapTwapPriceOracleV2Factory", - deployer + oraclesAdmin )) as UniswapTwapPriceOracleV2Factory; let tx = await uniTwapOracleFactory.deploy(apeSwapFactory, wtoken); diff --git a/packages/sdk/tasks/oracle/add-chainlink-feeds.ts b/packages/sdk/tasks/oracle/add-chainlink-feeds.ts index c68dd8182..808aa52d6 100644 --- a/packages/sdk/tasks/oracle/add-chainlink-feeds.ts +++ b/packages/sdk/tasks/oracle/add-chainlink-feeds.ts @@ -13,16 +13,16 @@ export default task("add-chainlink-feeds", "Add Chainlink Feeds") console.log("baseCurrency: ", baseCurrency); - const { deployer } = await getNamedAccounts(); + const { oraclesAdmin } = await getNamedAccounts(); - const cpo = await ethers.getContract("ChainlinkPriceOracleV2", deployer); + const cpo = await ethers.getContract("ChainlinkPriceOracleV2", oraclesAdmin); let tx = await cpo.setPriceFeeds(underlyings, feeds, baseCurrency); console.log("setPriceFeeds tx: ", tx); let receipt = await tx.wait(); console.log("setPriceFeeds tx mined: ", receipt.transactionHash); - const mpo = await ethers.getContract("MasterPriceOracle", deployer); + const mpo = await ethers.getContract("MasterPriceOracle", oraclesAdmin); tx = await mpo.add(underlyings, Array(underlyings.length).fill(cpo.address)); console.log("add tx: ", tx); diff --git a/packages/sdk/tasks/oracle/add-tokens.ts b/packages/sdk/tasks/oracle/add-tokens.ts index b1822ba01..efcbe8b43 100644 --- a/packages/sdk/tasks/oracle/add-tokens.ts +++ b/packages/sdk/tasks/oracle/add-tokens.ts @@ -4,12 +4,12 @@ task("oracle:add-tokens", "Initialize MasterPriceOracle with underlying oracle f .addOptionalParam("underlyings", "Token for which to set the price", undefined, types.string) .addOptionalParam("oracles", "Token address for which to set the price", undefined, types.string) .setAction(async ({ underlyings: _underlyings, oracles: _oracles }, { ethers }) => { - const { deployer } = await ethers.getNamedSigners(); + const { oraclesAdmin } = await ethers.getNamedSigners(); // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); const sdk = await midasSdkModule.getOrCreateMidas(); - const mpo = sdk.createMasterPriceOracle(deployer); + const mpo = sdk.createMasterPriceOracle(oraclesAdmin); const underlyingTokens = _underlyings.split(","); const underlyingOracleInput = _oracles.split(","); diff --git a/packages/sdk/tasks/oracle/flux-feed.ts b/packages/sdk/tasks/oracle/flux-feed.ts index dadec8844..7c103c5ef 100644 --- a/packages/sdk/tasks/oracle/flux-feed.ts +++ b/packages/sdk/tasks/oracle/flux-feed.ts @@ -2,9 +2,6 @@ import { BigNumber, utils } from "ethers"; import { task } from "hardhat/config"; export default task("get-flux-price", "Get Flux price").setAction(async ({}, { ethers }) => { - const { deployer } = await ethers.getNamedSigners(); - console.log("deployer: ", deployer.address); - const iface = new utils.Interface(["function latestAnswer() external view returns (int256)"]); const data = iface.encodeFunctionData("latestAnswer", []); console.log("data: ", data); diff --git a/packages/sdk/tasks/oracle/get-price.ts b/packages/sdk/tasks/oracle/get-price.ts index 8143bd8c7..77bfecd65 100644 --- a/packages/sdk/tasks/oracle/get-price.ts +++ b/packages/sdk/tasks/oracle/get-price.ts @@ -4,21 +4,20 @@ task("oracle:get-price", "Get price of token") .addOptionalParam("address", "Token address for which to get the price", undefined, types.string) .addOptionalParam("ctoken", "CToken address for which to get the price", undefined, types.string) .setAction(async ({ ctoken: _ctoken, address: _address }, { ethers }) => { - const { deployer } = await ethers.getNamedSigners(); // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); const sdk = await midasSdkModule.getOrCreateMidas(); - const mpo = sdk.createMasterPriceOracle(deployer); + const mpo = sdk.createMasterPriceOracle(); console.log("oracle: ", mpo.address); if (_address) { - const tokenPriceMPO = await mpo.price(_address); + const tokenPriceMPO = await mpo.callStatic.price(_address); console.log("underlying oracle address: ", await mpo.callStatic.oracles(_address)); console.log(`mpo.price(address): ${tokenPriceMPO.toString()}, i.e.: ${ethers.utils.formatEther(tokenPriceMPO)}`); } if (_ctoken) { - const tokenPriceMPO = await mpo.getUnderlyingPrice(_ctoken); + const tokenPriceMPO = await mpo.callStatic.getUnderlyingPrice(_ctoken); console.log( `mpo.getUnderlyingPrice(cToken): ${tokenPriceMPO.toString()}, i.e.: ${ethers.utils.formatEther(tokenPriceMPO)}` ); diff --git a/packages/sdk/tasks/oracle/increase-cardinality.ts b/packages/sdk/tasks/oracle/increase-cardinality.ts index d3ec2477c..323703a48 100644 --- a/packages/sdk/tasks/oracle/increase-cardinality.ts +++ b/packages/sdk/tasks/oracle/increase-cardinality.ts @@ -5,14 +5,15 @@ import { IUniswapV3Pool__factory } from "../../typechain/factories/IUniswapV3Poo task("oracle:increase-cardinality", "Increase cardinality for pool") .addParam("address") .setAction(async (taskArgs, hre) => { - const { deployer } = await hre.ethers.getNamedSigners(); + const { oraclesAdmin } = await hre.ethers.getNamedSigners(); const address = taskArgs.address; - const poolContract = new hre.ethers.Contract(address, IUniswapV3Pool__factory.abi, deployer); - await poolContract.increaseObservationCardinalityNext(10, { + const poolContract = new hre.ethers.Contract(address, IUniswapV3Pool__factory.abi, oraclesAdmin); + const tx = await poolContract.increaseObservationCardinalityNext(10, { gasLimit: 1000000, }); + await tx.wait(); console.log(`Cardinality increased for pool ${address}`); }); diff --git a/packages/sdk/tasks/oracle/set-price.ts b/packages/sdk/tasks/oracle/set-price.ts index 4cd926308..143acf4bd 100644 --- a/packages/sdk/tasks/oracle/set-price.ts +++ b/packages/sdk/tasks/oracle/set-price.ts @@ -5,7 +5,7 @@ export default task("oracle:set-price", "Set price of token") .addOptionalParam("address", "Token address for which to set the price", undefined, types.string) .addParam("price", "Price to set in the SPO for the token") .setAction(async ({ token: _token, address: _address, price: _price }, { getNamedAccounts, ethers }) => { - const { deployer } = await ethers.getNamedSigners(); + const { oraclesAdmin } = await ethers.getNamedSigners(); // @ts-ignore const oracleModule = await import("../../tests/utils/oracle"); @@ -13,7 +13,7 @@ export default task("oracle:set-price", "Set price of token") const underlyingOracle = await ethers.getContractAt( "SimplePriceOracle", await oracle.callStatic.oracles(tokenAddress), - deployer + oraclesAdmin ); const tx = await underlyingOracle.setDirectPrice(tokenAddress, ethers.utils.parseEther(_price)); await tx.wait(); diff --git a/packages/sdk/tasks/oracle/update-twap.ts b/packages/sdk/tasks/oracle/update-twap.ts index 8e4e415e6..d2e7dd6d7 100644 --- a/packages/sdk/tasks/oracle/update-twap.ts +++ b/packages/sdk/tasks/oracle/update-twap.ts @@ -3,7 +3,7 @@ import { task, types } from "hardhat/config"; task("oracle:update-twap", "Call update on twap oracle to update the last price observation") .addParam("pair", "pair address for which to run the update", undefined, types.string) .setAction(async ({ pair: _pair }, { ethers }) => { - const { deployer } = await ethers.getNamedSigners(); + const { oraclesAdmin } = await ethers.getNamedSigners(); // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); @@ -12,7 +12,7 @@ task("oracle:update-twap", "Call update on twap oracle to update the last price const uniswapTwapRoot = await ethers.getContractAt( "UniswapTwapPriceOracleV2Root", sdk.chainDeployment.UniswapTwapPriceOracleV2Root.address, - deployer + oraclesAdmin ); const tx = await uniswapTwapRoot["update(address)"](_pair); @@ -22,7 +22,7 @@ task("oracle:update-twap", "Call update on twap oracle to update the last price task("oracle:remove-twap-pair", "Call update on twap oracle to update the last price observation") .addParam("pairIndex", "pair address for which to run the update", undefined, types.string) .setAction(async ({ pairIndex: _pairIndex }, { ethers }) => { - const { deployer } = await ethers.getNamedSigners(); + const { oraclesAdmin } = await ethers.getNamedSigners(); // @ts-ignore const midasSdkModule = await import("../../tests/utils/midasSdk"); @@ -31,7 +31,7 @@ task("oracle:remove-twap-pair", "Call update on twap oracle to update the last p const uniswapTwapRoot = await ethers.getContractAt( "UniswapTwapPriceOracleV2Resolver", sdk.chainDeployment.UniswapTwapPriceOracleV2Resolver.address, - deployer + oraclesAdmin ); const existingPairs = await uniswapTwapRoot.callStatic.getPairs(); console.log("Existing Pairs", existingPairs); diff --git a/packages/sdk/tasks/plugin/replace.ts b/packages/sdk/tasks/plugin/replace.ts index 73ca96c7a..303990699 100644 --- a/packages/sdk/tasks/plugin/replace.ts +++ b/packages/sdk/tasks/plugin/replace.ts @@ -5,13 +5,14 @@ import { task, types } from "hardhat/config"; import { CErc20PluginRewardsDelegate } from "../../typechain/CErc20PluginRewardsDelegate"; import { Comptroller } from "../../typechain/Comptroller"; import { FuseFeeDistributor } from "../../typechain/FuseFeeDistributor"; +import { SafeOwnableUpgradeable } from "../../typechain/SafeOwnableUpgradeable"; task("plugins:deploy:upgradable", "Deploys the upgradable plugins from a config list").setAction( async ({}, { ethers, getChainId, deployments }) => { - const deployer = await ethers.getNamedSigner("deployer"); + const { upgradesAdmin, poolsSuperAdmin, extrasAdmin } = await ethers.getNamedSigners(); - console.log({ deployer: deployer.address }); - const ffd = (await ethers.getContract("FuseFeeDistributor", deployer)) as FuseFeeDistributor; + console.log({ deployer: poolsSuperAdmin.address }); + const ffd = (await ethers.getContract("FuseFeeDistributor", poolsSuperAdmin)) as FuseFeeDistributor; const chainid = parseInt(await getChainId()); const pluginConfigs: DeployedPlugins = chainIdToConfig[chainid].deployedPlugins; @@ -49,7 +50,7 @@ task("plugins:deploy:upgradable", "Deploys the upgradable plugins from a config const artifact = await deployments.getArtifact(conf.strategy); const deployment = await deployments.deploy(contractId, { contract: artifact, - from: deployer.address, + from: upgradesAdmin.address, proxy: { proxyContract: "OpenZeppelinTransparentProxy", execute: { @@ -58,7 +59,7 @@ task("plugins:deploy:upgradable", "Deploys the upgradable plugins from a config args: deployArgs, }, }, - owner: deployer.address, + owner: upgradesAdmin.address, }, log: true, }); @@ -66,6 +67,16 @@ task("plugins:deploy:upgradable", "Deploys the upgradable plugins from a config if (deployment.transactionHash) await ethers.provider.waitForTransaction(deployment.transactionHash); console.log("ERC4626 Strategy: ", deployment.address); + let asOwnable = (await ethers.getContract(contractId, upgradesAdmin)) as SafeOwnableUpgradeable; + let tx = await asOwnable._setPendingOwner(extrasAdmin.address); + await tx.wait(); + console.log(`transferring the admin to ${extrasAdmin.address} with tx ${tx.hash}`); + + asOwnable = (await ethers.getContract(contractId, extrasAdmin)) as SafeOwnableUpgradeable; + tx = await asOwnable._acceptOwner(); + await tx.wait(); + console.log(`accepted to be the owner ${extrasAdmin.address} with tx ${tx.hash}`); + newImplementations.push(deployment.address); arrayOfTrue.push(true); } @@ -81,7 +92,7 @@ task("plugins:deploy:upgradable", "Deploys the upgradable plugins from a config const market = (await ethers.getContractAt( "CErc20PluginRewardsDelegate", conf.market, - deployer + poolsSuperAdmin )) as CErc20PluginRewardsDelegate; const comptrollerAddress = await market.callStatic.comptroller(); @@ -89,11 +100,11 @@ task("plugins:deploy:upgradable", "Deploys the upgradable plugins from a config const comptroller = (await ethers.getContractAt( "Comptroller.sol:Comptroller", comptrollerAddress, - deployer + poolsSuperAdmin )) as Comptroller; const admin = await comptroller.callStatic.admin(); - if (admin == deployer.address) { + if (admin == poolsSuperAdmin.address) { const currentPluginAddress = await market.callStatic.plugin(); const contractId = `${conf.strategy}_${conf.market}`; const newPlugin = await ethers.getContract(contractId); @@ -106,7 +117,7 @@ task("plugins:deploy:upgradable", "Deploys the upgradable plugins from a config console.log("_updatePlugin: ", tx.hash); } } else { - console.log(`market poll has a different admin ${admin}`); + console.log(`market and pool have different admins ${admin}`); } } } @@ -116,12 +127,12 @@ task("plugins:replace", "Replaces an old plugin contract with a new one") .addParam("market", "The address of the market", undefined, types.string) .addParam("newPlugin", "The address of the new plugin", undefined, types.string) .setAction(async ({ market: marketAddress, newPlugin: newPluginAddress }, { ethers }) => { - const deployer = await ethers.getNamedSigner("deployer"); + const { poolsSuperAdmin } = await ethers.getNamedSigners(); const market = (await ethers.getContractAt( "CErc20PluginRewardsDelegate", marketAddress, - deployer + poolsSuperAdmin )) as CErc20PluginRewardsDelegate; try { const currentPluginAddress = await market.callStatic.plugin(); diff --git a/packages/sdk/tasks/pool/deprecate.ts b/packages/sdk/tasks/pool/deprecate.ts index 78f8610ed..862a3c7b1 100644 --- a/packages/sdk/tasks/pool/deprecate.ts +++ b/packages/sdk/tasks/pool/deprecate.ts @@ -6,9 +6,9 @@ export default task("pool:deprecate", "Whitelists a new comptroller implementati .addOptionalParam("index", "Pool index for which to deprecate", undefined, types.string) .addOptionalParam("comptroller", "Pool address for which to deprecate", undefined, types.string) .setAction(async (taskArgs, { ethers }) => { - const deployer = await ethers.getNamedSigner("deployer"); + const { poolsSuperAdmin } = await ethers.getNamedSigners(); - const fusePoolDirectory = (await ethers.getContract("FusePoolDirectory", deployer)) as FusePoolDirectory; + const fusePoolDirectory = (await ethers.getContract("FusePoolDirectory", poolsSuperAdmin)) as FusePoolDirectory; if (taskArgs.index) { const tx = await fusePoolDirectory["_deprecatePool(uint256)"](taskArgs.index); await tx.wait(); diff --git a/packages/sdk/tasks/pool/get-pool-data.ts b/packages/sdk/tasks/pool/get-pool-data.ts index e73252bfc..33ecabec7 100644 --- a/packages/sdk/tasks/pool/get-pool-data.ts +++ b/packages/sdk/tasks/pool/get-pool-data.ts @@ -121,10 +121,8 @@ task("get-position-ratio", "Get unhealthy po data") return ratio; }); -task("get-public-pools", "Get public pools").setAction(async ({}, { ethers, getNamedAccounts }) => { - const { deployer } = await getNamedAccounts(); - - const fpd = await ethers.getContract("FusePoolLens", deployer); +task("get-public-pools", "Get public pools").setAction(async ({}, { ethers }) => { + const fpd = await ethers.getContract("FusePoolLens"); const pools = await fpd.callStatic.getPublicPoolsWithData(); console.log("pools: ", pools); }); diff --git a/packages/sdk/tasks/pool/upgrade.ts b/packages/sdk/tasks/pool/upgrade.ts index 79b795ca0..e3cbbe35b 100644 --- a/packages/sdk/tasks/pool/upgrade.ts +++ b/packages/sdk/tasks/pool/upgrade.ts @@ -14,13 +14,14 @@ export default task("comptroller:implementation:whitelist", "Whitelists a new co .addFlag("setLatest", "Set the new implementation as the latest for the autoimplementations") .setAction(async ({ oldImplementation, newImplementation, setLatest }, { ethers }) => { let tx; - const deployer = await ethers.getNamedSigner("deployer"); + const { poolsSuperAdmin } = await ethers.getNamedSigners(); + if (!newImplementation) { const currentLatestComptroller = await ethers.getContract("Comptroller"); newImplementation = currentLatestComptroller.address; } - const fuseFeeDistributor = (await ethers.getContract("FuseFeeDistributor", deployer)) as FuseFeeDistributor; + const fuseFeeDistributor = (await ethers.getContract("FuseFeeDistributor", poolsSuperAdmin)) as FuseFeeDistributor; const whitelisted = await fuseFeeDistributor.callStatic.comptrollerImplementationWhitelist( oldImplementation, newImplementation @@ -63,20 +64,20 @@ export default task("comptroller:implementation:whitelist", "Whitelists a new co task("pools:all:upgrade", "Upgrades all pools comptroller implementations whose autoimplementatoins are on").setAction( async ({}, { ethers }) => { - const deployer = await ethers.getNamedSigner("deployer"); + const { poolsSuperAdmin } = await ethers.getNamedSigners(); - const fusePoolDirectory = (await ethers.getContract("FusePoolDirectory", deployer)) as FusePoolDirectory; - const fuseFeeDistributor = (await ethers.getContract("FuseFeeDistributor", deployer)) as FuseFeeDistributor; + const fusePoolDirectory = (await ethers.getContract("FusePoolDirectory", poolsSuperAdmin)) as FusePoolDirectory; + const fuseFeeDistributor = (await ethers.getContract("FuseFeeDistributor", poolsSuperAdmin)) as FuseFeeDistributor; const [, pools] = await fusePoolDirectory.callStatic.getActivePools(); for (let i = 0; i < pools.length; i++) { const pool = pools[i]; console.log("pool", { name: pool.name, address: pool.comptroller }); - const unitroller = (await ethers.getContractAt("Unitroller", pool.comptroller, deployer)) as Unitroller; + const unitroller = (await ethers.getContractAt("Unitroller", pool.comptroller, poolsSuperAdmin)) as Unitroller; const asComptroller = (await ethers.getContractAt( "Comptroller.sol:Comptroller", pool.comptroller, - deployer + poolsSuperAdmin )) as Comptroller; const admin = await unitroller.callStatic.admin(); @@ -92,7 +93,7 @@ task("pools:all:upgrade", "Upgrades all pools comptroller implementations whose const comptrollerAsExtension = (await ethers.getContractAt( "ComptrollerFirstExtension", pool.comptroller, - deployer + poolsSuperAdmin )) as ComptrollerFirstExtension; const markets = await comptrollerAsExtension.callStatic.getAllMarkets(); for (let j = 0; j < markets.length; j++) { @@ -166,11 +167,10 @@ task("pools:all:upgrade", "Upgrades all pools comptroller implementations whose task("pools:all:autoimpl", "Toggle the autoimplementations flag of all managed pools") .addParam("enable", "If autoimplementations should be on or off", true, types.boolean) - .addOptionalParam("admin", "Named account that is an admin of the pool", "deployer", types.string) - .setAction(async ({ enable, admin }, { ethers }) => { - const signer = await ethers.getNamedSigner(admin); + .setAction(async ({ enable }, { ethers }) => { + const { poolsSuperAdmin } = await ethers.getNamedSigners(); - const fusePoolDirectory = (await ethers.getContract("FusePoolDirectory", signer)) as FusePoolDirectory; + const fusePoolDirectory = (await ethers.getContract("FusePoolDirectory", poolsSuperAdmin)) as FusePoolDirectory; const [, pools] = await fusePoolDirectory.callStatic.getActivePools(); for (let i = 0; i < pools.length; i++) { const pool = pools[i]; @@ -178,20 +178,20 @@ task("pools:all:autoimpl", "Toggle the autoimplementations flag of all managed p const comptroller = (await ethers.getContractAt( "Comptroller.sol:Comptroller", pool.comptroller, - signer + poolsSuperAdmin )) as Comptroller; const admin = await comptroller.callStatic.admin(); console.log(`pool name ${pool.name} admin ${admin}`); const autoImplOn = await comptroller.callStatic.autoImplementation(); if (autoImplOn != enable) { - if (admin === signer.address) { + if (admin === poolsSuperAdmin.address) { const tx = await comptroller._toggleAutoImplementations(enable); console.log(`_toggleAutoImplementations ${tx.hash}`); const receipt = await tx.wait(); console.log(`toggled to ${enable} with ${receipt.transactionHash}`); } else { - console.log(`signer is not the admin`); + console.log(`poolsSuperAdmin is not the admin`); } } else { console.log(`autoimplementations for the pool is ${autoImplOn}`); @@ -201,11 +201,10 @@ task("pools:all:autoimpl", "Toggle the autoimplementations flag of all managed p task("pools:all:pause-guardian", "Sets the pause guardian for all pools that have a different address for it") .addParam("replacingGuardian", "Address of the replacing pause guardian", undefined, types.string) - .addOptionalParam("admin", "Named account that is an admin of the pool", "deployer", types.string) - .setAction(async ({ replacingGuardian, admin }, { ethers }) => { - const signer = await ethers.getNamedSigner(admin); + .setAction(async ({ replacingGuardian }, { ethers }) => { + const { poolsSuperAdmin } = await ethers.getNamedSigners(); - const fusePoolDirectory = (await ethers.getContract("FusePoolDirectory", signer)) as FusePoolDirectory; + const fusePoolDirectory = (await ethers.getContract("FusePoolDirectory", poolsSuperAdmin)) as FusePoolDirectory; const [, pools] = await fusePoolDirectory.callStatic.getActivePools(); for (let i = 0; i < pools.length; i++) { const pool = pools[i]; @@ -213,7 +212,7 @@ task("pools:all:pause-guardian", "Sets the pause guardian for all pools that hav const comptroller = (await ethers.getContractAt( "ComptrollerFirstExtension", pool.comptroller, - signer + poolsSuperAdmin )) as ComptrollerFirstExtension; const pauseGuardian = await comptroller.callStatic.pauseGuardian(); console.log(`pool name ${pool.name} pause guardian ${pauseGuardian}`); diff --git a/packages/sdk/tasks/replaceFlywheels.ts b/packages/sdk/tasks/replaceFlywheels.ts index 070f2eaf4..548814a12 100644 --- a/packages/sdk/tasks/replaceFlywheels.ts +++ b/packages/sdk/tasks/replaceFlywheels.ts @@ -11,105 +11,106 @@ task("flywheel:replace:dynamic", "Replaces a flywheel with dynamic rewards") .addParam("flywheelToReplaceAddress", "address of flywheel to replace", undefined, types.string) .addParam("flywheelName", "name of the deploy artifact of the replacing flywheel", undefined, types.string) .addParam("pool", "address of comptroller", undefined, types.string) - .setAction(async ({ flywheelToReplaceAddress, flywheelName, pool }, { ethers, getChainId, deployments }) => { - const deployer = await ethers.getNamedSigner("deployer"); + .setAction( + async ({ flywheelToReplaceAddress, flywheelName, pool }, { ethers, getNamedAccounts, getChainId, deployments }) => { + const { upgradesAdmin, poolsSuperAdmin, extrasAdmin } = await getNamedAccounts(); - if (flywheelToReplaceAddress == "0xC6431455AeE17a08D6409BdFB18c4bc73a4069E4") { - if (flywheelName != "EPX") throw new Error(`name EPX`); - } - if (flywheelToReplaceAddress == "0x851Cc0037B6923e60dC81Fa79Ac0799cC983492c") { - if (flywheelName != "DDD") throw new Error(`name DDD`); - } - const chainid = await getChainId(); - if (chainid == 56) { - const flywheelContractName = `MidasFlywheel_${flywheelName}`; - - const flywheelToReplace = (await ethers.getContractAt( - "MidasFlywheel", - flywheelToReplaceAddress, - deployer - )) as MidasFlywheel; - - const oldRewardsAddress = await flywheelToReplace.callStatic.flywheelRewards(); - const oldRewards = (await ethers.getContractAt( - "FuseFlywheelDynamicRewardsPlugin", - oldRewardsAddress, - deployer - )) as FuseFlywheelDynamicRewardsPlugin; - - const rewardToken = flywheelToReplace.callStatic.rewardToken(); - const booster = flywheelToReplace.callStatic.flywheelBooster(); - - //// deploy a replacing flywheel - const replacingFw = await deployments.deploy(flywheelContractName, { - contract: "MidasReplacingFlywheel", - from: deployer.address, - log: true, - proxy: { - execute: { - init: { - methodName: "initialize", - args: [rewardToken, constants.AddressZero, booster, deployer.address], - }, - onUpgrade: { - methodName: "reinitialize", - args: [flywheelToReplaceAddress], + if (flywheelToReplaceAddress == "0xC6431455AeE17a08D6409BdFB18c4bc73a4069E4") { + if (flywheelName != "EPX") throw new Error(`name EPX`); + } + if (flywheelToReplaceAddress == "0x851Cc0037B6923e60dC81Fa79Ac0799cC983492c") { + if (flywheelName != "DDD") throw new Error(`name DDD`); + } + const chainid = await getChainId(); + if (chainid == 56) { + const flywheelContractName = `MidasFlywheel_${flywheelName}`; + + const flywheelToReplace = (await ethers.getContractAt( + "MidasFlywheel", + flywheelToReplaceAddress, + extrasAdmin + )) as MidasFlywheel; + + const oldRewardsAddress = await flywheelToReplace.callStatic.flywheelRewards(); + const oldRewards = (await ethers.getContractAt( + "FuseFlywheelDynamicRewardsPlugin", + oldRewardsAddress + )) as FuseFlywheelDynamicRewardsPlugin; + + const rewardToken = flywheelToReplace.callStatic.rewardToken(); + const booster = flywheelToReplace.callStatic.flywheelBooster(); + + //// deploy a replacing flywheel + const replacingFw = await deployments.deploy(flywheelContractName, { + contract: "MidasReplacingFlywheel", + from: upgradesAdmin, + log: true, + proxy: { + execute: { + init: { + methodName: "initialize", + args: [rewardToken, constants.AddressZero, booster, extrasAdmin], + }, + onUpgrade: { + methodName: "reinitialize", + args: [flywheelToReplaceAddress], + }, }, + proxyContract: "OpenZeppelinTransparentProxy", + owner: upgradesAdmin, }, - proxyContract: "OpenZeppelinTransparentProxy", - owner: deployer.address, - }, - waitConfirmations: 1, - }); - if (replacingFw.transactionHash) { - await ethers.provider.waitForTransaction(replacingFw.transactionHash); - } - console.log("MidasReplacingFlywheel: ", replacingFw.address); - - const replacingFlywheel = (await ethers.getContractAt( - "MidasReplacingFlywheel", - replacingFw.address, - deployer - )) as MidasReplacingFlywheel; - - let tx = await replacingFlywheel.reinitialize(flywheelToReplaceAddress); - await tx.wait(); - console.log(`reinitialize`, tx.hash); - - const oldRewardsCycleLen = await oldRewards.callStatic.rewardsCycleLength(); - - const replacingRewards = await deployments.deploy("ReplacingFlywheelDynamicRewards", { - from: deployer.address, - log: true, - args: [flywheelToReplaceAddress, replacingFw.address, oldRewardsCycleLen], - }); - if (replacingRewards.transactionHash) { - await ethers.provider.waitForTransaction(replacingRewards.transactionHash); + waitConfirmations: 1, + }); + if (replacingFw.transactionHash) { + await ethers.provider.waitForTransaction(replacingFw.transactionHash); + } + console.log("MidasReplacingFlywheel: ", replacingFw.address); + + const replacingFlywheel = (await ethers.getContractAt( + "MidasReplacingFlywheel", + replacingFw.address, + extrasAdmin + )) as MidasReplacingFlywheel; + + let tx = await replacingFlywheel.reinitialize(flywheelToReplaceAddress); + await tx.wait(); + console.log(`reinitialize`, tx.hash); + + const oldRewardsCycleLen = await oldRewards.callStatic.rewardsCycleLength(); + + const replacingRewards = await deployments.deploy("ReplacingFlywheelDynamicRewards", { + from: extrasAdmin, + log: true, + args: [flywheelToReplaceAddress, replacingFw.address, oldRewardsCycleLen], + }); + if (replacingRewards.transactionHash) { + await ethers.provider.waitForTransaction(replacingRewards.transactionHash); + } + console.log("ReplacingFlywheelDynamicRewards: ", replacingRewards.address); + + tx = await flywheelToReplace.setFlywheelRewards(replacingRewards.address); + await tx.wait(); + console.log(`old flywheel setFlywheelRewards`, tx.hash); + + tx = await replacingFlywheel.setFlywheelRewards(replacingRewards.address); + await tx.wait(); + console.log(`new flywheel setFlywheelRewards`, tx.hash); + + const comptrollerAsExtension = (await ethers.getContractAt( + "ComptrollerFirstExtension", + pool, + poolsSuperAdmin + )) as ComptrollerFirstExtension; + + const comptroller = (await ethers.getContractAt("Comptroller", pool, poolsSuperAdmin)) as Comptroller; + + tx = await comptroller._addRewardsDistributor(replacingFlywheel.address); + await tx.wait(); + console.log(`added the flywheel ${tx.hash}`); + + tx = await comptrollerAsExtension.addNonAccruingFlywheel(flywheelToReplaceAddress); + await tx.wait(); + console.log(`added the flywheel to the non-accruing with tx ${tx.hash}`); } - console.log("ReplacingFlywheelDynamicRewards: ", replacingRewards.address); - - tx = await flywheelToReplace.setFlywheelRewards(replacingRewards.address); - await tx.wait(); - console.log(`old flywheel setFlywheelRewards`, tx.hash); - - tx = await replacingFlywheel.setFlywheelRewards(replacingRewards.address); - await tx.wait(); - console.log(`new flywheel setFlywheelRewards`, tx.hash); - - const comptrollerAsExtension = (await ethers.getContractAt( - "ComptrollerFirstExtension", - pool, - deployer - )) as ComptrollerFirstExtension; - - const comptroller = (await ethers.getContractAt("Comptroller", pool, deployer)) as Comptroller; - - tx = await comptroller._addRewardsDistributor(replacingFlywheel.address); - await tx.wait(); - console.log(`added the flywheel ${tx.hash}`); - - tx = await comptrollerAsExtension.addNonAccruingFlywheel(flywheelToReplaceAddress); - await tx.wait(); - console.log(`added the flywheel to the non-accruing with tx ${tx.hash}`); } - }); + ); diff --git a/packages/sdk/tasks/sendTestTokens.ts b/packages/sdk/tasks/sendTestTokens.ts index c69749be3..8b4bb4026 100644 --- a/packages/sdk/tasks/sendTestTokens.ts +++ b/packages/sdk/tasks/sendTestTokens.ts @@ -1,21 +1,19 @@ -import { BigNumber, constants, providers } from "ethers"; +import { BigNumber, providers } from "ethers"; import { task, types } from "hardhat/config"; -export default task("send-tokens", "Edit deployers") +export default task("send-tokens", "send tokens") .addParam("tokens", "Comma-separated symbols") - .addOptionalParam("sendTo", "Address to which the minted tokens should be sent to") + .addParam("sendFrom", "Account to send from", undefined, types.string) + .addParam("sendTo", "Address to which the minted tokens should be sent to", undefined, types.string) .addOptionalParam("sendAmount", "Amount to be sent", "10", types.string) - .setAction(async ({ tokens: _tokens, sendTo: _sendTo, sendAmount: _sendAmount }, { getNamedAccounts, ethers }) => { - // @ts-ignore - const { deployer } = await getNamedAccounts(); + .setAction(async ({ tokens: _tokens, sendTo: _sendTo, sendAmount: _sendAmount, sendFrom: _sendFrom }, { ethers }) => { const tokens = _tokens.split(","); let tx: providers.TransactionResponse; for (const tokenName of tokens) { - const token = await ethers.getContract(`${tokenName}Token`, await ethers.getSigner(deployer)); - tx = await token.approve(deployer, constants.MaxUint256); - tx = await token.transferFrom(deployer, _sendTo, BigNumber.from(_sendAmount).mul(BigNumber.from(10).pow(18))); + const token = await ethers.getContract(`${tokenName}Token`, await ethers.getSigner(_sendFrom)); + tx = await token.transfer(_sendTo, BigNumber.from(_sendAmount).mul(BigNumber.from(10).pow(18))); console.log(await tx.wait()); - const balance = await token.balanceOf(deployer); + const balance = await token.balanceOf(_sendFrom); console.log(balance.toString()); } });