Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Quickswap Perps, Quickswap Hydra, LineHub V2 and LineHub V3 adapters #2012

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions dexs/linehub-v2/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { CHAIN } from "../../helpers/chains";
import { univ2Adapter2 } from "../../helpers/getUniSubgraphVolume";

const endpoints = {
[CHAIN.LINEA]:
"https://api.studio.thegraph.com/query/55804/linehub-v2/version/latest",
};

export default univ2Adapter2(endpoints, {
factoriesName: "factories",
totalVolume: "volumeUSD",
dayData: "factoryDaySnapshot",
dailyVolume: "volumeUSD",
dailyVolumeTimestampField: "timestamp",
});
81 changes: 81 additions & 0 deletions dexs/quickswap-hydra/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import request, { gql } from "graphql-request";
import { Adapter, ChainEndpoints, FetchV2 } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getTimestampAtStartOfDayUTC } from "../../utils/date";

const endpoints: ChainEndpoints = {
[CHAIN.POLYGON_ZKEVM]:
"https://api.studio.thegraph.com/query/55804/hydra-trade/version/latest",
[CHAIN.MANTA]:
"https://api.goldsky.com/api/public/project_cly4708cqpcj601tt7gzf1jdj/subgraphs/manta-trade/latest/gn",
};

interface IVolumeStat {
cumulativeVolumeUsd: string;
volumeUsd: string;
id: string;
}

const graphs = (graphUrls: ChainEndpoints) => {
const fetch: FetchV2 = async ({ chain, startTimestamp }) => {
const todaysTimestamp = getTimestampAtStartOfDayUTC(startTimestamp);

const graphQuery = gql`
query MyQuery {
volumeStats(where: {timestamp: ${todaysTimestamp}, period: "daily"}) {
cumulativeVolumeUsd
volumeUsd
id
}
}
`;

const graphRes = await request(graphUrls[chain], graphQuery);
const volumeStats: IVolumeStat[] = graphRes.volumeStats;

let dailyVolumeUSD = BigInt(0);
let totalVolumeUSD = BigInt(0);

volumeStats.forEach((vol) => {
dailyVolumeUSD += BigInt(vol.volumeUsd);
totalVolumeUSD += BigInt(vol.cumulativeVolumeUsd);
});

const finalDailyVolume = parseInt(dailyVolumeUSD.toString()) / 1e18;
const finalTotalVolume = parseInt(totalVolumeUSD.toString()) / 1e18;

return {
dailyVolume: finalDailyVolume.toString(),
totalVolume: finalTotalVolume.toString(),
timestamp: todaysTimestamp,
};
};
return fetch;
};

const methodology = {
dailyVolume:
"Total cumulativeVolumeUsd for specified chain for the given day",
};

const adapter: Adapter = {
version: 2,
adapter: {
[CHAIN.POLYGON_ZKEVM]: {
fetch: graphs(endpoints),
start: 1719878400,
meta: {
methodology,
},
},
[CHAIN.MANTA]: {
fetch: graphs(endpoints),
start: 1719878400,
meta: {
methodology,
},
},
},
};

export default adapter;
72 changes: 72 additions & 0 deletions dexs/quickswap-perps/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import request, { gql } from "graphql-request";
import { Adapter, ChainEndpoints, FetchV2 } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getTimestampAtStartOfDayUTC } from "../../utils/date";

const endpoints = {
[CHAIN.POLYGON_ZKEVM]:
"https://api.studio.thegraph.com/query/46725/quickperp-subgraph/version/latest",
};

interface IVolumeStat {
cumulativeVolumeUsd: string;
volumeUsd: string;
id: string;
}

const graphs = (graphUrls: ChainEndpoints) => {
const fetch: FetchV2 = async ({ chain, startTimestamp }) => {
const todaysTimestamp = getTimestampAtStartOfDayUTC(startTimestamp);

const graphQuery = gql`
query MyQuery {
volumeStats(where: {timestamp: ${todaysTimestamp}, period: "daily"}) {
cumulativeVolumeUsd
volumeUsd
id
}
}
`;

const graphRes = await request(graphUrls[chain], graphQuery);
const volumeStats: IVolumeStat[] = graphRes.volumeStats;

let dailyVolumeUSD = BigInt(0);
let totalVolumeUSD = BigInt(0);

volumeStats.forEach((vol) => {
dailyVolumeUSD += BigInt(vol.volumeUsd);
totalVolumeUSD += BigInt(vol.cumulativeVolumeUsd);
});

const finalDailyVolume = parseInt(dailyVolumeUSD.toString()) / 1e30;
const finalTotalVolume = parseInt(totalVolumeUSD.toString()) / 1e30;

return {
dailyVolume: finalDailyVolume.toString(),
totalVolume: finalTotalVolume.toString(),
timestamp: todaysTimestamp,
};
};
return fetch;
};

const methodology = {
dailyVolume:
"Total cumulativeVolumeUsd for specified chain for the given day",
};

const adapter: Adapter = {
version: 2,
adapter: {
[CHAIN.POLYGON_ZKEVM]: {
fetch: graphs(endpoints),
start: 1704067200,
meta: {
methodology,
},
},
},
};

