Skip to content

Commit 3bd0adf

Browse files
committed
track obsidian DefiLlama#15357
1 parent e1753f7 commit 3bd0adf

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

projects/obsidian/index.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
const { getUniTVL } = require('../helper/unknownTokens')
2+
const { sumTokens2 } = require('../helper/unwrapLPs')
3+
4+
// TVL DEX Factories
5+
const V2_FACTORY_CRONOS = '0xCd2E5cC83681d62BEb066Ad0a2ec94Bf301570C9';
6+
const V2_FACTORY_ZKEVM = '0xEDc17bf0f27afc2e767cA08aE426d095207A7804';
7+
8+
// Staking contracts
9+
const SMART_CHEF_FACTORY_CRONOS = "0x1eC6e891Bdaa523da0F538C9556064D909d0c566";
10+
const SMART_CHEF_FACTORY_ZKEVM = "0x4E5CDf0A7a13f05e4168E3B2b9ba96c740877275";
11+
const ROBIN_DIAMOND_CONTRACT = "0x6D5599616732Ea278235b47A76Cfd398fDe00DEB";
12+
const FIXED_STAKING_CONTRACT = "0x1215B773d67fd9ed17656B08e223caEF4a93904f";
13+
14+
const liquidityPoolsCronos = getUniTVL({ factory: V2_FACTORY_CRONOS, useDefaultCoreAssets: true })
15+
const liquidityPoolsZkEVM = getUniTVL({ factory: V2_FACTORY_ZKEVM, useDefaultCoreAssets: true })
16+
17+
async function stakingSmartChef(factoryAddress, api) {
18+
const [poolAddresses, stakedTokens] = await api.call({
19+
abi: "function getAllPoolTVL() view returns (address[] poolAddresses, address[] stakedTokens, uint256[] stakedAmounts)",
20+
target: factoryAddress,
21+
});
22+
23+
return sumTokens2({ tokensAndOwners2: [stakedTokens, poolAddresses], api });
24+
}
25+
26+
async function stakingPoolContract(api, contractAddress, poolAbi) {
27+
const poolLength = await api.call({ target: contractAddress, abi: "uint256:poolLength" });
28+
const tokens = await api.fetchList({ lengthAbi: "uint256:poolLength", itemAbi: poolAbi, target: contractAddress });
29+
return sumTokens2({
30+
api,
31+
owner: contractAddress, tokens: tokens.map(i => i.token),
32+
});
33+
}
34+
35+
async function stakingRobinDiamond(api) {
36+
return stakingPoolContract(
37+
api,
38+
ROBIN_DIAMOND_CONTRACT,
39+
"function pools(uint256) view returns (address token, address rewardToken, uint256, uint256 totalDeposited, uint256, uint256, uint256, uint256, address, uint256)"
40+
);
41+
}
42+
43+
async function stakingFixedStaking(api) {
44+
return stakingPoolContract(
45+
api,
46+
FIXED_STAKING_CONTRACT,
47+
"function pools(uint256) view returns (address token, uint32 endDay, uint32 lockDayPercent, uint32 unlockDayPercent, uint32 lockPeriod, uint32 withdrawalCut1, uint32 withdrawalCut2, bool depositEnabled, uint128 maxDeposit, uint128 minDeposit, uint128 totalDeposited, uint128 maxPoolAmount)"
48+
);
49+
}
50+
51+
async function cronosStaking(api) {
52+
await Promise.all([
53+
stakingSmartChef(SMART_CHEF_FACTORY_CRONOS, api),
54+
stakingRobinDiamond(api),
55+
stakingFixedStaking(api),
56+
]);
57+
}
58+
59+
async function zkevmStaking(api) {
60+
return stakingSmartChef(SMART_CHEF_FACTORY_ZKEVM, api);
61+
}
62+
63+
module.exports = {
64+
misrepresentedTokens: true,
65+
methodology: "TVL includes all liquidity pools from Obsidian V2 factories across Cronos and Cronos zkEVM. Staking includes tokens staked in Fixed Staking, SmartChefFactory, and RobinDiamondHands contracts for yield farming and staking rewards.",
66+
cronos: {
67+
tvl: liquidityPoolsCronos,
68+
staking: cronosStaking,
69+
},
70+
cronos_zkevm: {
71+
tvl: liquidityPoolsZkEVM,
72+
staking: zkevmStaking,
73+
},
74+
};

0 commit comments

Comments
 (0)