Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ftm1337 authored Jul 21, 2024
1 parent 17b8373 commit b51e9e7
Showing 1 changed file with 56 additions and 3 deletions.
59 changes: 56 additions & 3 deletions projects/elocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,37 @@ async function findTvl(chain, nft, block, api) {
chain,
})
len = Number(len);
//console.log("nft.ts", len);


/*
/// Using TVL GURU (on-chain price calcs)
let calls = []
for (let i = 1; i <= len; i++) { calls.push({ params: [i] }) }
let { output: lockaddrs } = await sdk.api.abi.multiCall({
target: nft,
abi: IELOCKS.lockers,
calls,
chain,
})
lockaddrs = lockaddrs.map(i=>i.output)
//console.log("lockaddrs",lockaddrs)
const ltvls = (
await sdk.api.abi.multiCall({
abi: IELOCKS.tvl,
calls: lockaddrs.map((la) => ({ target: la })),
chain
})
).output.map((tvl) => Number(tvl.output)/1e18);
//console.log("ltvls",ltvls)
return { tether: ltvls.reduce((a,b)=>a+b) };
*/


/// Using DefiLlama pricing

let calls = []
for (let i = 1; i <= len; i++) { calls.push({ params: [i] }) }
Expand All @@ -36,10 +67,32 @@ async function findTvl(chain, nft, block, api) {
calls,
chain,
})
lpBalances = las.map(i=> ({token: i.output[0], balance: Number(i.output[1])/1e0}) )
tokens = lpBalances.map(i=>i.token)
bals = lpBalances.map(i=>i.balance)
/*
/// Using { 0x123: 123, 0xtoken2: 456, ... }
//las = las.map(i=> ({lpt: i.output[0], amt: Number(i.output[1])/1e0}) )
las = las.map(i=> ({ [i.output[0].toLowerCase()] : Number(i.output[1])/1e0 }) )
let lpamts = {};
las.forEach(obj => {
for (let key in obj) {
if (lpamts[key]) {
lpamts[key] += obj[key];
} else {
lpamts[key] = obj[key];
}
}
});
//console.log("las",las,lpamts)
console.log(await getTokenPrices(lpamts))
return lpamts;
*/
let lpBalances = las.map(i=> ({token: i.output[0], balance: Number(i.output[1])/1e0}) )
//console.log("las",las,lpBalances)
let tokens = lpBalances.map(i=>i.token)
let bals = lpBalances.map(i=>i.balance)
api.addTokens(tokens, bals)
//return await sumUnknownTokens({ api, tokensAndOwners: [], useDefaultCoreAssets: true, lps: tokens, resolveLP: true, })
//await unwrapUniswapLPs(lpBalances, chain)
return await unwrapUniswapLPs(bals, lpBalances, block, chain)
}

Expand Down

0 comments on commit b51e9e7

Please sign in to comment.