diff --git a/contracts/deploy/deployActions.js b/contracts/deploy/deployActions.js index 29a136b8a6..c832f728df 100644 --- a/contracts/deploy/deployActions.js +++ b/contracts/deploy/deployActions.js @@ -6,6 +6,8 @@ const { getOracleAddresses, isMainnet, isHolesky, + isHoleskyOrFork, + isSonicOrFork, isTest, } = require("../test/helpers.js"); const { deployWithConfirmation, withConfirmation } = require("../utils/deploy"); @@ -1019,23 +1021,27 @@ const deployOracles = async () => { let args = []; if (isMainnet) { oracleContract = "OracleRouter"; - } else if (isHolesky) { + } else if (isHoleskyOrFork) { oracleContract = "OETHFixedOracle"; contractName = "OETHOracleRouter"; args = [addresses.zero]; + } else if (isSonicOrFork) { + oracleContract = "OETHFixedOracle"; + contractName = "OSonicOracleRouter"; + args = [addresses.zero]; } await deployWithConfirmation(contractName, args, oracleContract); - const oracleRouter = await ethers.getContract("OracleRouter"); - log("Deployed OracleRouter"); - - if (isHolesky) { + if (isHoleskyOrFork || isSonicOrFork) { // no need to configure any feeds since they are hardcoded to a fixed feed // TODO: further deployments will require more intelligent separation of different // chains / environment oracle deployments return; } + const oracleRouter = await ethers.getContract("OracleRouter"); + log("Deployed OracleRouter"); + const assetAddresses = await getAssetAddresses(deployments); await deployWithConfirmation("AuraWETHPriceFeed", [ assetAddresses.auraWeightedOraclePool, diff --git a/contracts/deploy/sonic/002_oracle_router.js b/contracts/deploy/sonic/002_oracle_router.js new file mode 100644 index 0000000000..3fa746c583 --- /dev/null +++ b/contracts/deploy/sonic/002_oracle_router.js @@ -0,0 +1,32 @@ +const { deployOnSonic } = require("../../utils/deploy-l2.js"); +const { deployOracles } = require("../deployActions"); + +module.exports = deployOnSonic( + { + deployName: "002_oracle_router", + forceSkip: false, + }, + async ({ ethers }) => { + const cOSonicVaultProxy = await ethers.getContract("OSonicVaultProxy"); + const cOSonicVault = await ethers.getContractAt( + "IVault", + cOSonicVaultProxy.address + ); + + await deployOracles(); + const oracleRouter = await ethers.getContract("OSonicOracleRouter"); + console.log(`Deployed Oracle Router at: ${oracleRouter.address}`); + + return { + name: "Configure Oracle Router as Price provider", + actions: [ + // 1. Approve Sonic Staking Strategy on the Vault + { + contract: cOSonicVault, + signature: "setPriceProvider(address)", + args: [oracleRouter.address], + }, + ], + }; + } +); diff --git a/contracts/deploy/sonic/002_sonic_staking_strategy.js b/contracts/deploy/sonic/003_sonic_staking_strategy.js similarity index 98% rename from contracts/deploy/sonic/002_sonic_staking_strategy.js rename to contracts/deploy/sonic/003_sonic_staking_strategy.js index 508e795403..3195557fd8 100644 --- a/contracts/deploy/sonic/002_sonic_staking_strategy.js +++ b/contracts/deploy/sonic/003_sonic_staking_strategy.js @@ -7,7 +7,7 @@ const addresses = require("../../utils/addresses.js"); module.exports = deployOnSonic( { - deployName: "002_sonic_staking_strategy", + deployName: "003_sonic_staking_strategy", forceSkip: false, }, async ({ ethers }) => { diff --git a/contracts/docs/plantuml/sonicContracts.png b/contracts/docs/plantuml/sonicContracts.png index 78ea2c39d4..913c2b9dca 100644 Binary files a/contracts/docs/plantuml/sonicContracts.png and b/contracts/docs/plantuml/sonicContracts.png differ diff --git a/contracts/docs/plantuml/sonicContracts.puml b/contracts/docs/plantuml/sonicContracts.puml index 29c25d2d2e..2a54a3769b 100644 --- a/contracts/docs/plantuml/sonicContracts.puml +++ b/contracts/docs/plantuml/sonicContracts.puml @@ -60,6 +60,10 @@ object "OSonicHarvester" as harv <><> #$phase2 { rewards: ? } +' Oracle +object "OSonicOracleRouter" as router <> #DeepSkyBlue { +} + wos <. zap zap ..> os zap ..> vault @@ -72,6 +76,7 @@ vault <.> drip vault <...> stakeStrat stakeStrat ..> sfc vault <...> amoStrat +vault .> router vault <.. harv drip <.. harv diff --git a/contracts/test/behaviour/sfcStakingStrategy.js b/contracts/test/behaviour/sfcStakingStrategy.js index 5c70dd5739..d13975dc41 100644 --- a/contracts/test/behaviour/sfcStakingStrategy.js +++ b/contracts/test/behaviour/sfcStakingStrategy.js @@ -28,8 +28,13 @@ const MIN_WITHDRAWAL_EPOCH_ADVANCE = 4; const shouldBehaveLikeASFCStakingStrategy = (context) => { describe("Initial setup", function () { it("Should verify the initial state", async () => { - const { sonicStakingStrategy, addresses, oSonicVault, testValidatorIds } = - await context(); + const { + sonicStakingStrategy, + addresses, + oSonicVault, + testValidatorIds, + wS, + } = await context(); expect(await sonicStakingStrategy.wrappedSonic()).to.equal( addresses.wS, "Incorrect wrapped sonic address set" @@ -69,6 +74,16 @@ const shouldBehaveLikeASFCStakingStrategy = (context) => { expect( (await sonicStakingStrategy.getRewardTokenAddresses()).length ).to.equal(0, "Incorrectly configured Reward Token Addresses"); + + expect(await oSonicVault.priceProvider()).to.not.equal( + AddressZero, + "Price provider address not set" + ); + + expect(await oSonicVault.priceUnitMint(wS.address)).to.equal( + oethUnits("1"), + "not expected PriceUnitMint" + ); }); });