Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data and parsing for initial supplies and well balances #1088

Merged
merged 3 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {C} from "contracts/C.sol";
*/
contract ReseedInternalBalances {
AppStorage internal s;
event InternalBalanceMigrated(address indexed user, IERC20 indexed token, int256 delta);
event InternalBalanceMigrated(address indexed account, IERC20 indexed token, int256 delta);

struct BeanstalkInternalBalance {
address farmer;
Expand Down
21 changes: 21 additions & 0 deletions protocol/reseed/data/exports/contract-circulating20736200.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"beanstalk": {
"beans": "32952499881747",
"unripeBeans": "107495547853813",
"unripeLp": "67632589795645"
},
"pools": {
"beanweth": {
"bean": "107380655868",
"weth": "20582720189638019906"
},
"beanwsteth": {
"bean": "14544578478380",
"wsteth": "2361659050325418670234"
},
"bean3crv": {
"bean": "83855245277",
"3crv": "20668624046092866087554"
}
}
}
6 changes: 5 additions & 1 deletion protocol/reseed/data/r2/L2_initial_supply.json
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
["10000000000", "10000000000", "10000000000"]
[
"32952499881747",
"107495547853813",
"67632589795645"
]
6 changes: 3 additions & 3 deletions protocol/reseed/data/r2/L2_well_balances.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
["1000000000", "10000000000000"],
["1000000000", "1000000000000"],
["1000000000", "1000000000"]
["107380655868", "20582720189638019906"],
["14544578478380", "2361659050325418670234"],
["83855245277", "20668624046092866087554"]
]
33 changes: 33 additions & 0 deletions protocol/reseed/dataConverts/convertTokens.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const fs = require("fs");
const { convertToBigNum } = require("../../utils/read.js"); // Assuming you have a conversion utility function

function parseTokens(inputFilePath, outputFilePaths) {
try {
// Read the input file
const data = JSON.parse(fs.readFileSync(inputFilePath, "utf8"));

// Extract the initial supply from the "beanstalk" section
const L2_initial_supply = [
data.beanstalk.beans,
data.beanstalk.unripeBeans,
data.beanstalk.unripeLp
];

// Extract the well balances from the "pools" section
const L2_well_balances = [
[data.pools.beanweth.bean, data.pools.beanweth.weth],
[data.pools.beanwsteth.bean, data.pools.beanwsteth.wsteth],
[data.pools.bean3crv.bean, data.pools.bean3crv["3crv"]]
];

// Write the JSON files to the specified output paths
fs.writeFileSync(outputFilePaths.L2_initial_supply, JSON.stringify(L2_initial_supply, null, 2));
fs.writeFileSync(outputFilePaths.L2_well_balances, JSON.stringify(L2_well_balances, null, 2));

console.log("Token Reserves and Supplies JSONs have been written successfully");
} catch (err) {
console.error("Error:", err);
}
}

exports.parseTokens = parseTokens;
8 changes: 8 additions & 0 deletions protocol/reseed/reseedL2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { parseFertilizer } = require("./dataConverts/convertFert.js");
const { parsePodMarketplace } = require("./dataConverts/convertPodMarketplace.js");
const { parseGlobals } = require("./dataConverts/convertGlobal.js");
const { parseExternalHolders } = require("./dataConverts/convertExternalHolders.js");
const { parseTokens } = require("./dataConverts/convertTokens.js");
const { reseedDeployL2Beanstalk } = require("./reseedDeployL2Beanstalk.js");
const { reseed2 } = require("./reseed2.js");
const { reseed3 } = require("./reseed3.js");
Expand Down Expand Up @@ -177,6 +178,13 @@ function parseBeanstalkData() {
"./reseed/data/r2/L2_external_unripe_lp_balances.json",
contractAccounts
);
// Initial supplies and well balances
const reserveSupplyJsonPath = `./reseed/data/exports/contract-circulating${BLOCK_NUMBER}.json`
const outputFilePaths = {
L2_initial_supply: "./reseed/data/r2/L2_initial_supply.json",
L2_well_balances: "./reseed/data/r2/L2_well_balances.json"
};
parseTokens(reserveSupplyJsonPath, outputFilePaths);
parseWhitelist(storageSystemPath, "./reseed/data/r9-whitelist.json");
}

Expand Down
Loading