Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

artexswap #2403

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading