Skip to content

Commit

Permalink
Merge pull request #2197 from Plunderswap/master
Browse files Browse the repository at this point in the history
add plunderswap dex volume
  • Loading branch information
dtmkeng authored Dec 13, 2024
2 parents a744831 + 7e8cc05 commit b5f6e99
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions dexs/plunderswap/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import fetchURL from "../../utils/fetchURL"
import { ChainBlocks, FetchOptions, SimpleAdapter } from "../../adapters/types";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume";

const historicalVolumeEndpoint = "https://static.plunderswap.com/volume-history"

interface IVolumeall {
value: string;
time: string;
}

const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, startOfDay, }: FetchOptions) => {
const dailyVolume = createBalances()
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000))
const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint));

// Format the timestamp without milliseconds
const targetTime = new Date(dayTimestamp * 1000).toISOString().replace('.000Z', 'Z');

// Filter entries to find exact 00:00 UTC entry of the current day
const dayEntries = historicalVolume.filter(entry => {
return entry.time === targetTime;
});

if (dayEntries.length > 0) {
dailyVolume.addCGToken("zilliqa", Number(dayEntries[0].value));
}

return { dailyVolume, timestamp: startOfDay, };
};

const adapter: SimpleAdapter = {
adapter: {
zilliqa: {
fetch,
runAtCurrTime: true,
start: '2024-12-10',
meta: {
methodology: {
Volume: "Volume of trades on Plunderswap at the start of the day (00:00:00 UTC) for the previous day"
}
}
},
},
};

export default adapter;

0 comments on commit b5f6e99

Please sign in to comment.