Skip to content

Commit c55e6e7

Browse files
authored
Merge pull request #2403 from DefiLlama/enable-artexswap
enable artexswap
2 parents 0f96af3 + 47d1230 commit c55e6e7

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

protocols/artexswap/index.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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

0 commit comments

Comments
 (0)