Skip to content

Commit

Permalink
Modify gmx sol total volume (#2446)
Browse files Browse the repository at this point in the history
* Modify Total Volumes

Modified total trade volumes

* Modify timing comparison for daily volumes for sol
  • Loading branch information
K-Lascar authored Feb 21, 2025
1 parent c2afa99 commit b513fc9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions dexs/gmx-v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,29 @@ const methodology = {
}

const fetchSolana = async (_tt: number, _t: any, options: FetchOptions) => {

const targetDate = new Date(options.startOfDay * 1000).toISOString();
const query = gql`
{
volumeRecordDailies(where: {timestamp_eq: "${new Date(options.startOfDay * 1000).toISOString()}"}) {
totalVolume
volumeRecordDailies(
where: {timestamp_lte: "${targetDate}"},
orderBy: timestamp_ASC
) {
timestamp
tradeVolume
}
}
`

const url = "https://gmx-solana-sqd.squids.live/gmx-solana-base:prod/api/graphql"
const res = await request(url , query)

const dailyVolume = res.volumeRecordDailies
.filter((record: {timestamp : string}) => new Date(record.timestamp).getTime() === new Date(targetDate).getTime())
.reduce((acc: number, record: { tradeVolume: string }) => acc + Number(record.tradeVolume), 0)
const totalVolume = res.volumeRecordDailies
.reduce((acc: number, record: { totalVolume: string }) => acc + Number(record.totalVolume), 0)
.filter((record: {timestamp : string}) => record.timestamp <= targetDate)
.reduce((acc: number, record: { tradeVolume: string }) => acc + Number(record.tradeVolume), 0)
return {
timestamp: options.startOfDay,
dailyVolume: dailyVolume / (10 ** 20),
Expand Down

0 comments on commit b513fc9

Please sign in to comment.