Skip to content

Commit

Permalink
adding july august sept
Browse files Browse the repository at this point in the history
  • Loading branch information
Defi-Moses committed Sep 4, 2024
1 parent 1630b19 commit 00fdd9a
Show file tree
Hide file tree
Showing 8 changed files with 1,136 additions and 239 deletions.
55 changes: 27 additions & 28 deletions components/pastHoldings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,28 @@ const MonthList = () => {
// Update the useEffect hook
useEffect(() => {
console.log('useEffect triggered');
const months = Array.from({ length: 12 }, (_, i) => i + 1); // Months from 1 to 12
const years = [2023, 2024]; // Include both 2023 and 2024
const months = Array.from({ length: 12 }, (_, i) => i + 1);
const years = [2023, 2024];
const currentYear = new Date().getFullYear();
const currentMonth = new Date().getMonth();

// Fetch treasury sums for both years, up to January 2024
Promise.all(
years.flatMap((year) =>
months.map((month) =>
(year < 2024 || (year === 2024 && month < 7)) ?
fetch(`/api/data?file=treasurySums_${month}_${year}.csv&type=summary`).then((response) => response.json()) :
Promise.resolve(null) // Resolve to null for dates beyond January 2024
Promise.all(
years.flatMap((year) =>
months.map((month) =>
(year < 2024 || (year === 2024 && month <= 9)) ?
fetch(`/api/data?file=treasurySums_${month}_${year}.csv&type=summary`)
.then((response) => response.json())
.catch(() => null) : // Return null for missing data
Promise.resolve(null)
)
)
)
)
.then((csvData) => {
console.log('Fetched CSV data:', csvData);
const monthlyTotals = csvData.reduce((acc, curr, index) => {
if (!curr) return acc; // Skip if current is null
const year = years[Math.floor(index / 12)]; // Determine the year based on index
const month = months[index % 12]; // Determine the month based on index
if (year < 2024 || (year === 2024 && month < 7)) {
acc[`${month}/${year}`] = Object.values(curr).reduce((a, b) => a + b, 0);
}
const year = years[Math.floor(index / 12)];
const month = months[index % 12];
acc[`${month}/${year}`] = curr ? Object.values(curr).reduce((a, b) => a + b, 0) : null;
return acc;
}, {});
console.log('Monthly totals:', monthlyTotals);
Expand All @@ -52,20 +50,21 @@ Promise.all(
console.error('Error fetching CSV data:', error);
});

// Fetch token data for both years, up to January 2024
Promise.all(
years.flatMap((year) =>
months.map((month) =>
(year < 2024 || (year === 2024 && month < 7 )) ?
fetch(`/api/data?file=treasuryHoldings_${month}_${year}.csv&type=breakdown`).then((response) => response.json()) :
Promise.resolve([]) // Resolve to an empty array for dates beyond January 2024
Promise.all(
years.flatMap((year) =>
months.map((month) =>
(year < 2024 || (year === 2024 && month <= 9)) ?
fetch(`/api/data?file=treasuryHoldings_${month}_${year}.csv&type=breakdown`)
.then((response) => response.json())
.catch(() => null) : // Return null for missing data
Promise.resolve(null)
)
)
)
)
.then((monthlyData) => {
console.log('Fetched monthly token data:', monthlyData);
const sortedMonthlyData = monthlyData.map((data) => {
if (!data) return []; // Skip if data is null
if (!data) return null; // Return null for missing data
const sortedData = Object.entries(data)
.filter(([key]) => key !== 'SYN')
.map(([key, value]) => {
Expand Down Expand Up @@ -119,9 +118,9 @@ return (
{Object.entries(csvData).map(([key, value], index) => {
const [month, year] = key.split('/');
const formattedMonth = monthNames[parseInt(month) - 1] ? `${monthNames[parseInt(month) - 1]} ${year}` : '0';
const fee = monthlyFees[key] ? formatToDollar(monthlyFees[key]) : '0';
const holding = value ? formatToDollar(value) : '0';
const currentTokenData = tokenData && tokenData[index] ? tokenData[index] : '0';
const fee = monthlyFees[key] ? formatToDollar(monthlyFees[key]) : '-';
const holding = value !== null ? formatToDollar(value) : '-';
const currentTokenData = tokenData && tokenData[index] ? tokenData[index] : null;

return <Row key={index} month={formattedMonth} fee={fee} holding={holding} tokenData={currentTokenData} />;
})}
Expand Down
384 changes: 194 additions & 190 deletions public/data/currentTreasuryHoldings.csv

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions public/data/sums.csv
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Chain,Claimed Fees,Unclaimed Fees,Swap Unclaimed Fees,CCTP Unclaimed Fees
arbitrum,439806.83109765314,541431.6012784924,79426.38928457972,16157.51422
aurora,0.0,127758.58902687287,66029.93353834742,0
avax,793500.7341265669,35109.681787528614,3615.8503460962083,4024.472917
base,205885.31594396473,95133.1486825101,73857.54527856513,0.0
blast,0.0,172026.2156164475,432782.8361079386,0
boba,53505.58370270311,151449.5889971666,62208.37658931585,0.0
bsc,151.56085469929678,330059.4383254599,403037.3705802165,0.0
canto,0.0,170179.64410893785,10001.493803164092,0.0
cronos,0.0,29087.835690751333,2872.642243716898,0.0
dfk,0.0,166055.47902728594,0,0.0
dogechain,0.0,6562.952321206967,0,0.0
ethereum,8590670.71,612857.7727789145,29277.996018362475,0.0
fantom,1382.1722519243312,15488.227549702788,0.15024795490661397,0
harmony,10458.072473383754,96.9577172579189,0.6797312394409456,0
metis,234962.46774938697,125291.97141100674,20003.069775448184,0
moonbeam,0.0,333.7876505510277,0,0
moonriver,0.0,203.71185646535815,0,0.0
optimism,248920.22323962333,506873.1428,97693.28192136742,7057.238247
polygon,9594.352631296548,27178.299628592704,12536.151412320516,0
klaytn,0.0,36449.95059389585,0,0.0
arbitrum,403479.0623867768,474387.0244612467,76172.9633986631,20614.430841
aurora,0.0,127786.58902687287,65933.46204291226,0
avax,764363.8484498779,35577.33234125424,4157.492793740005,4845.361056
base,161220.5054521944,78141.59778343677,61090.87406354613,0.0
blast,0.0,152886.9990280293,413213.69109635975,0
boba,41853.34283595817,145340.44472288433,58129.15420851766,0.0
bsc,137.63745100953278,333480.75547706307,407861.3078730745,0.0
canto,0.0,165466.87095789728,7864.772622457285,0.0
cronos,0.0,29362.821508839854,2889.492292647915,0.0
dfk,0.0,161220.46655867292,0,0.0
dogechain,0.0,5959.64220441794,0,0.0
ethereum,8410729.585136026,686605.3380925693,38315.16060740162,0.0
fantom,1236.7235057041153,16275.105469343755,0.19595944605286678,0
harmony,8175.906108762055,94.0573772579189,0.6822185984160258,0
metis,220850.85733137862,129717.23405862565,17636.077923990593,0
moonbeam,0.0,300.2855358278497,0,0
moonriver,0.0,199.9840972658019,0,0.0
optimism,277798.83246691216,375326.35597707174,86056.03047182037,7948.796933
polygon,7296.023293212716,40435.32384582306,24650.22375498966,0
klaytn,0.0,32855.66599171731,0,0.0
Loading

0 comments on commit 00fdd9a

Please sign in to comment.