Skip to content

Commit

Permalink
add try catch to reseed. update sunrise arb task.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brean0 committed Sep 20, 2024
1 parent bb1b9cf commit b9d231c
Show file tree
Hide file tree
Showing 14 changed files with 171 additions and 154 deletions.
31 changes: 7 additions & 24 deletions protocol/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,13 @@ task("sunrise2", async function () {

task("sunriseArb", async function () {
beanstalk = await getBeanstalk("0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70");
// call sunrise before attempting to mine more blocks:
try {
await beanstalk.sunrise();
} catch (error) {
// make a few seconds pass to avoid pump NoTimePassed() error for twa reserves right after the sunrise.
const lastTimestamp = (await ethers.provider.getBlock("latest")).timestamp;
const hourTimestamp = parseInt(lastTimestamp / 3600 + 1) * 3600;
const additionalSeconds = 12;
await network.provider.send("evm_setNextBlockTimestamp", [hourTimestamp + additionalSeconds]);

await beanstalk.sunrise();

await network.provider.send("evm_mine");
}
// Simulate the transaction to check if it would succeed
const lastTimestamp = (await ethers.provider.getBlock("latest")).timestamp;
const hourTimestamp = parseInt(lastTimestamp / 3600 + 1) * 3600;
const additionalSeconds = 12;
await network.provider.send("evm_setNextBlockTimestamp", [hourTimestamp + additionalSeconds]);
await beanstalk.sunrise();
await network.provider.send("evm_mine");
const unixTime = await time.latest();
const currentTime = new Date(unixTime * 1000).toLocaleString();

Expand Down Expand Up @@ -533,16 +526,6 @@ module.exports = {
url: "<CUSTOM_URL>",
timeout: 100000
},
reseedArbitrum: {
url: "https://virtual.arbitrum.rpc.tenderly.co/65fd0946-649e-4927-b8db-9a5ff8afa284",
chainId: 42161,
timeout: 10000000000000
},
reseedArbitrumSync: {
url: "https://virtual.arbitrum.rpc.tenderly.co/af868e07-a45a-41e7-b05f-c272e8d42cdd",
chainId: 42161,
timeout: 10000000000000
},
goerli: {
chainId: 5,
url: process.env.GOERLI_RPC || "",
Expand Down
25 changes: 14 additions & 11 deletions protocol/reseed/reseed10.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 { retryOperation } = require("../utils/read.js");

/**
* @notice reseed9 (final step) adds all facets to beanstalk, and unpauses beanstalk.
Expand Down Expand Up @@ -85,17 +86,19 @@ async function reseed10(account, L2Beanstalk, mock, verbose = true) {
};

// upgrade beanstalk with all facets. calls `InitReseed`
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: facets,
facetLibraries: facetLibraries,
libraryNames: libraryNames,
linkedLibraries: libraryLinks,
initFacetName: "InitReseed",
initArgs: [],
bip: false,
verbose: verbose,
account: account
await retryOperation(async () => {
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: facets,
facetLibraries: facetLibraries,
libraryNames: libraryNames,
linkedLibraries: libraryLinks,
initFacetName: "InitReseed",
initArgs: [],
bip: false,
verbose: verbose,
account: account
});
});
}
exports.reseed10 = reseed10;
50 changes: 22 additions & 28 deletions protocol/reseed/reseed2.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const { impersonateSigner } = require("../utils/index.js");
const { upgradeWithNewFacets } = require("../scripts/diamond.js");
const fs = require("fs");
const { deployMockToken, getWellContractAt } = require("../utils/well.js");
const { deployBasinV1_2Components, deployUpgradeableWell } = require("../scripts/basinV1_2.js");
const { retryOperation } = require("../utils/read.js");

// Files
const INIT_SUPPLY = "./reseed/data/r2/L2_initial_supply.json";
Expand All @@ -15,7 +13,7 @@ const EXTERNAL_UNRIPE_BEAN_LP = "./reseed/data/r2/L2_external_unripe_lp_balances
* 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.
*/
async function reseed2(account, L2Beanstalk, deployBasin = false, fertilizerImplementation, mock) {
async function reseed2(account, L2Beanstalk, fertilizerImplementation, mock) {
verbose = true;
console.log("-----------------------------------");
console.log("reseed2: deploy bean tokens.\n");
Expand All @@ -26,36 +24,32 @@ async function reseed2(account, L2Beanstalk, deployBasin = false, fertilizerImpl
externalUrBean = JSON.parse(await fs.readFileSync(EXTERNAL_UNRIPE_BEAN));
externalUrBeanLP = JSON.parse(await fs.readFileSync(EXTERNAL_UNRIPE_BEAN_LP));

if (deployBasin) {
[uWell, stable2] = await deployBasinV1_2Components();
console.log("uWell:", uWell.address);
console.log("stable2:", stable2.address);
}

// get the bean sided liquidity from the L1 wells to mint it to the bcm.
const beansInBeanEthWell = balancesInBeanEthWell[0];
const beansInBeanWstEthWell = balancesInBeanWstEthWell[0];
const beansInBeanStableWell = balancesInBeanStableWell[0];

// call init:
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedBean",
initArgs: [
beanSupply,
unripeBeanSupply,
unripeLpSupply,
beansInBeanEthWell,
beansInBeanWstEthWell,
beansInBeanStableWell,
externalUrBean,
externalUrBeanLP,
fertilizerImplementation
],
bip: false,
verbose: false,
account: account
await retryOperation(async () => {
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedBean",
initArgs: [
beanSupply,
unripeBeanSupply,
unripeLpSupply,
beansInBeanEthWell,
beansInBeanWstEthWell,
beansInBeanStableWell,
externalUrBean,
externalUrBeanLP,
fertilizerImplementation
],
bip: false,
verbose: false,
account: account
});
});

console.log("-----------------------------------");
Expand Down
4 changes: 2 additions & 2 deletions protocol/reseed/reseed3.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ async function reseed3(account, L2Beanstalk, mock, verbose = false) {
initFacetName: "ReseedPodMarket",
initArgs: [podListings, podOrders],
bip: false,
verbose: true,
verbose: verbose,
account: account,
checkGas: true
});
console.log("-----------------------------------");
}

exports.reseed3 = reseed3;
exports.reseed3 = reseed3;
25 changes: 14 additions & 11 deletions protocol/reseed/reseed4.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 { splitEntriesIntoChunksOptimized, updateProgress } = require("../utils/read.js");
const { retryOperation } = require("../utils/read.js");

async function reseed4(account, L2Beanstalk, mock, verbose = false) {
console.log("-----------------------------------");
Expand All @@ -27,17 +28,19 @@ async function reseed4(account, L2Beanstalk, mock, verbose = false) {
console.log("Data chunk:", plotChunks[i]);
console.log("-----------------------------------");
}
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedField",
initFacetAddress: InitFacet.address,
initArgs: [plotChunks[i]],
bip: false,
verbose: verbose,
account: account,
checkGas: true,
initFacetNameInfo: "ReseedField"
await retryOperation(async () => {
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedField",
initFacetAddress: InitFacet.address,
initArgs: [plotChunks[i]],
bip: false,
verbose: verbose,
account: account,
checkGas: true,
initFacetNameInfo: "ReseedField"
});
});
}
}
Expand Down
25 changes: 14 additions & 11 deletions protocol/reseed/reseed5.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 { splitEntriesIntoChunksOptimized, updateProgress } = require("../utils/read.js");
const { retryOperation } = require("../utils/read.js");

async function reseed5(account, L2Beanstalk, mock, verbose = false) {
console.log("-----------------------------------");
Expand All @@ -26,17 +27,19 @@ async function reseed5(account, L2Beanstalk, mock, verbose = false) {
console.log("Data chunk:", fertChunks[i]);
console.log("-----------------------------------");
}
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedBarn",
initFacetAddress: InitFacet.address,
initArgs: [fertChunks[i]],
bip: false,
verbose: verbose,
account: account,
checkGas: true,
initFacetNameInfo: "ReseedBarn"
await retryOperation(async () => {
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedBarn",
initFacetAddress: InitFacet.address,
initArgs: [fertChunks[i]],
bip: false,
verbose: verbose,
account: account,
checkGas: true,
initFacetNameInfo: "ReseedBarn"
});
});
}
}
Expand Down
26 changes: 14 additions & 12 deletions protocol/reseed/reseed6.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 { splitEntriesIntoChunksOptimized, updateProgress } = require("../utils/read.js");

