Skip to content

Commit

Permalink
more progress on integrating sonic
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrowDom committed Dec 27, 2024
1 parent 124ab29 commit 055792e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 25 deletions.
44 changes: 29 additions & 15 deletions contracts/deploy/deployActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const {
getOracleAddresses,
isMainnet,
isHolesky,
isSonicOrFork
isSonicOrFork,
isSonic,
} = require("../test/helpers.js");
const { deployWithConfirmation, withConfirmation } = require("../utils/deploy");
const {
Expand Down Expand Up @@ -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
Expand All @@ -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));
}
Expand Down Expand Up @@ -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");

Expand All @@ -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,
[]
Expand Down Expand Up @@ -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");
Expand All @@ -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,
[]
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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)}`);
Expand Down Expand Up @@ -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,
[]
Expand All @@ -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,
[]
Expand Down
2 changes: 1 addition & 1 deletion contracts/deploy/holesky/001_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion contracts/deploy/mainnet/001_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const main = async () => {
oethDripper
);
await configureVault();
await configureOETHVault(false);
await configureOETHVault("OETH");
await configureStrategies(harvesterProxy, oethHarvesterProxy);
await deployFlipper();
await deployBuyback();
Expand Down
14 changes: 6 additions & 8 deletions contracts/deploy/sonic/001_core.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const {
deployOracles,
deployOETHCore,
// deployOETHDripper,
// deployOETHHarvester,
// configureOETHVault,
deployOETHDripper,
deployOETHHarvester,
configureOETHVault,
} = require("../deployActions");

//const { withConfirmation } = require("../../utils/deploy");
Expand All @@ -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);

Check failure on line 28 in contracts/deploy/sonic/001_core.js

View workflow job for this annotation

GitHub Actions / Contracts Linter

'cOETHHarvester' is assigned a value but never used
await configureOETHVault("sonicOETH");

// const cVault = await ethers.getContractAt(
// "IVault",
Expand Down
1 change: 1 addition & 0 deletions contracts/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ module.exports = {
process.env.DEPLOYER_PK || privateKeys[0],
process.env.GOVERNOR_PK || privateKeys[0],
],
chainId: 146,
live: true,
saveDeployments: true,
}
Expand Down

0 comments on commit 055792e

Please sign in to comment.