Skip to content

Commit

Permalink
Merge pull request #907 from Rajwanshi1/master
Browse files Browse the repository at this point in the history
Kriya-dex volume dimension adapter
  • Loading branch information
dtmkeng authored Oct 20, 2023
2 parents 237a970 + a3983ec commit 3557dff
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions dexs/kriya-dex/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import fetchURL from "../../utils/fetchURL"
import { Chain } from "@defillama/sdk/build/general";
import { SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume";

type IUrl = {
[s: string]: string;
}

const url: IUrl = {
[CHAIN.SUI]: `https://tkmw8dmcp8.execute-api.ap-southeast-1.amazonaws.com/prod/volume/`
}

interface IVolume {
totalVolume: number,
dailyVolume: number,
weeklyVolume: number,
monthlyVolume: number,
}

const fetch = (chain: Chain) => {
return async (timestamp: number) => {
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000));
// fetch for the passed timestamp.
const volumeUrl = url[chain] + String(timestamp);
const volume: IVolume = (await fetchURL(volumeUrl))?.data;
return {
totalVolume: `${volume?.totalVolume || undefined}`,
dailyVolume: `${volume?.dailyVolume || undefined}`,
timestamp: dayTimestamp,
};
};
}

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.SUI]: {
fetch: fetch(CHAIN.SUI),
start: async () => 1683604174,
}
},
};

export default adapter;

0 comments on commit 3557dff

Please sign in to comment.