Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: nimbora tvl calculation #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions projects/nimbora/abi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const L1TroveInterface = [{
name:"getEntireDebtAndColl",
type:"function",
inputs:[{
internalType:"address",
name:"_borrower",
type:"address"
}],
outputs:[{
internalType:"uint256",
name:"debt",
type:"uint256"
},
{
internalType:"uint256",
name:"coll",
type:"uint256"
}]
}];

const L1TroveAbi = {};

L1TroveInterface.forEach((i) => (L1TroveAbi[i.name] = i));

module.exports = {
L1TroveAbi
};
31 changes: 31 additions & 0 deletions projects/nimbora/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { L1TroveAbi } = require('./abi');
const { multiCall } = require('@defillama/sdk/build/abi');

const TROVE_HIGH_RISK = "0xEF3cf0ede2cA738A8Bd0c38fd5D43DC639B41532";
const TROVE_MEDIUM_RISK = "0x4cdB2fdE85Da92Dbe9b568dda2Cc22d426b0b642";
const TROVE_MANAGER = "0xA39739EF8b0231DbFA0DcdA07d7e29faAbCf4bb2";
const ETH_L2_ADDRESS = "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7";

async function tvl(_, _1, _2, { api }) {
const calls = [{params: [TROVE_HIGH_RISK]}, {params: [TROVE_MEDIUM_RISK]}];

var tvl = 0;
const multicallResponse = await multiCall({
abi: L1TroveAbi.getEntireDebtAndColl,
calls: calls,
target: TROVE_MANAGER,
chain: 'ethereum'
});

multicallResponse.output.forEach(response => {
tvl += Number(response.output.coll);
});
api.addToken(ETH_L2_ADDRESS, tvl);
}

module.exports = {
methodology: "The TVL is calculated as a sum of total assets deposited into the Trove contracts.",
starknet: {
tvl,
},
};