Skip to content

Commit

Permalink
protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
waynebruce0x committed Sep 11, 2024
1 parent c6f30da commit 3a8138c
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 225 deletions.
21 changes: 4 additions & 17 deletions fees/dragonswap/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Chain } from "@defillama/sdk/build/types";
import { BaseAdapter, BreakdownAdapter, FetchOptions, IJSON } from "../../adapters/types";
import { BaseAdapter, BreakdownAdapter, IJSON } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getGraphDimensions } from "../../helpers/getUniSubgraph";
import { getGraphDimensions2 } from "../../helpers/getUniSubgraph";

const endpoints = {
[CHAIN.KLAYTN]: "https://graph.dgswap.io/subgraphs/name/dragonswap/exchange-v2",
Expand All @@ -11,8 +11,6 @@ const v3Endpoint = {
[CHAIN.KLAYTN]: "https://graph.dgswap.io/subgraphs/name/dragonswap/exchange-v3",
};

const VOLUME_USD = "volumeUSD";

const startTimes = {
[CHAIN.KLAYTN]: 1707297572,
} as IJSON<number>;
Expand All @@ -30,7 +28,7 @@ const methodology = {
Fees: "All fees comes from the user."
}

const graphs = getGraphDimensions({
const graphs = getGraphDimensions2({
graphUrls: endpoints,
graphRequestHeaders: {
[CHAIN.KLAYTN]: {
Expand All @@ -40,9 +38,6 @@ const graphs = getGraphDimensions({
totalVolume: {
factory: "pancakeFactories"
},
dailyVolume: {
factory: "pancakeDayData"
},
feesPercent: {
type: "volume",
Fees: 0.3,
Expand All @@ -54,22 +49,14 @@ const graphs = getGraphDimensions({
}
});

const v3Graph = getGraphDimensions({
const v3Graph = getGraphDimensions2({
graphUrls: v3Endpoint,
totalVolume: {
factory: "factories",
},
dailyVolume: {
factory: "pancakeDayData",
field: VOLUME_USD
},
totalFees: {
factory: "factories",
},
dailyFees: {
factory: "pancakeDayData",
field: "feesUSD"
},
});

const adapter: BreakdownAdapter = {
Expand Down
10 changes: 2 additions & 8 deletions fees/kyotoswap.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
import * as sdk from "@defillama/sdk";
import { getDexChainFees } from "../helpers/getUniSubgraphFees";
import volumeAdapter from "../dexs/spookyswap";
import {
Adapter,
BaseAdapter,
BreakdownAdapter,
IJSON,
} from "../adapters/types";
import { CHAIN } from "../helpers/chains";
import { getGraphDimensions } from "../helpers/getUniSubgraph";
import { getGraphDimensions, getGraphDimensions2 } from "../helpers/getUniSubgraph";
import { Chain } from "@defillama/sdk/build/general";

const endpoints = {
[CHAIN.BSC]:
sdk.graph.modifyEndpoint('B1VWKexyptT1ixDdHsxj3EJnAxvuje7ANT39rnfq9rRG'),
};

const graphs = getGraphDimensions({
const graphs = getGraphDimensions2({
graphUrls: endpoints,
totalVolume: {
factory: "pancakeFactories",
},
dailyVolume: {
factory: "pancakeDayData",
},
feesPercent: {
type: "volume",
Fees: 0.25,
Expand Down
11 changes: 3 additions & 8 deletions fees/nile-exchange/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Adapter, FetchOptions } from "../../adapters/types";
import { ARBITRUM, CHAIN } from "../../helpers/chains";
import { CHAIN } from "../../helpers/chains";
import { fees_bribes } from './bribes';
import {
getGraphDimensions,
DEFAULT_DAILY_VOLUME_FACTORY,
DEFAULT_TOTAL_VOLUME_FIELD,
getGraphDimensions2,
} from "../../helpers/getUniSubgraph"

type TStartTime = {
Expand All @@ -31,18 +32,12 @@ const v2Endpoints = {
[CHAIN.LINEA]: "https://api.studio.thegraph.com/query/66247/nile-cl/version/latest/",
};

const VOLUME_USD = "volumeUSD";

const v2Graphs = getGraphDimensions({
const v2Graphs = getGraphDimensions2({
graphUrls: v2Endpoints,
totalVolume: {
factory: "factories",
field: DEFAULT_TOTAL_VOLUME_FIELD,
},
dailyVolume: {
factory: DEFAULT_DAILY_VOLUME_FACTORY,
field: VOLUME_USD,
},
feesPercent: {
type: "fees",
HoldersRevenue: 72,
Expand Down
13 changes: 3 additions & 10 deletions fees/nuri-exchange-v2/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Adapter, FetchOptions } from "../../adapters/types";
import { ARBITRUM, CHAIN } from "../../helpers/chains";
import { CHAIN } from "../../helpers/chains";
import { fees_bribes } from './bribes';
import {
getGraphDimensions,
DEFAULT_DAILY_VOLUME_FACTORY,
DEFAULT_TOTAL_VOLUME_FIELD,
getGraphDimensions2,
} from "../../helpers/getUniSubgraph"

type TStartTime = {
Expand All @@ -31,18 +30,12 @@ const v2Endpoints = {
[CHAIN.SCROLL]: "https://api.studio.thegraph.com/query/66247/nuri-cl/version/latest",
};

const VOLUME_USD = "volumeUSD";

const v2Graphs = getGraphDimensions({
const v2Graphs = getGraphDimensions2({
graphUrls: v2Endpoints,
totalVolume: {
factory: "factories",
field: DEFAULT_TOTAL_VOLUME_FIELD,
},
dailyVolume: {
factory: DEFAULT_DAILY_VOLUME_FACTORY,
field: VOLUME_USD,
},
feesPercent: {
type: "fees",
HoldersRevenue: 72,
Expand Down
11 changes: 3 additions & 8 deletions fees/pharaoh-exchange.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as sdk from "@defillama/sdk";
import { SimpleAdapter, FetchResultFees, BaseAdapter } from "../adapters/types";
import { SimpleAdapter } from "../adapters/types";
import { AVAX, CHAIN } from "../helpers/chains";

import {
getGraphDimensions,
DEFAULT_DAILY_VOLUME_FACTORY,
DEFAULT_TOTAL_VOLUME_FIELD,
getGraphDimensions2,
} from "../helpers/getUniSubgraph";

type TStartTime = {
Expand All @@ -22,16 +21,12 @@ const v2Endpoints = {

const VOLUME_USD = "volumeUSD";

const v2Graphs = getGraphDimensions({
const v2Graphs = getGraphDimensions2({
graphUrls: v2Endpoints,
totalVolume: {
factory: "factories",
field: DEFAULT_TOTAL_VOLUME_FIELD,
},
dailyVolume: {
factory: DEFAULT_DAILY_VOLUME_FACTORY,
field: VOLUME_USD,
},
feesPercent: {
type: "fees",
HoldersRevenue: 72,
Expand Down
66 changes: 29 additions & 37 deletions fees/quickswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import * as sdk from "@defillama/sdk";
import { Chain } from "@defillama/sdk/build/general";
import { BreakdownAdapter, BaseAdapter } from "../adapters/types";
import { CHAIN } from "../helpers/chains";
import customBackfill from "../helpers/customBackfill";

import {
getGraphDimensions
} from "../helpers/getUniSubgraph"
import { getGraphDimensions2 } from "../helpers/getUniSubgraph";

const v2Endpoints = {
[CHAIN.POLYGON]: sdk.graph.modifyEndpoint('FUWdkXWpi8JyhAnhKL5pZcVshpxuaUQG8JHMDqNCxjPd'),
}
const v2Graph = getGraphDimensions({
[CHAIN.POLYGON]: sdk.graph.modifyEndpoint(
"FUWdkXWpi8JyhAnhKL5pZcVshpxuaUQG8JHMDqNCxjPd",
),
};
const v2Graph = getGraphDimensions2({
graphUrls: v2Endpoints,
feesPercent: {
type: "volume",
Expand All @@ -20,50 +18,44 @@ const v2Graph = getGraphDimensions({
SupplySideRevenue: 0.3,
HoldersRevenue: 0,
Revenue: 0,
Fees: 0.3
}
Fees: 0.3,
},
});

const v3Endpoints = {
[CHAIN.POLYGON]: sdk.graph.modifyEndpoint('CCFSaj7uS128wazXMdxdnbGA3YQnND9yBdHjPtvH7Bc7'),
[CHAIN.POLYGON]: sdk.graph.modifyEndpoint(
"CCFSaj7uS128wazXMdxdnbGA3YQnND9yBdHjPtvH7Bc7",
),
// [CHAIN.DOGECHAIN]: "https://graph-node.dogechain.dog/subgraphs/name/quickswap/dogechain-info",
[CHAIN.POLYGON_ZKEVM]:"https://api.studio.thegraph.com/query/44554/quickswap-v3-02/0.0.7"
}
[CHAIN.POLYGON_ZKEVM]:
"https://api.studio.thegraph.com/query/44554/quickswap-v3-02/0.0.7",
};

type TStartTime = {
[s: string | Chain]: number;
}
};

const startTimeV3: TStartTime = {
[CHAIN.POLYGON]: 1662425243,
[CHAIN.POLYGON_ZKEVM]: 1679875200,
[CHAIN.DOGECHAIN]: 1660694400,
}
};

const v3Graphs = getGraphDimensions({
const v3Graphs = getGraphDimensions2({
graphUrls: v3Endpoints,
totalVolume: {
factory: "factories",
field: "totalVolumeUSD",
},
dailyVolume: {
factory: "algebraDayData",
field: "volumeUSD",
dateField: "date"
},
dailyFees: {
factory: "algebraDayData",
field: "feesUSD",
},
feesPercent: {
type: "fees",
ProtocolRevenue: 0,
HoldersRevenue: 0,
Fees: 0,
UserFees: 100, // User fees are 100% of collected fees
SupplySideRevenue: 100, // 100% of fees are going to LPs
Revenue: 0 // Revenue is 100% of collected fees
}
Revenue: 0, // Revenue is 100% of collected fees
},
});

const methodology = {
Expand All @@ -72,8 +64,8 @@ const methodology = {
Revenue: "Protocol have no revenue",
ProtocolRevenue: "Protocol have no revenue.",
SupplySideRevenue: "All user fees are distributed among LPs.",
HoldersRevenue: "Holders have no revenue."
}
HoldersRevenue: "Holders have no revenue.",
};

const adapter: BreakdownAdapter = {
version: 2,
Expand All @@ -83,7 +75,7 @@ const adapter: BreakdownAdapter = {
fetch: v2Graph(CHAIN.POLYGON),
start: 1602118043,
meta: {
methodology
methodology,
},
},
},
Expand All @@ -92,12 +84,12 @@ const adapter: BreakdownAdapter = {
fetch: v3Graphs(chain as Chain),
start: startTimeV3[chain],
meta: {
methodology
}
}
return acc
}, {} as BaseAdapter)
}
}
methodology,
},
};
return acc;
}, {} as BaseAdapter),
},
};

export default adapter;
11 changes: 2 additions & 9 deletions fees/ramses-exchange-v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { Adapter, FetchOptions } from "../../adapters/types";
import { ARBITRUM, CHAIN } from "../../helpers/chains";
import { fees_bribes } from './bribes';
import {
getGraphDimensions,
DEFAULT_DAILY_VOLUME_FACTORY,
DEFAULT_TOTAL_VOLUME_FIELD,
getGraphDimensions2,
} from "../../helpers/getUniSubgraph"

type TStartTime = {
Expand All @@ -32,18 +31,12 @@ const v2Endpoints = {
[CHAIN.ARBITRUM]: sdk.graph.modifyEndpoint('G2tXDm6mgqBMuC7hq9GRVeTv5SRBAVnPFGcpGBab2cea'),
};

const VOLUME_USD = "volumeUSD";

const v2Graphs = getGraphDimensions({
const v2Graphs = getGraphDimensions2({
graphUrls: v2Endpoints,
totalVolume: {
factory: "factories",
field: DEFAULT_TOTAL_VOLUME_FIELD,
},
dailyVolume: {
factory: DEFAULT_DAILY_VOLUME_FACTORY,
field: VOLUME_USD,
},
feesPercent: {
type: "fees",
HoldersRevenue: 72,
Expand Down
Loading

0 comments on commit 3a8138c

Please sign in to comment.