Skip to content

Commit

Permalink
update yieldflow (#11168)
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Aug 2, 2024
1 parent 1cf6542 commit 4f1a93b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion projects/yieldflow/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const ADDRESSES = require('../helper/coreAssets.json')

const abi = {
"getCurrentTokenId": "function currentTokenId() view returns (uint)",
"getPositions": "function positions(uint256 tokenId) view returns (uint96 nonce,address operator,address token0,address token1,uint24 fee,int24 tickLower,int24 tickUpper,uint128 liquidity,uint256 feeGrowthInside0LastX128,uint256 feeGrowthInside1LastX128,uint128 tokensOwed0,uint128 tokensOwed1)",
Expand Down Expand Up @@ -73,11 +75,12 @@ async function tvl(api) {
const liquidities = await api.multiCall({ abi: abi.getPositions, calls: positionManagers.map((v, i) => ({ target: v, params: tokenIds[i] })) })
const tokenAmounts = await api.multiCall({ abi: abi.getAmountsForTicks, calls: liquidities.map((v, i) => ({ target: managers[i], params: [v.tickLower, v.tickUpper, v.liquidity] })) })

const ownerTokens = liquidities.map((v, i) => [[v.token0, v.token1, ADDRESSES.null], managers[i]])
liquidities.forEach((v, i) => {
api.add(v.token0, tokenAmounts[i][0])
api.add(v.token1, tokenAmounts[i][1])
})
return api.getBalances()
return api.sumTokens({ ownerTokens })
}

module.exports = {
Expand Down

0 comments on commit 4f1a93b

Please sign in to comment.