From f7d15b80e3b228632d826358f301846278be6382 Mon Sep 17 00:00:00 2001 From: waynebruce0x Date: Thu, 13 Oct 2022 17:21:34 +0100 Subject: [PATCH] test fix --- projects/curve/index.js | 94 ++++++++++++++++++++--------------------- test.js | 16 ++++++- 2 files changed, 62 insertions(+), 48 deletions(-) diff --git a/projects/curve/index.js b/projects/curve/index.js index 3e9261cd3f15..213286e5f5bb 100644 --- a/projects/curve/index.js +++ b/projects/curve/index.js @@ -18,7 +18,7 @@ const chains = [ "avax", //-30M "fantom", //-80M "optimism", //-6M - "xdai", //G + //"xdai", //G "moonbeam", "kava" ]; // Object.keys(contracts); @@ -371,52 +371,52 @@ const chainTypeExports = chains => { (obj, chain) => ({ ...obj, [chain]: { tvl: tvl(chain) } }), {} ); - exports.ethereum["staking"] = staking( - contracts.ethereum.veCRV, - contracts.ethereum.CRV - ); - - exports.harmony = { - tvl: async (ts, ethB, chainB) => { - if (ts > 1655989200) { - // harmony hack - return {}; - } - const block = await getBlock(ts, "harmony", chainB, true); - const balances = {}; - await sumTokensSharedOwners( - balances, - [ - "0xef977d2f931c1978db5f6747666fa1eacb0d0339", - "0x3c2b8be99c50593081eaa2a724f0b8285f5aba8f" - ], - ["0xC5cfaDA84E902aD92DD40194f0883ad49639b023"], - block, - "harmony", - addr => `harmony:${addr}` - ); - return balances; - } - }; - exports.kava = { - tvl: async (ts, ethB, chainB) => { - const block = await getBlock(ts, "kava", chainB, true); - const balances = {}; - await sumTokensSharedOwners( - balances, - [ - "0x765277EebeCA2e31912C9946eAe1021199B39C61", - "0xB44a9B6905aF7c801311e8F4E76932ee959c663C", - "0xfA9343C3897324496A05fC75abeD6bAC29f8A40f" - ], - ["0x7A0e3b70b1dB0D6CA63Cac240895b2D21444A7b9"], - block, - "kava", - addr => `kava:${addr}` - ); - return balances; - } - }; + // exports.ethereum["staking"] = staking( + // contracts.ethereum.veCRV, + // contracts.ethereum.CRV + // ); + + // exports.harmony = { + // tvl: async (ts, ethB, chainB) => { + // if (ts > 1655989200) { + // // harmony hack + // return {}; + // } + // const block = await getBlock(ts, "harmony", chainB, true); + // const balances = {}; + // await sumTokensSharedOwners( + // balances, + // [ + // "0xef977d2f931c1978db5f6747666fa1eacb0d0339", + // "0x3c2b8be99c50593081eaa2a724f0b8285f5aba8f" + // ], + // ["0xC5cfaDA84E902aD92DD40194f0883ad49639b023"], + // block, + // "harmony", + // addr => `harmony:${addr}` + // ); + // return balances; + // } + // }; + // exports.kava = { + // tvl: async (ts, ethB, chainB) => { + // const block = await getBlock(ts, "kava", chainB, true); + // const balances = {}; + // await sumTokensSharedOwners( + // balances, + // [ + // "0x765277EebeCA2e31912C9946eAe1021199B39C61", + // "0xB44a9B6905aF7c801311e8F4E76932ee959c663C", + // "0xfA9343C3897324496A05fC75abeD6bAC29f8A40f" + // ], + // ["0x7A0e3b70b1dB0D6CA63Cac240895b2D21444A7b9"], + // block, + // "kava", + // addr => `kava:${addr}` + // ); + // return balances; + // } + // }; exports.hallmarks = [ [1597446675, "CRV Launch"], [1621213201, "Convex Launch"], diff --git a/test.js b/test.js index c258c74270ea..49985df6a1e7 100644 --- a/test.js +++ b/test.js @@ -341,6 +341,18 @@ const confidenceThreshold = 0.5 async function computeTVL(balances, timestamp) { fixBalances(balances) + Object.keys(balances).map(k => { + if (+balances[k] === 0) { + delete balances[k] + return; + } + if (k.toLowerCase() === k) return; + balances[k.toLowerCase()] = (k.toLowerCase() in balances) + ? Number(balances[k.toLowerCase()]) + + Number(balances[k]) : balances[k]; + delete balances[k] + }) + const eth = balances[ethereumAddress]; if (eth !== undefined) { balances[weth] = new BigNumber(balances[weth] ?? 0).plus(eth).toFixed(0); @@ -397,7 +409,9 @@ async function computeTVL(balances, timestamp) { amount = Number(balance); usdAmount = amount * data.price; } - + if (isNaN(usdAmount)) { + console.log('hi') + } tokenBalances[data.symbol] = (tokenBalances[data.symbol] ?? 0) + amount; usdTokenBalances[data.symbol] = (usdTokenBalances[data.symbol] ?? 0) + usdAmount; usdTvl += usdAmount;