forked from DefiLlama/DefiLlama-Adapters
-
Notifications
You must be signed in to change notification settings - Fork 0
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
cec3d9f
commit 11cd5c2
Showing
1 changed file
with
29 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,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' | ||
} |