Skip to content

Commit

Permalink
Ajira2 (DefiLlama#8971)
Browse files Browse the repository at this point in the history
* feat: Ajira Pay Finance V2

* update: activate linea chain and recalculate tvl

* code refactor

---------

Co-authored-by: dickensodera <[email protected]>
  • Loading branch information
g1nt0ki and dickensodera authored Feb 15, 2024
1 parent 50e0f8f commit d680b23
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions projects/ajira-pay-finance-v2/index.js
Original file line number Diff line number Diff line change
@@ -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})})
}
}
})
2 changes: 2 additions & 0 deletions projects/helper/streamingHelper.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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
Expand Down

0 comments on commit d680b23

Please sign in to comment.