-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62784e7
commit d1f4ba5
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const { sumTokens2 } = require('../helper/unwrapLPs') | ||
|
||
const factories = { | ||
mantle: '0xa6630671775c4EA2743840F9A5016dCf2A104054', | ||
} | ||
async function tvl(api) { | ||
const pools = await api.fetchList({ | ||
target: factories[api.chain], | ||
itemAbi: 'function getLBPairAtIndex(uint256) view returns (address)', | ||
lengthAbi: 'uint256:getNumberOfLBPairs', | ||
}) | ||
const tokenA = await api.multiCall({ | ||
abi: 'address:getTokenX', | ||
calls: pools, | ||
}) | ||
const tokenB = await api.multiCall({ | ||
abi: 'address:getTokenY', | ||
calls: pools, | ||
}) | ||
const toa = [] | ||
tokenA.map((_, i) => { | ||
toa.push([tokenA[i], pools[i]]) | ||
toa.push([tokenB[i], pools[i]]) | ||
}) | ||
return sumTokens2({ api, tokensAndOwners: toa, }) | ||
} | ||
|
||
module.exports = { | ||
methodology: 'We count the token balances in in different liquidity book contracts', | ||
} | ||
|
||
Object.keys(factories).forEach(chain => { | ||
module.exports[chain] = { tvl } | ||
}) |