Skip to content

Commit 77e2522

Browse files
committed
Refactor TVL calculation and add Ethereum support for Mineral Vault
Simplified the TVL calculation to use only total supply for both Plume Mainnet and Ethereum, removing issuer reserve wallet logic. Added Ethereum chain support with its own TVL function.
1 parent e97c189 commit 77e2522

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

projects/mineral-vault/index.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
1-
async function tvl_plume_mainnet(api) {
2-
const mineralVaults = ["0x5107272921A750A20d492Fb41Acf0b770b09a624"];
3-
const issuerReserveWallets = ["0xCcBA2623B2CE6148c09d8E676B81E472D85c21Ea"];
1+
const mineralVaults = ["0x9D08946Ca5856f882A56c29042FbEDC5142663b9"];
42

3+
async function tvl_ethereum(api) {
54
const totalSupplies = await api.multiCall({ abi: 'erc20:totalSupply', calls: mineralVaults });
6-
const issuerReserveBalances = await api.multiCall({
7-
abi: 'erc20:balanceOf',
8-
calls: mineralVaults.flatMap(token => issuerReserveWallets.map(owner => ({ target: token, params: owner })))
9-
});
10-
11-
const circulatingSupplies = mineralVaults.map((vault, index) => {
12-
const reserveBalances = issuerReserveWallets
13-
.map((_, j) => BigInt(issuerReserveBalances[index * issuerReserveWallets.length + j]))
14-
.reduce((a, b) => a + b, 0n);
15-
return {
16-
vault,
17-
circulating: BigInt(totalSupplies[index]) - reserveBalances
18-
};
19-
});
5+
api.add(mineralVaults, totalSupplies);
6+
}
207

21-
circulatingSupplies.forEach(({ vault, circulating }) => api.add(vault, circulating));
8+
async function tvl_plume_mainnet(api) {
9+
const totalSupplies = await api.multiCall({ abi: 'erc20:totalSupply', calls: mineralVaults });
10+
api.add(mineralVaults, totalSupplies);
2211
}
2312

2413
module.exports = {
2514
methodology: "TVL is the total supply of tokens, each representing a fully-backed real-world oil & gas asset from Mineral Vault funds.",
15+
ethereum: { tvl: tvl_ethereum },
2616
plume_mainnet: { tvl: tvl_plume_mainnet },
2717
}

0 commit comments

Comments
 (0)