Skip to content

Commit

Permalink
Merge branch 'beanstalk-3' into spacebean/bs3/pipeline-convert
Browse files Browse the repository at this point in the history
  • Loading branch information
Space-Bean authored Sep 26, 2024
2 parents a7769f4 + 7019a63 commit 2992ce9
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 200 deletions.
2 changes: 1 addition & 1 deletion protocol/.env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ BLOCK_NUMBER=
MAINNET_RPC=
ARBITRUM_RPC=
ETHERSCAN_KEY=
DIAMOND_DEPLOYER_PRIVATE_KEY=
ETHERSCAN_KEY_ARBITRUM=
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ contract ReseedAccountStatus {
uint128 germinatingStalkEven;
}

// emitted when a status is migrated.
event MigratedAccountStatus(
event MigratedAccountTokenStatus(
address indexed account,
address indexed token,
uint256 stalk,
uint256 roots,
uint256 bdv,
int96 lastStem
);

// emitted when a status is migrated.
event MigratedAccountStatus(address indexed account, uint256 stalk, uint256 roots);

function init(AccountStatus[] calldata accountStatuses) external {
// for each account
for (uint i = 0; i < accountStatuses.length; i++) {
Expand All @@ -51,6 +51,14 @@ contract ReseedAccountStatus {
.accts[accountStatuses[i].account]
.mowStatuses[accountStatuses[i].tokens[j]]
.lastStem = accountStatuses[i].mowStatuses[j].lastStem;

// emit event on a per account per token basis.
emit MigratedAccountTokenStatus(
accountStatuses[i].account,
accountStatuses[i].tokens[j],
accountStatuses[i].mowStatuses[j].bdv,
accountStatuses[i].mowStatuses[j].lastStem
);
}
// set stalk and roots for account.
s.accts[accountStatuses[i].account].stalk = accountStatuses[i].stalk;
Expand All @@ -64,6 +72,13 @@ contract ReseedAccountStatus {
s.accts[accountStatuses[i].account].germinatingStalk[
GerminationSide.EVEN
] = accountStatuses[i].germinatingStalkEven;

// emit event on a per account basis.
emit MigratedAccountStatus(
accountStatuses[i].account,
accountStatuses[i].stalk,
accountStatuses[i].stalk * 1e12 // roots
);
}
}
}
57 changes: 0 additions & 57 deletions protocol/contracts/beanstalk/init/reseed/L2/ReseedSun.sol

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ contract WhitelistFacet is Invariable, WhitelistedTokens, ReentrancyGuard {
/**
* @notice Updates the Liquidity Weight Implementation for a given Token.
*/
function updateLiqudityWeightImplementationForToken(
function updateLiquidityWeightImplementationForToken(
address token,
Implementation memory impl
) external payable {
LibDiamond.enforceIsOwnerOrContract();
LibWhitelist.updateLiqudityWeightImplementationForToken(token, impl);
LibWhitelist.updateLiquidityWeightImplementationForToken(token, impl);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions protocol/contracts/interfaces/IMockFBeanstalk.sol
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ interface IMockFBeanstalk {
address indexed token,
Implementation gaugePointImplementation
);
event UpdatedLiqudityWeightImplementationForToken(
event UpdatedLiquidityWeightImplementationForToken(
address indexed token,
Implementation liquidityWeightImplementation
);
Expand Down Expand Up @@ -2048,7 +2048,7 @@ interface IMockFBeanstalk {
Implementation memory impl
) external payable;

function updateLiqudityWeightImplementationForToken(
function updateLiquidityWeightImplementationForToken(
address token,
Implementation memory impl
) external payable;
Expand Down
5 changes: 1 addition & 4 deletions protocol/contracts/libraries/Convert/LibPipelineConvert.sol
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,7 @@ library LibPipelineConvert {
pipeData.initialLpSupply
);

require(
pipeData.stalkPenaltyBdv == 0,
"Convert: Penalty would be applied to this convert, use pipeline convert"
);
require(pipeData.stalkPenaltyBdv == 0, "Convert: Non-zero Stalk Penalty");
}
}
}
4 changes: 2 additions & 2 deletions protocol/contracts/libraries/Silo/LibWhitelist.sol
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ library LibWhitelist {
Implementation memory lwImplementation
) internal {
updateGaugePointImplementationForToken(token, gpImplementation);
updateLiqudityWeightImplementationForToken(token, lwImplementation);
updateLiquidityWeightImplementationForToken(token, lwImplementation);
updateOptimalPercentDepositedBdvForToken(token, optimalPercentDepositedBdv);
}

Expand Down Expand Up @@ -261,7 +261,7 @@ library LibWhitelist {
/**
* @notice updates the gauge point implementation for a token.
*/
function updateLiqudityWeightImplementationForToken(
function updateLiquidityWeightImplementationForToken(
address token,
Implementation memory lwImplementation
) internal {
Expand Down
35 changes: 6 additions & 29 deletions protocol/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const {
INTERNAL_EXTERNAL,
INTERNAL_TOLERANT
} = require("./test/hardhat/utils/balances.js");
const { BEANSTALK, PUBLIUS, BEAN_ETH_WELL, BCM } = require("./test/hardhat/utils/constants.js");
const { BEANSTALK, PUBLIUS, BEAN_ETH_WELL, BCM, L2_BCM } = require("./test/hardhat/utils/constants.js");
const { to6 } = require("./test/hardhat/utils/helpers.js");
//const { replant } = require("./replant/replant.js")
const { reseedL2 } = require("./reseed/reseedL2.js");
Expand Down Expand Up @@ -120,32 +120,6 @@ task("sunriseArb", async function () {
);
});

task("addReseedFacets", async function () {
let l2bcm = await impersonateSigner("0xDd5b31E73dB1c566Ca09e1F1f74Df34913DaaF69");
const l2BeanstalkAddress = "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70";
let beanstalkDeployer = await impersonateSigner("0xe26367ca850da09a478076481535d7c1c67d62f9");
await mintEth(l2bcm.address);
await mintEth(beanstalkDeployer.address);
// transfer ownership to the l2bcm.
await upgradeWithNewFacets({
diamondAddress: l2BeanstalkAddress,
facetNames: ["OwnershipFacet"],
initFacetName: "ReseedTransferOwnership",
initArgs: [l2bcm.address],
bip: false,
verbose: false,
account: beanstalkDeployer,
checkGas: true,
initFacetNameInfo: "ReseedTransferOwnership"
});
// claim ownership of the l2 beanstalk.
await (await getBeanstalk(l2BeanstalkAddress)).connect(l2bcm).claimOwnership();
// perform the diamond cut.
await reseed10(l2bcm, l2BeanstalkAddress, false, true);
console.log("-----------------------------------");
console.log("\nDiamond cut complete: Facets added to L2 Beanstalk.");
});

task("getTime", async function () {
beanstalk = await ethers.getContractAt("SeasonFacet", BEANSTALK);
console.log("Current time: ", await this.seasonGetter.time());
Expand All @@ -167,7 +141,7 @@ task("reseedL2", async () => {
// the account that deploys the new diamond address at nonce 0.
let beanstalkDeployer = await impersonateSigner("0xe26367ca850da09a478076481535d7c1c67d62f9");
// the l2 bcm safe account address.
let l2bcm = await impersonateSigner("0xDd5b31E73dB1c566Ca09e1F1f74Df34913DaaF69");
let l2bcm = await impersonateSigner(L2_BCM);
await mintEth(beanstalkDeployer.address);
await mintEth(l2bcm.address);
await reseedL2({
Expand Down Expand Up @@ -533,7 +507,10 @@ module.exports = {
}
},
etherscan: {
apiKey: process.env.ETHERSCAN_KEY
apiKey: {
arbitrumOne: process.env.ETHERSCAN_KEY_ARBITRUM,
mainnet: process.env.ETHERSCAN_KEY
}
},
solidity: {
compilers: [
Expand Down
105 changes: 46 additions & 59 deletions protocol/reseed/reseed10.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
const { upgradeWithNewFacets } = require("../scripts/diamond.js");
const { upgradeWithDeployedFacets } = require("../scripts/diamond.js");
const fs = require("fs");
const { retryOperation } = require("../utils/read.js");

/**
* @notice reseed9 (final step) adds all facets to beanstalk, and unpauses beanstalk.
* note: All facets will be deployed prior to running the reseed.
*/
async function reseed10(account, L2Beanstalk, mock, verbose = true) {
// get list of facets to deploy:
let facets = [
console.log("-----------------------------------");
console.log("reseed10: add all facets to L2 Beanstalk.\n");

// get list of facet names to link
let facetNames = [
"SeasonFacet", // SUN
"SeasonGettersFacet",
"GaugeGettersFacet",
Expand Down Expand Up @@ -38,67 +42,50 @@ async function reseed10(account, L2Beanstalk, mock, verbose = true) {
"L1RecieverFacet" // MIGRATION
];

// A list of public libraries that need to be deployed separately.
libraryNames = [
"LibGauge",
"LibIncentive",
"LibConvert",
"LibLockedUnderlying",
"LibWellMinting",
"LibGerminate",
"LibPipelineConvert",
"LibSilo",
"LibShipping",
"LibFlood",
"LibTokenSilo",
"LibEvaluate",
"LibSiloPermit"
// get list of facet addresses to link
const facetAddresses = [
"0x552322CD960FFB809d91012CE05d6FBB86BaE290",
"0xdf522AC66735CB506D15236CF35938588f29e34B",
"0x16b6B2Deb4b19DDb664167CF8cBE601DFA9a87e5",
"0x043a11704A9e508a2b03c4Dc38Ae60dEE369EAEC",
"0x837B2DB3ea3092E9452fCB118027aeBA1d9FfbD3",
"0xA89Fbf550A453f0eD9D75DAac706fa41eE7F9A1d",
"0xD14b7AB5fd36C770e3339A94F3763cAeC046DDCc",
"0x51757F6c0A662B4fB57E96a903b199d9D0fCd312",
"0x7eF1D0449dD48189AF968586b2F91c8294ADDC07",
"0x0D6dF5E737EF25913F6f2fA1649D0F9530c83D59",
"0xa7D49dC04ab8530509A03f9B8669ac6Bc026711f",
"0x320AaEBB1a644BEd2B86038eDE49B81072D02be0",
"0xd7a7Ec3B2EC70EdFFfB969f94436908fB53B3B85",
"0x3D5Cd5A7C7312bF005de78B09e125b34165a69Ec",
"0x35f6977D9236C0734520878799598eA0FE692965",
"0x958679Ab3CC0961F4339FaeCcbf36a1d5906cbF5",
"0x6464446d74C27961396A126b2d449aBdDea354cd",
"0xE6f9cE8737fa856e2aEeD2925DB39Fcac25c6513",
"0x47422eEEcd1cE855dcf59eE7EaEb23c6A4666699",
"0xd4A0797D7700bbA801d2DeD34e5d44480D0061Fe",
"0x4D26Caf0778D651922e89c546f09Ae852cc4933a",
"0xcC0f8117B6c0c45C15D4d306Cdb14454263f33Ba",
"0xD61E6F775dE1B0C3aC8A4b2516FEb7A935DC85Bb",
"0x6f252Ecf79aF1bd57c48047a8B109001FFB4c1DB",
"0x0b980ab39F9fDf3226b98Bc32d96EC180fd61687",
"0xD9171D21C414AE676946a60cd226b3EDa5aC3a2A",
"0x7ee24734b97902E6081D702514776416F11F971b",
"0x53106dc7D78dF1EeD36947cf0536d7eCcCa7e0b1"
];

// A mapping of facet to public library names that will be linked to it.
// MockFacets will be deployed with the same public libraries.
facetLibraries = {
SeasonFacet: [
"LibGauge",
"LibIncentive",
"LibWellMinting",
"LibGerminate",
"LibShipping",
"LibFlood",
"LibEvaluate"
],
ConvertFacet: ["LibConvert", "LibPipelineConvert", "LibSilo", "LibTokenSilo"],
PipelineConvertFacet: ["LibPipelineConvert", "LibSilo", "LibTokenSilo"],
UnripeFacet: ["LibLockedUnderlying"],
SeasonGettersFacet: ["LibLockedUnderlying", "LibWellMinting"],
SiloFacet: ["LibSilo", "LibTokenSilo", "LibSiloPermit"],
EnrootFacet: ["LibSilo", "LibTokenSilo"],
ClaimFacet: ["LibSilo", "LibTokenSilo"],
GaugeGettersFacet: ["LibLockedUnderlying"],
L1RecieverFacet: ["LibSilo", "LibTokenSilo"]
};

// A mapping of external libraries to external libraries that need to be linked.
// note: if a library depends on another library, the dependency will need to come
// before itself in `libraryNames`
libraryLinks = {
LibEvaluate: ["LibLockedUnderlying"]
};

// upgrade beanstalk with all facets. calls `InitReseed`
// link all facets to beanstalk diamond:
await retryOperation(async () => {
await upgradeWithNewFacets({
await upgradeWithDeployedFacets({
diamondAddress: L2Beanstalk,
facetNames: facets,
facetLibraries: facetLibraries,
libraryNames: libraryNames,
linkedLibraries: libraryLinks,
initFacetName: "InitReseed",
initArgs: [],
bip: false,
verbose: verbose,
account: account
facetNames: facetNames,
facetAddresses: facetAddresses,
verbose: true,
account: account,
checkGas: true
});
});

console.log("\nFacets added to L2 Beanstalk.");
}
exports.reseed10 = reseed10;
2 changes: 1 addition & 1 deletion protocol/reseed/reseedAddLiquidityAndTransfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async function reseedAddLiquidityAndTransfer(account, L2Beanstalk, mock = true,
to6("0") // to6("1000000") // BEAN/USDT
];
console.log("-----------------------------------");
console.log("add liquidity to wells and transfers to l2 beanstalk.\n");
console.log("Add liquidity to wells and transfer LP tokens to L2 beanstalk.\n");
const beanAddress = "0xBEA0005B8599265D41256905A9B3073D397812E4";
await impersonateToken(beanAddress, 6);
const bean = await ethers.getContractAt("MockToken", beanAddress);
Expand Down
Loading

0 comments on commit 2992ce9

Please sign in to comment.