Skip to content

Commit

Permalink
Add data and parsing for initial supplies and well balances (#1088)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickkatsios authored Sep 15, 2024
2 parents dd6b041 + 9c70ed2 commit fe3f07c
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 5 deletions.
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

0 comments on commit fe3f07c

Please sign in to comment.