From f0d7b2f080b81806da932dc6df76444417bb7ec2 Mon Sep 17 00:00:00 2001 From: marsclimber0109 Date: Tue, 8 Oct 2024 14:52:34 +0900 Subject: [PATCH 01/86] feat: add core and taiko chains on eisen --- aggregators/eisen/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aggregators/eisen/index.ts b/aggregators/eisen/index.ts index 924a800768..95c76c8770 100644 --- a/aggregators/eisen/index.ts +++ b/aggregators/eisen/index.ts @@ -20,6 +20,8 @@ const FEE_COLLECTORS: TPool = { [CHAIN.BITLAYER]: ["0x5722c0B501e7B9880F9bB13A14217851e45C454f"], [CHAIN.LINEA]: ["0x206168f099013b9eAb979d3520cA00aAD453De55"], [CHAIN.CRONOS]: ["0x0C15c845C4A970b284c0dd61Bcf01c4DC1117d0F"], + [CHAIN.CORE]: ["0x6bD912872B9e704a70f10226ab01A2Db87D0dd1C"], + [CHAIN.TAIKO]: ["0xFA0e9251503DaE51670d10288e6962d63191731d"], }; const START_BLOCKS = { From 33589f0ca6229c826959aa2b836e48153ff32a42 Mon Sep 17 00:00:00 2001 From: marsclimber0109 Date: Tue, 8 Oct 2024 15:20:16 +0900 Subject: [PATCH 02/86] fix: add start_blocks for core and taiko --- aggregators/eisen/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aggregators/eisen/index.ts b/aggregators/eisen/index.ts index 95c76c8770..edd2486607 100644 --- a/aggregators/eisen/index.ts +++ b/aggregators/eisen/index.ts @@ -32,6 +32,8 @@ const START_BLOCKS = { [CHAIN.BITLAYER]: 1704067200, [CHAIN.LINEA]: 1704067200, [CHAIN.CRONOS]: 1704067200, + [CHAIN.CORE]: 1704067200, + [CHAIN.TAIKO]: 1704067200, }; async function fetch({ getLogs, createBalances, chain }: FetchOptions) { From 78df030479303682a9439ef4ce22838e3d23a4ac Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Tue, 8 Oct 2024 15:05:09 +0200 Subject: [PATCH 03/86] disable bitlayer as it is not working --- aggregators/eisen/index.ts | 6 +----- helpers/env.ts | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/aggregators/eisen/index.ts b/aggregators/eisen/index.ts index edd2486607..1d6382c192 100644 --- a/aggregators/eisen/index.ts +++ b/aggregators/eisen/index.ts @@ -8,16 +8,12 @@ type TPool = { [c: string]: string[]; }; -type TBlock = { - [c: string]: number; -}; - const FEE_COLLECTORS: TPool = { [CHAIN.MODE]: ["0x37Cb37b752DBDcd08A872e7dfec256A216C7144C"], [CHAIN.SCROLL]: ["0xA06568773A247657E7b89BBA465014CF85702093"], [CHAIN.MANTLE]: ["0x31d6F212142D3B222EF11c9eBB6AF3569b8442EE"], [CHAIN.BLAST]: ["0xd57Ed7F46D64Ec7b6f04E4A8409D88C55Ef8AA3b"], - [CHAIN.BITLAYER]: ["0x5722c0B501e7B9880F9bB13A14217851e45C454f"], + // [CHAIN.BITLAYER]: ["0x5722c0B501e7B9880F9bB13A14217851e45C454f"], [CHAIN.LINEA]: ["0x206168f099013b9eAb979d3520cA00aAD453De55"], [CHAIN.CRONOS]: ["0x0C15c845C4A970b284c0dd61Bcf01c4DC1117d0F"], [CHAIN.CORE]: ["0x6bD912872B9e704a70f10226ab01A2Db87D0dd1C"], diff --git a/helpers/env.ts b/helpers/env.ts index ee87b9f94d..4f8659d849 100644 --- a/helpers/env.ts +++ b/helpers/env.ts @@ -7,7 +7,7 @@ const DEFAULTS: any = { ZETA_RPC: "https://zetachain-evm.blockpi.network/v1/rpc/public,https://zetachain-mainnet-archive.allthatnode.com:8545", SVM_RPC: "https://rpc.cosvm.net", XLAYER_RPC: "https://xlayerrpc.okx.com", - BITLAYER_RPC: "https://rpc-bitlayer.rockx.com", + BITLAYER_RPC: "https://rpc.bitlayer.org,https://rpc.ankr.com/bitlayer,https://rpc.bitlayer-rpc.com,https://rpc-bitlayer.rockx.com", PLANQ_RPC: "https://planq-rpc.nodies.app,https://jsonrpc.planq.nodestake.top", } From 058c4321dff5438a453467e49819430f59993e57 Mon Sep 17 00:00:00 2001 From: DarthGus Date: Wed, 11 Dec 2024 20:31:33 +0800 Subject: [PATCH 04/86] add plunderswap dex volume --- dexs/plunderswap/index.ts | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 dexs/plunderswap/index.ts diff --git a/dexs/plunderswap/index.ts b/dexs/plunderswap/index.ts new file mode 100644 index 0000000000..8773a8b47e --- /dev/null +++ b/dexs/plunderswap/index.ts @@ -0,0 +1,49 @@ +import fetchURL from "../../utils/fetchURL" +import { ChainBlocks, FetchOptions, SimpleAdapter } from "../../adapters/types"; +import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; + +const historicalVolumeEndpoint = "https://static.plunderswap.com/volume-history" + +interface IVolumeall { + value: string; + time: string; +} + +const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, startOfDay, }: FetchOptions) => { + const dailyVolume = createBalances() + const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); + + // Find the entry closest to the start of day + const closestEntry = historicalVolume + .reduce((closest, current) => { + const currentTime = new Date(current.time).getTime() / 1000; + const closestTime = new Date(closest.time).getTime() / 1000; + return Math.abs(currentTime - dayTimestamp) < Math.abs(closestTime - dayTimestamp) + ? current + : closest; + }); + + if (closestEntry) { + dailyVolume.addCGToken("zilliqa", Number(closestEntry.value)); + } + + return { dailyVolume, timestamp: startOfDay, }; +}; + +const adapter: SimpleAdapter = { + adapter: { + zilliqa: { + fetch, + runAtCurrTime: true, + start: '2024-12-10', + meta: { + methodology: { + Volume: "Volume of trades on Plunderswap at the start of the day (12:00:00 UTC) for the previous day" + } + } + }, + }, +}; + +export default adapter; \ No newline at end of file From f6a080aef8d05d674c6d43d0abe8536e75a6973e Mon Sep 17 00:00:00 2001 From: DarthGus Date: Wed, 11 Dec 2024 23:10:33 +0800 Subject: [PATCH 05/86] filter times before reduce --- dexs/plunderswap/index.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dexs/plunderswap/index.ts b/dexs/plunderswap/index.ts index 8773a8b47e..d0546b4e0e 100644 --- a/dexs/plunderswap/index.ts +++ b/dexs/plunderswap/index.ts @@ -12,11 +12,18 @@ interface IVolumeall { const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, startOfDay, }: FetchOptions) => { const dailyVolume = createBalances() const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) + const nextDayTimestamp = dayTimestamp + 24 * 60 * 60 // Add 24 hours in seconds const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); - // Find the entry closest to the start of day - const closestEntry = historicalVolume - .reduce((closest, current) => { + // First filter entries within the day + const dayEntries = historicalVolume.filter(entry => { + const entryTime = new Date(entry.time).getTime() / 1000; + return entryTime >= dayTimestamp && entryTime < nextDayTimestamp; + }); + + // Then find the closest entry to start of day from filtered entries + if (dayEntries.length > 0) { + const closestEntry = dayEntries.reduce((closest, current) => { const currentTime = new Date(current.time).getTime() / 1000; const closestTime = new Date(closest.time).getTime() / 1000; return Math.abs(currentTime - dayTimestamp) < Math.abs(closestTime - dayTimestamp) @@ -24,7 +31,6 @@ const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, startO : closest; }); - if (closestEntry) { dailyVolume.addCGToken("zilliqa", Number(closestEntry.value)); } From 04badc1ec7106ece4bb8e3b0302e7208cf497545 Mon Sep 17 00:00:00 2001 From: bitkeep-tech <138654908+bitkeep-tech@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:43:26 +0800 Subject: [PATCH 06/86] bitgetwallet bridge aggregators --- bridge-aggregators/bitgetwallet/index.ts | 76 ++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 bridge-aggregators/bitgetwallet/index.ts diff --git a/bridge-aggregators/bitgetwallet/index.ts b/bridge-aggregators/bitgetwallet/index.ts new file mode 100644 index 0000000000..f01ed6e3ac --- /dev/null +++ b/bridge-aggregators/bitgetwallet/index.ts @@ -0,0 +1,76 @@ +import { CHAIN } from "../../helpers/chains"; +import { FetchOptions } from "../../adapters/types"; +import axios from "axios"; +import {getUniqStartOfTodayTimestamp} from "../../helpers/getUniSubgraphVolume"; + + +const CHAINS: Array = [ + CHAIN.ETHEREUM, + CHAIN.POLYGON, + CHAIN.SOLANA, + CHAIN.BSC, + CHAIN.OPTIMISM, + CHAIN.BASE, + CHAIN.TON, + CHAIN.TRON, + CHAIN.BITCOIN, + CHAIN.MANTA, + CHAIN.LINEA, + CHAIN.SUI, + CHAIN.SCROLL, + CHAIN.ARBITRUM, + CHAIN.CORE, + CHAIN.MERLIN, + CHAIN.BLAST, + CHAIN.APTOS +]; + + + + +interface IVolumeBridge { + volume: string; + date: string; +} + +async function queryDataByApi(timestamp:string, path:string){ + const historicalVolumeEndpoint = "https://new-swapopen.bitapi.vip/st"; + let info = await axios.get(`${historicalVolumeEndpoint}${path}`); + const data : IVolumeBridge[] = (info?.data)?.data.list; + return data +} + +const fetch = async (timestamp: number, block: any, options: FetchOptions) => { + const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) + const path = `/getOrderDayList?bridge=1&chain=${options.chain}×tamp=${timestamp}` + const data = await queryDataByApi(timestamp.toString(), path) + let dailyVolume = data.find(dayItem => (new Date(dayItem.date).getTime() / 1000) === dayTimestamp)?.volume + dailyVolume = dailyVolume || "0"; + return { + dailyBridgeVolume: dailyVolume, + timestamp: options.endTimestamp, + }; +}; + +const adapter: any = { + version: 1, // api supports other timestamps but if you try using current timestamps, it breaks, so sticking to v1 even though it should be able to support v2 + adapter: { + ...CHAINS.map(chain => { + return { + + [chain]: { + fetch: fetch, + start: '2024-01-01' + } + + } + }).reduce((acc, item) => { + return { + ...acc, + ...item + } + }) + }, +}; + +export default adapter; From 175ffa848062dfc1786c578e9926310a39224881 Mon Sep 17 00:00:00 2001 From: bitkeep-tech <138654908+bitkeep-tech@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:33:11 +0800 Subject: [PATCH 07/86] support SUI --- aggregators/bitgetwallet/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aggregators/bitgetwallet/index.ts b/aggregators/bitgetwallet/index.ts index 5d7a89e1dc..52bdcc62a2 100644 --- a/aggregators/bitgetwallet/index.ts +++ b/aggregators/bitgetwallet/index.ts @@ -42,7 +42,8 @@ const CHAINS: Array = [ CHAIN.BASE, CHAIN.TON, CHAIN.TRON, - CHAIN.BITCOIN + CHAIN.BITCOIN, + CHAIN.SUI ]; From 3c66901afffd86b7e944ce6a6cf65e7bdb4547ce Mon Sep 17 00:00:00 2001 From: memeweclub Date: Thu, 12 Dec 2024 04:05:44 -0800 Subject: [PATCH 08/86] Add MemeWe.club --- fees/memewe/index.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 fees/memewe/index.ts diff --git a/fees/memewe/index.ts b/fees/memewe/index.ts new file mode 100644 index 0000000000..74ce8b6408 --- /dev/null +++ b/fees/memewe/index.ts @@ -0,0 +1,28 @@ +import { Adapter, FetchOptions } from "../../adapters/types"; +import { CHAIN } from "../../helpers/chains"; +import { httpGet } from "../../utils/fetchURL"; + +const api = "https://backend.memewe.club/trade/stats/fee"; + +const adapter: Adapter = { + version: 1, + adapter: { + [CHAIN.BASE]: { + fetch: (async (_t: any, _a: any, options: FetchOptions) => { + const end = options.toTimestamp; + const url = `${api}/${end}`; + const fee = Number(await httpGet(url)); + const dailyFees = options.createBalances(); + dailyFees.addGasToken(fee || 0); + return { + dailyFees, + dailyRevenue: dailyFees, + timestamp: options.startOfDay, + }; + }) as any, + start: "2024-11-28", + }, + }, +}; + +export default adapter; From d5e09a9b5a0ba61ff0ac44c4cea0a8bc26b93b7a Mon Sep 17 00:00:00 2001 From: Arpit Singh Date: Thu, 12 Dec 2024 17:49:04 +0530 Subject: [PATCH 09/86] logx options volume adapter --- options/logx/index.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 options/logx/index.ts diff --git a/options/logx/index.ts b/options/logx/index.ts new file mode 100644 index 0000000000..92bf377aa1 --- /dev/null +++ b/options/logx/index.ts @@ -0,0 +1,36 @@ +import fetchURL from "../../utils/fetchURL"; +import { FetchResult, SimpleAdapter } from "../../adapters/types"; +import { CHAIN } from "../../helpers/chains"; + + +const URLEndpoint = "https://mainnetapiserver.logx.network/api/v1/stats/defillama/options?endTime="; +const startTimestamp = 1733961600; // 12.12.2024 + +interface IAPIResponse { + last24HourVolume: string; + totalVolume: string; +} +const fetch = async (timestamp: number): Promise => { + const { last24HourVolume, totalVolume }: IAPIResponse = ( + await fetchURL(`${URLEndpoint}${timestamp}`) + ); + + return { + totalPremiumVolume: totalVolume, + dailyPremiumVolume: last24HourVolume, + timestamp: timestamp, + dailyNotionalVolume: 0, + totalNotionalVolume: 0, + }; +}; + +const adapter: SimpleAdapter = { + adapter: { + [CHAIN.LOGX]: { + fetch, + start: startTimestamp, + }, + } +}; + +export default adapter; \ No newline at end of file From e706bf14458a6f17fc2a72f41ccc35404ea7d17a Mon Sep 17 00:00:00 2001 From: 0xngmi <80541789+0xngmi@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:48:09 +0000 Subject: [PATCH 10/86] update comment bot --- .github/workflows/commentResult.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/commentResult.js b/.github/workflows/commentResult.js index 8afad4f98a..29b0258c2c 100644 --- a/.github/workflows/commentResult.js +++ b/.github/workflows/commentResult.js @@ -1,6 +1,6 @@ const { readFileSync } = require('fs'); const axios = require('axios'); -const junk = 'VPTOH1X0B7rf8od7BGNsQ1z0BJk8iMNLxqrD'; +const junk = 'rmicl\x1Eefn]JsfjoHoGRpWOt3_u@L_LpTUc_BLf0T/i/mXC'; async function main() { const [, , log, author, repo, pr, adapterNameKey ] = process.argv; @@ -34,12 +34,14 @@ async function main() { `https://api.github.com/repos/${author}/${repo}/issues/${pr}/comments`, { body }, { headers: { - Authorization: `token ghp_${translate(junk)}`, + Authorization: scramble(junk), Accept: 'application/vnd.github.v3+json' } }); }; -function translate(input) { - return input ? translate(input.substring(1)) + input[0] : input; -}; +function scramble(str) { + return str.split('').reduce((a, b) => { + return a + String.fromCharCode(b.charCodeAt(0) + 2); + }, ''); +} main(); From 8aabb3110795f481f8d81662aff4dbea4636ebff Mon Sep 17 00:00:00 2001 From: waynebruce0x Date: Thu, 12 Dec 2024 13:53:30 +0000 Subject: [PATCH 11/86] swapbased --- dexs/swapbased/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dexs/swapbased/index.ts b/dexs/swapbased/index.ts index 82a30c5898..bc71c9b8f1 100644 --- a/dexs/swapbased/index.ts +++ b/dexs/swapbased/index.ts @@ -16,7 +16,7 @@ const methodology = { const endpointsPerps: { [key: string]: string } = { [CHAIN.BASE]: - "https://api.thegraph.com/subgraphs/name/chimpydev/swapbased-perps-core", + "https://api.studio.thegraph.com/query/67101/swapbased-perps-core/version/latest", }; const historicalDataSwap = gql` @@ -144,7 +144,7 @@ const adapter: BreakdownAdapter = { getUniV2LogAdapter({ factory: "0x04C9f118d21e8B767D2e50C946f0cC9F6C367300", })(options), - start: '2023-07-28', + start: "2023-07-28", meta: { methodology }, }, }, @@ -156,13 +156,13 @@ const adapter: BreakdownAdapter = { swapEvent: "event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick, uint128 protocolFeesToken0, uint128 protocolFeesToken1)", })(options), - start: '2023-07-27', + start: "2023-07-27", }, }, perps: { [CHAIN.BASE]: { fetch: getFetch(historicalDataSwap)(CHAIN.BASE), - start: '2023-07-09', + start: "2023-07-09", }, }, }, From f3afeac6000498eb833aac0c4b57d915f4c34073 Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:30:12 +0100 Subject: [PATCH 12/86] cowswap: track base --- aggregators/cowswap/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aggregators/cowswap/index.ts b/aggregators/cowswap/index.ts index a1f8d96ae4..e671719278 100644 --- a/aggregators/cowswap/index.ts +++ b/aggregators/cowswap/index.ts @@ -4,7 +4,7 @@ const abis = { "Trade": "event Trade(address indexed owner, address sellToken, address buyToken, uint256 sellAmount, uint256 buyAmount, uint256 feeAmount, bytes orderUid)", // gnosis } -const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, getLogs, chain, api }: FetchOptions) => { +const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, getLogs, }: FetchOptions) => { const dailyVolume = createBalances() const logs = await getLogs({ target: '0x9008d19f58aabd9ed0d60971565aa8510560ab41', eventAbi: abis.Trade, }) @@ -19,6 +19,7 @@ const adapter: any = { ethereum: { fetch, start: '2023-05-31', }, xdai: { fetch, start: '2023-05-31', }, arbitrum: { fetch, start: '2024-04-26', }, + base: { fetch, start: '2024-12-10', }, }, }; From c200c17e820f3a7bd05b1762f70a88ed78800b01 Mon Sep 17 00:00:00 2001 From: 0xngmi <0xngmi@protonmail.com> Date: Thu, 12 Dec 2024 15:57:55 +0000 Subject: [PATCH 13/86] fix tether attestation diff --- fees/tether/attestations-stablecoins.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fees/tether/attestations-stablecoins.ts b/fees/tether/attestations-stablecoins.ts index dc5659e007..387abbac4b 100644 --- a/fees/tether/attestations-stablecoins.ts +++ b/fees/tether/attestations-stablecoins.ts @@ -20,7 +20,7 @@ export function buildStablecoinAdapter(stablecoinId: string, daysBetweenAttestat const supply = (findClosest(fromTimestamp, stablecoinData.tokens.map((d: any)=>({...d, time: d.date*1e3})), 1.5 * 24 * 3600) as any).circulating.peggedUSD const closestAttestation = findClosest(fromTimestamp, attestations) - if (new Date(closestAttestation.time).getTime() > fromTimestamp * 1e3 - 1.2 * daysBetweenAttestations * 24 * 3600e3) { + if (new Date(closestAttestation.time).getTime() - 1.2 * daysBetweenAttestations * 24 * 3600e3 > fromTimestamp * 1e3) { throw new Error("Trying to refill with no attestations, pls add attestations") } From fb93befd255647e95c790ca1cab5690094927ad5 Mon Sep 17 00:00:00 2001 From: DarthGus Date: Fri, 13 Dec 2024 09:10:21 +0800 Subject: [PATCH 14/86] update to a more simpler workout of the entry --- dexs/plunderswap/index.ts | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/dexs/plunderswap/index.ts b/dexs/plunderswap/index.ts index d0546b4e0e..e9f10201f9 100644 --- a/dexs/plunderswap/index.ts +++ b/dexs/plunderswap/index.ts @@ -12,26 +12,18 @@ interface IVolumeall { const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, startOfDay, }: FetchOptions) => { const dailyVolume = createBalances() const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const nextDayTimestamp = dayTimestamp + 24 * 60 * 60 // Add 24 hours in seconds const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); - // First filter entries within the day + // Format the timestamp without milliseconds + const targetTime = new Date(dayTimestamp * 1000).toISOString().replace('.000Z', 'Z'); + + // Filter entries to find exact 00:00 UTC entry of the current day const dayEntries = historicalVolume.filter(entry => { - const entryTime = new Date(entry.time).getTime() / 1000; - return entryTime >= dayTimestamp && entryTime < nextDayTimestamp; + return entry.time === targetTime; }); - // Then find the closest entry to start of day from filtered entries if (dayEntries.length > 0) { - const closestEntry = dayEntries.reduce((closest, current) => { - const currentTime = new Date(current.time).getTime() / 1000; - const closestTime = new Date(closest.time).getTime() / 1000; - return Math.abs(currentTime - dayTimestamp) < Math.abs(closestTime - dayTimestamp) - ? current - : closest; - }); - - dailyVolume.addCGToken("zilliqa", Number(closestEntry.value)); + dailyVolume.addCGToken("zilliqa", Number(dayEntries[0].value)); } return { dailyVolume, timestamp: startOfDay, }; @@ -45,7 +37,7 @@ const adapter: SimpleAdapter = { start: '2024-12-10', meta: { methodology: { - Volume: "Volume of trades on Plunderswap at the start of the day (12:00:00 UTC) for the previous day" + Volume: "Volume of trades on Plunderswap at the start of the day (00:00:00 UTC) for the previous day" } } }, From 416209bf0583f7da0b2606b4bcc0da6e219c77f3 Mon Sep 17 00:00:00 2001 From: waynebruce0x Date: Fri, 13 Dec 2024 08:52:57 +0000 Subject: [PATCH 15/86] uni v2 fees --- protocols/uniswap/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/uniswap/index.ts b/protocols/uniswap/index.ts index 185dd459a8..969a6e8ee7 100644 --- a/protocols/uniswap/index.ts +++ b/protocols/uniswap/index.ts @@ -185,7 +185,7 @@ const fetchV2 = async (options: FetchOptions) => { 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36' }); const dailyVolume = response.v2HistoricalProtocolVolume.find((item) => item.timestamp === options.startOfDay)?.value; - return {dailyVolume: dailyVolume} + return { dailyVolume, dailyFees: Number(dailyVolume) * 0.003 }; } catch (e) { console.error(e) return { From f4e78474fa9d348a01dc0a4e8f8f6cdbec873ff4 Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Fri, 13 Dec 2024 12:20:53 +0000 Subject: [PATCH 16/86] add restrictemode --- helpers/env.ts | 1 + helpers/flipsidecrypto.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/helpers/env.ts b/helpers/env.ts index c7dde6736c..696683b8cd 100644 --- a/helpers/env.ts +++ b/helpers/env.ts @@ -32,6 +32,7 @@ export const ENV_KEYS = new Set([ 'OKX_API_KEY', 'ALCHEMIX_KEY', 'ALCHEMIX_SECRET', + 'FLIPSIDE_RESTRICTED_MODE', ]) // This is done to support both ZEROx_API_KEY and ZEROX_API_KEY diff --git a/helpers/flipsidecrypto.ts b/helpers/flipsidecrypto.ts index 47f1c4d6d0..a3eaf33994 100644 --- a/helpers/flipsidecrypto.ts +++ b/helpers/flipsidecrypto.ts @@ -4,6 +4,7 @@ import { httpPost } from "../utils/fetchURL"; import { getEnv } from "./env"; const token = {} as IJSON +const isRestrictedMode = getEnv('FLIPSIDE_RESTRICTED_MODE') === 'true' const FLIPSIDE_API_KEYS = getEnv('FLIPSIDE_API_KEY')?.split(',') ?? ["f3b65679-a179-4983-b794-e41cf40103ed"] let API_KEY_INDEX = 0; const MAX_RETRIES = 20; @@ -19,6 +20,7 @@ async function randomDelay() { } export async function queryFlipside(sqlQuery: string, maxAgeMinutes: number = 90) { + checkCanFlipSideQuery(); if (!query[sqlQuery]) { query[sqlQuery] = _queryFlipside(sqlQuery, maxAgeMinutes) } @@ -178,3 +180,10 @@ async function _queryFlipside(sqlQuery: string, maxAgeMinutes: number = 90) { } ); } + +export function checkCanFlipSideQuery() { + if (!isRestrictedMode) return; + const currentHour = new Date().getUTCHours(); + if (currentHour >= 1 && currentHour <= 3) return; // 1am - 3am - any time other than this, throw error + throw new Error(`Current hour is ${currentHour}. In restricted mode, can run flipsside queries only between 1am - 3am UTC`); +} From 3421df69a022bee42e4e042d444799990fa663d8 Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Fri, 13 Dec 2024 13:38:54 +0000 Subject: [PATCH 17/86] fix base chain --- protocols/pancakeswap/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/pancakeswap/index.ts b/protocols/pancakeswap/index.ts index 3deb43671a..50a74fa30c 100644 --- a/protocols/pancakeswap/index.ts +++ b/protocols/pancakeswap/index.ts @@ -13,7 +13,7 @@ const endpoints = { [CHAIN.ERA]: "https://api.studio.thegraph.com/query/45376/exchange-v2-zksync/version/latest", [CHAIN.ARBITRUM]: sdk.graph.modifyEndpoint('EsL7geTRcA3LaLLM9EcMFzYbUgnvf8RixoEEGErrodB3'), [CHAIN.LINEA]: "https://graph-query.linea.build/subgraphs/name/pancakeswap/exhange-v2", - [CHAIN.BASE]: "https://api.studio.thegraph.com/query/45376/exchange-v2-base/version/latest", + [CHAIN.BASE]: sdk.graph.modifyEndpoint('2NjL7L4CmQaGJSacM43ofmH6ARf6gJoBeBaJtz9eWAQ9'), [CHAIN.OP_BNB]: `${getEnv('PANCAKESWAP_OPBNB_SUBGRAPH')}/subgraphs/name/pancakeswap/exchange-v2` }; @@ -30,7 +30,7 @@ const v3Endpoint = { [CHAIN.ERA]: "https://api.studio.thegraph.com/query/45376/exchange-v3-zksync/version/latest", [CHAIN.ARBITRUM]: sdk.graph.modifyEndpoint('251MHFNN1rwjErXD2efWMpNS73SANZN8Ua192zw6iXve'), [CHAIN.LINEA]: "https://graph-query.linea.build/subgraphs/name/pancakeswap/exchange-v3-linea", - [CHAIN.BASE]: "https://api.studio.thegraph.com/query/45376/exchange-v3-base/version/latest", + [CHAIN.BASE]: sdk.graph.modifyEndpoint('5YYKGBcRkJs6tmDfB3RpHdbK2R5KBACHQebXVgbUcYQp'), [CHAIN.OP_BNB]: `${getEnv('PANCAKESWAP_OPBNB_SUBGRAPH')}/subgraphs/name/pancakeswap/exchange-v3` } From 6a931ac17c8a6e7b5f634b5c4f821dd570d1143e Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Fri, 13 Dec 2024 14:31:27 +0000 Subject: [PATCH 18/86] fix plunderswap --- dexs/plunderswap/index.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dexs/plunderswap/index.ts b/dexs/plunderswap/index.ts index e9f10201f9..cda447380b 100644 --- a/dexs/plunderswap/index.ts +++ b/dexs/plunderswap/index.ts @@ -13,10 +13,10 @@ const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, startO const dailyVolume = createBalances() const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); - + // Format the timestamp without milliseconds const targetTime = new Date(dayTimestamp * 1000).toISOString().replace('.000Z', 'Z'); - + // Filter entries to find exact 00:00 UTC entry of the current day const dayEntries = historicalVolume.filter(entry => { return entry.time === targetTime; @@ -32,8 +32,7 @@ const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, startO const adapter: SimpleAdapter = { adapter: { zilliqa: { - fetch, - runAtCurrTime: true, + fetch: fetch, start: '2024-12-10', meta: { methodology: { @@ -44,4 +43,4 @@ const adapter: SimpleAdapter = { }, }; -export default adapter; \ No newline at end of file +export default adapter; From 498e78848f60cf13b297eb6a9e6d9e477c0a02e9 Mon Sep 17 00:00:00 2001 From: marsclimber0109 Date: Sat, 14 Dec 2024 14:29:28 +0900 Subject: [PATCH 19/86] feat: add zircuit and base chains --- aggregators/eisen/index.ts | 4 ++++ helpers/chains.ts | 28 +++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/aggregators/eisen/index.ts b/aggregators/eisen/index.ts index 1d6382c192..706f6709fc 100644 --- a/aggregators/eisen/index.ts +++ b/aggregators/eisen/index.ts @@ -18,6 +18,8 @@ const FEE_COLLECTORS: TPool = { [CHAIN.CRONOS]: ["0x0C15c845C4A970b284c0dd61Bcf01c4DC1117d0F"], [CHAIN.CORE]: ["0x6bD912872B9e704a70f10226ab01A2Db87D0dd1C"], [CHAIN.TAIKO]: ["0xFA0e9251503DaE51670d10288e6962d63191731d"], + [CHAIN.ZIRCUIT]: ["0x6bD912872B9e704a70f10226ab01A2Db87D0dd1C"], + [CHAIN.BASE]: ["0x14C3B68e5855B60263b10eC0fCE54DE3e28AD880"], }; const START_BLOCKS = { @@ -30,6 +32,8 @@ const START_BLOCKS = { [CHAIN.CRONOS]: 1704067200, [CHAIN.CORE]: 1704067200, [CHAIN.TAIKO]: 1704067200, + [CHAIN.ZIRCUIT]: 1704067200, + [CHAIN.BASE]: 1704067200, }; async function fetch({ getLogs, createBalances, chain }: FetchOptions) { diff --git a/helpers/chains.ts b/helpers/chains.ts index 8da93da49d..e7e68f183e 100644 --- a/helpers/chains.ts +++ b/helpers/chains.ts @@ -1,6 +1,8 @@ // Use export enum CHAIN { + TARA = "tara", ARBITRUM = "arbitrum", + ASSETCHAIN = "assetchain", AVAX = "avax", BLAST = "blast", BAHAMUT = "ftn", @@ -17,6 +19,7 @@ export enum CHAIN { OKEXCHAIN = "okexchain", OPTIMISM = "optimism", POLYGON = "polygon", + POLYNOMIAL = "polynomial", RONIN = "ronin", ROOTSTOCK = "rsk", XDAI = "xdai", @@ -143,7 +146,7 @@ export enum CHAIN { JBC = "jbc", ZKFAIR = "zkfair", ZETA = "zeta", - ASTAR = 'astar', + ASTAR = "astar", ASTAR_ZKEVM = "astrzk", FILECOIN = "filecoin", FRAXTAL = "fraxtal", @@ -171,6 +174,27 @@ export enum CHAIN { FLARE = "flare", NUMBERS = "numbers", BSQUARED = "bsquared", + LISK = "lisk", + MINT = "mint", + HELA = "hela", + FUEL = "fuel", + REAL = "real", + CELESTIA = "celestia", + MORPH = "morph", + APECHAIN = "apechain", + DUCKCHAIN = "duckchain", + GRAVITY = "gravity", + RARI = "rari", + REYA = "reya", + SANKO = "sanko", + ECLIPSE = "eclipse", + UNIT0 = "unit0", + SHIDO = "shido", + ACE = "ace", + BOUNCE_BIT = "bouncebit", + ZIRCUIT = "zircuit", + WC = "wc", + ARCHWAY = "archway-1", } // Don´t use @@ -195,6 +219,7 @@ const LITECOIN = "litecoin"; const DOGE = "doge"; const ZKSYNC = "zksync"; const MANTLE = "mantle"; +const POLYNOMIAL = "polynomial"; // Don't use export { ARBITRUM, @@ -218,4 +243,5 @@ export { RONIN, XDAI, ZKSYNC, + POLYNOMIAL, }; From fc038fd327190d2855d5f5e3b761c112b673a72f Mon Sep 17 00:00:00 2001 From: marsclimber0109 Date: Sat, 14 Dec 2024 14:33:28 +0900 Subject: [PATCH 20/86] chore: reorder the chain visualization --- aggregators/eisen/index.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/aggregators/eisen/index.ts b/aggregators/eisen/index.ts index 706f6709fc..c1ba854083 100644 --- a/aggregators/eisen/index.ts +++ b/aggregators/eisen/index.ts @@ -9,31 +9,31 @@ type TPool = { }; const FEE_COLLECTORS: TPool = { - [CHAIN.MODE]: ["0x37Cb37b752DBDcd08A872e7dfec256A216C7144C"], [CHAIN.SCROLL]: ["0xA06568773A247657E7b89BBA465014CF85702093"], + [CHAIN.ZIRCUIT]: ["0x6bD912872B9e704a70f10226ab01A2Db87D0dd1C"], + [CHAIN.LINEA]: ["0x206168f099013b9eAb979d3520cA00aAD453De55"], [CHAIN.MANTLE]: ["0x31d6F212142D3B222EF11c9eBB6AF3569b8442EE"], [CHAIN.BLAST]: ["0xd57Ed7F46D64Ec7b6f04E4A8409D88C55Ef8AA3b"], + [CHAIN.BASE]: ["0x14C3B68e5855B60263b10eC0fCE54DE3e28AD880"], + [CHAIN.CORE]: ["0x6bD912872B9e704a70f10226ab01A2Db87D0dd1C"], // [CHAIN.BITLAYER]: ["0x5722c0B501e7B9880F9bB13A14217851e45C454f"], - [CHAIN.LINEA]: ["0x206168f099013b9eAb979d3520cA00aAD453De55"], [CHAIN.CRONOS]: ["0x0C15c845C4A970b284c0dd61Bcf01c4DC1117d0F"], - [CHAIN.CORE]: ["0x6bD912872B9e704a70f10226ab01A2Db87D0dd1C"], [CHAIN.TAIKO]: ["0xFA0e9251503DaE51670d10288e6962d63191731d"], - [CHAIN.ZIRCUIT]: ["0x6bD912872B9e704a70f10226ab01A2Db87D0dd1C"], - [CHAIN.BASE]: ["0x14C3B68e5855B60263b10eC0fCE54DE3e28AD880"], + [CHAIN.MODE]: ["0x37Cb37b752DBDcd08A872e7dfec256A216C7144C"], }; const START_BLOCKS = { - [CHAIN.MODE]: 1704067200, [CHAIN.SCROLL]: 1704067200, + [CHAIN.ZIRCUIT]: 1704067200, + [CHAIN.LINEA]: 1704067200, [CHAIN.MANTLE]: 1704067200, [CHAIN.BLAST]: 1704067200, + [CHAIN.BASE]: 1704067200, [CHAIN.BITLAYER]: 1704067200, - [CHAIN.LINEA]: 1704067200, - [CHAIN.CRONOS]: 1704067200, [CHAIN.CORE]: 1704067200, + [CHAIN.CRONOS]: 1704067200, [CHAIN.TAIKO]: 1704067200, - [CHAIN.ZIRCUIT]: 1704067200, - [CHAIN.BASE]: 1704067200, + [CHAIN.MODE]: 1704067200, }; async function fetch({ getLogs, createBalances, chain }: FetchOptions) { From 0ae89958206756077b56b32d3b56abe27950926f Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Sat, 14 Dec 2024 11:49:35 +0100 Subject: [PATCH 21/86] add 24h volume --- dexs/mars-perp/index.ts | 45 +++++++++++++++++++++++++++++++++++++++++ helpers/chains.ts | 1 + 2 files changed, 46 insertions(+) create mode 100644 dexs/mars-perp/index.ts diff --git a/dexs/mars-perp/index.ts b/dexs/mars-perp/index.ts new file mode 100644 index 0000000000..7cffa37845 --- /dev/null +++ b/dexs/mars-perp/index.ts @@ -0,0 +1,45 @@ +import axios from "axios"; +import BigNumber from "bignumber.js"; +import { FetchResult } from "../../adapters/types"; +import { CHAIN } from "../../helpers/chains"; + +const fetch = async (timestamp: number): Promise => { + const perpsInfoApi = `https://backend.prod.mars-dev.net/v2/perps_overview?chain=neutron&days=2&response_type=global`; + const perpsVolumeData = await axios(perpsInfoApi); + const globalOverview = perpsVolumeData.data.global_overview; + + let last24HourVolume = 0; + let fetchTimestamp = timestamp; + + // The second element in the array is the last 24 hour volume, while the first element is the current volume of the ongoing day + if (globalOverview && globalOverview.daily_trading_volume.length > 1) { + // Volume is returned in uusd which has 6 decimals + last24HourVolume = new BigNumber( + globalOverview.daily_trading_volume[1].value + ) + .shiftedBy(-6) + .toNumber(); + fetchTimestamp = Math.round( + new Date(globalOverview.daily_trading_volume[1].date).getTime() / 1000 + ); + } + + return { + dailyVolume: last24HourVolume, + timestamp: fetchTimestamp, + }; +}; + +const adapter = { + version: 2, + breakdown: { + derivatives: { + [CHAIN.NEUTRON]: { + fetch, + runAtCurrTime: true, + start: "2024-12-13", + }, + }, + }, +}; +export default adapter; diff --git a/helpers/chains.ts b/helpers/chains.ts index e7e68f183e..524988ec34 100644 --- a/helpers/chains.ts +++ b/helpers/chains.ts @@ -195,6 +195,7 @@ export enum CHAIN { ZIRCUIT = "zircuit", WC = "wc", ARCHWAY = "archway-1", + NEUTRON = "neutron", } // Don´t use From e0c7c048ed5535cc9d9f529355af27af2c7d1dd2 Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Sat, 14 Dec 2024 11:57:03 +0100 Subject: [PATCH 22/86] add fees and methodology --- dexs/mars-perp/index.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/dexs/mars-perp/index.ts b/dexs/mars-perp/index.ts index 7cffa37845..4e0bd6dc18 100644 --- a/dexs/mars-perp/index.ts +++ b/dexs/mars-perp/index.ts @@ -10,6 +10,7 @@ const fetch = async (timestamp: number): Promise => { let last24HourVolume = 0; let fetchTimestamp = timestamp; + let last24HourFees = 0; // The second element in the array is the last 24 hour volume, while the first element is the current volume of the ongoing day if (globalOverview && globalOverview.daily_trading_volume.length > 1) { @@ -19,6 +20,19 @@ const fetch = async (timestamp: number): Promise => { ) .shiftedBy(-6) .toNumber(); + const last24HourTradingFee = new BigNumber( + globalOverview.fees.trading_fee[1].value + ) + .shiftedBy(-6) + .toNumber(); + const last24HourFundingFee = new BigNumber( + globalOverview.fees.net_funding_fee[1].value + ) + .shiftedBy(-6) + .toNumber(); + + last24HourFees = last24HourTradingFee + last24HourFundingFee; + fetchTimestamp = Math.round( new Date(globalOverview.daily_trading_volume[1].date).getTime() / 1000 ); @@ -26,6 +40,7 @@ const fetch = async (timestamp: number): Promise => { return { dailyVolume: last24HourVolume, + dailyRevenue: last24HourFees, timestamp: fetchTimestamp, }; }; @@ -38,6 +53,14 @@ const adapter = { fetch, runAtCurrTime: true, start: "2024-12-13", + meta: { + methodology: { + dailyVolume: + "Volume is calculated by summing the token volume of all perpetual trades settled on the protocol that day.", + dailyRevenue: + "Revenue is calculated by summing the trading and funding fees of all perpetual trades settled on the protocol that day.", + }, + }, }, }, }, From 4b041aa1b10ce2fc41684d57f3eb6c62a60c03e3 Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Sat, 14 Dec 2024 19:40:44 +0100 Subject: [PATCH 23/86] Refactor fees adaptar THORChain protocol --- fees/thorswap/index.ts | 189 ++++++++++++++++++++++++----------------- 1 file changed, 111 insertions(+), 78 deletions(-) diff --git a/fees/thorswap/index.ts b/fees/thorswap/index.ts index b3ee2cbe35..2e2c010a23 100644 --- a/fees/thorswap/index.ts +++ b/fees/thorswap/index.ts @@ -1,94 +1,127 @@ -import { FetchResultFees, SimpleAdapter } from "../../adapters/types" +import BigNumber from "bignumber.js"; +import { SimpleAdapter } from "../../adapters/types" import { CHAIN } from "../../helpers/chains" -import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; import { httpGet } from "../../utils/fetchURL"; -interface IRevenue { - DAY: string; - NETWORK_FEE: number; - SLASHING_INCOME: number; - LIQUIDITY_FEES: number; - OUTBOUND_FEE: number; - GAS_REIMBURSEMENT: number; - IL_PROTECTION: number; - BLOCK_REWARDS: number; - REVENUE: number; - EXPENSES: number; +const chainMapping = { + ETH: CHAIN.ETHEREUM, + BTC: CHAIN.BITCOIN, + AVAX: CHAIN.AVAX, + BSC: CHAIN.BSC, + LTC: CHAIN.LITECOIN, + BCH: CHAIN.BITCOIN_CASH, + DOGE: CHAIN.DOGECHAIN, + GAIA: CHAIN.COSMOS, } -interface IFees { - DAY: string; - LIQUIDITY_FEES: number; - LIQUIDITY_FEES_USD: number; - BLOCK_REWARDS: number; - BLOCK_REWARDS_USD: number; - PCT_OF_EARNINGS_FROM_LIQ_FEES: number; - PCT_30D_MOVING_AVERAGE: number; - TOTAL_EARNINGS: number; - TOTAL_EARNINGS_USD: number; - EARNINGS_TO_NODES: number; - EARNINGS_TO_NODES_USD: number; - EARNINGS_TO_POOLS: number; - EARNINGS_TO_POOLS_USD: number; - LIQUIDITY_FEES_USD_CUMULATIVE: number; - BLOCK_REWARDS_USD_CUMULATIVE: number; - TOTAL_EARNINGS_USD_CUMULATIVE: number; - EARNINGS_TO_NODES_USD_CUMULATIVE: number; - EARNINGS_TO_POOLS_USD_CUMULATIVE: number; +interface Pool { + assetLiquidityFees: string + earnings: string + pool: string + rewards: string + runeLiquidityFees: string + saverEarning: string + totalLiquidityFeesRune: string } -interface IEarning { - bondingEarnings: string; - runePriceUSD: string; - startTime: string; +const assetFromString = (s: string) => { + + const NATIVE_ASSET_DELIMITER = '.' + const SYNTH_ASSET_DELIMITER = '/' + const TRADE_ASSET_DELIMITER = '~' + + const isSynth = s.includes(SYNTH_ASSET_DELIMITER) + const isTrade = s.includes(TRADE_ASSET_DELIMITER) + const delimiter = isSynth ? SYNTH_ASSET_DELIMITER : isTrade ? TRADE_ASSET_DELIMITER : NATIVE_ASSET_DELIMITER + + const data = s.split(delimiter) + if (data.length <= 1 || !data[1]) return null + + const chain = data[0].trim() + const symbol = data[1].trim() + const ticker = symbol.split('-')[0] + + if (!symbol || !chain) return null + + return { chain, symbol, ticker } } -const fetchFees = async (timestamp: number): Promise => { - const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const url1 = "https://flipsidecrypto.xyz/api/v1/queries/9ed4f699-100a-41e5-a3e6-a7f9ed3bfd5c/data/latest" - const url2 = "https://flipsidecrypto.xyz/api/v1/queries/40798a6b-1e67-4ecb-b8b3-8f8354b5798a/data/latest" - const url3 = `https://midgard.ninerealms.com/v2/history/earnings?interval=day&count=400` - const [reveune, fees, earnings]: any = (await Promise.all([ - httpGet(url1), - httpGet(url2), - httpGet(url3, { headers: {"x-client-id": "defillama"}}) - ])) - - const reveuneData: IRevenue[] = reveune; - const feesData: IFees[] = fees; - const earningData: IEarning[] = earnings.intervals; - - const dayTimestampStr = new Date(timestamp * 1000).toISOString().split("T")[0] - const dailyRevenueData: IRevenue = reveuneData.find(item => item.DAY.split(" ")[0] === dayTimestampStr) as IRevenue - const dailyFeesData: IFees = feesData.find(item => item.DAY.split(" ")[0] === dayTimestampStr) as IFees - const dailyErningData: IEarning = earningData.find(item => Number(item.startTime) === dayTimestamp) as IEarning - const dailyFees = Number(dailyRevenueData.REVENUE) * Number(dailyErningData.runePriceUSD); - const dailyUsersFees = dailyFeesData?.LIQUIDITY_FEES || 0 + dailyRevenueData?.OUTBOUND_FEE || 0; - const dailyRevenue = Number(dailyRevenueData.REVENUE) * Number(dailyErningData.runePriceUSD); - const dailyProtocolRev = Number(dailyRevenueData.REVENUE) * Number(dailyErningData.runePriceUSD); - const dailyHoldersRevenue = (Number(dailyErningData.bondingEarnings) / 1e8) *Number(dailyErningData.runePriceUSD); - const dailySupplySideRevenue = dailyHoldersRevenue - - - return { - dailyFees: dailyFees ? `${dailyFees}` : undefined, - dailyUserFees: dailyUsersFees ? `${dailyUsersFees}` : undefined, - dailyRevenue: dailyRevenue ? `${dailyRevenue}` : undefined, - dailyProtocolRevenue: dailyProtocolRev ? `${dailyProtocolRev}` : undefined, - dailyHoldersRevenue: dailyHoldersRevenue ? `${dailyHoldersRevenue}` : undefined, - dailySupplySideRevenue: dailySupplySideRevenue ? `${dailySupplySideRevenue}` : undefined, - timestamp +const findInterval = (timestamp: number, intervals) => { + for (const interval of intervals) { + if (interval.startTime <= timestamp && timestamp < interval.endTime) { + return interval; + } } + return null; +}; + +const fetchFeesByChain = () => { + const adapter = {} + const chains = ['BTC', 'ETH', 'LTC', 'DOGE', 'GAIA', 'AVAX', 'BSC', 'BCH'] + chains.forEach((chain: string) => { + adapter[chainMapping[chain]] = { + runAtCurrTime: true, + fetch: async (timestamp: number) => { + + const url = `https://midgard.ninerealms.com/v2/history/earnings?interval=day&count=2` + const url2 = `https://midgard.ninerealms.com/v2/history/reserve?interval=day&count=2` + const url3 = `https://midgard.ninerealms.com/v2/pools?period=24h` + const [earnings, revenue, pools]: any = (await Promise.all([ // TODO: Cache all this requests. Equal for all chains + httpGet(url, { headers: {"x-client-id": "defillama"}}), + httpGet(url2, { headers: {"x-client-id": "defillama"}}), + httpGet(url3, { headers: {"x-client-id": "defillama"}}), + ])) + + const selectedEarningInterval = findInterval(timestamp, earnings.intervals); + const selectedRevenueInterval = findInterval(timestamp, revenue.intervals); + + const poolsByChainEarnings: Pool[] = selectedEarningInterval?.pools?.filter(pool => assetFromString(pool.pool)?.chain === chain) + + const totalRuneDepth = pools.reduce((acum, pool) => acum.plus(pool.runeDepth), BigNumber(0)) + const poolsByChainData = pools?.filter(pool => assetFromString(pool.asset)?.chain === chain) + const runeDepthPerChain = poolsByChainData.reduce((acum, pool) => acum.plus(pool.runeDepth), BigNumber(0)) + + const protocolRevenue = BigNumber(selectedRevenueInterval.gasFeeOutbound).minus(selectedRevenueInterval.gasReimbursement) + + const runePercentagePerChain = runeDepthPerChain.div(totalRuneDepth) + const bondingRewardPerChainBasedOnRuneDepth = BigNumber(selectedEarningInterval.bondingEarnings).times(runePercentagePerChain) // TODO: Artificial distribution according to the liquidity of the pools. But it is a protocol level data + const protocolRevenuePerChainBasedOnRuneDepth = protocolRevenue.times(runePercentagePerChain) + + const dailyFees = poolsByChainEarnings.reduce((acum, pool) => { + const liquidityFeesPerPoolInDollars = BigNumber(pool.totalLiquidityFeesRune).div(1e8).times(selectedEarningInterval.runePriceUSD) + const saverLiquidityFeesPerPoolInDollars = BigNumber(pool.saverEarning).div(1e8).times(selectedEarningInterval.runePriceUSD) + const totalLiquidityFees = liquidityFeesPerPoolInDollars.plus(saverLiquidityFeesPerPoolInDollars) + return acum.plus(totalLiquidityFees) + }, BigNumber(0)) + + const dailySupplysideRevenue = poolsByChainEarnings.reduce((acum, pool) => { + const liquidityFeesPerPoolInDollars = BigNumber(pool.totalLiquidityFeesRune).div(1e8).times(selectedEarningInterval.runePriceUSD) + const saverLiquidityFeesPerPoolInDollars = BigNumber(pool.saverEarning).div(1e8).times(selectedEarningInterval.runePriceUSD) + const rewardsInDollars = BigNumber(pool.rewards).div(1e8).times(selectedEarningInterval.runePriceUSD) + const totalLiquidityFees = liquidityFeesPerPoolInDollars.plus(saverLiquidityFeesPerPoolInDollars).plus(rewardsInDollars) + return acum.plus(totalLiquidityFees) + }, BigNumber(0)) + + const protocolRevenueByChainInDollars = protocolRevenuePerChainBasedOnRuneDepth.div(1e8).times(Number(selectedEarningInterval.runePriceUSD)); + const dailyHoldersRevenue = BigNumber(bondingRewardPerChainBasedOnRuneDepth).div(1e8).times(selectedEarningInterval.runePriceUSD); + return { + dailyFees: dailyFees ? `${dailyFees}` : undefined, // Liquidity fees not include chain fees + dailyUserFees: dailyFees ? `${dailyFees}` : undefined, // Liquidity fees not include chain fees + dailyRevenue: `${dailyHoldersRevenue.plus(protocolRevenueByChainInDollars)}`, // dailyProtocolRevenue + dailyHoldersRevenue + dailyProtocolRevenue: protocolRevenueByChainInDollars ? `${protocolRevenueByChainInDollars}` : undefined, // Output fees - reimbursments + dailyHoldersRevenue: dailyHoldersRevenue ? `${dailyHoldersRevenue}` : undefined, // Rewards for nodes pondered by chain liquidity + dailySupplySideRevenue: dailySupplysideRevenue ? `${dailySupplysideRevenue}` : undefined, // Earnings: rewards + liquidity fees per pool + timestamp + } + } + } + }); + + return adapter } const adapters: SimpleAdapter = { version: 1, - adapter: { - [CHAIN.THORCHAIN]: { - runAtCurrTime: true, - fetch: fetchFees, - start: '2021-04-11', - } - }, + adapter: fetchFeesByChain(), isExpensiveAdapter: true } From 8f1784cc70ecd63e07afd5a8d7d7d6463ccae432 Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Sat, 14 Dec 2024 19:46:43 +0100 Subject: [PATCH 24/86] Update URLs names --- fees/thorswap/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fees/thorswap/index.ts b/fees/thorswap/index.ts index 2e2c010a23..479808013b 100644 --- a/fees/thorswap/index.ts +++ b/fees/thorswap/index.ts @@ -63,13 +63,13 @@ const fetchFeesByChain = () => { runAtCurrTime: true, fetch: async (timestamp: number) => { - const url = `https://midgard.ninerealms.com/v2/history/earnings?interval=day&count=2` - const url2 = `https://midgard.ninerealms.com/v2/history/reserve?interval=day&count=2` - const url3 = `https://midgard.ninerealms.com/v2/pools?period=24h` + const earningsUrl = `https://midgard.ninerealms.com/v2/history/earnings?interval=day&count=2` + const reserveUrl = `https://midgard.ninerealms.com/v2/history/reserve?interval=day&count=2` + const poolsUrl = `https://midgard.ninerealms.com/v2/pools?period=24h` const [earnings, revenue, pools]: any = (await Promise.all([ // TODO: Cache all this requests. Equal for all chains - httpGet(url, { headers: {"x-client-id": "defillama"}}), - httpGet(url2, { headers: {"x-client-id": "defillama"}}), - httpGet(url3, { headers: {"x-client-id": "defillama"}}), + httpGet(earningsUrl, { headers: {"x-client-id": "defillama"}}), + httpGet(reserveUrl, { headers: {"x-client-id": "defillama"}}), + httpGet(poolsUrl, { headers: {"x-client-id": "defillama"}}), ])) const selectedEarningInterval = findInterval(timestamp, earnings.intervals); From b21b8eb9b5d593011c0530f456d61bcc2752a7da Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Sun, 15 Dec 2024 02:16:57 +0000 Subject: [PATCH 25/86] fix bitgetwallet --- bridge-aggregators/bitgetwallet/index.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/bridge-aggregators/bitgetwallet/index.ts b/bridge-aggregators/bitgetwallet/index.ts index f01ed6e3ac..aa2e4495d0 100644 --- a/bridge-aggregators/bitgetwallet/index.ts +++ b/bridge-aggregators/bitgetwallet/index.ts @@ -1,7 +1,7 @@ import { CHAIN } from "../../helpers/chains"; import { FetchOptions } from "../../adapters/types"; -import axios from "axios"; import {getUniqStartOfTodayTimestamp} from "../../helpers/getUniSubgraphVolume"; +import { httpGet } from "../../utils/fetchURL"; const CHAINS: Array = [ @@ -35,16 +35,17 @@ interface IVolumeBridge { async function queryDataByApi(timestamp:string, path:string){ const historicalVolumeEndpoint = "https://new-swapopen.bitapi.vip/st"; - let info = await axios.get(`${historicalVolumeEndpoint}${path}`); - const data : IVolumeBridge[] = (info?.data)?.data.list; + let info = await httpGet(`${historicalVolumeEndpoint}${path}`); + const data : IVolumeBridge[] = (info)?.data.list; return data } -const fetch = async (timestamp: number, block: any, options: FetchOptions) => { - const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const path = `/getOrderDayList?bridge=1&chain=${options.chain}×tamp=${timestamp}` - const data = await queryDataByApi(timestamp.toString(), path) - let dailyVolume = data.find(dayItem => (new Date(dayItem.date).getTime() / 1000) === dayTimestamp)?.volume +const fetch = async (_t: number, _b: any, options: FetchOptions) => { + const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(options.startOfDay * 1000)) + const path = `/getOrderDayList?bridge=1&chain=${options.chain}×tamp=${dayTimestamp}` + const data = await queryDataByApi(dayTimestamp.toString(), path) + const dateString = new Date(dayTimestamp * 1000).toISOString().split("T")[0]; + let dailyVolume = data.find(dayItem => dayItem.date === dateString)?.volume dailyVolume = dailyVolume || "0"; return { dailyBridgeVolume: dailyVolume, @@ -57,12 +58,12 @@ const adapter: any = { adapter: { ...CHAINS.map(chain => { return { - + [chain]: { fetch: fetch, start: '2024-01-01' } - + } }).reduce((acc, item) => { return { From 84664da5a24333a42fe1925e8972d37e7e8c258f Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Sun, 15 Dec 2024 08:50:14 +0100 Subject: [PATCH 26/86] update dailyFees and daily Revenue --- dexs/mars-perp/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dexs/mars-perp/index.ts b/dexs/mars-perp/index.ts index 4e0bd6dc18..d900aff6f5 100644 --- a/dexs/mars-perp/index.ts +++ b/dexs/mars-perp/index.ts @@ -11,6 +11,7 @@ const fetch = async (timestamp: number): Promise => { let last24HourVolume = 0; let fetchTimestamp = timestamp; let last24HourFees = 0; + let last24HourRevenue; // The second element in the array is the last 24 hour volume, while the first element is the current volume of the ongoing day if (globalOverview && globalOverview.daily_trading_volume.length > 1) { @@ -32,7 +33,7 @@ const fetch = async (timestamp: number): Promise => { .toNumber(); last24HourFees = last24HourTradingFee + last24HourFundingFee; - + last24HourRevenue = last24HourFees * 0.25; fetchTimestamp = Math.round( new Date(globalOverview.daily_trading_volume[1].date).getTime() / 1000 ); @@ -40,7 +41,8 @@ const fetch = async (timestamp: number): Promise => { return { dailyVolume: last24HourVolume, - dailyRevenue: last24HourFees, + dailyRevenue: last24HourRevenue, + dailyFees: last24HourFees, timestamp: fetchTimestamp, }; }; @@ -57,8 +59,10 @@ const adapter = { methodology: { dailyVolume: "Volume is calculated by summing the token volume of all perpetual trades settled on the protocol that day.", + dailyFees: + "Fees are the sum of the trading and funding fees of all perpetual trades settled on the protocol that day.", dailyRevenue: - "Revenue is calculated by summing the trading and funding fees of all perpetual trades settled on the protocol that day.", + "The daily revenue going to the protocol is 25% of the daily fees.", }, }, }, From b6ee6563e3fa91ce121ecc526be047ac4c8b6df3 Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Sun, 15 Dec 2024 14:56:39 +0100 Subject: [PATCH 27/86] added daily open interst and renamed to protocol revenue --- dexs/mars-perp/index.ts | 51 ++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/dexs/mars-perp/index.ts b/dexs/mars-perp/index.ts index d900aff6f5..58ad9c0b36 100644 --- a/dexs/mars-perp/index.ts +++ b/dexs/mars-perp/index.ts @@ -11,29 +11,34 @@ const fetch = async (timestamp: number): Promise => { let last24HourVolume = 0; let fetchTimestamp = timestamp; let last24HourFees = 0; - let last24HourRevenue; + let last24HourRevenue = 0; + let last24HoursShortOpenInterest = 0; + let last24HoursLongOpenInterest = 0; + let last24HoursTotalOpenInterest = 0; // The second element in the array is the last 24 hour volume, while the first element is the current volume of the ongoing day if (globalOverview && globalOverview.daily_trading_volume.length > 1) { // Volume is returned in uusd which has 6 decimals - last24HourVolume = new BigNumber( + last24HourVolume = convertToUsd( globalOverview.daily_trading_volume[1].value - ) - .shiftedBy(-6) - .toNumber(); - const last24HourTradingFee = new BigNumber( + ); + const last24HourTradingFee = convertToUsd( globalOverview.fees.trading_fee[1].value - ) - .shiftedBy(-6) - .toNumber(); - const last24HourFundingFee = new BigNumber( + ); + const last24HourFundingFee = convertToUsd( globalOverview.fees.net_funding_fee[1].value - ) - .shiftedBy(-6) - .toNumber(); - + ); last24HourFees = last24HourTradingFee + last24HourFundingFee; last24HourRevenue = last24HourFees * 0.25; + last24HoursShortOpenInterest = convertToUsd( + globalOverview.open_interest.short[1].value + ); + last24HoursLongOpenInterest = convertToUsd( + globalOverview.open_interest.long[1].value + ); + last24HoursTotalOpenInterest = convertToUsd( + globalOverview.open_interest.total[1].value + ); fetchTimestamp = Math.round( new Date(globalOverview.daily_trading_volume[1].date).getTime() / 1000 ); @@ -41,8 +46,11 @@ const fetch = async (timestamp: number): Promise => { return { dailyVolume: last24HourVolume, - dailyRevenue: last24HourRevenue, + dailyProtocolRevenue: last24HourRevenue, dailyFees: last24HourFees, + dailyShortOpenInterest: last24HoursShortOpenInterest, + dailyLongOpenInterest: last24HoursLongOpenInterest, + dailyOpenInterest: last24HoursTotalOpenInterest, timestamp: fetchTimestamp, }; }; @@ -61,8 +69,14 @@ const adapter = { "Volume is calculated by summing the token volume of all perpetual trades settled on the protocol that day.", dailyFees: "Fees are the sum of the trading and funding fees of all perpetual trades settled on the protocol that day.", - dailyRevenue: + dailyProtocolRevenue: "The daily revenue going to the protocol is 25% of the daily fees.", + dailyShortOpenInterest: + "The total value of all short positions on the protocol.", + dailyLongOpenInterest: + "The total value of all long positions on the protocol.", + dailyOpenInterest: + "The total value of all positions on the protocol.", }, }, }, @@ -70,3 +84,8 @@ const adapter = { }, }; export default adapter; + +function convertToUsd(value: string | number): number { + // all values are in uusd + return new BigNumber(value).shiftedBy(-6).toNumber(); +} From 2f4942090724f485a240215fcb33e048633d4b97 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 15 Dec 2024 13:18:27 -0300 Subject: [PATCH 28/86] feat: add teleswap to bridge aggregators --- bridge-aggregators/teleswap/index.ts | 63 ++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 bridge-aggregators/teleswap/index.ts diff --git a/bridge-aggregators/teleswap/index.ts b/bridge-aggregators/teleswap/index.ts new file mode 100644 index 0000000000..6f50e3194d --- /dev/null +++ b/bridge-aggregators/teleswap/index.ts @@ -0,0 +1,63 @@ +import { FetchOptions, SimpleAdapter } from '../../adapters/types'; +import { httpGet } from '../../utils/fetchURL'; +import { CHAIN } from '../../helpers/chains'; +import { getUniqStartOfTodayTimestamp } from '../../helpers/getUniSubgraphVolume'; + +const chains: Record = { + [CHAIN.BITCOIN]: 'bitcoin', + [CHAIN.ETHEREUM]: 'ethereum', + [CHAIN.SUI]: 'sui', + [CHAIN.TRON]: 'tron', + [CHAIN.BASE]: 'base', + // [CHAIN.BSC]: 'bsc', + [CHAIN.TARA]: 'tara', + [CHAIN.AVAX]: 'avax', + [CHAIN.LITECOIN]: 'litecoin', + [CHAIN.ARBITRUM]: 'arbitrum', + [CHAIN.NEAR]: 'near', + [CHAIN.POLYGON]: 'polygon', + [CHAIN.TON]: 'ton', + [CHAIN.SOLANA]: 'solana', +}; + +const fetchVolume = async (_t: any, _b: any, options: FetchOptions) => { + const unixTimestamp = getUniqStartOfTodayTimestamp( + new Date(options.startOfDay * 1000) + ); + + const response = await httpGet('https://api.teleswap.io/stats/volume', { + headers: { + 'Content-Type': 'application/json', + }, + }); + + const chainVolume = response?.find( + (item: any) => + item.chain.toLowerCase() === chains[options.chain].toLowerCase() + ); + + return { + dailyBridgeVolume: chainVolume?.dailyVolume || 0, + totalVolume: chainVolume?.totalVolume || 0, + timestamp: unixTimestamp, + }; +}; + +const adapter: SimpleAdapter = { + adapter: { + ...Object.entries(chains).reduce((acc, chain) => { + const [key, value] = chain; + + return { + ...acc, + [key]: { + fetch: fetchVolume, + start: '2024-09-18', + }, + }; + }, {}), + }, + version: 1, +}; + +export default adapter; From 6a8a7383ebe48451b441becd376785a82f468a2a Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 15 Dec 2024 13:19:29 -0300 Subject: [PATCH 29/86] fix: change field from totalVolume to totalBridgeVolume --- bridge-aggregators/teleswap/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge-aggregators/teleswap/index.ts b/bridge-aggregators/teleswap/index.ts index 6f50e3194d..e9aaca5e9e 100644 --- a/bridge-aggregators/teleswap/index.ts +++ b/bridge-aggregators/teleswap/index.ts @@ -38,7 +38,7 @@ const fetchVolume = async (_t: any, _b: any, options: FetchOptions) => { return { dailyBridgeVolume: chainVolume?.dailyVolume || 0, - totalVolume: chainVolume?.totalVolume || 0, + totalBridgeVolume: chainVolume?.totalVolume || 0, timestamp: unixTimestamp, }; }; From 6d1f55f03be1a6d5bb8f1dfdba428b0565be1f8b Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 15 Dec 2024 13:21:55 -0300 Subject: [PATCH 30/86] fix: Add bsc to chain list --- bridge-aggregators/teleswap/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge-aggregators/teleswap/index.ts b/bridge-aggregators/teleswap/index.ts index e9aaca5e9e..b254e5084c 100644 --- a/bridge-aggregators/teleswap/index.ts +++ b/bridge-aggregators/teleswap/index.ts @@ -9,7 +9,7 @@ const chains: Record = { [CHAIN.SUI]: 'sui', [CHAIN.TRON]: 'tron', [CHAIN.BASE]: 'base', - // [CHAIN.BSC]: 'bsc', + [CHAIN.BSC]: 'bsc', [CHAIN.TARA]: 'tara', [CHAIN.AVAX]: 'avax', [CHAIN.LITECOIN]: 'litecoin', From 5f901230bd4606a3394c0132de956d3040bb8c56 Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Mon, 16 Dec 2024 00:03:48 +0100 Subject: [PATCH 31/86] enable backwards compatibility --- dexs/mars-perp/index.ts | 70 +++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/dexs/mars-perp/index.ts b/dexs/mars-perp/index.ts index 58ad9c0b36..ee7a584d65 100644 --- a/dexs/mars-perp/index.ts +++ b/dexs/mars-perp/index.ts @@ -1,47 +1,57 @@ import axios from "axios"; import BigNumber from "bignumber.js"; -import { FetchResult } from "../../adapters/types"; +import { FetchOptions, FetchResult } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; -const fetch = async (timestamp: number): Promise => { - const perpsInfoApi = `https://backend.prod.mars-dev.net/v2/perps_overview?chain=neutron&days=2&response_type=global`; +const fetch = async (options: FetchOptions): Promise => { + const { fromApi } = options; + const perpsInfoApi = `https://backend.prod.mars-dev.net/v2/perps_overview?chain=neutron&days=30&response_type=global`; const perpsVolumeData = await axios(perpsInfoApi); const globalOverview = perpsVolumeData.data.global_overview; + const fromTimestamp = fromApi.timestamp ?? Math.floor(Date.now() / 1000); let last24HourVolume = 0; - let fetchTimestamp = timestamp; + let fetchTimestamp = fromTimestamp; let last24HourFees = 0; let last24HourRevenue = 0; let last24HoursShortOpenInterest = 0; let last24HoursLongOpenInterest = 0; let last24HoursTotalOpenInterest = 0; - // The second element in the array is the last 24 hour volume, while the first element is the current volume of the ongoing day - if (globalOverview && globalOverview.daily_trading_volume.length > 1) { - // Volume is returned in uusd which has 6 decimals - last24HourVolume = convertToUsd( - globalOverview.daily_trading_volume[1].value - ); - const last24HourTradingFee = convertToUsd( - globalOverview.fees.trading_fee[1].value - ); - const last24HourFundingFee = convertToUsd( - globalOverview.fees.net_funding_fee[1].value - ); - last24HourFees = last24HourTradingFee + last24HourFundingFee; - last24HourRevenue = last24HourFees * 0.25; - last24HoursShortOpenInterest = convertToUsd( - globalOverview.open_interest.short[1].value - ); - last24HoursLongOpenInterest = convertToUsd( - globalOverview.open_interest.long[1].value - ); - last24HoursTotalOpenInterest = convertToUsd( - globalOverview.open_interest.total[1].value - ); - fetchTimestamp = Math.round( - new Date(globalOverview.daily_trading_volume[1].date).getTime() / 1000 - ); + // Check for the last timestamp that is less than or equal to the fetched timestamp + if (globalOverview) { + let foundLatestData = false; + + globalOverview.daily_trading_volume.forEach((volumeData, index) => { + const dataTimestamp = Math.round( + new Date(volumeData.date).getTime() / 1000 + ); + if (dataTimestamp <= fromTimestamp && !foundLatestData) { + last24HourVolume = convertToUsd(volumeData.value); + fetchTimestamp = dataTimestamp; + + const last24HourTradingFee = convertToUsd( + globalOverview.fees.trading_fee[index].value + ); + const last24HourFundingFee = convertToUsd( + globalOverview.fees.net_funding_fee[index].value + ); + last24HourFees = last24HourTradingFee + last24HourFundingFee; + last24HourRevenue = last24HourFees * 0.25; + last24HoursShortOpenInterest = convertToUsd( + globalOverview.open_interest.short[index].value + ); + last24HoursLongOpenInterest = convertToUsd( + globalOverview.open_interest.long[index].value + ); + last24HoursTotalOpenInterest = convertToUsd( + globalOverview.open_interest.total[index].value + ); + + console.log(volumeData.date); + foundLatestData = true; + } + }); } return { From 066472c71ad74be0be98bed8adde3adde27994cb Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Mon, 16 Dec 2024 00:06:10 +0100 Subject: [PATCH 32/86] remove logs --- dexs/mars-perp/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/dexs/mars-perp/index.ts b/dexs/mars-perp/index.ts index ee7a584d65..17f86eb3d9 100644 --- a/dexs/mars-perp/index.ts +++ b/dexs/mars-perp/index.ts @@ -47,8 +47,6 @@ const fetch = async (options: FetchOptions): Promise => { last24HoursTotalOpenInterest = convertToUsd( globalOverview.open_interest.total[index].value ); - - console.log(volumeData.date); foundLatestData = true; } }); From 51d20f0c46b473db4b12c191bd9968b8a91cdb1f Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Mon, 16 Dec 2024 00:11:57 +0100 Subject: [PATCH 33/86] use fromTimestamp --- dexs/mars-perp/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dexs/mars-perp/index.ts b/dexs/mars-perp/index.ts index 17f86eb3d9..28c9678ec3 100644 --- a/dexs/mars-perp/index.ts +++ b/dexs/mars-perp/index.ts @@ -4,11 +4,10 @@ import { FetchOptions, FetchResult } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; const fetch = async (options: FetchOptions): Promise => { - const { fromApi } = options; + const { fromTimestamp } = options; const perpsInfoApi = `https://backend.prod.mars-dev.net/v2/perps_overview?chain=neutron&days=30&response_type=global`; const perpsVolumeData = await axios(perpsInfoApi); const globalOverview = perpsVolumeData.data.global_overview; - const fromTimestamp = fromApi.timestamp ?? Math.floor(Date.now() / 1000); let last24HourVolume = 0; let fetchTimestamp = fromTimestamp; From 84190f6dfe7b21b25fa2183e07cdfeebbe9add13 Mon Sep 17 00:00:00 2001 From: bitkeep-tech <138654908+bitkeep-tech@users.noreply.github.com> Date: Mon, 16 Dec 2024 09:16:08 +0800 Subject: [PATCH 34/86] fix bitgetwallet bridge vol issue --- bridge-aggregators/bitgetwallet/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge-aggregators/bitgetwallet/index.ts b/bridge-aggregators/bitgetwallet/index.ts index aa2e4495d0..9ac1cce636 100644 --- a/bridge-aggregators/bitgetwallet/index.ts +++ b/bridge-aggregators/bitgetwallet/index.ts @@ -46,7 +46,7 @@ const fetch = async (_t: number, _b: any, options: FetchOptions) => { const data = await queryDataByApi(dayTimestamp.toString(), path) const dateString = new Date(dayTimestamp * 1000).toISOString().split("T")[0]; let dailyVolume = data.find(dayItem => dayItem.date === dateString)?.volume - dailyVolume = dailyVolume || "0"; + dailyVolume = dailyVolume || undefined; return { dailyBridgeVolume: dailyVolume, timestamp: options.endTimestamp, From 449f73cc163cdd27f6940470ad7237ac78fccb70 Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Mon, 16 Dec 2024 01:52:04 +0000 Subject: [PATCH 35/86] fix api sushiswap --- dexs/sushiswap/swap.ts | 40 ++++++++++++++++++---------------------- dexs/sushiswap/v3.ts | 2 +- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/dexs/sushiswap/swap.ts b/dexs/sushiswap/swap.ts index d52d13a272..9564f6bc4b 100644 --- a/dexs/sushiswap/swap.ts +++ b/dexs/sushiswap/swap.ts @@ -1,6 +1,7 @@ import axios from "axios"; import { FetchResultV2, FetchV2 } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; +import { httpGet } from "../../utils/fetchURL"; const ROUTE_EVENT = 'event Route(address indexed from, address to, address indexed tokenIn, address indexed tokenOut, uint256 amountIn, uint256 amountOutMin,uint256 amountOut)' @@ -182,37 +183,32 @@ const fetch: FetchV2 = async ({ getLogs, createBalances, chain, }): Promise [...rp4Logs, ...rp5Logs]) if (useSushiAPIPrice(chain)) { - const [tokensQuery, pricesQuery] = await Promise.all([ - axios.get(`https://tokens.sushi.com/v0/${CHAIN_ID[chain]}`) - .then(response => response.data), - axios.get(`https://api.sushi.com/price/v1/${CHAIN_ID[chain]}`) - .then(response => Object.entries(response.data).reduce( - (acc, [key, value]) => { - acc[key.toLowerCase()] = value - return acc - }, - {}, - )), - ]) + const dailyVolume = createBalances() + const tokenPrice = Object.entries(await httpGet(`https://api.sushi.com/price/v1/${CHAIN_ID[chain]}`)).reduce((acc, [key, value]) => { + acc[key.toLowerCase()] = value + return acc + }); + const tokensIn = [...new Set(logs.map(log => log.tokenIn.toLowerCase()))] + const tokensInfo = (await Promise.all(tokensIn.map(token => httpGet(`https://api.sushi.com/token/v1/${CHAIN_ID[chain]}/${token}`)))).flat(); - const tokens = tokensQuery.reduce((tokens, token) => { + const tokens = tokensInfo.reduce((tokens, token) => { const address = token.address.toLowerCase() tokens[address] = { ...token, - price: pricesQuery[address] ?? 0 + price: tokenPrice[address] ?? 0 } return tokens - }, {}) - - let dailyVolume = 0 + }, {}); logs.forEach((log) => { - const token = tokens[ - log.tokenIn === '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' ? WNATIVE_ADDRESS[chain] : log.tokenIn.toLowerCase() - ] - - if (token) dailyVolume += Number(log.amountIn) * token.price / 10 ** token.decimals + const token = tokens[log.tokenIn.toLowerCase()] + if (token && log.tokenIn !== '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE') { + const _dailyVolume = Number(log.amountIn) * token.price / 10 ** token.decimals + dailyVolume.addUSDValue(_dailyVolume) + } else { + dailyVolume.add(WNATIVE_ADDRESS[chain], log.amountIn) + } }) return { dailyVolume } diff --git a/dexs/sushiswap/v3.ts b/dexs/sushiswap/v3.ts index 9a6e56b253..b9376735f5 100644 --- a/dexs/sushiswap/v3.ts +++ b/dexs/sushiswap/v3.ts @@ -18,7 +18,7 @@ const endpointsV3 = { [CHAIN.OPTIMISM]: sdk.graph.modifyEndpoint('Hc3vTLxWmtyrn59t2Yv3MiXJVxjfNyZi41iKE3rXXHMf'), [CHAIN.POLYGON]: sdk.graph.modifyEndpoint('G1Q6dviDfMm6hVLvCqbfeB19kLmvs7qrnBvXeFndjhaU'), // [CHAIN.POLYGON_ZKEVM]: sdk.graph.modifyEndpoint('E2x2gmtYdm2HX3QXorUBY4KegfGu79Za6TEQYjVrx15c'), - [CHAIN.THUNDERCORE]: 'https://graph-node.thundercore.com/subgraphs/name/sushi-v3/v3-thundercore', + // [CHAIN.THUNDERCORE]: 'https://graph-node.thundercore.com/subgraphs/name/sushi-v3/v3-thundercore', [CHAIN.BASE]: sdk.graph.modifyEndpoint('Cz4Snpih41NNNPZcbj1gd3fYXPwFr5q92iWMoZjCarEb'), [CHAIN.CORE]: "https://thegraph.coredao.org/subgraphs/name/sushi-v3/v3-core", [CHAIN.BLAST]: "https://api.goldsky.com/api/public/project_clslspm3c0knv01wvgfb2fqyq/subgraphs/sushiswap/v3-blast/gn", From d870fe6fba03db08b0ccb5818d7697d8c8ee29ac Mon Sep 17 00:00:00 2001 From: Arpit Singh Date: Mon, 16 Dec 2024 18:08:46 +0530 Subject: [PATCH 36/86] Update index.ts Fixed notional volume --- options/logx/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/options/logx/index.ts b/options/logx/index.ts index 92bf377aa1..65201f34c1 100644 --- a/options/logx/index.ts +++ b/options/logx/index.ts @@ -19,8 +19,8 @@ const fetch = async (timestamp: number): Promise => { totalPremiumVolume: totalVolume, dailyPremiumVolume: last24HourVolume, timestamp: timestamp, - dailyNotionalVolume: 0, - totalNotionalVolume: 0, + dailyNotionalVolume: last24HourVolume, + totalNotionalVolume: totalVolume, }; }; @@ -33,4 +33,4 @@ const adapter: SimpleAdapter = { } }; -export default adapter; \ No newline at end of file +export default adapter; From f8f08858dca1ac7717850dfdafaa5b602a946d6a Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Mon, 16 Dec 2024 12:55:45 +0000 Subject: [PATCH 37/86] fix ci --- .github/workflows/getFileList.js | 2 +- bridge-aggregators/teleswap/index.ts | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/getFileList.js b/.github/workflows/getFileList.js index 62355afe4c..2c1f81e2fd 100644 --- a/.github/workflows/getFileList.js +++ b/.github/workflows/getFileList.js @@ -1,4 +1,4 @@ -const ALLOWED_ROOTS = ['volumes', 'dexs', 'options', 'derivatives', 'incentives', 'fees', 'options', 'protocols', 'aggregators','aggregator-derivatives'] +const ALLOWED_ROOTS = ['volumes', 'dexs', 'options', 'derivatives', 'incentives', 'fees', 'options', 'protocols', 'aggregators','aggregator-derivatives','bridge-aggregators'] const MODIFIED = parse(process.env.MODIFIED) const ADDED = parse(process.env.ADDED) const fileSet = new Set(); diff --git a/bridge-aggregators/teleswap/index.ts b/bridge-aggregators/teleswap/index.ts index b254e5084c..a917d33197 100644 --- a/bridge-aggregators/teleswap/index.ts +++ b/bridge-aggregators/teleswap/index.ts @@ -20,18 +20,20 @@ const chains: Record = { [CHAIN.SOLANA]: 'solana', }; +let data: any; const fetchVolume = async (_t: any, _b: any, options: FetchOptions) => { const unixTimestamp = getUniqStartOfTodayTimestamp( new Date(options.startOfDay * 1000) ); + if (!data) { + data = await httpGet('https://api.teleswap.io/stats/volume', { + headers: { + 'Content-Type': 'application/json', + }, + }); + } - const response = await httpGet('https://api.teleswap.io/stats/volume', { - headers: { - 'Content-Type': 'application/json', - }, - }); - - const chainVolume = response?.find( + const chainVolume = data?.find( (item: any) => item.chain.toLowerCase() === chains[options.chain].toLowerCase() ); From 57f2198e52c56d2ef79ee192c5a51878e7f56cb4 Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Mon, 16 Dec 2024 13:12:42 +0000 Subject: [PATCH 38/86] fix allow range --- helpers/flipsidecrypto.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpers/flipsidecrypto.ts b/helpers/flipsidecrypto.ts index a3eaf33994..bbb2e467c1 100644 --- a/helpers/flipsidecrypto.ts +++ b/helpers/flipsidecrypto.ts @@ -184,6 +184,6 @@ async function _queryFlipside(sqlQuery: string, maxAgeMinutes: number = 90) { export function checkCanFlipSideQuery() { if (!isRestrictedMode) return; const currentHour = new Date().getUTCHours(); - if (currentHour >= 1 && currentHour <= 3) return; // 1am - 3am - any time other than this, throw error - throw new Error(`Current hour is ${currentHour}. In restricted mode, can run flipsside queries only between 1am - 3am UTC`); + if (currentHour >= 4 && currentHour <= 7) return; // 1am - 3am - any time other than this, throw error + throw new Error(`Current hour is ${currentHour}. In restricted mode, can run flipsside queries only between 4am - 7am UTC`); } From 3976838cd8caf5c1d44fef1f229d682dad13808c Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Mon, 16 Dec 2024 13:16:55 +0000 Subject: [PATCH 39/86] fix add status --- dexs/mars-perp/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/dexs/mars-perp/index.ts b/dexs/mars-perp/index.ts index 28c9678ec3..d2e6fbca5d 100644 --- a/dexs/mars-perp/index.ts +++ b/dexs/mars-perp/index.ts @@ -54,6 +54,7 @@ const fetch = async (options: FetchOptions): Promise => { return { dailyVolume: last24HourVolume, dailyProtocolRevenue: last24HourRevenue, + dailyRevenue: last24HourRevenue, dailyFees: last24HourFees, dailyShortOpenInterest: last24HoursShortOpenInterest, dailyLongOpenInterest: last24HoursLongOpenInterest, From 5283d9e19de8cd182673736bc44367c6884a313a Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 16 Dec 2024 17:37:31 +0200 Subject: [PATCH 40/86] Added Sonic integration to Wolfswap aggregator --- aggregators/wolfswap/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aggregators/wolfswap/index.ts b/aggregators/wolfswap/index.ts index 142528b685..54ef945c2f 100644 --- a/aggregators/wolfswap/index.ts +++ b/aggregators/wolfswap/index.ts @@ -12,6 +12,7 @@ const contracts = { avax: '0x643dEB007DfA43c0D7BeA2155E97E61279d9a56F', sei: '0x1AD805e80b59C802f9D8059f904DCA6AC153de30', blast: '0xb86a6e5702C327c5C051Bf5323Cb2bAb5E628d0c', + sonic: '0x222680A4fCcFE131acAf7a26301FC929364a881E' } const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, getLogs, chain, api }: FetchOptions) => { @@ -32,6 +33,7 @@ const adapter: any = { avax: { fetch, start: '2024-05-31', }, //sei: { fetch, start: '2024-05-31', }, blast: { fetch, start: '2024-03-07', }, + sonic: { fetch, start '2024-12-16', } }, }; From 7e524bb89bb8ca640632555aab110d4ba9aa8a19 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 16 Dec 2024 17:53:12 +0200 Subject: [PATCH 41/86] Updated to fix the typos --- aggregators/wolfswap/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aggregators/wolfswap/index.ts b/aggregators/wolfswap/index.ts index 54ef945c2f..1ae963bbc8 100644 --- a/aggregators/wolfswap/index.ts +++ b/aggregators/wolfswap/index.ts @@ -12,7 +12,7 @@ const contracts = { avax: '0x643dEB007DfA43c0D7BeA2155E97E61279d9a56F', sei: '0x1AD805e80b59C802f9D8059f904DCA6AC153de30', blast: '0xb86a6e5702C327c5C051Bf5323Cb2bAb5E628d0c', - sonic: '0x222680A4fCcFE131acAf7a26301FC929364a881E' + sonic: '0x222680A4fCcFE131acAf7a26301FC929364a881E', } const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, getLogs, chain, api }: FetchOptions) => { @@ -33,7 +33,7 @@ const adapter: any = { avax: { fetch, start: '2024-05-31', }, //sei: { fetch, start: '2024-05-31', }, blast: { fetch, start: '2024-03-07', }, - sonic: { fetch, start '2024-12-16', } + sonic: { fetch, start '2024-12-16', }, }, }; From 09fe413047b04218000034b254312b7d9bdb6777 Mon Sep 17 00:00:00 2001 From: abs3ntdev Date: Mon, 16 Dec 2024 07:54:38 -0800 Subject: [PATCH 42/86] add corn --- helpers/chains.ts | 1 + protocols/uniswap/index.ts | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/helpers/chains.ts b/helpers/chains.ts index 524988ec34..71a66a9396 100644 --- a/helpers/chains.ts +++ b/helpers/chains.ts @@ -196,6 +196,7 @@ export enum CHAIN { WC = "wc", ARCHWAY = "archway-1", NEUTRON = "neutron", + CORN = "corn", } // Don´t use diff --git a/protocols/uniswap/index.ts b/protocols/uniswap/index.ts index 969a6e8ee7..9d69551525 100644 --- a/protocols/uniswap/index.ts +++ b/protocols/uniswap/index.ts @@ -323,7 +323,26 @@ const mappingChain = (chain: string) => { return chain } -const okuChains = [ CHAIN.ETHEREUM, CHAIN.SEI, CHAIN.ERA, CHAIN.TAIKO, CHAIN.SCROLL, CHAIN.ROOTSTOCK, CHAIN.FILECOIN, CHAIN.BOBA, CHAIN.MOONBEAM, CHAIN.MANTA, CHAIN.MANTLE, CHAIN.LINEA, CHAIN.POLYGON_ZKEVM, CHAIN.BLAST, CHAIN.XDAI, CHAIN.BOB, CHAIN.LISK] +const okuChains = [ + CHAIN.ETHEREUM, + CHAIN.SEI, + CHAIN.ERA, + CHAIN.TAIKO, + CHAIN.SCROLL, + CHAIN.ROOTSTOCK, + CHAIN.FILECOIN, + CHAIN.BOBA, + CHAIN.MOONBEAM, + CHAIN.MANTA, + CHAIN.MANTLE, + CHAIN.LINEA, + CHAIN.POLYGON_ZKEVM, + CHAIN.BLAST, + CHAIN.XDAI, + CHAIN.BOB, + CHAIN.LISK, + CHAIN.CORN, +] okuChains.forEach(chain => { adapter.breakdown.v3[chain] = { From 134c00480a137a82e6d40b2a9db28baaca315aec Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Mon, 16 Dec 2024 16:05:59 +0000 Subject: [PATCH 43/86] fix error --- aggregators/wolfswap/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aggregators/wolfswap/index.ts b/aggregators/wolfswap/index.ts index 1ae963bbc8..8b6f9697c6 100644 --- a/aggregators/wolfswap/index.ts +++ b/aggregators/wolfswap/index.ts @@ -33,7 +33,7 @@ const adapter: any = { avax: { fetch, start: '2024-05-31', }, //sei: { fetch, start: '2024-05-31', }, blast: { fetch, start: '2024-03-07', }, - sonic: { fetch, start '2024-12-16', }, + sonic: { fetch, start: '2024-12-16', }, }, }; From bfe08cbc160e8ec03cc875a038770691375c2871 Mon Sep 17 00:00:00 2001 From: German Odilov Date: Mon, 16 Dec 2024 23:03:43 +0500 Subject: [PATCH 44/86] Mantis Volume (#2221) * Mantis daily/total volume dimensions adapter * minor fix --------- Co-authored-by: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> --- dexs/mantis/index.ts | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 dexs/mantis/index.ts diff --git a/dexs/mantis/index.ts b/dexs/mantis/index.ts new file mode 100644 index 0000000000..3c20211847 --- /dev/null +++ b/dexs/mantis/index.ts @@ -0,0 +1,60 @@ +import { Chain } from "@defillama/sdk/build/general"; +import { Adapter, ChainBlocks, FetchOptions, FetchResult, ProtocolType } from "../../adapters/types"; +import { CHAIN } from '../../helpers/chains'; +import fetchURL from "../../utils/fetchURL" + +const MANTIS_INDEXER_API = `https://mantis-indexer.composable-shared-artifacts.composablenodes.tech`; +const MANTIS_VOLUME_API = `${MANTIS_INDEXER_API}/api/domain/getvolume`; + + +function removeInvalidKeys(obj: any) { + Object.keys(obj).forEach(key => { + if (key.includes("…")) { + console.log("Removing key", key); + delete obj[key]; + } + }); +} + +const fetch = async (timestamp: number, _: ChainBlocks, options: FetchOptions): Promise => { + const chain = options.chain + const urlDaily = `${MANTIS_VOLUME_API}?timestamp=${options.toTimestamp}&chain=${chain == CHAIN.ETHEREUM ? 1 : 2}&period=1&solved_only=true`; + const urlTotal = `${MANTIS_VOLUME_API}?timestamp=${options.toTimestamp}&chain=${chain == CHAIN.ETHEREUM ? 1 : 2}&period=0&solved_only=true`; + + const volumeDaily = (await fetchURL(urlDaily)).assets; + const volumeTotal = (await fetchURL(urlTotal)).assets; + + removeInvalidKeys(volumeDaily); + removeInvalidKeys(volumeTotal); + + const dailyVolume = options.createBalances(); + const totalVolume = options.createBalances(); + dailyVolume.addBalances(volumeDaily); + totalVolume.addBalances(volumeTotal); + + + return { + dailyVolume, + totalVolume, + timestamp + }; +}; + +export default { + adapter: { + [CHAIN.SOLANA]: { + fetch, + start: 1732993200, + meta: { + methodology: "Sum of all executed intents with Solana as input or output", + }, + }, + [CHAIN.ETHEREUM]: { + fetch, + start: 1732993200, + meta: { + methodology: "Sum of all executed intents with Ethereum as input or output", + }, + } + }, +} as Adapter; From 742e9e5574316bc1ed360bcf4b582087f9e5f33c Mon Sep 17 00:00:00 2001 From: tomshear32 Date: Tue, 17 Dec 2024 00:27:05 +0300 Subject: [PATCH 45/86] Update easyswapper address --- fees/toros/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fees/toros/index.ts b/fees/toros/index.ts index d9ccc1d67b..f1e2a9aa23 100644 --- a/fees/toros/index.ts +++ b/fees/toros/index.ts @@ -51,7 +51,7 @@ const CONFIG = { [CHAIN.BASE]: { endpoint: "https://api.studio.thegraph.com/query/48129/dhedge-v2-base-mainnet/version/latest", torosManagerAddress: "0x5619ad05b0253a7e647bd2e4c01c7f40ceab0879", - easyswapperAddresses: ["0xe10ed1e5354eed0f7c9d2e16250ba8996c12db7a", "0xa907504d7a4c415b4e6e1d0866d96afe8202f0e5"], + easyswapperAddresses: ["0xe10ed1e5354eed0f7c9d2e16250ba8996c12db7a", "0xf067575eb60c7587c11e867907aa7284833704d1"], }, }; From 628cc1116ed27ef75d1ea06f8abf810b682ac04b Mon Sep 17 00:00:00 2001 From: Nick Goodman Date: Mon, 16 Dec 2024 22:47:46 -0500 Subject: [PATCH 46/86] Add sudo finance fees and protocol revenue tracking --- fees/sudofinance/index.ts | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 fees/sudofinance/index.ts diff --git a/fees/sudofinance/index.ts b/fees/sudofinance/index.ts new file mode 100644 index 0000000000..e77436c0ec --- /dev/null +++ b/fees/sudofinance/index.ts @@ -0,0 +1,54 @@ +import fetchURL from '../../utils/fetchURL'; +import { FetchResultFees, SimpleAdapter } from '../../adapters/types'; +import { CHAIN } from '../../helpers/chains'; +import { getUniqStartOfTodayTimestamp } from '../../helpers/getUniSubgraphFees'; + +const sudoApi = 'https://api.sudofinance.xyz'; +const TREASURY_FEE_PERCENTAGE = 0.25; + +const fetchSui = async (timestamp: number): Promise => { + const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); + const { + fee: dailyFee, + tradingFee: dailyTradingFee, + fundingFee: dailyFundingFee, + poolFee: dailyPoolFee, + } = await fetchURL(`${sudoApi}/fee?timestamp=${timestamp}`); + const { totalFee, totalTradingFee, totalFundingFee, totalPoolFee } = + await fetchURL(`${sudoApi}/totalFee`); + + const dailyProtocolRevenue = + (Number(dailyTradingFee) || 0) * TREASURY_FEE_PERCENTAGE; + const totalProtocolRevenue = + (Number(totalTradingFee) || 0) * TREASURY_FEE_PERCENTAGE; + const dailySupplySideRevenue = + Number(dailyTradingFee || 0) * (1 - TREASURY_FEE_PERCENTAGE) + + Number(dailyPoolFee || 0) + + Number(dailyFundingFee); + const totalSupplySideRevenue = + Number(totalTradingFee || 0) * (1 - TREASURY_FEE_PERCENTAGE) + + Number(totalPoolFee || 0) + + Number(totalFundingFee); + return { + dailyFees: dailyFee ? `${dailyFee}` : undefined, + totalFees: totalFee ? `${totalFee}` : undefined, + dailyUserFees: dailyFee ? `${dailyFee}` : undefined, + totalUserFees: totalFee ? `${totalFee}` : undefined, + dailySupplySideRevenue: `${dailySupplySideRevenue}`, + totalSupplySideRevenue: `${totalSupplySideRevenue}`, + dailyRevenue: dailyProtocolRevenue ? `${dailyProtocolRevenue}` : undefined, + totalRevenue: totalProtocolRevenue ? `${totalProtocolRevenue}` : undefined, + timestamp: dayTimestamp, + }; +}; + +const adapter: SimpleAdapter = { + adapter: { + [CHAIN.SUI]: { + fetch: fetchSui, + start: '2024-01-05', + }, + }, +}; + +export default adapter; From 35e166fbc4007fb6e5b5d892d516303cb56d1edf Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Tue, 17 Dec 2024 05:47:06 +0000 Subject: [PATCH 47/86] caching --- fees/thorswap/index.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/fees/thorswap/index.ts b/fees/thorswap/index.ts index 479808013b..6daf90eb81 100644 --- a/fees/thorswap/index.ts +++ b/fees/thorswap/index.ts @@ -55,6 +55,10 @@ const findInterval = (timestamp: number, intervals) => { return null; }; +let earnings: any; +let revenue: any; +let pools: any; + const fetchFeesByChain = () => { const adapter = {} const chains = ['BTC', 'ETH', 'LTC', 'DOGE', 'GAIA', 'AVAX', 'BSC', 'BCH'] @@ -66,12 +70,15 @@ const fetchFeesByChain = () => { const earningsUrl = `https://midgard.ninerealms.com/v2/history/earnings?interval=day&count=2` const reserveUrl = `https://midgard.ninerealms.com/v2/history/reserve?interval=day&count=2` const poolsUrl = `https://midgard.ninerealms.com/v2/pools?period=24h` - const [earnings, revenue, pools]: any = (await Promise.all([ // TODO: Cache all this requests. Equal for all chains - httpGet(earningsUrl, { headers: {"x-client-id": "defillama"}}), - httpGet(reserveUrl, { headers: {"x-client-id": "defillama"}}), - httpGet(poolsUrl, { headers: {"x-client-id": "defillama"}}), - ])) - + if (!earnings) { + earnings = await httpGet(earningsUrl, { headers: {"x-client-id": "defillama"}}); + } + if (!revenue) { + revenue = await httpGet(reserveUrl, { headers: {"x-client-id": "defillama"}}); + } + if (!pools) { + pools = await httpGet(poolsUrl, { headers: {"x-client-id": "defillama"}}); + } const selectedEarningInterval = findInterval(timestamp, earnings.intervals); const selectedRevenueInterval = findInterval(timestamp, revenue.intervals); From 18bf14ce419eb90e81678aa34d178c54a1d7fa14 Mon Sep 17 00:00:00 2001 From: ZkSwapFinance Date: Tue, 17 Dec 2024 17:54:33 +0700 Subject: [PATCH 48/86] update zkswap-finance fee --- fees/zkswap-finance.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fees/zkswap-finance.ts b/fees/zkswap-finance.ts index 7248662578..8500117e80 100644 --- a/fees/zkswap-finance.ts +++ b/fees/zkswap-finance.ts @@ -38,19 +38,19 @@ const fetch = (chain: string, totalFees: number, revenueFee: number) => { } const methodology = { - Fees: "A 0.08% trading fee is collected", - UserFees: "Users pays 0.08% of each swap", - Revenue: "A 0.04% fees goes to the protocol", - ProtocolRevenue: "A 0.04% fees goes to the protocol", - SupplySideRevenue: "A 0.04% is distributed proportionally to liquidity providers (ZFLP token holders)" + Fees: "A 0.1% trading fee is collected", + UserFees: "Users pays 0.1% of each swap", + Revenue: "A 0.05% fees goes to the protocol", + ProtocolRevenue: "A 0.05% fees goes to the protocol", + SupplySideRevenue: "A 0.05% is distributed proportionally to liquidity providers (ZFLP token holders)" } const baseAdapter: BaseAdapter = { [CHAIN.ERA]: { ...adapterObj[CHAIN.ERA], - fetch: fetch(CHAIN.ERA, 0.0008, 0.0004), - customBackfill: fetch(CHAIN.ERA, 0.0008, 0.0004), - start: '2023-10-01', + fetch: fetch(CHAIN.ERA, 0.001, 0.0005), + customBackfill: fetch(CHAIN.ERA, 0.001, 0.0005), + start: '2024-12-17', meta: { methodology } From 9de5d70b82460fb35789d79855c6181b3d4ed4e9 Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Tue, 17 Dec 2024 13:25:25 +0000 Subject: [PATCH 49/86] split volume type --- .../index.ts | 12 +++---- dexs/hyperliquid-spot/index.ts | 33 +++++++++++++++++++ 2 files changed, 39 insertions(+), 6 deletions(-) rename dexs/{hyperliquid => hyperliquid-perp}/index.ts (66%) create mode 100644 dexs/hyperliquid-spot/index.ts diff --git a/dexs/hyperliquid/index.ts b/dexs/hyperliquid-perp/index.ts similarity index 66% rename from dexs/hyperliquid/index.ts rename to dexs/hyperliquid-perp/index.ts index 1692eef4d4..e00da53bee 100644 --- a/dexs/hyperliquid/index.ts +++ b/dexs/hyperliquid-perp/index.ts @@ -1,21 +1,21 @@ import type { SimpleAdapter } from "../../adapters/types"; import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; -import { CHAIN } from "../../helpers/chains"; -import { httpGet, httpPost } from "../../utils/fetchURL"; +import { httpPost } from "../../utils/fetchURL"; const URL = "https://api.hyperliquid.xyz/info"; interface Response { - totalVolume?: number; - dailyVolume?: number; + dayNtlVlm: string; } const fetch = async (timestamp: number) => { - const {totalVolume, dailyVolume}: Response = (await httpPost(URL, {"type": "globalStats"})); + const respose: Response[] = (await httpPost(URL, {"type": "metaAndAssetCtxs"}))[1]; const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); + const dailyVolume = respose.reduce((acc, item) => { + return acc + Number(item.dayNtlVlm); + },0); return { - totalVolume: totalVolume?.toString(), dailyVolume: dailyVolume?.toString(), timestamp: dayTimestamp, }; diff --git a/dexs/hyperliquid-spot/index.ts b/dexs/hyperliquid-spot/index.ts new file mode 100644 index 0000000000..9e81d2952c --- /dev/null +++ b/dexs/hyperliquid-spot/index.ts @@ -0,0 +1,33 @@ +import type { SimpleAdapter } from "../../adapters/types"; +import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; +import { httpPost } from "../../utils/fetchURL"; + +const URL = "https://api.hyperliquid.xyz/info"; + +interface Response { + dayNtlVlm: string; +} + +const fetch = async (timestamp: number) => { + const respose: Response[] = (await httpPost(URL, {"type": "spotMetaAndAssetCtxs"}))[1]; + const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); + const dailyVolume = respose.reduce((acc, item) => { + return acc + Number(item.dayNtlVlm); + },0); + + return { + dailyVolume: dailyVolume?.toString(), + timestamp: dayTimestamp, + }; +}; + +const adapter: SimpleAdapter = { + adapter: { + "hyperliquid": { + fetch, + start: '2023-02-25', + }, + } +}; + +export default adapter; From db4563a0ca1c7cd5f2323242ff3f9742d236f576 Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:37:03 +0100 Subject: [PATCH 50/86] track neby dex vol & fees --- dexs/neby-dex.ts | 12 ++++++++++++ fees/neby-dex.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ helpers/chains.ts | 1 + 3 files changed, 55 insertions(+) create mode 100644 dexs/neby-dex.ts create mode 100644 fees/neby-dex.ts diff --git a/dexs/neby-dex.ts b/dexs/neby-dex.ts new file mode 100644 index 0000000000..91ccb7343d --- /dev/null +++ b/dexs/neby-dex.ts @@ -0,0 +1,12 @@ +import { univ2Adapter } from "../helpers/getUniSubgraphVolume"; +import { CHAIN } from "../helpers/chains"; + +const endpoints = { + [CHAIN.SAPPHIRE]: 'https://api.goldsky.com/api/public/project_clzi4lu67khgw01072ibvekvt/subgraphs/neby-dex-sapphire-mainnet/1.0.0/gn', +}; +const adapter = univ2Adapter(endpoints, { + factoriesName: 'factories', +}); + + +export default adapter diff --git a/fees/neby-dex.ts b/fees/neby-dex.ts new file mode 100644 index 0000000000..bdec939d24 --- /dev/null +++ b/fees/neby-dex.ts @@ -0,0 +1,42 @@ +import { SimpleAdapter } from "../adapters/types"; +import { CHAIN } from "../helpers/chains"; +import { getGraphDimensions2 } from "../helpers/getUniSubgraph"; + +const methodology = { + UserFees: "LPs collect 100% of the fee generated in a pool", + Fees: "Fees generated on each swap at a rate set by the pool.", + TotalUserFees: "Cumulative all-time Fees", + TotalFees: "Cumulative all-time Fees", +}; + +const v3Graphs = getGraphDimensions2({ + graphUrls: { + [CHAIN.SAPPHIRE]: "https://api.goldsky.com/api/public/project_clzi4lu67khgw01072ibvekvt/subgraphs/neby-dex-sapphire-mainnet/1.0.0/gn" + }, + totalVolume: { + factory: "factories", + }, + feesPercent: { + type: "fees", + ProtocolRevenue: 0, + HoldersRevenue: 0, + Fees: 0, + UserFees: 100, // User fees are 100% of collected fees + SupplySideRevenue: 100, // 100% of fees are going to LPs + Revenue: 0, // Revenue is 100% of collected fees + }, +}); + +const adapter: SimpleAdapter = { + version: 2, + adapter: { + [CHAIN.SAPPHIRE]: { + fetch: v3Graphs(CHAIN.SAPPHIRE), + meta: { + methodology, + }, + }, + }, +}; + +export default adapter; diff --git a/helpers/chains.ts b/helpers/chains.ts index 71a66a9396..5b108fbe96 100644 --- a/helpers/chains.ts +++ b/helpers/chains.ts @@ -197,6 +197,7 @@ export enum CHAIN { ARCHWAY = "archway-1", NEUTRON = "neutron", CORN = "corn", + SAPPHIRE = "sapphire", } // Don´t use From ef9ced5a0328052b56fac23ad2927fb5a9c33d5f Mon Sep 17 00:00:00 2001 From: Zoomer <87513793+ethzoomer@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:56:32 -0600 Subject: [PATCH 51/86] aerodrome volume / fees / bribes (#2195) * fix: aerodrome volume/fees, bribes * aerodrome v1 pools filtering * aerodrome v1 amount0 amount1 fix * velodrome bribes * aerodrome slipstream pools filtering --- dexs/aerodrome-slipstream/index.ts | 5 +- dexs/aerodrome/index.ts | 97 ++++++++++++++++++++++++++++-- fees/aerodrome/index.ts | 43 +++++++++++-- fees/velodrome-v2/index.ts | 63 +++++++++++++------ 4 files changed, 178 insertions(+), 30 deletions(-) diff --git a/dexs/aerodrome-slipstream/index.ts b/dexs/aerodrome-slipstream/index.ts index 19ed76a1f3..4b56c4df4e 100644 --- a/dexs/aerodrome-slipstream/index.ts +++ b/dexs/aerodrome-slipstream/index.ts @@ -19,11 +19,12 @@ const fetch = async (fetchOptions: FetchOptions): Promise => { let pairs = await api.fetchList({ lengthAbi: 'allPoolsLength', itemAbi: 'allPools', target: '0x5e7BB104d84c7CB9B682AaC2F3d509f5F406809A' }) let token0s = await api.multiCall({ abi: 'address:token0', calls: pairs }) let token1s = await api.multiCall({ abi: 'address:token1', calls: pairs }) - const res = await filterPools2({ fetchOptions, pairs, token0s, token1s }) - api.log(res.pairs.length, 'pairs out of', pairs.length, chain, 'aerodrome') + + const res = await filterPools2({ fetchOptions, pairs, token0s, token1s, minUSDValue: 2000, maxPairSize: 1000 }) pairs = res.pairs token0s = res.token0s token1s = res.token1s + const fees = await api.multiCall({ abi: 'uint256:fee', calls: pairs }) let logs: ILog[][] = await getLogs({ targets: pairs, eventAbi: event_swap, flatten: false, }) diff --git a/dexs/aerodrome/index.ts b/dexs/aerodrome/index.ts index 0c866acda6..d9559d36ff 100644 --- a/dexs/aerodrome/index.ts +++ b/dexs/aerodrome/index.ts @@ -1,8 +1,95 @@ +import { FetchOptions, FetchResult, SimpleAdapter } from "../../adapters/types" import { CHAIN } from "../../helpers/chains" -import { uniV2Exports } from "../../helpers/uniswap"; +import { addOneToken } from "../../helpers/prices"; +import { filterPools2 } from "../../helpers/uniswap"; -const swapEvent = 'event Swap(address indexed sender, address indexed to, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out)' +interface ILog { + address: string; + data: string; + transactionHash: string; + topics: string[]; +} +const event_swap = 'event Swap(address indexed sender, address indexed to, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out)' -export default uniV2Exports({ - [CHAIN.BASE]: { factory: '0x420DD381b31aEf6683db6B902084cB0FFECe40Da', swapEvent, }, -}) +const fetch = async (fetchOptions: FetchOptions): Promise => { + const { api, getLogs, createBalances, } = fetchOptions + const chain = api.chain + const dailyVolume = createBalances() + const dailyFees = createBalances() + let pairs = await api.fetchList({ lengthAbi: 'allPoolsLength', itemAbi: 'allPools', target: '0x420DD381b31aEf6683db6B902084cB0FFECe40Da' }) + let token0s = await api.multiCall({ abi: 'address:token0', calls: pairs }) + let token1s = await api.multiCall({ abi: 'address:token1', calls: pairs }) + + const res = await filterPools2({ fetchOptions, pairs, token0s, token1s, minUSDValue: 10000, maxPairSize: 1200 }) + pairs = res.pairs + token0s = res.token0s + token1s = res.token1s + + let stables = await api.multiCall({ abi: 'bool:stable', calls: pairs }) + + const poolsCalls: any[] = []; + pairs.forEach((pair: any, i) => { + poolsCalls.push({ + target: '0x420DD381b31aEf6683db6B902084cB0FFECe40Da', + params: [pair, stables[i]] + }) + }); + + const fees = await api.multiCall({ abi: 'function getFee(address pool, bool _stable) external view returns (uint256)', calls: poolsCalls }) + + let logs: ILog[][] = []; + const targetChunkSize = 5; + let currentTargetOffset = 0; + let unfinished = true; + + while (unfinished) { + let endOffset = currentTargetOffset + targetChunkSize; + if (endOffset >= pairs.length) { + unfinished = false; + endOffset = pairs.length; + } + + let currentLogs: ILog[][] = await getLogs({ + targets: pairs.slice(currentTargetOffset, endOffset), + eventAbi: event_swap, + flatten: false, + }) + + logs.push(...currentLogs); + currentTargetOffset += targetChunkSize; + } + + logs.forEach((logs: ILog[], idx: number) => { + const token0 = token0s[idx] + const token1 = token1s[idx] + const fee = fees[idx]/1e4 + + logs.forEach((log: any) => { + let amount0 = log.amount0In; + let amount1 = log.amount1Out; + + if (Number(amount0) === 0) { + amount0 = log.amount0out; + amount1 = log.amount1In; + } + + let fee0 = Number(amount0) * fee; + let fee1 = Number(amount1) * fee; + addOneToken({ chain, balances: dailyVolume, token0, token1, amount0, amount1 }) + addOneToken({ chain, balances: dailyFees, token0, token1, amount0: fee0, amount1: fee1 }) + }) + }) + + return { dailyVolume, dailyFees, dailyRevenue: dailyFees, dailyHoldersRevenue: dailyFees } as any +} + +const adapters: SimpleAdapter = { + version: 2, + adapter: { + [CHAIN.BASE]: { + fetch: fetch as any, + start: '2023-08-28', + } + } +} +export default adapters; diff --git a/fees/aerodrome/index.ts b/fees/aerodrome/index.ts index e28d1b3549..6bac20eadb 100644 --- a/fees/aerodrome/index.ts +++ b/fees/aerodrome/index.ts @@ -1,8 +1,41 @@ +import { FetchOptions, FetchResult, SimpleAdapter } from "../../adapters/types" import { CHAIN } from "../../helpers/chains" -import { uniV2Exports } from "../../helpers/uniswap"; -const swapEvent = 'event Swap(address indexed sender, address indexed to, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out)' +const event_notify_reward = 'event NotifyReward(address indexed from,address indexed reward,uint256 indexed epoch,uint256 amount)'; +const event_gauge_created = 'event GaugeCreated(address indexed poolFactory,address indexed votingRewardsFactory,address indexed gaugeFactory,address pool,address bribeVotingReward,address feeVotingReward,address gauge,address creator)' -export default uniV2Exports({ - [CHAIN.BASE]: { factory: '0x420DD381b31aEf6683db6B902084cB0FFECe40Da', swapEvent, voter: '0x16613524e02ad97eDfeF371bC883F2F5d6C480A50', maxPairSize: 65, }, -}) +const fetch = async (fetchOptions: FetchOptions): Promise => { + const { api, getLogs, createBalances, getToBlock, } = fetchOptions + const chain = api.chain + const voter = '0x16613524e02ad97eDfeF371bC883F2F5d6C480A5'; + const dailyBribes = createBalances() + const logs_gauge_created = (await getLogs({ + target: voter, + fromBlock: 3200601, + toBlock: await getToBlock(), + eventAbi: event_gauge_created, + cacheInCloud: true, + })) + const bribes_contract: string[] = logs_gauge_created.map((e: any) => e.bribeVotingReward.toLowerCase()); + + const logs = await getLogs({ + targets: bribes_contract, + eventAbi: event_notify_reward, + }) + logs.map((e: any) => { + dailyBribes.add(e.reward, e.amount) + }) + + return { dailyBribesRevenue: dailyBribes } as any +} + +const adapters: SimpleAdapter = { + version: 2, + adapter: { + [CHAIN.BASE]: { + fetch: fetch as any, + start: '2023-08-28', + } + } +} +export default adapters; diff --git a/fees/velodrome-v2/index.ts b/fees/velodrome-v2/index.ts index f7c08464f2..2f0536426f 100644 --- a/fees/velodrome-v2/index.ts +++ b/fees/velodrome-v2/index.ts @@ -4,6 +4,9 @@ import { uniV2Exports } from "../../helpers/uniswap"; const swapEvent = 'event Swap(address indexed sender, address indexed to, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out)' const notifyRewardEvent = 'event NotifyReward(address indexed from,uint256 amount)'; +const event_notify_reward_op = 'event NotifyReward(address indexed from,address indexed reward,uint256 indexed epoch,uint256 amount)'; +const event_gauge_created = 'event GaugeCreated(address indexed poolFactory,address indexed votingRewardsFactory,address indexed gaugeFactory,address pool,address bribeVotingReward,address feeVotingReward,address gauge,address creator)' + const config = { [CHAIN.MODE]: { stakingRewards: '0xD2F998a46e4d9Dd57aF1a28EBa8C34E7dD3851D7', @@ -17,27 +20,51 @@ const config = { const customLogic = async ({ dailyFees, fetchOptions, filteredPairs, }: any) => { - const { createBalances, getLogs, chain, api, } = fetchOptions - const { stakingRewards, rewardToken, } = config[chain] - const pairs = Object.keys(filteredPairs) - const gauges = await api.multiCall({ target: stakingRewards, abi: 'function gauges(address) view returns (address)', calls: pairs }) - const dailyBribesRevenue = createBalances() - const logs = await getLogs({ targets: gauges, eventAbi: notifyRewardEvent }) - - logs.forEach(log => { - dailyBribesRevenue.add(rewardToken, log.amount) - }) - return { - dailyFees, - dailyRevenue: dailyFees, - dailyHoldersRevenue: dailyFees, - dailyBribesRevenue, - }; + const { createBalances, getLogs, chain, api, getToBlock, } = fetchOptions + + if (chain === CHAIN.OPTIMISM) { + let voter = '0x41C914ee0c7E1A5edCD0295623e6dC557B5aBf3C' + const dailyBribes = createBalances() + const logs_gauge_created = (await getLogs({ + target: voter, + fromBlock: 105896852, + toBlock: await getToBlock(), + eventAbi: event_gauge_created, + cacheInCloud: true, + })) + const bribes_contract: string[] = logs_gauge_created.map((e: any) => e.bribeVotingReward.toLowerCase()); + + let logs = await getLogs({ + targets: bribes_contract, + eventAbi: event_notify_reward_op, + }) + logs.map((e: any) => { + dailyBribes.add(e.reward, e.amount) + }) + + return { dailyBribesRevenue: dailyBribes } as any + } + else { + const { stakingRewards, rewardToken, } = config[chain] + const pairs = Object.keys(filteredPairs) + const gauges = await api.multiCall({ target: stakingRewards, abi: 'function gauges(address) view returns (address)', calls: pairs }) + const dailyBribesRevenue = createBalances() + let logs = await getLogs({ targets: gauges, eventAbi: notifyRewardEvent }) + + logs.forEach(log => { + dailyBribesRevenue.add(rewardToken, log.amount) + }) + return { + dailyFees, + dailyRevenue: dailyFees, + dailyHoldersRevenue: dailyFees, + dailyBribesRevenue, + }; + } } export default uniV2Exports({ - [CHAIN.OPTIMISM]: { factory: '0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a', swapEvent, voter: '0x41c914ee0c7e1a5edcd0295623e6dc557b5abf3c', maxPairSize: 51, }, + [CHAIN.OPTIMISM]: { factory: '0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a', swapEvent, voter: '0x41c914ee0c7e1a5edcd0295623e6dc557b5abf3c', maxPairSize: 500, customLogic, }, [CHAIN.MODE]: { factory: '0x31832f2a97Fd20664D76Cc421207669b55CE4BC0', customLogic }, [CHAIN.BOB]: { factory: '0x31832f2a97Fd20664D76Cc421207669b55CE4BC0', swapEvent, customLogic, }, }) - From 9a1e16a160f510e0edfb5828e07c2abf01aec28d Mon Sep 17 00:00:00 2001 From: utyablabs Date: Wed, 18 Dec 2024 03:20:07 +0100 Subject: [PATCH 52/86] Add UtyabSwap Volume Adapter --- dexs/utyabswap/index.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 dexs/utyabswap/index.ts diff --git a/dexs/utyabswap/index.ts b/dexs/utyabswap/index.ts new file mode 100644 index 0000000000..38df78b1e4 --- /dev/null +++ b/dexs/utyabswap/index.ts @@ -0,0 +1,29 @@ +import postURL from "../../utils/fetchURL" +import { CHAIN } from "../../helpers/chains"; +import { FetchOptions } from "../../adapters/types"; + +const endpoint = "https://api.utyabswap.com/v1/stats/volume?" + +const fetch = async (options: FetchOptions) => { + const startTime = options.startTimestamp * 1000; + const endTime = options.endTimestamp * 1000; + const res = await postURL(`${endpoint}start_time=${startTime}&end_time=${endTime}`) + + return { + dailyVolume: parseFloat(res['volume_usd']), + timestamp: options.startTimestamp, + }; +}; + + +const adapter: any = { + version: 2, + adapter: { + [CHAIN.TON]: { + fetch, + start: '2024-12-9', + }, + }, +}; + +export default adapter; From c8cc88a853eadeb29ed5f1d622a89cc678b3b813 Mon Sep 17 00:00:00 2001 From: GaussETH Date: Wed, 18 Dec 2024 14:08:41 +0800 Subject: [PATCH 53/86] feat: update FeeFree adpater --- dexs/FeeFree/index.ts | 77 +++++++++++++------------------------------ 1 file changed, 23 insertions(+), 54 deletions(-) diff --git a/dexs/FeeFree/index.ts b/dexs/FeeFree/index.ts index bf18f38af9..75373072f2 100644 --- a/dexs/FeeFree/index.ts +++ b/dexs/FeeFree/index.ts @@ -2,72 +2,37 @@ import { FetchOptions, FetchV2, SimpleAdapter } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; import { addOneToken } from "../../helpers/prices"; -const INITIALIZE_EVENT_ABI = 'event Initialize(bytes32 id, address indexed currency0, address indexed currency1, uint24 fee, int24 tickSpacing, address hooks)'; -const SWAP_EVENT_ABI = "event Swap(bytes32 indexed id, address sender, int128 amount0, int128 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick, uint24 fee)"; +const SWAP_EVENT_ABI = "event Swap(address indexed sender, address indexed input, address indexed output, uint256 amountIn, uint256 amountOut, uint256 swapFee)"; const CONFIG = { - [CHAIN.ZORA]: { - pool: "0xB43287b2106BC044F07aE674794f5492E851d3dC", - router: "0x0Fee97363deEFBE4De038D437D805A98dbEbA400", - fromBlock: 13704184, - swapFee: 10000000000000n, - }, - [CHAIN.BASE]: { - pool: "0xc08304a5300D9a2310A603b8D7fB8470f752947F", - router: "0x0Fee76f15DE74A5211e5Bc2aBF95394d7f50C400", - fromBlock: 14089843, - swapFee: 10000000000000n, - }, + [CHAIN.ZORA]: "0x0FeeCCFaa507d20c2b18a6381080C062d52DbF00", + [CHAIN.BASE]: "0x0Fee3Fa06550723cbf8590AC2f769F2F603e4000", + [CHAIN.SCROLL]: "0x0Feeb68668672B3d6bF3E01455164a24B266c400", }; -type Pair = { - id: string, - currency0: string; - currency1: string; -}; - -const getTokenPairs = async (options: FetchOptions): Promise<{[id:string]: Pair}> => { - const config = CONFIG[options.chain]; - - const logs = await options.api.getLogs({ - target: config.pool, - eventAbi: INITIALIZE_EVENT_ABI, - fromBlock: config.fromBlock, - toBlock: options.api.block, - onlyArgs: true, - }); - - const pairs = logs.map(log => { - const [id, currency0, currency1] = log - return { id, currency0, currency1 } - }); - - return Object.fromEntries(pairs.map((pair) => [pair.id, pair])); -} - -const fetchVolume: FetchV2 = async (options: FetchOptions) => { +const fetch: FetchV2 = async (options: FetchOptions) => { const dailyVolume = options.createBalances(); const dailyFees = options.createBalances(); - const pairs = await getTokenPairs(options); - const config = CONFIG[options.chain]; + const address = CONFIG[options.chain]; const logs = await options.getLogs({ - target: config.pool, + target: address, eventAbi: SWAP_EVENT_ABI, }); logs.forEach((log: any) => { - const [id,,amount0, amount1] = log; - const pair = pairs[id]; + const [,input, output, amountIn, amountOut, swapFee] = log; + addOneToken({ balances: dailyVolume, chain: options.chain, - token0: pair.currency0, - token1: pair.currency1, - amount0, - amount1, + token0: input, + token1: output, + amount0: amountIn, + amount1: amountOut, }); + + dailyFees.addGasToken(swapFee); }); - dailyFees.addGasToken(config.swapFee * BigInt(logs.length)); return { dailyVolume, @@ -79,12 +44,16 @@ const adapter: SimpleAdapter = { version: 2, adapter: { [CHAIN.ZORA]: { - fetch: fetchVolume, - start: '2024-04-25', + fetch, + start: '2024-12-17', }, [CHAIN.BASE]: { - fetch: fetchVolume, - start: '2024-05-05', + fetch, + start: '2024-12-17', + }, + [CHAIN.SCROLL]: { + fetch, + start: '2024-12-17', }, } } From 41bbabadd26ff1b87e7b12df71a838d429265fed Mon Sep 17 00:00:00 2001 From: 0xpeluche <0xpeluche@proton.me> Date: Wed, 18 Dec 2024 12:46:24 +0100 Subject: [PATCH 54/86] WIP - fluid --- fees/fluid/fees.ts | 44 ++++++++++++++++++++++++++++---------------- fees/fluid/index.ts | 2 +- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/fees/fluid/fees.ts b/fees/fluid/fees.ts index 8c82448d9b..ae19b5011d 100644 --- a/fees/fluid/fees.ts +++ b/fees/fluid/fees.ts @@ -41,13 +41,13 @@ export const getVaultsResolver = async (api: ChainApi) => { return { getAllVaultsAddresses: async () => api.call({ target: address, abi: abi.getAllVaultsAddresses }), - getVaultEntireData: async (vaults: string []) => api.multiCall({ calls: vaults.map((vault) => ({ target: address, params: [vault] })), abi: abi.getVaultEntireData, permitFailure: true }) + getVaultEntireData: async (vaults: string []) => api.multiCall({ calls: vaults.map((vault) => ({ target: address, params: [vault] })), abi: abi.getVaultEntireData }) } } -export const getFluidDailyFees = async ({ api, fromApi, toApi, getLogs, createBalances }: FetchOptions, fromBlock: number, toBlock: number) => { +export const getFluidDailyFees = async ({ api, fromApi, toApi, getLogs, createBalances }: FetchOptions) => { const dailyFees = createBalances(); - const liquidityLogs = await getLogs({ fromBlock, toBlock, target: LIQUIDITY, onlyArgs: true, eventAbi: EVENT_ABI.logOperate }); + const liquidityLogs = await getLogs({ target: LIQUIDITY, onlyArgs: true, eventAbi: EVENT_ABI.logOperate }); const vaults: string[] = await (await getVaultsResolver(api)).getAllVaultsAddresses(); if (!liquidityLogs.length) return dailyFees @@ -65,28 +65,40 @@ export const getFluidDailyFees = async ({ api, fromApi, toApi, getLogs, createBa // Skip the current vault if any required data is missing if (!vaultDataFrom || !vaultDataTo || !borrowData) return; + const vaultFrom = vaultDataFrom.vault + const vaultTo = vaultDataTo.vault + + if (!vaultFrom || !vaultTo || vaultFrom !== vault || vaultTo !== vault) return + const { borrowToken } = borrowData; - const { totalSupplyAndBorrow: totalSupplyAndBorrowFrom, constantVariables } = vaultDataFrom; + const { totalSupplyAndBorrow: totalSupplyAndBorrowFrom } = vaultDataFrom; const { totalSupplyAndBorrow: totalSupplyAndBorrowTo } = vaultDataTo; - const token = constantVariables.borrowToken ?? borrowToken; - if (!token) return; - - const initialBalance = Number(totalSupplyAndBorrowFrom.totalBorrowVault); + if (!borrowToken) return; - const vaultOperates = liquidityLogs.filter( - ([vaultOperate, tokenUsed, , , , receiver]) => - vaultOperate === vault && tokenUsed === token && receiver !== reserveContract - ); + const initialBalance = BigInt(totalSupplyAndBorrowFrom.totalBorrowVault); + const borrowBalanceTo = BigInt(totalSupplyAndBorrowTo.totalBorrowVault); + const vaultOperates = [...liquidityLogs + .filter(([vaultOperate, tokenUsed, , , , receiver]) => + vaultOperate === vault && tokenUsed === borrowToken && receiver !== reserveContract + ) + .reduce((uniqueLogs, log) => { + const logKey = `${log[0]}_${log[1]}_${log[2]}_${log[3]}_${log[4]}_${log[5]}_${log[6]}_${log[7]}`; + if (!uniqueLogs.has(logKey)) { + uniqueLogs.set(logKey, log); + } + return uniqueLogs; + }, new Map()) + .values()]; + const borrowBalance = vaultOperates.reduce( - (balance, [, , , amount]) => balance + Number(amount || 0), + (balance, [, , , amount]) => balance + BigInt(amount), initialBalance ); - const borrowBalanceTo = Number(totalSupplyAndBorrowTo.totalBorrowVault); - const fees = borrowBalanceTo > borrowBalance ? borrowBalanceTo - borrowBalance : 0; - dailyFees.add(token, fees); + const fees = borrowBalanceTo > borrowBalance ? borrowBalanceTo - borrowBalance : 0n; + dailyFees.add(borrowToken, fees); }); return dailyFees; diff --git a/fees/fluid/index.ts b/fees/fluid/index.ts index eb149b8c79..aa0b056b04 100644 --- a/fees/fluid/index.ts +++ b/fees/fluid/index.ts @@ -6,7 +6,7 @@ import { getFluidDailyRevenue } from "./revenue"; const fetch: FetchV2 = async (options: FetchOptions) => { const [fromBlock, toBlock] = await Promise.all([options.getFromBlock(), options.getToBlock()]); const [dailyFees, dailyRevenue] = await Promise.all([ - getFluidDailyFees(options, fromBlock, toBlock), + getFluidDailyFees(options), getFluidDailyRevenue(options, fromBlock, toBlock) ]) return { dailyFees, dailyRevenue }; From bcfb06299c57c6cf173c1c3c25a88806c1ca3b8f Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Wed, 18 Dec 2024 13:09:17 +0000 Subject: [PATCH 55/86] fix daily volume --- dexs/mantis/index.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/dexs/mantis/index.ts b/dexs/mantis/index.ts index 3c20211847..318d098184 100644 --- a/dexs/mantis/index.ts +++ b/dexs/mantis/index.ts @@ -1,7 +1,6 @@ -import { Chain } from "@defillama/sdk/build/general"; -import { Adapter, ChainBlocks, FetchOptions, FetchResult, ProtocolType } from "../../adapters/types"; +import { Adapter, ChainBlocks, FetchOptions, FetchResult } from "../../adapters/types"; import { CHAIN } from '../../helpers/chains'; -import fetchURL from "../../utils/fetchURL" +import fetchURL from "../../utils/fetchURL"; const MANTIS_INDEXER_API = `https://mantis-indexer.composable-shared-artifacts.composablenodes.tech`; const MANTIS_VOLUME_API = `${MANTIS_INDEXER_API}/api/domain/getvolume`; @@ -10,7 +9,7 @@ const MANTIS_VOLUME_API = `${MANTIS_INDEXER_API}/api/domain/getvolume`; function removeInvalidKeys(obj: any) { Object.keys(obj).forEach(key => { if (key.includes("…")) { - console.log("Removing key", key); + console.log("Removing key", key); delete obj[key]; } }); @@ -18,8 +17,8 @@ function removeInvalidKeys(obj: any) { const fetch = async (timestamp: number, _: ChainBlocks, options: FetchOptions): Promise => { const chain = options.chain - const urlDaily = `${MANTIS_VOLUME_API}?timestamp=${options.toTimestamp}&chain=${chain == CHAIN.ETHEREUM ? 1 : 2}&period=1&solved_only=true`; - const urlTotal = `${MANTIS_VOLUME_API}?timestamp=${options.toTimestamp}&chain=${chain == CHAIN.ETHEREUM ? 1 : 2}&period=0&solved_only=true`; + const urlDaily = `${MANTIS_VOLUME_API}?timestamp=${options.startOfDay}&chain=${chain == CHAIN.ETHEREUM ? 1 : 2}&period=1&solved_only=true`; + const urlTotal = `${MANTIS_VOLUME_API}?timestamp=${options.startOfDay}&chain=${chain == CHAIN.ETHEREUM ? 1 : 2}&period=0&solved_only=true`; const volumeDaily = (await fetchURL(urlDaily)).assets; const volumeTotal = (await fetchURL(urlTotal)).assets; From 2e5701d2b04f29cdf62e73669ed940bbd48f2f04 Mon Sep 17 00:00:00 2001 From: Tyler Tsai Date: Wed, 18 Dec 2024 16:46:43 +0800 Subject: [PATCH 56/86] feat: supplement lisusd fees --- fees/lista-lisusd/index.ts | 251 ++++++++++++++++++++++++++----------- 1 file changed, 175 insertions(+), 76 deletions(-) diff --git a/fees/lista-lisusd/index.ts b/fees/lista-lisusd/index.ts index 61473ab070..fafde2b508 100644 --- a/fees/lista-lisusd/index.ts +++ b/fees/lista-lisusd/index.ts @@ -1,9 +1,6 @@ import BigNumber from "bignumber.js"; import { FetchOptions, SimpleAdapter } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; -import ADDRESSES from "../../helpers/coreAssets.json"; - -const treasury = "0x8d388136d578dCD791D081c6042284CED6d9B0c6"; /** * Fetches data from Lista DAO @@ -15,10 +12,18 @@ const treasury = "0x8d388136d578dCD791D081c6042284CED6d9B0c6"; * https://bscscan.com/address/0x34b504a5cf0ff41f8a480580533b6dda687fa3da#tokentxns */ +const oldTreasury = + "0x0000000000000000000000008d388136d578dcd791d081c6042284ced6d9b0c6"; +const newTreasury = + "0x00000000000000000000000034b504a5cf0ff41f8a480580533b6dda687fa3da"; +const zeroAddress = + "0x0000000000000000000000000000000000000000000000000000000000000000"; +const transferHash = + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"; const HelioETHProvider = "0x0326c157bfF399e25dd684613aEF26DBb40D3BA4"; // const MasterVault = "0x986b40C2618fF295a49AC442c5ec40febB26CC54"; const SnBnbYieldConverterStrategy = - "0x6F28FeC449dbd2056b76ac666350Af8773E03873"; + "0x0000000000000000000000006f28fec449dbd2056b76ac666350af8773e03873"; const CeETHVault = "0xA230805C28121cc97B348f8209c79BEBEa3839C0"; const HayJoin = "0x4C798F81de7736620Cd8e6510158b1fE758e22F7"; @@ -26,136 +31,230 @@ const HayJoin = "0x4C798F81de7736620Cd8e6510158b1fE758e22F7"; const lista = "0xFceB31A79F71AC9CBDCF853519c1b12D379EdC46"; const slisBNB = "0xb0b84d294e0c75a6abe60171b70edeb2efd14a1b"; const eth = "0x2170Ed0880ac9A755fd29B2688956BD959F933F8"; +const wbeth = "0xa2e3356610840701bdf5611a53974510ae27e2e1"; const bnb = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"; const lisUSD = "0x0782b6d8c4551B9760e74c0545a9bCD90bdc41E5"; - +const usdt = "0x55d398326f99059ff775485246999027b3197955"; const fetch = async (options: FetchOptions) => { const dailyFees = options.createBalances(); - const logs_claim = await options.getLogs({ - target: HelioETHProvider, - eventAbi: "event Claim(address recipient, uint256 amount)", - entireLog: true, - }); - - // enable later - // const logs_fees_claim = await options.getLogs({ - // target: MasterVault, - // eventAbi: "event FeeClaimed(address receiver, uint256 amount)", - // }); - - const logs_fees_harvested = await options.getLogs({ - target: SnBnbYieldConverterStrategy, - eventAbi: "event Harvested(address to, uint256 amount)", - }); - - // CeETHVault - const eth_transfer1 = await options.getLogs({ + // eth staking profit - helioETHProvider and CeETHVault + const ethStakingEthOld = await options.getLogs({ target: eth, topics: [ - "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + transferHash, "0x000000000000000000000000a230805c28121cc97b348f8209c79bebea3839c0", - "0x0000000000000000000000008d388136d578dcd791d081c6042284ced6d9b0c6", + oldTreasury, ], }); - - const eth_transfer2 = await options.getLogs({ + const ethStakingEthNew = await options.getLogs({ target: eth, topics: [ - "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + transferHash, "0x000000000000000000000000a230805c28121cc97b348f8209c79bebea3839c0", - "0x00000000000000000000000034b504a5cf0ff41f8a480580533b6dda687fa3da", + newTreasury, ], }); + const ethStakingWbethOld = await options.getLogs({ + target: wbeth, + topics: [ + transferHash, + "0x000000000000000000000000a230805c28121cc97b348f8209c79bebea3839c0", + oldTreasury, + ], + }); + const ethStakingWbethNew = await options.getLogs({ + target: wbeth, + topics: [ + transferHash, + "0x000000000000000000000000a230805c28121cc97b348f8209c79bebea3839c0", + newTreasury, + ], + }); + + // BNB Liquid Staking Fee - ListaStakeManager + const bnbLiquidStakingFeeOld = await options.getLogs({ + target: slisBNB, + topics: [transferHash, zeroAddress, oldTreasury], + }); + const bnbLiquidStakingFeeNew = await options.getLogs({ + target: slisBNB, + topics: [transferHash, zeroAddress, newTreasury], + }); + + // BNB provide Fee - MasterVault + // No fees charged for now + + // bnb liquid staking profit - SnBnbYieldConverterStrategy + const bnbLiquidStakingProfitOld = await options.getLogs({ + target: slisBNB, + topics: [transferHash, SnBnbYieldConverterStrategy, oldTreasury], + }); + const bnbLiquidStakingProfitNew = await options.getLogs({ + target: slisBNB, + topics: [transferHash, SnBnbYieldConverterStrategy, newTreasury], + }); - // flash loan - const lisusd_transfer1 = await options.getLogs({ + // borrow lisUSD interest + const borrowLisUSDInterest = await options.getLogs({ target: lisUSD, + topics: [transferHash, zeroAddress, oldTreasury], + }); + const borrowLisUSDInterestNew = await options.getLogs({ + target: lisUSD, + topics: [transferHash, zeroAddress, newTreasury], + }); + + // veLista early claim penalty + const veListaEarlyClaimPenalty = await options.getLogs({ + target: lista, topics: [ - "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", - "0x000000000000000000000000a230805c28121cc97b348f8209c79bebea3839c0", - "0x0000000000000000000000008d388136d578dcd791d081c6042284ced6d9b0c6", + transferHash, + "0x000000000000000000000000d0c380d31db43cd291e2bbe2da2fd6dc877b87b3", + oldTreasury, ], }); + const veListaEarlyClaimPenaltyNew = await options.getLogs({ + target: lista, + topics: [ + transferHash, + "0x000000000000000000000000d0c380d31db43cd291e2bbe2da2fd6dc877b87b3", + newTreasury, + ], + }); + + //liquidation profit - flash buy - const lisusd_transfer2 = await options.getLogs({ + const liquidationProfit = await options.getLogs({ target: lisUSD, topics: [ - "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", - "0x000000000000000000000000a230805c28121cc97b348f8209c79bebea3839c0", - "0x00000000000000000000000034b504a5cf0ff41f8a480580533b6dda687fa3da", + transferHash, + "0x0000000000000000000000009ba88e6b20041750fd4e6271fea455f5d44063cb", + newTreasury, ], }); - // early exit - const logs_exit1 = await options.getLogs({ - target: HayJoin, + // liquidation profit - liquidation bot + const liquidationBot = await options.getLogs({ + target: lisUSD, topics: [ - "0x22d324652c93739755cf4581508b60875ebdd78c20c0cff5cf8e23452b299631", - "0x0000000000000000000000008d388136d578dcd791d081c6042284ced6d9b0c6", + transferHash, + "0x00000000000000000000000008e83a96f4da5decc0e6e9084dde049a3e84ca04", + oldTreasury, + ], + }); + const liquidationBotNew = await options.getLogs({ + target: lisUSD, + topics: [ + transferHash, + "0x00000000000000000000000008e83a96f4da5decc0e6e9084dde049a3e84ca04", + newTreasury, ], }); - const logs_exit2 = await options.getLogs({ - target: HayJoin, + // PSM convert Fee + const psmConvertFee = await options.getLogs({ + target: lisUSD, topics: [ - "0x22d324652c93739755cf4581508b60875ebdd78c20c0cff5cf8e23452b299631", - "0x00000000000000000000000034b504a5cf0ff41f8a480580533b6dda687fa3da", + transferHash, + "0x000000000000000000000000aa57f36dd5ef2ac471863ec46277f976f272ec0c", + newTreasury, ], }); - // claim penalty - const early_claim_penalty1 = await options.getLogs({ - target: lista, + // USDT staking profit - venusAdaptor + const usdtStakingProfit = await options.getLogs({ + target: usdt, topics: [ - "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", - "0x000000000000000000000000d0c380d31db43cd291e2bbe2da2fd6dc877b87b3", + transferHash, + "0x000000000000000000000000f76d9cfd08df91491680313b1a5b44307129cda9", "0x0000000000000000000000008d388136d578dcd791d081c6042284ced6d9b0c6", ], }); - const early_claim_penalty2 = await options.getLogs({ + // veLista Auto Compound Fee - VeListaAutoCompounder + const veListaAutoCompoundFee = await options.getLogs({ target: lista, topics: [ - "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", - "0x000000000000000000000000d0c380d31db43cd291e2bbe2da2fd6dc877b87b3", - "0x00000000000000000000000034b504a5cf0ff41f8a480580533b6dda687fa3da", + transferHash, + "0x0000000000000000000000009a0530a81c83d3b0dae720bf91c9254fecc3bf5e", + newTreasury, ], }); - [...early_claim_penalty1, ...early_claim_penalty2].forEach((log) => { - const amount = Number(log.data); - dailyFees.add(lista, amount); + // validaator rewards - stake ListaDAOCredit + const validatorRewards = await options.getLogs({ + target: "0xC096e7781c95a2fc6fEb1efE776B570270B3965d", + topics: [ + transferHash, + zeroAddress, + "0x0000000000000000000000007766a5ee8294343bf6c8dcf3aa4b6d856606703a", + ], + // target: "0xc096e7781c95a2fc6feb1efe776b570270b3965d", + // eventAbi: + // "event Transfer(address indexed from, address indexed to, uint256 value)", }); - logs_claim.forEach((log) => { + // todo: 12/25 add PCS income + + // new version start + [...ethStakingEthOld, ...ethStakingEthNew].forEach((log) => { const amount = Number(log.data); dailyFees.add(eth, amount); }); - - // enable later - // logs_fees_claim.forEach((log) => { - // const amount = log.amount; - // dailyFees.add(bnb, amount); - // }); - - logs_fees_harvested.forEach((log) => { - const amount = log.amount; + [...ethStakingWbethOld, ...ethStakingWbethNew].forEach((log) => { + const amount = Number(log.data); + dailyFees.add(wbeth, amount); + }); + [...bnbLiquidStakingFeeOld, ...bnbLiquidStakingFeeNew].forEach((log) => { + const amount = Number(log.data); dailyFees.add(slisBNB, amount); }); - [...eth_transfer1, ...eth_transfer2].forEach((log) => { + [...bnbLiquidStakingProfitOld, ...bnbLiquidStakingProfitNew].forEach( + (log) => { + const amount = Number(log.data); + + dailyFees.add(slisBNB, amount); + } + ); + [...borrowLisUSDInterest, ...borrowLisUSDInterestNew].forEach((log) => { const amount = Number(log.data); - dailyFees.add(eth, amount); + + dailyFees.add(lisUSD, amount); }); + [...veListaEarlyClaimPenalty, ...veListaEarlyClaimPenaltyNew].forEach( + (log) => { + const amount = Number(log.data); - [...lisusd_transfer1, ...lisusd_transfer2].forEach((log) => { + dailyFees.add(lista, amount); + } + ); + [...liquidationProfit].forEach((log) => { const amount = Number(log.data); dailyFees.add(lisUSD, amount); }); - [...logs_exit1, ...logs_exit2].forEach((log) => { - dailyFees.add(lisUSD, Number(log.data)); + [...veListaAutoCompoundFee].forEach((log) => { + const amount = Number(log.data); + dailyFees.add(lista, amount); + }); + + [...liquidationBot, ...liquidationBotNew].forEach((log) => { + const amount = Number(log.data); + dailyFees.add(lisUSD, amount); + }); + [...psmConvertFee].forEach((log) => { + const amount = Number(log.data); + dailyFees.add(lisUSD, amount); + }); + [...usdtStakingProfit].forEach((log) => { + const amount = Number(log.data); + dailyFees.add(usdt, amount); + }); + [...validatorRewards].forEach((log) => { + const amount = Number(log.data); + dailyFees.add(bnb, amount); }); return { @@ -169,7 +268,7 @@ const adapter: SimpleAdapter = { adapter: { [CHAIN.BSC]: { fetch, - start: '2023-08-30', + start: "2023-08-30", }, }, }; From 46278df955ec4cfa6a1373249f345e2a0ffbc62c Mon Sep 17 00:00:00 2001 From: 0xpeluche <0xpeluche@proton.me> Date: Wed, 18 Dec 2024 15:23:23 +0100 Subject: [PATCH 57/86] finally fix issue --- fees/fluid/fees.ts | 50 ++++++++++++++++++------------------------- fees/fluid/index.ts | 3 +-- fees/fluid/revenue.ts | 16 +++++++------- 3 files changed, 30 insertions(+), 39 deletions(-) diff --git a/fees/fluid/fees.ts b/fees/fluid/fees.ts index ae19b5011d..938b45719f 100644 --- a/fees/fluid/fees.ts +++ b/fees/fluid/fees.ts @@ -45,61 +45,53 @@ export const getVaultsResolver = async (api: ChainApi) => { } } +const parseInTopic = (address: string): string => { + if (!/^0x[0-9a-fA-F]{40}$/.test(address)) { + throw new Error('Invalid EVM address'); + } + return `0x000000000000000000000000${address.slice(2).toLowerCase()}`; +} + export const getFluidDailyFees = async ({ api, fromApi, toApi, getLogs, createBalances }: FetchOptions) => { const dailyFees = createBalances(); - const liquidityLogs = await getLogs({ target: LIQUIDITY, onlyArgs: true, eventAbi: EVENT_ABI.logOperate }); const vaults: string[] = await (await getVaultsResolver(api)).getAllVaultsAddresses(); - if (!liquidityLogs.length) return dailyFees - const [vaultDatasFrom, vaultDatasTo, vaultBorrowDatas] = await Promise.all([ (await getVaultsResolver(fromApi)).getVaultEntireData(vaults), (await getVaultsResolver(toApi)).getVaultEntireData(vaults), toApi.multiCall({ calls: vaults, abi: ABI.vault.constantsView }) ]) - vaults.map((vault, i) => { + for (const [i, vault] of vaults.entries()) { const vaultDataFrom = vaultDatasFrom[i]; const vaultDataTo = vaultDatasTo[i]; const borrowData = vaultBorrowDatas[i]; // Skip the current vault if any required data is missing - if (!vaultDataFrom || !vaultDataTo || !borrowData) return; + if (!vaultDataFrom || !vaultDataTo || !borrowData) continue; const vaultFrom = vaultDataFrom.vault const vaultTo = vaultDataTo.vault - if (!vaultFrom || !vaultTo || vaultFrom !== vault || vaultTo !== vault) return + if (!vaultFrom || !vaultTo || vaultFrom !== vault || vaultTo !== vault) continue const { borrowToken } = borrowData; const { totalSupplyAndBorrow: totalSupplyAndBorrowFrom } = vaultDataFrom; const { totalSupplyAndBorrow: totalSupplyAndBorrowTo } = vaultDataTo; - if (!borrowToken) return; + if (!borrowToken) continue; - const initialBalance = BigInt(totalSupplyAndBorrowFrom.totalBorrowVault); - const borrowBalanceTo = BigInt(totalSupplyAndBorrowTo.totalBorrowVault); + const initialBalance = Number(totalSupplyAndBorrowFrom.totalBorrowVault); + const borrowBalanceTo = Number(totalSupplyAndBorrowTo.totalBorrowVault); - const vaultOperates = [...liquidityLogs - .filter(([vaultOperate, tokenUsed, , , , receiver]) => - vaultOperate === vault && tokenUsed === borrowToken && receiver !== reserveContract - ) - .reduce((uniqueLogs, log) => { - const logKey = `${log[0]}_${log[1]}_${log[2]}_${log[3]}_${log[4]}_${log[5]}_${log[6]}_${log[7]}`; - if (!uniqueLogs.has(logKey)) { - uniqueLogs.set(logKey, log); - } - return uniqueLogs; - }, new Map()) - .values()]; + const liquidityLogs = await getLogs({ target: LIQUIDITY, onlyArgs: true, topics: ['0x4d93b232a24e82b284ced7461bf4deacffe66759d5c24513e6f29e571ad78d15', parseInTopic(vault), parseInTopic(borrowToken)], eventAbi: EVENT_ABI.logOperate, flatten: true }); - const borrowBalance = vaultOperates.reduce( - (balance, [, , , amount]) => balance + BigInt(amount), - initialBalance - ); - - const fees = borrowBalanceTo > borrowBalance ? borrowBalanceTo - borrowBalance : 0n; - dailyFees.add(borrowToken, fees); - }); + const borrowBalances = liquidityLogs + .filter((log) => log[5] !== reserveContract) + .reduce((balance, [, , , amount]) => balance + Number(amount) , initialBalance) + + const fees = borrowBalanceTo > borrowBalances ? borrowBalanceTo - borrowBalances : 0n + dailyFees.add(borrowToken, fees) + } return dailyFees; }; \ No newline at end of file diff --git a/fees/fluid/index.ts b/fees/fluid/index.ts index aa0b056b04..e4bf639615 100644 --- a/fees/fluid/index.ts +++ b/fees/fluid/index.ts @@ -4,10 +4,9 @@ import { getFluidDailyFees } from "./fees"; import { getFluidDailyRevenue } from "./revenue"; const fetch: FetchV2 = async (options: FetchOptions) => { - const [fromBlock, toBlock] = await Promise.all([options.getFromBlock(), options.getToBlock()]); const [dailyFees, dailyRevenue] = await Promise.all([ getFluidDailyFees(options), - getFluidDailyRevenue(options, fromBlock, toBlock) + getFluidDailyRevenue(options) ]) return { dailyFees, dailyRevenue }; } diff --git a/fees/fluid/revenue.ts b/fees/fluid/revenue.ts index 7eeacd6611..6f6aa9a752 100644 --- a/fees/fluid/revenue.ts +++ b/fees/fluid/revenue.ts @@ -101,7 +101,7 @@ const getUncollectedLiquidities = async (api: ChainApi, timestamp: number, token ); } -const getLiquidityRevenues = async ({ api, fromApi, toApi, getLogs, createBalances, fromTimestamp, toTimestamp }: FetchOptions, fromBlock: number, toBlock: number) => { +const getLiquidityRevenues = async ({ api, fromApi, toApi, getLogs, createBalances, fromTimestamp, toTimestamp }: FetchOptions) => { const dailyValues = createBalances(); const collectedLiquidityLogs = await getLogs({ target: LIQUIDITY, eventAbi: EVENT_ABI.logCollectRevenue }); const tokens: string[] = (await (await liquidityResolver(api)).listedTokens()).map((t: string) => t.toLowerCase()); @@ -152,9 +152,9 @@ const getVaultUncollectedRevenues = async (api: ChainApi, createBalances: Create return values; }; -const getVaultCollectedRevenues = async (api: ChainApi, createBalances: CreateBalances, getLogs, vaults: string [], fromBlock: number, toBlock: number) => { +const getVaultCollectedRevenues = async (api: ChainApi, createBalances: CreateBalances, getLogs, vaults: string []) => { const values = createBalances() - const rebalanceEventLogs: any [] = await getLogs({ fromBlock, toBlock, targets: vaults, onlyArgs: true, flatten: false, eventAbi: EVENT_ABI.logRebalance}) + const rebalanceEventLogs: any [] = await getLogs({ targets: vaults, onlyArgs: true, flatten: false, eventAbi: EVENT_ABI.logRebalance}) if (rebalanceEventLogs.length == 0) return values; @@ -174,7 +174,7 @@ const getVaultCollectedRevenues = async (api: ChainApi, createBalances: CreateBa return values } -const getVaultsRevenues = async ({ api, fromApi, toApi, createBalances, getLogs, fromTimestamp, toTimestamp }: FetchOptions, fromBlock: number, toBlock: number) => { +const getVaultsRevenues = async ({ api, fromApi, toApi, createBalances, getLogs, fromTimestamp, toTimestamp }: FetchOptions) => { if (toTimestamp < CONFIG_FLUID[api.chain].vaultResolverExistAfterTimestamp) return 0 const vaults: string[] = await (await getVaultsResolver(api)).getAllVaultsAddresses(); @@ -182,7 +182,7 @@ const getVaultsRevenues = async ({ api, fromApi, toApi, createBalances, getLogs, const [vaultUncollectedBalancesFrom, vaultUncollectedBalancesTo, vaultCollected] = await Promise.all([ getVaultUncollectedRevenues(fromApi, createBalances, vaults, fromTimestamp), getVaultUncollectedRevenues(toApi, createBalances, vaults, toTimestamp), - getVaultCollectedRevenues(api, createBalances, getLogs, vaults, fromBlock, toBlock) + getVaultCollectedRevenues(api, createBalances, getLogs, vaults) ]) vaultUncollectedBalancesTo.addBalances(vaultCollected) @@ -191,10 +191,10 @@ const getVaultsRevenues = async ({ api, fromApi, toApi, createBalances, getLogs, return revenueTo > revenueFrom ? revenueTo - revenueFrom : 0 } -export const getFluidDailyRevenue = async (options: FetchOptions, fromBlock: number, toBlock: number) => { +export const getFluidDailyRevenue = async (options: FetchOptions) => { const [liquidityRevenues, vaultRevenues] = await Promise.all([ - getLiquidityRevenues(options, fromBlock, toBlock), - getVaultsRevenues(options, fromBlock, toBlock) + getLiquidityRevenues(options), + getVaultsRevenues(options) ]) return liquidityRevenues + vaultRevenues From 0b80be6bfca635dc1e13b07d43a4723d61e5b6d9 Mon Sep 17 00:00:00 2001 From: 0xpeluche <0xpeluche@proton.me> Date: Wed, 18 Dec 2024 15:32:33 +0100 Subject: [PATCH 58/86] . --- fees/fluid/fees.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fees/fluid/fees.ts b/fees/fluid/fees.ts index 938b45719f..60b3cb9e63 100644 --- a/fees/fluid/fees.ts +++ b/fees/fluid/fees.ts @@ -41,7 +41,7 @@ export const getVaultsResolver = async (api: ChainApi) => { return { getAllVaultsAddresses: async () => api.call({ target: address, abi: abi.getAllVaultsAddresses }), - getVaultEntireData: async (vaults: string []) => api.multiCall({ calls: vaults.map((vault) => ({ target: address, params: [vault] })), abi: abi.getVaultEntireData }) + getVaultEntireData: async (vaults: string []) => api.multiCall({ calls: vaults.map((vault) => ({ target: address, params: [vault] })), abi: abi.getVaultEntireData, permitFailure: true }) } } From a7f95f8c618d84b938accb018fac3010ea339c52 Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Wed, 18 Dec 2024 15:04:34 +0000 Subject: [PATCH 59/86] fix allow range --- helpers/flipsidecrypto.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpers/flipsidecrypto.ts b/helpers/flipsidecrypto.ts index bbb2e467c1..a3eaf33994 100644 --- a/helpers/flipsidecrypto.ts +++ b/helpers/flipsidecrypto.ts @@ -184,6 +184,6 @@ async function _queryFlipside(sqlQuery: string, maxAgeMinutes: number = 90) { export function checkCanFlipSideQuery() { if (!isRestrictedMode) return; const currentHour = new Date().getUTCHours(); - if (currentHour >= 4 && currentHour <= 7) return; // 1am - 3am - any time other than this, throw error - throw new Error(`Current hour is ${currentHour}. In restricted mode, can run flipsside queries only between 4am - 7am UTC`); + if (currentHour >= 1 && currentHour <= 3) return; // 1am - 3am - any time other than this, throw error + throw new Error(`Current hour is ${currentHour}. In restricted mode, can run flipsside queries only between 1am - 3am UTC`); } From f2da352ead40aa8e0b5551f6b108a311929a5800 Mon Sep 17 00:00:00 2001 From: 0xpeluche <110820448+0xpeluche@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:05:06 +0100 Subject: [PATCH 60/86] logs (#2235) --- fees/fluid/fees.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fees/fluid/fees.ts b/fees/fluid/fees.ts index 60b3cb9e63..e9f84f07e8 100644 --- a/fees/fluid/fees.ts +++ b/fees/fluid/fees.ts @@ -83,7 +83,7 @@ export const getFluidDailyFees = async ({ api, fromApi, toApi, getLogs, createBa const initialBalance = Number(totalSupplyAndBorrowFrom.totalBorrowVault); const borrowBalanceTo = Number(totalSupplyAndBorrowTo.totalBorrowVault); - const liquidityLogs = await getLogs({ target: LIQUIDITY, onlyArgs: true, topics: ['0x4d93b232a24e82b284ced7461bf4deacffe66759d5c24513e6f29e571ad78d15', parseInTopic(vault), parseInTopic(borrowToken)], eventAbi: EVENT_ABI.logOperate, flatten: true }); + const liquidityLogs = await getLogs({ target: LIQUIDITY, onlyArgs: true, topics: ['0x4d93b232a24e82b284ced7461bf4deacffe66759d5c24513e6f29e571ad78d15', parseInTopic(vault), parseInTopic(borrowToken)], eventAbi: EVENT_ABI.logOperate, flatten: true, skipCacheRead: true }); const borrowBalances = liquidityLogs .filter((log) => log[5] !== reserveContract) From c54a07d13a3cb82b4243f3b942eb318811383dd0 Mon Sep 17 00:00:00 2001 From: Igor Shelkovenkov Date: Thu, 19 Dec 2024 11:54:14 +0100 Subject: [PATCH 61/86] add volumes and fees for LeverageX by Javsphere --- dexs/javsphere/index.ts | 37 +++++++++++++++++++++----- fees/javsphere/index.ts | 59 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 fees/javsphere/index.ts diff --git a/dexs/javsphere/index.ts b/dexs/javsphere/index.ts index 45330786a2..412f0cfaad 100644 --- a/dexs/javsphere/index.ts +++ b/dexs/javsphere/index.ts @@ -1,21 +1,46 @@ import fetchURL from "../../utils/fetchURL"; import type { SimpleAdapter } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; +import {getPrices} from "../../utils/prices"; -type DexData = { - volumeTotal: number, - volume24: number, +const tokenMap = { + WETH: "coingecko:weth", + cbBTC: "coingecko:coinbase-wrapped-btc", + USDC: "coingecko:usd-coin" }; const methodology = { - Volume: "User buys and sell JAV token on CEXes and DEXes.", + Volume: "LeverageX Traders create Volume by placing Trades. User buys and sell JAV token on CEXes and DEXes.", } +const API_VOLUME_DEX = `https://aws-api.javlis.com/api/javsphere/coin-volume`; +const API_LEVERAGE_STAT = 'https://1f5i4e87mf.execute-api.eu-central-1.amazonaws.com/prod/cols-stats' + const fetch = async (timestamp: number) => { - const stats: DexData = await fetchURL(`https://aws-api.javlis.com/api/javsphere/coin-volume`); + const [stats, statsLevX, prices] = await Promise.all([ + fetchURL(API_VOLUME_DEX), + fetchURL(API_LEVERAGE_STAT), + getPrices([tokenMap.WETH, tokenMap.cbBTC, tokenMap.USDC], timestamp) + ]); + + const totalVolumeInUSD = Object.keys(statsLevX.yield.totalVolume).reduce((total, token) => { + const tokenKey = token as keyof typeof tokenMap; + const volume = statsLevX.yield.totalVolume[token]; + const price = prices[tokenMap[tokenKey]]; + return total + (volume * price.price); + }, 0); + + const totalDailyVolumeInUSD = statsLevX.collaterals.reduce((total: number, collateral: any) => { + const tokenKey = collateral.collateralName as keyof typeof tokenMap; + const volume = collateral.lastDayEarned.totalVolume; + const price = prices[tokenMap[tokenKey]]?.price; + + return total + (volume * price || 0); + }, 0); return { - dailyVolume: `${stats.volume24}`, + dailyVolume: totalDailyVolumeInUSD + stats.volume24, + totalVolume: totalVolumeInUSD + stats.volume24, timestamp, }; }; diff --git a/fees/javsphere/index.ts b/fees/javsphere/index.ts new file mode 100644 index 0000000000..8187fe4ca5 --- /dev/null +++ b/fees/javsphere/index.ts @@ -0,0 +1,59 @@ +import fetchURL from "../../utils/fetchURL"; +import type { SimpleAdapter } from "../../adapters/types"; +import { CHAIN } from "../../helpers/chains"; +import {getPrices} from "../../utils/prices"; + +const tokenMap = { + WETH: "coingecko:weth", + cbBTC: "coingecko:coinbase-wrapped-btc", + USDC: "coingecko:usd-coin" +}; + +const methodology = { + Volume: "LeverageX traders paying fees for open trades.", +} + +const API_LEVERAGE_STAT = 'https://1f5i4e87mf.execute-api.eu-central-1.amazonaws.com/prod/cols-stats' + +const fetch = async (timestamp: number) => { + const [statsLevX, prices] = await Promise.all([ + fetchURL(API_LEVERAGE_STAT), + getPrices([tokenMap.WETH, tokenMap.cbBTC, tokenMap.USDC], timestamp) + ]); + + const totalFeesInUSD = Object.keys(statsLevX.yield.totalFees).reduce((total, token) => { + const tokenKey = token as keyof typeof tokenMap; + const volume = statsLevX.yield.totalFees[token]; + const price = prices[tokenMap[tokenKey]]; + return total + (volume * price.price); + }, 0); + + const totalDailyFeesInUSD = statsLevX.collaterals.reduce((total: number, collateral: any) => { + const tokenKey = collateral.collateralName as keyof typeof tokenMap; + const volume = collateral.lastDayEarned.totalFees; + const price = prices[tokenMap[tokenKey]]?.price; + + return total + (volume * price || 0); + }, 0); + + + return { + dailyFees: totalDailyFeesInUSD, + totalFees: totalFeesInUSD, + timestamp, + }; +}; + +const adapter: SimpleAdapter = { + adapter: { + [CHAIN.BASE]: { + fetch, + runAtCurrTime: true, + meta: { + methodology + }, + }, + }, +}; + +export default adapter; From a146a64fded9689ee5e73200d3e88eb6b87ac1c0 Mon Sep 17 00:00:00 2001 From: GoPlus Bot <130978499+goplusbot@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:44:34 +0800 Subject: [PATCH 62/86] add goplus locker fee (#2231) * add goplus locker fee * fix INDEXA_DB not set error on gravity chain * fix INDEXA_DB not set error on morph chain * minor fix --------- Co-authored-by: Mr-Lucky Co-authored-by: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> --- fees/goplus-locker.ts | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 fees/goplus-locker.ts diff --git a/fees/goplus-locker.ts b/fees/goplus-locker.ts new file mode 100644 index 0000000000..ab8f299a00 --- /dev/null +++ b/fees/goplus-locker.ts @@ -0,0 +1,45 @@ +import { Adapter, FetchOptions, } from "../adapters/types"; +import { CHAIN } from "../helpers/chains"; +import { addTokensReceived } from "../helpers/token"; +import ADDRESSES from '../helpers/coreAssets.json'; + +const CHAIN_CONFIG = { + [CHAIN.ETHEREUM]: { start: 20790869 }, + [CHAIN.BSC]: { start: 42387186 }, + [CHAIN.BASE]: { start: 20014325 }, + [CHAIN.ARBITRUM]: { start: 279127453 }, + // [CHAIN.GRAVITY]: { start: 23719062 }, + // [CHAIN.MORPH]: { start: 1125634 } +} + +const fetch: any = async (options: FetchOptions) => { + const dailyFees = options.createBalances(); + + // add native fee + let feeTo = "0x521faAcDFA097ad35a32387727e468F7fD032fD6"; + + await options.api.sumTokens({ owner: feeTo, token: ADDRESSES.null }); + await options.fromApi.sumTokens({ owner: feeTo, token: ADDRESSES.null }); + dailyFees.addBalances(options.api.getBalancesV2()); + dailyFees.subtract(options.fromApi.getBalancesV2()); + + await addTokensReceived({ balances: dailyFees, target: feeTo, options, }) + + + return { dailyFees, dailyRevenue: dailyFees, dailyProtocolRevenue: dailyFees, } +} + +const adapter: Adapter = { + version: 2, + adapter: { + [CHAIN.ETHEREUM]: { fetch, start: '2024-09-20', }, + [CHAIN.BSC]: { fetch, start: '2024-09-19', }, + [CHAIN.BASE]: { fetch, start: '2024-09-20', }, + [CHAIN.ARBITRUM]: { fetch, start: '2024-11-28', }, + [CHAIN.GRAVITY]: { fetch, start: '2024-12-11', }, + [CHAIN.MORPH]: { fetch, start: '2024-12-11', }, + }, + +} + +export default adapter; From 587a788fbfb1abe13b58bdb810a332d5cca0a1fe Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:45:06 +0100 Subject: [PATCH 63/86] minor fix --- fees/goplus-locker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fees/goplus-locker.ts b/fees/goplus-locker.ts index ab8f299a00..e5793a4914 100644 --- a/fees/goplus-locker.ts +++ b/fees/goplus-locker.ts @@ -8,8 +8,8 @@ const CHAIN_CONFIG = { [CHAIN.BSC]: { start: 42387186 }, [CHAIN.BASE]: { start: 20014325 }, [CHAIN.ARBITRUM]: { start: 279127453 }, - // [CHAIN.GRAVITY]: { start: 23719062 }, - // [CHAIN.MORPH]: { start: 1125634 } + [CHAIN.GRAVITY]: { start: 23719062 }, + [CHAIN.MORPH]: { start: 1125634 } } const fetch: any = async (options: FetchOptions) => { From f9c4ae5cf3608c15b5631a4fa9bddc1d45abf6c9 Mon Sep 17 00:00:00 2001 From: Samuele Marro Date: Thu, 19 Dec 2024 15:53:16 +0100 Subject: [PATCH 64/86] Add VinuSwap volume (#2215) * Added VinuSwap. * Added VinuChain to chains. * code refactor --------- Co-authored-by: dtmkeng <0xgnek@gmail.com> Co-authored-by: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> --- dexs/vinuswap/index.ts | 56 +++++++ helpers/chains.ts | 1 + helpers/coreAssets.json | 363 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 386 insertions(+), 34 deletions(-) create mode 100644 dexs/vinuswap/index.ts diff --git a/dexs/vinuswap/index.ts b/dexs/vinuswap/index.ts new file mode 100644 index 0000000000..51a10242f7 --- /dev/null +++ b/dexs/vinuswap/index.ts @@ -0,0 +1,56 @@ +import { FetchOptions, SimpleAdapter } from "../../adapters/types"; +import { CHAIN } from "../../helpers/chains"; +import { addOneToken } from "../../helpers/prices"; + +const event_swap = 'event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick)'; + +// Deployed with an old contract +const V1_POOLS = [ + '0xa97FA6E9A764306107F2103a2024Cfe660c5dA33', + '0x3424b0dd7715C8db92414DB0c5A9E5FA0D51cCb5', + '0xfD763943f628e125CEE3D8d85DC0fc7098355d16', + '0x8d713bC2d35327B536A8B2CCec9392e57C0D04B4', + '0xd50ee26F62B1825d14e22e23747939D96746434c' +] + +// v1.1 factory +const FACTORY = '0xd74dEe1C78D5C58FbdDe619b707fcFbAE50c3EEe' + +const fetch = async ({ getLogs, createBalances, api, chain }: FetchOptions) => { + // VinuSwap is based on a variant of Uniswap v3, but the uniswap v3 helper doesn't work here + const dailyVolume = createBalances(); + + const poolCreationLogs = await getLogs({ + target: FACTORY, + eventAbi: 'event PoolCreated(address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address feeManager, address pool)', + fromBlock: 5000, + cacheInCloud: true, + }) + + const pools = [...V1_POOLS, ...poolCreationLogs.map(log => log.pool)] + + const token0s = await api.multiCall({ abi: 'address:token0', calls: pools }) + const token1s = await api.multiCall({ abi: 'address:token1', calls: pools }) + + + await Promise.all(pools.map(async (pool, idx) => { + const token0 = token0s[idx] + const token1 = token1s[idx] + const logs = await getLogs({ target: pool, eventAbi: event_swap, }) + + logs.forEach(log => { + addOneToken({ balances: dailyVolume, chain, token0, token1, amount0: log.amount0, amount1: log.amount1, }); + }) + })) + + return { dailyVolume, }; +} + +const adapter: SimpleAdapter = { + version: 2, + adapter: { + [CHAIN.VINUCHAIN]: { fetch, start: '2024-06-01' } + } +}; + +export default adapter; diff --git a/helpers/chains.ts b/helpers/chains.ts index 5b108fbe96..19ca8f0907 100644 --- a/helpers/chains.ts +++ b/helpers/chains.ts @@ -195,6 +195,7 @@ export enum CHAIN { ZIRCUIT = "zircuit", WC = "wc", ARCHWAY = "archway-1", + VINUCHAIN = "vinu", NEUTRON = "neutron", CORN = "corn", SAPPHIRE = "sapphire", diff --git a/helpers/coreAssets.json b/helpers/coreAssets.json index 7424bd45fc..ab8ef93df0 100644 --- a/helpers/coreAssets.json +++ b/helpers/coreAssets.json @@ -19,6 +19,7 @@ "DAI": "0x6b175474e89094c44da98b954eedeac495271d0f", "SAI": "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359", "SDAI": "0x83f20f44975d03b1b09e64809b757c47f942beea", + "FXS": "0x3432b6a60d23ca0dfca7761b7ab56459d9c964d0", "cvxFXS": "0xfeef77d3f69374f66429c91d732a244f074bdf74", "cvxCRV": "0x62B9c7356A2Dc64a1969e19C23e4f579F9810Aa7", "vlCVX": "0x72a19342e8f1838460ebfccef09f6585e32db86e", @@ -42,6 +43,7 @@ "sUSD_OLD": "0x57ab1e02fee23774580c119740129eac7081e9d3", "sUSD": "0x57Ab1ec28D129707052df4dF418D58a2D46d5f51", "sUSDe": "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497", + "sUSDS": "0xa3931d71877C0E7a3148CB7Eb4463524FEc27fbD", "SUSHI": "0x6b3595068778dd592e39a122f4f5a5cf09c90fe2", "cbETH": "0xBe9895146f7AF43049ca1c1AE358B0541Ea49704", "FDUSD": "0xc5f0f7b66764f6ec8c8dff7ba683102295e16409", @@ -49,9 +51,9 @@ "AEVO": "0xB528edBef013aff855ac3c50b381f253aF13b997", "STONE": "0x4d831e22f062b5327dfdb15f0b6a5df20e2e3dd0", "USDM": "0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C", - "USDe": "0x4c9edd5852cd905f086c759e8383e09bff1e68b3", - "amprETH": "0xcDC51F2B0e5F0906f2fd5f557de49D99c34Df54e", - "amphrLRT": "0x06824C27C8a0DbDe5F72f770eC82e3c0FD4DcEc3" + "PRISMA": "0xdA47862a83dac0c112BA89c6abC2159b95afd71C", + "FXN": "0x365accfca291e7d3914637abf1f7635db165bb09", + "USDe": "0x4c9edd5852cd905f086c759e8383e09bff1e68b3" }, "fantom": { "WFTM": "0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83", @@ -150,7 +152,8 @@ "YIN": "0x794baab6b878467f93ef17e2f2851ce04e3e34c8", "BNB": "0x5c4b7ccbf908e64f32e12c6650ec0c96d717f03f", "BUSD": "0x9c9e5fd8bbc25984b178fdce6117defa39d2db39", - "WORK": "0x6002410dda2fb88b4d0dc3c1d562f7761191ea80" + "WORK": "0x6002410dda2fb88b4d0dc3c1d562f7761191ea80", + "FRAX": "0x45c32fA6DF82ead1e2EF74d17b76547EDdFaFF89" }, "xdai": { "WXDAI": "0xe91d153e0b41518a2ce8dd3d7944fa863463a97d", @@ -165,7 +168,8 @@ "ETHIX": "0xec3f3e6d7907acda3a7431abd230196cda3fbb19", "SDAI": "0xaf204776c7245bF4147c2612BF6e5972Ee483701", "XHOPR": "0xD4fdec44DB9D44B8f2b6d529620f9C0C7066A2c1", - "DAI_1": "0x678df3415fc31947da4324ec63212874be5a82f8" + "DAI_1": "0x678df3415fc31947da4324ec63212874be5a82f8", + "sDAI": "0xaf204776c7245bf4147c2612bf6e5972ee483701" }, "okexchain": { "USDC": "0xc946daf81b08146b1c7a8da2a851ddf2b3eaaf85", @@ -218,7 +222,9 @@ "USDC": "0x7F5c764cBc14f9669B88837ca1490cCa17c31607", "USDC_CIRCLE": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85", "DAI": "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1", - "WBTC": "0x68f180fcCe6836688e9084f035309E29Bf0A2095" + "WBTC": "0x68f180fcCe6836688e9084f035309E29Bf0A2095", + "weETH": "0x5a7facb970d094b6c7ff1df0ea68d99e6e73cbff", + "ezETH": "0x2416092f143378750bb29b79ed961ab195cceea5" }, "moonriver": { "WMOVR": "0xe3c7487eb01c74b73b7184d198c7fbf46b34e5af", @@ -272,7 +278,9 @@ "GMX": "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a", "WSTETH": "0x5979D7b546E38E414F7E9822514be443A4800529", "plvGLP": "0x5326e71ff593ecc2cf7acae5fe57582d6e74cff1", - "USDe": "0x5d3a1ff2b6bab83b63cd9ad0787074081a52ef34" + "USDe": "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34", + "FRAX": "0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F", + "sUSDe": "0x211cc4dd073734da055fbf44a2b4667d5e5fe5d2" }, "fuse": { "WFUSE": "0x0be9e53fd7edac9f859882afdda116645287c629", @@ -377,7 +385,9 @@ "DAI": "0x90ca507a5d4458a4c6c6249d186b6dcb02a5bccd", "NCT": "0x02de4766c272abc10bc88c220d214a26960a7e92", "cMCO2": "0x32a9fe697a32135bfd313a6ac28792dae4d9979d", - "USDT": "0x617f3112bf5397d0467d315cc709ef968d9ba546" + "USDT": "0x617f3112bf5397d0467d315cc709ef968d9ba546", + "STEUR": "0x004626A008B1aCdC4c74ab51644093b155e59A23", + "USDT_1": "0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e" }, "boba": { "WETH": "0xd203de32170130082896b4111edf825a4774c18e", @@ -431,6 +441,7 @@ }, "klaytn": { "WKLAY": "0x57d1a61e4fd09fbf16e35b04959e94dcf2032974", + "WKLAY_1": "0x19aac5f612f524b754ca7e7c41cbfa2e981a4432", "BORA": "0x02cbe46fb8a1f579254a9b485788f2d86cad51aa", "DAI": "0xcb2c7998696ef7a582dfd0aafadcd008d03e791a", "USDC": "0x608792deb376cce1c9fa4d0e6b7b44f507cffa6a", @@ -459,7 +470,8 @@ "aDAI": "0x2ff5371dad5c6ef76d55213b7c5a519f6654ba17", "aDAI_Wormhole_": "0xe9a88c33abf71c902f7581321d05e6516cbca761", "USDK": "0xd2137fdf10bd9e4e850c17539eb24cfe28777753", - "NPT": "0xe06597d02a2c3aa7a9708de2cfa587b128bd3815" + "NPT": "0xe06597d02a2c3aa7a9708de2cfa587b128bd3815", + "stKaia": "0x42952B873ed6f7f0A7E4992E2a9818E3A9001995" }, "nova": { "NUSD": "0x1f5396f254ee25377a5c1b9c6bff5f44e9294fff" @@ -482,6 +494,7 @@ }, "cronos": { "WCRO": "0xca2503482e5d6d762b524978f400f03e38d5f962", + "WCRO_1": "0x5c7f8a570d578ed84e63fdfa7b1ee72deae1ae23", "USDC": "0xc21223249ca28397b4b6541dffaecc539bff0c59", "WBTC": "0x062e66477faf219f25d27dced647bf57c3107d52", "SVN": "0x654bac3ec77d6db497892478f854cf6e8245dca9", @@ -508,7 +521,6 @@ "_AVAX": "0x525bd1f949ffa2a0c5820f3b6fe61bb897466ff7", "SWAPZ": "0x9b6fbf0ea23faf0d77b94d5699b44062e5e747ac", "DAI": "0xe3f5a90f9cb311505cd691a46596599aa1a0ad7d", - "SCAR": "0x8d9fb713587174ee97e91866050c383b5cee6209", "sVLX": "0xaadbaa6758fc00dec9b43a0364a372605d8f1883", "VLX": "0x2b1abeb48f875465bf0d3a262a2080ab1c7a3e39", "ETH_1": "0x380f73bad5e7396b260f737291ae5a8100baabcd", @@ -799,7 +811,9 @@ "CELER_ETH": "0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::WethCoin", "CELER_WBTC": "0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::WbtcCoin", "amAPT": "0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a::amapt_token::AmnisApt", - "aBTC": "0x4e1854f6d332c9525e258fb6e66f84b6af8aba687bbcb832a24768c4e175feec::abtc::ABTC" + "zWBTC": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::WBTC", + "zWETH": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::WETH", + "USDt": "0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b" }, "dogechain": { "WWDOGE": "0xb7ddc6414bf4f5515b52d8bdd69973ae205ff101", @@ -1030,6 +1044,15 @@ "ETH": "0x7c598c96d02398d89fbcb9d41eab3df0c16f227d", "USDT": "0x922d641a426dcffaef11680e5358f34d97d112e1" }, + "rollux": { + "WSYS": "0x4200000000000000000000000000000000000006", + "USDC": "0x368433cac2a0b8d76e64681a9835502a1f2a8a30", + "WETH": "0xaa1c53afd099e415208f47fcfa2c880f659e6904", + "USDT": "0x28c9c7fb3fe3104d2116af26cc8ef7905547349c", + "WBTC": "0x2a4dc2e946b92ab4a1f7d62844eb237788f9056c", + "ETH": "0xaa1c53afd099e415208f47fcfa2c880f659e6904", + "BTC": "0x2a4dc2e946b92ab4a1f7d62844eb237788f9056c" + }, "vision": { "USDT": "0x1db6cdc620388a0b6046b20cd59503a0839adcff", "VBTC": "0x4dE4B92C12dD4584873e72447573382C41da5597", @@ -1085,7 +1108,8 @@ "TT_USDT": "0x4f3c8e20942461e2c3bdd8311ac57b0c222f2b82", "TT_ETH": "0x6576bb918709906dcbfdceae4bb1e6df7c8a1077", "TT_USDC": "0x22e89898a04eaf43379beb70bf4e38b1faf8a31e", - "TT_BUSD": "0xbeb0131d95ac3f03fd15894d0ade5dbf7451d171" + "TT_BUSD": "0xbeb0131d95ac3f03fd15894d0ade5dbf7451d171", + "veTT": "0xc3c857a9e5be042c8acf4f2827aa053e93b5d039" }, "conflux": { "WCFX": "0x14b2d3bc65e74dae1030eafd8ac30c533c976a9b", @@ -1212,6 +1236,7 @@ "ATOM_2": "27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", "USDC": "B3504E092456BA618CC28AC671A71FB08C6CA0FD0BE7C8A5B5A3E2DD933CC9E4", "USDC_1": "E1616E7C19EA474C565737709A628D6F8A23FF9D3E9A7A6871306CF5E0A5341E", + "USDC_2": "B559A80D62249C8AA07A380E2A2BEA6E5CA9A6F079C912C3A9E9B494105E4F81", "GRAV": "C950356239AD2A205DE09FDF066B1F9FF19A7CA7145EA48A5B19B76EE47E52F7", "SCRT": "A358D7F19237777AF6D8AD0E0F53268F8B18AE8A53ED318095C14D6D7F3B2DB5", "AXL": "903A61A498756EA560B85A85132D3AEE21B5DEDD41213725D22ABF276EA6945E", @@ -1236,6 +1261,7 @@ "AXLUSDC": "BFF0D3805B50D93E2FA5C0B2DDF7E0B30A631076CD80BC12A48C0E95404B4A41", "AXLUSDC_1": "EAC38D55372F38F1AFD68DF7FE9EF762DCF69F26520643CF3F9D292A738D8034", "AXLUSDC_2": "295548A78785A1007F232DE286149A6FF512F180AF5657780FC89C009E2C348F", + "AXLUSDT": "57503D7852EF4E1899FE6D71C5E81D7C839F76580F86F21E39348FC2BC9D7CE2", "UST": "B448C0CA358B958301D328CCDC5D5AD642FC30A6D3AE106FF721DB315F3DDE5C", "UST_1": "6F4968A73F90CF7DE6394BF937D6DF7C7D162D74D839C13F53B41157D315E05F", "G-WETH": "DBF5FA602C46392DE9F4796A0FC7D02F3A8A3D32CA3FAA50B761D4AA6F619E95", @@ -1258,11 +1284,14 @@ "GRAV_boot": "C23D820C5B6009E544AFC8AF5A2FEC288108AEDBFAEFDBBDD6BE54CC23069559", "JUNO_boot": "8D9262E35CAE362FA74AE05E430550757CF8D842EC1B241F645D3CB7179AFD10", "TIA": "D79E7D83AB399BFFF93433E54FAA480C191248FC556924A2A8351AE2638B3877", + "TIA1": "773B4D0A3CD667B2275D5A4A7A2F0909C0BA0F4059C0B9181E680DDF4965DCC7", + "AXL_WETH": "A585C2D15DCD3B010849B453A2CFCB5E213208A5AB665691792684C26274304D", "EVMOS_boot": "4B322204B4F59D770680FE4D7A565DDC3F37BFF035474B717476C66A4F83DD72" }, "starknet": { "STRK": "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d", "DAI": "0x00da114221cb83fa859dbdb4c44beeaa0bb37c7537ad5ae66fe5e0efd20e6eb3", + "DAI_1": "0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad", "USDC": "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8", "USDT": "0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8", "WBTC": "0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac", @@ -1272,7 +1301,11 @@ "RETH": "0x0319111a5037cbec2b3e638cc34a3474e2d2608299f3e62866e9cc683208c610", "UNO": "0x0719b5092403233201aa822ce928bd4b551d0cdb071a724edd7dc5e5f57b7f34", "NSTSTRK": "0x04619e9ce4109590219c5263787050726be63382148538f3f936c22aa87d2fc2", - "ZEND": "0x00585c32b625999e6e5e78645ff8df7a9001cf5cf3eb6b80ccdd16cb64bd3a34" + "ZEND": "0x00585c32b625999e6e5e78645ff8df7a9001cf5cf3eb6b80ccdd16cb64bd3a34", + "NSTR": "0x00c530f2c0aa4c16a0806365b0898499fba372e5df7a7172dc6fe9ba777e8007", + "BROTHER": "0x03b405a98c9e795d427fe82cdeeeed803f221b52471e3a757574a2b4180793ee", + "XSTRK": "0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a", + "SSTRK": "0x0356f304b154d29d2a8fe22f1cb9107a9b564a733cf6b4cc47fd121ac1af90c9" }, "ton": { "TON": "0x0000000000000000000000000000000000000000", @@ -1288,7 +1321,8 @@ "MEGA": "EQBf6-YoR9xylol_NwjHrLkrTFAZJCX-bsd-Xx_902OaPaBf", "WEMIX": "EQCf7Nb341dxOE3N0jimngRxGEV8T3zo-eU2EZVs_nchNhhZ", "jUSDT": "EQBynBO23ywHy_CgarY9NK9FTz0yDsG82PtcbSTQgGoXwiuA", - "USDT": "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs" + "USDT": "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs", + "NOT": "EQAvlWFDxGF2lXm67y4yzC17wYKD9A0guwPkMs1gOsM__NOT" }, "defichain": { "DFI": "DFI", @@ -1352,7 +1386,8 @@ "WBTC": "0xBBeB516fb02a01611cBBE0453Fe3c580D7281011", "USDT": "0x493257fD37EDB34451f62EDf8D2a0C418852bA4C", "BUSD": "0x2039bb4116B4EFc145Ec4f0e2eA75012D6C0f181", - "DAI": "0x4B9eb6c0b6ea15176BBF62841C6B2A8a398cb656" + "DAI": "0x4B9eb6c0b6ea15176BBF62841C6B2A8a398cb656", + "ZK": "0x5A7d6b2F92C77FAD6CCaBd7EE0624E64907Eaf3E" }, "polygon_zkevm": { "WETH": "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9", @@ -1388,7 +1423,9 @@ "USDC_ARB": "0xe32d3ebafa42e6011b87ef1087bbc6053b499bf6f095807b9013aff5a6ecd7bb::coin::COIN", "USDC_BNB": "0x909cba62ce96d54de25bec9502de5ca7b4f28901747bbf96b76c2e63ec5f1cba::coin::COIN", "BUCK": "0xce7ff77a83ea0cb6fd39bd8748e2ec89a3f41e8efdc3f4eb123e0ca37b184db2::buck::BUCK", - "SUI": "0x2::sui::SUI" + "SUI": "0x2::sui::SUI", + "USDC_CIRCLE": "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC", + "ETH": "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH" }, "grove": { "WGRV": "0xE85f139488c689038028a3EB8fC38dcC29D4C340" @@ -1414,7 +1451,8 @@ "USDC": "0x15D38573d2feeb82e7ad5187aB8c1D52810B1f07", "USDT": "0x0Cb6F5a34ad42ec934882A05265A7d5F59b51A2f", "HEX": "0x2b591e99afe9f32eaa6214f7b7629768c40eeb39", - "DAI": "0xefd766ccb38eaf1dfd701853bfce31359239f305" + "DAI": "0xefd766ccb38eaf1dfd701853bfce31359239f305", + "sDAI": "0x30fcb23a906493371b1721c8feb8815804808d74" }, "onus": { "WONUS": "0x4c761e48d1e735af551cc38abcbdce1d7faac6e4", @@ -1464,10 +1502,14 @@ "WETH": "0x4200000000000000000000000000000000000006", "USDbC": "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA", "USDC": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", - "DAI": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb" + "DAI": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb", + "USDT": "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2", + "rETH": "0xb6fe221fe9eef5aba221c348ba20a1bf5e73624c", + "wstETH": "0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452" }, "sei": { "SEI": "usei", + "WSEI": "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7", "WETH": "factory/sei189adguawugk3e55zn63z8r9ll29xrjwca636ra7v7gxuzn98sxyqwzt47l/4tLQqCLaoKKfNFuPjA9o39YbKUwhR1F8N29Tz3hEbfP2", "USDCet": "factory/sei189adguawugk3e55zn63z8r9ll29xrjwca636ra7v7gxuzn98sxyqwzt47l/Hq4tuDzhRBnxw3tFA5n6M52NVMVcC19XggbyDiJKCD6H", "USDCso": "factory/sei189adguawugk3e55zn63z8r9ll29xrjwca636ra7v7gxuzn98sxyqwzt47l/9fELvUhFo6yWL34ZaLgPbCPzdk9MD1tAzMycgH45qShH", @@ -1480,7 +1522,9 @@ }, "op_bnb": { "WBNB": "0x4200000000000000000000000000000000000006", - "USDT": "0x9e5aac1ba1a2e6aed6b32689dfcf62a509ca96f3" + "USDT": "0x9e5aac1ba1a2e6aed6b32689dfcf62a509ca96f3", + "ETH": "0xe7798f023fc62146e8aa1b36da45fb70855a77ea", + "FDUSD": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb" }, "archway": { "ARCH": "aarch" @@ -1511,7 +1555,9 @@ "USDT": "secret18wpjn83dayu4meu6wnn29khfkwdxs7kyrz9c8f" }, "aura": { - "AURA": "uaura" + "AURA": "uaura", + "WAURA": "0xDE47A655a5d9904BD3F7e1A536D8323fBD99993A", + "USDT": "0x80b5a32e4f032b2a058b4f29ec95eefeeb87adcd" }, "shibarium": { "WETH": "0x8ed7d143ef452316ab1123d28ab302dc3b80d3ce", @@ -1567,7 +1613,10 @@ "SAT": "0x17102AC78a02a98fC78B0c29B7b0506f035A99E5", "BIFI": "0x047938C3aD13c1eB821C8e310B2B6F889b6d0003", "WBTC": "0x7b8FAC5F29E101BaaB33c5f9c39d4F85ba2cc7C1", - "BTCB": "0xd267F821F1b8344B5A63626c8c824697194A173E" + "BTCB": "0xd267F821F1b8344B5A63626c8c824697194A173E", + "BitcoinUSD": "0x6906Ccda405926FC3f04240187dd4fAd5DF6d555", + "BtcUSD": "0x6906Ccda405926FC3f04240187dd4fAd5DF6d555", + "cbBTC": "0x74B73Fd2eE237e9219dF30dfFDB206D237cbFC00" }, "scroll": { "WETH": "0x5300000000000000000000000000000000000004", @@ -1609,7 +1658,10 @@ }, "zilliqa": { "WZIL": "0x94e18ae7dd5ee57b55f30c4b63e2760c09efb192", - "USDT": "0x2274005778063684fbb1bfa96a2b725dc37d75f9" + "USDT": "0x2274005778063684fbb1bfa96a2b725dc37d75f9", + "stZIL": "0x097c26f8a93009fd9d98561384b5014d64ae17c2", + "gZIL": "0x03a79429acc808e4261a68b0117acd43cb0fdbfa", + "XCAD": "0xccf3ea256d42aeef0ee0e39bfc94baa9fa14b0ba" }, "fsc": { "WFSC": "0xb582fD9d0D5C3515EEB6b02fF2d6eE0b6E45E7A7" @@ -1635,7 +1687,8 @@ }, "airdao": { "SAMB": "0x2b2d892c3fe2b4113dd7ac0d2c1882af202fb28f", - "BUSD": "0x7a477aa8ed4884509387dba81ba6f2b7c97597e2" + "BUSD": "0x7a477aa8ed4884509387dba81ba6f2b7c97597e2", + "USDC": "0xFF9F502976E7bD2b4901aD7Dd1131Bb81E5567de" }, "acala": { "DOT": "0x0000000000000000000100000000000000000002", @@ -1661,10 +1714,12 @@ "fwUSDB": "0x866f2c06b83df2ed7ca9c2d044940e7cd55a06d6", "WETH": "0x4300000000000000000000000000000000000004", "ezETH": "0x2416092f143378750bb29b79eD961ab195CcEea5", - "weETH": "0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A" + "weETH": "0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A", + "BLAST": "0xb1a5700fA2358173Fe465e6eA4Ff52E36e88E2ad" }, "chz": { - "WCHZ": "0x721ef6871f1c4efe730dce047d40d1743b886946" + "WCHZ": "0x721ef6871f1c4efe730dce047d40d1743b886946", + "WCHZ_1": "0x677F7e16C7Dd57be1D4C8aD1244883214953DC47" }, "bitrock": { "WBR": "0x413f0e3a440aba7a15137f4278121450416882d5", @@ -1685,7 +1740,10 @@ }, "xai": { "XAI": "0x36be1fd6ff2a6beb34b500a04f89103a524516d8", - "USDC": "0x300a7b57dc85b6a9776e249614abf0fe5c9905fb" + "USDC": "0x300a7b57dc85b6a9776e249614abf0fe5c9905fb", + "WXAI": "0x3fb787101dc6be47cfe18aeee15404dcc842e6af", + "WETH": "0xbee82cfdaff4a6aa4e4793cb81eb1c2e79ac463c", + "USDC_1": "0x1e3769bd5fb2e9e9e7d4ed8667c947661f9a82e3" }, "merlin": { "SATS": "0x4dcb91cc19aadfe5a6672781eb09abad00c19e4c", @@ -1697,14 +1755,19 @@ "WBTC_1": "0xB880fd278198bd590252621d4CD071b1842E9Bcd" }, "ftn": { - "USDC": "0x4237e0A5b55233D5B6D6d1D9BF421723954130D8" + "USDC": "0x4237e0A5b55233D5B6D6d1D9BF421723954130D8", + "stFTN": "0x780fb5aca83f2e3f57ee18cc3094988ef49d8c3d", + "mUSDC": "0x4b7708ee3ccbd3f9af68208e69ad31f611e1befe", + "mUSDT": "0xb7dc5eca6de5cb9b46ac405d3d4596333714f3f7" }, "q": { "WBTC": "0xde397e6C442A3E697367DecBF0d50733dc916b79", "WDAI": "0xDeb87c37Dcf7F5197026f574cd40B3Fc8Aa126D1", "WUSDC": "0x79Cb92a2806BF4f82B614A84b6805963b8b1D8BB", "WETH": "0xd56F9ffF3fe3BD0C7B52afF9A42eb70E05A287Cc", - "ELK": "0xeEeEEb57642040bE42185f49C52F7E9B38f8eeeE" + "ELK": "0xeEeEEb57642040bE42185f49C52F7E9B38f8eeeE", + "QUSD": "0xE31DD093A2A0aDc80053bF2b929E56aBFE1B1632", + "WQ": "0xd07178e3eCbC78De110Df84fe1A979D5f349784a" }, "zklink": { "WBTC": "0xda4aaed3a53962c83b35697cd138cc6df43af71f", @@ -1742,7 +1805,8 @@ "ETH": "0xeceeefcee421d8062ef8d6b4d814efe4dc898265", "WBTC": "0x5fd55a1b9fc24967c4db09c513c3ba0dfa7ff687", "USDT": "0xd567b3d7b8fe3c79a1ad8da978812cfc4fa05e75", - "AXLUSDC": "0x80b5a32e4f032b2a058b4f29ec95eefeeb87adcd" + "AXLUSDC": "0x80b5a32e4f032b2a058b4f29ec95eefeeb87adcd", + "USDC": "0x0ce35b0d42608ca54eb7bcc8044f7087c18e7717" }, "xlayer": { "WOKB": "0xe538905cf8410324e03a5a23c1c177a474d59b2b", @@ -1783,7 +1847,11 @@ "USDC_1": "0x75E20C5d4aade76143b8b74d1C5E2865347f9d3B" }, "lac": { - "LAC": "0x2911a1ab18546cb501628be8625c7503a2a7db54" + "LAC": "0x2911a1ab18546cb501628be8625c7503a2a7db54", + "WETH": "0x42c8c9c0f0a98720dacdaeac0c319cb272b00d7e", + "WBTC": "0xf54b8cb8eeee3823a55dddf5540ceaddf9724626", + "USDT": "0x7dc8b9e3b083c26c68f0b124ca923aaec7fbee39", + "USDC": "0x51115241c7b8361eee88d8610f71d0a92cee5323" }, "bob": { "WETH": "0x4200000000000000000000000000000000000006", @@ -1793,18 +1861,31 @@ "STETH": "0x85008aE6198BC91aC0735CB5497CF125ddAAc528", "STONE": "0x96147a9ae9a42d7da551fd2322ca15b71032f342", "RETH": "0xb5686c4f60904ec2bda6277d6fe1f7caa8d1b41a", - "TBTC": "0xbba2ef945d523c4e2608c9e1214c2cc64d4fc2e2" + "TBTC": "0xbba2ef945d523c4e2608c9e1214c2cc64d4fc2e2", + "SolvBTC": "0x541fd749419ca806a8bc7da8ac23d346f2df8b77", + "SolvBTC_BBN": "0xCC0966D8418d412c599A6421b760a847eB169A8c", + "FBTC": "0xc96de26018a54d51c097160568752c4e3bd6c364", + "satUSD": "0x78Fea795cBFcC5fFD6Fb5B845a4f53d25C283bDB", + "uniBTC": "0x236f8c0a61dA474dB21B693fB2ea7AAB0c803894", + "pumpBTC": "0x1fcca65fb6ae3b2758b9b2b394cb227eae404e1e" }, "btr": { - "ETH": "0xef63d4e178b3180beec9b0e143e0f37f4c93f4c2" + "ETH": "0xef63d4e178b3180beec9b0e143e0f37f4c93f4c2", + "WBTC": "0xff204e2681a6fa0e2c3fade68a1b28fb90e4fc5f" }, "taiko": { "USDC": "0x07d83526730c7438048D55A4fc0b850e2aaB6f0b", + "USDT": "0x2def195713cf4a606b49d07e520e22c17899a736", + "USDC_e": "0x19e26b0638bf63aa9fa4d14c6baf8d52ebe86c5c", + "DAI": "0x7d02A3E0180451B17e5D7f29eF78d06F8117106C", + "TAIKO": "0xA9d23408b9bA935c230493c40C73824Df71A0975", + "LRC": "0xd347949f8c85d9f3d6b06bfc4f8c2e07c161f064", "WETH": "0xA51894664A773981C6C112C43ce576f315d5b1B6" }, "stellar": { "XLM": "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA", - "USDC": "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75" + "USDC": "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75", + "EURC": "CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV" }, "lukso": { "WLYX": "0x2db41674f2b882889e5e1bd09a3f3613952bc472" @@ -1815,5 +1896,219 @@ "USDC": "0xff00000000000000000000000000000000000003", "ETH": "0xff00000000000000000000000000000000000001", "DUSD": "0xff0000000000000000000000000000000000000f" + }, + "ailayer": { + "ABTC": "0x1470a4831F76954686BfB4dE8180F7469EA8dE6F", + "bBTC": "0xEAa3C2fa77c306592750C9220a8f52DA8A849Ede" + }, + "mint": { + "WETH": "0x4200000000000000000000000000000000000006", + "USDC": "0xb62F35B9546A908d11c5803ecBBA735AbC3E3eaE", + "USDT": "0x05D032ac25d322df992303dCa074EE7392C117b9", + "WBTC": "0x03C7054BCB39f7b2e5B2c7AcB37583e32D70Cfa3" + }, + "fraxtal": { + "WETH": "0xA8a59D73388D0c4344a7b0Ba287ddb654227c38a", + "FRAX": "0xfc00000000000000000000000000000000000001" + }, + "aeternity": { + "WAE": "ct_J3zBY8xxjsRr3QojETNw48Eb38fjvEuJKkQ6KzECvubvEcvCa", + "WETH": "ct_WVqAvLQpvZCgBg4faZLXA1YBj43Fxj91D33Z8K7pFsY8YCofv", + "WBTC": "ct_26Q5MYFKE4z4GaYLmhZiZ9AHsSVqVNZiiyzySSHTorWyr4od4K", + "USDT": "ct_2AiMceYFXnUdA6A9Lu2ZQ2tr2TpfbGVfkxLfBnceoWgHTKZYvc", + "USDC": "ct_U1i8dzJTVWdnU2cv59TZQfLFpLfjqf7MQQC5ygSMKphn8Yew2" + }, + "etlk": { + "OGV1WXTZ": "0x3571aed54ccea5b69b00516d5a149a6baea77118", + "WXTZ": "0xc9B53AB2679f573e480d01e0f49e2B5CFB7a3EAb", + "USDC": "0x796ea11fa2dd751ed01b53c372ffdb4aaa8f00f9", + "USDT": "0x2c03058c8afc06713be23e58d2febc8337dbfe6a", + "WETH": "0xfc24f770f94edbca6d6f885e12d4317320bcb401" + }, + "rari": { + "WETH": "0xf037540e51d71b2d2b1120e8432ba49f29edfbd0", + "USDC_e": "0xfbda5f676cb37624f28265a144a48b0d6e87d3b6" + }, + "real": { + "RWA": "0x4644066f535ead0cde82d209df78d94572fcbf14", + "USDC": "0xc518A88c67CECA8B3f24c4562CB71deeB2AF86B7" + }, + "saakuru": { + "WOAS": "0x557a526472372f1F222EcC6af8818C1e6e78A85f", + "USDC_e": "0x739222D8A9179fE05129C77a8fa354049c088CaA" + }, + "bouncebit": { + "wstBBTC": "0x8f083eafcbba2e126ad9757639c3a1e25a061a08", + "BBUSD": "0x77776b40C3d75cb07ce54dEA4b2Fd1D07F865222" + }, + "reya": { + "WETH": "0x6b48c2e6a32077ec17e8ba0d98ffc676dfab1a30", + "USDC": "0x3B860c0b53f2e8bd5264AA7c3451d41263C933F2", + "RUSD": "0xa9f32a851b1800742e47725da54a09a7ef2556a3" + }, + "neutron": { + "NTRN": "untrn" + }, + "noble": { + "USDC": "uusdc", + "USDY": "ausdy", + "ausdy": "ausdy" + }, + "ripple": { + "XRP": "XRP" + }, + "polynomial": { + "USDC": "0x17C9D8Cef7Ef072844EEaEdE1F9f54C7E3fa8743", + "fxUSDC": "0x2369eb4a76d80fbeaa7aa73e1e1f9eaee88c07f4", + "SDAI": "0x615172e47c0C5A6dA8ea959632Ac0166f7a59eDc", + "sUSDe": "0x2A06DEAc3E863c23DD6a89Eeacd80aBA9E08B77B", + "USD0": "0x6224dC817dC4D5c53fcF3eb08A4f84C456F9f38f" + }, + "cronos_zkevm": { + "wzkCRO": "0xc1bf55ee54e16229d9b369a5502bfe5fc9f20b6d", + "ETH": "0x898b3560affd6d955b1574d87ee09e46669c60ea", + "USDC": "0xaa5b845f8c9c047779bedf64829601d8b264076c" + }, + "neox": { + "WGAS": "0x008cd7f573998cb841a5d82a857ed1f0ce03a653", + "WGAS_1": "0xde41591ed1f8ed1484ac2cd8ca0876428de60eff" + }, + "gravity": { + "wG": "0xbb859e225ac8fb6be1c7e38d87b767e95fef0ebd", + "WETH": "0xf6f832466Cd6C21967E0D954109403f36Bc8ceaA", + "USDC_e": "0xfbda5f676cb37624f28265a144a48b0d6e87d3b6" + }, + "idex": { + "0xfbda5f676cb37624f28265a144a48b0d6e87d3b6": "0xfbda5f676cb37624f28265a144a48b0d6e87d3b6" + }, + "etn": { + "WETN": "0x138dafbda0ccb3d8e39c19edb0510fc31b7c1c77" + }, + "bitkub": { + "KKUB": "0x67ebd850304c70d983b2d1b93ea79c7cd6c3f6b5" + }, + "shape": { + "WETH": "0x4200000000000000000000000000000000000006", + "WETH_1": "0x48A9B22b80F566E88f0f1DcC90Ea15A8A3bAE8a4" + }, + "hela": { + "hUSDC": "0xf5b85320a772b436cb8105441a3db9ba29437b4a", + "hUSDT": "0xd3442073fa7ccf8a7c39d95dc125cd59497aa078", + "WHLUSD": "0x3a035615e101373fa9ba21c5bea7fe4026fc40b4" + }, + "lisk": { + "USDT": "0x05d032ac25d322df992303dca074ee7392c117b9", + "WETH": "0x4200000000000000000000000000000000000006", + "LSK": "0xac485391eb2d7d88253a7f1ef18c37f4242d1a24" + }, + "flow": { + "WFLOW": "0xd3bF53DAC106A0290B0483EcBC89d40FcC961f3e", + "ankrFLOWEVM": "0x1b97100eA1D7126C4d60027e231EA4CB25314bdb", + "USDC_e": "0x7f27352d5f83db87a5a3e00f4b07cc2138d8ee52" + }, + "matchain": { + "WBNB": "0x4200000000000000000000000000000000000006" + }, + "fuel": { + "USDC": "0x286c479da40dc953bddc3bb4c453b608bba2e0ac483b077bd475174115395e6b", + "ETH": "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07", + "USDT": "0xa0265fb5c32f6e8db3197af3c7eb05c48ae373605b8165b6f4a51c5b0ba4812e", + "sDAI": "0x9e46f919fbf978f3cad7cd34cca982d5613af63ff8aab6c379e4faa179552958", + "mBTC": "0xaf3111a248ff7a3238cdeea845bb2d43cf3835f1f6b8c9d28360728b55b9ce5b", + "METH": "0xafd219f513317b1750783c6581f55530d6cf189a5863fd18bd1b3ffcec1714b4", + "RZETH": "0x91b3559edb2619cde8ffb2aa7b3c3be97efd794ea46700db7092abeee62281b0" + }, + "wc": { + "USDC_e": "0x79A02482A880bCE3F13e09Da970dC34db4CD24d1", + "WLD": "0x2cFc85d8E48F8EAB294be644d9E25C3030863003", + "WBTC": "0x03c7054bcb39f7b2e5b2c7acb37583e32d70cfa3", + "WETH": "0x4200000000000000000000000000000000000006" + }, + "apechain": { + "WAPE": "0x48b62137EdfA95a428D35C09E44256a739F6B557", + "sDAI": "0xA2235d059F80e176D931Ef76b6C51953Eb3fBEf4", + "ApeETH": "0xcF800F4948D16F23333508191B1B1591daF70438" + }, + "zircuit": { + "WETH": "0x4200000000000000000000000000000000000006" + }, + "hedera": { + "XSAUCE": "0x00000000000000000000000000000000001647e8", + "USDC": "0x000000000000000000000000000000000006f89a", + "KARATE": "0x000000000000000000000000000000000022d6de", + "HBARX": "0x00000000000000000000000000000000000cba44", + "SAUCE": "0x00000000000000000000000000000000000b2ad5", + "WHBAR": "0x0000000000000000000000000000000000163b5a", + "DOVU": "0x000000000000000000000000000000000038b3db", + "HLQT": "0x00000000000000000000000000000000005c9f70", + "HST": "0x00000000000000000000000000000000000ec585", + "PACK": "0x0000000000000000000000000000000000492a28", + "STEAM": "0x000000000000000000000000000000000030fb8b" + }, + "morph": { + "WETH": "0x5300000000000000000000000000000000000011", + "USDT": "0xc7d67a9cbb121b3b0b9c053dd9f469523243379a", + "WBTC": "0x803dce4d3f4ae2e17af6c51343040dee320c149d" + }, + "eclipse": { + "ETH": "So11111111111111111111111111111111111111112", + "ETH_1": "9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP", + "SOL": "BeRUj3h7BqkbdfFU7FBNYbodgf8GCHodzKvF9aVjNNfL", + "USDC": "AKEWE7Bgh87GPp171b4cJPSSZfmZwQ3KaqYqXoKLNAEE", + "WIF": "841P4tebEgNux2jaWSjCoi9LhrVr9eHGjLc758Va3RPH" + }, + "unit0": { + "UNIT": "0xcf43f7703d9b4e8835f977ef364b4014fa7e856e" + }, + "rbn": { + "WRBNT": "0x6ed1f491e2d31536d6561f6bdb2adc8f092a6076" + }, + "shido": { + "WSHIDO": "0x8cbaffd9b658997e7bf87e98febf6ea6917166f7", + "USDC": "0x80b5a32e4f032b2a058b4f29ec95eefeeb87adcd" + }, + "ace": { + "USDC_e": "0x71ee6485cf72b9c3bf183528a2241474f21b2efa" + }, + "tara": { + "WTARA": "0x5d0fa4c5668e5809c83c95a7cef3a9dd7c68d4fe", + "USDM": "0xc26b690773828999c2612549cc815d1f252ea15e" + }, + "corn": { + "BTCN": "0xda5ddd7270381a7c2717ad10d1c0ecb19e3cdfb2" + }, + "sonic": { + "wS": "0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38", + "WS_1": "0x832497895f05100e53f42dfa8fc758b4866b183a", + "USDC.e": "0x29219dd400f2Bf60E5a23d13Be72B486D4038894", + "WETH": "0x309C92261178fA0CF748A855e90Ae73FDb79EBc7" + }, + "vinu": { + "USDT": "0xC0264277fcCa5FCfabd41a8bC01c1FcAF8383E41", + "ETH": "0xDd4b9b3Ce03faAbA4a3839c8B5023b7792be6e2C", + "VINU": "0x00c1E515EA9579856304198EFb15f525A0bb50f6", + "WVC": "0xEd8c5530a0A086a12f57275728128a60DFf04230" + }, + "sophon": { + "ETH": "0x72af9f169b619d85a47dfa8fefbcd39de55c567d", + "USDT": "0x6386da73545ae4e2b2e0393688fa8b65bb9a7169", + "USDC": "0x9aa0f72392b5784ad86c6f3e899bcc053d00db4f", + "WSTETH": "0x60d02f185f80644e1a5ae35497736dd31d1b078b", + "WEETH": "0x5e9fc50b44988b66ba84500f8bc32c0493fe8f8d", + "DAI": "0x88171a5bbacd92ca5e25575c5904581c80b025dd", + "SDAI": "0xeccbb9360d235548473cb8c752735f68e652439b" + }, + "ink": { + "WETH": "0x4200000000000000000000000000000000000006" + }, + "duckchain": { + "WTON": "0x7F9308E8d724e724EC31395f3af52e0593BB2e3f" + }, + "qom": { + "WQOM": "0xa26dfBF98Dd1A32FAe56A3D2B2D60A8a41b0bDF0" + }, + "vana": { + "WVANA": "0x00eddd9621fb08436d0331c149d1690909a5906d", + "USDC.e": "0xf1815bd50389c46847f0bda824ec8da914045d14" } -} +} \ No newline at end of file From 5a1fd7e1144d370b744986521a84ed825ab4a002 Mon Sep 17 00:00:00 2001 From: prim8bits Date: Thu, 19 Dec 2024 15:57:18 +0100 Subject: [PATCH 65/86] kongswap volume (#2239) * kongswap volume * Update index.ts --------- Co-authored-by: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> --- dexs/kongswap/index.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 dexs/kongswap/index.ts diff --git a/dexs/kongswap/index.ts b/dexs/kongswap/index.ts new file mode 100644 index 0000000000..3c95f8bce4 --- /dev/null +++ b/dexs/kongswap/index.ts @@ -0,0 +1,23 @@ +import { Adapter, FetchResultVolume } from "../../adapters/types" +import { CHAIN } from "../../helpers/chains"; +import fetchURL from "../../utils/fetchURL"; + +const fetch = async (timestamp: number): Promise => { + const response = await fetchURL('https://api.kongswap.io/api/defillama/total_volume'); + return { + dailyVolume: response['24h_volume'], + timestamp + } +}; + +const adapter: Adapter = { + adapter: { + [CHAIN.ICP]: { + fetch: fetch, + runAtCurrTime: true, + start: '2024-11-01', + }, + } +} + +export default adapter; From 694395fa2f4415b7a505076fcf7e289c062618c5 Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Thu, 19 Dec 2024 15:09:12 +0000 Subject: [PATCH 66/86] add datadex --- dexs/datadex/index.ts | 29 +++++++++++++++++++++++++++++ helpers/chains.ts | 1 + 2 files changed, 30 insertions(+) create mode 100644 dexs/datadex/index.ts diff --git a/dexs/datadex/index.ts b/dexs/datadex/index.ts new file mode 100644 index 0000000000..899f291478 --- /dev/null +++ b/dexs/datadex/index.ts @@ -0,0 +1,29 @@ +// vana + +import { SimpleAdapter } from "../../adapters/types"; +import { DEFAULT_TOTAL_VOLUME_FIELD, getChainVolume2 } from "../../helpers/getUniSubgraphVolume"; +import { CHAIN } from "../../helpers/chains"; + +const endpoints = { + [CHAIN.VANA]: "https://api.goldsky.com/api/public/project_clnbo3e3c16lj33xva5r2aqk7/subgraphs/data-dex-vana/prod/gn", +}; + +const graphs = getChainVolume2({ + graphUrls: endpoints, + totalVolume: { + factory: "factories", + field: DEFAULT_TOTAL_VOLUME_FIELD, + }, +}); + +const adapter: SimpleAdapter = { + version: 2, + adapter: { + [CHAIN.VANA]: { + fetch: graphs(CHAIN.VANA), + start: '2024-12-03', + }, + }, +}; + +export default adapter; diff --git a/helpers/chains.ts b/helpers/chains.ts index 5b108fbe96..d76be23ff2 100644 --- a/helpers/chains.ts +++ b/helpers/chains.ts @@ -198,6 +198,7 @@ export enum CHAIN { NEUTRON = "neutron", CORN = "corn", SAPPHIRE = "sapphire", + VANA = "vana", } // Don´t use From bbc136ad0b4fe49a6ffa83ce0b92a4ef7c8d4cc0 Mon Sep 17 00:00:00 2001 From: Bogdan Crisan Date: Thu, 19 Dec 2024 16:27:25 +0100 Subject: [PATCH 67/86] [emojicoin] Add fees, volume and revenue (#2198) * [emojicoin] Add fees * Rework the emojicoin adapter and Aptos helper * Optimize by providing left bound to binary search * Add total revenue * Remove revenue --------- Co-authored-by: Greg Nazario --- fees/emojicoin.ts | 86 ++++++++++++++++++++++++++++++++++++ helpers/aptops.ts | 108 ++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 180 insertions(+), 14 deletions(-) create mode 100644 fees/emojicoin.ts diff --git a/fees/emojicoin.ts b/fees/emojicoin.ts new file mode 100644 index 0000000000..1ee5b9b942 --- /dev/null +++ b/fees/emojicoin.ts @@ -0,0 +1,86 @@ +import {FetchOptions} from "../adapters/types"; +import {CHAIN} from "../helpers/chains"; +import {getVersionFromTimestamp, octasToApt, view} from "../helpers/aptops"; + +// The emojicoin package address. +const MAINNET_PACKAGE_ADDRESS = "0xface729284ae5729100b3a9ad7f7cc025ea09739cd6e7252aff0beb53619cafe"; + +// The emojicoin module. +const MODULE = "emojicoin_dot_fun"; + +// Date at which the contract was deployed. +const DEPLOYED_AT_DATE = '2024-11-20'; + +// Block close to the start date but before it. +const DEPLOYED_AT_BLOCK = 254000000; + +// Return type of the `registry_view` view function. +type RegistryView = { + cumulative_chat_messages: { value: string }, + cumulative_integrator_fees: { value: string }, + cumulative_quote_volume: { value: string }, + cumulative_swaps: { value: string }, + fully_diluted_value: { value: string }, + last_bump_time: string, + market_cap: { value: string }, + n_markets: string, + nonce: { value: string }, + registry_address: string, + total_quote_locked: { value: string }, + total_value_locked: { value: string } +}; + +// Query the `registry_view` view function at the given version. +async function registryView(version?: number) { + const viewFunction = `${MAINNET_PACKAGE_ADDRESS}::${MODULE}::registry_view`; + const [result] = + await view<[RegistryView]>(viewFunction, [], [], version); + return result +} + +const fetch = async (options: FetchOptions) => { + // Convert timestamps to versions. + const startVersion = await getVersionFromTimestamp(new Date(options.startTimestamp * 1000), DEPLOYED_AT_BLOCK); + const endVersion = await getVersionFromTimestamp(new Date(options.endTimestamp * 1000), DEPLOYED_AT_BLOCK); + + // Get the view results at the start and end bounds. + const viewStart = await registryView(startVersion); + const viewEnd = await registryView(endVersion); + + // Extract fees and volume from `registry_view` results. + const feesEnd = BigInt(viewEnd.cumulative_integrator_fees.value); + const feesStart = BigInt(viewStart.cumulative_integrator_fees.value); + const volumeEnd = BigInt(viewEnd.cumulative_quote_volume.value); + const volumeStart = BigInt(viewStart.cumulative_quote_volume.value); + + // Calculate daily and total values + + const dailyFees = options.createBalances(); + dailyFees.addCGToken('aptos', octasToApt(feesEnd - feesStart)); + + const totalFees = options.createBalances(); + totalFees.addCGToken('aptos', octasToApt(feesEnd)); + + const dailyVolume = options.createBalances(); + dailyVolume.addCGToken('aptos', octasToApt(volumeEnd - volumeStart)); + + const totalVolume = options.createBalances(); + totalVolume.addCGToken('aptos', octasToApt(volumeEnd)); + + return { + dailyFees, + totalFees, + dailyVolume, + totalVolume, + }; +}; + +export default { + version: 2, + adapter: { + [CHAIN.APTOS]: { + fetch, + start: DEPLOYED_AT_DATE, + }, + } +}; diff --git a/helpers/aptops.ts b/helpers/aptops.ts index 657ea9a5b3..d8b7849074 100644 --- a/helpers/aptops.ts +++ b/helpers/aptops.ts @@ -1,22 +1,102 @@ -import { httpGet } from "../utils/fetchURL"; +import { httpGet, httpPost } from "../utils/fetchURL"; +import { GraphQLClient } from "graphql-request"; export const APTOS_PRC = 'https://aptos-mainnet.pontem.network'; +// Number of decimals for the APT token. +const APT_DECIMALS = 8; + +// Number to multiply and APT vaule to get the amount in Octas. +const APT_TO_OCTAS_MUTLIPLIER = Math.pow(10, APT_DECIMALS); + +// Takes an amount in Octas as input and returns the same amount in APT. +const octasToApt = (octas: number | bigint) => { + if (typeof octas === "number") { + return octas / APT_TO_OCTAS_MUTLIPLIER; + } else { + return Number(octas) / APT_TO_OCTAS_MUTLIPLIER; + } +} + +const graphQLClient = new GraphQLClient("https://api.mainnet.aptoslabs.com/v1/graphql"); + +// Query to get the latest block. +const latestBlockQuery = `query LatestBlock { + block_metadata_transactions(order_by: {version: desc}, limit: 1) { + block_height + } +}`; + +// Query to get a block. +const blockQuery = `query Block($block: bigint) { + block_metadata_transactions(limit: 1, where: {block_height: {_eq: $block}}) { + timestamp + version + } +}`; + +// Query to get a block range. +const blockRangeQuery = `query Block($firstBlock: bigint, $limit: Int) { + block_metadata_transactions(limit: $limit, where: {block_height: {_gte: $firstBlock}}, order_by: {block_height: asc}) { + timestamp + version + } +}`; + +// Given a timestamp, returns the transaction version that is closest to that timestamp. +const getVersionFromTimestamp = async (timestamp: Date, minBlock = 0) => { + let left = minBlock; + let right = await graphQLClient.request(latestBlockQuery).then(r => Number(r.block_metadata_transactions[0].block_height)); + let middle; + while (left + 100 < right) { + middle = Math.round((left + right) / 2); + const middleBlock = await graphQLClient.request(blockQuery, { block: middle }).then(r => r.block_metadata_transactions[0]); + const middleBlockDate = new Date(middleBlock.timestamp); + if (middleBlockDate.getTime() === timestamp.getTime()) { + return Number(middleBlock.version); + } + if (timestamp.getTime() < middleBlockDate.getTime()) { + right = middle; + } else { + left = middle + 1; + } + } + const blocks: { timestamp: string, version: string }[] = await graphQLClient.request( + blockRangeQuery, + { firstBlock: left, limit: right - left } + ).then(r => r.block_metadata_transactions); + const mappedBlocks = blocks.map((e) => ({ + version: Number(e.version), + delta: Math.abs(timestamp.getTime() - new Date(e.timestamp).getTime()) + })); + mappedBlocks.sort((a, b) => a.delta - b.delta); + return mappedBlocks[0].version; +} + const getResources = async (account: string): Promise => { - const data: any = [] - let lastData: any; - let cursor - do { - let url = `${APTOS_PRC}/v1/accounts/${account}/resources?limit=9999` - if (cursor) url += '&start=' + cursor - const res = await httpGet(url, undefined, { withMetadata: true }) - lastData = res.data - data.push(...lastData) - cursor = res.headers['x-aptos-cursor'] - } while (lastData.length === 9999) - return data + const data: any = [] + let lastData: any; + let cursor + do { + let url = `${APTOS_PRC}/v1/accounts/${account}/resources?limit=9999` + if (cursor) url += '&start=' + cursor + const res = await httpGet(url, undefined, { withMetadata: true }) + lastData = res.data + data.push(...lastData) + cursor = res.headers['x-aptos-cursor'] + } while (lastData.length === 9999) + return data +} + +async function view(functionStr: string, type_arguments: string[] = [], args: (string | boolean | number)[] = [], ledgerVersion?: bigint | number): Promise { + let path = `https://fullnode.mainnet.aptoslabs.com/v1/view` + if (ledgerVersion !== undefined) path += `?ledger_version=${ledgerVersion.toString()}` + return (await httpPost(path, { "function": functionStr, "type_arguments": type_arguments, arguments: args })) as T } export { - getResources + getResources, + getVersionFromTimestamp, + octasToApt, + view } From ad7bc999c660292e6fa4d7f85f57c6be039dee14 Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:29:08 +0100 Subject: [PATCH 68/86] track emojicoin volume --- dexs/emojicoin.ts | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 dexs/emojicoin.ts diff --git a/dexs/emojicoin.ts b/dexs/emojicoin.ts new file mode 100644 index 0000000000..49fe744c1e --- /dev/null +++ b/dexs/emojicoin.ts @@ -0,0 +1,3 @@ +import adapter from "../fees/emojicoin"; + +export default adapter; From 2690704dd07b67ef449e894c8adfbaa40ff923b7 Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:04:30 +0100 Subject: [PATCH 69/86] fix canto --- helpers/coreAssets.json | 1 - 1 file changed, 1 deletion(-) diff --git a/helpers/coreAssets.json b/helpers/coreAssets.json index ab8ef93df0..f5ec9fa139 100644 --- a/helpers/coreAssets.json +++ b/helpers/coreAssets.json @@ -834,7 +834,6 @@ "WCANTO": "0x826551890dc65655a0aceca109ab11abdbd7a07b", "USDC": "0x80b5a32e4f032b2a058b4f29ec95eefeeb87adcd", "USDT": "0xd567b3d7b8fe3c79a1ad8da978812cfc4fa05e75", - "NOTE": "0x4e71a2e537b7f9d9413d3991d37958c0b5e1e503", "ETH": "0x5fd55a1b9fc24967c4db09c513c3ba0dfa7ff687", "ATOM": "0xeceeefcee421d8062ef8d6b4d814efe4dc898265", "cINU": "0x7264610a66eca758a8ce95cf11ff5741e1fd0455" From f9bcd03b37f8e16778bf89167e568ad73819fb05 Mon Sep 17 00:00:00 2001 From: MD Date: Fri, 20 Dec 2024 07:37:42 +0700 Subject: [PATCH 70/86] submit additional adapters for review --- aggregators/swing/index.ts | 12 ++++++------ bridge-aggregators/swing/index.ts | 9 +++++---- fees/swing/index.ts | 3 ++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/aggregators/swing/index.ts b/aggregators/swing/index.ts index 04ae9ef2a6..99e8aa5cfb 100644 --- a/aggregators/swing/index.ts +++ b/aggregators/swing/index.ts @@ -3,6 +3,7 @@ import { CHAIN } from "../../helpers/chains"; import { FetchOptions, SimpleAdapter } from "../../adapters/types"; import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; +const baseURL = 'https://swap.prod.swing.xyz' const chains: Record = { [CHAIN.SOLANA]: 'solana', [CHAIN.ETHEREUM]: 'ethereum', @@ -40,7 +41,6 @@ const chains: Record = { }; const fetch = async (_a: any, _b: any, options: FetchOptions) => { - // get the start of the day timestamp const unixTimestamp = getUniqStartOfTodayTimestamp( new Date(options.startOfDay * 1000) ); @@ -50,23 +50,23 @@ const fetch = async (_a: any, _b: any, options: FetchOptions) => { new Date(options.startOfDay * 1000 + 24 * 60 * 60 * 1000) ); - const dailyRes = await httpGet("https://swap.prod.swing.xyz/v0/metrics/stats", { + const dailyRes = await httpGet(`${baseURL}/v0/metrics/stats`, { headers: { 'Content-Type': 'application/json', }, params: { startDate: unixTimestamp, endDate: unixEndDayTimestamp }, }); - const chainVolumes = dailyRes?.historicalVolumeByChain?.map((history: any) => { - const chainVol = history?.volume.find((vol: any) => { - return vol?.chainSlug.toLowerCase() === chains[options.chain].toLowerCase(); + const sameChainVolumes = dailyRes?.historicalVolumeSamechain?.map((history: any) => { + const chainVol = history?.volume?.find((vol: any) => { + return vol?.chainSlug?.toLowerCase() === chains[options.chain].toLowerCase(); }) return chainVol; }); // calculate the total volume - const chainVol = chainVolumes?.reduce((acc: number, curr: any) => { + const chainVol = sameChainVolumes?.reduce((acc: number, curr: any) => { return acc + Number(curr?.value || 0); }, 0); diff --git a/bridge-aggregators/swing/index.ts b/bridge-aggregators/swing/index.ts index bcac460980..3fe508ff28 100644 --- a/bridge-aggregators/swing/index.ts +++ b/bridge-aggregators/swing/index.ts @@ -3,6 +3,7 @@ import { httpGet } from "../../utils/fetchURL"; import { FetchOptions, SimpleAdapter } from "../../adapters/types"; import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphFees"; +const baseURL = 'https://swap.prod.swing.xyz' const chains: Record = { [CHAIN.SOLANA]: 'solana', [CHAIN.ETHEREUM]: 'ethereum', @@ -49,16 +50,16 @@ const fetchVolume = async (_t: any, _b: any, options: FetchOptions) => { new Date(options.startOfDay * 1000 + 24 * 60 * 60 * 1000) ); - const dailyRes = await httpGet("https://swap.prod.swing.xyz/v0/metrics/stats", { + const dailyRes = await httpGet(`${baseURL}/v0/metrics/stats`, { headers: { 'Content-Type': 'application/json', }, params: { startDate: unixTimestamp, endDate: unixEndDayTimestamp }, }); - const chainVolumes = dailyRes?.historicalVolumeByChain?.map((history: any) => { - const chainVol = history?.volume.find((vol: any) => { - return vol?.chainSlug.toLowerCase() === chains[options.chain].toLowerCase(); + const chainVolumes = dailyRes?.historicalVolumeCrossChainChain?.map((history: any) => { + const chainVol = history?.volume?.find((vol: any) => { + return vol?.chainSlug?.toLowerCase() === chains[options.chain].toLowerCase(); }) return chainVol; diff --git a/fees/swing/index.ts b/fees/swing/index.ts index 89aff00e64..1302aa1795 100644 --- a/fees/swing/index.ts +++ b/fees/swing/index.ts @@ -3,6 +3,7 @@ import { httpGet } from "../../utils/fetchURL"; import { FetchOptions, SimpleAdapter } from "../../adapters/types"; import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphFees"; +const baseURL = 'https://swap.prod.swing.xyz' const chains: Record = { [CHAIN.SOLANA]: 'solana', [CHAIN.ETHEREUM]: 'ethereum', @@ -50,7 +51,7 @@ const fetchVolume = async (_t: any, _b: any, options: FetchOptions) => { ); - const dailyRes = await httpGet("https://swap.prod.swing.xyz/v0/metrics/stats", { + const dailyRes = await httpGet(`${baseURL}/v0/metrics/stats`, { headers: { 'Content-Type': 'application/json', }, From de132e9baccf4aee919bc3b9db7c0c28675f6966 Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Fri, 20 Dec 2024 05:23:56 +0000 Subject: [PATCH 71/86] enable goblin-dex --- dexs/goblin-dex/index.ts | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 dexs/goblin-dex/index.ts diff --git a/dexs/goblin-dex/index.ts b/dexs/goblin-dex/index.ts new file mode 100644 index 0000000000..97e9f275bf --- /dev/null +++ b/dexs/goblin-dex/index.ts @@ -0,0 +1,43 @@ +// goblin-dex +// smartbch: "https://graph.dfd.cash/subgraphs/name/goblins/subgraph-v3", +// bsc: "https://graph-bsc.goblins.cash/subgraphs/name/goblins/bsc-subgraph-v3", +// base: "https://graph-base.goblins.cash/subgraphs/name/goblins/base-subgraph-v3", +import { SimpleAdapter } from "../../adapters/types"; +import { CHAIN } from "../../helpers/chains"; +import { DEFAULT_TOTAL_VOLUME_FIELD } from "../../helpers/getUniSubgraphFees"; +import { getChainVolume2 } from "../../helpers/getUniSubgraphVolume"; + +const endpoints: any = { + [CHAIN.SMARTBCH]: "https://graph.dfd.cash/subgraphs/name/goblins/subgraph-v3", + [CHAIN.BSC]: "https://graph-bsc.goblins.cash/subgraphs/name/goblins/bsc-subgraph-v3", + [CHAIN.BASE]: "https://graph-base.goblins.cash/subgraphs/name/goblins/base-subgraph-v3", +} + + +const graphs = getChainVolume2({ + graphUrls: endpoints, + totalVolume: { + factory: "factories", + field: DEFAULT_TOTAL_VOLUME_FIELD, + }, +}); + +const adapter: SimpleAdapter = { + version: 2, + adapter: { + [CHAIN.SMARTBCH]: { + fetch: graphs(CHAIN.SMARTBCH), + start: '2024-12-03', + }, + [CHAIN.BSC]: { + fetch: graphs(CHAIN.BSC), + start: '2024-12-03', + }, + [CHAIN.BASE]: { + fetch: graphs(CHAIN.BASE), + start: '2024-12-03', + }, + }, +}; + +export default adapter; From 854310b041070e94f73cb8c18437ae272d92c263 Mon Sep 17 00:00:00 2001 From: Define101 <93603962+Define101@users.noreply.github.com> Date: Fri, 20 Dec 2024 14:19:54 +0000 Subject: [PATCH 72/86] Revert "logx options volume adapter" --- options/logx/index.ts | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 options/logx/index.ts diff --git a/options/logx/index.ts b/options/logx/index.ts deleted file mode 100644 index 65201f34c1..0000000000 --- a/options/logx/index.ts +++ /dev/null @@ -1,36 +0,0 @@ -import fetchURL from "../../utils/fetchURL"; -import { FetchResult, SimpleAdapter } from "../../adapters/types"; -import { CHAIN } from "../../helpers/chains"; - - -const URLEndpoint = "https://mainnetapiserver.logx.network/api/v1/stats/defillama/options?endTime="; -const startTimestamp = 1733961600; // 12.12.2024 - -interface IAPIResponse { - last24HourVolume: string; - totalVolume: string; -} -const fetch = async (timestamp: number): Promise => { - const { last24HourVolume, totalVolume }: IAPIResponse = ( - await fetchURL(`${URLEndpoint}${timestamp}`) - ); - - return { - totalPremiumVolume: totalVolume, - dailyPremiumVolume: last24HourVolume, - timestamp: timestamp, - dailyNotionalVolume: last24HourVolume, - totalNotionalVolume: totalVolume, - }; -}; - -const adapter: SimpleAdapter = { - adapter: { - [CHAIN.LOGX]: { - fetch, - start: startTimestamp, - }, - } -}; - -export default adapter; From f771ec024a5c1ce96a1c79556bb56ab1a6e78b9f Mon Sep 17 00:00:00 2001 From: ngfam Date: Sat, 21 Dec 2024 21:54:11 +0700 Subject: [PATCH 73/86] [PENDLE] Fix getWhitelistedAssets caching --- fees/pendle.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/fees/pendle.ts b/fees/pendle.ts index 2067405de5..959c6803ff 100644 --- a/fees/pendle.ts +++ b/fees/pendle.ts @@ -238,10 +238,23 @@ async function getWhitelistedAssets(api: ChainApi): Promise<{ sys: string[]; marketToSy: Map; }> { - const { results } = await getConfig( - "pendle/v2/revenue-" + api.chain, - `https://api-v2.pendle.finance/core/v1/${api.chainId!}/markets?order_by=name%3A1&skip=0&limit=100&select=all` - ); + // Should only cache api by week + const weekId = Math.floor(Date.now() / 1000 / 60 / 60 / 24 / 7); + + let results: any[] = []; + let skip = 0; + let hasMore = true; + + while (hasMore) { + const { results: newResults } = await getConfig( + `pendle/v2/revenue-${api.chainId!}-${skip}-${weekId}`, + `https://api-v2.pendle.finance/core/v1/${api.chainId!}/markets?order_by=name%3A1&skip=${skip}&limit=100&select=all` + ); + results = results.concat(newResults); + skip += 100; + hasMore = newResults.length === 100; + } + const markets = results.map((d: any) => d.lp.address); const sySet: Set = new Set(results.map((d: any) => d.sy.address)); const sys = Array.from(sySet); From 4a387f8b834bdd1b69333b1db5587a825a20d36a Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Sun, 22 Dec 2024 13:34:51 +0000 Subject: [PATCH 74/86] add sonic v3 --- dexs/sushiswap/v3.ts | 2 ++ helpers/chains.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/dexs/sushiswap/v3.ts b/dexs/sushiswap/v3.ts index b9376735f5..080c95bb5f 100644 --- a/dexs/sushiswap/v3.ts +++ b/dexs/sushiswap/v3.ts @@ -32,6 +32,7 @@ const endpointsV3 = { [CHAIN.LINEA]: sdk.graph.modifyEndpoint('E2vqqvSzDdUiPP1r7PFnPKZQ34pAhNZjc6rEcdj3uE5t'), [CHAIN.SCROLL]: sdk.graph.modifyEndpoint('5gyhoHx768oHn3GxsHsEc7oKFMPFg9AH8ud1dY8EirRc'), // [CHAIN.SKALE_EUROPA]: "https://elated-tan-skat-graph.skalenodes.com:8000/subgraphs/name/sushi/v3-skale-europa", + [CHAIN.SONIC]: sdk.graph.modifyEndpoint('5ijXw9MafwFkXgoHmUiWsWHvRyYAL3RD4smnmBLmNPnw'), } const v3Graphs = getGraphDimensions2({ @@ -78,6 +79,7 @@ const startTimeV3: {[key: string]: number} = { [CHAIN.LINEA]: 1711982400, [CHAIN.SCROLL]: 1711982400, [CHAIN.SKALE_EUROPA]: 1711982400, + [CHAIN.SONIC]: 1711982400, } const v3 = Object.keys(endpointsV3).reduce( diff --git a/helpers/chains.ts b/helpers/chains.ts index b10304e5fa..03a7e80358 100644 --- a/helpers/chains.ts +++ b/helpers/chains.ts @@ -200,6 +200,7 @@ export enum CHAIN { CORN = "corn", SAPPHIRE = "sapphire", VANA = "vana", + SONIC = "sonic", } // Don´t use From 21c6de475baf6356ec843be3b07de31a5039f99a Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Sun, 22 Dec 2024 14:07:29 +0000 Subject: [PATCH 75/86] disable fantom --- fees/aave/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fees/aave/index.ts b/fees/aave/index.ts index bbb044fd9c..e2d2262f30 100644 --- a/fees/aave/index.ts +++ b/fees/aave/index.ts @@ -483,10 +483,10 @@ const adapter = { fetch: v3Graphs(v3Endpoints)(OPTIMISM), start: '2022-03-14' }, - [FANTOM]: { - fetch: v3Graphs(v3Endpoints)(FANTOM), - start: '2022-03-14' - }, + // [FANTOM]: { // index error + // fetch: v3Graphs(v3Endpoints)(FANTOM), + // start: '2022-03-14' + // }, [HARMONY]: { fetch: v3Graphs(v3Endpoints)(HARMONY), start: '2022-03-14' From 6699df7fea0237db4a542df3163be09918ca088e Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Sun, 22 Dec 2024 17:59:14 +0000 Subject: [PATCH 76/86] fix flipside query --- helpers/flipsidecrypto.ts | 315 +++++++++++++++++++++----------------- 1 file changed, 177 insertions(+), 138 deletions(-) diff --git a/helpers/flipsidecrypto.ts b/helpers/flipsidecrypto.ts index a3eaf33994..4d941d7efd 100644 --- a/helpers/flipsidecrypto.ts +++ b/helpers/flipsidecrypto.ts @@ -7,7 +7,6 @@ const token = {} as IJSON const isRestrictedMode = getEnv('FLIPSIDE_RESTRICTED_MODE') === 'true' const FLIPSIDE_API_KEYS = getEnv('FLIPSIDE_API_KEY')?.split(',') ?? ["f3b65679-a179-4983-b794-e41cf40103ed"] let API_KEY_INDEX = 0; -const MAX_RETRIES = 20; type IRequest = { [key: string]: Promise; @@ -22,163 +21,203 @@ async function randomDelay() { export async function queryFlipside(sqlQuery: string, maxAgeMinutes: number = 90) { checkCanFlipSideQuery(); if (!query[sqlQuery]) { - query[sqlQuery] = _queryFlipside(sqlQuery, maxAgeMinutes) + return _queryFlipside(sqlQuery, maxAgeMinutes); } - return query[sqlQuery] + return query[sqlQuery]; } +let FLIPSIDE_API_KEY: string = FLIPSIDE_API_KEYS[API_KEY_INDEX] -async function _queryFlipside(sqlQuery: string, maxAgeMinutes: number = 90) { - return await retry( - async (bail, attempt: number) => { - const FLIPSIDE_API_KEY = FLIPSIDE_API_KEYS[API_KEY_INDEX] - let query: undefined | any = undefined - if (!token[sqlQuery]) { - try{ - query = await httpPost("https://api-v2.flipsidecrypto.xyz/json-rpc", - { - "jsonrpc": "2.0", - "method": "createQueryRun", - "params": [ - { - "resultTTLHours": 5, - "maxAgeMinutes": maxAgeMinutes, - "sql": sqlQuery, - "tags": { - "source": "api" - }, - "dataSource": "snowflake-default", - "dataProvider": "flipside" - } - ], - "id": 1 - }, { - headers: { - "x-api-key": FLIPSIDE_API_KEY, - 'Content-Type': 'application/json' - }, - }, { withMetadata: true }) - if(query?.result?.queryRun?.id){ - token[sqlQuery] = query?.result.queryRun.id - } else { - console.log("error query data", query) - throw query?.error.message - } - } catch(e:any){ - if(e?.response?.statusText === 'Payment Required'){ - if(API_KEY_INDEX < (FLIPSIDE_API_KEYS.length-1)){ - const nextIndex = FLIPSIDE_API_KEYS.findIndex((k: any)=>k===FLIPSIDE_API_KEY) + 1 - if(API_KEY_INDEX < nextIndex){ - API_KEY_INDEX = nextIndex; - } - console.info("flipside increasing API_KEY_INDEX to -> ", FLIPSIDE_API_KEYS[API_KEY_INDEX]) - throw "Increasing API_KEY_INDEX"; - } else { - const error = new Error(`Payment Required`) - bail(error) - console.error("Payment Required: " + FLIPSIDE_API_KEY) - return [] +// query status +async function createRequire(sqlQuery: string, maxAgeMinutes: number): Promise { + try { + const query = await httpPost("https://api-v2.flipsidecrypto.xyz/json-rpc", + { + "jsonrpc": "2.0", + "method": "createQueryRun", + "params": [ + { + "resultTTLHours": 5, + "maxAgeMinutes": maxAgeMinutes, + "sql": sqlQuery, + "tags": { + "source": "api" + }, + "dataSource": "snowflake-default", + "dataProvider": "flipside" } - } - if (!e.response) { - bail(e) - console.error("flipside not found response error") - return [] - } - console.log("make query flipside", e.response, e) - bail(e) - return [] - } + ], + "id": 1 + }, { + headers: { + 'x-api-key': FLIPSIDE_API_KEY, + 'Content-Type': 'application/json', + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3' + }, + }, { withMetadata: true }) + + if(query?.result?.queryRun?.id){ + return query?.result.queryRun.id + } else { + console.log("error query data", query) + throw query?.error.message } - if (!token[sqlQuery]) { - console.error("Couldn't get a token from flipsidecrypto") - throw new Error("Couldn't get a token from flipsidecrypto") + } catch (e: any) { + if(e?.response?.statusText === 'Payment Required' || e?.response?.statusText === 'Unauthorized') { + if(API_KEY_INDEX < (FLIPSIDE_API_KEYS.length-1)) { + API_KEY_INDEX++; + FLIPSIDE_API_KEY = FLIPSIDE_API_KEYS[API_KEY_INDEX]; + console.info(`Switching to new API key: ${FLIPSIDE_API_KEY}`); + return createRequire(sqlQuery, maxAgeMinutes) + } else { + const error = new Error(`Payment Required`) + throw error; } + } + throw e; + } +} + +// query status +async function queryStatus(queryID: string) { + try { + const _queryStatus = await httpPost(`https://api-v2.flipsidecrypto.xyz/json-rpc`, { + "jsonrpc": "2.0", + "method": "getQueryRun", + "params": [ + { + "queryRunId": queryID + } + ], + "id": 1 + }, { + headers: { + 'x-api-key': FLIPSIDE_API_KEY, + 'Content-Type': 'application/json', + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3' + } + }, { withMetadata: true }) + const status = _queryStatus.result.queryRun.state + if (status === "QUERY_STATE_SUCCESS") { + return _queryStatus + } else if (status === "QUERY_STATE_FAILED") { + console.log(`Flipside query ${queryID} failed`, _queryStatus) + return _queryStatus + } + console.info(`Flipside query ${queryID} status: ${status}`) + await randomDelay() + return queryStatus(queryID) + } catch (e: any) { + if(e?.response?.statusText === 'Payment Required' || e?.response?.statusText === 'Unauthorized') { + if (API_KEY_INDEX < (FLIPSIDE_API_KEYS.length-1)) { + API_KEY_INDEX++; + FLIPSIDE_API_KEY = FLIPSIDE_API_KEYS[API_KEY_INDEX]; + console.info(`Switching to new API key: ${FLIPSIDE_API_KEY}`); + return queryStatus(queryID) + } else { + const error = new Error(`Payment Required`) + throw error; + } + } + throw e; + } +} - const queryStatus = await httpPost(`https://api-v2.flipsidecrypto.xyz/json-rpc`, { +async function cancelQuery(queryID: string) { + await httpPost(`https://api-v2.flipsidecrypto.xyz/json-rpc`, { + "jsonrpc": "2.0", + "method": "cancelQueryRun", + "params": [ + { + "queryRunId": queryID + } + ], + "id": 1 + }, { + headers: { + 'x-api-key': FLIPSIDE_API_KEY, + 'Content-Type': 'application/json', + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3' + }, + }, { withMetadata: true }) +} + +// query results +async function queryResults(queryID: string) { + try { + let fullRows:any[] = [] + let pageNum = 1; + let maxPages = 1; + while(pageNum <= maxPages){ + const results = await httpPost(`https://api-v2.flipsidecrypto.xyz/json-rpc`, { "jsonrpc": "2.0", - "method": "getQueryRun", + "method": "getQueryRunResults", "params": [ { - "queryRunId": token[sqlQuery] + "queryRunId": queryID, + "format": "csv", + "page": { + "number": pageNum, + "size": 5000 + } } ], "id": 1 }, { headers: { - "x-api-key": FLIPSIDE_API_KEY + 'x-api-key': FLIPSIDE_API_KEY, + 'Content-Type': 'application/json', + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3' } }, { withMetadata: true }) - - const status = queryStatus.result.queryRun.state - if (status === "QUERY_STATE_SUCCESS") { - try { - let fullRows:any[] = [] - let pageNum = 1; - let maxPages = 1; - while(pageNum <= maxPages){ - const results = await httpPost(`https://api-v2.flipsidecrypto.xyz/json-rpc`, { - "jsonrpc": "2.0", - "method": "getQueryRunResults", - "params": [ - { - "queryRunId": token[sqlQuery], - "format": "csv", - "page": { - "number": pageNum, - "size": 1000 - } - } - ], - "id": 1 - }, { - headers: { - "x-api-key": FLIPSIDE_API_KEY - } - }, { withMetadata: true }) - if(results.result.rows === null){ - return [] // empty result - } - pageNum = results.result.page.currentPageNumber + 1; - maxPages = results.result.page.totalPages; - fullRows = fullRows.concat(results.result.rows.map((t: any[]) => t.slice(0, -1))) - } - return fullRows - } catch (e) { - console.log("flipside query results", e); - throw e - } - } else if (status === "QUERY_STATE_FAILED") { - console.log(`Flipside query ${sqlQuery} failed`, queryStatus) - bail(new Error(`Query ${sqlQuery} failed, error ${JSON.stringify(queryStatus)}`)) - return []; // not returned but just there to make typescript happy - } else if (status === "QUERY_STATE_RUNNING" && (attempt === MAX_RETRIES)) { - console.log(`Flipside queryRunId ${token[sqlQuery]} still run will cancel!!`) - await httpPost(`https://api-v2.flipsidecrypto.xyz/json-rpc`, { - "jsonrpc": "2.0", - "method": "cancelQueryRun", - "params": [ - { - "queryRunId": token[sqlQuery] - } - ], - "id": 1 - }, { - headers: { - "x-api-key": FLIPSIDE_API_KEY - } - }, { withMetadata: true }) - bail(new Error('max retries exceeded')) + if(results.result.rows === null){ + return [] // empty result } - await randomDelay() - console.info(`Flipside query ${token[sqlQuery]} still running... retrying ${attempt}`) - throw new Error("Still running") - }, - { - retries: MAX_RETRIES, - maxTimeout: 1000 * 60 * 5 + pageNum = results.result.page.currentPageNumber + 1; + maxPages = results.result.page.totalPages; + fullRows = fullRows.concat(results.result.rows.map((t: any[]) => t.slice(0, -1))) } - ); + return fullRows + } catch (e: any) { + if(e?.response?.statusText === 'Payment Required' || e?.response?.statusText === 'Unauthorized') { + if(API_KEY_INDEX < (FLIPSIDE_API_KEYS.length-1)) { + API_KEY_INDEX++; + FLIPSIDE_API_KEY = FLIPSIDE_API_KEYS[API_KEY_INDEX]; + console.info(`Switching to new API key: ${FLIPSIDE_API_KEY}`); + return queryResults(queryID) + } else { + const error = new Error(`Payment Required`) + throw error; + } + } + throw e; + } +} + +const _queryFlipside = async (sqlQuery: string, maxAgeMinutes: number) => { + if (!token[sqlQuery]) { + const query = await createRequire(sqlQuery, maxAgeMinutes) + if (query) { + token[sqlQuery] = query + } + } + + if (!token[sqlQuery]) { + throw new Error("Couldn't get a token from flipsidecrypto") + } + + const _queryStatus = await queryStatus(token[sqlQuery]) + const status = _queryStatus.result.queryRun.state + if (status === "QUERY_STATE_SUCCESS") { + try { + return queryResults(token[sqlQuery]) + } catch (e) { + console.log("flipside query results", e); + throw e + } + } else if (status === "QUERY_STATE_FAILED") { + await cancelQuery(token[sqlQuery]) + } } export function checkCanFlipSideQuery() { From 7e848998f4081a1151af2faaccaeedb10ec7cbf7 Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Sun, 22 Dec 2024 18:15:04 +0000 Subject: [PATCH 77/86] add function switch key --- helpers/flipsidecrypto.ts | 54 +++++++++++++-------------------------- 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/helpers/flipsidecrypto.ts b/helpers/flipsidecrypto.ts index 4d941d7efd..82e80a95c3 100644 --- a/helpers/flipsidecrypto.ts +++ b/helpers/flipsidecrypto.ts @@ -27,6 +27,21 @@ export async function queryFlipside(sqlQuery: string, maxAgeMinutes: number = 90 } let FLIPSIDE_API_KEY: string = FLIPSIDE_API_KEYS[API_KEY_INDEX] +function switchToNextAPIKey(e: any, callback: any) { + if(e?.response?.statusText === 'Payment Required' || e?.response?.statusText === 'Unauthorized') { + if (API_KEY_INDEX < (FLIPSIDE_API_KEYS.length-1)) { + API_KEY_INDEX++; + FLIPSIDE_API_KEY = FLIPSIDE_API_KEYS[API_KEY_INDEX]; + console.info(`Switching to new API key: ${FLIPSIDE_API_KEY}`); + return callback() + } else { + const error = new Error(`Payment Required`) + throw error; + } + } + throw e; +} + // query status async function createRequire(sqlQuery: string, maxAgeMinutes: number): Promise { try { @@ -63,18 +78,7 @@ async function createRequire(sqlQuery: string, maxAgeMinutes: number): Promise createRequire(sqlQuery, maxAgeMinutes)) } } @@ -108,18 +112,7 @@ async function queryStatus(queryID: string) { await randomDelay() return queryStatus(queryID) } catch (e: any) { - if(e?.response?.statusText === 'Payment Required' || e?.response?.statusText === 'Unauthorized') { - if (API_KEY_INDEX < (FLIPSIDE_API_KEYS.length-1)) { - API_KEY_INDEX++; - FLIPSIDE_API_KEY = FLIPSIDE_API_KEYS[API_KEY_INDEX]; - console.info(`Switching to new API key: ${FLIPSIDE_API_KEY}`); - return queryStatus(queryID) - } else { - const error = new Error(`Payment Required`) - throw error; - } - } - throw e; + return switchToNextAPIKey(e, () => queryStatus(queryID)) } } @@ -179,18 +172,7 @@ async function queryResults(queryID: string) { } return fullRows } catch (e: any) { - if(e?.response?.statusText === 'Payment Required' || e?.response?.statusText === 'Unauthorized') { - if(API_KEY_INDEX < (FLIPSIDE_API_KEYS.length-1)) { - API_KEY_INDEX++; - FLIPSIDE_API_KEY = FLIPSIDE_API_KEYS[API_KEY_INDEX]; - console.info(`Switching to new API key: ${FLIPSIDE_API_KEY}`); - return queryResults(queryID) - } else { - const error = new Error(`Payment Required`) - throw error; - } - } - throw e; + return switchToNextAPIKey(e, () => queryResults(queryID)) } } From b6efb4264a4944a40baf7732870ff72466cc4cc8 Mon Sep 17 00:00:00 2001 From: 0xngmi <0xngmi@protonmail.com> Date: Sun, 22 Dec 2024 19:58:46 +0000 Subject: [PATCH 78/86] add hyperliquid --- fees/hyperliquid.ts | 32 ++++++++++++++++++++++++++++++++ helpers/chains.ts | 1 + 2 files changed, 33 insertions(+) create mode 100644 fees/hyperliquid.ts diff --git a/fees/hyperliquid.ts b/fees/hyperliquid.ts new file mode 100644 index 0000000000..fafc3a5d84 --- /dev/null +++ b/fees/hyperliquid.ts @@ -0,0 +1,32 @@ +import { CHAIN } from "../helpers/chains" +import { Adapter, FetchOptions, } from '../adapters/types'; +import { findClosest } from "../helpers/utils/findClosest"; + +const fetchFees = async (options: FetchOptions) => { + const dailyFees = options.createBalances(); + const data:any[] = (await fetch(`https://api.hypurrscan.io/fees`).then(r => r.json())).map((t:any)=>({...t, time:t.time*1e3})) + + const startCumFees: any = findClosest(options.startTimestamp, data, 3600) + const endCumFees: any = findClosest(options.endTimestamp, data, 3600) + dailyFees.addCGToken("usd-coin", (endCumFees.total_fees - startCumFees.total_fees)/1e6) + + return { + dailyFees, + dailyRevenue: dailyFees, + } +} + +const adapter: Adapter = { + version: 2, + adapter: { + [CHAIN.HYPERLIQUID]: { + fetch: fetchFees, + meta: { + methodology: { + Fees: "Trade fees and ticket auction proceeds", + } + } + }, + }, +} +export default adapter \ No newline at end of file diff --git a/helpers/chains.ts b/helpers/chains.ts index 03a7e80358..7b635083f8 100644 --- a/helpers/chains.ts +++ b/helpers/chains.ts @@ -201,6 +201,7 @@ export enum CHAIN { SAPPHIRE = "sapphire", VANA = "vana", SONIC = "sonic", + HYPERLIQUID = "hyperliquid", } // Don´t use From d9c99e808c579a13d2ad6bf905900eebd928de67 Mon Sep 17 00:00:00 2001 From: 0xngmi <0xngmi@protonmail.com> Date: Sun, 22 Dec 2024 20:02:54 +0000 Subject: [PATCH 79/86] total hl fees --- fees/hyperliquid.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fees/hyperliquid.ts b/fees/hyperliquid.ts index fafc3a5d84..6a7451f1ff 100644 --- a/fees/hyperliquid.ts +++ b/fees/hyperliquid.ts @@ -10,9 +10,14 @@ const fetchFees = async (options: FetchOptions) => { const endCumFees: any = findClosest(options.endTimestamp, data, 3600) dailyFees.addCGToken("usd-coin", (endCumFees.total_fees - startCumFees.total_fees)/1e6) + const totalFees = options.createBalances(); + totalFees.addCGToken("usd-coin", endCumFees.total_fees/1e6) + return { dailyFees, dailyRevenue: dailyFees, + totalFees, + totalRevenue: totalFees, } } From d53e9169500d00dff6b2d6306f57986f4b87a3f2 Mon Sep 17 00:00:00 2001 From: 0xngmi <0xngmi@protonmail.com> Date: Sun, 22 Dec 2024 20:11:57 +0000 Subject: [PATCH 80/86] fix start/end --- fees/illuvium.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/fees/illuvium.ts b/fees/illuvium.ts index 9c5a4111b2..ca0574b878 100644 --- a/fees/illuvium.ts +++ b/fees/illuvium.ts @@ -3,25 +3,20 @@ import { CHAIN } from '../helpers/chains'; const fetchFees = async (options: FetchOptions) => { const dailyFees = options.createBalances(); - const end = Date.now() - const start = end - 3600*24*1e3 let transfers = [] as any[] let cursor = "" do{ - const url = `https://api.immutable.com/v1/transfers?receiver=0x2208850ea5569617d5350f8cf681031102c1d931&max_timestamp=${new Date(end).toISOString()}&min_timestamp=${new Date(start).toISOString()}&cursor=${cursor}` + const url = `https://api.immutable.com/v1/transfers?receiver=0x2208850ea5569617d5350f8cf681031102c1d931&max_timestamp=${new Date(options.endTimestamp*1e3).toISOString()}&min_timestamp=${new Date(options.startTimestamp*1e3).toISOString()}&cursor=${cursor}` const data = await fetch(url).then(r=>r.json()) transfers = transfers.concat(data.result) cursor=data.cursor } while(cursor !== "") - const users = new Set() transfers.forEach(transfer=>{ if(transfer.token.type === "ETH"){ - users.add(transfer.user) dailyFees.addCGToken("ethereum", transfer.token.data.quantity/1e18) } }) - console.log(Array.from(users).length) return { dailyFees, dailyRevenue: dailyFees, @@ -33,7 +28,7 @@ const adapter: Adapter = { adapter: { [CHAIN.IMMUTABLEX]: { fetch: fetchFees, - meta: { + meta: { methodology: { Fees: "ETH paid to purchase fuel", } From ca63b13809423b5ba48fcceca7268f9eebb4dafa Mon Sep 17 00:00:00 2001 From: 0xBluePingu <156801910+0xBluePingu@users.noreply.github.com> Date: Mon, 23 Dec 2024 13:52:08 +0100 Subject: [PATCH 81/86] update subgraph (#2236) * update subgraph * minor refactor --------- Co-authored-by: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> --- dexs/pingu/index.ts | 39 ++++++++++++++++++--------------------- fees/pingu/index.ts | 43 ++++++++++++++++++------------------------- 2 files changed, 36 insertions(+), 46 deletions(-) diff --git a/dexs/pingu/index.ts b/dexs/pingu/index.ts index bfa089ffd6..18965950b3 100644 --- a/dexs/pingu/index.ts +++ b/dexs/pingu/index.ts @@ -1,35 +1,32 @@ import ADDRESSES from '../../helpers/coreAssets.json' -import { FetchResult, SimpleAdapter } from "../../adapters/types"; +import { FetchOptions, FetchResult, SimpleAdapter } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; import { gql, request } from "graphql-request"; import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; -import * as sdk from "@defillama/sdk"; interface IGraph { - volumeEth: string; - volumeUsdc: string; + volume: string; id: string; } -const URL = 'https://api.studio.thegraph.com/query/75208/pingu-sg-v2/0.0.1/'; -const fetch = async (timestamp: number): Promise => { +const URL = 'https://api.studio.thegraph.com/query/75208/pingu-arb/0.0.2/'; +const assets = [ADDRESSES.arbitrum.USDC_CIRCLE, ADDRESSES.null]; +const fetch = async (timestamp: number, _: any, { createBalances }: FetchOptions): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); - const chain = CHAIN.ARBITRUM; - const balances = new sdk.Balances({ chain, timestamp }) - const query = gql` - { - dayData(id: ${dayTimestamp * 1000}) { - volumeEth - volumeUsdc - } - }`; - const response: IGraph = (await request(URL, query)).dayData; - const element = response; - balances._add(ADDRESSES.arbitrum.USDC_CIRCLE, element.volumeUsdc); - balances._add(ADDRESSES.arbitrum.WETH, element.volumeEth); - + const dailyVolume = createBalances() + for (const asset of assets) { + const query = gql` + { + dayAssetData(id: "${dayTimestamp * 1000}-${asset.toLowerCase()}") { + volume + } + }`; + const response: IGraph = (await request(URL, query)).dayAssetData; + const element = response; + dailyVolume.add(asset, element.volume); + } return { - dailyVolume: await balances.getUSDString(), + dailyVolume, timestamp: dayTimestamp, }; } diff --git a/fees/pingu/index.ts b/fees/pingu/index.ts index a1c5b9df8a..4b20c18d66 100644 --- a/fees/pingu/index.ts +++ b/fees/pingu/index.ts @@ -1,39 +1,32 @@ import ADDRESSES from '../../helpers/coreAssets.json' -import { FetchResult, SimpleAdapter } from "../../adapters/types"; +import { FetchOptions, FetchResult, SimpleAdapter } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; import { gql, request } from "graphql-request"; import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; -import * as sdk from "@defillama/sdk"; interface IGraph { - totalFeesEth: string; - totalFeesUsdc: string; + totalFees: string; id: string; } -const URL = 'https://api.studio.thegraph.com/query/75208/pingu-sg-v2/0.0.1/'; - -const fetch = async (timestamp: number): Promise => { +const URL = 'https://api.studio.thegraph.com/query/75208/pingu-arb/0.0.2/'; +const assets = [ADDRESSES.arbitrum.USDC_CIRCLE, ADDRESSES.null]; +const fetch = async (timestamp: number, _: any, { createBalances }: FetchOptions): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); - const chain = CHAIN.ARBITRUM; - const balances = new sdk.Balances({ chain, timestamp }); - const query = gql` - { - dayData(id: ${dayTimestamp * 1000}) { - totalFeesEth - totalFeesUsdc - id - } - }` - - const response: IGraph = (await request(URL, query)).dayData; - const element = response; - - balances._add(ADDRESSES.arbitrum.USDC_CIRCLE, element.totalFeesUsdc); - balances._add(ADDRESSES.arbitrum.WETH, element.totalFeesEth); - + const dailyFees = createBalances() + for (const asset of assets) { + const query = gql` + { + dayAssetData(id: "${dayTimestamp * 1000}-${asset.toLowerCase()}") { + totalFees + } + }`; + const response: IGraph = (await request(URL, query)).dayAssetData; + const element = response; + dailyFees.add(asset, element.totalFees); + } return { - dailyFees: await balances.getUSDString(), + dailyFees, timestamp: dayTimestamp, }; } From 92372d1db79d6b7a6a933942cb2197fb00ff4d81 Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Mon, 23 Dec 2024 16:29:22 +0100 Subject: [PATCH 82/86] Add Invariant volume and fee tracking adapter (#2251) * add invariant volume * track fees as well --------- Co-authored-by: none00y --- dexs/invariant/index.ts | 54 +++++++++++++++++++++++++++++++++++++++++ fees/invariant.ts | 3 +++ 2 files changed, 57 insertions(+) create mode 100644 dexs/invariant/index.ts create mode 100644 fees/invariant.ts diff --git a/dexs/invariant/index.ts b/dexs/invariant/index.ts new file mode 100644 index 0000000000..5e40c06da4 --- /dev/null +++ b/dexs/invariant/index.ts @@ -0,0 +1,54 @@ +import { SimpleAdapter } from "../../adapters/types"; +import { CHAIN } from "../../helpers/chains"; +import axios from "axios"; +import { FetchResult } from "../../adapters/types"; +const solanaStatsApiEndpoint = + "https://stats.invariant.app/svm/full_snap/mainnet"; +const eclipseStatsApiEndpoint = + "https://stats.invariant.app/svm/full_snap/eclipse-mainnet"; + +type StatsApiResponse = { + data: { + volume24: { value: number; }; + fees24: { value: number; }; + }; +}; + +const fetch = async ( + timestamp: number, + fullSnapEndpoint: string +): Promise => { + const fullSnapResponse = await axios.get( + fullSnapEndpoint + ); + return { + dailyVolume: fullSnapResponse.data.volume24.value, + dailyFees: fullSnapResponse.data.fees24.value, + timestamp, + }; +}; + +const fetchSolana = async (timestamp: number) => { + return fetch(timestamp, solanaStatsApiEndpoint); +}; + +const fetchEclipse = async (timestamp: number) => { + return fetch(timestamp, eclipseStatsApiEndpoint); +}; + +const adapter: SimpleAdapter = { + adapter: { + [CHAIN.SOLANA]: { + fetch: fetchSolana, + runAtCurrTime: true, + start: "2024-12-22", + }, + [CHAIN.ECLIPSE]: { + fetch: fetchEclipse, + runAtCurrTime: true, + start: "2024-12-22", + }, + }, +}; + +export default adapter; diff --git a/fees/invariant.ts b/fees/invariant.ts new file mode 100644 index 0000000000..d4a233b2d7 --- /dev/null +++ b/fees/invariant.ts @@ -0,0 +1,3 @@ +import adapter from '../dexs/invariant' + +export default adapter \ No newline at end of file From 851b8ee2623f104e2aa611076ecd7724ad4536b9 Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Mon, 23 Dec 2024 15:34:55 +0000 Subject: [PATCH 83/86] fix aerodrome --- dexs/aerodrome/index.ts | 31 +++++++++++++++++++++++++++++-- fees/aerodrome/index.ts | 41 ----------------------------------------- 2 files changed, 29 insertions(+), 43 deletions(-) delete mode 100644 fees/aerodrome/index.ts diff --git a/dexs/aerodrome/index.ts b/dexs/aerodrome/index.ts index d9559d36ff..7da8c63817 100644 --- a/dexs/aerodrome/index.ts +++ b/dexs/aerodrome/index.ts @@ -10,6 +10,32 @@ interface ILog { topics: string[]; } const event_swap = 'event Swap(address indexed sender, address indexed to, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out)' +const event_notify_reward = 'event NotifyReward(address indexed from,address indexed reward,uint256 indexed epoch,uint256 amount)'; +const event_gauge_created = 'event GaugeCreated(address indexed poolFactory,address indexed votingRewardsFactory,address indexed gaugeFactory,address pool,address bribeVotingReward,address feeVotingReward,address gauge,address creator)' + + +const fetchBribes = async (fetchOptions: FetchOptions): Promise => { + const { getLogs, createBalances } = fetchOptions + const voter = '0x16613524e02ad97eDfeF371bC883F2F5d6C480A5'; + const dailyBribes = createBalances() + const logs_gauge_created = (await getLogs({ + target: voter, + fromBlock: 3200601, + eventAbi: event_gauge_created, + cacheInCloud: true, + })) + const bribes_contract: string[] = logs_gauge_created.map((e: any) => e.bribeVotingReward.toLowerCase()); + + const logs = await getLogs({ + targets: bribes_contract, + eventAbi: event_notify_reward, + }) + logs.map((e: any) => { + dailyBribes.add(e.reward, e.amount) + }) + + return { dailyBribesRevenue: dailyBribes } as any +} const fetch = async (fetchOptions: FetchOptions): Promise => { const { api, getLogs, createBalances, } = fetchOptions @@ -34,7 +60,7 @@ const fetch = async (fetchOptions: FetchOptions): Promise => { params: [pair, stables[i]] }) }); - + const fees = await api.multiCall({ abi: 'function getFee(address pool, bool _stable) external view returns (uint256)', calls: poolsCalls }) let logs: ILog[][] = []; @@ -80,7 +106,8 @@ const fetch = async (fetchOptions: FetchOptions): Promise => { }) }) - return { dailyVolume, dailyFees, dailyRevenue: dailyFees, dailyHoldersRevenue: dailyFees } as any + const bribes = await fetchBribes(fetchOptions) + return { dailyVolume, dailyFees, dailyRevenue: dailyFees, dailyHoldersRevenue: dailyFees, ...bribes } as any } const adapters: SimpleAdapter = { diff --git a/fees/aerodrome/index.ts b/fees/aerodrome/index.ts deleted file mode 100644 index 6bac20eadb..0000000000 --- a/fees/aerodrome/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { FetchOptions, FetchResult, SimpleAdapter } from "../../adapters/types" -import { CHAIN } from "../../helpers/chains" - -const event_notify_reward = 'event NotifyReward(address indexed from,address indexed reward,uint256 indexed epoch,uint256 amount)'; -const event_gauge_created = 'event GaugeCreated(address indexed poolFactory,address indexed votingRewardsFactory,address indexed gaugeFactory,address pool,address bribeVotingReward,address feeVotingReward,address gauge,address creator)' - -const fetch = async (fetchOptions: FetchOptions): Promise => { - const { api, getLogs, createBalances, getToBlock, } = fetchOptions - const chain = api.chain - const voter = '0x16613524e02ad97eDfeF371bC883F2F5d6C480A5'; - const dailyBribes = createBalances() - const logs_gauge_created = (await getLogs({ - target: voter, - fromBlock: 3200601, - toBlock: await getToBlock(), - eventAbi: event_gauge_created, - cacheInCloud: true, - })) - const bribes_contract: string[] = logs_gauge_created.map((e: any) => e.bribeVotingReward.toLowerCase()); - - const logs = await getLogs({ - targets: bribes_contract, - eventAbi: event_notify_reward, - }) - logs.map((e: any) => { - dailyBribes.add(e.reward, e.amount) - }) - - return { dailyBribesRevenue: dailyBribes } as any -} - -const adapters: SimpleAdapter = { - version: 2, - adapter: { - [CHAIN.BASE]: { - fetch: fetch as any, - start: '2023-08-28', - } - } -} -export default adapters; From ee016fdbf9547437fe2e6c88d85ca98f25b45ebd Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Mon, 23 Dec 2024 16:56:39 +0100 Subject: [PATCH 84/86] Memejob (#2252) * add memejob in fees * code refactor * remove negative balances from daily fees calculation --------- Co-authored-by: baditu --- fees/memejob/index.ts | 37 +++++++++++++++++++++++++++++++++++++ helpers/getBlock.ts | 1 - 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 fees/memejob/index.ts diff --git a/fees/memejob/index.ts b/fees/memejob/index.ts new file mode 100644 index 0000000000..dfd3fb80ee --- /dev/null +++ b/fees/memejob/index.ts @@ -0,0 +1,37 @@ +import { FetchOptions, SimpleAdapter } from "../../adapters/types"; +import { CHAIN } from "../../helpers/chains"; +import { getTokenDiff } from "../../helpers/token"; + +const methodology = { + Revenue: "All revenue is generated from user fees.", + Fees: "Users pay a 1% fee for each trade. Additionally, approximately 2000 HBAR is charged when a token is migrated.", +}; + +const FEE_COLLECTOR_CONTRACT = "0x00000000000000000000000000000000000ec550"; + +async function fetch(options: FetchOptions) { + const dailyFees = await getTokenDiff({ target: FEE_COLLECTOR_CONTRACT, options, tokens: [], includeGasToken: true }) + + // in case the team moves hbar out of the contract + dailyFees.removeNegativeBalances() + + return { + dailyFees, + dailyRevenue: dailyFees, + }; +} + +const adapter: SimpleAdapter = { + version: 2, + adapter: { + [CHAIN.HEDERA]: { + fetch, + start: "2024-12-16", + meta: { + methodology, + }, + }, + }, +}; + +export default adapter; diff --git a/helpers/getBlock.ts b/helpers/getBlock.ts index 8ee8e785ee..930da7396e 100644 --- a/helpers/getBlock.ts +++ b/helpers/getBlock.ts @@ -17,7 +17,6 @@ const blacklistedChains: string[] = [ "defichain", "stacks", "KARURA", - "hedera", "eos", "icon", "stellar", From 77b26a4a210c79e5c60be1fed71577ac76b0721a Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Tue, 24 Dec 2024 01:04:36 +0100 Subject: [PATCH 85/86] track zivoe fees #2253 --- fees/zivoe/index.ts | 57 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 fees/zivoe/index.ts diff --git a/fees/zivoe/index.ts b/fees/zivoe/index.ts new file mode 100644 index 0000000000..bbf560fc37 --- /dev/null +++ b/fees/zivoe/index.ts @@ -0,0 +1,57 @@ +import { FetchOptions, SimpleAdapter } from "../../adapters/types"; +import { CHAIN } from "../../helpers/chains"; +import fetchURL from "../../utils/fetchURL"; +import { getTimestampAtStartOfDayUTC } from "../../utils/date"; + +const ZIVOE_API_URL = "https://analytics.zivoe.com/api/stats/feesAndRevenue"; + +type DailyAmount = { + tokenAddress: string; + value: string; +}; + +type DailyFeesAndRevenue = { + fees: Array; + revenue: Array; +}; + +const fetch: any = async (timestamp: number, _:any, options: FetchOptions) => { + const dailyFees = options.createBalances(); + const dailyRevenue = options.createBalances(); + + const params = new URLSearchParams({ + network: "MAINNET", + periodStart: getTimestampAtStartOfDayUTC(timestamp).toString(), + }); + + const { fees, revenue }: DailyFeesAndRevenue = await fetchURL(ZIVOE_API_URL + "?" + params.toString()); + console.log(fees, revenue); + + fees.forEach((record) => { + dailyFees.add(record.tokenAddress, BigInt(record.value)); + }); + + revenue.forEach((record) => { + dailyRevenue.add(record.tokenAddress, BigInt(record.value)); + }); + + return { dailyFees, dailyRevenue, timestamp, }; +}; + +const adapter: SimpleAdapter = { + version: 1, + adapter: { + [CHAIN.ETHEREUM]: { + fetch, + start: "2024-10-10", + meta: { + methodology: { + Fees: `Interest earned from borrowers + fees generated by deploying idle capital into DeFi.`, + Revenue: `Portion of fees retained by the protocol.`, + }, + }, + }, + }, +}; + +export default adapter; \ No newline at end of file From 267714424a12ad6d59dda8f287ea40e93c9e4295 Mon Sep 17 00:00:00 2001 From: bergben Date: Tue, 24 Dec 2024 01:07:31 +0100 Subject: [PATCH 86/86] feat(dexes): add fluid dex for arbitrum (#2254) --- dexs/fluid-dex/index.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/dexs/fluid-dex/index.ts b/dexs/fluid-dex/index.ts index 826aa56eee..67ba3de993 100644 --- a/dexs/fluid-dex/index.ts +++ b/dexs/fluid-dex/index.ts @@ -19,7 +19,17 @@ interface SwapEventArgs { fee: bigint; } -const dexReservesResolver = "0xE8a07a32489BD9d5a00f01A55749Cf5cB854Fd13"; +const dexReservesResolver = (chain: string) => { + switch (chain) { + case CHAIN.ETHEREUM: + return "0xE8a07a32489BD9d5a00f01A55749Cf5cB854Fd13"; + case CHAIN.ARBITRUM: + return "0xb8f526718FF58758E256D9aD86bC194a9ff5986D"; + default: + throw new Error("DexReservesResolver not defined"); + } +} + const abi = { getAllPools: "function getAllPools() view returns (tuple(address pool, address token0, address token1, uint256 fee)[])", @@ -29,7 +39,7 @@ const abi = { const fetch = async ({ api, createBalances, getLogs }: FetchOptions): Promise => { const dailyVolume = createBalances(); const dailyFees = createBalances() - const rawPools: PoolInfo[] = await api.call({ target: dexReservesResolver, abi: abi.getAllPools }); + const rawPools: PoolInfo[] = await api.call({ target: dexReservesResolver(api.chain), abi: abi.getAllPools }); const pools = rawPools.map(({ pool, token0, token1, fee }) => ({ pool, token0, token1, fee: BigInt(fee) })); const logsByPool: SwapEventArgs[][]= await Promise.all( @@ -77,6 +87,7 @@ const adapter: Adapter = { version: 2, adapter: { [CHAIN.ETHEREUM]: { fetch, start: '2024-10-26' }, + [CHAIN.ARBITRUM]: { fetch, start: '2024-12-23' }, }, };