Skip to content

Commit

Permalink
add btc tvl
Browse files Browse the repository at this point in the history
  • Loading branch information
tlatkdgus1 committed Nov 25, 2024
1 parent 2fea544 commit 8c55a96
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion projects/btcfi-cdp/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const ADDRESSES = require('../helper/coreAssets.json')
const { sumTokensExport, } = require('../helper/unwrapLPs')
const { sumTokens } = require("../helper/chain/bitcoin");
const { ethers } = require("ethers");

const chainPools = {
bfc: {
Expand All @@ -8,10 +10,33 @@ const chainPools = {
},
}

const targetContract = "0x0000000000000000000000000000000000000100";
const rpc = "https://public-01.mainnet.bifrostnetwork.com/rpc";

async function fetchVaultAddresses() {
const vaultContract = new ethers.Contract(
targetContract,
["function vault_addresses(uint32 pool_round) view returns (string[])"],
new ethers.JsonRpcProvider(rpc)
);

const vaultAddresses = await vaultContract.vault_addresses(0);

return vaultAddresses
}

async function bitcoinTvl() {
return sumTokens({ owners: await fetchVaultAddresses() })
}

Object.keys(chainPools).forEach(chain => {
const pools = chainPools[chain]
const tokensAndOwners = Object.values(pools).map(({ pool, token }) => ([token, pool,]))
module.exports[chain] = {
tvl: sumTokensExport({ tokensAndOwners })
}
})
})

module.exports["bitcoin"] = {
tvl: bitcoinTvl,
}

0 comments on commit 8c55a96

Please sign in to comment.