Skip to content

Commit

Permalink
morreeeee
Browse files Browse the repository at this point in the history
  • Loading branch information
waynebruce0x committed Mar 5, 2024
1 parent f35b6b1 commit 135b6b2
Show file tree
Hide file tree
Showing 50 changed files with 77 additions and 28 deletions.
1 change: 1 addition & 0 deletions dexs/3xcalibur/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.ARBITRUM]: {
fetch: graphs(CHAIN.ARBITRUM),
Expand Down
1 change: 1 addition & 0 deletions dexs/ascent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const graphsV3 = getChainVolume({


const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v2: {
[CHAIN.EON]: {
Expand Down
1 change: 1 addition & 0 deletions dexs/auragi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.ARBITRUM]: {
fetch: graphs(CHAIN.ARBITRUM),
Expand Down
8 changes: 4 additions & 4 deletions dexs/balancer/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Chain } from "@defillama/sdk/build/general";
import request, { gql } from "graphql-request";
import { BaseAdapter, BreakdownAdapter, ChainEndpoints, FetchResultVolume } from "../../adapters/types";
import { BaseAdapter, BreakdownAdapter, ChainEndpoints, FetchResultV2, FetchResultVolume, FetchV2 } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import customBackfill from "../../helpers/customBackfill";
import { getStartTimestamp } from "../../helpers/getStartTimestamp";
Expand Down Expand Up @@ -37,8 +37,8 @@ interface IPoolSnapshot {


const v2Graphs = (chain: Chain) => {
return async (timestamp: number): Promise<FetchResultVolume> => {
const startTimestamp = getTimestampAtStartOfDayUTC(timestamp)
return async ({ endTimestamp }): Promise<FetchResultV2> => {
const startTimestamp = getTimestampAtStartOfDayUTC(endTimestamp)
const fromTimestamp = startTimestamp - 60 * 60 * 24
const toTimestamp = startTimestamp
const graphQuery = gql
Expand All @@ -62,7 +62,6 @@ const v2Graphs = (chain: Chain) => {

return {
dailyVolume: `${dailyVolume}`,
timestamp,
};
};
};
Expand All @@ -76,6 +75,7 @@ const v1graphs = getChainVolume({
});

const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v1: {
[CHAIN.ETHEREUM]: {
Expand Down
1 change: 1 addition & 0 deletions dexs/carthage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const v3Graphs = getChainVolume({
});

const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v3: {
[CANDLE]: {
Expand Down
1 change: 1 addition & 0 deletions dexs/cherryswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.OKEXCHAIN]: {
fetch: graphs(CHAIN.OKEXCHAIN),
Expand Down
1 change: 1 addition & 0 deletions dexs/clipper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const graphs = getChainVolume({


const adapter: SimpleAdapter = {
version: 2,
adapter: Object.keys(endpoints).reduce((acc, chain: any) => {
return {
...acc,
Expand Down
1 change: 1 addition & 0 deletions dexs/crescent-swap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.ARBITRUM]: {
fetch: graphs(CHAIN.ARBITRUM),
Expand Down
1 change: 1 addition & 0 deletions dexs/cryptoswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.BSC]: {
fetch: graphs(CHAIN.BSC),
Expand Down
1 change: 1 addition & 0 deletions dexs/elektrik/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.LIGHTLINK_PHOENIX]: {
fetch: graphs(CHAIN.LIGHTLINK_PHOENIX),
Expand Down
1 change: 1 addition & 0 deletions dexs/fairyswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.FINDORA]: {
fetch: graphs(CHAIN.FINDORA),
Expand Down
1 change: 1 addition & 0 deletions dexs/ferro/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.CRONOS]: {
fetch: graphs(CHAIN.CRONOS),
Expand Down
1 change: 1 addition & 0 deletions dexs/forge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const v1Graph = getChainVolume({


const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.EVMOS]: {
fetch: v1Graph(CHAIN.EVMOS),
Expand Down
1 change: 1 addition & 0 deletions dexs/hadouken-amm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const v1graphs = getChainVolume({


const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.GODWOKEN_V1]: {
fetch: v1graphs(CHAIN.GODWOKEN_V1 as Chain),
Expand Down
1 change: 1 addition & 0 deletions dexs/holdr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const v1graphs = getChainVolume({


const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.AURORA]: {
fetch: v1graphs(CHAIN.AURORA as Chain),
Expand Down
1 change: 1 addition & 0 deletions dexs/integral/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: chains.reduce((acc, chain) => {
return {
...acc,
Expand Down
1 change: 1 addition & 0 deletions dexs/katana/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[RONIN]: {
fetch: graphs(RONIN),
Expand Down
1 change: 1 addition & 0 deletions dexs/klex-finance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: Object.keys(endpoints).reduce((acc, chain: any) => {
return {
...acc,
Expand Down
1 change: 1 addition & 0 deletions dexs/knightswap-finance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const v2Graph = getChainVolume({


const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.BSC]: {
fetch: v2Graph(CHAIN.BSC),
Expand Down
1 change: 1 addition & 0 deletions dexs/koyo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.BOBA]: {
fetch: graphs(CHAIN.BOBA),
Expand Down
10 changes: 5 additions & 5 deletions dexs/kyberswap/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ADDRESSES from '../../helpers/coreAssets.json'
import request from "graphql-request";
import { BaseAdapter, BreakdownAdapter, FetchResultVolume } from "../../adapters/types";
import { BaseAdapter, BreakdownAdapter, FetchOptions, FetchResultVolume } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getStartTimestamp } from "../../helpers/getStartTimestamp";
import {
Expand Down Expand Up @@ -210,15 +210,14 @@ const customeElasicVolumeFunctions: {[s: Chain]: any} = {
function buildFromEndpoints(endpoints: typeof classicEndpoints, graphs: typeof classicGraphs, volumeField:string, dailyDataField:string, isElastic: boolean){
return Object.keys(endpoints).reduce((acc, chain) => {
acc[chain] = {
fetch: async (timestamp: number) => {
const a = (customeElasicVolumeFunctions[chain] !== undefined) && isElastic ? await customeElasicVolumeFunctions[chain](timestamp) : (await graphs(chain as any)(timestamp, {}))
const elasticV2 = (kyberswapElasticV2.adapter[chain as Chain]?.fetch != undefined && isElastic) ? (await kyberswapElasticV2.adapter[chain as Chain]?.fetch(timestamp, {})) : {} as FetchResultVolume;
fetch: async (options: FetchOptions) => {
const a = (customeElasicVolumeFunctions[chain] !== undefined) && isElastic ? await customeElasicVolumeFunctions[chain](options.endTimestamp) : (await graphs(chain as any)(options))
const elasticV2 = (kyberswapElasticV2.adapter[chain as Chain]?.fetch != undefined && isElastic) ? (await kyberswapElasticV2.adapter[chain as Chain]?.fetch(options as any, {}, options)) : {} as FetchResultVolume;
const dailyVolume = Number(a.dailyVolume) + Number(elasticV2?.dailyVolume || 0)
const totalVolume = Number(a.totalVolume) + Number(elasticV2?.totalVolume || 0)
return {
dailyVolume: `${dailyVolume}`,
totalVolume: chain === CHAIN.ARBITRUM ? undefined : `${totalVolume}`,
timestamp
};
},
start: getStartTimestamp({
Expand All @@ -233,6 +232,7 @@ function buildFromEndpoints(endpoints: typeof classicEndpoints, graphs: typeof c
}

const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
classic: buildFromEndpoints(classicEndpoints, classicGraphs, DEFAULT_DAILY_VOLUME_FIELD, "dmmDayDatas", false),
elastic: buildFromEndpoints(elasticEndpoints, elasticGraphs, "volumeUSD", "kyberSwapDayDatas", true)
Expand Down
1 change: 1 addition & 0 deletions dexs/mimo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const graphs = getChainVolume({


const adapter: SimpleAdapter = {
version: 2,
adapter: Object.keys(endpoints).reduce((acc, chain: any) => {
return {
...acc,
Expand Down
1 change: 1 addition & 0 deletions dexs/mobius-money/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.CELO]: {
fetch: graphs(CHAIN.CELO),
Expand Down
1 change: 1 addition & 0 deletions dexs/mooniswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[ETHEREUM]: {
fetch: graphs(ETHEREUM),
Expand Down
1 change: 1 addition & 0 deletions dexs/okcswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.OKEXCHAIN]: {
fetch: graphs(CHAIN.OKEXCHAIN),
Expand Down
1 change: 1 addition & 0 deletions dexs/pegasys-v3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const graphs = getChainVolume({
});
// rollux
const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.ROLLUX]: {
fetch: graphs(CHAIN.ROLLUX),
Expand Down
1 change: 1 addition & 0 deletions dexs/radioshack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.POLYGON]: {
fetch: graphs(CHAIN.POLYGON),
Expand Down
1 change: 1 addition & 0 deletions dexs/reax-one-dex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: Object.keys(endpoints).reduce((acc, chain: any) => {
return {
...acc,
Expand Down
1 change: 1 addition & 0 deletions dexs/saddle-finance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.ARBITRUM]: {
fetch: graphs(CHAIN.ARBITRUM),
Expand Down
1 change: 1 addition & 0 deletions dexs/sobal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.NEON]: {
fetch: graphs(CHAIN.NEON),
Expand Down
1 change: 1 addition & 0 deletions dexs/soulswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const volume = Object.keys(endpoints).reduce(
);

const adapter: SimpleAdapter = {
version: 2,
adapter: volume,
};

Expand Down
1 change: 1 addition & 0 deletions dexs/spiritswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const graphs = getChainVolumeWithGasToken({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
fantom: {
fetch: graphs("fantom"),
Expand Down
1 change: 1 addition & 0 deletions dexs/spookyswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const graphsV3 = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[FANTOM]: {
fetch: graphs(FANTOM),
Expand Down
5 changes: 3 additions & 2 deletions dexs/sushiswap/classic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getGraphDimensions } from "../../helpers/getUniSubgraph";
import {
getChainVolumeWithGasToken,
} from "../../helpers/getUniSubgraphVolume";
import { FetchOptions } from "../../adapters/types";

const blacklistTokens = {
[CHAIN.ARBITRUM]: [
Expand Down Expand Up @@ -150,8 +151,8 @@ const fantomGraphs = getChainVolumeWithGasToken({
priceToken: "coingecko:fantom"
} as any);
classic[CHAIN.FANTOM] = {
fetch: async (timestamp: number) => {
const values = await fantomGraphs(CHAIN.FANTOM)(timestamp, {});
fetch: async (options: FetchOptions) => {
const values = await fantomGraphs(CHAIN.FANTOM)(options);
const vol = Number(values.dailyVolume)
return {
...values,
Expand Down
1 change: 1 addition & 0 deletions dexs/swaap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ const v1graphs = getChainVolume({
});

const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v1: {
[CHAIN.POLYGON]: {
Expand Down
1 change: 1 addition & 0 deletions dexs/templedao-trade/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const graphs = getChainVolume({


const adapter: SimpleAdapter = {
version: 2,
adapter: Object.keys(endpoints).reduce((acc, chain: any) => {
return {
...acc,
Expand Down
1 change: 1 addition & 0 deletions dexs/traderjoe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const graphsV2 = getChainVolume({
});

const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v1: {
[CHAIN.AVAX]: {
Expand Down
9 changes: 5 additions & 4 deletions dexs/velodrome/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SimpleAdapter } from "../../adapters/types";
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { DEFAULT_DAILY_VOLUME_FIELD, DEFAULT_TOTAL_VOLUME_FIELD, getChainVolume } from "../../helpers/getUniSubgraphVolume";
import { CHAIN } from "../../helpers/chains";
import { Chain } from "@defillama/sdk/build/general";
Expand All @@ -19,18 +19,19 @@ const graphs = getChainVolume({
},
});


const fetch = (chain: Chain) => {
return async (timestamp: number) => {
const [v1] = await Promise.all([graphs(chain)(timestamp, {})])
return async (options: FetchOptions) => {
const [v1] = await Promise.all([graphs(chain)(options)])
const dailyVolume = Number(v1.dailyVolume);
return {
dailyVolume: `${dailyVolume}`,
timestamp
}
}
}

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.OPTIMISM]: {
fetch: fetch(CHAIN.OPTIMISM),
Expand Down
1 change: 1 addition & 0 deletions dexs/verse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const volumeAdapter: BaseAdapter = {
}

const adapter: SimpleAdapter = {
version: 2,
adapter: volumeAdapter,
}

Expand Down
Loading

0 comments on commit 135b6b2

Please sign in to comment.