diff --git a/adapters/utils/runAdapter.ts b/adapters/utils/runAdapter.ts index 7205967f7a..230e2b85d0 100644 --- a/adapters/utils/runAdapter.ts +++ b/adapters/utils/runAdapter.ts @@ -27,7 +27,11 @@ export default async function runAdapter(volumeAdapter: BaseAdapter, cleanCurren // console.log("Result before cleaning", id, version, cleanCurrentDayTimestamp, chain, result, JSON.stringify(chainBlocks ?? {})) for (const [key, value] of Object.entries(result)) { if (ignoreKeys.includes(key)) continue; - if (value === undefined || value === null) throw new Error(`Value: ${value} ${key} is undefined or null`) + if (value === undefined || value === null) { // dont store undefined or null values + delete result[key] + continue; + } + // if (value === undefined || value === null) throw new Error(`Value: ${value} ${key} is undefined or null`) if (value instanceof Balances) result[key] = await value.getUSDString() result[key] = +Number(result[key]).toFixed(0) if (isNaN(result[key] as number)) throw new Error(`[${chain}]Value: ${value} ${key} is NaN`) diff --git a/dexs/DerpDEX/index.ts b/dexs/DerpDEX/index.ts index db657c57a3..69d4718321 100644 --- a/dexs/DerpDEX/index.ts +++ b/dexs/DerpDEX/index.ts @@ -37,15 +37,15 @@ const adapter: Adapter = { adapter: { [CHAIN.ERA]: { fetch: v3Graphs(CHAIN.ERA), - start: async () => 1688515200 + start: 1688515200 }, [CHAIN.BASE]: { fetch: v3Graphs(CHAIN.BASE), - start: async () => 1692296100 + start: 1692296100 }, [CHAIN.OP_BNB]: { fetch: v3Graphs(CHAIN.OP_BNB), - start: async () => 1695275237 + start: 1695275237 } } }; diff --git a/dexs/alienfi/index.ts b/dexs/alienfi/index.ts index b583a771dd..86814554a7 100644 --- a/dexs/alienfi/index.ts +++ b/dexs/alienfi/index.ts @@ -10,6 +10,6 @@ const adapter = univ2Adapter(endpoints, { dayData: "pancakeDayData", }); -adapter.adapter.arbitrum.start = async () => 1676505600; +adapter.adapter.arbitrum.start = 1676505600; export default adapter diff --git a/dexs/ampleswap/index.ts b/dexs/ampleswap/index.ts index 6ca022bc80..2619b7451f 100644 --- a/dexs/ampleswap/index.ts +++ b/dexs/ampleswap/index.ts @@ -6,6 +6,6 @@ const endpoints = { }; const adapter = univ2Adapter(endpoints, {}); -adapter.adapter.bsc.start = async()=> 1631404800; +adapter.adapter.bsc.start = 1631404800; export default adapter diff --git a/dexs/apeswap/index.ts b/dexs/apeswap/index.ts index 55f5dec39d..28ba8ff6b7 100644 --- a/dexs/apeswap/index.ts +++ b/dexs/apeswap/index.ts @@ -9,10 +9,10 @@ const adapters = univ2Adapter({ // [CHAIN.TELOS]: "https://telos.apeswapgraphs.com/subgraphs/name/ape-swap/apeswap-graph" }, {}); -adapters.adapter.bsc.start = async () => 1613273226; -adapters.adapter.polygon.start = async () => 1623814026; -adapters.adapter.ethereum.start = async () => 1652239626; -// adapters.adapter.telos.start = async () => 1665880589; -adapters.adapter.arbitrum.start = async () => 1678406400; +adapters.adapter.bsc.start = 1613273226; +adapters.adapter.polygon.start = 1623814026; +adapters.adapter.ethereum.start = 1652239626; +// adapters.adapter.telos.start = 1665880589; +adapters.adapter.arbitrum.start = 1678406400; export default adapters; diff --git a/dexs/archerswap/index.ts b/dexs/archerswap/index.ts index 5ba4e75b7a..0f1cc317d5 100644 --- a/dexs/archerswap/index.ts +++ b/dexs/archerswap/index.ts @@ -8,6 +8,6 @@ const endpoints = { const adapter = univ2Adapter(endpoints, {}); -adapter.adapter.core.start = async()=> 1678060800; +adapter.adapter.core.start = 1678060800; export default adapter diff --git a/dexs/astroswap/index.ts b/dexs/astroswap/index.ts index c897154c9a..8657140053 100644 --- a/dexs/astroswap/index.ts +++ b/dexs/astroswap/index.ts @@ -11,6 +11,6 @@ const adapters = univ2Adapter({ }); -adapters.adapter.velas.start = async () => 1643414400; +adapters.adapter.velas.start = 1643414400; adapters.adapter[DISABLED_ADAPTER_KEY] = disabledAdapter; export default adapters; diff --git a/dexs/auraswap/index.ts b/dexs/auraswap/index.ts index 91b37c6c6a..e892c438ef 100644 --- a/dexs/auraswap/index.ts +++ b/dexs/auraswap/index.ts @@ -10,5 +10,5 @@ const adapters = univ2Adapter({ totalVolume: "volumeUSD", }); -adapters.adapter.polygon.start = async () => 1654992851; +adapters.adapter.polygon.start = 1654992851; export default adapters; diff --git a/dexs/babydogeswap/index.ts b/dexs/babydogeswap/index.ts index 8ca566bb32..c79453cf41 100644 --- a/dexs/babydogeswap/index.ts +++ b/dexs/babydogeswap/index.ts @@ -8,5 +8,5 @@ const adapters = univ2Adapter({ dayData: "factoryDayData", }); -adapters.adapter.bsc.start = async () => 1661780137; +adapters.adapter.bsc.start = 1661780137; export default adapters; diff --git a/dexs/babyswap/index.ts b/dexs/babyswap/index.ts index df3536bbdf..2da2b37f83 100644 --- a/dexs/babyswap/index.ts +++ b/dexs/babyswap/index.ts @@ -7,5 +7,5 @@ const adapters = univ2Adapter({ factoriesName: "pancakeFactories", dayData: "pancakeDayData", }); -adapters.adapter.bsc.start = async () => 1622518288; +adapters.adapter.bsc.start = 1622518288; export default adapters; diff --git a/dexs/baseswap/index.ts b/dexs/baseswap/index.ts index 0d7d2c560e..3612659616 100644 --- a/dexs/baseswap/index.ts +++ b/dexs/baseswap/index.ts @@ -3,7 +3,7 @@ import { DEFAULT_TOTAL_VOLUME_FACTORY, DEFAULT_TOTAL_VOLUME_FIELD, DEFAULT_DAILY import { CHAIN } from "../../helpers/chains"; import type { BreakdownAdapter, ChainEndpoints, SimpleAdapter } from "../../adapters/types"; import type { Chain } from "@defillama/sdk/build/general"; -import { getGraphDimensions } from "../../helpers/getUniSubgraph"; +import { getGraphDimensions, wrapGraphError } from "../../helpers/getUniSubgraph"; import { handle200Errors } from "../../helpers/getUniSubgraph/utils"; import { getTimestampAtStartOfDayUTC } from "../../utils/date"; import { gql, request } from "graphql-request"; @@ -75,7 +75,7 @@ const derivativesGraph = (chain: Chain) => { const tokens = derivativesTokenIds[chain]; const prices = await getPrices(derivativesTokenIds[chain].map(e => chain + ":" + e), timestamp); - const graphResTotalVolume = await request(derivativesEndpoints[chain], totalVolumeQuery, { tokens }).catch(handle200Errors).catch(e => console.error(`Failed to get total volume on ${chain} with graph ${derivativesEndpoints[chain]}: ${e.message}`)); + const graphResTotalVolume = await request(derivativesEndpoints[chain], totalVolumeQuery, { tokens }).catch(handle200Errors).catch(e => console.error(`Failed to get total volume on ${chain} with graph ${derivativesEndpoints[chain]}: ${wrapGraphError(e).message}`)); const totalVolume = graphResTotalVolume['datas'].reduce((acc: number, e: any) => acc + Number(e.cumulativeVolume * prices[chain + ":" + e.id].price), 0) / 1e8; const totalFees = graphResTotalVolume['datas'].reduce((acc: number, e: any) => acc + Number(e.cumulativeFees * prices[chain + ":" + e.id].price), 0) / 1e8; diff --git a/dexs/benswap/index.ts b/dexs/benswap/index.ts index f46572e086..e12f48bee8 100644 --- a/dexs/benswap/index.ts +++ b/dexs/benswap/index.ts @@ -8,5 +8,5 @@ const adapters = univ2Adapter({ dayData: "benSwapDayData", }); -adapters.adapter.smartbch.start = async () => 1632326400; +adapters.adapter.smartbch.start = 1632326400; export default adapters; diff --git a/dexs/bxh/index.ts b/dexs/bxh/index.ts index 14ed0d85a3..1b312395c7 100644 --- a/dexs/bxh/index.ts +++ b/dexs/bxh/index.ts @@ -7,6 +7,6 @@ const adapters = univ2Adapter({ // [CHAIN.AVAX]: "https://api.thegraph.com/subgraphs/name/privatelabs-chainx/bxhavax", not current daily volume }, {}); -adapters.adapter.bsc.start = async () => 1627172051; -adapters.adapter.ethereum.start = async () => 1629764051; +adapters.adapter.bsc.start = 1627172051; +adapters.adapter.ethereum.start = 1629764051; export default adapters; diff --git a/dexs/camelot-v3/index.ts b/dexs/camelot-v3/index.ts index b8f295191a..ad8895505e 100644 --- a/dexs/camelot-v3/index.ts +++ b/dexs/camelot-v3/index.ts @@ -11,5 +11,5 @@ const adapters = univ2Adapter({ totalVolume: "totalVolumeUSD", }); -adapters.adapter.arbitrum.start = async () => 1680220800; +adapters.adapter.arbitrum.start = 1680220800; export default adapters; diff --git a/dexs/camelot/index.ts b/dexs/camelot/index.ts index f3ff9214fb..8e2852e493 100644 --- a/dexs/camelot/index.ts +++ b/dexs/camelot/index.ts @@ -6,5 +6,5 @@ const adapters = univ2Adapter({ [CHAIN.ARBITRUM]: "https://api.thegraph.com/subgraphs/name/camelotlabs/camelot-amm-2" }, {}); -adapters.adapter.arbitrum.start = async () => 1668124800; +adapters.adapter.arbitrum.start = 1668124800; export default adapters; diff --git a/dexs/candyswap/index.ts b/dexs/candyswap/index.ts index 31e09be546..29f7cd1eb0 100644 --- a/dexs/candyswap/index.ts +++ b/dexs/candyswap/index.ts @@ -11,6 +11,6 @@ const adapter = univ2Adapter(endpoints, { dayData: "pancakeDayData", }); -adapter.adapter.meer.start = async () => 1662940800; +adapter.adapter.meer.start = 1662940800; export default adapter diff --git a/dexs/carbonswap/index.ts b/dexs/carbonswap/index.ts index e804f9a435..841e9e2690 100644 --- a/dexs/carbonswap/index.ts +++ b/dexs/carbonswap/index.ts @@ -7,5 +7,5 @@ const adapters = univ2Adapter({ }, { }); -adapters.adapter.energyweb.start = async () => 1618446893; +adapters.adapter.energyweb.start = 1618446893; export default adapters; diff --git a/dexs/cone/index.ts b/dexs/cone/index.ts index 1e604bdaa0..715fe1c32c 100644 --- a/dexs/cone/index.ts +++ b/dexs/cone/index.ts @@ -5,6 +5,6 @@ const endpoints = { [CHAIN.BSC]: "https://api.thegraph.com/subgraphs/name/cone-exchange/cone", }; const adapter = univ2Adapter(endpoints, {}); -adapter.adapter.bsc.start = async () => 1626677527; +adapter.adapter.bsc.start = 1626677527; export default adapter diff --git a/dexs/croswap/index.ts b/dexs/croswap/index.ts index ec4d4c275d..c3c2b0f2b8 100644 --- a/dexs/croswap/index.ts +++ b/dexs/croswap/index.ts @@ -14,6 +14,6 @@ const adapters = univ2Adapter({ dayData: "uniswapDayData" }); -adapters.adapter.cronos.start = async () => 1664409600; +adapters.adapter.cronos.start = 1664409600; adapters.adapter[DISABLED_ADAPTER_KEY] = disabledAdapter; export default adapters; diff --git a/dexs/dao-swap/index.ts b/dexs/dao-swap/index.ts index ced9b0be7c..f78bdcaf51 100644 --- a/dexs/dao-swap/index.ts +++ b/dexs/dao-swap/index.ts @@ -7,5 +7,5 @@ const adpters = univ2Adapter({ factoriesName: "pancakeFactories", dayData: "pancakeDayData", }); -adpters.adapter.bsc.start = async () => 1663921255; +adpters.adapter.bsc.start = 1663921255; export default adpters; diff --git a/dexs/defi-swap/index.ts b/dexs/defi-swap/index.ts index facc226902..78b5557ad7 100644 --- a/dexs/defi-swap/index.ts +++ b/dexs/defi-swap/index.ts @@ -9,6 +9,6 @@ const adapter = univ2Adapter({ dailyVolume: "dailyVolumeUSD", totalVolume: "totalVolumeUSD", }); -adapter.adapter.ethereum.start = async () => 1632268798; +adapter.adapter.ethereum.start = 1632268798; export default adapter; diff --git a/dexs/dfx-finance/index.ts b/dexs/dfx-finance/index.ts index e6a9c5ab2f..668e4ac35f 100644 --- a/dexs/dfx-finance/index.ts +++ b/dexs/dfx-finance/index.ts @@ -9,6 +9,6 @@ const adapter = univ2Adapter({ dayData: "dfxdayData", dailyVolume: "dailyVolumeUSD" }); -adapter.adapter.ethereum.start = async () => 1621418717; -adapter.adapter.polygon.start = async () => 1626861917; +adapter.adapter.ethereum.start = 1621418717; +adapter.adapter.polygon.start = 1626861917; export default adapter; diff --git a/dexs/dinosaur-eggs/index.ts b/dexs/dinosaur-eggs/index.ts index e3f341b8e5..6715a45d2a 100644 --- a/dexs/dinosaur-eggs/index.ts +++ b/dexs/dinosaur-eggs/index.ts @@ -7,5 +7,5 @@ const adapters = univ2Adapter({ factoriesName: "swapFactories", dayData: "swapDayData" }); -adapters.adapter.bsc.start = async () => 1633046917; +adapters.adapter.bsc.start = 1633046917; export default adapters; diff --git a/dexs/dystopia/index.ts b/dexs/dystopia/index.ts index e630866e6b..87a2d83321 100644 --- a/dexs/dystopia/index.ts +++ b/dexs/dystopia/index.ts @@ -4,5 +4,5 @@ import { univ2Adapter } from "../../helpers/getUniSubgraphVolume"; const adapters = univ2Adapter({ [CHAIN.POLYGON]: "https://api.thegraph.com/subgraphs/name/dystopia-exchange/dystopia" }, {}); -adapters.adapter.polygon.start = async () => 1652932015; +adapters.adapter.polygon.start = 1652932015; export default adapters; diff --git a/dexs/echodex-v3/index.ts b/dexs/echodex-v3/index.ts index facfa2d3d7..fe29a2a89e 100644 --- a/dexs/echodex-v3/index.ts +++ b/dexs/echodex-v3/index.ts @@ -10,5 +10,5 @@ const adapters = univ2Adapter({ }); -adapters.adapter.linea.start = async () => 1691107200; +adapters.adapter.linea.start = 1691107200; export default adapters; diff --git a/dexs/echodex/index.ts b/dexs/echodex/index.ts index 081ab40388..d35b52c792 100644 --- a/dexs/echodex/index.ts +++ b/dexs/echodex/index.ts @@ -10,5 +10,5 @@ const adapters = univ2Adapter({ }); -adapters.adapter.linea.start = async () => 1689638400; +adapters.adapter.linea.start = 1689638400; export default adapters; diff --git a/dexs/elk/index.ts b/dexs/elk/index.ts index c012254118..6f46a386ed 100644 --- a/dexs/elk/index.ts +++ b/dexs/elk/index.ts @@ -24,19 +24,19 @@ const adapter = univ2Adapter({ dayData: "elkDayData", }); -adapter.adapter.arbitrum.start = async () => 1648950817; -adapter.adapter.avax.start = async () => 1616118817; -adapter.adapter.bsc.start = async () => 1629251617; -adapter.adapter.fantom.start = async () => 1621562017; -adapter.adapter.polygon.start = async () => 1618019617; -adapter.adapter.xdai.start = async () => 1629251617; -adapter.adapter.elastos.start = async () => 1634954017; -adapter.adapter.okexchain.start = async () => 1649555617; -adapter.adapter.kcc.start = async () => 1634954017; -adapter.adapter.ethereum.start = async () => 1619747617; -adapter.adapter.optimism.start = async () => 1651542817; -adapter.adapter.fuse.start = async () => 1639187617; -adapter.adapter.iotex.start = async () => 1639792417; -adapter.adapter.telos.start = async () => 1648684800; +adapter.adapter.arbitrum.start = 1648950817; +adapter.adapter.avax.start = 1616118817; +adapter.adapter.bsc.start = 1629251617; +adapter.adapter.fantom.start = 1621562017; +adapter.adapter.polygon.start = 1618019617; +adapter.adapter.xdai.start = 1629251617; +adapter.adapter.elastos.start = 1634954017; +adapter.adapter.okexchain.start = 1649555617; +adapter.adapter.kcc.start = 1634954017; +adapter.adapter.ethereum.start = 1619747617; +adapter.adapter.optimism.start = 1651542817; +adapter.adapter.fuse.start = 1639187617; +adapter.adapter.iotex.start = 1639792417; +adapter.adapter.telos.start = 1648684800; export default adapter; diff --git a/dexs/fathom-dex/index.ts b/dexs/fathom-dex/index.ts index f1dcf65c82..cc414d2931 100644 --- a/dexs/fathom-dex/index.ts +++ b/dexs/fathom-dex/index.ts @@ -9,5 +9,5 @@ const adapters = univ2Adapter({ }); -adapters.adapter.xdc.start = async () => 1682640000; +adapters.adapter.xdc.start = 1682640000; export default adapters; diff --git a/dexs/gin-finance/index.ts b/dexs/gin-finance/index.ts index 93cb7bae56..190adabb61 100644 --- a/dexs/gin-finance/index.ts +++ b/dexs/gin-finance/index.ts @@ -6,5 +6,5 @@ const adapters = univ2Adapter({ }, { }); -adapters.adapter.boba.start = async () => 1653525524; +adapters.adapter.boba.start = 1653525524; export default adapters; diff --git a/dexs/glide-finance/index.ts b/dexs/glide-finance/index.ts index 013c6c665c..77e657e0c0 100644 --- a/dexs/glide-finance/index.ts +++ b/dexs/glide-finance/index.ts @@ -7,5 +7,5 @@ const adapters = univ2Adapter({ factoriesName: "glideFactories", dayData: "glideDayData" }); -adapters.adapter.elastos.start = async () => 1635479215; +adapters.adapter.elastos.start = 1635479215; export default adapters; diff --git a/dexs/gravis/index.ts b/dexs/gravis/index.ts index ad8cc3d5b8..05e791244d 100644 --- a/dexs/gravis/index.ts +++ b/dexs/gravis/index.ts @@ -8,6 +8,6 @@ const adapters = univ2Adapter({ }, { }); -adapters.adapter.polygon.start = async () => 1622766258; -adapters.adapter.bsc.start = async () => 1620174258; +adapters.adapter.polygon.start = 1622766258; +adapters.adapter.bsc.start = 1620174258; export default adapters; diff --git a/dexs/gravity-finance/index.ts b/dexs/gravity-finance/index.ts index 5897c72038..cdf8f9323a 100644 --- a/dexs/gravity-finance/index.ts +++ b/dexs/gravity-finance/index.ts @@ -7,5 +7,5 @@ const adapters = univ2Adapter({ }, { }); -adapters.adapter.polygon.start = async () => 1629419058; +adapters.adapter.polygon.start = 1629419058; export default adapters; diff --git a/dexs/hiveswap/index.ts b/dexs/hiveswap/index.ts index 59744de9df..a12c3e816f 100644 --- a/dexs/hiveswap/index.ts +++ b/dexs/hiveswap/index.ts @@ -7,6 +7,6 @@ const endpoints = { const adapter = univ2Adapter(endpoints, {}); -adapter.adapter.map.start = async () => 1657929600; +adapter.adapter.map.start = 1657929600; export default adapter diff --git a/dexs/honeyswap/index.ts b/dexs/honeyswap/index.ts index 31aa9d6337..24d58bcf3f 100644 --- a/dexs/honeyswap/index.ts +++ b/dexs/honeyswap/index.ts @@ -8,7 +8,7 @@ const adapters = univ2Adapter({ factoriesName: "honeyswapFactories", dayData: "honeyswapDayData", }); -adapters.adapter.polygon.start = async () => 1622173831; -adapters.adapter.xdai.start = async () => 1599191431; +adapters.adapter.polygon.start = 1622173831; +adapters.adapter.xdai.start = 1599191431; export default adapters; diff --git a/dexs/horizondex/index.ts b/dexs/horizondex/index.ts index 64a929f4c2..26507eb896 100644 --- a/dexs/horizondex/index.ts +++ b/dexs/horizondex/index.ts @@ -11,7 +11,7 @@ const adapters = univ2Adapter({ totalVolume: "totalVolumeUSD", }); -adapters.adapter.linea.start = async () => 1689373614; -adapters.adapter.base.start = async () => 1690894800; +adapters.adapter.linea.start = 1689373614; +adapters.adapter.base.start = 1690894800; export default adapters; diff --git a/dexs/hummus/index.ts b/dexs/hummus/index.ts index 1e71a712bc..a4e3503a30 100644 --- a/dexs/hummus/index.ts +++ b/dexs/hummus/index.ts @@ -10,7 +10,6 @@ const fetch: any = async (timestamp: number, _, { getLogs, createBalances, toTim const dailyVolume = createBalances(); const logs: any[] = await getLogs({ target: "0x248fD66e6ED1E0B325d7b80F5A7e7d8AA2b2528b", eventAbi: abi_event.swap, }) - console.log(logs, logs.length) logs.forEach((log: any) => dailyVolume.add(log.toToken, Number(log.toAmount))); return { dailyVolume, timestamp: toTimestamp, }; diff --git a/dexs/hydradex/index.ts b/dexs/hydradex/index.ts index 98e7c041f9..e422a69461 100644 --- a/dexs/hydradex/index.ts +++ b/dexs/hydradex/index.ts @@ -8,6 +8,7 @@ import { DEFAULT_DAILY_VOLUME_FACTORY, DEFAULT_TOTAL_VOLUME_FIELD, DEFAULT_DAILY_VOLUME_FIELD, + wrapGraphError, } from '../../helpers/getUniSubgraph'; import request, { gql } from 'graphql-request'; import disabledAdapter from '../../helpers/disabledAdapter'; @@ -24,20 +25,23 @@ const VOLUME_USD = 'volumeUSD'; const FEES_USD = 'feesUSD'; const getV2CustomBlock = async (timestamp: number) => { - const blockGraphQuery = gql` + const blockGraphQuery = ` query get_block { blocks(orderBy: "height", first: 1, orderDirection: "desc", where: { timestamp_lte: ${timestamp} }) { number } } `; - - const blocks = (await request(v2Endpoints[CHAIN.HYDRA], blockGraphQuery)).blocks; - return Number(blocks[0].number); + try { + const blocks = (await request(v2Endpoints[CHAIN.HYDRA], blockGraphQuery)).blocks; + return Number(blocks[0].number); + } catch (e) { + throw new Error(`Error getting block: ${CHAIN.HYDRA} ${timestamp} ${wrapGraphError(e).message}`) + } }; const getV3CustomBlock = async (timestamp: number) => { - const blockGraphQuery = gql` + const blockGraphQuery = ` query get_block { blocks(orderBy: "number", first: 1, orderDirection: "desc", where: { timestamp_lte: ${timestamp} }) { number @@ -45,10 +49,14 @@ const getV3CustomBlock = async (timestamp: number) => { } `; - const blocks = ( - await request('https://graph.hydradex.org/subgraphs/name/blocklytics/ethereum-blocks', blockGraphQuery) - ).blocks; - return Number(blocks[0].number); + try { + const blocks = ( + await request('https://graph.hydradex.org/subgraphs/name/blocklytics/ethereum-blocks', blockGraphQuery) + ).blocks; + return Number(blocks[0].number); + } catch (e) { + throw new Error(`Error getting block: ${CHAIN.HYDRA} ${timestamp} ${wrapGraphError(e).message}`) + } }; const v2Graph = getGraphDimensions({ diff --git a/dexs/hyperjump/index.ts b/dexs/hyperjump/index.ts index 94560ec67b..9cb50847cd 100644 --- a/dexs/hyperjump/index.ts +++ b/dexs/hyperjump/index.ts @@ -10,6 +10,6 @@ const adapter = univ2Adapter(endpoints, { dayData: "thugswapDayData", }); -adapter.adapter.bsc.start = async () => 1605139200; +adapter.adapter.bsc.start = 1605139200; export default adapter diff --git a/dexs/icecreamswap/index.ts b/dexs/icecreamswap/index.ts index 45f6e3d604..5f5f44bb12 100644 --- a/dexs/icecreamswap/index.ts +++ b/dexs/icecreamswap/index.ts @@ -10,7 +10,7 @@ const adapters = univ2Adapter({ factoriesName: "pancakeFactories", dayData: "pancakeDayData" }); -adapters.adapter.bitgert.start = async () => 1655917200; -adapters.adapter.core.start = async () => 1675814400; +adapters.adapter.bitgert.start = 1655917200; +adapters.adapter.core.start = 1675814400; adapters.adapter[DISABLED_ADAPTER_KEY] = disabledAdapter; export default adapters; diff --git a/dexs/jibswap/index.ts b/dexs/jibswap/index.ts index c0e0082e5f..a37dad0986 100644 --- a/dexs/jibswap/index.ts +++ b/dexs/jibswap/index.ts @@ -5,6 +5,6 @@ const adapters = univ2Adapter({ [CHAIN.JBC]: "https://graph.jibswap.com/subgraphs/name/jibswap", }, {}); -adapters.adapter.jbc.start = async () => 1702494791; +adapters.adapter.jbc.start = 1702494791; export default adapters; diff --git a/dexs/kyberswap/index.ts b/dexs/kyberswap/index.ts index 81f87c9f69..0a3143b8d4 100644 --- a/dexs/kyberswap/index.ts +++ b/dexs/kyberswap/index.ts @@ -34,16 +34,16 @@ const kyberswapElasticV2 = univ2Adapter({ totalVolume: "totalVolumeUSD", }); -kyberswapElasticV2.adapter.ethereum.start = async () => 1654905600; -kyberswapElasticV2.adapter.bsc.start = async () => 1654732800; -kyberswapElasticV2.adapter.polygon.start = async () => 1654732800; -kyberswapElasticV2.adapter.avax.start = async () => 1654905600; -kyberswapElasticV2.adapter.arbitrum.start = async () => 1655942400; -kyberswapElasticV2.adapter.optimism.start = async () => 1656460800; -kyberswapElasticV2.adapter.fantom.start = async () => 1654732800; -kyberswapElasticV2.adapter.bittorrent.start = async () => 1658188800; -kyberswapElasticV2.adapter.oasis.start = async () => 1660780800; -kyberswapElasticV2.adapter.cronos.start = async () => 1660780800; +kyberswapElasticV2.adapter.ethereum.start = 1654905600; +kyberswapElasticV2.adapter.bsc.start = 1654732800; +kyberswapElasticV2.adapter.polygon.start = 1654732800; +kyberswapElasticV2.adapter.avax.start = 1654905600; +kyberswapElasticV2.adapter.arbitrum.start = 1655942400; +kyberswapElasticV2.adapter.optimism.start = 1656460800; +kyberswapElasticV2.adapter.fantom.start = 1654732800; +kyberswapElasticV2.adapter.bittorrent.start = 1658188800; +kyberswapElasticV2.adapter.oasis.start = 1660780800; +kyberswapElasticV2.adapter.cronos.start = 1660780800; // velas, oasis & bittorrent missing const elasticChains = ["ethereum", "polygon", "bsc", "avax", "fantom", "arbitrum", "optimism"] diff --git a/dexs/kyotoswap/index.ts b/dexs/kyotoswap/index.ts index 5731021e78..b9d753b521 100644 --- a/dexs/kyotoswap/index.ts +++ b/dexs/kyotoswap/index.ts @@ -11,5 +11,5 @@ const adapters = univ2Adapter( dayData: "pancakeDayData", } ); -adapters.adapter.bsc.start = async () => 1670113423; +adapters.adapter.bsc.start = 1670113423; export default adapters; diff --git a/dexs/levinswap/index.ts b/dexs/levinswap/index.ts index 1f623fb5bf..deb16b80fd 100644 --- a/dexs/levinswap/index.ts +++ b/dexs/levinswap/index.ts @@ -5,5 +5,5 @@ const adapters = univ2Adapter({ [CHAIN.XDAI]: "https://api.thegraph.com/subgraphs/name/levinswap/uniswap-v2" }, {}); -adapters.adapter.xdai.start = async () => 1610767793; +adapters.adapter.xdai.start = 1610767793; export default adapters; diff --git a/dexs/litx/index.ts b/dexs/litx/index.ts index 897d6e0791..dc6bba5367 100644 --- a/dexs/litx/index.ts +++ b/dexs/litx/index.ts @@ -13,7 +13,7 @@ const adapters = univ2Adapter({ totalVolume: "totalVolumeUSD", }); -adapters.adapter.bsc.start = async () => 1687305600; -adapters.adapter.pulse.start = async () => 1686096000; +adapters.adapter.bsc.start = 1687305600; +adapters.adapter.pulse.start = 1686096000; adapters.adapter[DISABLED_ADAPTER_KEY] = disabledAdapter; export default adapters; diff --git a/dexs/lynex/index.ts b/dexs/lynex/index.ts index e74c57e44b..aebddd92b1 100644 --- a/dexs/lynex/index.ts +++ b/dexs/lynex/index.ts @@ -10,5 +10,5 @@ const adapters = univ2Adapter({ totalVolume: "totalVolumeUSD", }); -adapters.adapter.linea.start = async () => 1691394680; +adapters.adapter.linea.start = 1691394680; export default adapters; diff --git a/dexs/merlin/index.ts b/dexs/merlin/index.ts index c0fc68e5d1..2d38bdad1a 100644 --- a/dexs/merlin/index.ts +++ b/dexs/merlin/index.ts @@ -5,5 +5,5 @@ const adapters = univ2Adapter({ [CHAIN.ERA]: "https://api.studio.thegraph.com/query/45654/merlin-subgraph/v0.1.0" }, {}); -adapters.adapter.era.start = async () => 1680274800; +adapters.adapter.era.start = 1680274800; export default adapters; diff --git a/dexs/metropolis/index.ts b/dexs/metropolis/index.ts index 6199f790a4..3f24a1dd6b 100644 --- a/dexs/metropolis/index.ts +++ b/dexs/metropolis/index.ts @@ -15,7 +15,7 @@ const adapter = univ2Adapter(endpoints, { dailyVolumeTimestampField: "date" }); -adapter.adapter.fantom.start = async () => 1673827200; +adapter.adapter.fantom.start = 1673827200; // Metropolis was acquired by Swapline. // Currently, both adapters (tvl) are the same code. diff --git a/dexs/mistswap/index.ts b/dexs/mistswap/index.ts index 00b820968f..4d34cc45de 100644 --- a/dexs/mistswap/index.ts +++ b/dexs/mistswap/index.ts @@ -13,6 +13,6 @@ const adapters = univ2Adapter({ dailyVolumeTimestampField: "date" }); -adapters.adapter.smartbch.start = async () => 1633220803; +adapters.adapter.smartbch.start = 1633220803; adapters.adapter[DISABLED_ADAPTER_KEY] = disabledAdapter; export default adapters; diff --git a/dexs/mm-finance-arbitrum/index.ts b/dexs/mm-finance-arbitrum/index.ts index af66186cdb..fe45da6eea 100644 --- a/dexs/mm-finance-arbitrum/index.ts +++ b/dexs/mm-finance-arbitrum/index.ts @@ -10,6 +10,6 @@ const adapter = univ2Adapter(endpoints, { dayData: "pancakeDayData", }); -adapter.adapter.arbitrum.start = async () => 1680134400; +adapter.adapter.arbitrum.start = 1680134400; export default adapter diff --git a/dexs/mojitoswap/index.ts b/dexs/mojitoswap/index.ts index 28480d48cc..031d0b59e0 100644 --- a/dexs/mojitoswap/index.ts +++ b/dexs/mojitoswap/index.ts @@ -12,6 +12,6 @@ const adapter = univ2Adapter(endpoints, { totalVolume: "totalVolumeUSD" }); -adapter.adapter.kcc.start = async () => 1634200191; +adapter.adapter.kcc.start = 1634200191; export default adapter diff --git a/dexs/monocerus/index.ts b/dexs/monocerus/index.ts index e2f6ec6a00..3d5e9b6420 100644 --- a/dexs/monocerus/index.ts +++ b/dexs/monocerus/index.ts @@ -37,7 +37,7 @@ const adapter: Adapter = { [DISABLED_ADAPTER_KEY]: disabledAdapter, [CHAIN.MANTA]: { fetch: v3Graphs(CHAIN.MANTA), - start: async () => 1703548800 + start: 1703548800 } } }; diff --git a/dexs/morpheus-swap/index.ts b/dexs/morpheus-swap/index.ts index 11f29c08fc..6e2145f448 100644 --- a/dexs/morpheus-swap/index.ts +++ b/dexs/morpheus-swap/index.ts @@ -9,5 +9,5 @@ const adapters = univ2Adapter({ gasToken: "coingecko:fantom" }); -adapters.adapter.fantom.start = async () => 1636106400; +adapters.adapter.fantom.start = 1636106400; export default adapters; diff --git a/dexs/muesliswap/index.ts b/dexs/muesliswap/index.ts index 4799bb2ff2..f580b8b38c 100644 --- a/dexs/muesliswap/index.ts +++ b/dexs/muesliswap/index.ts @@ -44,5 +44,5 @@ const adapters = (() => { })(); -adapters.adapter.milkomeda.start = async () => 1648427924; +adapters.adapter.milkomeda.start = 1648427924; export default adapters; diff --git a/dexs/mute.io/index.ts b/dexs/mute.io/index.ts index d8ba78c3d2..2ef992c945 100644 --- a/dexs/mute.io/index.ts +++ b/dexs/mute.io/index.ts @@ -13,6 +13,6 @@ const adapter = univ2Adapter(endpoints, { dailyVolumeTimestampField: "date", }); -adapter.adapter.era.start = async () => 1679529600 +adapter.adapter.era.start = 1679529600 export default adapter diff --git a/dexs/nether-fi/index.ts b/dexs/nether-fi/index.ts index a159a8a4e7..74913bf537 100644 --- a/dexs/nether-fi/index.ts +++ b/dexs/nether-fi/index.ts @@ -4,7 +4,7 @@ import { CHAIN } from "../../helpers/chains"; import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; const graphEndpoint = "https://api.studio.thegraph.com/query/51510/nefi-base-mainnet-stats/version/latest"; -const startTimestamp = async () => 1693526400; +const startTimestamp = 1693526400; const historicalDataSwap = gql` query get_volume($period: String!, $id: String!) { diff --git a/dexs/netswap/index.ts b/dexs/netswap/index.ts index 0dc9f3a1dd..6ae6295fc4 100644 --- a/dexs/netswap/index.ts +++ b/dexs/netswap/index.ts @@ -7,5 +7,5 @@ const adapters = univ2Adapter({ factoriesName: "netswapFactories", dayData: "netswapDayData" }); -adapters.adapter.metis.start = async () => 1638760703; +adapters.adapter.metis.start = 1638760703; export default adapters; diff --git a/dexs/onepunch/index.ts b/dexs/onepunch/index.ts index 6a3dd4ab60..0bdfee5cd1 100644 --- a/dexs/onepunch/index.ts +++ b/dexs/onepunch/index.ts @@ -14,6 +14,6 @@ const adapters = univ2Adapter( hasTotalVolume: true, } ); -adapters.adapter.bsc.start = async () => 1671580800; +adapters.adapter.bsc.start = 1671580800; export default adapters; diff --git a/dexs/oolongswap/index.ts b/dexs/oolongswap/index.ts index 17a2426069..96f993bbe7 100644 --- a/dexs/oolongswap/index.ts +++ b/dexs/oolongswap/index.ts @@ -7,6 +7,6 @@ const endpoints = { const adapter = univ2Adapter(endpoints, {}); -adapter.adapter.boba.start = async () => 1635938988; +adapter.adapter.boba.start = 1635938988; export default adapter diff --git a/dexs/padswap/index.ts b/dexs/padswap/index.ts index 436cd5f9bc..3e36bf7737 100644 --- a/dexs/padswap/index.ts +++ b/dexs/padswap/index.ts @@ -7,7 +7,7 @@ const adapters = univ2Adapter({ [CHAIN.MOONBEAN]: 'https://api.thegraph.com/subgraphs/name/toadguy/padswap-subgraph-moonbeam', }, {}); -adapters.adapter.bsc.start = async () => 1620518400; -// adapters.adapter.moonriver.start = async () => 1635638400; -adapters.adapter.moonbeam.start = async () => 1642032000; +adapters.adapter.bsc.start = 1620518400; +// adapters.adapter.moonriver.start = 1635638400; +adapters.adapter.moonbeam.start = 1642032000; export default adapters; diff --git a/dexs/pandora/index.ts b/dexs/pandora/index.ts index 94630fddfd..af8379b73b 100644 --- a/dexs/pandora/index.ts +++ b/dexs/pandora/index.ts @@ -8,5 +8,5 @@ const adapters = univ2Adapter({ dayData: "pandoraDayData", }); -adapters.adapter.bsc.start = async () => 1652757593; +adapters.adapter.bsc.start = 1652757593; export default adapters; diff --git a/dexs/pharaoh-exchange/index.ts b/dexs/pharaoh-exchange/index.ts index 75411124b8..58485e68cb 100644 --- a/dexs/pharaoh-exchange/index.ts +++ b/dexs/pharaoh-exchange/index.ts @@ -10,5 +10,5 @@ const adapters = univ2Adapter({ totalVolume: "totalVolumeUSD", }); -adapters.adapter.avax.start = async () => 1702339200; +adapters.adapter.avax.start = 1702339200; export default adapters; diff --git a/dexs/pulsex-v2/index.ts b/dexs/pulsex-v2/index.ts index 7f6aeaa764..8c2ca1150d 100644 --- a/dexs/pulsex-v2/index.ts +++ b/dexs/pulsex-v2/index.ts @@ -8,6 +8,6 @@ const adapters = univ2Adapter({ dayData: "pulsexDayData", }); -adapters.adapter.pulse.start = async () => 1685577600; +adapters.adapter.pulse.start = 1685577600; export default adapters; diff --git a/dexs/pyeswap/index.ts b/dexs/pyeswap/index.ts index 220a4bb1df..9327367f8d 100644 --- a/dexs/pyeswap/index.ts +++ b/dexs/pyeswap/index.ts @@ -7,5 +7,5 @@ const adapter = univ2Adapter({ factoriesName: "pyeFactories", dayData: "pyeDayData", }); -adapter.adapter.bsc.start = async () => 1660893036; +adapter.adapter.bsc.start = 1660893036; export default adapter; diff --git a/dexs/ramses-exchange-v2/index.ts b/dexs/ramses-exchange-v2/index.ts index 865a490b6c..16d81e682c 100644 --- a/dexs/ramses-exchange-v2/index.ts +++ b/dexs/ramses-exchange-v2/index.ts @@ -10,5 +10,5 @@ const adapters = univ2Adapter({ totalVolume: "totalVolumeUSD", }); -adapters.adapter.arbitrum.start = async () => 1685574000; +adapters.adapter.arbitrum.start = 1685574000; export default adapters; diff --git a/dexs/rubicon/index.ts b/dexs/rubicon/index.ts index b7b7a356fc..72f077d461 100644 --- a/dexs/rubicon/index.ts +++ b/dexs/rubicon/index.ts @@ -12,6 +12,6 @@ const adapters = univ2Adapter({ dailyVolumeTimestampField: "dayStartUnix" }); -adapters.adapter.arbitrum.start = async () => 1686345120; -adapters.adapter.optimism.start = async () => 1637020800; +adapters.adapter.arbitrum.start = 1686345120; +adapters.adapter.optimism.start = 1637020800; export default adapters; \ No newline at end of file diff --git a/dexs/satoshiswap/index.ts b/dexs/satoshiswap/index.ts index 5b983a7240..ca59be2b8a 100644 --- a/dexs/satoshiswap/index.ts +++ b/dexs/satoshiswap/index.ts @@ -13,6 +13,6 @@ const adapter = univ2Adapter(endpoints, { dayData: "pancakeDayData", }); -adapter.adapter.core.start = async()=> 1680825600; +adapter.adapter.core.start = 1680825600; adapter.adapter[DISABLED_ADAPTER_KEY] = disabledAdapter; export default adapter diff --git a/dexs/shibaswap/index.ts b/dexs/shibaswap/index.ts index dc1205ffb1..c2d236b3c0 100644 --- a/dexs/shibaswap/index.ts +++ b/dexs/shibaswap/index.ts @@ -12,6 +12,6 @@ const adapter = univ2Adapter(endpoints, { totalVolume: "volumeUSD" }); -adapter.adapter.ethereum.start = async () => 1625566975; +adapter.adapter.ethereum.start = 1625566975; export default adapter diff --git a/dexs/solarbeam/index.ts b/dexs/solarbeam/index.ts index 2dcd6aaf26..be229ca2ed 100644 --- a/dexs/solarbeam/index.ts +++ b/dexs/solarbeam/index.ts @@ -6,5 +6,5 @@ const adapter = univ2Adapter({ },{ hasTotalVolume: false, }); -adapter.adapter.moonriver.start = async () => 1630903340; +adapter.adapter.moonriver.start = 1630903340; export default adapter; diff --git a/dexs/solarflare/index.ts b/dexs/solarflare/index.ts index 8bd3b541a9..9c2c0167fc 100644 --- a/dexs/solarflare/index.ts +++ b/dexs/solarflare/index.ts @@ -5,5 +5,5 @@ import { univ2Adapter } from "../../helpers/getUniSubgraphVolume"; const adapter = univ2Adapter({ [CHAIN.MOONBEAM]: "https://api.thegraph.com/subgraphs/name/solarbeamio/solarflare-subgraph" },{}); -adapter.adapter.moonbeam.start = async () => 1642032000; +adapter.adapter.moonbeam.start = 1642032000; export default adapter; diff --git a/dexs/solidlizard/index.ts b/dexs/solidlizard/index.ts index aff48d27d0..8a224b637e 100644 --- a/dexs/solidlizard/index.ts +++ b/dexs/solidlizard/index.ts @@ -7,6 +7,6 @@ const endpoints = { const adapter = univ2Adapter(endpoints, {}); -adapter.adapter.arbitrum.start = async()=> 1675036800; +adapter.adapter.arbitrum.start = 1675036800; export default adapter diff --git a/dexs/solidly-v3/index.ts b/dexs/solidly-v3/index.ts index 0c6d7a6c37..24e9d98704 100644 --- a/dexs/solidly-v3/index.ts +++ b/dexs/solidly-v3/index.ts @@ -14,5 +14,5 @@ const adapters = univ2Adapter({ totalVolume: "totalVolumeUSD", }); -adapters.adapter.ethereum.start = async () => 1693526400; +adapters.adapter.ethereum.start = 1693526400; export default adapters; diff --git a/dexs/solidlydex/index.ts b/dexs/solidlydex/index.ts index f200d4d2c8..329e8ac946 100644 --- a/dexs/solidlydex/index.ts +++ b/dexs/solidlydex/index.ts @@ -7,6 +7,6 @@ const endpoints = { const adapter = univ2Adapter(endpoints, {}); -adapter.adapter.ethereum.start = async()=> 1672444800; +adapter.adapter.ethereum.start = 1672444800; export default adapter diff --git a/dexs/soy-finance/index.ts b/dexs/soy-finance/index.ts index aa9bc7c9f4..ae41fedcaa 100644 --- a/dexs/soy-finance/index.ts +++ b/dexs/soy-finance/index.ts @@ -7,6 +7,6 @@ const adapters = univ2Adapter({ factoriesName: "soySwapFactories", dayData: "soySwapDayData", }); -adapters.adapter.callisto.start = async () => 1634699765; +adapters.adapter.callisto.start = 1634699765; export default adapters; diff --git a/dexs/spartacus-exchange/index.ts b/dexs/spartacus-exchange/index.ts index 5a7aef98d7..d252541a60 100644 --- a/dexs/spartacus-exchange/index.ts +++ b/dexs/spartacus-exchange/index.ts @@ -5,6 +5,6 @@ const endpoints = { [CHAIN.FANTOM]: "https://api.thegraph.com/subgraphs/name/spartacus-finance/spadexinfo", }; const adapter = univ2Adapter(endpoints, {"gasToken" : "coingecko:fantom"}); -adapter.adapter.fantom.start = async () => 1650883041; +adapter.adapter.fantom.start = 1650883041; export default adapter diff --git a/dexs/spookyswap/index.ts b/dexs/spookyswap/index.ts index 155b13adf4..0635d1441d 100644 --- a/dexs/spookyswap/index.ts +++ b/dexs/spookyswap/index.ts @@ -42,7 +42,7 @@ const adapter: SimpleAdapter = { }, [CHAIN.EON]: { fetch: graphsV3(CHAIN.EON), - start: async () => 1698969600 + start: 1698969600 }, }, }; diff --git a/dexs/stellaswap-v3/index.ts b/dexs/stellaswap-v3/index.ts index 31c0701a5c..75d2ec79f4 100644 --- a/dexs/stellaswap-v3/index.ts +++ b/dexs/stellaswap-v3/index.ts @@ -10,5 +10,5 @@ const adapters = univ2Adapter({ dailyVolume: "volumeUSD", totalVolume: "totalVolumeUSD", }); -adapters.adapter.moonbeam.start = async () => 1672876800; +adapters.adapter.moonbeam.start = 1672876800; export default adapters; diff --git a/dexs/stellaswap/index.ts b/dexs/stellaswap/index.ts index 3f5f30580c..b4bf383148 100644 --- a/dexs/stellaswap/index.ts +++ b/dexs/stellaswap/index.ts @@ -4,5 +4,5 @@ import { univ2Adapter } from "../../helpers/getUniSubgraphVolume"; const adapters = univ2Adapter({ [CHAIN.MOONBEAN]: "https://api.thegraph.com/subgraphs/name/stellaswap/stella-swap" }, {}); -adapters.adapter.moonbeam.start = async () => 1641960253; +adapters.adapter.moonbeam.start = 1641960253; export default adapters; diff --git a/dexs/subzero-zswap/index.ts b/dexs/subzero-zswap/index.ts index 4664814a24..74e36393f0 100644 --- a/dexs/subzero-zswap/index.ts +++ b/dexs/subzero-zswap/index.ts @@ -12,6 +12,6 @@ const adapter = univ2Adapter(endpoints, { totalVolume: "totalVolumeUSD" }); -adapter.adapter.avax.start = async()=> 1675814400; +adapter.adapter.avax.start = 1675814400; export default adapter diff --git a/dexs/sushiswap/classic.ts b/dexs/sushiswap/classic.ts index 5ca3c99574..dd67edfb45 100644 --- a/dexs/sushiswap/classic.ts +++ b/dexs/sushiswap/classic.ts @@ -163,7 +163,7 @@ classic[CHAIN.FANTOM] = { dailyRevenue: vol * 0.003, } }, - start: async() => 0 + start: 0 } export default classic diff --git a/dexs/syncswap/index.ts b/dexs/syncswap/index.ts index 0280f63d22..e3333d2b5c 100644 --- a/dexs/syncswap/index.ts +++ b/dexs/syncswap/index.ts @@ -13,6 +13,6 @@ const adapter = univ2Adapter(endpoints, { dailyVolumeTimestampField: "date", }); -adapter.adapter.era.start = async () => 1679529600 +adapter.adapter.era.start = 1679529600 export default adapter diff --git a/dexs/tetu/index.ts b/dexs/tetu/index.ts index 94f29a993c..4dcf6815dd 100644 --- a/dexs/tetu/index.ts +++ b/dexs/tetu/index.ts @@ -6,5 +6,5 @@ const adapters = univ2Adapter({ }, { }); -adapters.adapter.polygon.start = async () => 1634863038; +adapters.adapter.polygon.start = 1634863038; export default adapters; diff --git a/dexs/thena-v3/index.ts b/dexs/thena-v3/index.ts index a00181f829..813d85c7b8 100644 --- a/dexs/thena-v3/index.ts +++ b/dexs/thena-v3/index.ts @@ -10,5 +10,5 @@ const adapters = univ2Adapter({ totalVolume: "totalVolumeUSD", }); -adapters.adapter.bsc.start = async () => 1681516800; +adapters.adapter.bsc.start = 1681516800; export default adapters; diff --git a/dexs/thena/index.ts b/dexs/thena/index.ts index 826c6fee66..1f29106611 100644 --- a/dexs/thena/index.ts +++ b/dexs/thena/index.ts @@ -11,5 +11,5 @@ const adapters = univ2Adapter({ dailyVolumeTimestampField: "date" }); -adapters.adapter.bsc.start = async () => 1672790400; +adapters.adapter.bsc.start = 1672790400; export default adapters; diff --git a/dexs/titano-swych/index.ts b/dexs/titano-swych/index.ts index d486e8b61f..68a383a124 100644 --- a/dexs/titano-swych/index.ts +++ b/dexs/titano-swych/index.ts @@ -8,5 +8,5 @@ const adapters = univ2Adapter({ factoriesName: "pancakeFactories", dayData: "pancakeDayData", }); -adapters.adapter.bsc.start = async () => 1648005393; +adapters.adapter.bsc.start = 1648005393; export default adapters; diff --git a/dexs/tomb-swap/index.ts b/dexs/tomb-swap/index.ts index 46f91c7277..56d88ce453 100644 --- a/dexs/tomb-swap/index.ts +++ b/dexs/tomb-swap/index.ts @@ -7,6 +7,6 @@ const adapter = univ2Adapter({ gasToken: "coingecko:fantom" }); -adapter.adapter.fantom.start = async () => 1632268798; +adapter.adapter.fantom.start = 1632268798; export default adapter; diff --git a/dexs/ubeswap/index.ts b/dexs/ubeswap/index.ts index 530de0503d..c8c6fdf4ed 100644 --- a/dexs/ubeswap/index.ts +++ b/dexs/ubeswap/index.ts @@ -7,6 +7,6 @@ const adapters = univ2Adapter({ factoriesName: "ubeswapFactories", dayData: "ubeswapDayData", }); -adapters.adapter.celo.start = async () => 1614574153; +adapters.adapter.celo.start = 1614574153; export default adapters; diff --git a/dexs/ultronswap/index.ts b/dexs/ultronswap/index.ts index b3fdc53d39..ded8083046 100644 --- a/dexs/ultronswap/index.ts +++ b/dexs/ultronswap/index.ts @@ -4,5 +4,5 @@ import { univ2Adapter } from "../../helpers/getUniSubgraphVolume"; const adapters = univ2Adapter({ [CHAIN.ULTRON]: "https://graph-node.ultron-dev.net/subgraphs/name/root/ultronswap-exchange" }, {}); -adapters.adapter.ultron.start = async () => 1659323793; +adapters.adapter.ultron.start = 1659323793; export default adapters; diff --git a/dexs/vapordex/v1.ts b/dexs/vapordex/v1.ts index 18ee40809b..9c33b448a8 100644 --- a/dexs/vapordex/v1.ts +++ b/dexs/vapordex/v1.ts @@ -15,5 +15,5 @@ const v1 = univ2Adapter( } ); -v1.adapter.avax.start = async () => 1663545600; +v1.adapter.avax.start = 1663545600; export default v1.adapter; diff --git a/dexs/veniceswap/index.ts b/dexs/veniceswap/index.ts index 1b732e055b..d4735e6cde 100644 --- a/dexs/veniceswap/index.ts +++ b/dexs/veniceswap/index.ts @@ -12,7 +12,7 @@ const adapter = univ2Adapter(endpoints, { dayData: "veniceDayData", }); -adapter.adapter.findora.start = async() => 1675036800; +adapter.adapter.findora.start = 1675036800; adapter.adapter[DISABLED_ADAPTER_KEY] = disabledAdapter; export default adapter diff --git a/dexs/voodoo-trade/index.ts b/dexs/voodoo-trade/index.ts index 1ae8f327fc..d74147fdb1 100644 --- a/dexs/voodoo-trade/index.ts +++ b/dexs/voodoo-trade/index.ts @@ -67,7 +67,7 @@ const getFetch = (query: string): Fetch => async (timestamp: number) => { } } -const startTimestamp = async () => 1693997105; +const startTimestamp = 1693997105; const adapter: BreakdownAdapter = { breakdown: { diff --git a/dexs/vvs-finance/index.ts b/dexs/vvs-finance/index.ts index bd725127de..1375d9b330 100644 --- a/dexs/vvs-finance/index.ts +++ b/dexs/vvs-finance/index.ts @@ -7,6 +7,6 @@ const adapter = univ2Adapter({ dayData: "vvsDayData", }); -adapter.adapter.cronos.start = async()=> 1632035122; // 1 a year ago +adapter.adapter.cronos.start = 1632035122; // 1 a year ago export default adapter diff --git a/dexs/wagyuswap/index.ts b/dexs/wagyuswap/index.ts index abb31e37c8..41e143c113 100644 --- a/dexs/wagyuswap/index.ts +++ b/dexs/wagyuswap/index.ts @@ -9,6 +9,6 @@ const adapters = univ2Adapter({ factoriesName: "pancakeFactories", dayData: "pancakeDayData" }); -adapters.adapter.velas.start = async () => 1635653053; +adapters.adapter.velas.start = 1635653053; adapters.adapter[DISABLED_ADAPTER_KEY] = disabledAdapter; export default adapters; diff --git a/dexs/wanswap-dex/index.ts b/dexs/wanswap-dex/index.ts index e32ad8fe29..2ad409c563 100644 --- a/dexs/wanswap-dex/index.ts +++ b/dexs/wanswap-dex/index.ts @@ -7,6 +7,6 @@ const adapter = univ2Adapter({ factoriesName: "uniswapFactories", dayData: "uniswapDayData", }); -adapter.adapter.wan.start = async () => 1632268798; +adapter.adapter.wan.start = 1632268798; export default adapter; diff --git a/dexs/wigoswap/index.ts b/dexs/wigoswap/index.ts index a7e96fbdba..9ae91ed5fa 100644 --- a/dexs/wigoswap/index.ts +++ b/dexs/wigoswap/index.ts @@ -9,5 +9,5 @@ const adapters = univ2Adapter({ gasToken: "coingecko:fantom" }); -adapters.adapter.fantom.start = async () => 1642982400; +adapters.adapter.fantom.start = 1642982400; export default adapters; diff --git a/dexs/wingswap/index.ts b/dexs/wingswap/index.ts index 55a593206f..2311d6b911 100644 --- a/dexs/wingswap/index.ts +++ b/dexs/wingswap/index.ts @@ -11,6 +11,6 @@ const adapter = univ2Adapter(endpoints, { gasToken: "coingecko:fantom" }); -adapter.adapter.fantom.start = async () => 1637452800; +adapter.adapter.fantom.start = 1637452800; export default adapter diff --git a/dexs/yfx-v3/index.ts b/dexs/yfx-v3/index.ts index 819f59b1c0..4105a4ee98 100644 --- a/dexs/yfx-v3/index.ts +++ b/dexs/yfx-v3/index.ts @@ -43,12 +43,10 @@ interface IGraphResponse { const getFetch = (chain: string): Fetch => async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date((timestamp * 1000))) -// console.log(dayTimestamp, timestamp); const dailyData: IGraphResponse = await request(endpoints[chain], historicalDailyData, { dayTime: String(dayTimestamp), }) - //console.log('dailyData', chain, dailyData); let dailyVolume = 0; for(let i in dailyData.marketInfoDailies) { dailyVolume += parseFloat(dailyData.marketInfoDailies[i].totalVol) @@ -60,10 +58,6 @@ const getFetch = (chain: string): Fetch => async (timestamp: number) => { totalVolume += parseFloat(totalData.markets[i].totalVol) } - //console.log('totalData', chain, totalData); - - //console.log(dailyVolume, totalVolume); - return { timestamp: dayTimestamp, dailyVolume: dailyVolume.toString(), diff --git a/dexs/zebra-v1/index.ts b/dexs/zebra-v1/index.ts index 9568b900f0..2aa12f8bc0 100644 --- a/dexs/zebra-v1/index.ts +++ b/dexs/zebra-v1/index.ts @@ -9,6 +9,6 @@ const endpoints = { const adapter = univ2Adapter(endpoints, { }); -adapter.adapter.scroll.start = async () => 1698364800 +adapter.adapter.scroll.start = 1698364800 export default adapter diff --git a/dexs/zebra-v2/index.ts b/dexs/zebra-v2/index.ts index 088937f7e4..ac8bdc2e38 100644 --- a/dexs/zebra-v2/index.ts +++ b/dexs/zebra-v2/index.ts @@ -15,5 +15,5 @@ const adapter = univ2Adapter(endpoints, { dailyVolumeTimestampField: "date", }); -adapter.adapter.scroll.start = async () => 1700697600 +adapter.adapter.scroll.start = 1700697600 export default adapter diff --git a/dexs/zircon-gamma/index.ts b/dexs/zircon-gamma/index.ts index b71045351d..36fcf0f3e5 100644 --- a/dexs/zircon-gamma/index.ts +++ b/dexs/zircon-gamma/index.ts @@ -7,6 +7,6 @@ const endpoints = { const adapter = univ2Adapter(endpoints, {}); -adapter.adapter.moonriver.start = async()=> 1663200000; +adapter.adapter.moonriver.start = 1663200000; export default adapter diff --git a/fees/Scale.ts b/fees/Scale.ts index 2f0205419b..9bb04b6387 100644 --- a/fees/Scale.ts +++ b/fees/Scale.ts @@ -156,9 +156,6 @@ const fetch = async (timestamp: number): Promise => { const rawCoins = [...tokens0, ...tokens1, ...allBribedTokens].map((e: string) => `${CHAIN_SLUG}:${e}`); const coins = [...new Set(rawCoins)]; - // const prices = await getPrices(coins, timestamp); - // { getPrices } function breaks above 100 tokens..splitting into chunks of 100 - const coins_split: string[][] = []; for (let i = 0; i < coins.length; i += 100) { coins_split.push(coins.slice(i, i + 100)) @@ -208,7 +205,6 @@ const fetch = async (timestamp: number): Promise => { const _token = _log.args.reward; const _price = (prices[`${CHAIN_SLUG}:${_token}`]?.price || 0); const _deci = prices[`${CHAIN_SLUG}:${_token}`]?.decimals || 0; - //console.log("_log.args.from", _log.args.from); const amount = Number(p.data) / 10 ** _deci * _price; return { amount } as IAmountUSD }) as IAmountUSD[]; diff --git a/fees/aave/index.ts b/fees/aave/index.ts index 817d0a758a..f06a031364 100644 --- a/fees/aave/index.ts +++ b/fees/aave/index.ts @@ -406,51 +406,51 @@ const adapter: Adapter = { v1: { [ETHEREUM]: { fetch: v1Graphs(v1Endpoints)(ETHEREUM), - start: async () => 1578459600 + start: 1578459600 }, }, v2: { [AVAX]: { fetch: v2Graphs(v2Endpoints)(AVAX), - start: async () => 1606971600 + start: 1606971600 }, [ETHEREUM]: { fetch: v2Graphs(v2Endpoints)(ETHEREUM), - start: async () => 1606971600 + start: 1606971600 }, [POLYGON]: { fetch: v2Graphs(v2Endpoints)(POLYGON), - start: async () => 1606971600 + start: 1606971600 }, }, v3: { [AVAX]: { fetch: v3Graphs(v3Endpoints)(AVAX), - start: async () => 1647230400 + start: 1647230400 }, [POLYGON]: { fetch: v3Graphs(v3Endpoints)(POLYGON), - start: async () => 1647230400 + start: 1647230400 }, [ARBITRUM]: { fetch: v3Graphs(v3Endpoints)(ARBITRUM), - start: async () => 1647230400 + start: 1647230400 }, [OPTIMISM]: { fetch: v3Graphs(v3Endpoints)(OPTIMISM), - start: async () => 1647230400 + start: 1647230400 }, [FANTOM]: { fetch: v3Graphs(v3Endpoints)(FANTOM), - start: async () => 1647230400 + start: 1647230400 }, [HARMONY]: { fetch: v3Graphs(v3Endpoints)(HARMONY), - start: async () => 1647230400 + start: 1647230400 }, [CHAIN.ETHEREUM]: { fetch: v3Graphs(v3Endpoints)(CHAIN.ETHEREUM), - start: async () => 1647230400 + start: 1647230400 }, } } diff --git a/fees/abracadabra.ts b/fees/abracadabra.ts index 3814d2ffb3..db747d2c29 100644 --- a/fees/abracadabra.ts +++ b/fees/abracadabra.ts @@ -76,23 +76,23 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: graphs(endpoints)(CHAIN.ETHEREUM), - start: async () => 1630468800, + start: 1630468800, }, [CHAIN.FANTOM]: { fetch: graphs(endpoints)(CHAIN.FANTOM), - start: async () => 1630468800, + start: 1630468800, }, [CHAIN.AVAX]: { fetch: graphs(endpoints)(CHAIN.AVAX), - start: async () => 1630468800, + start: 1630468800, }, [CHAIN.BSC]: { fetch: graphs(endpoints)(CHAIN.BSC), - start: async () => 1630468800, + start: 1630468800, }, [CHAIN.ARBITRUM]: { fetch: graphs(endpoints)(CHAIN.ARBITRUM), - start: async () => 1630468800, + start: 1630468800, }, } } diff --git a/fees/allbridge-classic.ts b/fees/allbridge-classic.ts index cbf78dc002..4c810bd5ee 100644 --- a/fees/allbridge-classic.ts +++ b/fees/allbridge-classic.ts @@ -24,7 +24,6 @@ const getFeesFunction = (chain: Chain) => { const dailyFees = await getFees(chainCode, dateString, dateString); const dailyRevenue = dailyFees * 0.2; const dailySupplySideRevenue = dailyFees * 0.8; - // console.log(`Fees for ${chain} on : ${dailyFees}`) return { timestamp, dailyFees: dailyFees !== undefined ? String(dailyFees) : undefined, diff --git a/fees/allbridge-core.ts b/fees/allbridge-core.ts index 38573a351a..013dd783d7 100644 --- a/fees/allbridge-core.ts +++ b/fees/allbridge-core.ts @@ -83,7 +83,6 @@ const tronRpc = `https://api.trongrid.io` const getTronLogs = async (address: string, eventName: string, minBlockTimestamp: number, maxBlockTimestamp: number) => { const url = `${tronRpc}/v1/contracts/${address}/events?event_name=${eventName}&min_block_timestamp=${minBlockTimestamp}&max_block_timestamp=${maxBlockTimestamp}&limit=200`; const res = await httpGet(url); - console.log(res.data) return res.data; } diff --git a/fees/aura.ts b/fees/aura.ts index 57877a679e..17c5f633b5 100644 --- a/fees/aura.ts +++ b/fees/aura.ts @@ -111,7 +111,7 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: fetch(), - start: async () => 1669852800, + start: 1669852800, }, }, diff --git a/fees/babydogeswap.ts b/fees/babydogeswap.ts index 302296bf2b..1a2742ed9a 100644 --- a/fees/babydogeswap.ts +++ b/fees/babydogeswap.ts @@ -35,5 +35,5 @@ const adapters = univ2DimensionAdapter({ } }); -adapters.adapter.bsc.start = async () => 1661780137; +adapters.adapter.bsc.start = 1661780137; export default adapters; \ No newline at end of file diff --git a/fees/basepaint.ts b/fees/basepaint.ts index ce8a774a0a..a826592c69 100644 --- a/fees/basepaint.ts +++ b/fees/basepaint.ts @@ -24,7 +24,7 @@ const adapterFees: SimpleAdapter = { adapter: { [CHAIN.BASE]: { fetch, - start: async () => 1691625600, + start: 1691625600, } } } diff --git a/fees/betswirl/index.ts b/fees/betswirl/index.ts index b8182a544c..0fd04bff65 100644 --- a/fees/betswirl/index.ts +++ b/fees/betswirl/index.ts @@ -1,7 +1,7 @@ import { request } from "graphql-request"; import BigNumber from "bignumber.js"; -import { Adapter, FetchResultFees } from "../../adapters/types"; +import { Adapter, ChainBlocks, FetchOptions, FetchResultFees } from "../../adapters/types"; import { BSC, POLYGON, AVAX, ARBITRUM } from "../../helpers/chains"; import { getTimestampAtStartOfDayUTC, getTimestampAtStartOfNextDayUTC } from "../../utils/date"; import { Chain } from "@defillama/sdk/build/general"; @@ -52,13 +52,10 @@ interface IGraph { } function graphs() { - return (chain: Chain) => { - return async (timestamp: number): Promise => { - const yesterdaysTimestamp = getTimestampAtStartOfDayUTC(timestamp) - const todaysTimestamp = getTimestampAtStartOfNextDayUTC(timestamp) - - const todaysBlock = (await getBlock(todaysTimestamp, chain, {})); - const yesterdaysBlock = (await getBlock(yesterdaysTimestamp, chain, {})); + return (chain: Chain): any => { + return async (timestamp: number, _: ChainBlocks, { createBalances, getFromBlock, getToBlock }: FetchOptions): Promise => { + const todaysBlock = await getToBlock(); + const yesterdaysBlock = await getFromBlock(); const graphRes: IGraph = await request( endpoints[chain], @@ -101,273 +98,79 @@ function graphs() { }` ); - const coins = [...graphRes.todayTokens, ...graphPvPRes.todayPvPTokens].map((token: IToken | IPvPToken) => { - if (token.id === "0xfb5b838b6cfeedc2873ab27866079ac55363d37e") { - return "coingecko:floki"; - } else { - return chain + ":" + token.id; - } - }); - - const currentPrices = await getPrices( - [...coins, `coingecko:binance-usd`], - timestamp - ); - if (chain === BSC) { - // Floki price taken from CG - currentPrices["bsc:0xfb5b838b6cfeedc2873ab27866079ac55363d37e"] = - currentPrices["coingecko:floki"]; - currentPrices["bsc:0xe9e7cea3dedca5984780bafc599bd69add087d56"] = currentPrices["coingecko:binance-usd"]; - currentPrices['bsc:0xe9e7cea3dedca5984780bafc599bd69add087d56'].decimals = 18; - currentPrices['bsc:0xfb5b838b6cfeedc2873ab27866079ac55363d37e'].decimals = 9; - // Hardcoding TITANO price since it migrated to SWYCH - if (!currentPrices["bsc:0x4e3cabd3ad77420ff9031d19899594041c420aee"]) { - currentPrices["bsc:0x4e3cabd3ad77420ff9031d19899594041c420aee"] = { - decimals: 18, - symbol: "TITANO", - price: 0.000015, - timestamp, - }; - }// Hardcoding MDB+ price - if (!currentPrices["bsc:0x9f8bb16f49393eea4331a39b69071759e54e16ea"]) { - currentPrices["bsc:0x9f8bb16f49393eea4331a39b69071759e54e16ea"] = { - decimals: 18, - symbol: "MDB+", - price: 1.2, - timestamp, - }; - } - // Hardcoding INF-MDB - if (!currentPrices["bsc:0xacc966b91100f879c9ed4839ed2f77c70e3e97ed"]) { - currentPrices["bsc:0xacc966b91100f879c9ed4839ed2f77c70e3e97ed"] = { - decimals: 18, - symbol: "INF-MDB", - price: 0, // There was 0 volume anyway - timestamp, - }; - } - } - - const dailyUserFees: TBalance = {}; - const dailyFees: TBalance = {}; - const dailyRevenue: TBalance = {}; - const dailyProtocolRevenue: TBalance = {}; - const dailyHoldersRevenue: TBalance = {}; - const dailySupplySideRevenue: TBalance = {}; - const totalUserFees: TBalance = {}; - const totalFees: TBalance = {}; - const totalRevenue: TBalance = {}; - const totalProtocolRevenue: TBalance = {}; - const totalDailyHoldersRevenue: TBalance = {}; - const totalSupplySideRevenue: TBalance = {}; + const dailyUserFees = createBalances() + const dailyFees = createBalances() + const dailyRevenue = createBalances() + const dailyProtocolRevenue = createBalances() + const dailyHoldersRevenue = createBalances() + const dailySupplySideRevenue = createBalances() + const totalFees = createBalances() + const totalRevenue = createBalances() + const totalProtocolRevenue = createBalances() + const totalDailyHoldersRevenue = createBalances() + const totalSupplySideRevenue = createBalances() for (const token of graphRes.todayTokens) { - let tokenKey = chain + `:` + token.id.split(':')[0]; - if (!currentPrices[tokenKey.toLocaleLowerCase()]) { - console.log('not found token: ',tokenKey); - } - const tokenDecimals = currentPrices[tokenKey]?.decimals || 0; - const tokenPrice = currentPrices[tokenKey]?.price || 0; - - totalUserFees[tokenKey] = fromWei( - toBN(token.dividendAmount) - .plus(token.bankAmount) - .plus(token.partnerAmount) - .plus(token.treasuryAmount) - .plus(token.teamAmount), - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); - totalFees[tokenKey] = totalUserFees[tokenKey]; - - totalSupplySideRevenue[tokenKey] = fromWei( - toBN(token.bankAmount).plus(token.partnerAmount), - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); - - totalProtocolRevenue[tokenKey] = fromWei( - toBN(token.treasuryAmount).plus(token.teamAmount), - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); - - totalDailyHoldersRevenue[tokenKey] = fromWei( - token.dividendAmount, - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); - - totalRevenue[tokenKey] = - totalProtocolRevenue[tokenKey] + totalDailyHoldersRevenue[tokenKey]; + let tokenKey = token.id.split(':')[0]; + const { dividendAmount, bankAmount, partnerAmount, treasuryAmount, teamAmount } = token + + totalFees.add(tokenKey, +dividendAmount + +bankAmount + +partnerAmount + +treasuryAmount + +teamAmount) + dailyFees.add(tokenKey, +dividendAmount + +bankAmount + +partnerAmount + +treasuryAmount + +teamAmount) + totalSupplySideRevenue.add(tokenKey, +bankAmount + +partnerAmount) + dailySupplySideRevenue.add(tokenKey, +bankAmount + +partnerAmount) + totalProtocolRevenue.add(tokenKey, +treasuryAmount + +teamAmount) + dailyProtocolRevenue.add(tokenKey, +treasuryAmount + +teamAmount) + totalDailyHoldersRevenue.add(tokenKey, +dividendAmount) + dailyHoldersRevenue.add(tokenKey, +dividendAmount) + totalRevenue.add(tokenKey, +treasuryAmount + +teamAmount + +dividendAmount) + dailyRevenue.add(tokenKey, +treasuryAmount + +teamAmount + +dividendAmount) } for (const token of graphPvPRes.todayPvPTokens) { - let tokenKey = chain + `:` + token.id.split(':')[0]; - if (!currentPrices[tokenKey.toLocaleLowerCase()]) { - console.log('not found token: ',tokenKey); - } - const tokenDecimals = currentPrices[tokenKey]?.decimals || 0; - const tokenPrice = currentPrices[tokenKey]?.price || 0; - - if (!totalUserFees[tokenKey]) { - totalUserFees[tokenKey] = 0 - totalSupplySideRevenue[tokenKey] = 0 - totalProtocolRevenue[tokenKey] = 0 - totalDailyHoldersRevenue[tokenKey] = 0 - } - - totalUserFees[tokenKey] += fromWei( - toBN(token.dividendAmount) - .plus(token.initiatorAmount) - .plus(token.treasuryAmount) - .plus(token.teamAmount), - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); - totalFees[tokenKey] = totalUserFees[tokenKey]; - - totalSupplySideRevenue[tokenKey] += fromWei( - token.initiatorAmount, - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); - - totalProtocolRevenue[tokenKey] += fromWei( - toBN(token.treasuryAmount).plus(token.teamAmount), - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); - - totalDailyHoldersRevenue[tokenKey] += fromWei( - token.dividendAmount, - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); - - totalRevenue[tokenKey] = - totalProtocolRevenue[tokenKey] + totalDailyHoldersRevenue[tokenKey]; + let tokenKey = token.id.split(':')[0]; + const { dividendAmount, initiatorAmount, treasuryAmount, teamAmount } = token + totalFees.add(tokenKey, +dividendAmount + +initiatorAmount + +treasuryAmount + +teamAmount) + dailyFees.add(tokenKey, +dividendAmount + +initiatorAmount + +treasuryAmount + +teamAmount) + totalSupplySideRevenue.add(tokenKey, +initiatorAmount) + dailySupplySideRevenue.add(tokenKey, +initiatorAmount) + totalProtocolRevenue.add(tokenKey, +treasuryAmount + +teamAmount) + dailyProtocolRevenue.add(tokenKey, +treasuryAmount + +teamAmount) + totalDailyHoldersRevenue.add(tokenKey, +dividendAmount) + dailyHoldersRevenue.add(tokenKey, +dividendAmount) + totalRevenue.add(tokenKey, +treasuryAmount + +teamAmount + +dividendAmount) + dailyRevenue.add(tokenKey, +treasuryAmount + +teamAmount + +dividendAmount) } for (const token of graphRes.yesterdayTokens) { - const tokenKey = chain + `:` + token.id; - if (!currentPrices[tokenKey.toLocaleLowerCase()]) { - console.log('not found token: ',tokenKey); - } - const tokenDecimals = currentPrices[tokenKey]?.decimals || 0; - const tokenPrice = currentPrices[tokenKey]?.price || 0; - - dailyUserFees[tokenKey] = - totalUserFees[tokenKey] - - fromWei( - toBN(token.dividendAmount) - .plus(token.bankAmount) - .plus(token.partnerAmount) - .plus(token.treasuryAmount) - .plus(token.teamAmount), - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); - dailyFees[tokenKey] = dailyUserFees[tokenKey]; - - dailyHoldersRevenue[tokenKey] = - totalDailyHoldersRevenue[tokenKey] - - fromWei(token.dividendAmount, tokenDecimals) - .multipliedBy(tokenPrice) - .toNumber(); - - dailyProtocolRevenue[tokenKey] = - totalProtocolRevenue[tokenKey] - - fromWei( - toBN(token.treasuryAmount).plus(token.teamAmount), - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); - dailyRevenue[tokenKey] = - dailyHoldersRevenue[tokenKey] + dailyProtocolRevenue[tokenKey]; - - dailySupplySideRevenue[tokenKey] = - totalSupplySideRevenue[tokenKey] - - fromWei( - toBN(token.bankAmount).plus(token.partnerAmount), - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); + let tokenKey = token.id.split(':')[0]; + const { dividendAmount, bankAmount, partnerAmount, treasuryAmount, teamAmount } = token + dailyFees.add(tokenKey, 0 - +dividendAmount - +bankAmount - +partnerAmount - +treasuryAmount - +teamAmount) + dailyHoldersRevenue.add(tokenKey, 0 - +dividendAmount) + dailyProtocolRevenue.add(tokenKey, 0 - +treasuryAmount - +teamAmount) + dailyRevenue.add(tokenKey, 0 - +treasuryAmount - +teamAmount - +dividendAmount) + dailySupplySideRevenue.add(tokenKey, 0 - +bankAmount - +partnerAmount) } for (const token of graphPvPRes.yesterdayPvPTokens) { - const tokenKey = chain + `:` + token.id; - if (!currentPrices[tokenKey.toLocaleLowerCase()]) { - console.log('not found token: ',tokenKey); - } - const tokenDecimals = currentPrices[tokenKey]?.decimals || 0; - const tokenPrice = currentPrices[tokenKey]?.price || 0; - - if (!dailyUserFees[tokenKey]) { - dailyUserFees[tokenKey] = 0 - dailyHoldersRevenue[tokenKey] = 0 - dailyProtocolRevenue[tokenKey] = 0 - dailySupplySideRevenue[tokenKey] = 0 - } - - dailyUserFees[tokenKey] -= - fromWei( - toBN(token.dividendAmount) - .plus(token.initiatorAmount) - .plus(token.treasuryAmount) - .plus(token.teamAmount), - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); - dailyFees[tokenKey] = dailyUserFees[tokenKey]; - - dailyHoldersRevenue[tokenKey] -= - fromWei(token.dividendAmount, tokenDecimals) - .multipliedBy(tokenPrice) - .toNumber(); - - dailyProtocolRevenue[tokenKey] -= - fromWei( - toBN(token.treasuryAmount).plus(token.teamAmount), - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); - dailyRevenue[tokenKey] = - dailyHoldersRevenue[tokenKey] + dailyProtocolRevenue[tokenKey]; - - dailySupplySideRevenue[tokenKey] -= - fromWei( - token.initiatorAmount, - tokenDecimals - ) - .multipliedBy(tokenPrice) - .toNumber(); + let tokenKey = token.id.split(':')[0]; + const { dividendAmount, initiatorAmount, treasuryAmount, teamAmount } = token + dailyFees.add(tokenKey, 0 - +dividendAmount - +initiatorAmount - +treasuryAmount - +teamAmount) + dailyHoldersRevenue.add(tokenKey, 0 - +dividendAmount) + dailyProtocolRevenue.add(tokenKey, 0 - +treasuryAmount - +teamAmount) + dailyRevenue.add(tokenKey, 0 - +treasuryAmount - +teamAmount - +dividendAmount) + dailySupplySideRevenue.add(tokenKey, 0 - +initiatorAmount) } return { timestamp, - dailyFees: Object.values(dailyFees).reduce((a: number, b: number) => a + b, 0).toString(), - dailyUserFees: Object.values(dailyUserFees).reduce((a: number, b: number) => a + b, 0).toString(), - dailyRevenue: Object.values(dailyRevenue).reduce((a: number, b: number) => a + b, 0).toString(), - dailyProtocolRevenue: Object.values(dailyProtocolRevenue).reduce((a: number, b: number) => a + b, 0).toString(), - dailyHoldersRevenue: Object.values(dailyHoldersRevenue).reduce((a: number, b: number) => a + b, 0).toString(), - dailySupplySideRevenue: Object.values(dailySupplySideRevenue).reduce((a: number, b: number) => a + b, 0).toString(), - totalFees: Object.values(totalFees).reduce((a: number, b: number) => a + b, 0).toString(), - totalUserFees: Object.values(totalUserFees).reduce((a: number, b: number) => a + b, 0).toString(), - totalRevenue: Object.values(totalRevenue).reduce((a: number, b: number) => a + b, 0).toString(), - totalProtocolRevenue: Object.values(totalProtocolRevenue).reduce((a: number, b: number) => a + b, 0).toString(), - totalSupplySideRevenue: Object.values(totalSupplySideRevenue).reduce((a: number, b: number) => a + b, 0).toString(), - // totalDailyHoldersRevenue, + dailyFees, + dailyUserFees: dailyFees, + dailyRevenue, + dailyProtocolRevenue, + dailyHoldersRevenue, + dailySupplySideRevenue, + totalFees, + totalUserFees: totalFees, + totalRevenue, + totalProtocolRevenue, + totalSupplySideRevenue, }; }; }; diff --git a/fees/blastapi.ts b/fees/blastapi.ts index cc847e04cc..7f84550baf 100644 --- a/fees/blastapi.ts +++ b/fees/blastapi.ts @@ -78,35 +78,35 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: fetch(CHAIN.ETHEREUM), - start: async () => 1675382400, + start: 1675382400, }, [CHAIN.BSC]: { fetch: fetch(CHAIN.BSC), - start: async () => 1675382400, + start: 1675382400, }, [CHAIN.AVAX]: { fetch: fetch(CHAIN.AVAX), - start: async () => 1675382400, + start: 1675382400, }, [CHAIN.MOONBEAM]: { fetch: fetch(CHAIN.MOONBEAM), - start: async () => 1675382400, + start: 1675382400, }, [CHAIN.FANTOM]: { fetch: fetch(CHAIN.FANTOM), - start: async () => 1675382400, + start: 1675382400, }, [CHAIN.POLYGON]: { fetch: fetch(CHAIN.POLYGON), - start: async () => 1675382400, + start: 1675382400, }, // [CHAIN.XDAI]: { // fetch: fetch(CHAIN.XDAI), - // start: async () => 1675382400, + // start: 1675382400, // }, [CHAIN.OPTIMISM]: { fetch: fetch(CHAIN.OPTIMISM), - start: async () => 1675382400, + start: 1675382400, } } } diff --git a/fees/bsc.ts b/fees/bsc.ts index 6510b8b46b..bb11f00434 100644 --- a/fees/bsc.ts +++ b/fees/bsc.ts @@ -60,7 +60,7 @@ const adapter: Adapter = { adapter: { [BSC]: { fetch: graphs(endpoints)(BSC), - start: async () => 1598671449, + start: 1598671449, }, }, protocolType: ProtocolType.CHAIN diff --git a/fees/buffer/index.ts b/fees/buffer/index.ts index 8b1e435739..1f1a4e0a0d 100644 --- a/fees/buffer/index.ts +++ b/fees/buffer/index.ts @@ -52,7 +52,7 @@ const adapter: Adapter = { adapter: { [CHAIN.ARBITRUM]: { fetch: graphs(endpoints)(CHAIN.ARBITRUM), - start: async () => 1674950400 , + start: 1674950400 , }, } } diff --git a/fees/cardano.ts b/fees/cardano.ts index 68f3c51c22..e78df6f95a 100644 --- a/fees/cardano.ts +++ b/fees/cardano.ts @@ -59,7 +59,7 @@ const adapter: Adapter = { adapter: { [CHAIN.CARDANO]: { fetch: fetch, - start: async () => 1577836800, + start: 1577836800, }, }, protocolType: ProtocolType.CHAIN diff --git a/fees/cipher.ts b/fees/cipher.ts index d9dc31cbca..cd57a4956c 100644 --- a/fees/cipher.ts +++ b/fees/cipher.ts @@ -1,84 +1,12 @@ -import { Adapter, FetchResultFees, SimpleAdapter } from "../adapters/types"; +import { Adapter,} from "../adapters/types"; +import { getFeesExport } from "../helpers/friend-tech"; import { CHAIN } from "../helpers/chains"; -import * as sdk from "@defillama/sdk"; -import { getBlock } from "../helpers/getBlock"; -import { getPrices } from "../utils/prices"; -import { Chain } from "@defillama/sdk/build/general"; -import { ethers } from "ethers"; - -const FriendtechSharesAddress = '0x2544a6412bc5aec279ea0f8d017fb4a9b6673dca'; -const topic0_trade = '0x2c76e7a47fd53e2854856ac3f0a5f3ee40d15cfaa82266357ea9779c486ab9c3'; -const event_trade = 'event Trade(address trader, address subject, bool isBuy, uint256 shareAmount, uint256 ethAmount, uint256 protocolEthAmount, uint256 subjectEthAmount, uint256 supply)' -const contract_interface = new ethers.Interface([ - event_trade -]); - -interface ILog { - data: string; - transactionHash: string; - topics: string[]; -} - -interface IFee { - fees: number; - rev: number; -} - -const fetch = async (timestamp: number): Promise => { - const fromTimestamp = timestamp - 60 * 60 * 24 - const toTimestamp = timestamp - - const fromBlock = (await getBlock(fromTimestamp, CHAIN.ARBITRUM, {})); - const toBlock = (await getBlock(toTimestamp, CHAIN.ARBITRUM, {})); - // let _logs: ILog[] = []; - // for(let i = fromBlock; i < toBlock; i += 10000) { - // const logs: ILog[] = (await sdk.getEventLogs({ - // target: FriendtechSharesAddress, - // toBlock: i + 10000, - // fromBlock: i, - // chain: CHAIN.ARBITRUM, - // topics: [topic0_trade] - // }))as ILog[]; - // console.log(logs.length) - // _logs = _logs.concat(logs); - // } - const logs: ILog[] = (await sdk.getEventLogs({ - target: FriendtechSharesAddress, - toBlock: toBlock, - fromBlock: fromBlock, - chain: CHAIN.ARBITRUM, - topics: [topic0_trade] - })) as ILog[]; - - const fees_details: IFee[] = logs.map((e: ILog) => { - const value = contract_interface.parseLog(e); - const protocolEthAmount = Number(value!.args.protocolEthAmount) / 10 ** 18; - const subjectEthAmount = Number(value!.args.subjectEthAmount) / 10 ** 18; - return { - fees: protocolEthAmount + subjectEthAmount, - rev: protocolEthAmount - } as IFee - }) - const dailyFees = fees_details.reduce((a: number, b: IFee) => a + b.fees, 0) - const dailyRev = fees_details.reduce((a: number, b: IFee) => a + b.rev, 0) - const ethAddress = "ethereum:0x0000000000000000000000000000000000000000"; - const ethPrice = (await getPrices([ethAddress], timestamp))[ethAddress].price; - const dailyFeesUSD = (dailyFees) * ethPrice; - const dailyRevUSD = (dailyRev) * ethPrice; - return { - dailyFees: `${dailyFeesUSD}`, - dailyRevenue: `${dailyRevUSD}`, - timestamp - } - -} - const adapter: Adapter = { adapter: { [CHAIN.ARBITRUM]: { - fetch: fetch, - start: async () => 1695600000, + fetch: getFeesExport('0x2544a6412bc5aec279ea0f8d017fb4a9b6673dca'), + start: 1695600000, }, } } diff --git a/fees/compound.ts b/fees/compound.ts index daa7354991..abc78ba144 100644 --- a/fees/compound.ts +++ b/fees/compound.ts @@ -60,7 +60,7 @@ const adapter: Adapter = { adapter: { [ETHEREUM]: { fetch: graphs(endpoints)(ETHEREUM), - start: async () => 1557201600, + start: 1557201600, }, } } diff --git a/fees/cow-protocol.ts b/fees/cow-protocol.ts index a2e8d04d3b..d078f26417 100644 --- a/fees/cow-protocol.ts +++ b/fees/cow-protocol.ts @@ -133,14 +133,14 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: fetch(CHAIN.ETHEREUM), - start: async () => 1675382400, + start: 1675382400, meta: { methodology } }, // [CHAIN.XDAI]: { // fetch: fetch(CHAIN.XDAI), - // start: async () => 1675382400, + // start: 1675382400, // meta: { // methodology // } diff --git a/fees/cryptex-v2.ts b/fees/cryptex-v2.ts index cf4408e0cd..12b9db9992 100644 --- a/fees/cryptex-v2.ts +++ b/fees/cryptex-v2.ts @@ -167,7 +167,7 @@ const adapter: Adapter = { adapter: { [CHAIN.ARBITRUM]: { fetch: fetch, - start: async () => 1684540800 + start: 1684540800 } } } diff --git a/fees/dodo.ts b/fees/dodo.ts index 79adf5b3ec..8a6e6e2d81 100644 --- a/fees/dodo.ts +++ b/fees/dodo.ts @@ -29,7 +29,7 @@ const adapter: Adapter = { }; }, runAtCurrTime: true, - start: async()=>0, + start: 0, } }), {} as any) }; diff --git a/fees/elk.ts b/fees/elk.ts index 81946eec3e..2e39e107ee 100644 --- a/fees/elk.ts +++ b/fees/elk.ts @@ -47,19 +47,19 @@ const adapter = univ2DimensionAdapter({ } }); -adapter.adapter.arbitrum.start = async () => 1648950817; -adapter.adapter.avax.start = async () => 1616118817; -adapter.adapter.bsc.start = async () => 1629251617; -adapter.adapter.fantom.start = async () => 1621562017; -adapter.adapter.polygon.start = async () => 1618019617; -adapter.adapter.xdai.start = async () => 1629251617; -// adapter.adapter.elastos.start = async () => 1634954017; -// adapter.adapter.okexchain.start = async () => 1649555617; -// adapter.adapter.kcc.start = async () => 1634954017; -adapter.adapter.ethereum.start = async () => 1619747617; -adapter.adapter.optimism.start = async () => 1651542817; -// adapter.adapter.fuse.start = async () => 1639187617; -// adapter.adapter.iotex.start = async () => 1639792417; -// adapter.adapter.telos.start = async () => 1648684800; +adapter.adapter.arbitrum.start = 1648950817; +adapter.adapter.avax.start = 1616118817; +adapter.adapter.bsc.start = 1629251617; +adapter.adapter.fantom.start = 1621562017; +adapter.adapter.polygon.start = 1618019617; +adapter.adapter.xdai.start = 1629251617; +// adapter.adapter.elastos.start = 1634954017; +// adapter.adapter.okexchain.start = 1649555617; +// adapter.adapter.kcc.start = 1634954017; +adapter.adapter.ethereum.start = 1619747617; +adapter.adapter.optimism.start = 1651542817; +// adapter.adapter.fuse.start = 1639187617; +// adapter.adapter.iotex.start = 1639792417; +// adapter.adapter.telos.start = 1648684800; export default adapter; diff --git a/fees/ens.ts b/fees/ens.ts index 2d9130b192..8d1eb56035 100644 --- a/fees/ens.ts +++ b/fees/ens.ts @@ -130,7 +130,7 @@ const adapter: Adapter = { timestamp } }, - start: async () => 1677110400, + start: 1677110400, meta: { methodology } diff --git a/fees/equalizer-exchange.ts b/fees/equalizer-exchange.ts index a04dbb06af..188a07e36b 100644 --- a/fees/equalizer-exchange.ts +++ b/fees/equalizer-exchange.ts @@ -213,7 +213,6 @@ const fetch = async (timestamp: number): Promise => { const _token = _log.args.reward; const _price = (prices[`${CHAIN_SLUG}:${_token}`]?.price || 0); const _deci = prices[`${CHAIN_SLUG}:${_token}`]?.decimals || 0; - //console.log("_log.args.from", _log.args.from); const amount = Number(p.data) / 10 ** _deci * _price; return { amount } as IAmountUSD }) as IAmountUSD[]; diff --git a/fees/ethereum/index.ts b/fees/ethereum/index.ts index 4b1e9feb9a..687a0830ae 100644 --- a/fees/ethereum/index.ts +++ b/fees/ethereum/index.ts @@ -48,7 +48,7 @@ const adapter: Adapter = { adapter: { [ETHEREUM]: { fetch: graphs()(), - start: async () => 1438228800, + start: 1438228800, }, }, protocolType: ProtocolType.CHAIN diff --git a/fees/ferro.ts b/fees/ferro.ts index f660da11ee..0b8557095e 100644 --- a/fees/ferro.ts +++ b/fees/ferro.ts @@ -25,5 +25,5 @@ const adapters = univ2DimensionAdapter({ } }, { }); -adapters.adapter.cronos.start = async () => 1661731973; +adapters.adapter.cronos.start = 1661731973; export default adapters; diff --git a/fees/foundation.ts b/fees/foundation.ts index 35ccf6b3c5..9fc6f37a74 100644 --- a/fees/foundation.ts +++ b/fees/foundation.ts @@ -130,7 +130,7 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: fetch, - start: async () => 1612137600, + start: 1612137600, }, } } diff --git a/fees/frax-ether.ts b/fees/frax-ether.ts index 90b6d2ec28..2f15dd66b8 100644 --- a/fees/frax-ether.ts +++ b/fees/frax-ether.ts @@ -73,7 +73,7 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: fetch(), - start: async () => 1665014400, + start: 1665014400, }, } } diff --git a/fees/friend-room.ts b/fees/friend-room.ts index ca39d5f510..83ae4087e2 100644 --- a/fees/friend-room.ts +++ b/fees/friend-room.ts @@ -66,7 +66,7 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: fetch, - start: async () => 1693731179, + start: 1693731179, }, } } diff --git a/fees/friend-tech.ts b/fees/friend-tech.ts index 2caefd789e..db6dca608c 100644 --- a/fees/friend-tech.ts +++ b/fees/friend-tech.ts @@ -1,78 +1,14 @@ -import { Adapter, FetchResultFees, SimpleAdapter } from "../adapters/types"; +import { Adapter,} from "../adapters/types"; +import { getFeesExport } from "../helpers/friend-tech"; import { CHAIN } from "../helpers/chains"; -import * as sdk from "@defillama/sdk"; -import { getBlock } from "../helpers/getBlock"; -import { getPrices } from "../utils/prices"; -import { Chain } from "@defillama/sdk/build/general"; -import { ethers } from "ethers"; - -const FriendtechSharesAddress = '0xcf205808ed36593aa40a44f10c7f7c2f67d4a4d4'; -const topic0_trade = '0x2c76e7a47fd53e2854856ac3f0a5f3ee40d15cfaa82266357ea9779c486ab9c3'; -const event_trade = 'event Trade(address trader, address subject, bool isBuy, uint256 shareAmount, uint256 ethAmount, uint256 protocolEthAmount, uint256 subjectEthAmount, uint256 supply)' -const contract_interface = new ethers.Interface([ - event_trade -]); - -interface ILog { - data: string; - transactionHash: string; - topics: string[]; -} - -interface IFee { - fees: number; - rev: number; -} - -const fetch = async (timestamp: number): Promise => { - const fromTimestamp = timestamp - 60 * 60 * 24 - const toTimestamp = timestamp - - const fromBlock = (await getBlock(fromTimestamp, CHAIN.BASE, {})); - const toBlock = (await getBlock(toTimestamp, CHAIN.BASE, {})); - let _logs: ILog[] = []; - for (let i = fromBlock; i < toBlock; i += 5000) { - const logs: ILog[] = (await sdk.getEventLogs({ - target: FriendtechSharesAddress, - toBlock: i + 5000, - fromBlock: i, - chain: CHAIN.BASE, - topics: [topic0_trade] - })) as ILog[]; - _logs = _logs.concat(logs); - } - - const fees_details: IFee[] = _logs.map((e: ILog) => { - const value = contract_interface.parseLog(e); - const protocolEthAmount = Number(value!.args.protocolEthAmount) / 10 ** 18; - const subjectEthAmount = Number(value!.args.subjectEthAmount) / 10 ** 18; - return { - fees: protocolEthAmount + subjectEthAmount, - rev: protocolEthAmount - } as IFee - }) - const dailyFees = fees_details.reduce((a: number, b: IFee) => a + b.fees, 0) - const dailyRev = fees_details.reduce((a: number, b: IFee) => a + b.rev, 0) - const ethAddress = "ethereum:0x0000000000000000000000000000000000000000"; - const ethPrice = (await getPrices([ethAddress], timestamp))[ethAddress].price; - const dailyFeesUSD = (dailyFees) * ethPrice; - const dailyRevUSD = (dailyRev) * ethPrice; - return { - dailyFees: `${dailyFeesUSD}`, - dailyRevenue: `${dailyRevUSD}`, - timestamp - } - -} - const adapter: Adapter = { adapter: { [CHAIN.BASE]: { - fetch: fetch, - start: async () => 1691539200, + fetch: getFeesExport('0xcf205808ed36593aa40a44f10c7f7c2f67d4a4d4'), + start: 1691539200, }, } } -export default adapter; +export default adapter; \ No newline at end of file diff --git a/fees/friend3.ts b/fees/friend3.ts index 467d59fd07..28381d301c 100644 --- a/fees/friend3.ts +++ b/fees/friend3.ts @@ -40,11 +40,11 @@ const adapter: Adapter = { adapter: { [CHAIN.BSC]: { fetch: fetch, - start: async () => 1692835200, + start: 1692835200, }, [CHAIN.OP_BNB]: { fetch: fetchOpbnb, - start: async () => 1698710400, + start: 1698710400, }, } } diff --git a/fees/gnd-protocol.ts b/fees/gnd-protocol.ts index b02872e0dd..c883fdaea6 100644 --- a/fees/gnd-protocol.ts +++ b/fees/gnd-protocol.ts @@ -98,7 +98,7 @@ const adapter: Adapter = { adapter: { [CHAIN.ARBITRUM]: { fetch: fetch(CHAIN.ARBITRUM), - start: async () => 1681430400, + start: 1681430400, meta: { methodology } diff --git a/fees/honeyswap.ts b/fees/honeyswap.ts index 05ede923e2..b2fd033ef1 100644 --- a/fees/honeyswap.ts +++ b/fees/honeyswap.ts @@ -31,7 +31,7 @@ const adapters = univ2DimensionAdapter({ ProtocolRevenue: "A 0.05% goes to the protocol treasury" } }); -adapters.adapter.polygon.start = async () => 1622173831; -adapters.adapter.xdai.start = async () => 1599191431; +adapters.adapter.polygon.start = 1622173831; +adapters.adapter.xdai.start = 1599191431; export default adapters; diff --git a/fees/houdini-swap.ts b/fees/houdini-swap.ts index de52717c88..2850a08a2e 100644 --- a/fees/houdini-swap.ts +++ b/fees/houdini-swap.ts @@ -57,7 +57,7 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: graph(CHAIN.ETHEREUM), - start: async () => 1673827200, + start: 1673827200, }, } } diff --git a/fees/junoswap.ts b/fees/junoswap.ts index f8c2ca55d8..04f82c96ae 100644 --- a/fees/junoswap.ts +++ b/fees/junoswap.ts @@ -37,7 +37,7 @@ const adapter: Adapter = { [DISABLED_ADAPTER_KEY]: disabledAdapter, [CHAIN.JUNO]: { fetch: fetch, - start: async () => 1646784000, + start: 1646784000, }, } } diff --git a/fees/klaytn.ts b/fees/klaytn.ts index 6f2fa9a619..790ea31816 100644 --- a/fees/klaytn.ts +++ b/fees/klaytn.ts @@ -30,7 +30,7 @@ const adapter: Adapter = { adapter: { [CHAIN.KLAYTN]: { fetch: fetch, - start: async () => 1577836800, + start: 1577836800, }, }, protocolType: ProtocolType.CHAIN diff --git a/fees/lido.ts b/fees/lido.ts index 7b7c123f8d..9f7e76ef82 100644 --- a/fees/lido.ts +++ b/fees/lido.ts @@ -59,7 +59,7 @@ const adapter: Adapter = { adapter: { [ETHEREUM]: { fetch: graphs(endpoints)(ETHEREUM), - start: async () => 1608354000, + start: 1608354000, meta: { methodology: { UserFees: "Lido takes 10% fee on users staking rewards", diff --git a/fees/liquis.ts b/fees/liquis.ts index 0fd456c681..bbd98d8fa4 100644 --- a/fees/liquis.ts +++ b/fees/liquis.ts @@ -61,7 +61,7 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: fetch(), - start: async () => 1693380630, + start: 1693380630, }, }, diff --git a/fees/looksrare.ts b/fees/looksrare.ts index 52b3fdd336..b41d3e322f 100644 --- a/fees/looksrare.ts +++ b/fees/looksrare.ts @@ -64,7 +64,7 @@ const adapter: Adapter = { adapter: { [ETHEREUM]: { fetch: graphs(ETHEREUM), - start: async () => 1640775864, + start: 1640775864, }, } } diff --git a/fees/maestro.ts b/fees/maestro.ts index e088960569..c8274b3027 100644 --- a/fees/maestro.ts +++ b/fees/maestro.ts @@ -57,15 +57,15 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: graph(CHAIN.ETHEREUM), - start: async () => 1656633600, + start: 1656633600, }, [CHAIN.BSC]: { fetch: graph(CHAIN.BSC), - start: async () => 1656633600, + start: 1656633600, }, [CHAIN.ARBITRUM]: { fetch: graph(CHAIN.ARBITRUM), - start: async () => 1675468800, + start: 1675468800, }, } } diff --git a/fees/makerdao.ts b/fees/makerdao.ts index c7a0e90b48..ab46e2b4c4 100644 --- a/fees/makerdao.ts +++ b/fees/makerdao.ts @@ -85,7 +85,7 @@ const adapter: Adapter = { adapter: { [ETHEREUM]: { fetch: graphs(endpoints)(ETHEREUM), - start: async () => 1573672933, + start: 1573672933, }, } } diff --git a/fees/metamask.ts b/fees/metamask.ts index 379ac216c8..4904e819b1 100644 --- a/fees/metamask.ts +++ b/fees/metamask.ts @@ -110,19 +110,19 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: graph(CHAIN.ETHEREUM), - start: async () => 1672531200, + start: 1672531200, }, [CHAIN.POLYGON]: { fetch: graph(CHAIN.POLYGON), - start: async () => 1672531200, + start: 1672531200, }, [CHAIN.BSC]: { fetch: graph(CHAIN.BSC), - start: async () => 1672531200, + start: 1672531200, }, [CHAIN.ARBITRUM]: { fetch: graph(CHAIN.ARBITRUM), - start: async () => 1672531200, + start: 1672531200, } } } diff --git a/fees/mojitoswap.ts b/fees/mojitoswap.ts index f35b0d9887..c1327f1a06 100644 --- a/fees/mojitoswap.ts +++ b/fees/mojitoswap.ts @@ -27,6 +27,6 @@ const adapter = univ2DimensionAdapter({ } }); -adapter.adapter.kcc.start = async () => 1634200191; +adapter.adapter.kcc.start = 1634200191; export default adapter diff --git a/fees/moonwell-apollo.ts b/fees/moonwell-apollo.ts index c6f2d45d22..fad4431927 100644 --- a/fees/moonwell-apollo.ts +++ b/fees/moonwell-apollo.ts @@ -43,7 +43,7 @@ const adapter: Adapter = { adapter: { [CHAIN.MOONRIVER]: { fetch: graphs(endpoints)(CHAIN.MOONRIVER), - start: async () => 1645747200, + start: 1645747200, }, } } diff --git a/fees/moonwell-artemis.ts b/fees/moonwell-artemis.ts index 2c53b06e27..181ad64323 100644 --- a/fees/moonwell-artemis.ts +++ b/fees/moonwell-artemis.ts @@ -43,7 +43,7 @@ const adapter: Adapter = { adapter: { [CHAIN.MOONBEAN]: { fetch: graphs(endpoints)(CHAIN.MOONBEAN), - start: async () => 1656115200, + start: 1656115200, }, } } diff --git a/fees/mux.ts b/fees/mux.ts index fe1b9bc3c5..68da3140c8 100644 --- a/fees/mux.ts +++ b/fees/mux.ts @@ -89,23 +89,23 @@ const adapter: Adapter = { adapter: { [ARBITRUM]: { fetch: getFees(CHAIN_ID.ARB), - start: async () => 1659312000, // 2022-08-01 + start: 1659312000, // 2022-08-01 }, [BSC]: { fetch: getFees(CHAIN_ID.BSC), - start: async () => 1659312000, // 2022-08-01 + start: 1659312000, // 2022-08-01 }, [AVAX]: { fetch: getFees(CHAIN_ID.AVALANCHE), - start: async () => 1659312000, // 2022-08-01 + start: 1659312000, // 2022-08-01 }, [FANTOM]: { fetch: getFees(CHAIN_ID.FTM), - start: async () => 1659312000, // 2022-08-01 + start: 1659312000, // 2022-08-01 }, [OPTIMISM]: { fetch: getFees(CHAIN_ID.OPTIMISM), - start: async () => 1672876800, // 2023-01-05 + start: 1672876800, // 2023-01-05 }, } } diff --git a/fees/nether-fi/index.ts b/fees/nether-fi/index.ts index c97cbdc1e5..5ed8ff31ba 100644 --- a/fees/nether-fi/index.ts +++ b/fees/nether-fi/index.ts @@ -4,7 +4,7 @@ import { request, gql } from "graphql-request"; import { getTimestampAtStartOfDayUTC } from "../../utils/date"; const subgraphEndpoint = "https://api.studio.thegraph.com/query/51510/nefi-base-mainnet-stats/version/latest"; -const startTimestamp = async () => 1693526400; +const startTimestamp = 1693526400; const methodology = { Fees: "Open/Close position: 0.1% | Swap: 0.2% to 0.8% | Mint and Burn: 0% to 0.85% (based on tokens balance in the pool) | Borrow Fee: `(assets borrowed) / (total assets in pool) * 0.01%`", diff --git a/fees/nftearth.ts b/fees/nftearth.ts index de99791be0..167098bc23 100644 --- a/fees/nftearth.ts +++ b/fees/nftearth.ts @@ -93,15 +93,15 @@ const adapter: Adapter = { adapter: { [CHAIN.OPTIMISM]: { fetch: fetch(CHAIN.OPTIMISM), - start: async () => 1675036800, + start: 1675036800, }, [CHAIN.ARBITRUM]: { fetch: fetch(CHAIN.ARBITRUM), - start: async () => 1676332800, + start: 1676332800, }, [CHAIN.POLYGON]: { fetch: fetch(CHAIN.POLYGON), - start: async () => 1675036800, + start: 1675036800, }, } } diff --git a/fees/odos.ts b/fees/odos.ts index b462272245..2cd5155068 100644 --- a/fees/odos.ts +++ b/fees/odos.ts @@ -30,30 +30,11 @@ To do: */ -import { FetchResultFees, SimpleAdapter } from "../adapters/types"; +import { ChainBlocks, FetchOptions, FetchResultFees, SimpleAdapter } from "../adapters/types"; import { CHAIN } from "../helpers/chains"; -import * as sdk from "@defillama/sdk"; -import { getBlock } from "../helpers/getBlock"; -import { getPrices } from "../utils/prices"; import { Chain } from "@defillama/sdk/build/general"; -import { ethers } from "ethers"; - -interface ILog { - data: string; - transactionHash: string; - topics: string[]; -} -interface IAmount { - feesAmount: number; -} const event_swap = 'event Swap (address sender, uint256 inputAmount, address inputToken, uint256 amountOut, address outputToken, int256 slippage, uint32 referralCode)'; -const topic0_swap_one = '0x823eaf01002d7353fbcadb2ea3305cc46fa35d799cb0914846d185ac06f8ad05'; -const ROUTER_ADDRESS_FTM_V2 = '0xd0c22a5435f4e8e5770c1fafb5374015fc12f7cd'; - -const contract_interface = new ethers.Interface([ - event_swap -]); type TPool = { [c: string]: string[]; @@ -67,73 +48,22 @@ const FEE_COLLECTORS: TPool = { [CHAIN.AVAX]: ['0x88de50B233052e4Fb783d4F6db78Cc34fEa3e9FC',], [CHAIN.BSC]: ['0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E',], [CHAIN.FANTOM]: ['0xd0c22a5435f4e8e5770c1fafb5374015fc12f7cd',], - //[CHAIN.ZKSYNC]: [ '0x4bBa932E9792A2b917D47830C93a9BC79320E4f7', ], + [CHAIN.ZKSYNC]: [ '0x4bBa932E9792A2b917D47830C93a9BC79320E4f7', ], [CHAIN.POLYGON_ZKEVM]: ['0x2b8B3f0949dfB616602109D2AAbBA11311ec7aEC',], } -const graph = (chain: Chain) => { - return async (timestamp: number): Promise => { - const fromTimestamp = timestamp - 60 * 60 * 24 - const toTimestamp = timestamp +const graph = (chain: Chain): any => { + return async (timestamp: number, _: ChainBlocks, { getLogs, createBalances, }: FetchOptions): Promise => { const feeCollectors = FEE_COLLECTORS[chain]; + const dailyFees = createBalances() + const logs = await getLogs({ targets: feeCollectors, eventAbi: event_swap, }) + logs.forEach(i => dailyFees.add(i.outputToken, Number(i.slippage) > 0 ? i.slippage : 0)) - const fromBlock = (await getBlock(fromTimestamp, chain, {})); - const toBlock = (await getBlock(toTimestamp, chain, {})); - - //console.log(feeCollectors,fromBlock,toBlock,chain); - - const logs: ILog[][] = (await Promise.all(feeCollectors.map((address: string) => sdk.getEventLogs({ - target: address, - toBlock: toBlock, - fromBlock: fromBlock, - chain: chain, - topics: [topic0_swap_one] - })))) as ILog[][]; - - const rawCoinsPerTreasury: string[][] = feeCollectors.map((_: string, index: number) => { - const logsToTokenList: string[] = logs[index] - .map((e: ILog) => { return { ...e } }) - .map((p: ILog) => { - return `${chain}:${contract_interface.parseLog(p)!.args.outputToken}`; - }); - return (logsToTokenList); - }); - - const rawCoins: string[] = rawCoinsPerTreasury.reduce((a: string[], b: any) => [...a, ...b]); - const coins = [...new Set(rawCoins)]; - const prices = await getPrices(coins, timestamp); - - - const untrackVolumes: any[] = feeCollectors.map((_: string, index: number) => { - //const token0Decimals = prices[`${chain}:${tokens0[index]}`]?.decimals || 0 - //const token1Decimals = prices[`${chain}:${tokens1[index]}`]?.decimals || 0 - const log: IAmount[] = logs[index] - .map((e: ILog) => { return { ...e } }) - .map((p: ILog) => { - const value = contract_interface.parseLog(p); - const _token = value!.args.outputToken; - const _price = (prices[`${chain}:${_token}`]?.price || 0); - const _deci = prices[`${chain}:${_token}`]?.decimals || 0; - const _slip = Number(value!.args.slippage); - const feesAmount = (_slip > 0 ? _slip : 0) / 10 ** _deci * _price; - return { - feesAmount, - } as IAmount - }); - - const totalFees = log.reduce((a: number, b: IAmount) => Number(b.feesAmount) + a, 0); - return { - fees: totalFees - }; - }); - - const dailyFees = untrackVolumes.reduce((a: number, b: any) => a + b.fees, 0); - const dailyRevenue = untrackVolumes.reduce((a: number, b: any) => a + b.rev, 0); return { - dailyFees: `${dailyFees}`, - dailyRevenue: `${dailyFees}`, - dailyHoldersRevenue: `${0}`, - dailySupplySideRevenue: `${0}`, + dailyFees: dailyFees, + dailyRevenue: dailyFees, + dailyHoldersRevenue: 0, + dailySupplySideRevenue: 0, timestamp, }; } diff --git a/fees/paraswap.ts b/fees/paraswap.ts index 671b4a3ea8..9989ddfef0 100644 --- a/fees/paraswap.ts +++ b/fees/paraswap.ts @@ -56,31 +56,31 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: fetch(CHAIN.ETHEREUM), - start: async () => 1647907200, + start: 1647907200, }, [CHAIN.POLYGON]: { fetch: fetch(CHAIN.POLYGON), - start: async () => 1647907200, + start: 1647907200, }, [CHAIN.BSC]: { fetch: fetch(CHAIN.BSC), - start: async () => 1647907200, + start: 1647907200, }, [CHAIN.AVAX]: { fetch: fetch(CHAIN.AVAX), - start: async () => 1647907200, + start: 1647907200, }, [CHAIN.FANTOM]: { fetch: fetch(CHAIN.FANTOM), - start: async () => 1647907200, + start: 1647907200, }, [CHAIN.ARBITRUM]: { fetch: fetch(CHAIN.ARBITRUM), - start: async () => 1647907200, + start: 1647907200, }, [CHAIN.OPTIMISM]: { fetch: fetch(CHAIN.OPTIMISM), - start: async () => 1647907200, + start: 1647907200, } } } diff --git a/fees/radiant.ts b/fees/radiant.ts index ce16b21340..3fa4c2506c 100644 --- a/fees/radiant.ts +++ b/fees/radiant.ts @@ -76,15 +76,15 @@ const adapter: Adapter = { adapter: { [CHAIN.ARBITRUM]: { fetch: fetch(CHAIN.ARBITRUM), - start: async () => 1679097600, + start: 1679097600, }, [CHAIN.BSC]: { fetch: fetch(CHAIN.BSC), - start: async () => 1679788800, + start: 1679788800, }, [CHAIN.ETHEREUM]: { fetch: fetch(CHAIN.ETHEREUM), - start: async () => 1698796800, + start: 1698796800, }, } } diff --git a/fees/rainbow-wallet.ts b/fees/rainbow-wallet.ts index c6d25e6d01..88bc279d3b 100644 --- a/fees/rainbow-wallet.ts +++ b/fees/rainbow-wallet.ts @@ -86,35 +86,35 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: fetch(CHAIN.ETHEREUM), - start: async () => 1672531200, + start: 1672531200, meta: { methodology } }, [CHAIN.OPTIMISM]: { fetch: fetch(CHAIN.OPTIMISM), - start: async () => 1672531200, + start: 1672531200, meta: { methodology } }, [CHAIN.ARBITRUM]: { fetch: fetch(CHAIN.ARBITRUM), - start: async () => 1672531200, + start: 1672531200, meta: { methodology } }, [CHAIN.POLYGON]: { fetch: fetch(CHAIN.POLYGON), - start: async () => 1672531200, + start: 1672531200, meta: { methodology } }, [CHAIN.BSC]: { fetch: fetch(CHAIN.BSC), - start: async () => 1672531200, + start: 1672531200, meta: { methodology } diff --git a/fees/scatter.ts b/fees/scatter.ts index d60caf806d..7771d19eab 100644 --- a/fees/scatter.ts +++ b/fees/scatter.ts @@ -56,8 +56,8 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: graph(CHAIN.ETHEREUM), - // start: async () => 1650844800, - start: async () => 1656633600, // + // start: 1650844800, + start: 1656633600, // }, } } diff --git a/fees/solarbeam.ts b/fees/solarbeam.ts index d8609f6407..020bd1088f 100644 --- a/fees/solarbeam.ts +++ b/fees/solarbeam.ts @@ -16,7 +16,7 @@ const adapter: Adapter = { adapter: { [CHAIN.MOONRIVER]: { fetch: feeAdapter.moonriver.fetch, - start: async () => 1630903340 + start: 1630903340 } } }; diff --git a/fees/squa-defi.ts b/fees/squa-defi.ts index 9621d9997c..3853e2884e 100644 --- a/fees/squa-defi.ts +++ b/fees/squa-defi.ts @@ -72,7 +72,7 @@ const adapter: Adapter = { adapter: { [CHAIN.BASE]: { fetch: fetch, - start: async () => 1703255087, + start: 1703255087, }, } } diff --git a/fees/stargate.ts b/fees/stargate.ts index 3ff35c6e59..7903341826 100644 --- a/fees/stargate.ts +++ b/fees/stargate.ts @@ -143,31 +143,31 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: fetch(CHAIN.ETHEREUM), - start: async () => 1661990400, + start: 1661990400, }, [CHAIN.ARBITRUM]: { fetch: fetch(CHAIN.ARBITRUM), - start: async () => 1661990400, + start: 1661990400, }, [CHAIN.AVAX]: { fetch: fetch(CHAIN.AVAX), - start: async () => 1661990400, + start: 1661990400, }, [CHAIN.BSC]: { fetch: fetch(CHAIN.BSC), - start: async () => 1661990400, + start: 1661990400, }, // [CHAIN.FANTOM]: { // fetch: fetch(CHAIN.FANTOM), - // start: async () => 1661990400, + // start: 1661990400, // }, [CHAIN.OPTIMISM]: { fetch: fetch(CHAIN.OPTIMISM), - start: async () => 1661990400, + start: 1661990400, }, [CHAIN.POLYGON]: { fetch: fetch(CHAIN.POLYGON), - start: async () => 1661990400, + start: 1661990400, }, } } diff --git a/fees/stars-arena.ts b/fees/stars-arena.ts index e33acaaac2..3b1c3c89b4 100644 --- a/fees/stars-arena.ts +++ b/fees/stars-arena.ts @@ -15,7 +15,7 @@ const adapter: Adapter = { [DISABLED_ADAPTER_KEY]: disabledAdapter, [CHAIN.AVAX]: { fetch: fetch, - start: async () => 1695081600, + start: 1695081600, }, } } diff --git a/fees/unicrypt.ts b/fees/unicrypt.ts index 922c9432a9..85d5c6d307 100644 --- a/fees/unicrypt.ts +++ b/fees/unicrypt.ts @@ -89,7 +89,7 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: fetch(CHAIN.ETHEREUM), - start: async () => 1661990400, + start: 1661990400, } }, diff --git a/fees/vvs-finance.ts b/fees/vvs-finance.ts index a0b7e46586..76ea751a13 100644 --- a/fees/vvs-finance.ts +++ b/fees/vvs-finance.ts @@ -22,5 +22,5 @@ const adapters = univ2DimensionAdapter({ } }, { }); -adapters.adapter.cronos.start = async () => 1632035122; +adapters.adapter.cronos.start = 1632035122; export default adapters; diff --git a/fees/wigoswap.ts b/fees/wigoswap.ts index 9333bd2208..d7abea453e 100644 --- a/fees/wigoswap.ts +++ b/fees/wigoswap.ts @@ -22,5 +22,5 @@ const adapters = univ2DimensionAdapter({ } }, { }); -adapters.adapter.fantom.start = async () => 1642982400; +adapters.adapter.fantom.start = 1642982400; export default adapters; diff --git a/fees/woofi.ts b/fees/woofi.ts index 3e1a5c7347..8a803926f8 100644 --- a/fees/woofi.ts +++ b/fees/woofi.ts @@ -106,27 +106,27 @@ const adapter: Adapter = { adapter: { [CHAIN.AVAX]: { fetch: fetch(CHAIN.AVAX), - start: async () => 1673222400, + start: 1673222400, }, [CHAIN.BSC]: { fetch: fetch(CHAIN.BSC), - start: async () => 1673222400, + start: 1673222400, }, [CHAIN.FANTOM]: { fetch: fetch(CHAIN.FANTOM), - start: async () => 1673222400, + start: 1673222400, }, [CHAIN.POLYGON]: { fetch: fetch(CHAIN.POLYGON), - start: async () => 1673222400, + start: 1673222400, }, [CHAIN.ARBITRUM]: { fetch: fetch(CHAIN.ARBITRUM), - start: async () => 1673222400, + start: 1673222400, }, [CHAIN.OPTIMISM]: { fetch: fetch(CHAIN.OPTIMISM), - start: async () => 1673222400, + start: 1673222400, }, } } diff --git a/fees/x2y2.ts b/fees/x2y2.ts index aac7088eb1..f3e4c4d2b6 100644 --- a/fees/x2y2.ts +++ b/fees/x2y2.ts @@ -93,7 +93,7 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: fetch(), - start: async () => 1671321600, + start: 1671321600, }, } } diff --git a/fees/yfx-v3.ts b/fees/yfx-v3.ts index 6a7ad76e63..8f6e7e9ee6 100644 --- a/fees/yfx-v3.ts +++ b/fees/yfx-v3.ts @@ -51,8 +51,6 @@ const graphs = (graphUrls: ChainEndpoints) => { liquidityFee += parseFloat(poolFees.poolDataDailyDatas[i].removeLiquidityFee) } - //console.log(swapFee, liquidityFee); - return { timestamp, dailyFees: (swapFee+liquidityFee).toString(), diff --git a/fees/yield-yak-staked-avax.ts b/fees/yield-yak-staked-avax.ts index c05f78a445..55c008e670 100644 --- a/fees/yield-yak-staked-avax.ts +++ b/fees/yield-yak-staked-avax.ts @@ -106,7 +106,7 @@ const adapter: Adapter = { adapter: { [CHAIN.AVAX]: { fetch: fetch, - start: async () => 1636848000, + start: 1636848000, }, } } diff --git a/fees/zapper-channels.ts b/fees/zapper-channels.ts index b6d48dca89..49a08b7b75 100644 --- a/fees/zapper-channels.ts +++ b/fees/zapper-channels.ts @@ -70,7 +70,7 @@ const adapter: Adapter = { adapter: { [CHAIN.BASE]: { fetch: fetch, - start: async () => 1696204800, + start: 1696204800, }, } } diff --git a/fees/zonic.ts b/fees/zonic.ts index 5099e8aeff..c087bda640 100644 --- a/fees/zonic.ts +++ b/fees/zonic.ts @@ -80,31 +80,31 @@ const adapter: Adapter = { adapter: { [CHAIN.OPTIMISM]: { fetch: fetch(CHAIN.OPTIMISM), - start: async () => 1675382400, + start: 1675382400, }, [CHAIN.ARBITRUM]: { fetch: fetch(CHAIN.ARBITRUM), - start: async () => 1675382400, + start: 1675382400, }, [CHAIN.ARBITRUM_NOVA]: { fetch: fetch(CHAIN.ARBITRUM_NOVA), - start: async () => 1675382400, + start: 1675382400, }, [CHAIN.ERA]: { fetch: fetch(CHAIN.ERA), - start: async () => 1679961600, + start: 1679961600, }, [CHAIN.POLYGON_ZKEVM]: { fetch: fetch(CHAIN.POLYGON_ZKEVM), - start: async () => 1679961600, + start: 1679961600, }, [CHAIN.BASE]: { fetch: fetch(CHAIN.BASE), - start: async () => 1692662400, + start: 1692662400, }, [CHAIN.LINEA]: { fetch: fetch(CHAIN.LINEA), - start: async () => 1692662400, + start: 1692662400, } } } diff --git a/fees/zora.ts b/fees/zora.ts index 89e5bbeed6..8e20048533 100644 --- a/fees/zora.ts +++ b/fees/zora.ts @@ -108,7 +108,7 @@ const adapter: Adapter = { adapter: { [CHAIN.ETHEREUM]: { fetch: fetch(), - start: async () => 1669852800, + start: 1669852800, meta: { methodology } diff --git a/helpers/friend-tech.ts b/helpers/friend-tech.ts new file mode 100644 index 0000000000..6edbbfa2a9 --- /dev/null +++ b/helpers/friend-tech.ts @@ -0,0 +1,21 @@ +import { ChainBlocks, Fetch, FetchOptions } from "../adapters/types"; + +const event_trade = 'event Trade(address trader, address subject, bool isBuy, uint256 shareAmount, uint256 ethAmount, uint256 protocolEthAmount, uint256 subjectEthAmount, uint256 supply)' + +export function getFeesExport(FriendtechSharesAddress: string) { + return (async (timestamp: number, _: ChainBlocks, { getLogs, createBalances, }: FetchOptions) => { + const dailyFees = createBalances() + const dailyRevenue = createBalances() + const logs = (await getLogs({ + target: FriendtechSharesAddress, + eventAbi: event_trade + })) + + logs.map((e) => { + dailyFees.addGasToken(e.protocolEthAmount) + dailyFees.addGasToken(e.subjectEthAmount) + dailyRevenue.addGasToken(e.protocolEthAmount) + }) + return { dailyFees, dailyRevenue, timestamp, } + }) as Fetch +} \ No newline at end of file diff --git a/helpers/getBlock.ts b/helpers/getBlock.ts index b87ef821e6..a08f3e4d9b 100644 --- a/helpers/getBlock.ts +++ b/helpers/getBlock.ts @@ -10,9 +10,13 @@ async function getBlock(timestamp: number, chain: Chain, chainBlocks = {} as Cha if (chainBlocks[chain] !== undefined) return chainBlocks[chain] - - let block: number | undefined = await sdk.blocks.getBlockNumber(chain, timestamp) + + let block: number | undefined + try { + block = await sdk.blocks.getBlockNumber(chain, timestamp) + } catch (e) { console.log('error fetching block', e) } + if (block) { chainBlocks[chain] = block return block @@ -24,7 +28,6 @@ async function getBlock(timestamp: number, chain: Chain, chainBlocks = {} as Cha }))?.result?.blockNumber))); else if (chain === CHAIN.KAVA) block = Number((await retry(async () => (await httpGet(`https://explorer.kava.io/api?module=block&action=getblocknobytime×tamp=${timestamp}&closest=before`).catch((e) => { - console.log(`Error getting block: ${chain} ${timestamp} ${e.message}`) throw new Error(`Error getting block: ${chain} ${timestamp} ${e.message}`) }))?.result?.blockNumber))); else if (chain === CHAIN.ONUS) @@ -47,7 +50,6 @@ async function getBlock(timestamp: number, chain: Chain, chainBlocks = {} as Cha }))?.result?.blockNumber))); else block = Number((await retry(async () => (await httpGet(`https://coins.llama.fi/block/${chain}/${timestamp}`).catch((e) => { - console.log(`Error getting block: ${chain} ${timestamp} ${e.message}`) throw new Error(`Error getting block: ${chain} ${timestamp} ${e.message}`) }))?.height, { retries: 3 }))); if (block) chainBlocks[chain] = block diff --git a/helpers/getUniSubgraph/index.ts b/helpers/getUniSubgraph/index.ts index 7dfe440324..4127a9f8b8 100644 --- a/helpers/getUniSubgraph/index.ts +++ b/helpers/getUniSubgraph/index.ts @@ -187,7 +187,7 @@ function getGraphDimensions({ const id = String(getUniswapDateId(new Date(timestamp * 1000))); const cleanTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) const customBlockFunc = getCustomBlock ? getCustomBlock : chainBlocks?.[chain] ? async (_: number) => chainBlocks[chain] : getBlock - const block = await customBlockFunc(timestamp, chain, chainBlocks).catch(e => console.log(e.message)) ?? undefined + const block = await customBlockFunc(timestamp, chain, chainBlocks).catch(e => console.log(wrapGraphError(e).message)) ?? undefined // Execute queries // DAILY VOLUME let graphResDailyVolume @@ -197,7 +197,7 @@ function getGraphDimensions({ graphResDailyVolume = await request(graphUrls[chain], dailyVolumePairsQuery, { timestamp_gt: timestamp - 3600 * 24, timestamp_lte: timestamp - }, graphRequestHeaders?.[chain]).catch(handle200Errors).catch(e => console.error(`Failed to get daily volume on ${chain} with graph ${graphUrls[chain]}: ${e.message}`)) + }, graphRequestHeaders?.[chain]).catch(handle200Errors).catch(e => console.error(`GraphFetchError: Failed to get daily volume on ${chain} with graph ${graphUrls[chain]}: ${wrapGraphError(e).message}`)) dailyVolume = graphResDailyVolume?.[graphFieldsDailyVolume.pairs]?.reduce((acc: number | undefined, current: pair) => { if (blacklistTokens[chain].includes(current.token0.id) || blacklistTokens[chain].includes(current.token1.id)) return acc @@ -208,18 +208,18 @@ function getGraphDimensions({ return acc }, undefined as number | undefined) } else { - graphResDailyVolume = await request(graphUrls[chain], dailyVolumeQuery, { id }, graphRequestHeaders?.[chain]).catch(handle200Errors).catch(e => console.error(`Failed to get daily volume on ${chain} with graph ${graphUrls[chain]}: ${e.message}`)) + graphResDailyVolume = await request(graphUrls[chain], dailyVolumeQuery, { id }, graphRequestHeaders?.[chain]).catch(handle200Errors).catch(e => console.error(`GraphFetchError: Failed to get daily volume on ${chain} with graph ${graphUrls[chain]}: ${wrapGraphError(e).message}`)) dailyVolume = graphResDailyVolume?.[graphFieldsDailyVolume.factory]?.[graphFieldsDailyVolume.field] if (!graphResDailyVolume || !dailyVolume) { console.info("Attempting with alternative query...") - graphResDailyVolume = await request(graphUrls[chain], alternativeDailyQuery, { timestamp: cleanTimestamp }, graphRequestHeaders?.[chain]).catch(handle200Errors).catch(e => console.error(`Failed to get alternative daily volume on ${chain} with graph ${graphUrls[chain]}: ${e.message}`)) + graphResDailyVolume = await request(graphUrls[chain], alternativeDailyQuery, { timestamp: cleanTimestamp }, graphRequestHeaders?.[chain]).catch(handle200Errors).catch(e => console.error(`Failed to get alternative daily volume on ${chain} with graph ${graphUrls[chain]}: ${wrapGraphError(e).message}`)) const factory = graphFieldsDailyVolume.factory.toLowerCase().charAt(graphFieldsDailyVolume.factory.length - 1) === 's' ? graphFieldsDailyVolume.factory : `${graphFieldsDailyVolume.factory}s` dailyVolume = graphResDailyVolume?.[factory].reduce((p: any, c: any) => p + Number(c[graphFieldsDailyVolume.field]), 0); } } // TOTAL VOLUME - const graphResTotalVolume = await request(graphUrls[chain], totalVolumeQuery, { block }, graphRequestHeaders?.[chain]).catch(handle200Errors).catch(e => console.error(`Failed to get total volume on ${chain} with graph ${graphUrls[chain]}: ${e.message}`)); + const graphResTotalVolume = await request(graphUrls[chain], totalVolumeQuery, { block }, graphRequestHeaders?.[chain]).catch(handle200Errors).catch(e => console.error(`GraphFetchError: Failed to get total volume on ${chain} with graph ${graphUrls[chain]}: ${wrapGraphError(e).message}`)); const totalVolume = graphResTotalVolume?.[graphFieldsTotalVolume.factory]?.reduce((total: number, factory: any) => total + Number(factory[graphFieldsTotalVolume.field]), 0)?.toString() // DAILY FEES @@ -287,7 +287,17 @@ function univ2DimensionAdapter(params: IGetChainVolumeParams, meta: BaseAdapter[ return adapter; } +function wrapGraphError(e: Error) { + const message = (e as any).response?.errors?.[0]?.message ?? e.message + return new Error(shortenString(message)) + + function shortenString(str: string, maxLength: number = 420) { + return str.length > maxLength ? str.slice(0, maxLength) + '...' : str + } +} + export { + wrapGraphError, getGraphDimensions, univ2DimensionAdapter, DEFAULT_TOTAL_VOLUME_FACTORY, diff --git a/helpers/getUniSubgraphFees.ts b/helpers/getUniSubgraphFees.ts index 16a9ba5f9a..275be1c616 100644 --- a/helpers/getUniSubgraphFees.ts +++ b/helpers/getUniSubgraphFees.ts @@ -188,8 +188,7 @@ const getDexChainFees = ({ volumeAdapter, totalFees = 0, protocolFees = 0, ...pa return finalBaseAdapter; } else { - console.log("volumeAdapter", volumeAdapter) - console.log(`Failed to grab dex volume data (volume adapter not include 'volume' props)`) + console.log(`Failed to grab dex volume data (volume adapter not include 'volume' props)`, volumeAdapter) return {} } } diff --git a/helpers/getUniSubgraphVolume.ts b/helpers/getUniSubgraphVolume.ts index 99ae918d51..7991c680fe 100644 --- a/helpers/getUniSubgraphVolume.ts +++ b/helpers/getUniSubgraphVolume.ts @@ -5,6 +5,7 @@ import { BaseAdapter, ChainBlocks } from "../adapters/types"; import { SimpleAdapter } from "../adapters/types"; import { DEFAULT_DATE_FIELD, getStartTimestamp } from "./getStartTimestamp"; import { Balances } from "@defillama/sdk"; +import { wrapGraphError } from "./getUniSubgraph"; const getUniqStartOfTodayTimestamp = (date = new Date()) => { @@ -102,14 +103,14 @@ function getChainVolume({ try { return JSON.parse(e.response.error).data } catch (error) { - console.error(`Failed to get total volume on ${chain}: ${e.message}`) + console.error(`Failed to get total volume on ${chain} ${graphUrls[chain]}: ${wrapGraphError(e).message}`) } }) : undefined; let graphResDaily = hasDailyVolume ? await request(graphUrls[chain], graphQueryDailyVolume, { id }).catch(e => { try { return JSON.parse(e.response.error).data } catch (error) { - console.error(`Failed to get daily volume on ${chain}: ${e.message}`) + console.error(`Failed to get daily volume on ${chain} ${graphUrls[chain]}: ${wrapGraphError(e).message}`) } }) : undefined; let dailyVolumeValue = graphResDaily ? graphResDaily[dailyVolume.factory]?.[dailyVolume.field] : undefined @@ -118,7 +119,7 @@ function getChainVolume({ try { return JSON.parse(e.response.error).data } catch (error) { - console.error(`Failed to get daily volume via alternative query on ${chain}: ${e.message}`) + console.error(`Failed to get daily volume via alternative query on ${graphUrls[chain]} ${chain}: ${wrapGraphError(e).message}`) } }); const factory = dailyVolume.factory.toLowerCase().charAt(dailyVolume.factory.length - 1) === 's' ? dailyVolume.factory : `${dailyVolume.factory}s` @@ -161,7 +162,6 @@ function getChainVolumeWithGasToken({ dailyVolume, } = await basic(chain)(timestamp, chainBlocks); - console.log(chain, dailyVolume, timestamp) const balances = new Balances({ chain, timestamp}) balances.add(priceToken, Number(dailyVolume).toFixed(0), { skipChain: true }) diff --git a/options/lyra/getLyraSubgraphVolume.ts b/options/lyra/getLyraSubgraphVolume.ts index c8e29f70a5..eb54f49b69 100644 --- a/options/lyra/getLyraSubgraphVolume.ts +++ b/options/lyra/getLyraSubgraphVolume.ts @@ -1,6 +1,7 @@ import { Chain } from "@defillama/sdk/build/general"; import { request, gql } from "graphql-request"; import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; +import { wrapGraphError } from "../../helpers/getUniSubgraph"; const UNIT = 1e18 @@ -55,7 +56,7 @@ function getChainVolume({ graphUrls }: IGetChainVolumeParams) { dailyVolumeQuery, { timestamp: cleanTimestamp } ).catch((e) => - console.error(`Failed to get total volume on ${chain}: ${e.message}`) + console.error(`Failed to get total volume on ${chain}: ${wrapGraphError(e).message}`) ); diff --git a/options/typus/getChainData.ts b/options/typus/getChainData.ts index 3cf4c93adf..467782e345 100644 --- a/options/typus/getChainData.ts +++ b/options/typus/getChainData.ts @@ -81,12 +81,6 @@ async function getChainData( for (const curr of data) { const parsedJson = curr.parsedJson; - // console.log(parsedJson); - - // const prices = await getPrices( - // ["sui:0x" + parsedJson.o_token.name, "sui:0x" + parsedJson.b_token.name], - // Number(curr.timestampMs) / 1000 - // ); let o_token_name: string; let dailyNotionalVolume: number; @@ -147,8 +141,6 @@ async function getChainData( } } - // console.log(acc); - acc.dailyNotionalVolume = (await sdk.Balances.getUSDString(acc.dailyNotionalVolume, end_timestamp)) as any; acc.dailyPremiumVolume = (await sdk.Balances.getUSDString(acc.dailyPremiumVolume, end_timestamp)) as any; acc.totalPremiumVolume = (await sdk.Balances.getUSDString(acc.totalPremiumVolume, end_timestamp)) as any; diff --git a/protocols/alita-finance/index.ts b/protocols/alita-finance/index.ts index d2d7c7444c..e254015c94 100644 --- a/protocols/alita-finance/index.ts +++ b/protocols/alita-finance/index.ts @@ -24,5 +24,5 @@ const adapter = univ2DimensionAdapter({ } }); -adapter.adapter.bsc.start = async () => 1629947542; +adapter.adapter.bsc.start = 1629947542; export default adapter;