export default adapter;
69 changes: 69 additions & 0 deletions fees/linehub-v2/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { gql, request } from "graphql-request";
import { Adapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";

import { getTimestampAtStartOfDayUTC } from "../../utils/date";

const endpoints = {
[CHAIN.LINEA]:
"https://api.studio.thegraph.com/query/55804/linehub-v2/version/latest",
};

interface IFeeStat {
cumulativeFeeUsd: string;
feeUsd: string;
id: string;
}

const fetch = (endpoint) => {
return async (timestamp: number) => {
const todaysTimestamp = getTimestampAtStartOfDayUTC(timestamp);
const period = "daily";

const graphQuery = gql`{
feeStats(where: {timestamp: ${todaysTimestamp}, period: "${period}"}) {
id
timestamp
period
cumulativeFee
cumulativeFeeUsd
feeUsd
}
}`;

const response = await request(endpoint, graphQuery);
const feeStats: IFeeStat[] = response.feeStats;

let dailyFeeUSD = BigInt(0);
let totalFeeUSD = BigInt(0);

feeStats.forEach((fee) => {
dailyFeeUSD += BigInt(fee.feeUsd);
totalFeeUSD += BigInt(fee.cumulativeFeeUsd);
});

const finalDailyFee = parseInt(dailyFeeUSD.toString()) / 1e18;
const finalTotalFee = parseInt(totalFeeUSD.toString()) / 1e18;

return {
timestamp: todaysTimestamp,
dailyFees: finalDailyFee.toString(),
totalFees: finalTotalFee.toString(),
};
};
};

const adapter: Adapter = {
version: 1,
adapter: {
[CHAIN.LINEA]: {
fetch: fetch(endpoints[CHAIN.LINEA]),
start: 1709251200,
meta: {
methodology: "Fees collected from user trading fees",
},
},
},
};

export default adapter;
69 changes: 69 additions & 0 deletions fees/linehub-v3/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { gql, request } from "graphql-request";
import { Adapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";

import { getTimestampAtStartOfDayUTC } from "../../utils/date";

const endpoints = {
[CHAIN.LINEA]:
"https://api.studio.thegraph.com/query/55804/linehub-v3/version/latest",
};

interface IFeeStat {
cumulativeFeeUsd: string;
feeUsd: string;
id: string;
}

const fetch = (endpoint) => {
return async (timestamp: number) => {
const todaysTimestamp = getTimestampAtStartOfDayUTC(timestamp);
const period = "daily";

const graphQuery = gql`{
feeStats(where: {timestamp: ${todaysTimestamp}, period: "${period}"}) {
id
timestamp
period
cumulativeFee
cumulativeFeeUsd
feeUsd
}
}`;

const response = await request(endpoint, graphQuery);
const feeStats: IFeeStat[] = response.feeStats;

let dailyFeeUSD = BigInt(0);
let totalFeeUSD = BigInt(0);

feeStats.forEach((fee) => {
dailyFeeUSD += BigInt(fee.feeUsd);
totalFeeUSD += BigInt(fee.cumulativeFeeUsd);
});

const finalDailyFee = parseInt(dailyFeeUSD.toString()) / 1e18;
const finalTotalFee = parseInt(totalFeeUSD.toString()) / 1e18;

return {
timestamp: todaysTimestamp,
dailyFees: finalDailyFee.toString(),
totalFees: finalTotalFee.toString(),
};
};
};

const adapter: Adapter = {
version: 1,
adapter: {
[CHAIN.LINEA]: {
fetch: fetch(endpoints[CHAIN.LINEA]),
start: 1709251200,
meta: {
methodology: "Fees collected from user trading fees",
},
},
},
};

export default adapter;
77 changes: 77 additions & 0 deletions fees/quickswap-hydra/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { gql, request } from "graphql-request";
import type { ChainEndpoints } from "../../adapters/types";
import { Adapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";

import { getTimestampAtStartOfDayUTC } from "../../utils/date";

const endpoints: ChainEndpoints = {
[CHAIN.POLYGON_ZKEVM]:
"https://api.studio.thegraph.com/query/55804/hydra-trade/version/latest",
[CHAIN.MANTA]:
"https://api.goldsky.com/api/public/project_cly4708cqpcj601tt7gzf1jdj/subgraphs/manta-trade/latest/gn",
};
interface IFeeStat {
cumulativeFeeUsd: string;
feeUsd: string;
id: string;
}

const fetch = (endpoint) => {
return async (timestamp: number) => {
const todaysTimestamp = getTimestampAtStartOfDayUTC(timestamp);
const period = "daily";

const graphQuery = gql`{
feeStats(where: {timestamp: ${todaysTimestamp}, period: "${period}"}) {
id
timestamp
period
cumulativeFee
cumulativeFeeUsd
feeUsd
}
}`;

const response = await request(endpoint, graphQuery);
const feeStats: IFeeStat[] = response.feeStats;

let dailyFeeUSD = BigInt(0);
let totalFeeUSD = BigInt(0);

feeStats.forEach((fee) => {
dailyFeeUSD += BigInt(fee.feeUsd);
totalFeeUSD += BigInt(fee.cumulativeFeeUsd);
});
const finalDailyFee = parseInt(dailyFeeUSD.toString()) / 1e18;
const finalTotalFee = parseInt(totalFeeUSD.toString()) / 1e18;

return {
timestamp: todaysTimestamp,
dailyFees: finalDailyFee.toString(),
totalFees: finalTotalFee.toString(),
};
};
};

const adapter: Adapter = {
version: 1,
adapter: {
[CHAIN.POLYGON_ZKEVM]: {
fetch: fetch(endpoints[CHAIN.POLYGON_ZKEVM]),
start: 1704067200,
meta: {
methodology: "All treasuryFee, poolFee and keeperFee are collected",
},
},
[CHAIN.MANTA]: {
fetch: fetch(endpoints[CHAIN.MANTA]),
start: 1704067200,
meta: {
methodology: "All treasuryFee, poolFee and keeperFee are collected",
},
},
},
};

export default adapter;
Loading
Loading