@@ -4,38 +4,26 @@ import { CHAIN } from "../helpers/chains";
44// const feeAdapter = chainAdapter(CHAIN.BITCOIN, "btc", 1230958800);
55
66async function fetchFunction ( _a : any , _b : any , options : FetchOptions ) {
7- const response = await fetch ( "https://ycharts.com /charts/fund_data.json?aiSummaries=&calcs=&chartId=&chartType=interactive&correlations=&customGrowthAmount=&dataInLegend=value&dateSelection=range&displayDateRange=false&endDate=& format=real&legendOnChart=false&lineAnnotations=&nameInLegend=name_and_ticker¬e=&partner=basic_2000&performanceDisclosure=false"eLegend=false&recessions=false&scaleType=linear&securities=id%3AI%3ABTTFPDND%2Cinclude%3Atrue%2C%2C&securityGroup=&securitylistName=&securitylistSecurityId=&source=false&splitType=single&startDate=&title=&units=false&useCustomColors=false&useEstimates=false&zoom=1&hideValueFlags=false&redesign=true&chartAnnotations=&axisExtremes=&sortColumn=&sortDirection=&le_o=quote_page_fund_data&maxPoints=678&chartCreator=false " , {
7+ const response = await fetch ( "https://api.blockchain.info /charts/transaction-fees?timespan=1year& format=json " , {
88 "headers" : {
9- "accept" : "application/json, text/plain, */*" ,
10- "accept-language" : "en-US,en;q=0.9" ,
11- "cache-control" : "no-cache" ,
12- "pragma" : "no-cache" ,
13- "priority" : "u=1, i" ,
14- "sec-ch-ua" : "\"Brave\";v=\"141\", \"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"141\"" ,
15- "sec-ch-ua-mobile" : "?0" ,
16- "sec-ch-ua-platform" : "\"Linux\"" ,
17- "sec-fetch-dest" : "empty" ,
18- "sec-fetch-mode" : "cors" ,
19- "sec-fetch-site" : "same-origin" ,
20- "sec-gpc" : "1" ,
21- "x-requested-with" : "XMLHttpRequest" ,
22- "cookie" : "cookieyes-consent=consentid:azc1WXdFckFuQ01wWTdNNmRCMFZBelJrT0ZtMEVzaUw,consent:yes,action:no,necessary:yes,functional:yes,analytics:yes,performance:yes,advertisement:yes,other:yes,lastRenewedDate:1704823885000; __stripe_mid=4352627b-d3f6-44a1-8247-f949c908ef54c8fb48; __stripe_sid=b1aa9827-42d9-4201-be06-be62b557bb3d1ee313; messagesUtk=bd1d031df0ee4d3089d7c39a7f5ee827; page_view_ctr=6" ,
23- "Referer" : "https://ycharts.com/indicators/bitcoin_total_transaction_fees_per_day"
9+ "accept" : "application/json, text/plain, */*"
2410 } ,
2511 "body" : null ,
2612 "method" : "GET"
2713 } ) ;
2814
29- const { chart_data } = await response . json ( ) ;
30- const raw_data = chart_data [ 0 ] [ 0 ] . raw_data ;
31-
32- const item = raw_data . find ( ( i : Array < number > ) => Number ( i [ 0 ] ) === options . startOfDay * 1000 ) ;
15+ const { values } = await response . json ( ) ;
16+
17+ const item = values . find ( ( i : any ) => Number ( i . x ) === options . startOfDay ) ;
3318 if ( ! item ) {
3419 throw Error ( `can not get Bitcoin fees for date ${ options . startOfDay } ` ) ;
3520 }
21+
22+ const dailyFees = options . createBalances ( )
23+ dailyFees . addCGToken ( 'bitcoin' , item . y )
3624
3725 return {
38- dailyFees : Number ( item [ 1 ] ) , // value in USD
26+ dailyFees,
3927 }
4028}
4129
0 commit comments