diff --git a/projects/ajira-pay-finance-v2/index.js b/projects/ajira-pay-finance-v2/index.js new file mode 100644 index 000000000000..fc70752ffea7 --- /dev/null +++ b/projects/ajira-pay-finance-v2/index.js @@ -0,0 +1,25 @@ +const { covalentGetTokens } = require('../helper/token') +const { getWhitelistedTokens } = require('../helper/streamingHelper') + +const config = { + linea: { owners: ['0xD2AA294B9A5097F4A09fd941eD0bE665bd85Eab2'], }, +} + +module.exports = { + methodology: "TVL is based on the active balances of assets deposited at the V2 stream vaults for token streaming and vesting.", +} + +Object.keys(config).forEach(chain => { + const { owners } = config[chain] + module.exports[chain] = { + tvl: tvl(false), + vesting: tvl(true), + } + + function tvl(isVesting) { + return async (_, _1, _2, { api }) => { + const tokens = (await Promise.all(owners.map(i => covalentGetTokens(i, api, { onlyWhitelisted: false, })))).flat() + return api.sumTokens({ owners, tokens: await getWhitelistedTokens({ api, tokens, isVesting})}) + } + } +}) \ No newline at end of file diff --git a/projects/helper/streamingHelper.js b/projects/helper/streamingHelper.js index af7fcea9a30b..82feff3b985d 100644 --- a/projects/helper/streamingHelper.js +++ b/projects/helper/streamingHelper.js @@ -1,4 +1,5 @@ const ADDRESSES = require('./coreAssets.json') +const { getUniqueAddresses } = require('./tokenMapping') let stableTokens = ['USDC', 'USDT', 'DAI', 'WETH', 'WFTM', 'WGLMR', 'WBNB', 'WAVAX', 'JCHF', 'JEUR', 'WBTC', 'AGDAI', 'JPYC', 'MIMATIC', 'WXDAI', 'EURS', 'JGBP', 'CNT', 'USD+', 'AMUSDC', 'RAI', 'SLP', 'SDAM3CRV', 'AMDAI', 'TUSD', 'RAI', 'UNI-V2', 'SLP', 'ScUSDC', 'cUSDC', 'iDAI', 'FTM', 'yUSDC', 'cDAI', 'MATIC', 'UST', 'stETH', 'USD', 'mUSD', 'iUSDC', 'aDAI', 'AGEUR', 'BCT', 'WMATIC', @@ -10,6 +11,7 @@ function isStableToken(symbol = '', address = '') { } async function getWhitelistedTokens({ api, tokens, isVesting }) { + tokens = getUniqueAddresses(tokens) const symbols = await api.multiCall({ abi: 'string:symbol', calls: tokens, permitFailure: true}) tokens = tokens.filter((v, i) => isWhitelistedToken(symbols[i], v, isVesting)) return tokens