Skip to content

Commit f914c52

Browse files
luminfinancestephang1nt0ki
authored
add lumin finance tvl and staking adapter (DefiLlama#9704)
* add lumin finance tvl and staking adapter * code refactor --------- Co-authored-by: stephan <[email protected]> Co-authored-by: g1nt0ki <[email protected]>
1 parent 05a0013 commit f914c52

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

projects/lumin-finance/index.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const { nullAddress } = require("../helper/tokenMapping");
2+
const { staking } = require('../helper/staking')
3+
4+
const LUMIN_V1_CONTRACT_ASSET_MANAGER = "0x61c6b185fafd2727ddeac6247e6770f5eadd823a"
5+
const LUMIN_V2_CONTRACT = "0x1F00009c0310A4804925695F44355dE5110EC074"
6+
7+
const abi = {
8+
v1: {
9+
assetIds: "function getRegisteredAssetIDs() view returns (bytes4[] memory)",
10+
asset: "function getAsset(bytes4) view returns ((address, uint8, uint8, uint8, uint256) memory)",
11+
depositOf: "function depositOf(bytes4, address) view returns (uint128, uint128)"
12+
},
13+
v2: {
14+
stakeStats: "function getStakeStats() view returns ((uint64, uint72, uint24, uint24, uint24, uint24, uint24) memory, (uint64, uint72, uint24, uint24, uint24, uint24, uint24) memory)",
15+
}
16+
}
17+
18+
async function tvl(api) {
19+
const assetIds = await api.call({ abi: abi.v1.assetIds, target: LUMIN_V1_CONTRACT_ASSET_MANAGER });
20+
const assetData = await api.multiCall({ abi: abi.v1.asset, calls: assetIds, target: LUMIN_V1_CONTRACT_ASSET_MANAGER })
21+
const tokens = assetData.map(asset => asset[0])
22+
return api.sumTokens({ tokens, owner: LUMIN_V1_CONTRACT_ASSET_MANAGER })
23+
}
24+
25+
async function borrowed(api) {
26+
const assetIds = await api.call({ abi: abi.v1.assetIds, target: LUMIN_V1_CONTRACT_ASSET_MANAGER });
27+
const assetData = await api.multiCall({ abi: abi.v1.asset, calls: assetIds, target: LUMIN_V1_CONTRACT_ASSET_MANAGER })
28+
const tokens = assetData.map(asset => asset[0])
29+
const deposit = await api.multiCall({ abi: abi.v1.depositOf, target: LUMIN_V1_CONTRACT_ASSET_MANAGER, calls: assetIds.map(i => ({ params: [i, nullAddress] })) });
30+
tokens.forEach((token, i) => api.add(token, deposit[i][1]))
31+
}
32+
33+
module.exports = {
34+
methodology: 'Gets v1 total deposits, and v2 staking statistics on-chain.',
35+
start: 194344665,
36+
arbitrum: {
37+
staking: staking('0x1F5FAB72ED3Be2F1cf8F4E20BC9096C94a04D5c5', '0x1FC01117E196800f416A577350CB1938d10501C2'),
38+
tvl, borrowed,
39+
}
40+
}

0 commit comments

Comments
 (0)