Skip to content

Commit

Permalink
reuse deployed init scripts, set deployed shippment planner
Browse files Browse the repository at this point in the history
  • Loading branch information
nickkatsios committed Sep 30, 2024
1 parent 579061d commit ae235d2
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 83 deletions.
49 changes: 2 additions & 47 deletions protocol/reseed/dataConverts/convertGlobal.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,52 +128,7 @@ function parseGlobals(inputFilePath, outputFilePath) {
data.rain?.roots ? convertToBigNum(data.rain.roots) : "0",
Array(4).fill("0x0000000000000000000000000000000000000000000000000000000000000000")
],
// seedGaugeSettings
// [
// data.seedGaugeSettings?.maxBeanMaxLpGpPerBdvRatio
// ? convertToBigNum(data.seedGaugeSettings.maxBeanMaxLpGpPerBdvRatio)
// : "0",
// data.seedGaugeSettings?.minBeanMaxLpGpPerBdvRatio
// ? convertToBigNum(data.seedGaugeSettings.minBeanMaxLpGpPerBdvRatio)
// : "0",
// data.seedGaugeSettings?.targetSeasonsToCatchUp
// ? convertToBigNum(data.seedGaugeSettings.targetSeasonsToCatchUp)
// : "0",
// data.seedGaugeSettings?.podRateLowerBound
// ? convertToBigNum(data.seedGaugeSettings.podRateLowerBound)
// : "0",
// data.seedGaugeSettings?.podRateOptimal
// ? convertToBigNum(data.seedGaugeSettings.podRateOptimal)
// : "0",
// data.seedGaugeSettings?.podRateUpperBound
// ? convertToBigNum(data.seedGaugeSettings.podRateUpperBound)
// : "0",
// data.seedGaugeSettings?.deltaPodDemandLowerBound
// ? convertToBigNum(data.seedGaugeSettings.deltaPodDemandLowerBound)
// : "0",
// data.seedGaugeSettings?.deltaPodDemandUpperBound
// ? convertToBigNum(data.seedGaugeSettings.deltaPodDemandUpperBound)
// : "0",
// data.seedGaugeSettings?.lpToSupplyRatioUpperBound
// ? convertToBigNum(data.seedGaugeSettings.lpToSupplyRatioUpperBound)
// : "0",
// data.seedGaugeSettings?.lpToSupplyRatioOptimal
// ? convertToBigNum(data.seedGaugeSettings.lpToSupplyRatioOptimal)
// : "0",
// data.seedGaugeSettings?.lpToSupplyRatioLowerBound
// ? convertToBigNum(data.seedGaugeSettings.lpToSupplyRatioLowerBound)
// : "0",
// data.seedGaugeSettings?.excessivePriceThreshold
// ? convertToBigNum(data.seedGaugeSettings.excessivePriceThreshold)
// : "0",
// data.seedGaugeSettings?.soilCoefficientHigh
// ? convertToBigNum(data.seedGaugeSettings.soilCoefficientHigh)
// : "0",
// data.seedGaugeSettings?.baseReward ? convertToBigNum(data.seedGaugeSettings.baseReward) : "0",
// data.seedGaugeSettings?.excessivePriceThreshold
// ? convertToBigNum(data.seedGaugeSettings.excessivePriceThreshold)
// : "0"
// ],
// Evaluation Parameters
[
"100000000000000000000",
"50000000000000000000",
Expand All @@ -194,7 +149,7 @@ function parseGlobals(inputFilePath, outputFilePath) {
// ShipmentRoute
data.shipmentRoutes.length
? data.shipmentRoutes.map((route) => [
route.planContract || "0x0000000000000000000000000000000000000000",
"0x555555987d98079b9f43CDcDBD52DbB24FfEEef5", // l2 shipment planner
route.planSelector || "0x00000000",
route.recipient ? convertToBigNum(route.recipient) : "0",
route.data || "0x"
Expand Down
9 changes: 4 additions & 5 deletions protocol/reseed/reseed2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { upgradeWithNewFacets } = require("../scripts/diamond.js");
const fs = require("fs");
const { retryOperation } = require("../utils/read.js");
const { L2_FERTILIZER } = require("../test/hardhat/utils/constants.js");
const { L2_FERTILIZER, L2_RESEED_BEAN } = require("../test/hardhat/utils/constants.js");

// Files
const INIT_SUPPLY = "./reseed/data/r2/L2_initial_supply.json";
Expand All @@ -10,10 +10,8 @@ const EXTERNAL_UNRIPE_BEAN = "./reseed/data/r2/L2_external_unripe_balances.json"
const EXTERNAL_UNRIPE_BEAN_LP = "./reseed/data/r2/L2_external_unripe_lp_balances.json";

/**
* reseed8 approves beanstalk to use the BCM's wsteth, eth, and a stablecoin,
* where it will 1) transfer to a well 2) sync and add liquidity, upon deployment.
* note: for testing purposes, the L2 is on base, and the stablecoin is USDC, but can be switched based on the discretion of the DAO.
*/
* reseed2 re-initializes the bean tokens mints beans to the bcm and deploys the upgradeable wells
**/
async function reseed2(account, L2Beanstalk, mock, verbose) {
verbose = true;
console.log("-----------------------------------");
Expand All @@ -36,6 +34,7 @@ async function reseed2(account, L2Beanstalk, mock, verbose) {
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedBean",
initFacetAddress: L2_RESEED_BEAN,
initArgs: [
beanSupply,
unripeBeanSupply,
Expand Down
5 changes: 2 additions & 3 deletions protocol/reseed/reseed3.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { upgradeWithNewFacets } = require("../scripts/diamond.js");
const fs = require("fs");
const { splitEntriesIntoChunksOptimized, updateProgress } = require("../utils/read.js");
const { retryOperation } = require("../utils/read.js");
const { L2_RESEED_FIELD } = require("../test/hardhat/utils/constants.js");

async function reseed3(account, L2Beanstalk, mock, verbose = false) {
console.log("-----------------------------------");
Expand All @@ -19,8 +20,6 @@ async function reseed3(account, L2Beanstalk, mock, verbose = false) {

targetEntriesPerChunk = 500;
plotChunks = await splitEntriesIntoChunksOptimized(accountPlots, targetEntriesPerChunk);
const InitFacet = await (await ethers.getContractFactory("ReseedField", account)).deploy();
await InitFacet.deployed();
console.log(`Starting to process ${plotChunks.length} chunks...`);
for (let i = 0; i < plotChunks.length; i++) {
await updateProgress(i + 1, plotChunks.length);
Expand All @@ -33,7 +32,7 @@ async function reseed3(account, L2Beanstalk, mock, verbose = false) {
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedField",
initFacetAddress: InitFacet.address,
initFacetAddress: L2_RESEED_FIELD,
initArgs: [plotChunks[i]],
bip: false,
verbose: verbose,
Expand Down
2 changes: 2 additions & 0 deletions protocol/reseed/reseed4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { upgradeWithNewFacets } = require("../scripts/diamond.js");
const fs = require("fs");
const { L2_RESEED_POD_MARKETPLACE } = require("../test/hardhat/utils/constants.js");

async function reseed4(account, L2Beanstalk, mock, verbose = false) {
console.log("-----------------------------------");
Expand All @@ -21,6 +22,7 @@ async function reseed4(account, L2Beanstalk, mock, verbose = false) {
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedPodMarket",
initFacetAddress: L2_RESEED_POD_MARKETPLACE,
initArgs: [podListings, podOrders],
bip: false,
verbose: verbose,
Expand Down
5 changes: 2 additions & 3 deletions protocol/reseed/reseed5.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { upgradeWithNewFacets } = require("../scripts/diamond.js");
const fs = require("fs");
const { splitEntriesIntoChunksOptimized, updateProgress } = require("../utils/read.js");
const { retryOperation } = require("../utils/read.js");
const { L2_RESEED_BARN } = require("../test/hardhat/utils/constants.js");

async function reseed5(account, L2Beanstalk, mock, verbose = false) {
console.log("-----------------------------------");
Expand All @@ -19,8 +20,6 @@ async function reseed5(account, L2Beanstalk, mock, verbose = false) {
// Keep this lower due to fert id 100663296
targetEntriesPerChunk = 50;
fertChunks = await splitEntriesIntoChunksOptimized(fertilizerIds, targetEntriesPerChunk);
const InitFacet = await (await ethers.getContractFactory("ReseedBarn", account)).deploy();
await InitFacet.deployed();
for (let i = 0; i < fertChunks.length; i++) {
await updateProgress(i + 1, fertChunks.length);
if (verbose) {
Expand All @@ -32,7 +31,7 @@ async function reseed5(account, L2Beanstalk, mock, verbose = false) {
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedBarn",
initFacetAddress: InitFacet.address,
initFacetAddress: L2_RESEED_BARN,
initArgs: [fertChunks[i]],
bip: false,
verbose: verbose,
Expand Down
6 changes: 3 additions & 3 deletions protocol/reseed/reseed6.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const { upgradeWithNewFacets } = require("../scripts/diamond.js");
const fs = require("fs");
const { splitEntriesIntoChunksOptimized, updateProgress } = require("../utils/read.js");
const { retryOperation } = require("../utils/read.js");
const { L2_RESEED_SILO } = require("../test/hardhat/utils/constants.js");

async function reseed6(account, L2Beanstalk, mock, verbose = false) {
console.log("-----------------------------------");
console.log("reseed6: reissue deposits.\n");
Expand All @@ -17,8 +19,6 @@ async function reseed6(account, L2Beanstalk, mock, verbose = false) {

targetEntriesPerChunk = 400;
depositChunks = await splitEntriesIntoChunksOptimized(beanDeposits, targetEntriesPerChunk);
const InitFacet = await (await ethers.getContractFactory("ReseedSilo", account)).deploy();
await InitFacet.deployed();
for (let i = 0; i < depositChunks.length; i++) {
await updateProgress(i + 1, depositChunks.length);
if (verbose) {
Expand All @@ -30,7 +30,7 @@ async function reseed6(account, L2Beanstalk, mock, verbose = false) {
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedSilo",
initFacetAddress: InitFacet.address,
initFacetAddress: L2_RESEED_SILO,
initArgs: [depositChunks[i]],
bip: false,
verbose: verbose,
Expand Down
7 changes: 2 additions & 5 deletions protocol/reseed/reseed7.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { upgradeWithNewFacets } = require("../scripts/diamond.js");
const fs = require("fs");
const { splitEntriesIntoChunksOptimized, updateProgress } = require("../utils/read.js");
const { retryOperation } = require("../utils/read.js");
const { L2_RESEED_ACCOUNT_STATUS } = require("../test/hardhat/utils/constants.js");

async function reseed7(account, L2Beanstalk, mock, verbose = false) {
console.log("-----------------------------------");
Expand All @@ -18,10 +19,6 @@ async function reseed7(account, L2Beanstalk, mock, verbose = false) {

targetEntriesPerChunk = 400;
statusChunks = await splitEntriesIntoChunksOptimized(statuses, targetEntriesPerChunk);
const InitFacet = await (
await ethers.getContractFactory("ReseedAccountStatus", account)
).deploy();
await InitFacet.deployed();
for (let i = 0; i < statusChunks.length; i++) {
await updateProgress(i + 1, statusChunks.length);
if (verbose) {
Expand All @@ -33,7 +30,7 @@ async function reseed7(account, L2Beanstalk, mock, verbose = false) {
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedAccountStatus",
initFacetAddress: InitFacet.address,
initFacetAddress: L2_RESEED_ACCOUNT_STATUS,
initArgs: [statusChunks[i]],
bip: false,
verbose: verbose,
Expand Down
7 changes: 2 additions & 5 deletions protocol/reseed/reseed8.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { upgradeWithNewFacets } = require("../scripts/diamond.js");
const fs = require("fs");
const { splitEntriesIntoChunksOptimized, updateProgress } = require("../utils/read.js");
const { retryOperation } = require("../utils/read.js");
const { L2_RESEED_INTERNAL_BALANCES } = require("../test/hardhat/utils/constants.js");

async function reseed8(account, L2Beanstalk, mock, verbose = false) {
console.log("-----------------------------------");
Expand All @@ -19,10 +20,6 @@ async function reseed8(account, L2Beanstalk, mock, verbose = false) {

targetEntriesPerChunk = 500;
balanceChunks = await splitEntriesIntoChunksOptimized(beanBalances, targetEntriesPerChunk);
const InitFacet = await (
await ethers.getContractFactory("ReseedInternalBalances", account)
).deploy();
await InitFacet.deployed();
for (let i = 0; i < balanceChunks.length; i++) {
await updateProgress(i + 1, balanceChunks.length);
if (verbose) {
Expand All @@ -34,7 +31,7 @@ async function reseed8(account, L2Beanstalk, mock, verbose = false) {
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedInternalBalances",
initFacetAddress: InitFacet.address,
initFacetAddress: L2_RESEED_INTERNAL_BALANCES,
initArgs: [balanceChunks[i]],
bip: false,
verbose: verbose,
Expand Down
2 changes: 2 additions & 0 deletions protocol/reseed/reseed9.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { upgradeWithNewFacets } = require("../scripts/diamond.js");
const fs = require("fs");
const { retryOperation } = require("../utils/read.js");
const { L2_RESEED_WHITELIST } = require("../test/hardhat/utils/constants.js");

async function reseed9(account, L2Beanstalk, mock = false) {
console.log("-----------------------------------");
Expand All @@ -26,6 +27,7 @@ async function reseed9(account, L2Beanstalk, mock = false) {
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedWhitelist",
initFacetAddress: L2_RESEED_WHITELIST,
initArgs: [tokens, nonBeanTokens, siloSettings, whitelistStatuses, oracles],
bip: false,
verbose: true,
Expand Down
8 changes: 0 additions & 8 deletions protocol/reseed/reseedGlobal.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ async function reseedGlobal(account, L2Beanstalk, mock) {
let globalsPath = "./reseed/data/global.json";
let settings = JSON.parse(await fs.readFileSync(globalsPath));

// deploy ShipmentPlanner.sol.
const ShipmentPlanner = await deployContract("ShipmentPlanner", account, true, [L2Beanstalk]);

// replace the shipment parameter with the deployed shipment address.
settings[9][0][0] = ShipmentPlanner.address;
settings[9][1][0] = ShipmentPlanner.address;
settings[9][2][0] = ShipmentPlanner.address;

await retryOperation(async () => {
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
Expand Down
7 changes: 4 additions & 3 deletions protocol/reseed/reseedL1.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { printBeanstalk } = require("./reseedL2.js");
* - pausing beanstalk.
* - transferring bean LP tokens to BCM.
*/
async function reseedL1(account) {
async function reseedL1(account, mock) {
await printBeanstalk();
beanstalkSelectors = [];
console.log("-----------------------------------");
Expand Down Expand Up @@ -47,11 +47,12 @@ async function reseedL1(account) {
await upgradeWithNewFacets({
diamondAddress: BEANSTALK,
facetNames: ["L2MigrationFacet", "L1TokenFacet"],
facetsToRemove: beanstalkSelectors,
selectorsToRemove: beanstalkSelectors,
initFacetName: "ReseedL2Migration",
bip: false,
verbose: true,
account: account
account: account,
object: !mock
});
console.log("Beanstalk is now paused and bean LP tokens are transferred to BCM.");
console.log("-----------------------------------");
Expand Down
1 change: 0 additions & 1 deletion protocol/reseed/reseedL2.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ async function reseedL2({
setState = true,
addLiquidity = true,
verbose = false,
onlyState = true
}) {
if (convertData) parseBeanstalkData();
// delete prev gas report
Expand Down
10 changes: 10 additions & 0 deletions protocol/test/hardhat/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,15 @@ module.exports = {
L2_FERTILIZER: "0xFEFEFE2cfb089aEF0b0578573eF3CFAbC15f1490",
L2_BCM: "0xDd5b31E73dB1c566Ca09e1F1f74Df34913DaaF69",

L2_RESEED_BEAN: "0x75C1212d7717f5aAa1179c6a71c9afc56ECddD85",
L2_RESEED_GLOBAL: "0x81D652b45627F699DCA555150B344DF4FC4b2057",
L2_RESEED_FIELD: "0x3EEE6CcbF41173b18C133200B1762A8D714AEA72",
L2_RESEED_POD_MARKETPLACE: "0x242bf5D0eB3aB66D431286a1B2EeA704e9745163",
L2_RESEED_BARN: "0xEA4b9B59a52fEeb98E8Cb7380b791e0126818266",
L2_RESEED_SILO: "0xb85aAA766C8FF08987BaF598e44264122675cD94",
L2_RESEED_ACCOUNT_STATUS: "0x0ee2c983874B4Faf3c1352eA0271c5810ba64B29",
L2_RESEED_INTERNAL_BALANCES: "0x36Afd58C440321fDf14B8311D019814eb94CEA20",
L2_RESEED_WHITELIST: "0xE657b28ba8F9c08Ac6C7efC669C0625Da704E4ef",

ZERO_BYTES: "0x0000000000000000000000000000000000000000000000000000000000000000"
};

0 comments on commit ae235d2

Please sign in to comment.