Skip to content

Commit 1fbb55e

Browse files
authored
Merge branch 'DefiLlama:main' into main
2 parents 80a4a23 + da54455 commit 1fbb55e

File tree

73 files changed

+1623
-376
lines changed

Some content is hidden

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

73 files changed

+1623
-376
lines changed

projects/DigiFT/index.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,52 @@
11
const sdk = require('@defillama/sdk');
2+
const { getLogs2 } = require('../helper/cache/getLogs')
23
//Polygon FeedPrice contract address
34
const DFeedPriceAddress = "0x7d4d68f18d1be3410ab8d827fb7ebc690f938d2d"
45
const tokenListAbi = "function getAllTokenRecords() view returns (tuple(uint256 chainId, address tokenAddress, uint64 tokenType)[])"
5-
6+
const uMintAddress = '0xC06036793272219179F846eF6bfc3B16E820Df0B'
7+
const ULTRAAddress = '0x50293dd8889b931eb3441d2664dce8396640b419'
8+
const BurnAbi = "event Burn (address indexed from, uint256 value, string data)"
9+
const MintAbi = "event Mint (address indexed to, uint256 amount)"
10+
const SubRedManagement = '0x3797c46db697c24a983222c335f17ba28e8c5b69'
611
async function getTokenList(tokenAPI, chainId) {
712
return (await tokenAPI.call({
813
target: DFeedPriceAddress,
914
abi: tokenListAbi
10-
})).filter(item => item[0] == chainId && item[2] == '1').map(item => item[1]);
15+
})).filter(item => item[0] == chainId && item[2] == '1').map(item => item[1]).filter(address => address.toLowerCase() !== uMintAddress.toLowerCase());
1116
}
12-
17+
18+
async function calculateTokenNetSupply(api, tokenAddress, managementAddress) {
19+
const BurnAmount = (await getLogs2({ api, target: tokenAddress, eventAbi: BurnAbi, fromBlock: 21091537, extraKey: 'Burn-key' }))
20+
.filter(log => log[0].toLowerCase() === managementAddress)
21+
.reduce((sum, log) => sum + log[1], 0n);
22+
23+
const MintAmount = (await getLogs2({ api, target: tokenAddress, eventAbi: MintAbi, fromBlock: 21091537, extraKey: 'Mint-key' }))
24+
.filter(log => log[0].toLowerCase() === managementAddress)
25+
.reduce((sum, log) => sum + log[1], 0n);
26+
27+
return MintAmount - BurnAmount;
28+
}
29+
1330
module.exports = {
1431
ethereum: {
1532
tvl: async (api) => {
1633
const tokenAPI = new sdk.ChainApi({ chain: 'polygon', timestamp: api.timestamp, });
1734
const tokens = await getTokenList(tokenAPI, api.chainId)
1835
const tokenSupplies = await api.multiCall({ abi: 'uint256:totalSupply', calls: tokens})
19-
api.addTokens(tokens, tokenSupplies)
36+
await api.addTokens(tokens, tokenSupplies)
37+
await api.removeTokenBalance(ULTRAAddress)
38+
await api.removeTokenBalance(uMintAddress)
39+
//uMint amount
40+
const netUMintSupply = await calculateTokenNetSupply(api, uMintAddress, SubRedManagement)
41+
await api.addToken(uMintAddress, netUMintSupply)
2042
return api.getBalances()
2143
}
2244
},
2345
arbitrum: {
2446
tvl: async (api) => {
2547
const tokenAPI = new sdk.ChainApi({ chain: 'polygon', timestamp: api.timestamp, });
2648
const tokens = await getTokenList(tokenAPI, api.chainId)
27-
const tokenSupplies = await api.multiCall({ abi: 'uint256:totalSupply', calls: tokens})
49+
const tokenSupplies = await api.multiCall({ abi: 'uint256:totalSupply', calls: tokens })
2850
api.addTokens(tokens, tokenSupplies)
2951
return api.getBalances()
3052
}

projects/TopCut-Finance/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const { sumTokens2 } = require('../helper/unwrapLPs')
2+
3+
const TOPCUT_VAULT = "0x3cfc3CBA1B4aAF969057F590D23efe46848F4270";
4+
const ETH = "0x0000000000000000000000000000000000000000"
5+
6+
7+
async function tvl(api) {
8+
return sumTokens2({
9+
owner: TOPCUT_VAULT,
10+
tokens: [ETH],
11+
api
12+
})
13+
}
14+
15+
module.exports = {
16+
methodology:
17+
"TVL is calculated based on the amount of ETH in the TopCut Vault.",
18+
arbitrum: { tvl },
19+
};

projects/arcadia-finance-v2/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async function tvl (api) {
9090
// 4. Return format is then transformed to be identical to the format of the V1 assetData
9191
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
9292

93-
const batchSize = 5;
93+
const batchSize = 25;
9494
for (let i = 0; i < v2Accounts.length; i += batchSize) {
9595
const batch = v2Accounts.slice(i, i + batchSize);
9696
await Promise.all(batch.map(async (account) => {
@@ -102,7 +102,7 @@ async function tvl (api) {
102102
// Since the return of the ownership data comes from a "blackbox" backend,
103103
// we verify onchain that the ownership of the NFTs is indeed correct
104104
// We check this for each asset where ID != 0
105-
const verificationCalls = assetData[0][1].map((tokenId, index) => {
105+
/* const verificationCalls = assetData[0][1].map((tokenId, index) => {
106106
if (tokenId === "0") return null; // Skip if tokenId is 0, just an erc20, balance will be fetched through sdk
107107
return {
108108
target: assetData[0][0][index],
@@ -119,7 +119,7 @@ async function tvl (api) {
119119
// Verify all owners match the account
120120
const allOwnersMatch = owners.every(owner => owner.toLowerCase() === account.toLowerCase());
121121
if (!allOwnersMatch) return; // Skip this account if any ownership verification fails
122-
}
122+
} */
123123

124124
ownerTokens.push([assetData[0][0], account])
125125
if (!assetData[0][0].length || !assetData[0][1].length || assetData[0][1] == "0") return;
@@ -138,9 +138,11 @@ async function tvl (api) {
138138
}
139139
}));
140140

141+
api.log(`[arcadia] Processed batch ${Math.ceil((i + 1) / batchSize)} of ${Math.ceil(v2Accounts.length / batchSize)} for v2 accounts.`);
142+
141143
// Add small delay between batches to prevent rate limiting
142144
if (i + batchSize < v2Accounts.length) { // Only sleep if there are more batches to process
143-
await sleep(1000);
145+
await sleep(500);
144146
}
145147
}
146148

projects/avalon-finance/index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { mergeExports } = require('../helper/utils')
77

88
//@note Main & Innovative Markets
99
const mainMarket = {
10-
merlin: aaveExports('', '0x6aB5d5E96aC59f66baB57450275cc16961219796', undefined, ['0x5F314b36412765f3E1016632fD1Ad528929536CA'], {v3: true}),
10+
merlin: aaveExports('', '0x6aB5d5E96aC59f66baB57450275cc16961219796', undefined, ['0x5F314b36412765f3E1016632fD1Ad528929536CA'], { v3: true, blacklistedTokens: ['0xb880fd278198bd590252621d4cd071b1842e9bcd'] }),
1111
btr: aaveExports('', '0x6aB5d5E96aC59f66baB57450275cc16961219796', undefined, ['0x5F314b36412765f3E1016632fD1Ad528929536CA'], {v3: true}),
1212
scroll: aaveExports('', '0xFBb77A68ee35e7902F1ABE0Bd34B263023e90c70', undefined, ['0x18cbe70602Ee17f79D56971F685E9EaF49DA53F2'], { v3: true }),
1313
iotex: aaveExports('', '', undefined, ['0xBa77520d38953BF6a8395D118CfF714Ed672533f'], { v3: true }),
@@ -33,12 +33,11 @@ const solvMarkets = {
3333
ethereum: aaveExports('', '0xff12470a969Dd362EB6595FFB44C82c959Fe9ACc', undefined, ['0xfabb0fDca4348d5A40EB1BB74AEa86A1C4eAd7E2'], { v3: true }),
3434
core: aaveExports('', '0x410d2D3Dc79ec66A2Cfc3A4a0AD4af3a38D38bd0', undefined, ['0x802CB61844325dc9A161bC3A498E3BE1B7b6FE00'], { v3: true }),
3535
arbitrum: aaveExports('', '0xa2ddc06baDc817C612111137c0cf6Bd43634EE1a', undefined, ['0xEc579d2cE07401258710199Ff12a5bb56e086a6F'], { v3: true }),
36-
bob: aaveExports('', '', undefined, ['0xfabb0fDca4348d5A40EB1BB74AEa86A1C4eAd7E2'], { v3: true }),
36+
bob: aaveExports('', '', undefined, ['0xfabb0fDca4348d5A40EB1BB74AEa86A1C4eAd7E2'], { v3: true, blacklistedTokens: ['0x541fd749419ca806a8bc7da8ac23d346f2df8b77', '0xcc0966d8418d412c599a6421b760a847eb169a8c'] }),
3737
corn: aaveExports('', '', undefined, ['0xf0d077728D424Ee6C6Eba82d23ce56C2e91E57Ea'], { v3: true }),
3838
sonic: aaveExports('', '', undefined, ['0x23f02C2eeFe2010298Ab74059393326d3df59a02'], { v3: true }),
39-
taiko: aaveExports('', '', undefined, ['0xF6Aa54a5b60c324602C9359E8221423793e5205d'], { v3: true }), // Taiko - Solv
39+
taiko: aaveExports('', '', undefined, ['0xF6Aa54a5b60c324602C9359E8221423793e5205d'], { v3: true, blacklistedTokens: ['0x541fd749419ca806a8bc7da8ac23d346f2df8b77'] }), // Taiko - Solv
4040
sei: aaveExports('', '', undefined, ['0x16b9b88B773C1a1aBA6D305e0560171405d45121'], { v3: true }),
41-
4241
}
4342

4443
const pumpBTCMarkets = {
@@ -48,7 +47,7 @@ const pumpBTCMarkets = {
4847
arbitrum: aaveExports('', '', undefined, ['0x2c4aEB7C9f0D196a51136B3c7bec49cB2DBD1966'], { v3: true }),
4948
corn: aaveExports('', '', undefined, ['0x867885c1dB3020E25A86Db7e20E35dC7b81d76A2'], { v3: true }),
5049
}
51-
50+
//
5251
const unibtcMarkets = {
5352
merlin: aaveExports('', '0x0024818043D04B1Cc9685233D47eF7eea6Df0A5E', undefined, ['0x623700Fee1dF64088f258e2c4DAB4D6aEac4dDA6'], { v3: true }),
5453
btr: aaveExports('', '', undefined, ['0x898D0EF6E20B7597728AEB41169c22608Fe4b234'], { v3: true }),
@@ -104,7 +103,7 @@ const uniIotxMarkets = {
104103

105104
// BSC - USDX
106105
const usdxMarkets = {
107-
bsc: aaveExports('', '', undefined, ['0x9515dC23bBE46f9C9885D24Fa276745A11b7f9D8'], { v3: true }),
106+
bsc: aaveExports('', '', undefined, ['0x9515dC23bBE46f9C9885D24Fa276745A11b7f9D8'], { v3: true, blacklistedTokens: ['0x7788a3538c5fc7f9c7c8a74eac4c898fc8d87d92', '0xf3527ef8de265eaa3716fb312c12847bfba66cef'] }),
108107
}
109108

110109
module.exports = mergeExports(

projects/backpack/index.js

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
1-
const { cexExports } = require("../helper/cex");
1+
const axios = require('axios')
22
const bitcoinAddressBook = require("../helper/bitcoin-book/index.js");
3+
const { sumTokensExport } = require('../helper/sumTokens')
4+
const ADDRESSES = require('../helper/coreAssets.json')
5+
const { defaultTokens } = require('../helper/cex')
36

4-
// https://dune.com/21co/backpack-exchange
5-
const config = {
6-
solana: {
7-
owners: [
8-
"43DbAvKxhXh1oSxkJSqGosNw3HpBnmsWiak6tB5wpecN",
9-
"BbHG9GvPActFGogv3iNrpDAj4qpXr8t3jF16uGxXcKci",
10-
"9NJmj9VaTU9D7ytdzy5RHMrfAgw2pYwqnUhuMqatcsr",
11-
"HwDX5eJkzPAJ7y7ENrH23HaDGUgB4nXPxG8UsB4cEMGE",
12-
"HgTWrWU195u6s4v3JiEjJFCb6J6wxtQh8DAYV63tCx6Q",
13-
"DFFN6XgrTYDR2uFvaXJFRcFrMrtt6ZbPxpDs3mVbpxuR",
14-
"J16ovD5x6kZLYDYAa6CqfrwacHdM7fcKD9iKG5EoNeGR",
15-
"4VULyn2PoqzF6EyQ9acJqeAwg7pwmQPppM56NRJyQ1Fi",
16-
"5stwKMsakQkH3uzN5eQx9LKzq6N8q3DBjXzkHyvudFde",
17-
"J4RR6RDvCBVcwrLgCnfDkXmv9cxYtxTz5t4NPvCRMSQR",
18-
"FCQSFKkw2JPhpG4M18nvGfiNAK6N3gFBmp8pkn4CxYGs",
19-
"6wspq3nz3qPQ9X6rbLM5bEDHK525yPSNqyqeABXcSMHQ",
20-
"6m68XVvBR4oLCgM7YFgH1VqzzV5vk9UimvmVUvyKw6c2",
21-
],
22-
},
23-
ethereum: {
24-
owners: [
25-
"0x2228e5704B637131A3798A186CAF18366c146f74",
26-
"0x6a3eAb9Ee70C82A2B13708041f2C5892bEa6857B",
27-
"0xEC8F9ef3031b0CdF05E42e0Ece8D6397F92595e8",
28-
"0x73ac628b14fb35d70266e96a886b8c5fe7ce22cf",
29-
],
30-
},
31-
bitcoin: {
32-
owners: bitcoinAddressBook.backpack,
33-
},
34-
sui: {
35-
owners: [
36-
"0x96073f85f1d558329999e03000dba6bcf30d8b0aff26a88a9227402e87c200aa",
37-
],
38-
},
39-
};
40-
41-
module.exports = cexExports(config);
7+
const API_URL = 'https://api.backpack.exchange/api/v1/wallets'
8+
9+
const getConfig = async () => {
10+
const { data } = await axios.get(API_URL)
11+
const config = {}
12+
data.forEach(({ address, blockchain }) => {
13+
let chain = blockchain.toLowerCase()
14+
if (chain === 'avalanche') chain = 'avax'
15+
if (!config[chain]) config[chain] = { owners: [] }
16+
config[chain].owners.push(address)
17+
})
18+
return config
19+
}
20+
21+
const exportObj = { timetravel: false }
22+
const chains = ['ethereum', 'solana', 'bitcoin', 'litecoin', 'arbitrum', 'optimism', 'polygon', 'base', 'bsc', 'avax', 'tron'];
23+
24+
chains.forEach((chain) => {
25+
exportObj[chain] = {
26+
tvl: async () => {
27+
const config = await getConfig()
28+
const entry = config[chain]
29+
if (!entry) return {}
30+
31+
let { tokensAndOwners, owners, tokens, blacklistedTokens, fungibleAssets } = entry
32+
if (!tokensAndOwners && !tokens && chain !== 'solana') tokens = defaultTokens[chain] || [ADDRESSES.null]
33+
34+
const options = { ...entry, owners, tokens, chain, blacklistedTokens }
35+
if (chain === 'solana' || chain === 'eclipse') options.solOwners = owners
36+
if (chain === 'ton') options.onlyWhitelistedTokens = true
37+
if (chain === 'aptos' && Array.isArray(fungibleAssets)) options.fungibleAssets = fungibleAssets
38+
39+
return sumTokensExport(options)()
40+
}
41+
}
42+
})
43+
44+
module.exports = exportObj

projects/badgerdao.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ chains.forEach(chain => {
1111
module.exports[chain] = {
1212
tvl: async (api) => {
1313
const data = await getConfig(`badgerdao/tvl/${chain}`, `https://api.badger.com/v2/vaults?chain=${oChain}&currency=usd`)
14+
if (!data || Object.keys(data).length === 0) return;
1415
const calls = data.map(i => i.vaultToken)
1516
return api.erc4626Sum({ calls, permitFailure: true, })
1617
}

projects/bakerfi/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ const config = {
33
vaults: ["0x4c6d58749126FEBb1D28E8B8FdE97DC3107996d3"]
44
},
55
base: {
6-
vaults: ["0x37327c99bBc522e677a97d01021dB20227faF60A", "0x892022FE1431fdE03836725BBD0f0380e21E2095"]
6+
vaults: ["0x37327c99bBc522e677a97d01021dB20227faF60A", "0x892022FE1431fdE03836725BBD0f0380e21E2095", "0x4BA3f77a8072217dabd7FeD28DB244A5d32C572E"]
77
},
88
ethereum: {
9-
vaults: ["0x01280b3683fE20Dc9cCF4D9526418F252871E4F7"]
9+
vaults: ["0x01280b3683fE20Dc9cCF4D9526418F252871E4F7", "0x909d587c482766814B368d5b136d98819B9373d7"]
1010
},
1111
}
1212

projects/bancor/index.js

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,48 @@
11
const ADDRESSES = require('../helper/coreAssets.json');
22
const { sumTokens2 } = require('../helper/unwrapLPs');
3-
const abi = require('./abi.json');
4-
5-
async function generateCallsByBlockchain(api) {
6-
const block = api.block
7-
const registryAddress = '0x52Ae12ABe5D8BD778BD5397F99cA900624CfADD4';
8-
const converterRegistryHex = '0x42616e636f72436f6e7665727465725265676973747279000000000000000000';
9-
10-
let converterRegistryAddress;
11-
12-
if (block && block < 9195218) {
13-
converterRegistryAddress = '0xf6E2D7F616B67E46D708e4410746E9AAb3a4C518';
14-
}
15-
else {
16-
// get converter registry address
17-
converterRegistryAddress = await api.call({ abi: abi.abiContractRegistryAddressOf, target: registryAddress, params: [converterRegistryHex] });
18-
}
19-
20-
// get pool anchor addresses
21-
const poolAnchorAddresses = await api.call({ abi: abi.abiConverterRegistryGetPools, target: converterRegistryAddress });
22-
const converterAddresses = await api.call({ abi: abi.abiRegistryGetConvertersBySmartTokens, target: converterRegistryAddress, params: [poolAnchorAddresses] });
23-
const reserveTokenCalls = [];
24-
const owners = [];
25-
for (let i = 0; i < converterAddresses.length; i++) {
26-
reserveTokenCalls.push({
27-
target: converterAddresses[i],
28-
params: [0]
29-
});
30-
reserveTokenCalls.push({
31-
target: converterAddresses[i],
32-
params: [1]
33-
});
34-
owners.push(converterAddresses[i]);
35-
}
36-
37-
const tokens = await api.multiCall({ calls: reserveTokenCalls, abi: abi['abiConverterConnectorTokens'], });
38-
tokens.push(ADDRESSES.null);
39-
owners.push('0xc0829421C1d260BD3cB3E0F06cfE2D52db2cE315');
40-
return sumTokens2({ api, tokensAndOwners2: [tokens, owners] })
3+
4+
const abis = {
5+
"abiContractRegistryAddressOf": "function addressOf(bytes32 _contractName) view returns (address)",
6+
"abiConverterRegistryGetPools": "address[]:getLiquidityPools",
7+
"abiRegistryGetConvertersBySmartTokens": "function getConvertersBySmartTokens(address[] _smartTokens) view returns (address[])",
8+
"abiConverterConnectorTokens": "function connectorTokens(uint256) view returns (address)",
9+
"liquidityPools": "address[]:liquidityPools"
10+
}
11+
12+
const registryAddress = '0x52Ae12ABe5D8BD778BD5397F99cA900624CfADD4';
13+
const converterRegistryHex = '0x42616e636f72436f6e7665727465725265676973747279000000000000000000';
14+
const oldConverter = '0xf6E2D7F616B67E46D708e4410746E9AAb3a4C518'
15+
16+
const tvl = async (api) => {
17+
const block = await api.getBlock()
18+
const isOldBlock = block && block < 9195218
19+
20+
const converterRegistryAddress = isOldBlock
21+
? oldConverter
22+
: await api.call({ abi: abis.abiContractRegistryAddressOf, target: registryAddress, params: [converterRegistryHex] });
23+
24+
const poolAnchorAddresses = await api.call({ abi: abis.abiConverterRegistryGetPools, target: converterRegistryAddress });
25+
const converterAddresses = await api.call({ abi: abis.abiRegistryGetConvertersBySmartTokens, target: converterRegistryAddress, params: [poolAnchorAddresses] });
26+
const tokens = await api.fetchList({ itemAbi: abis.abiConverterConnectorTokens, itemCount: 2, calls: converterAddresses, groupedByInput: true })
27+
28+
const tokenList = []
29+
const ownerList = []
30+
31+
tokens.forEach((toks, i) => {
32+
toks.concat(ADDRESSES.null).forEach(token => {
33+
tokenList.push(token)
34+
ownerList.push(converterAddresses[i])
35+
})
36+
})
37+
38+
return sumTokens2({ api, tokensAndOwners2: [tokenList, ownerList] })
4139
}
4240

4341
module.exports = {
4442
start: '2017-08-02', // 08/02/2017 @ 12:00am (UTC)
45-
ethereum: {
46-
tvl: generateCallsByBlockchain,
47-
},
43+
ethereum : { tvl },
4844
hallmarks: [
4945
[1588114800, "V2.0 Launch"], // 29/04/2020 @ 12:00am (UTC)
5046
[1602457200, "V2.1 Launch"] // 12/10/2020 @ 12:00am (UTC)
5147
],
52-
};
48+
}

projects/bluefin-pro/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const ADDRESSES = require('../helper/coreAssets.json')
2+
const sui = require("../helper/chain/sui");
3+
4+
const DATA_STORE_ID =
5+
"0x740d972ea066fe3302ee655163373cda2e9529bfa93d2266e1355cf56899da57";
6+
7+
async function suiTvl(api) {
8+
const object = await sui.getObject(DATA_STORE_ID);
9+
const bankID = object.fields.asset_bank.fields.id.id;
10+
const assetBank = await sui.getDynamicFieldObject(bankID ,"USDC", {idType: "0x1::string::String"});
11+
12+
const tvl = assetBank.fields.value;
13+
api.add(ADDRESSES.sui.USDC, tvl);
14+
return api.getBalances()
15+
}
16+
17+
module.exports = {
18+
sui: {
19+
tvl: suiTvl
20+
}
21+
}

0 commit comments

Comments
 (0)