Skip to content

Commit a20fa18

Browse files
committed
track shmonad #17156
1 parent 0596fc1 commit a20fa18

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

projects/shmonad/index.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Shmonad Protocol - DeFiLlama TVL Adapter
2+
// TVL is calculated as: staked + reserved + allocated - distributed + currentAssets
3+
4+
const SHMONAD_CONTRACT = '0x1B68626dCa36c7fE922fD2d55E4f631d962dE19c';
5+
6+
// ABI for the contract functions
7+
const SHMONAD_ABI = {
8+
getAtomicCapital: 'function getAtomicCapital() view returns (uint256 allocated, uint256 distributed)',
9+
getCurrentAssets: 'function getCurrentAssets() view returns (uint256)',
10+
getWorkingCapital: 'function getWorkingCapital() view returns (uint256 staked, uint256 reserved)',
11+
};
12+
13+
async function tvl(api) {
14+
const atomicCapital = await api.call({ target: SHMONAD_CONTRACT, abi: SHMONAD_ABI.getAtomicCapital, })
15+
const currentAssetsValue = await api.call({ target: SHMONAD_CONTRACT, abi: SHMONAD_ABI.getCurrentAssets, })
16+
const workingCapital = await api.call({ target: SHMONAD_CONTRACT, abi: SHMONAD_ABI.getWorkingCapital, })
17+
18+
// Extract values from the results
19+
// getAtomicCapital returns a tuple: {allocated, distributed} or [allocated, distributed]
20+
const allocated = atomicCapital.allocated
21+
const distributed = atomicCapital.distributed
22+
23+
// getWorkingCapital returns a tuple: {staked, reserved} or [staked, reserved]
24+
const staked = workingCapital.staked
25+
const reserved = workingCapital.reserved
26+
27+
// Calculate TVL: staked + reserved + allocated - distributed + currentAssets
28+
const tvlBigInt = BigInt(staked) + BigInt(reserved) + BigInt(allocated) - BigInt(distributed) + BigInt(currentAssetsValue);
29+
30+
// Add the MON token balance to TVL
31+
api.addGasToken(tvlBigInt);
32+
}
33+
34+
module.exports = {
35+
methodology: 'TVL is calculated as the sum of staked, reserved, allocated capital (minus distributed), and current assets held by the Shmonad protocol.',
36+
monad: {
37+
tvl,
38+
},
39+
};
40+

0 commit comments

Comments
 (0)