@@ -2,6 +2,9 @@ import {FeeAllocations} from "./maxiStaticTypes";
22import React , { useEffect , useState } from 'react' ;
33import historicalData from './static/historical_fee_allocations_monthly.json' ;
44
5+ // Cutoff timestamp: January 30, 2025 00:00:00 UTC
6+ const V2_CUTOFF_TIMESTAMP = 1738195200 ;
7+
58export default function useGetCollectedFeesSummary ( ) : { feeData : FeeAllocations [ ] , loading : boolean , error : string } {
69
710 const [ feeData , setFeeData ] = useState < FeeAllocations [ ] > ( [ ] ) ;
@@ -11,14 +14,34 @@ export default function useGetCollectedFeesSummary () : { feeData: FeeAllocation
1114 useEffect ( ( ) => {
1215 const fetchData = async ( ) => {
1316 try {
14- const response = await fetch ( 'https://raw.githubusercontent.com/BalancerMaxis/protocol_fee_allocator/main/fee_allocator/summaries/recon.json' ) ;
15- if ( ! response . ok ) {
16- throw new Error ( 'Network response was not ok' ) ;
17+ // Fetch from both old and new endpoints in parallel
18+ const [ oldResponse , v2Response ] = await Promise . all ( [
19+ fetch ( 'https://raw.githubusercontent.com/BalancerMaxis/protocol_fee_allocator/main/fee_allocator/summaries/recon.json' ) ,
20+ fetch ( 'https://raw.githubusercontent.com/BalancerMaxis/protocol_fee_allocator_v2/refs/heads/collect-fees-cron/fee_allocator/summaries/v2_recon.json' )
21+ ] ) ;
22+
23+ let oldData : FeeAllocations [ ] = [ ] ;
24+ let v2Data : FeeAllocations [ ] = [ ] ;
25+
26+ if ( oldResponse . ok ) {
27+ oldData = await oldResponse . json ( ) ;
28+ // Filter old data to only include entries up to and including the cutoff
29+ oldData = oldData . filter ( entry => entry . periodEnd <= V2_CUTOFF_TIMESTAMP ) ;
1730 }
18- const fetchedData = await response . json ( ) ;
1931
20- // Combine the fetched data with historical data
21- const combinedData = [ ...historicalData , ...fetchedData ] ;
32+ if ( v2Response . ok ) {
33+ v2Data = await v2Response . json ( ) ;
34+ // Filter v2 data to only include entries after the cutoff
35+ v2Data = v2Data . filter ( entry => entry . periodEnd > V2_CUTOFF_TIMESTAMP ) ;
36+ } else {
37+ console . warn ( 'Failed to fetch v2 recon data' ) ;
38+ }
39+
40+ // Combine historical data, filtered old data, and v2 data
41+ // Sort by periodEnd to ensure chronological order
42+ const combinedData = [ ...historicalData , ...oldData , ...v2Data ]
43+ . sort ( ( a , b ) => a . periodEnd - b . periodEnd ) ;
44+
2245 setFeeData ( combinedData ) ;
2346 } catch ( error ) {
2447 if ( error instanceof Error ) {
0 commit comments