const { retryOperation } = require("../utils/read.js");
async function reseed6(account, L2Beanstalk, mock, verbose = false) {
console.log("-----------------------------------");
console.log("reseed6: reissue deposits.\n");
Expand All @@ -25,17 +25,19 @@ async function reseed6(account, L2Beanstalk, mock, verbose = false) {
console.log("Data chunk:", depositChunks[i]);
console.log("-----------------------------------");
}
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedSilo",
initFacetAddress: InitFacet.address,
initArgs: [depositChunks[i]],
bip: false,
verbose: verbose,
account: account,
checkGas: true,
initFacetNameInfo: "ReseedSilo"
await retryOperation(async () => {
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedSilo",
initFacetAddress: InitFacet.address,
initArgs: [depositChunks[i]],
bip: false,
verbose: verbose,
account: account,
checkGas: true,
initFacetNameInfo: "ReseedSilo"
});
});
}
}
Expand Down
23 changes: 13 additions & 10 deletions protocol/reseed/reseed7.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 { splitEntriesIntoChunksOptimized, updateProgress } = require("../utils/read.js");
const { retryOperation } = require("../utils/read.js");

async function reseed7(account, L2Beanstalk, mock, verbose = false) {
console.log("-----------------------------------");
Expand All @@ -27,16 +28,18 @@ async function reseed7(account, L2Beanstalk, mock, verbose = false) {
console.log("Data chunk:", statusChunks[i]);
console.log("-----------------------------------");
}
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedAccountStatus",
initFacetAddress: InitFacet.address,
initArgs: [statusChunks[i]],
bip: false,
verbose: verbose,
account: account,
initFacetNameInfo: "ReseedAccountStatus"
await retryOperation(async () => {
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedAccountStatus",
initFacetAddress: InitFacet.address,
initArgs: [statusChunks[i]],
bip: false,
verbose: verbose,
account: account,
initFacetNameInfo: "ReseedAccountStatus"
});
});
}
}
Expand Down
25 changes: 14 additions & 11 deletions protocol/reseed/reseed8.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 { splitEntriesIntoChunksOptimized, updateProgress } = require("../utils/read.js");
const { retryOperation } = require("../utils/read.js");

async function reseed8(account, L2Beanstalk, mock, verbose = false) {
console.log("-----------------------------------");
Expand Down Expand Up @@ -28,17 +29,19 @@ async function reseed8(account, L2Beanstalk, mock, verbose = false) {
console.log("Data chunk:", balanceChunks[i]);
console.log("-----------------------------------");
}
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedInternalBalances",
initFacetAddress: InitFacet.address,
initArgs: [balanceChunks[i]],
bip: false,
verbose: verbose,
account: account,
checkGas: true,
initFacetNameInfo: "ReseedInternalBalances"
await retryOperation(async () => {
await upgradeWithNewFacets({
diamondAddress: L2Beanstalk,
facetNames: [],
initFacetName: "ReseedInternalBalances",
initFacetAddress: InitFacet.address,
initArgs: [balanceChunks[i]],
bip: false,
verbose: verbose,
account: account,
checkGas: true,
initFacetNameInfo: "ReseedInternalBalances"
});
});
}
}
Expand Down
Loading

0 comments on commit b9d231c

Please sign in to comment.