Skip to content

Commit

Permalink
track balancer v3 vol & fees
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Dec 11, 2024
1 parent 59c1b0d commit 5d01aed
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
57 changes: 57 additions & 0 deletions dexs/balancer-v3/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import request from "graphql-request";
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";


const adapter: SimpleAdapter = {
version: 2,
adapter: {}
};

const v3ChainMapping: any = {
[CHAIN.ETHEREUM]: 'MAINNET',
[CHAIN.XDAI]: 'GNOSIS',
}

Object.keys(v3ChainMapping).forEach((chain: any) => {
adapter.adapter[chain] = { fetch, runAtCurrTime: true, }
})

// chains = ["MAINNET", "ARBITRUM", "AVALANCHE", "BASE", "GNOSIS", "POLYGON", "ZKEVM", "OPTIMISM", "MODE", "FRAXTAL"]

async function fetch({ createBalances, chain}: FetchOptions) {
const dailyVolume = createBalances()
const dailyFees = createBalances()
const query = `query {
pools: poolGetPools(
first: 1000
skip: 0
orderBy: volume24h
orderDirection: desc
where: { chainIn: [${v3ChainMapping[chain]}] protocolVersionIn: [3]}
) {
address
chain
createTime
decimals
protocolVersion
tags
dynamicData {
totalLiquidity
lifetimeVolume
lifetimeSwapFees
volume24h
fees24h
}
}
}`
const { pools } = await request('https://api-v3.balancer.fi/graphql', query);
pools.forEach((pool: any) => {
dailyFees.addUSDValue(+pool.dynamicData.fees24h)
dailyVolume.addUSDValue(+pool.dynamicData.volume24h)
})
return { dailyFees, dailyVolume }
}


export default adapter;
2 changes: 2 additions & 0 deletions fees/balancer-v3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import adapter from "../dexs/balancer-v3"
export default adapter;

0 comments on commit 5d01aed

Please sign in to comment.