Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System admin roles #1197

Open
wants to merge 14 commits into
base: development
Choose a base branch
from
14 changes: 7 additions & 7 deletions packages/sdk/chainDeploy/helpers/dynamicFlywheels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const deployFlywheelWithDynamicRewards = async ({
deployments,
deployConfig,
}: FuseFlywheelDeployFnParams): Promise<Array<string>> => {
const { deployer } = await getNamedAccounts();
const { upgradesAdmin, extrasAdmin } = await getNamedAccounts();

const dynamicFlywheels = [];

Expand All @@ -18,27 +18,27 @@ 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",
args: [flywheelToReplace],
},
},
proxyContract: "OpenZeppelinTransparentProxy",
owner: deployer,
owner: upgradesAdmin,
},
waitConfirmations: 1,
});
Expand All @@ -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,
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/chainDeploy/helpers/irms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export const deployIRMs = async ({
deployments,
deployConfig,
}: IrmDeployFnParams): Promise<void> => {
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
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions packages/sdk/chainDeploy/helpers/liquidators/fuseSafeLiquidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export const deployFuseSafeLiquidator = async ({
deployments,
deployConfig,
}: LiquidatorDeployFnParams): Promise<void> => {
const { deployer } = await getNamedAccounts();
const { upgradesAdmin, liquidator } = await getNamedAccounts();
const fsl = await deployments.deploy("FuseSafeLiquidator", {
from: deployer,
from: upgradesAdmin,
log: true,
proxy: {
execute: {
Expand All @@ -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}`);
};
Expand All @@ -51,15 +51,15 @@ export const configureFuseSafeLiquidator = async ({
getNamedAccounts,
chainId,
}: LiquidatorConfigFnParams): Promise<void> => {
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
Expand All @@ -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
Expand All @@ -97,11 +97,11 @@ export const configureAddressesProviderStrategies = async ({
getNamedAccounts,
chainId,
}: LiquidatorConfigFnParams): Promise<void> => {
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) {
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/chainDeploy/helpers/oracles/aXXXc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -26,7 +26,7 @@ export const deployAnkrCertificateTokenPriceOracle = async ({
},
},
proxyContract: "OpenZeppelinTransparentProxy",
owner: deployer,
owner: upgradesAdmin,
},
log: true,
waitConfirmations: 1,
Expand Down
10 changes: 5 additions & 5 deletions packages/sdk/chainDeploy/helpers/oracles/adrastia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -27,15 +27,15 @@ export const deployAdrastiaOracle = async ({
args: [nativeUsdFeed],
},
},
owner: deployer,
owner: upgradesAdmin,
proxyContract: "OpenZeppelinTransparentProxy",
},
});

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)
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/chainDeploy/helpers/oracles/balancerLp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export const deployBalancerLpPriceOracle = async ({
deployments,
balancerLpAssets,
}: BalancerLpFnParams): Promise<void> => {
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: {
Expand All @@ -23,7 +23,7 @@ export const deployBalancerLpPriceOracle = async ({
args: [mpo.address],
},
},
owner: deployer,
owner: upgradesAdmin,
proxyContract: "OpenZeppelinTransparentProxy",
},
});
Expand Down
12 changes: 6 additions & 6 deletions packages/sdk/chainDeploy/helpers/oracles/chainlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand All @@ -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);
Expand Down
20 changes: 10 additions & 10 deletions packages/sdk/chainDeploy/helpers/oracles/curveLp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export const deployCurveLpOracle = async ({
deployments,
curvePools,
}: CurveLpFnParams): Promise<void> => {
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: {
Expand All @@ -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);
Expand All @@ -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();

Expand All @@ -67,15 +67,15 @@ export const deployCurveV2LpOracle = async ({
deployments,
curveV2Pools,
}: CurveV2LpFnParams): Promise<void> => {
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: {
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions packages/sdk/chainDeploy/helpers/oracles/dia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down
Loading