Skip to content

Commit

Permalink
ebip9
Browse files Browse the repository at this point in the history
  • Loading branch information
BrendanSanderson committed Oct 20, 2023
1 parent cd9de38 commit 30df7d3
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
22 changes: 22 additions & 0 deletions protocol/contracts/beanstalk/init/InitTurnOffBeanEthWell.sol
Original file line number Diff line number Diff line change
@@ -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];
}

}
7 changes: 7 additions & 0 deletions protocol/contracts/libraries/Minting/LibWellMinting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ library LibWellMinting {

using SignedSafeMath for int256;

uint256 constant TURN_BACK_ON_SEASON = 16660;

/**
* @notice Emitted when a Well Minting Oracle is captured.
* @param season The season that the Well was captured.
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions protocol/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ////////////////////////

Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions protocol/scripts/ebips.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -76,3 +93,4 @@ async function bipDiamondCut(name, dc, account, mock = true) {
exports.ebip6 = ebip6;
exports.ebip7 = ebip7;
exports.ebip8 = ebip8;
exports.ebip9 = ebip9;

0 comments on commit 30df7d3

Please sign in to comment.