Skip to content

Commit 4ef7580

Browse files
Merge pull request DefiLlama#3642 from CaVang/main
Extend chain for MMO project
2 parents ff9ce67 + bcc0b72 commit 4ef7580

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

projects/mmo-finance-polygon/abi.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"inputs": [
3+
{
4+
"internalType": "address",
5+
"name": "pool",
6+
"type": "address"
7+
}
8+
],
9+
"name": "tvlOfPool",
10+
"outputs": [
11+
{
12+
"internalType": "uint256",
13+
"name": "tvl",
14+
"type": "uint256"
15+
}
16+
],
17+
"stateMutability": "view",
18+
"type": "function"
19+
}

projects/mmo-finance-polygon/index.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
const sdk = require("@defillama/sdk");
2+
const abi = require("./abi.json");
3+
const BigNumber = require("bignumber.js");
4+
5+
const dashboardPolygon = "0xFAacEA541e23F0D3eC7d4E202E791923Ce273787";
6+
7+
const poolsPolygon = [
8+
"0x7f64624C36d8356E05E85d7AfCD2F998d3C45bC1",
9+
"0xdC58C5F1BF1090E44AB976Eba60bA3bAe89c1b07",
10+
"0x5CfDf337993555E1FC3E94871642c13703eAb3b9",
11+
"0x56cB79209462A2e3454Cc84FE6B3FE5DC62389f6",
12+
"0x06515Aeb17448D0AeE00A28e3eB617cE7aFe9318",
13+
"0x658188a45B84c36407776320B01b98BD9eDCE9Cd",
14+
"0x95258eB8a10Ba6f8bB61666339eC65bdd380F941",
15+
"0x7dC29143C099919D9380dC74B9Eb95fF847e6536",
16+
"0x804Dc5352f1B3206FF3b0Df58035B80B421CD456",
17+
]
18+
19+
const stakingPolygon = [
20+
"0x2b9299f80a644CA60c0d398e257cb72488875d2A",
21+
"0x7f64624C36d8356E05E85d7AfCD2F998d3C45bC1",
22+
]
23+
24+
const ZERO = new BigNumber(0);
25+
const ETHER = new BigNumber(10).pow(18);
26+
27+
async function TVLPoolPolygon(timestamp, ethBlock, chainBlock) {
28+
const block = chainBlock.polygon;
29+
try {
30+
const total = (
31+
await sdk.api.abi.multiCall({
32+
calls: poolsPolygon.map((address) => ({
33+
target: dashboardPolygon,
34+
params: address,
35+
})),
36+
block,
37+
abi: abi,
38+
chain: "polygon",
39+
})
40+
).output.reduce((tvl, call) => {
41+
let value = call && call.output && new BigNumber(call.output);
42+
if (value) {
43+
return tvl.plus(value.dividedBy(ETHER));
44+
}
45+
return tvl;
46+
}, ZERO);
47+
48+
return {
49+
tether: total.toNumber(),
50+
};
51+
} catch (err) {
52+
console.error(err)
53+
}
54+
}
55+
56+
async function singleStakingPolygon(timestamp, ethBlock, chainBlock) {
57+
const block = chainBlock.polygon;
58+
const total = (
59+
await sdk.api.abi.multiCall({
60+
calls: stakingPolygon.map((address) => ({
61+
target: dashboardPolygon,
62+
params: address,
63+
})),
64+
block,
65+
abi: abi,
66+
chain: "polygon",
67+
})
68+
).output.reduce((tvl, call) => {
69+
let value = call && call.output && new BigNumber(call.output);
70+
if (value) {
71+
return tvl.plus(value.dividedBy(ETHER));
72+
}
73+
return tvl;
74+
}, ZERO);
75+
76+
return {
77+
tether: total.toNumber(),
78+
};
79+
}
80+
81+
module.exports = {
82+
methodology: `Total value in pools`,
83+
misrepresentedTokens: true,
84+
polygon: {
85+
tvl: TVLPoolPolygon,
86+
staking: singleStakingPolygon
87+
},
88+
};

0 commit comments

Comments
 (0)