Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
waynebruce0x committed Oct 13, 2022
1 parent fd01e55 commit f7d15b8
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 48 deletions.
94 changes: 47 additions & 47 deletions projects/curve/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const chains = [
"avax", //-30M
"fantom", //-80M
"optimism", //-6M
"xdai", //G
//"xdai", //G
"moonbeam",
"kava"
]; // Object.keys(contracts);
Expand Down Expand Up @@ -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"],
Expand Down
16 changes: 15 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f7d15b8

Please sign in to comment.