Skip to content

Commit

Permalink
Merge pull request #2431 from amedrontadora/master
Browse files Browse the repository at this point in the history
feat(syncswap): Add linea and scroll, add zksync-era univ3 pool
  • Loading branch information
dtmkeng authored Feb 22, 2025
2 parents b42ddf8 + edfdc90 commit 656aa0d
Showing 1 changed file with 61 additions and 7 deletions.
68 changes: 61 additions & 7 deletions dexs/syncswap/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,70 @@
import { univ2Adapter2 } from "../../helpers/getUniSubgraphVolume";
import * as sdk from "@defillama/sdk";
import { CHAIN } from "../../helpers/chains";
import { DEFAULT_TOTAL_VOLUME_FIELD, getChainVolume2 } from "../../helpers/getUniSubgraphVolume";
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { Chain } from "@defillama/sdk/build/general";

const endpoints = {
[CHAIN.ERA]:
"https://api.studio.thegraph.com/query/30365/syncswap-graph/1.4.0",
[CHAIN.ERA]: sdk.graph.modifyEndpoint('3PCPSyJXMuC26Vi37w7Q6amJdEJgMDYppfW9sma91uhj'),
[CHAIN.LINEA]: sdk.graph.modifyEndpoint('9R6uvVYXn9V1iAxkTLXL1Ajka75aD7mmHRj86DbXnyYQ'),
[CHAIN.SCROLL]: 'https://graph1.syncswap.xyz/subgraphs/name/syncswap/syncswap-scroll'
};

const adapter = univ2Adapter2(endpoints, {
factoriesName: "syncSwapFactories",
totalVolume: "totalVolumeUSD",
const v3Endpoints = {
[CHAIN.ERA]: sdk.graph.modifyEndpoint('6pXVWtpsLXMLAyS7UU49ftu38MCSVh5fqVoSWLiLBkmP'),
};

const graphs = getChainVolume2({
graphUrls: endpoints,
totalVolume: {
factory: "syncSwapFactories",
field: DEFAULT_TOTAL_VOLUME_FIELD,
},
});

const v3Graphs = getChainVolume2({
graphUrls: v3Endpoints,
totalVolume: {
factory: "factories",
field: DEFAULT_TOTAL_VOLUME_FIELD,
},
dailyVolume: {
factory: "uniswapDayData",
field: 'volumeUSD',
}
});

adapter.adapter.era.start = 1679529600;
const fetch = (chain: Chain) => {
return async (options: FetchOptions) => {
const [v2] = await Promise.all([graphs(chain)(options)])
let dailyVolume = Number(v2.dailyVolume)
if(v3Endpoints[chain]) {
const [v3] = await Promise.all([v3Graphs(chain)(options)])
dailyVolume += Number(v3.dailyVolume);
}
return {
dailyVolume: `${dailyVolume}`,
}
}
}


const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.ERA]: {
fetch: fetch(CHAIN.ERA),
start: '2023-03-23'
},
[CHAIN.LINEA]: {
fetch: fetch(CHAIN.LINEA),
start: '2023-07-19'
},
[CHAIN.SCROLL]: {
fetch: fetch(CHAIN.SCROLL),
start: '2023-10-17'
}
},
};

export default adapter;

0 comments on commit 656aa0d

Please sign in to comment.