File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ import request from "graphql-request"
2
+ import { FetchOptions , SimpleAdapter } from "../../adapters/types"
3
+
4
+ const url = 'https://api.goldsky.com/api/public/project_clxa80jhk286401wr744n680a/subgraphs/launchpad-swap/v1.0.0/gn'
5
+ interface IPairTrade {
6
+ type : string
7
+ timestamp : number
8
+ valueUSD : number
9
+
10
+ }
11
+
12
+ const fetchData = async ( timestamp : any , _b : any , options : FetchOptions ) => {
13
+ const querry = `
14
+ {
15
+ pairTrades(where:{timestamp_gte: ${ options . startOfDay } , timestamp_lte:${ options . startOfDay + 86400 } }) {
16
+ type
17
+ timestamp
18
+ valueUSD
19
+ timestamp
20
+ }
21
+ }
22
+ `
23
+ const respose : IPairTrade [ ] = ( await request ( url , querry ) ) . pairTrades as IPairTrade [ ]
24
+ const dailyVolume = options . createBalances ( ) ;
25
+ respose . forEach ( ( trade ) => {
26
+ dailyVolume . addUSDValue ( Number ( trade . valueUSD ) )
27
+ } )
28
+ const dailyFees = dailyVolume . clone ( ) ;
29
+ dailyFees . resizeBy ( 0.5 / 100 )
30
+
31
+ return {
32
+ timestamp : timestamp ,
33
+ dailyVolume : dailyVolume ,
34
+ dailyFees : dailyFees ,
35
+ }
36
+ }
37
+
38
+ const adapter : SimpleAdapter = {
39
+ adapter : {
40
+ artela : {
41
+ fetch : fetchData ,
42
+ }
43
+ }
44
+ }
45
+
46
+
47
+ export default adapter
You can’t perform that action at this time.
0 commit comments