Skip to content

Commit

Permalink
updates neutrino adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Mar 11, 2024
1 parent 67f2e9d commit 2335910
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion projects/helper/chain/waves.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ const tokenMapping = {
'HGgabTqUS8WtVFUJzfmrTDMgEccJuZLBPhFgQFxvnsoW': { cgId: 'usd-coin', decimals: 6 },
}

async function sumTokens({ owners, api, includeWaves = true, }) {
async function sumTokens({ owners, api, includeWaves = true, blacklistedTokens = [] }) {
blacklistedTokens = new Set(blacklistedTokens)
await Promise.all(
owners.map(async (owner) => {
const { balances } = await get(API_HOST + `assets/balance/${owner}`);
balances.forEach(({ assetId, balance }) => {
if (blacklistedTokens.has(assetId)) return;
if (tokenMapping[assetId]) {
const { cgId, decimals } = tokenMapping[assetId]
api.addCGToken(cgId, balance / (10 ** decimals))
Expand Down
12 changes: 9 additions & 3 deletions projects/neutrino/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
const { wavesExport } = require('../helper/chain/wavesAdapter')
const { sumTokens } = require('../helper/chain/waves')

const endpoint = "/neutrino"

module.exports = wavesExport(endpoint, item => item.usdnLocked + item.defoLocked)
module.exports = {
waves: { tvl }
}

async function tvl(_, _b, _cb, { api, }) {
return sumTokens({ owners: ['3PC9BfRwJWWiw9AREE2B3eWzCks3CYtg4yo',], includeWaves: true, api, blacklistedTokens: ['DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p', '6nSpVyNH7yM69eg446wrQR94ipbbcmZMU1ENPwanC97g'] })

}
2 changes: 0 additions & 2 deletions projects/vires/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const { sumTokens, call } = require('../helper/chain/waves')

const endpoint = "/vires"

module.exports = {
timetravel: false,
methodology: `Counts the tokens locked in the contracts to be used as collateral to borrow or to earn yield. Borrowed coins are not counted towards the TVL, so only the coins actually locked in the contracts are counted. There's multiple reasons behind this but one of the main ones is to avoid inflating the TVL through cycled lending`,
Expand Down

0 comments on commit 2335910

Please sign in to comment.