From 6d777829bb45c6db6dcc50724b31f82c28bfdd24 Mon Sep 17 00:00:00 2001 From: starketh25 Date: Fri, 27 Dec 2024 20:05:39 +0530 Subject: [PATCH] chore: remove unneccesary call in v3 pool --- src/adaptors/fenix-finance/index.js | 52 ++++------------------------- 1 file changed, 6 insertions(+), 46 deletions(-) diff --git a/src/adaptors/fenix-finance/index.js b/src/adaptors/fenix-finance/index.js index 1f6e5b44a..2bd2f40d0 100644 --- a/src/adaptors/fenix-finance/index.js +++ b/src/adaptors/fenix-finance/index.js @@ -82,53 +82,13 @@ const getApy = async () => { } } - const alreadySeen = []; - for (const pair of pairs) { - const token0Key = 'blast:' + pair.token0.id.toLowerCase(); - const token1Key = 'blast:' + pair.token1.id.toLowerCase(); - - if (!alreadySeen.includes(token0Key)) { - alreadySeen.push(token0Key); - } - if (!alreadySeen.includes(token1Key)) { - alreadySeen.push(token1Key); - } - } - - let fullCoin = {}; - const chunkSize = 60; - for (let i = 0; i < alreadySeen.length; i += chunkSize) { - const chunk = alreadySeen.slice(i, i + chunkSize); - const { coins } = await utils.getData( - `https://coins.llama.fi/prices/current/${chunk.join( - ',' - )}?searchWidth=4h` - ); - fullCoin = { ...fullCoin, ...coins }; - } - const pools = pairs.map((pair) => { let tvl = 0; - if ( - fullCoin['blast:' + pair.token0.id.toLowerCase()] && - fullCoin['blast:' + pair.token1.id.toLowerCase()] - ) { - // Fix: Use pair properties for TVL calculation - const token0Price = - fullCoin['blast:' + pair.token0.id.toLowerCase()].price; - const token1Price = - fullCoin['blast:' + pair.token1.id.toLowerCase()].price; - - const token0ValueInReserve = - parseFloat(pair.totalValueLockedToken0) * token0Price; - const token1ValueInReserve = - parseFloat(pair.totalValueLockedToken1) * token1Price; - - tvl = token0ValueInReserve + token1ValueInReserve; - } else { - tvl = parseFloat(pair.totalValueLockedUSD); - } + const token0ValueInReserve = parseFloat(pair.totalValueLockedToken0); + const token1ValueInReserve = parseFloat(pair.totalValueLockedToken1); + + tvl = token0ValueInReserve + token1ValueInReserve; const poolData = { pool: pair.id, @@ -143,14 +103,14 @@ const getApy = async () => { return poolData; }); - + console.log(pools); return pools; } catch (error) { console.error('Error in getApy:', error); throw error; } }; - +getApy(); module.exports = { timetravel: false, apy: getApy,