From 6ad7b83084e29cf2dec6ef952c854ce743c91cf8 Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Wed, 22 Nov 2023 13:23:14 +0200 Subject: [PATCH] chore: undo consolidation of monetary amounts - having monetary amount pairs can be useful and consolidation can easily be done by consumers of the api instead --- api/tvl_dex.js | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/api/tvl_dex.js b/api/tvl_dex.js index 471d8cee3..0c16070dc 100644 --- a/api/tvl_dex.js +++ b/api/tvl_dex.js @@ -1,23 +1,6 @@ import { createInterBtcApi } from "@interlay/interbtc-api"; import { getCoingeckoId, getCoingeckoQueryUrl, getUsdMonetaryAmount } from "./currency-utils"; -const consolidateMonetaryAmounts = (monetaryAmounts) => { - // { : } - const tickerToAmountMap = new Map(); - - monetaryAmounts.forEach(monAmt => { - const ticker = monAmt.currency.ticker; - if (tickerToAmountMap.has(ticker)) { - const newMonAmt = tickerToAmountMap.get(ticker).add(monAmt); - tickerToAmountMap.set(ticker, newMonAmt); - } else { - tickerToAmountMap.set(ticker, monAmt); - } - }); - - return Array.from(tickerToAmountMap.values()); -}; - const tvlDex = async (request, response) => { if (request.method === 'GET') { const interbtcApi = await createInterBtcApi( @@ -40,9 +23,7 @@ const tvlDex = async (request, response) => { const cgResponse = await fetch(queryUrl, { headers: { "accept": "application/json" } }); const cgData = await cgResponse.json(); - const allAmounts = pools.flatMap((pool) => pool.pooledCurrencies); - - const amounts = consolidateMonetaryAmounts(allAmounts) + const amounts = pools.flatMap((pool) => pool.pooledCurrencies) .map((monetaryAmount) => { const atomicAmount = monetaryAmount.toString(true); const amount = monetaryAmount.toString();