Skip to content

Commit c96297b

Browse files
Update TVL logic of Capybara Exchange (DefiLlama#11985)
Co-authored-by: g1nt0ki <[email protected]>
1 parent c69e6ae commit c96297b

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

projects/capybara-exchange/config.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
module.exports = {
22
klaytn: {
3-
pools: {
4-
mainPool: "0x540cce8ed7d210f71eeabb9e7ed7698ac745e077",
5-
volatilePool: "0x6389dbfa1427a3b0a89cddc7ea9bbda6e73dece7",
6-
lstPool: "0x5CDE63386D78362267d9A3edC8DA204bB64D07D3",
7-
stargatePool: "0x1dE1578476d9B4237F963eca5D37500Fc33DF3D1",
8-
},
3+
master: "0x3CA30C862769b5de7987D2E2db4c1A72800A1Da1",
94
},
105
};

projects/capybara-exchange/index.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@ const config = require("./config");
22
const { sumTokens2 } = require("../helper/unwrapLPs");
33

44
Object.keys(config).forEach((chain) => {
5-
const arg = config[chain];
5+
const { master } = config[chain];
66
module.exports[chain] = {
77
tvl: async (api) => {
8-
const pools = Object.values(arg["pools"]);
9-
10-
let allUnderlying = await api.multiCall({ abi: "address[]:getTokens", calls: pools, });
11-
12-
const tokens = [];
13-
const calls = [];
14-
pools.forEach((v, i) => {
15-
allUnderlying[i].forEach((t) => {
16-
tokens.push(t);
17-
calls.push({ target: v, params: t });
18-
});
8+
const poolInfos = await api.fetchList({
9+
// Reference: https://github.com/wombat-exchange/v1-core/blob/5887ec5e1f1cbd067eaee8aee49fcb857fb867c5/contracts/wombat-governance/MasterWombatV3.sol#L587
10+
lengthAbi: 'poolLength',
11+
itemAbi: "function poolInfo(uint256) external view returns (address asset, uint96, address, uint256, uint104, uint104, uint40)",
12+
target: master,
1913
});
20-
const wTokens = await api.multiCall({ abi: "function addressOfAsset(address) view returns (address)", calls, });
21-
return sumTokens2({ api, tokensAndOwners2: [tokens, wTokens], });
14+
// Reference: https://github.com/wombat-exchange/v1-core/blob/5887ec5e1f1cbd067eaee8aee49fcb857fb867c5/contracts/wombat-core/asset/Asset.sol#L4
15+
const assets = poolInfos.map(i => i.asset);
16+
const uTokens = await api.multiCall({ abi: 'address:underlyingToken', calls: assets })
17+
18+
return sumTokens2({ api, tokensAndOwners2: [uTokens, assets], });
2219
},
2320
};
2421
});

0 commit comments

Comments
 (0)