Skip to content

Commit

Permalink
update for total volume and historical data.
Browse files Browse the repository at this point in the history
  • Loading branch information
siong1987 committed Oct 22, 2024
1 parent 9a1bea0 commit 6f5962c
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions aggregators/jupiter-aggregator/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
import { CHAIN } from "../../helpers/chains";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume";
import { fetchURLWithRetry } from "../../helpers/duneRequest";
import { FetchOptions } from "../../adapters/types";
import { queryDune } from "../../helpers/dune";

const fetch = async (timestamp: number) => {
const unixTimestamp = getUniqStartOfTodayTimestamp();
const data = await fetchURLWithRetry(
`https://api.dune.com/api/v1/query/3099651/results`
);
const chainData = data.result.rows[0];
const fetch = async (options: FetchOptions) => {
const start = options.startOfDay;
const data = await queryDune("4187430", {
start: start,
end: start + 24 * 60 * 60,
});
const chainData = data[0];
if (!chainData) throw new Error(`Dune query failed: ${JSON.stringify(data)}`);
return {
dailyVolume: chainData.volume_24,
timestamp: unixTimestamp,
totalVolume: chainData.volume,
};
};

const adapter: any = {
timetravel: false,
adapter: {
[CHAIN.SOLANA]: {
fetch: fetch,
fetch: (_t: any, _tt: any, options: FetchOptions) => fetch(options),
runAtCurrTime: true,
start: 1729296000,
start: 1681599600,
meta: {
methodology: {
totalVolume:
"Volume is calculated by summing the token volume of all trades settled on the protocol since launch.",
dailyVolume:
"Volume is calculated by summing the token volume of all trades settled on the protocol that day.",
},
Expand Down

0 comments on commit 6f5962c

Please sign in to comment.