Skip to content

Commit

Permalink
add more chain
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Nov 8, 2024
1 parent ab01e59 commit 9d1ed01
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 10 deletions.
8 changes: 7 additions & 1 deletion dexs/camelot-v3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { CHAIN } from "../../helpers/chains";
import { univ2Adapter2 } from "../../helpers/getUniSubgraphVolume";

const adapters = univ2Adapter2({
[CHAIN.ARBITRUM]: sdk.graph.modifyEndpoint('7mPnp1UqmefcCycB8umy4uUkTkFxMoHn1Y7ncBUscePp')
[CHAIN.ARBITRUM]: sdk.graph.modifyEndpoint('7mPnp1UqmefcCycB8umy4uUkTkFxMoHn1Y7ncBUscePp'),
[CHAIN.APECHAIN]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv3-apechain/api`,
[CHAIN.GRAVITY]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv3-gravity/api`,
[CHAIN.RARI]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv3-rari/api`,
[CHAIN.REYA]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv3-reya/api`,
[CHAIN.XDAI]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv3-xai/api`,
[CHAIN.SANKO]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv3-sanko/api`,
}, {
factoriesName: "factories",
totalVolume: "totalVolumeUSD",
Expand Down
8 changes: 7 additions & 1 deletion dexs/camelot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { CHAIN } from "../../helpers/chains";
import { univ2Adapter2 } from "../../helpers/getUniSubgraphVolume";

const adapters = univ2Adapter2({
[CHAIN.ARBITRUM]: sdk.graph.modifyEndpoint('8zagLSufxk5cVhzkzai3tyABwJh53zxn9tmUYJcJxijG')
[CHAIN.ARBITRUM]: sdk.graph.modifyEndpoint('8zagLSufxk5cVhzkzai3tyABwJh53zxn9tmUYJcJxijG'),
[CHAIN.APECHAIN]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv2-apechain/api`,
[CHAIN.GRAVITY]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv2-gravity/api`,
[CHAIN.RARI]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv2-rari/api`,
[CHAIN.REYA]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv2-reya/api`,
[CHAIN.XDAI]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv2-xai/api`,
[CHAIN.SANKO]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv2-sanko/api`,
}, {});

adapters.adapter.arbitrum.start = 1668124800;
Expand Down
32 changes: 31 additions & 1 deletion fees/camelot-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ type IURL = {
}

const endpoints: IURL = {
[CHAIN.ARBITRUM]: sdk.graph.modifyEndpoint('8zagLSufxk5cVhzkzai3tyABwJh53zxn9tmUYJcJxijG')
[CHAIN.ARBITRUM]: sdk.graph.modifyEndpoint('8zagLSufxk5cVhzkzai3tyABwJh53zxn9tmUYJcJxijG'),
[CHAIN.APECHAIN]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv2-apechain/api`,
[CHAIN.GRAVITY]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv2-gravity/api`,
[CHAIN.RARI]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv2-rari/api`,
[CHAIN.REYA]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv2-reya/api`,
[CHAIN.XDAI]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv2-xai/api`,
[CHAIN.SANKO]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv2-sanko/api`,
}

const fetch = async (options: FetchOptions): Promise<FetchResultV2> => {
Expand Down Expand Up @@ -53,6 +59,30 @@ const adapter: Adapter = {
fetch: fetch,
start: '2022-11-11',
},
[CHAIN.APECHAIN]: {
fetch: fetch,
start: '2022-11-11',
},
[CHAIN.GRAVITY]: {
fetch: fetch,
start: '2022-11-11',
},
[CHAIN.RARI]: {
fetch: fetch,
start: '2022-11-11',
},
[CHAIN.REYA]: {
fetch: fetch,
start: '2022-11-11',
},
[CHAIN.XDAI]: {
fetch: fetch,
start: '2022-11-11',
},
[CHAIN.SANKO]: {
fetch: fetch,
start: '2022-11-11',
},
},
};

Expand Down
42 changes: 35 additions & 7 deletions fees/camelot-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as sdk from "@defillama/sdk";
import { Chain } from "@defillama/sdk/build/general";
import BigNumber from "bignumber.js";
import request, { gql } from "graphql-request";
import { Adapter, FetchResultFees } from "../adapters/types";
import { Adapter, FetchOptions, FetchResultFees } from "../adapters/types";
import { CHAIN } from "../helpers/chains";
import { getUniqStartOfTodayTimestamp } from "../helpers/getUniSubgraphVolume";
import { getTimestampAtStartOfDayUTC } from "../utils/date";
Expand All @@ -17,11 +17,16 @@ type IURL = {
}

const endpoints: IURL = {
[CHAIN.ARBITRUM]: sdk.graph.modifyEndpoint('7mPnp1UqmefcCycB8umy4uUkTkFxMoHn1Y7ncBUscePp')
[CHAIN.ARBITRUM]: sdk.graph.modifyEndpoint('7mPnp1UqmefcCycB8umy4uUkTkFxMoHn1Y7ncBUscePp'),
[CHAIN.APECHAIN]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv3-apechain/api`,
[CHAIN.GRAVITY]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv3-gravity/api`,
[CHAIN.RARI]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv3-rari/api`,
[CHAIN.REYA]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv3-reya/api`,
[CHAIN.XDAI]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv3-xai/api`,
[CHAIN.SANKO]: `https://subgraph.satsuma-prod.com/${process.env.CAMELOT_API_KEY}/camelot/camelot-ammv3-sanko/api`,
}

const fetch = (chain: Chain) => {
return async (timestamp: number): Promise<FetchResultFees> => {
const fetch = async (timestamp: number, _t: any, options: FetchOptions): Promise<FetchResultFees> => {
const todayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000));
const dateId = Math.floor(getTimestampAtStartOfDayUTC(todayTimestamp) / 86400)
const graphQuery = gql
Expand All @@ -34,7 +39,7 @@ const fetch = (chain: Chain) => {
}
`;

const graphRes: IPoolData = (await request(endpoints[chain], graphQuery)).algebraDayData;
const graphRes: IPoolData = (await request(endpoints[options.chain], graphQuery)).algebraDayData;
const dailyFeeUSD = graphRes;
const dailyFee = dailyFeeUSD?.feesUSD ? new BigNumber(dailyFeeUSD.feesUSD) : undefined
if (dailyFee === undefined) return { timestamp }
Expand All @@ -47,16 +52,39 @@ const fetch = (chain: Chain) => {
dailyHoldersRevenue: dailyFee.multipliedBy(0.17).toString(),
dailySupplySideRevenue: dailyFee.multipliedBy(0.80).toString(),
};
};
}

const adapter: Adapter = {
version: 1,
adapter: {
[CHAIN.ARBITRUM]: {
fetch: fetch(CHAIN.ARBITRUM),
fetch: fetch,
start: '2023-03-31',
},
[CHAIN.APECHAIN]: {
fetch: fetch,
start: '2022-11-11',
},
[CHAIN.GRAVITY]: {
fetch: fetch,
start: '2022-11-11',
},
[CHAIN.RARI]: {
fetch: fetch,
start: '2022-11-11',
},
[CHAIN.REYA]: {
fetch: fetch,
start: '2022-11-11',
},
[CHAIN.XDAI]: {
fetch: fetch,
start: '2022-11-11',
},
[CHAIN.SANKO]: {
fetch: fetch,
start: '2022-11-11',
},
},
};

Expand Down
6 changes: 6 additions & 0 deletions helpers/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ export enum CHAIN {
FUEL = "fuel",
REAL = "real",
CELESTIA = "celestia",
APECHAIN = "apechain",
DUCKCHAIN = "duckchain",
GRAVITY = "gravity",
RARI = "rari",
REYA = "reya",
SANKO = "sanko",
}

// Don´t use
Expand Down

0 comments on commit 9d1ed01

Please sign in to comment.