diff --git a/protocol/contracts/beanstalk/init/InitTurnOffBeanEthWell.sol b/protocol/contracts/beanstalk/init/InitTurnOffBeanEthWell.sol new file mode 100644 index 0000000000..7b3722c2d4 --- /dev/null +++ b/protocol/contracts/beanstalk/init/InitTurnOffBeanEthWell.sol @@ -0,0 +1,22 @@ +/* + SPDX-License-Identifier: MIT +*/ + +pragma solidity =0.7.6; +pragma experimental ABIEncoderV2; + +import {LibAppStorage} from "contracts/libraries/LibAppStorage.sol"; +import {C} from "contracts/C.sol"; + +/** + * @author Publius + * @title InitTurnOffBeanEthWell turns off the Bean:Eth Well +**/ + +contract InitTurnOffBeanEthWell { + + function init() external { + delete LibAppStorage.diamondStorage().wellOracleSnapshots[C.BEAN_ETH_WELL]; + } + +} \ No newline at end of file diff --git a/protocol/contracts/libraries/Minting/LibWellMinting.sol b/protocol/contracts/libraries/Minting/LibWellMinting.sol index 22e885920a..02c9852d07 100644 --- a/protocol/contracts/libraries/Minting/LibWellMinting.sol +++ b/protocol/contracts/libraries/Minting/LibWellMinting.sol @@ -33,6 +33,8 @@ library LibWellMinting { using SignedSafeMath for int256; + uint256 constant TURN_BACK_ON_SEASON = 16_665; + /** * @notice Emitted when a Well Minting Oracle is captured. * @param season The season that the Well was captured. @@ -103,6 +105,11 @@ library LibWellMinting { */ function initializeOracle(address well) internal { AppStorage storage s = LibAppStorage.diamondStorage(); + + if (s.season.current < TURN_BACK_ON_SEASON) { + return; + } + // If pump has not been initialized for `well`, `readCumulativeReserves` will revert. // Need to handle failure gracefully, so Sunrise does not revert. try ICumulativePump(C.BEANSTALK_PUMP).readCumulativeReserves( diff --git a/protocol/hardhat.config.js b/protocol/hardhat.config.js index 5aa013e896..bdb75acbd6 100644 --- a/protocol/hardhat.config.js +++ b/protocol/hardhat.config.js @@ -36,6 +36,7 @@ const { to6 } = require("./test/utils/helpers.js"); const { task } = require("hardhat/config"); const { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } = require("hardhat/builtin-tasks/task-names"); const { bipNewSilo, mockBeanstalkAdmin } = require("./scripts/bips.js"); +const { ebip9 } = require("./scripts/ebips.js"); //////////////////////// UTILITIES //////////////////////// @@ -211,6 +212,10 @@ task("migrate-bip38", async function () { await finishBeanEthMigration(); }); +task("ebip9", async function () { + await ebip9(); +}) + //////////////////////// SUBTASK CONFIGURATION //////////////////////// // Add a subtask that sets the action for the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS task diff --git a/protocol/scripts/ebips.js b/protocol/scripts/ebips.js index d5d3673855..81bd33a744 100644 --- a/protocol/scripts/ebips.js +++ b/protocol/scripts/ebips.js @@ -56,6 +56,23 @@ async function ebip8(mock = true, account = undefined) { }); } +async function ebip9(mock = true, account = undefined) { + if (account == undefined) { + account = await impersonateBeanstalkOwner(); + await mintEth(account.address); + } + + await upgradeWithNewFacets({ + diamondAddress: BEANSTALK, + facetNames: ["SeasonFacet"], + initFacetName: "InitTurnOffBeanEthWell", + bip: false, + object: !mock, + verbose: true, + account: account + }); +} + async function bipDiamondCut(name, dc, account, mock = true) { beanstalk = await getBeanstalk(); if (mock) { @@ -76,3 +93,4 @@ async function bipDiamondCut(name, dc, account, mock = true) { exports.ebip6 = ebip6; exports.ebip7 = ebip7; exports.ebip8 = ebip8; +exports.ebip9 = ebip9; \ No newline at end of file diff --git a/protocol/test/Season.test.js b/protocol/test/Season.test.js index e2503d4797..1d0e57c0ea 100644 --- a/protocol/test/Season.test.js +++ b/protocol/test/Season.test.js @@ -70,7 +70,7 @@ describe('Season', function () { }) describe("oracle not initialized, previous balance > 0", async function () { - it ('season incentive', async function () { + it.skip('season incentive', async function () { this.beanMetapool = await ethers.getContractAt('MockMeta3Curve', BEAN_3_CURVE); await this.beanMetapool.set_A_precise('1000'); await this.beanMetapool.set_virtual_price(ethers.utils.parseEther('1')); @@ -84,7 +84,7 @@ describe('Season', function () { }) describe("oracle initialized", async function () { - it ('season incentive', async function () { + it.skip('season incentive', async function () { this.beanMetapool = await ethers.getContractAt('MockMeta3Curve', BEAN_3_CURVE); await this.beanMetapool.set_A_precise('1000'); await this.beanMetapool.set_virtual_price(ethers.utils.parseEther('1')); diff --git a/protocol/test/WellMinting.test.js b/protocol/test/WellMinting.test.js index ee19f4bc15..e377ac9e42 100644 --- a/protocol/test/WellMinting.test.js +++ b/protocol/test/WellMinting.test.js @@ -67,7 +67,7 @@ describe('Well Minting', function () { }) - describe("Delta B > 0", async function () { + describe.skip("Delta B > 0", async function () { beforeEach(async function () { await advanceTime(1800) await this.well.setReserves([to6('500000'), to18('1000')]) @@ -78,7 +78,7 @@ describe('Well Minting', function () { }) }) - it ("Captures a delta B > 0", async function () { + it("Captures a delta B > 0", async function () { expect(await this.season.callStatic.captureWellE(this.well.address)).to.be.equal('133789634067') }) @@ -87,7 +87,7 @@ describe('Well Minting', function () { }) }) - describe("Delta B < 0", async function () { + describe.skip("Delta B < 0", async function () { beforeEach(async function () { await advanceTime(1800) await this.well.setReserves([to6('2000000'), to18('1000')])