@@ -16,6 +16,8 @@ const graphAPIEndpoints = {
1616 exchanger : 'https://api.thegraph.com/subgraphs/name/synthetixio-team/synthetix-exchanger' ,
1717} ;
1818
19+ const tempEndpoint = 'https://api.thegraph.com/subgraphs/name/dvd-schwrtz/exchanger' ;
20+
1921const graphWSEndpoints = {
2022 exchanges : 'wss://api.thegraph.com/subgraphs/name/synthetixio-team/synthetix-exchanges' ,
2123 rates : 'wss://api.thegraph.com/subgraphs/name/synthetixio-team/synthetix-rates' ,
@@ -1242,5 +1244,41 @@ module.exports = {
12421244 )
12431245 . catch ( err => console . error ( err ) ) ;
12441246 } ,
1247+ exchangeSourceData ( { timeSeries = '1mo' , partner = undefined } ) {
1248+ const now = new Date ( ) ;
1249+ const currentDayID = Math . floor ( now . getTime ( ) / 86400 / 1000 ) ;
1250+ let searchFromDayID ;
1251+ if ( timeSeries === '7d' ) {
1252+ searchFromDayID = currentDayID - 7 ;
1253+ } else if ( timeSeries === '1mo' || timeSeries === '30d' ) {
1254+ searchFromDayID = currentDayID - 30 ;
1255+ } else if ( timeSeries === '1y' || timeSeries === '365d' || timeSeries === '12mo' ) {
1256+ searchFromDayID = currentDayID - 365 ;
1257+ }
1258+ return pageResults ( {
1259+ api : tempEndpoint ,
1260+ max : 10000 ,
1261+ query : {
1262+ entity : 'dailyExchangePartners' ,
1263+ selection : {
1264+ orderBy : 'id' ,
1265+ orderDirection : 'desc' ,
1266+ where : {
1267+ dayID_gt : searchFromDayID ? `\\"${ searchFromDayID } \\"` : undefined ,
1268+ partner : partner ? `\\"${ partner } \\"` : undefined ,
1269+ } ,
1270+ } ,
1271+ properties : [ 'trades' , 'usdVolume' , 'usdFees' , 'partner' , 'dayID' ] ,
1272+ } ,
1273+ } ) . then ( results =>
1274+ results . map ( ( { dayID, partner, trades, usdFees, usdVolume } ) => ( {
1275+ dayID : Number ( dayID ) ,
1276+ partner,
1277+ trades : Number ( trades ) ,
1278+ usdFees : Math . round ( Number ( usdFees ) * 100 ) / 100 ,
1279+ usdVolume : Math . round ( Number ( usdVolume ) * 100 ) / 100 ,
1280+ } ) ) ,
1281+ ) ;
1282+ } ,
12451283 } ,
12461284} ;
0 commit comments