Skip to content

Commit

Permalink
fix dragonswap-sei
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Sep 17, 2024
1 parent edf9fca commit b8beed6
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions fees/dragonswap-sei.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Adapter } from "../adapters/types";
import { CHAIN } from "../helpers/chains";
import { request, gql } from "graphql-request";
import type { ChainEndpoints, FetchV2 } from "../adapters/types"
import type { ChainEndpoints, FetchOptions, FetchV2 } from "../adapters/types"
import { getTimestampAtStartOfDayUTC } from "../utils/date";
import { time } from "console";

const endpoints = {
[CHAIN.SEI]: "https://api.goldsky.com/api/public/project_clu1fg6ajhsho01x7ajld3f5a/subgraphs/dragonswap-prod/1.0.0/gn"
Expand All @@ -14,36 +15,37 @@ const methodology = {
ProtocolAccumulation: "Fees sent to the protocol wallet (30% of total accumulated fees), is used to provide benefits to users in custom ways."
}

const graphs = (graphUrls: ChainEndpoints) => {
const fetch: FetchV2 = async ({ chain, startTimestamp }) => {
const todaysTimestamp = getTimestampAtStartOfDayUTC(startTimestamp)
const graphs = async (_t: any, _b: any, options: FetchOptions) => {

const graphQuery = gql
`{
uniswapDayDatas(where: {date: ${todaysTimestamp}}) {
dailyFeesUSD
}
}`;

const graphRes = await request(graphUrls[chain], graphQuery);

const dailyFee = graphRes.uniswapDayDatas[0].dailyFeesUSD;
const dayID = Math.floor(options.startOfDay / 86400);
const query =gql`
{
uniswapDayData(id:${dayID}) {
id
dailyVolumeUSD
dailyFeesUSD
}
}`;
const url = "https://api.goldsky.com/api/public/project_clu1fg6ajhsho01x7ajld3f5a/subgraphs/dragonswap-prod/1.0.0/gn";
const req = await request(url, query);
const dailyFee = Number(req.uniswapDayData.dailyFeesUSD);
return {
timestamp: options.startOfDay,
dailyFees: dailyFee.toString(),
dailyLPProvidersRevenue: (dailyFee * 0.7).toString(),
// dailyLPProvidersRevenue: (dailyFee * 0.7).toString(),
dailyRevenue: (dailyFee * 0.3).toString(),
};
};
return fetch

};


const adapter: Adapter = {
version: 1,
adapter: {
[CHAIN.SEI]: {
fetch: graphs(endpoints),
fetch: graphs,
start: 79157663,
meta: {
methodology
Expand Down

0 comments on commit b8beed6

Please sign in to comment.