Skip to content

Commit e6058ce

Browse files
authored
Merge branch 'DefiLlama:main' into main
2 parents 6e069a6 + 4139e07 commit e6058ce

File tree

360 files changed

+7602
-4734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

360 files changed

+7602
-4734
lines changed

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/3jane-lending/index.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
1+
const { getLogs } = require("../helper/cache/getLogs");
12
const { sumTokens2 } = require('../helper/unwrapLPs')
3+
const abi = require("../helper/abis/morpho.json");
24

35
const contract = "0xde6e08ac208088cc62812ba30608d852c6b0ecbc"
6+
const fromBlock = 23214670
47

58
async function tvl(api) {
69
return sumTokens2({ tokens: ["0xd4fa2d31b7968e448877f69a96de69f5de8cd23e"], owner: contract, api })
710
}
811

12+
const eventAbis = {
13+
createMarket: 'event CreateMarket(bytes32 indexed id, (address loanToken, address collateralToken, address oracle, address irm, uint256 lltv, address creditLine) marketParams)'
14+
}
15+
16+
async function borrowed(api) {
17+
const logs = await getLogs({ api, target: contract, eventAbi: eventAbis.createMarket, fromBlock, onlyArgs: true })
18+
const markets = logs.map((i) => i.id.toLowerCase())
19+
const marketInfos = await api.multiCall({ target: contract, calls: markets, abi: abi.morphoBlueFunctions.idToMarketParams })
20+
const marketDatas = await api.multiCall({ target: contract, calls: markets, abi: abi.morphoBlueFunctions.market })
21+
22+
marketDatas.forEach((data, idx) => {
23+
const { loanToken } = marketInfos[idx];
24+
api.add(loanToken, data.totalBorrowAssets);
25+
});
26+
}
27+
928
module.exports = {
1029
methodology: `We count the tokens on ${contract}`,
1130
ethereum: {
12-
tvl
31+
tvl,
32+
borrowed,
1333
}
1434
}

projects/DigiFT/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,14 @@ module.exports = {
5959
await api.addTokens(tokens, tokenSupplies)
6060
return api.getBalances()
6161
}
62+
},
63+
bsc: {
64+
tvl: async (api) => {
65+
const tokenAPI = new sdk.ChainApi({ chain: 'polygon', timestamp: api.timestamp, });
66+
const tokens = await getTokenList(tokenAPI, api.chainId)
67+
const tokenSupplies = await api.multiCall({ abi: 'uint256:totalSupply', calls: tokens })
68+
await api.addTokens(tokens, tokenSupplies)
69+
return api.getBalances()
70+
}
6271
}
6372
};

projects/GotchiVault/index.js

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
const sdk = require('@defillama/sdk');
21
const abi = require("./abi.json");
32
const { request, gql } = require("graphql-request");
4-
const { getBlock } = require('../helper/http')
53

