Skip to content

Commit

Permalink
Add group sums calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaman1337 committed Sep 19, 2024
1 parent ddae95b commit f5498e3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions protocol/scripts/beanstalk-3/beanstalk-3-Contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ function processPlots(plots, maxPlotsPerAddress = 435) {
// Sort the plots by size in descending order
plotData.sort((a, b) => (b.size > a.size ? 1 : -1));

// sum the total of the first 435 plots, then the next 435 plots, etc.
let groupSums = [];
for (let i = 0; i < plotData.length; i += maxPlotsPerAddress) {
let groupSum = plotData
.slice(i, i + maxPlotsPerAddress)
.reduce((sum, plot) => sum + plot.size, BigInt(0));
groupSums.push(groupSum.toString());
}

console.log("Group sums for address:", address);
console.log(groupSums);

// Keep only the top 435 plots
plotData = plotData.slice(0, maxPlotsPerAddress);

Expand Down

0 comments on commit f5498e3

Please sign in to comment.