Skip to content

Commit b2b0430

Browse files
committed
minor fix
1 parent 9217468 commit b2b0430

File tree

3 files changed

+16
-229
lines changed

3 files changed

+16
-229
lines changed

projects/saharadao/index.js

Lines changed: 9 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
const BigNumber = require('bignumber.js')
21
const Abis = require("./abi.json");
3-
const sdk = require("@defillama/sdk");
42

53
const Contracts = {
64
cronos: {
@@ -11,128 +9,25 @@ const Contracts = {
119
bankMusd: "0xa23608087908F3812219886bCec68c4FA77A9eE5",
1210
multiFeeDistribution: "0xE6F7ADf2F2aCd219Ca68136cd47C2C826a3Ba1A9",
1311
chef: "0x6F132536069F8E35ED029CEd563710CF68fE8E54",
14-
mmfLps: [
15-
{
16-
address: "0xa7bE5cB8Be6484c06aBb8942fe682797bb9A76Ec", // MNG_MMF_LP
17-
isToken0: true
18-
},
19-
{
20-
address: "0x80fdDa345e707dd9e518094b9B50027D9AF148F4", // MMFX_MMF_LP
21-
isToken0: true
22-
}
23-
],
24-
musdLps: [
25-
{
26-
address: "0x6b4D24758a65c5bB2fC377B3b45e8b020ba6A4c1", // MNG_MUSD_LP
27-
isToken0: true
28-
},
29-
{
30-
address: "0xE516830c6dE6E1b653230370CD236c78DB9F66bf", // MMUSD_MUSD_LP
31-
isToken0: true
32-
}
33-
]
3412
},
3513
};
3614

37-
async function calcTvl(timestamp, ethBlock, chainBlocks) {
38-
const block = chainBlocks.cronos;
39-
const chain = "cronos";
40-
41-
const bankBalance = await sdk.api.abi.call({
42-
target: Contracts.cronos.bank,
43-
abi: Abis.bank.usableCollateralBalance,
44-
chain: chain,
45-
block,
46-
});
47-
48-
const bankBalanceMusd = await sdk.api.abi.call({
49-
target: Contracts.cronos.bankMusd,
50-
abi: Abis.bank.usableCollateralBalance,
51-
chain: chain,
52-
block,
53-
});
54-
55-
return {
56-
[`cronos:${Contracts.cronos.mmf}`]: bankBalance.output,
57-
[`cronos:${Contracts.cronos.musd}`]: bankBalanceMusd.output,
58-
};
59-
}
60-
61-
async function calcStaking(timestamp, ethBlock, chainBlocks) {
62-
const block = chainBlocks.cronos;
63-
const chain = "cronos";
64-
65-
const stakingData = await sdk.api.abi.call({
66-
target: Contracts.cronos.multiFeeDistribution,
67-
abi: Abis.multiFeeDistribution.totalSupply,
68-
chain: chain,
69-
block,
70-
});
71-
72-
return {
73-
[`cronos:${Contracts.cronos.mng}`]: stakingData.output
74-
};
75-
}
76-
77-
async function calcLp(lps, block, chain, baseToken) {
78-
const reserves = (
79-
await sdk.api.abi.multiCall({
80-
calls: lps.map((lp) => ({
81-
target: lp.address,
82-
params: [],
83-
})),
84-
abi: Abis.pair.getReserves,
85-
block,
86-
chain,
87-
})
88-
).output;
89-
const totalSupplies = (
90-
await sdk.api.abi.multiCall({
91-
calls: lps.map((lp) => ({
92-
target: lp.address,
93-
params: [],
94-
})),
95-
abi: "erc20:totalSupply",
96-
block,
97-
chain,
98-
})
99-
).output;
100-
const balances = (
101-
await sdk.api.abi.multiCall({
102-
calls: lps.map((lp) => ({
103-
target: lp.address,
104-
params: [Contracts.cronos.chef],
105-
})),
106-
abi: "erc20:balanceOf",
107-
block,
108-
chain,
109-
})
110-
).output;
111-
112-
const results = lps.map((lp, index) => (
113-
new BigNumber(reserves[index].output[lp.isToken0 ? "_reserve0" : "_reserve1"])
114-
.times(2)
115-
.times(new BigNumber(balances[index].output))
116-
.idiv(new BigNumber(totalSupplies[index].output))
117-
));
118-
const total = results.reduce((total, num) => total.plus(num), new BigNumber(0));
119-
120-
return {
121-
[`cronos:${baseToken}`]: total.toString(10),
122-
};
15+
async function calcTvl(api) {
16+
const bankBalance = await api.call({ target: Contracts.cronos.bank, abi: Abis.bank.usableCollateralBalance, });
17+
const bankBalanceMusd = await api.call({ target: Contracts.cronos.bankMusd, abi: Abis.bank.usableCollateralBalance, });
18+
api.add(Contracts.cronos.mmf, bankBalance);
19+
api.add(Contracts.cronos.musd, bankBalanceMusd);
12320
}
12421

125-
async function calcChef(timestamp, block, chainBlocks) {
126-
const farm = await calcLp(Contracts.cronos.mmfLps, chainBlocks.cronos, "cronos", Contracts.cronos.mmf);
127-
const farmMusd = await calcLp(Contracts.cronos.musdLps, chainBlocks.cronos, "cronos", Contracts.cronos.musd);
128-
129-
return { ...farm, ...farmMusd };
22+
async function calcStaking(api) {
23+
const stakingData = await api.call({ target: Contracts.cronos.multiFeeDistribution, abi: Abis.multiFeeDistribution.totalSupply, });
24+
api.add(Contracts.cronos.mng, stakingData);
13025
}
13126

13227
module.exports = {
13328
cronos: {
13429
tvl: calcTvl,
135-
pool2: calcChef,
30+
pool2: () => ({}),
13631
staking: calcStaking,
13732
},
13833
};

projects/sakeperp/abi.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

projects/sakeperp/index.js

Lines changed: 7 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,24 @@
1+
const { getUniTVL } = require('../helper/unknownTokens')
2+
const { staking } = require('../helper/staking')
13
const ADDRESSES = require('../helper/coreAssets.json')
24
const sdk = require("@defillama/sdk");
3-
const abi = require("./abi.json");
45

56
const ethSake = "0x066798d9ef0833ccc719076Dab77199eCbd178b0";
6-
const ethFactory = "0x75e48C954594d64ef9613AeEF97Ad85370F13807";
77
const ethSakebar = "0x5fe808a4889b714496E7b821c8542e26be2f8f67";
88
const bscSake = "0x8BD778B12b15416359A227F0533Ce2D91844e1eD";
9-
const bscFactory = "0xA534cf041Dcd2C95B4220254A0dCb4B905307Fd8";
109
const bscSakebar = "0xbC83FAdA7D0881F772daaB2B4295F949FA309B59";
1110
const perpVault = "0xa34dA41edB2b15A20893d2208377E24D8dcdeB6e";
12-
const bUsd = ADDRESSES.bsc.BUSD;
13-
14-
async function tvl(factory, block, chain) {
15-
let balances = {};
16-
let poolsLength = (
17-
await sdk.api.abi.call({
18-
target: factory,
19-
abi: abi.allPairsLength,
20-
block,
21-
chain,
22-
})
23-
).output;
24-
let allPools = (
25-
await sdk.api.abi.multiCall({
26-
calls: Array.from({ length: Number(poolsLength) }, (_, k) => ({
27-
target: factory,
28-
params: k,
29-
})),
30-
abi: abi.allPairs,
31-
block,
32-
chain,
33-
})
34-
).output;
35-
let reserves = (
36-
await sdk.api.abi.multiCall({
37-
calls: allPools.map((p) => ({
38-
target: p.output,
39-
})),
40-
abi: abi.getReserves,
41-
block,
42-
chain,
43-
})
44-
).output;
45-
let token0s = (
46-
await sdk.api.abi.multiCall({
47-
calls: allPools.map((p) => ({
48-
target: p.output,
49-
})),
50-
abi: abi.token0,
51-
block,
52-
chain,
53-
})
54-
).output;
55-
let token1s = (
56-
await sdk.api.abi.multiCall({
57-
calls: allPools.map((p) => ({
58-
target: p.output,
59-
})),
60-
abi: abi.token1,
61-
block,
62-
chain,
63-
})
64-
).output;
65-
for (let i = 0; i < reserves.length; i++) {
66-
sdk.util.sumSingleBalance(
67-
balances,
68-
`${chain}:${token0s[i].output}`,
69-
reserves[i].output._reserve0
70-
);
71-
sdk.util.sumSingleBalance(
72-
balances,
73-
`${chain}:${token1s[i].output}`,
74-
reserves[i].output._reserve1
75-
);
76-
}
77-
return balances;
78-
}
79-
80-
async function staking(sake, sakebar, block, chain) {
81-
let balances = {};
82-
let balance = (
83-
await sdk.api.erc20.balanceOf({
84-
target: sake,
85-
owner: sakebar,
86-
block,
87-
chain,
88-
})
89-
).output;
90-
sdk.util.sumSingleBalance(balances, `${chain}:${sake}`, balance);
91-
return balances;
92-
}
93-
94-
async function ethTvl(timestamp, block) {
95-
return await tvl(ethFactory, block, "ethereum");
96-
}
97-
98-
async function bscTvl(timestamp, block, chainBlocks) {
99-
return await tvl(bscFactory, chainBlocks.bsc, "bsc");
100-
}
101-
102-
async function ethStaking(timestamp, block) {
103-
return await staking(ethSake, ethSakebar, block);
104-
}
105-
106-
async function bscStaking(timestamp, block, chainBlocks) {
107-
return await staking(bscSake, bscSakebar, chainBlocks.bsc);
108-
}
109-
110-
async function perpVaultTvl(timestamp, block, chainBlocks) {
111-
return await staking(bUsd, perpVault, chainBlocks.bsc);
112-
}
11311

11412
module.exports = {
13+
misrepresentedTokens: true,
11514
methodology:
11615
"TVL consists of pools in the factory contract and the BUSD in the PerpVault contract. Staking consists of SAKE in SakeBar.",
11716
ethereum: {
118-
tvl: ethTvl,
119-
staking: ethStaking,
17+
tvl: getUniTVL({ factory: '0x75e48C954594d64ef9613AeEF97Ad85370F13807', useDefaultCoreAssets: true, }),
18+
staking: staking(ethSakebar, ethSake, ),
12019
},
12120
bsc: {
122-
tvl: sdk.util.sumChainTvls([bscTvl, perpVaultTvl]),
123-
staking: bscStaking,
21+
tvl: sdk.util.sumChainTvls([getUniTVL({ factory: '0xA534cf041Dcd2C95B4220254A0dCb4B905307Fd8', useDefaultCoreAssets: true, }), staking(perpVault, ADDRESSES.bsc.BUSD,)]),
22+
staking: staking(bscSakebar, bscSake, ),
12423
},
12524
};

0 commit comments

Comments
 (0)