-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2431 from amedrontadora/master
feat(syncswap): Add linea and scroll, add zksync-era univ3 pool
- Loading branch information
Showing
1 changed file
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |