Skip to content

Commit

Permalink
enable artexswap
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Feb 11, 2025
1 parent fb83d2d commit 47d1230
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions protocols/artexswap/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import request from "graphql-request"
import { FetchOptions, SimpleAdapter } from "../../adapters/types"

const url = 'https://api.goldsky.com/api/public/project_clxa80jhk286401wr744n680a/subgraphs/launchpad-swap/v1.0.0/gn'
interface IPairTrade {
type: string
timestamp: number
valueUSD: number

}

const fetchData = async (timestamp: any, _b: any, options: FetchOptions) => {
const querry = `
{
pairTrades(where:{timestamp_gte: ${options.startOfDay}, timestamp_lte:${options.startOfDay + 86400}}) {
type
timestamp
valueUSD
timestamp
}
}
`
const respose: IPairTrade[] = (await request(url, querry)).pairTrades as IPairTrade[]
const dailyVolume = options.createBalances();
respose.forEach((trade) => {
dailyVolume.addUSDValue(Number(trade.valueUSD))
})
const dailyFees = dailyVolume.clone();
dailyFees.resizeBy(0.5/100)

return {
timestamp: timestamp,
dailyVolume: dailyVolume,
dailyFees: dailyFees,
}
}

const adapter: SimpleAdapter = {
adapter: {
artela: {
fetch: fetchData,
}
}
}


export default adapter

0 comments on commit 47d1230

Please sign in to comment.