Skip to content

Commit

Permalink
EBIP-9 (#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrendanSanderson authored Oct 24, 2023
2 parents 527a7bd + 447be2d commit 2ad9014
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 5 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 = 16_665;

/**
* @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;
4 changes: 2 additions & 2 deletions protocol/test/Season.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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'));
Expand Down
6 changes: 3 additions & 3 deletions protocol/test/WellMinting.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')])
Expand All @@ -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')
})

Expand All @@ -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')])
Expand Down

0 comments on commit 2ad9014

Please sign in to comment.