From 055792e43d941e189c41edfb5ccb2265805d4d83 Mon Sep 17 00:00:00 2001 From: Domen Grabec Date: Fri, 27 Dec 2024 12:27:23 +0100 Subject: [PATCH] more progress on integrating sonic --- contracts/deploy/deployActions.js | 44 ++++++++++++++++++---------- contracts/deploy/holesky/001_core.js | 2 +- contracts/deploy/mainnet/001_core.js | 2 +- contracts/deploy/sonic/001_core.js | 14 ++++----- contracts/hardhat.config.js | 1 + 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/contracts/deploy/deployActions.js b/contracts/deploy/deployActions.js index 6cc974c616..2bc83578d8 100644 --- a/contracts/deploy/deployActions.js +++ b/contracts/deploy/deployActions.js @@ -6,7 +6,8 @@ const { getOracleAddresses, isMainnet, isHolesky, - isSonicOrFork + isSonicOrFork, + isSonic, } = require("../test/helpers.js"); const { deployWithConfirmation, withConfirmation } = require("../utils/deploy"); const { @@ -448,8 +449,9 @@ const configureVault = async () => { /** * Configure OETH Vault by adding supported assets and Strategies. + * @param oethDeployType: OETH, simpleOETH, sonicOETH */ -const configureOETHVault = async (isSimpleOETH) => { +const configureOETHVault = async (oethDeployType) => { const assetAddresses = await getAssetAddresses(deployments); const { governorAddr, strategistAddr } = await getNamedAccounts(); // Signers @@ -462,8 +464,18 @@ const configureOETHVault = async (isSimpleOETH) => { ).address ); // Set up supported assets for Vault - const { WETH, RETH, stETH, frxETH } = assetAddresses; - const assets = isSimpleOETH ? [WETH] : [WETH, RETH, stETH, frxETH]; + const { WETH, RETH, stETH, frxETH, WS } = assetAddresses; + let assets; + if (oethDeployType == "OETH") { + assets = [WETH, RETH, stETH, frxETH]; + } else if (oethDeployType == "simpleOETH") { + assets = [WETH]; + } else if (oethDeployType == "sonicOETH") { + assets = [WS]; + } else { + throw new Error(`Unrecognised deploy type: ${oethDeployType}`); + } + for (const asset of assets) { await withConfirmation(cVault.connect(sGovernor).supportAsset(asset, 0)); } @@ -566,7 +578,8 @@ const upgradeOETHHarvester = async () => { const deployOETHHarvester = async (oethDripper) => { const assetAddresses = await getAssetAddresses(deployments); - const { governorAddr } = await getNamedAccounts(); + const { governorAddr, deployerAddr } = await getNamedAccounts(); + const sDeployer = await ethers.provider.getSigner(deployerAddr); const sGovernor = await ethers.provider.getSigner(governorAddr); const cOETHVaultProxy = await ethers.getContract("OETHVaultProxy"); @@ -589,7 +602,7 @@ const deployOETHHarvester = async (oethDripper) => { await withConfirmation( // prettier-ignore - cOETHHarvesterProxy["initialize(address,address,bytes)"]( + cOETHHarvesterProxy.connect(sDeployer)["initialize(address,address,bytes)"]( dOETHHarvester.address, governorAddr, [] @@ -750,8 +763,9 @@ const deployOUSDDripper = async () => { return cDripper; }; -const deployOETHDripper = async () => { - const { governorAddr } = await getNamedAccounts(); +const deployOETHDripper = async ({ skipUpgradeSafety = false } = {}) => { + const { governorAddr, deployerAddr } = await getNamedAccounts(); + const sDeployer = await ethers.provider.getSigner(deployerAddr); const assetAddresses = await getAssetAddresses(deployments); const cVaultProxy = await ethers.getContract("OETHVaultProxy"); @@ -761,13 +775,13 @@ const deployOETHDripper = async () => { const dDripper = await deployWithConfirmation("OETHDripper", [ cVaultProxy.address, assetAddresses.WETH, - ]); + ], false, skipUpgradeSafety); await deployWithConfirmation("OETHDripperProxy"); // Deploy Dripper Proxy const cDripperProxy = await ethers.getContract("OETHDripperProxy"); await withConfirmation( - cDripperProxy["initialize(address,address,bytes)"]( + cDripperProxy.connect(sDeployer)["initialize(address,address,bytes)"]( dDripper.address, governorAddr, [] @@ -1019,7 +1033,7 @@ const deployOracles = async () => { let args = []; if (isMainnet) { oracleContract = "OracleRouter"; - } else if (isHolesky) { + } else if (isHolesky || isSonic) { oracleContract = "OETHFixedOracle"; contractName = "OETHOracleRouter"; args = [addresses.zero]; @@ -1085,7 +1099,7 @@ const deployOracles = async () => { const deployOETHCore = async () => { const { governorAddr, deployerAddr } = await hre.getNamedAccounts(); - const sDeloyer = await ethers.provider.getSigner(deployerAddr); + const sDeployer = await ethers.provider.getSigner(deployerAddr); const assetAddresses = await getAssetAddresses(deployments); log(`Using asset addresses: ${JSON.stringify(assetAddresses, null, 2)}`); @@ -1123,9 +1137,9 @@ const deployOETHCore = async () => { cOETHVaultProxy.address ); - await cOETHProxy.connect(sDeloyer); + await cOETHProxy.connect(sDeployer); await withConfirmation( - cOETHProxy.connect(sDeloyer)["initialize(address,address,bytes)"]( + cOETHProxy.connect(sDeployer)["initialize(address,address,bytes)"]( dOETH.address, governorAddr, [] @@ -1134,7 +1148,7 @@ const deployOETHCore = async () => { log("Initialized OETHProxy"); await withConfirmation( - cOETHVaultProxy.connect(sDeloyer)["initialize(address,address,bytes)"]( + cOETHVaultProxy.connect(sDeployer)["initialize(address,address,bytes)"]( dOETHVault.address, governorAddr, [] diff --git a/contracts/deploy/holesky/001_core.js b/contracts/deploy/holesky/001_core.js index 308c1f8838..c40207f750 100644 --- a/contracts/deploy/holesky/001_core.js +++ b/contracts/deploy/holesky/001_core.js @@ -23,7 +23,7 @@ const mainExport = async () => { const cOETHDripper = await deployOETHDripper(); const cOETHHarvester = await deployOETHHarvester(cOETHDripper); - await configureOETHVault(true); + await configureOETHVault("simpleOETH"); const cVault = await ethers.getContractAt( "IVault", diff --git a/contracts/deploy/mainnet/001_core.js b/contracts/deploy/mainnet/001_core.js index 61b7451e4d..0caa321eb1 100644 --- a/contracts/deploy/mainnet/001_core.js +++ b/contracts/deploy/mainnet/001_core.js @@ -47,7 +47,7 @@ const main = async () => { oethDripper ); await configureVault(); - await configureOETHVault(false); + await configureOETHVault("OETH"); await configureStrategies(harvesterProxy, oethHarvesterProxy); await deployFlipper(); await deployBuyback(); diff --git a/contracts/deploy/sonic/001_core.js b/contracts/deploy/sonic/001_core.js index 73c21c57c7..e82dd9bb8c 100644 --- a/contracts/deploy/sonic/001_core.js +++ b/contracts/deploy/sonic/001_core.js @@ -1,9 +1,9 @@ const { deployOracles, deployOETHCore, - // deployOETHDripper, - // deployOETHHarvester, - // configureOETHVault, + deployOETHDripper, + deployOETHHarvester, + configureOETHVault, } = require("../deployActions"); //const { withConfirmation } = require("../../utils/deploy"); @@ -21,14 +21,12 @@ const mainExport = async () => { await hardhatSetBalance(deployerAddr, "10000000000"); } - console.log("Deploying Oracles"); await deployOracles(); - console.log("Deploying Core"); await deployOETHCore(); - //const cOETHDripper = await deployOETHDripper(); - // const cOETHHarvester = await deployOETHHarvester(cOETHDripper); - // await configureOETHVault(true); + const cOETHDripper = await deployOETHDripper({ skipUpgradeSafety: true }); + const cOETHHarvester = await deployOETHHarvester(cOETHDripper); + await configureOETHVault("sonicOETH"); // const cVault = await ethers.getContractAt( // "IVault", diff --git a/contracts/hardhat.config.js b/contracts/hardhat.config.js index 0bd04ef2a6..0332afff5f 100644 --- a/contracts/hardhat.config.js +++ b/contracts/hardhat.config.js @@ -195,6 +195,7 @@ module.exports = { process.env.DEPLOYER_PK || privateKeys[0], process.env.GOVERNOR_PK || privateKeys[0], ], + chainId: 146, live: true, saveDeployments: true, }