Skip to content

Commit 32f59e4

Browse files
committed
fix kibbleswap
1 parent 7563034 commit 32f59e4

File tree

6 files changed

+346
-380
lines changed

6 files changed

+346
-380
lines changed

projects/KibbleSwap/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = {
1313
factory: '0xF4bc79D32A7dEfd87c8A9C100FD83206bbF19Af5',
1414
blacklist: [
1515
'0xe52CE89E16c4C596D30D111f3b5c137da412dEb8',
16+
'0xbe14fbbccd4587b276549e734cc80294fc4b0f83',
1617
]
1718
}),
1819
staking: staking({

projects/farmhero/index.js

Lines changed: 15 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const sdk = require("@defillama/sdk");
22
const abi = require("./abi.json");
33
const { stakings } = require("../helper/staking");
44
const { pool2s } = require("../helper/pool2");
5-
const { unwrapUniswapLPs } = require("../helper/unwrapLPs");
5+
const { unwrapUniswapLPs, sumTokens2, } = require("../helper/unwrapLPs");
66
const {
77
getChainTransform,
88
} = require("../helper/portedTokens");
@@ -120,14 +120,7 @@ const pool2StratsOkex = [
120120
"0xfa065195657A07f9c9F0A0a5e16DcD0Dff4AF11a",
121121
];
122122

123-
const calcTvl = async (
124-
balances,
125-
chain,
126-
block,
127-
masterchef,
128-
transformAddress,
129-
excludePool2
130-
) => {
123+
const calcTvl = async (balances, chain, block, masterchef, transformAddress, excludePool2) => {
131124
const poolLength = (
132125
await sdk.api.abi.call({
133126
abi: abi.poolLength,
@@ -137,66 +130,21 @@ const calcTvl = async (
137130
})
138131
).output;
139132

140-
const lpPositions = [];
133+
const toa = [];
134+
const calls = [];
141135

142-
for (let index = 0; index < poolLength; index++) {
143-
const strat = (
144-
await sdk.api.abi.call({
145-
abi: abi.poolInfo,
146-
target: masterchef,
147-
params: index,
148-
chain,
149-
block,
150-
})
151-
).output.strat;
152-
153-
const want = (
154-
await sdk.api.abi.call({
155-
abi: abi.poolInfo,
156-
target: masterchef,
157-
params: index,
158-
chain,
159-
block,
160-
})
161-
).output.want;
162-
163-
const strat_bal = (
164-
await sdk.api.abi.call({
165-
abi: 'erc20:balanceOf',
166-
target: want,
167-
params: strat,
168-
chain,
169-
block,
170-
})
171-
).output;
172-
173-
const symbol = (
174-
await sdk.api.abi.call({
175-
abi: abi.symbol,
176-
target: want,
177-
chain,
178-
block,
179-
})
180-
).output;
181-
182-
if (
183-
excludePool2.some((addr) => addr.toLowerCase() === want.toLowerCase()) ||
184-
symbol.includes("HC") ||
185-
symbol.includes("GC") ||
186-
symbol.includes("HERO") ||
187-
symbol.includes("HONOR")
188-
) {
189-
} else if (symbol.includes("LP") || symbol.includes("UNI-V2")) {
190-
lpPositions.push({
191-
token: want,
192-
balance: strat_bal,
193-
});
194-
} else {
195-
sdk.util.sumSingleBalance(balances, `${chain}:${want}`, strat_bal);
196-
}
197-
}
136+
for (let index = 0; index < poolLength; index++) calls.push({ params: index })
198137

199-
await unwrapUniswapLPs(balances, lpPositions, block, chain, transformAddress);
138+
const { output: data } = await sdk.api.abi.multiCall({
139+
target: masterchef,
140+
abi: abi.poolInfo,
141+
calls,
142+
chain, block,
143+
})
144+
145+
data.forEach(i => toa.push([i.output.want, i.output.strat]))
146+
147+
return sumTokens2({ balances, chain, block, tokensAndOwners: toa, resolveLP: true, blacklistedTokens: excludePool2 })
200148
};
201149

202150
const bscTvl = async (chainBlocks) => {

0 commit comments

Comments
 (0)