Skip to content

Commit

Permalink
add Kernel adapter (DefiLlama#10954)
Browse files Browse the repository at this point in the history
* add Kernel adapter

* update sdk

---------

Co-authored-by: 0xpeluche <[email protected]>
Co-authored-by: g1nt0ki <[email protected]>
  • Loading branch information
3 people authored Jul 12, 2024
1 parent b826104 commit 74d778a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/kernel/abi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exports.abi = {
numApprovedTokens: "function numApprovedTokens() view returns (uint256)",
approvedTokens: "function approvedTokens(uint256) view returns (address)",
tokens: "function tokens(address) view returns (address vaultToken, address rateProvider, uint256 cap, uint256 deposited, bool paused)"
};
30 changes: 30 additions & 0 deletions projects/kernel/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const abi = {
tokens: "function tokens(address) view returns (address vaultToken, address rateProvider, uint256 cap, uint256 deposited, bool paused)"
}

const ASSETS = [
"0xf02C96DbbB92DC0325AD52B3f9F2b951f972bf00", // krETH
"0x513D27c94C0D81eeD9DC2a88b4531a69993187cF", // ksETH
"0x0bB9aB78aAF7179b7515e6753d89822b91e670C4", // kUSD
]

const tvl = async (api) => {
const tokens = await api.fetchList({ lengthAbi: 'numApprovedTokens', itemAbi: 'approvedTokens', calls: ASSETS, groupedByInput: true, });
const assets = []
const balanceCalls = []
tokens.forEach((tokens, i) => {
assets.push(...tokens)
balanceCalls.push(...tokens.map(token => ({ target: ASSETS[i], params: token })))
})
const balances = (await api.multiCall({ calls: balanceCalls, abi: abi.tokens })).map(i => i.deposited)
api.add(assets, balances)
};

module.exports = {
doublecounted: true,
methodology: 'The TVL represents the sum of each LST deposited in the protocol',
ethereum: {
tvl,
},
};

0 comments on commit 74d778a

Please sign in to comment.