Skip to content

Commit

Permalink
track nearlenddao (DefiLlama#11231)
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki authored and tlatkdgus1 committed Nov 25, 2024
1 parent cec3d9f commit 11cd5c2
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions projects/nearlenddao/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { call, sumSingleBalance, sumTokens } = require('../helper/chain/near')
const NEARLEND_DAO_CONTRACT = 'v1.nearlend-official.near'

async function borrowed() {
const balances = {};
const assetsCallResponse = await call(NEARLEND_DAO_CONTRACT, 'get_assets_paged', {});

assetsCallResponse.forEach(([token, asset]) => {
const extraDecimals = asset.config.extra_decimals;
sumSingleBalance(balances, token, asset.borrowed.balance / (10 ** extraDecimals));
})

return balances;
}

async function tvl(api) {
const assetsCallResponse = await call(NEARLEND_DAO_CONTRACT, 'get_assets_paged', {});
const tokens = assetsCallResponse.map(([token]) => token);
return sumTokens({ owners: [NEARLEND_DAO_CONTRACT], tokens });
}

module.exports = {
near: {
tvl,
borrowed,
},
timetravel: false,
methodology: 'Summed up all the tokens deposited in their main lending contract'
}

0 comments on commit 11cd5c2

Please sign in to comment.