64
const VGHST_CONTRACT = "0x51195e21BDaE8722B29919db56d95Ef51FaecA6C";
75
const GHST_CONTRACT = "0x385Eeac5cB85A38A9a07A70c73e0a3271CfB54A7";
@@ -27,61 +25,41 @@ query GET_SUMMONED_GOTCHIS ($minGotchiId: Int, $block: Int) {
2725
stakedAmount
2826
}
2927
}`
30-
async function getGotchisCollateral(timestamp, block) {
31-
const allGotchis = [];
28+
async function getGotchisCollateral(block, api) {
3229
let minGotchiId = 0;
3330
while (minGotchiId !== -1) {
3431
const { aavegotchis } = await request(
3532
graphUrl,
36-
graphQuery,
37-
{minGotchiId, block}
33+
graphQuery,
34+
{ minGotchiId, block }
3835
);
3936
if (aavegotchis && aavegotchis.length > 0) {
4037
minGotchiId = parseInt(aavegotchis[aavegotchis.length - 1].gotchiId);
41-
allGotchis.push(...aavegotchis);
38+
aavegotchis.forEach(g => api.add(g.collateral, g.stakedAmount));
4239
} else {
4340
minGotchiId = -1;
4441
}
4542
}
46-
const gotchisBalances = {
47-
output: allGotchis.map(g => ({
48-
input: {target: g.collateral},
49-
success: true,
50-
output: g.stakedAmount
51-
}))
52-
};
53-
54-
const balances = {};
55-
sdk.util.sumMultiBalanceOf(balances, gotchisBalances, true, x => 'polygon:' + x);
56-
return gotchisBalances;
5743
}
5844

59-
async function tvl(timestamp, _, chainBlocks) {
60-
const balances = {};
61-
const block = await getBlock(timestamp, 'polygon', chainBlocks)
62-
const transform = i => `polygon:${i}`;
45+
async function tvl(api) {
46+
const block = await api.getBlock()
6347

64-
const collateralBalance = (await sdk.api.abi.call({
48+
const collateralBalance = await api.call({
6549
abi: abi.totalGHST,
66-
chain: 'polygon',
6750
target: VGHST_CONTRACT,
6851
params: [VGHST_CONTRACT],
69-
block,
70-
})).output;
71-
72-
sdk.util.sumSingleBalance(balances, transform(GHST_CONTRACT), collateralBalance)
73-
74-
const gotchisBalances = await getGotchisCollateral(timestamp, block-100);
75-
sdk.util.sumMultiBalanceOf(balances, gotchisBalances, true, x => 'polygon:' + x);
52+
})
53+
api.add(GHST_CONTRACT, collateralBalance)
7654

77-
78-
return balances;
55+
// return getGotchisCollateral(block - 100, api);
7956
}
8057

8158
module.exports = {
8259
methodology:
8360
"TVL counts the total GHST tokens that are staked by the Gotchi Vault vGHST contracts, as well as the collateral tokens that are locked in the Aavegotchis deposited in the Gotchi Vault contract",
84-
polygon: {
61+
polygon: {
8562
tvl,
86-
}
63+
},
64+
deadFrom: '2025-10-10',
8765
};

projects/RealProtocol/index.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
1-
const sdk = require("@defillama/sdk");
1+
const { sumTokensExport } = require("../helper/unwrapLPs");
2+
const { nullAddress } = require("../helper/tokenMapping");
23

34
// TroveManager holds total system collateral (deposited ETH)
4-
const TROVE_MANAGER_ADDRESS = "0x25d27cbdfaFb1B7314AC5e409a1F24112e376829";
5-
6-
async function tvl(_, _b, {ethpow: block}) {
7-
const troveEthTvl = (
8-
await sdk.api.abi.call({
9-
target: TROVE_MANAGER_ADDRESS,
10-
chain: 'ethpow',
11-
abi: "uint256:getEntireSystemColl",
12-
block,
13-
})
14-
).output;
15-
16-
return {
17-
'coingecko:ethereum-pow-iou': troveEthTvl/1e18 ,
18-
};
19-
}
5+
const TROVE_MANAGER_ADDRESS = "0x259ED2C59D350E608E1018162e641186c410c31B";
206

217
module.exports = {
228
ethpow: {
23-
tvl,
9+
tvl: sumTokensExport({ owners: [TROVE_MANAGER_ADDRESS], tokens: [nullAddress]}),
2410
}
2511
};

projects/aarna/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ const { generateAtvExport } = require('../helper/atv-helper');
33

44
// Configuration for all Aarna ATV vaults across chains
55
const AARNA_CONFIG = {
6-
methodology: 'TVL is calculated using direct on-chain storage contract queries via calculatePoolInUsd function for each âtv vault. This includes âtv802 (quant AI), âtv808 (asymmetric alpha), and âtv111 (multi layer yield) vaults deployed across Ethereum, Arbitrum, and Sonic chains.',
6+
methodology: `TVL: Total value of all coins held in the smart contracts of the protocol
7+
Fees: 1% deposit and 10% profit sharing (whereever applicable) fees from the vaults`,
78

89
// Vault addresses by chain and type
910
vaults: {
1011
ethereum: {
1112
'ATV-802': "0xb68e430c56ed9e548e864a68a60f9d41f993b32c",
1213
'ATV-808': "0x60697825812ecC1Fff07f41E2d3f5cf314674Fa6",
13-
'ATV-111': "0x72ec8447074dc0bfbedfb516cc250b525f3a4aba"
14+
'ATV-111': "0x72ec8447074dc0bfbedfb516cc250b525f3a4aba",
15+
'ATVPTMAX': "0xb9C1344105FaA4681bc7FFd68c5c526DA61F2AE8"
1416
},
1517
arbitrum: {
1618
'ATV-111': "0xe1a6bda42fbafae38607598386a1050613c1a64b"

projects/aave-horizon/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const { aaveV3Export } = require("../helper/aave");
2+
3+
const CONFIG = {
4+
ethereum: ['0x53519c32f73fE1797d10210c4950fFeBa3b21504'],
5+
6+
};
7+
8+
module.exports = aaveV3Export(CONFIG)

projects/aave-v3/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { aaveV3Export } = require("../helper/aave");
22

33
// https://aave.com/docs/resources/addresses
44
const CONFIG = {
5-
ethereum: ['0x41393e5e337606dc3821075Af65AeE84D7688CBD', '0x08795CFE08C7a81dCDFf482BbAAF474B240f31cD', '0xE7d490885A68f00d9886508DF281D67263ed5758', '0x53519c32f73fE1797d10210c4950fFeBa3b21504'],
5+
ethereum: ['0x41393e5e337606dc3821075Af65AeE84D7688CBD', '0x08795CFE08C7a81dCDFf482BbAAF474B240f31cD', '0xE7d490885A68f00d9886508DF281D67263ed5758'],
66
polygon: ['0x7F23D86Ee20D869112572136221e173428DD740B'],
77
avax: ['0x7F23D86Ee20D869112572136221e173428DD740B'],
88
arbitrum: ['0x7F23D86Ee20D869112572136221e173428DD740B'],

projects/accountable/index.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
const FACTORIES = [
2+
'0x606556A6B544ecDcbf15aF73A63B67516dc16Ad7',
3+
'0x8a5Caf00C3EB20aEC11Fc35C153a8601Cd127fEd',
4+
]
5+
6+
const abis = {
7+
strategyProxies: 'function strategyProxies(uint256) view returns (address)',
8+
strategyVaults: 'function strategyVaults(address) view returns (address)',
9+
convertToAssets: 'function convertToAssets(uint256) view returns (uint256)',
10+
asset: 'function asset() view returns (address)',
11+
}
12+
13+
const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'
14+
15+
async function getVaults(api) {
16+
const vaults = new Set()
17+
const batchSize = 20
18+
19+
for (const factory of FACTORIES) {
20+
for (let start = 0; ; start += batchSize) {
21+
const indexes = Array.from({ length: batchSize }, (_, i) => start + i)
22+
23+
const strategies = await api.multiCall({
24+
target: factory,
25+
abi: abis.strategyProxies,
26+
calls: indexes.map((i) => ({ params: [i] })),
27+
permitFailure: true,
28+
})
29+
const validStrategies = strategies.filter((s) => s && s !== NULL_ADDRESS)
30+
if (!validStrategies.length) break
31+
32+
const factoryVaults = await api.multiCall({
33+
target: factory,
34+
abi: abis.strategyVaults,
35+
calls: validStrategies.map((strategy) => ({ params: [strategy] })),
36+
permitFailure: true,
37+
})
38+
39+
factoryVaults.forEach((vault) => {
40+
if (!vault || vault === NULL_ADDRESS) return
41+
vaults.add(vault.toLowerCase())
42+
})
43+
}
44+
}
45+
46+
return Array.from(vaults)
47+
}
48+
49+
function tvl(isBorrowed) {
50+
return async (api) => {
51+
const vaults = await getVaults(api)
52+
if (!vaults.length) return
53+
54+
const [supplies, underlyings] = await Promise.all([
55+
api.multiCall({ abi: 'erc20:totalSupply', calls: vaults, permitFailure: true }),
56+
api.multiCall({ abi: abis.asset, calls: vaults, permitFailure: true }),
57+
])
58+
59+
const [totalAssets, liquidity] = await Promise.all([
60+
api.multiCall({
61+
abi: abis.convertToAssets,
62+
calls: vaults.map((vault, i) => ({ target: vault, params: [supplies[i] || 0] })),
63+
permitFailure: true,
64+
}),
65+
api.multiCall({ abi: 'erc20:balanceOf', calls: vaults.map((vault, i) => ({ target: underlyings[i], params: vault })), permitFailure: true })
66+
])
67+
68+
vaults.forEach((_, i) => {
69+
if (!underlyings[i] || !totalAssets[i]) return
70+
isBorrowed ? api.add(underlyings[i], totalAssets[i] - liquidity[i]) : api.add(underlyings[i], liquidity[i])
71+
})
72+
}
73+
}
74+
75+
module.exports = {
76+
methodology: 'TVL converts each vault totalSupply to underlying via convertToAssets(). Vaults are discovered from factory strategyProxies/strategyVaults.',
77+
monad: {
78+
tvl: tvl(false),
79+
borrowed: tvl(true)
80+
},
81+
}

0 commit comments

Comments
 (0)