Skip to content

Commit

Permalink
Merge pull request #1918 from DefiLlama/migrate
Browse files Browse the repository at this point in the history
Migrate
  • Loading branch information
waynebruce0x authored Sep 17, 2024
2 parents b0bba3d + 465c531 commit 76565bf
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 64 deletions.
4 changes: 2 additions & 2 deletions dexs/wagmi/wagmi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ const getData = async (chain: Chain, timestamp: number) => {
const totalVolume = Number(data.factories[0].totalVolumeUSD);
const totalFee = Number(data.factories[0].totalFeesUSD);

const dailyVolume = Number(data.uniswapDayData.volumeUSD);
const dailyFees = Number(data.uniswapDayData.feesUSD);
const dailyVolume = Number(data.uniswapDayData?.volumeUSD ?? '0');
const dailyFees = Number(data.uniswapDayData?.feesUSD ?? '0');

return {
dailyFees: `${dailyFees}`,
Expand Down
7 changes: 2 additions & 5 deletions fees/babydogeswap.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { CHAIN } from "../helpers/chains";
import { univ2DimensionAdapter } from "../helpers/getUniSubgraph";
import { univ2DimensionAdapter2 } from "../helpers/getUniSubgraph";

// 0.2% to LP providers
// 0.05% to treasury
// 0.05% to buy back and burn BabyDoge!

const adapters = univ2DimensionAdapter({
const adapters = univ2DimensionAdapter2({
graphUrls: {
[CHAIN.BSC]: "https://graph-bsc-mainnet.babydoge.com/subgraphs/name/babydoge/exchange"
},
dailyVolume: {
factory: "factoryDayData"
},
totalVolume: {
factory: "babyDogeFactories"
},
Expand Down
11 changes: 4 additions & 7 deletions fees/biswap.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import * as sdk from "@defillama/sdk";
import { graph } from "@defillama/sdk";
import { CHAIN } from "../helpers/chains";
import { univ2DimensionAdapter } from "../helpers/getUniSubgraph";
import { univ2DimensionAdapter2 } from "../helpers/getUniSubgraph";

const adapters = univ2DimensionAdapter({
const adapters = univ2DimensionAdapter2({
graphUrls: {
[CHAIN.BSC]: sdk.graph.modifyEndpoint('2D9rXpMTvAgofWngsyRE17jKr5ywrU4W3Eaa71579qkd')
},
dailyVolume: {
factory: "pancakeDayData"
[CHAIN.BSC]: graph.modifyEndpoint('2D9rXpMTvAgofWngsyRE17jKr5ywrU4W3Eaa71579qkd')
},
totalVolume: {
factory: "pancakeFactories"
Expand Down
7 changes: 2 additions & 5 deletions fees/elk.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as sdk from "@defillama/sdk";
import { CHAIN } from "../helpers/chains";
import { univ2DimensionAdapter } from "../helpers/getUniSubgraph";
import { univ2DimensionAdapter2 } from "../helpers/getUniSubgraph";

const adapter = univ2DimensionAdapter({
const adapter = univ2DimensionAdapter2({
graphUrls: {
[CHAIN.ARBITRUM]: sdk.graph.modifyEndpoint('B8TGNwQ8xMoeFCdsv9dPkciRBpEYAy1UxmXDr7nc9fpE'),
[CHAIN.AVAX]: sdk.graph.modifyEndpoint('2dyce92CewvhV17C8BMFoMCgaXdPTtwBzaz8AReQR3YV'),
Expand All @@ -22,9 +22,6 @@ const adapter = univ2DimensionAdapter({
// [CHAIN.IOTEX]: "https://iotex-graph.elk.finance/subgraphs/name/elkfinance/elkdex-iotex",
// [CHAIN.TELOS]: "https://telos-graph2.elk.finance/subgraphs/name/elkfinance/elkdex-telos"
},
dailyVolume: {
factory: "elkDayData"
},
totalVolume: {
factory: "elkFactories"
},
Expand Down
9 changes: 2 additions & 7 deletions fees/ferro.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { CHAIN } from "../helpers/chains";
import { univ2DimensionAdapter } from "../helpers/getUniSubgraph";
import { univ2DimensionAdapter2 } from "../helpers/getUniSubgraph";

const adapters = univ2DimensionAdapter({
const adapters = univ2DimensionAdapter2({
graphUrls: {
[CHAIN.CRONOS]: "https://graph.cronoslabs.com/subgraphs/name/ferro/swap",
},
dailyVolume: {
factory: "dailyVolume",
field: "volume",
dateField: "timestamp"
},
totalVolume: {
factory: "tradeVolumes",
field: "volume"
Expand Down
7 changes: 2 additions & 5 deletions fees/honeyswap.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { CHAIN } from "../helpers/chains";
import { univ2DimensionAdapter } from "../helpers/getUniSubgraph";
import { univ2DimensionAdapter2 } from "../helpers/getUniSubgraph";

const adapters = univ2DimensionAdapter({
const adapters = univ2DimensionAdapter2({
graphUrls: {
[CHAIN.POLYGON]: " https://api.thegraph.com/subgraphs/name/1hive/honeyswap-polygon",
[CHAIN.XDAI]: "https://api.thegraph.com/subgraphs/name/1hive/honeyswap-xdai"
},
dailyVolume: {
factory: "honeyswapDayData"
},
totalVolume: {
factory: "honeyswapFactories"
},
Expand Down
9 changes: 2 additions & 7 deletions fees/mimo.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import { CHAIN } from "../helpers/chains";
import { univ2DimensionAdapter } from "../helpers/getUniSubgraph";
import { univ2DimensionAdapter2 } from "../helpers/getUniSubgraph";

const adapter = univ2DimensionAdapter({
const adapter = univ2DimensionAdapter2({
graphUrls: {
[CHAIN.IOTEX]: "https://graph.mimo.exchange/subgraphs/name/mimo/mainnet"
},
totalVolume: {
factory: "uniswapFactories",
field: "totalVolumeUSD",
},
dailyVolume: {
factory: "uniswapDayData",
field: "dailyVolumeUSD",
dateField: "date"
},
feesPercent: {
type: "volume",
UserFees: 0.3,
Expand Down
4 changes: 2 additions & 2 deletions fees/mojitoswap.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CHAIN } from "../helpers/chains";
import { univ2DimensionAdapter } from "../helpers/getUniSubgraph";
import { univ2DimensionAdapter2 } from "../helpers/getUniSubgraph";

const graphUrls = {
[CHAIN.KCC]: "https://thegraph.kcc.network/subgraphs/name/mojito/swap",
};

const adapter = univ2DimensionAdapter({
const adapter = univ2DimensionAdapter2({
graphUrls,
feesPercent: {
type: "volume",
Expand Down
11 changes: 4 additions & 7 deletions fees/pangolin.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import * as sdk from "@defillama/sdk";
import { graph } from "@defillama/sdk";
import { CHAIN } from "../helpers/chains";
import { univ2DimensionAdapter } from "../helpers/getUniSubgraph";
import { univ2DimensionAdapter2 } from "../helpers/getUniSubgraph";

const adapter = univ2DimensionAdapter({
const adapter = univ2DimensionAdapter2({
graphUrls: {
[CHAIN.AVAX]: sdk.graph.modifyEndpoint('CPXTDcwh6tVP88QvFWW7pdvZJsCN4hSnfMmYeF1sxCLq')
},
dailyVolume: {
factory: "pangolinDayData"
[CHAIN.AVAX]: graph.modifyEndpoint('CPXTDcwh6tVP88QvFWW7pdvZJsCN4hSnfMmYeF1sxCLq')
},
totalVolume: {
factory: "pangolinFactories"
Expand Down
7 changes: 2 additions & 5 deletions fees/vvs-finance.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { CHAIN } from "../helpers/chains";
import { univ2DimensionAdapter } from "../helpers/getUniSubgraph";
import { univ2DimensionAdapter2 } from "../helpers/getUniSubgraph";

const adapters = univ2DimensionAdapter({
const adapters = univ2DimensionAdapter2({
graphUrls: {
[CHAIN.CRONOS]: "https://graph.cronoslabs.com/subgraphs/name/vvs/exchange"
},
dailyVolume: {
factory: "vvsDayData"
},
totalVolume: {
factory: "vvsFactories"
},
Expand Down
11 changes: 4 additions & 7 deletions fees/wigoswap.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import * as sdk from "@defillama/sdk";
import { graph } from "@defillama/sdk";
import { CHAIN } from "../helpers/chains";
import { univ2DimensionAdapter } from "../helpers/getUniSubgraph";
import { univ2DimensionAdapter2 } from "../helpers/getUniSubgraph";

const adapters = univ2DimensionAdapter({
const adapters = univ2DimensionAdapter2({
graphUrls: {
[CHAIN.FANTOM]: sdk.graph.modifyEndpoint('71os49womDk3DFcNRCAFYzATxxMgWpSMKhRn5ih6aWF1')
},
dailyVolume: {
factory: "wigoDayData"
[CHAIN.FANTOM]: graph.modifyEndpoint('71os49womDk3DFcNRCAFYzATxxMgWpSMKhRn5ih6aWF1')
},
totalVolume: {
factory: "wigoswapFactories"
Expand Down
27 changes: 27 additions & 0 deletions helpers/getUniSubgraph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,32 @@ function univ2DimensionAdapter(params: IGetChainVolumeParams, meta: BaseAdapter[
return adapter;
}

function univ2DimensionAdapter2(params: IGetChainVolumeParams, meta: BaseAdapter[string]['meta']) {
const graphs = getGraphDimensions2(params);

const adapter: SimpleAdapter = {
adapter: Object.keys(params.graphUrls).reduce((acc, chain) => {
return {
...acc,
[chain]: {
fetch: graphs(chain as Chain),
start: getStartTimestamp({
endpoints: params.graphUrls,
chain,
volumeField: params.dailyVolume?.field,
dailyDataField: params.dailyVolume?.factory + "s",
dateField: params.dailyVolume?.dateField,
}),
meta,
},
};
}, {} as BaseAdapter),
version: 2
};

return adapter;
}

function wrapGraphError(e: Error) {
const message = (e as any).response?.errors?.[0]?.message ?? e.message;
return new Error(shortenString(message));
Expand All @@ -463,6 +489,7 @@ export {
getGraphDimensions,
getGraphDimensions2,
univ2DimensionAdapter,
univ2DimensionAdapter2,
DEFAULT_TOTAL_VOLUME_FACTORY,
DEFAULT_TOTAL_VOLUME_FIELD,
DEFAULT_DAILY_VOLUME_FACTORY,
Expand Down
9 changes: 4 additions & 5 deletions protocols/alita-finance/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as sdk from "@defillama/sdk";
import { univ2Adapter } from "../../helpers/getUniSubgraphVolume";
import { graph } from "@defillama/sdk";
import { CHAIN } from "../../helpers/chains";
import { univ2DimensionAdapter } from "../../helpers/getUniSubgraph";
import { univ2DimensionAdapter2 } from "../../helpers/getUniSubgraph";

const adapter = univ2DimensionAdapter({
const adapter = univ2DimensionAdapter2({
graphUrls: {
[CHAIN.BSC]: sdk.graph.modifyEndpoint('FBPHPJNE1jX18Lz8rgscvsigfxAUXakUC8w9KMid4dDz')
[CHAIN.BSC]: graph.modifyEndpoint('FBPHPJNE1jX18Lz8rgscvsigfxAUXakUC8w9KMid4dDz')
},
feesPercent: {
type: "volume",
Expand Down

0 comments on commit 76565bf

Please sign in to comment.