Skip to content

Commit

Permalink
Merge branch 'DefiLlama:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
waynebruce0x authored Jan 9, 2025
2 parents 2047f36 + d19ea70 commit ddc617e
Show file tree
Hide file tree
Showing 80 changed files with 2,577 additions and 371 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions projects/Equalizer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ module.exports = {
tvl: uniTvlExport("0xc6366EFD0AF1d09171fe0EBF32c7943BB310832a", "fantom", undefined, undefined, { hasStablePools: true, useDefaultCoreAssets: true, }),
staking: staking("0x8313f3551C4D3984FfbaDFb42f780D0c8763Ce94", "0x3Fd3A0c85B70754eFc07aC9Ac0cbBDCe664865A6"),
},
sonic: {
tvl: uniTvlExport("0xDDD9845Ba0D8f38d3045f804f67A1a8B9A528FcC", "fantom", undefined, undefined, { hasStablePools: true, useDefaultCoreAssets: true, stablePoolSymbol: 's-'}),
}
}
43 changes: 18 additions & 25 deletions projects/ZTLN/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,31 @@ query MyQuery {
}
`;

async function getTvl() {
try {
const data = await request(endpoint, query);

const securities = data.securities || [];

let tokens = 0;
const currencyDecimal = 10 ** 18;

securities.forEach(security => {
security.secondaryInvestors.forEach(investor => {
const amt = parseFloat(investor.amount);
tokens += amt / currencyDecimal;
});
});
async function tvl(api) {
const data = await request(endpoint, query);

const price = 100.5;
const tvl = tokens * price;
const securities = data.securities || [];

// console.log("tvl", tvl);
return tvl;
} catch (error) {
console.error("Error fetching TVL:", error);
return 0;
}
let tokens = 0;
const currencyDecimal = 10 ** 18;

securities.forEach(security => {
security.secondaryInvestors.forEach(investor => {
const amt = parseFloat(investor.amount);
tokens += amt / currencyDecimal;
});
});

const price = 100.5;
const tvl = tokens * price
api.addUSDValue(tvl);
}

module.exports = {
timetravel: false,
misrepresentedTokens: true,
methodology: "The value in RWA held by the protocol",
ethereum: {
fetch: getTvl
tvl
},
fetch: getTvl
};
12 changes: 7 additions & 5 deletions projects/alexar/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const { getConfig } = require('../helper/cache')
const { sumTokens } = require('../helper/sumTokens')

const blacklistedAssets = ['uaxl'];

const chainMapping = {
avax: 'avalanche',
cosmos: 'cosmoshub',
Expand All @@ -11,9 +9,12 @@ const chainMapping = {
};

const blackListChains = ['comdex', 'crescent'];
const chainListSupply = ['juno', 'cosmos', 'carbon', 'injective', 'kujira', 'osmosis', 'persistence', 'stargaze', 'secret', 'stargaze', 'umee', 'evmos', 'terra2'];
const chainListSupply = ['juno', 'cosmos', 'injective', 'kujira', 'osmosis', 'persistence', 'stargaze', 'secret', 'stargaze', 'umee', 'evmos', 'terra2'];
const chainListTotal = ['avax', 'bsc', 'moonbeam', 'polygon', 'fantom', 'arbitrum', 'aurora', 'celo', 'kava', 'mantle', 'ethereum', 'base'];

const blacklistedTokensChain = {
ethereum: ['0x946fb08103b400d1c79e07acCCDEf5cfd26cd374'], // KIP tvl is higher than the circulating supply
}

chainListSupply.concat(chainListTotal).forEach(chain => {
if (blackListChains.includes(chain)) {
Expand All @@ -25,6 +26,7 @@ chainListSupply.concat(chainListTotal).forEach(chain => {
const config = await getConfig('alexar', 'https://api.axelarscan.io/api/getTVL')
const tokensAndOwners = []
const owners = []
const blacklistedTokens = blacklistedTokensChain[chain] || []
const mappedChain = chainMapping[chain] || chain;
config.data.forEach(({ tvl: { [mappedChain]: assetTvl } = {} }) => {
if (!assetTvl) return;
Expand All @@ -42,8 +44,8 @@ chainListSupply.concat(chainListTotal).forEach(chain => {
}
})
if (tokensAndOwners.length > 0)
return api.sumTokens({ tokensAndOwners })
return sumTokens({ chain, owners })
return api.sumTokens({ tokensAndOwners, blacklistedTokens })
return sumTokens({ chain, owners, blacklistedTokens, })
}
});

Expand Down
2 changes: 1 addition & 1 deletion projects/apwine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module.exports = {
doublecounted: true,
ethereum: {
tvl: tvl_from_registry('ethereum'),
staking: staking(veAPW, APW),
//staking: staking(veAPW, APW),
},
polygon: {
tvl: tvl_from_registry('polygon'),
Expand Down
48 changes: 48 additions & 0 deletions projects/blacksail/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const { get } = require('../helper/http')
const { sumUnknownTokens } = require('../helper/unknownTokens')

async function fetcher() {
const response = await get('https://api.blacksail.finance/stats');
return response;
}

const strats = [
"0x11d58E28048132957FA344Be0Ae3FaE56bA185d2", "0x197329445441dFa5B725eA654A6f910f7669e83f", "0x14E19a5d30E75e252F02f6cFD3985b1b5c64D298", "0x33f02985658B7E2763859154B92A97d90F8Ec7ad", "0xAc57B713C630f188bc2d95c2ae3C27A1DE1DebA1", "0xDBa26763C6DbA30891453897Ef0b85C3Ab126Bb7", "0x6506920CF039087792BE09066712F4dC2186C749", "0xba5eC23096D5579b2052aA77317167E2d905D84E", "0xBdfF1fFbBdA067416c10719804EAC95A49B84EE4", "0xb896e66473915157534C77e06925d88E5b42C057", "0xe15825c6a9e26F47b436b9c3bd76b79daDfd7075", "0x613662ED769c0313cF228d76Fb3863456B6D0C5a", "0x88BF4D8efF256eEaE1Ccc7D5A93f23d88EC178f4", "0x2D5016734838FDf467016c9EF649327FD4110c71", "0x79f28bebd165D2B884f90e60b1946154A58752f1", "0xF5F2A9Ae7673dc28A327684b023A89248F8E8318", "0x0149Ed6072b343E587718f5B82dE7F665E44E403", "0x32259E464d130479eE4cB2c3F375d21A401Ab129", "0x3bBf53067B7C596De32092C789C051f5284c50bD", "0xc48077cDdbD8AC80aC1E7e22D510480ba700cbd1", "0x14A8B80078b818E62A53B39781C357610EC3C16F", "0xC84FcDF81b86D817A28d046eA89752030f6c1c4d", "0x491612ACe7d4ccd255fC5D08710ABF1b666a77DF", "0x4D6C1b29FD117790b8dA064d259821154fe99a42", "0x41b3407e368F96f58645543Bce307493631e303B", "0x30f10efC192BC2095f9085199F3916Cd043b2d44", "0xba6b2bb02854E174Ab9B995261B447154EAbd10a", "0x9Fb4B224Ab74DeB01899C4CdBC037419e2700aCF", "0x96c2BCed606bdddb1f1f0BAfe6a5dc8d746F8484", "0x1175D5fF8fA3cC545eAEb9697eB20237873281B3", "0x4d8C24Ab68B5C32c38BC39ab841B6cCE454C03aD", "0x4f796426B6d8cD98cE814837e03eCa4e8D66Dff3", "0x174A963186BB90852461D189035eB923f6fCc838", "0xAC76a4714f08F04F32DF75D647979f2660239078", "0x978526df622cE9b02b5A32f4D76C73d066b72FEb", "0x33B1C16403fF2BFbA0508e15eAEA58BDA1eDc48C", "0xe8F694512973eBE7D6FDA181872e6Ffb1B7eaB5c"
]

async function tvl(api) {
const bals = await api.multiCall({ abi: 'uint256:balanceOf', calls: strats })
const tokens = await api.multiCall({ abi: 'address:staking_token', calls: strats })
const symbols = await api.multiCall({ abi: 'string:symbol', calls: tokens })
const ichiVaults = []
const ichiBals = []
tokens.forEach((token, i) => {
if (symbols[i] === 'ICHI_Vault_LP') {
ichiVaults.push(token)
ichiBals.push(bals[i])
} else
api.add(token, bals[i])
})

// resolve ichi vaults
const iSupplies = await api.multiCall({ abi: 'uint256:totalSupply', calls: ichiVaults })
const iToken0s = await api.multiCall({ abi: 'address:token0', calls: ichiVaults })
const iToken1s = await api.multiCall({ abi: 'address:token1', calls: ichiVaults })
const iTokenBals = await api.multiCall({ abi: 'function getTotalAmounts() view returns (uint256 bal1, uint256 bal2)', calls: ichiVaults })

iSupplies.map((_, i) => {
const token0 = iToken0s[i]
const token1 = iToken1s[i]
const ratio = ichiBals[i] / iSupplies[i]
api.add(token0, iTokenBals[i].bal1 * ratio)
api.add(token1, iTokenBals[i].bal2 * ratio)
})

return sumUnknownTokens({ api, useDefaultCoreAssets: true, lps: tokens.filter((_, i) => symbols[i].startsWith('v-')), resolveLP: true, allLps: true, })
}

module.exports = {
sonic: {
tvl,
}
}
42 changes: 37 additions & 5 deletions projects/credbull/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,46 @@
const { getConfig } = require('../helper/cache');

const STAKING_VAULT_CONTRACT = "0xe4a4d891f02DF7bFFc5ff9e691313DE8a9E76b91";
const CBL_TOKEN = "0xD6b3d81868770083307840F513A3491960b95cb6";
const cblConfigArbitrum = {
cbl: "0xD6b3d81868770083307840F513A3491960b95cb6",
cblStakingV2: "0xc0C1DaA773570C041c47cE12c397AdDFD6B7403F",
};

const fundConfigPolygon = {
liquidStoneFund: "0x2eda17eb596858566be933b26fae6fa4ee8ccd6d",
fundNavCalculator: "0xcdf038dd3b66506d2e5378aee185b2f0084b7a33",
};

// Credbull DeFi Vaults v1 TVL (6 or 12 month fixed APY)
async function tvl(api) {
let vaults = await getConfig('credbull', "https://incredbull.io/api/vaults")
vaults = vaults[api.chain]
const tokens = await api.multiCall({ abi: 'address:asset', calls: vaults })

return api.sumTokens({ tokensAndOwners2: [tokens, vaults] })
}

// Credbull Fund, including LiquidStone
async function borrowedFund(api) {
const fundNavResults = await api.multiCall({
abi: 'function calcNav(address _vaultProxy) external returns (address denominationAsset, uint256 nav)',
calls: [fundConfigPolygon.liquidStoneFund],
target: fundConfigPolygon.fundNavCalculator,
excludeFailed: true,
})
const vaultBalance = await api.call({ abi: 'erc20:balanceOf', target: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359', params: fundConfigPolygon.liquidStoneFund })
api.add('0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359', vaultBalance * -1)

fundNavResults.forEach((i) => {
api.add(i.denominationAsset, i.nav)
});
api.getBalancesV2().removeNegativeBalances()
}

async function polygonTvl(api) {
const vaultBalance = await api.call({ abi: 'erc20:balanceOf', target: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359', params: fundConfigPolygon.liquidStoneFund })
api.add('0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359', vaultBalance)
}

async function borrowed(api) {
let vaults = await getConfig('credbull', "https://incredbull.io/api/vaults")
vaults = vaults[api.chain]
Expand All @@ -21,12 +52,13 @@ async function borrowed(api) {
}

async function stakedCbl(api) {
const bals = await api.multiCall({ abi: 'address:totalAssets', calls: [STAKING_VAULT_CONTRACT,] })
api.add(CBL_TOKEN, bals)
const bals = await api.multiCall({ abi: 'address:totalAssets', calls: [cblConfigArbitrum.cblStakingV2,] })
api.add(cblConfigArbitrum.cbl, bals)
}

module.exports = {
methodology: 'TVL consist of the sum of every deposit of all vaults for a given asset.',
btr: { tvl, borrowed, },
arbitrum: { tvl, borrowed, staking: stakedCbl },
btr: { tvl, borrowed, },
polygon: { borrowed: borrowedFund, tvl: polygonTvl },
};
30 changes: 3 additions & 27 deletions projects/cronos-zk/index.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
const { sumTokens2 } = require("../helper/unwrapLPs");

const target = "0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB"
const gasQuery = '0x0000000000000000000000000000000000000001'
const gasAddress = '0x0000000000000000000000000000000000000000'
const chainId = 388
const getTvl = require("../txBridge/util")

module.exports = {
ethereum: {
tvl: async (api) => {
const totalBalances = await sumTokens2({
api,
owner: target,
fetchCoValentTokens: true,
})
const balances = await api.multiCall({
calls: [gasQuery, ...Object.keys(totalBalances)].map(token => ({
target, params: [chainId, token.substring(token.indexOf(':') + 1)]
})),
abi: { "inputs": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "l1Token", "type": "address" }], "name": "chainBalance", "outputs": [{ "internalType": "uint256", "name": "balance", "type": "uint256" }], "stateMutability": "view", "type": "function" },
permitFailure: true,
withMetadata: true
})
api._balances._balances = {}
balances.map(call => {
const token = call.input.params[1]
api.add(token == gasQuery ? gasAddress : token, call.output)
})
}
tvl: async (api) => getTvl(api, { chainId: 388, }),
},
};
}
7 changes: 7 additions & 0 deletions projects/curve/contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,12 @@
"CurveStableswapFactoryNG": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B",
"CurveTwocryptoFactoryNG": "0x5Ea9DD3b6f042A34Df818C6c1324BC5A7c61427a",
"CurveTricryptoFactoryNG": "0x7Ca46A636b02D4aBC66883D7FF164bDE506DC66a"
},
"sonic": {
"gasTokenDummy": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"wrapped": "0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38",
"CurveStableswapFactoryNG": "0x7C2085419BE6a04f4ad88ea91bC9F5C6E6C463D8",
"CurveTwocryptoFactoryNG": "0x1A83348F9cCFD3Fe1A8C0adBa580Ac4e267Fe495",
"CurveTricryptoFactoryNG": "0x635742dCC8313DCf8c904206037d962c042EAfBd"
}
}
33 changes: 18 additions & 15 deletions projects/curve/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ const contracts = require("./contracts.json");
const { getLogs } = require('../helper/cache/getLogs')

const chains = [
"ethereum", //-200M
"polygon", //-40M
"arbitrum", //G
"aurora", //G
"avax", //-30M
"fantom", //-80M
"optimism", //-6M
"xdai", //G
"ethereum",
"polygon",
"arbitrum",
"aurora",
"avax",
"fantom",
"optimism",
"xdai",
"moonbeam",
"celo",
"kava",
Expand All @@ -29,7 +29,8 @@ const chains = [
"mantle",
"taiko",
"corn",
]; // Object.keys(contracts);
"sonic",
];
const registryIds = {
stableswap: 0,
stableFactory: 3,
Expand Down Expand Up @@ -94,7 +95,7 @@ async function getPools(block, chain) {
let { registriesMapping, addressProvider } = contracts[chain]
if (!registriesMapping) {
registriesMapping = {};
if(addressProvider){
if (addressProvider) {
(await sdk.api.abi.multiCall({
block, chain,
calls: Object.values(registryIds).map(r => ({ params: r })),
Expand Down Expand Up @@ -259,18 +260,20 @@ module.exports = chainTypeExports(chains);
module.exports.ethereum["staking"] = staking(
contracts.ethereum.veCRV,
contracts.ethereum.CRV
);
);

module.exports.harmony = {
tvl: async (api) => {
if (api.timestamp > 1655989200) {
// harmony hack
return {};
}
return api.sumTokens({ owner: '0xC5cfaDA84E902aD92DD40194f0883ad49639b023', tokens: [
"0xef977d2f931c1978db5f6747666fa1eacb0d0339",
"0x3c2b8be99c50593081eaa2a724f0b8285f5aba8f"
]})
return api.sumTokens({
owner: '0xC5cfaDA84E902aD92DD40194f0883ad49639b023', tokens: [
"0xef977d2f931c1978db5f6747666fa1eacb0d0339",
"0x3c2b8be99c50593081eaa2a724f0b8285f5aba8f"
]
})
}
};

Expand Down
6 changes: 6 additions & 0 deletions projects/dtrinity-dlend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { aaveExports, methodology } = require('../helper/aave')

module.exports = {
fraxtal: aaveExports(null, undefined, undefined, ['0xFB3adf4c845fD6352D24F3F0981eb7954401829c'], { v3: true, blacklistedTokens: ['0x788D96f655735f52c676A133f4dFC53cEC614d4A'] }),
methodology,
}
26 changes: 26 additions & 0 deletions projects/dtrinity/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const ADDRESSES = require('../helper/coreAssets.json')

const dUSDCollateralVault = "0x624E12dE7a97B8cFc1AD1F050a1c9263b1f4FeBC"

async function getAMOTvl(api) {
const fraxDUSDCurveLP = '0x9CA648D2f51098941688Db9a0beb1DadC2D1B357'
const fraxDUSDCurveLPBal = await api.call({ abi: 'erc20:balanceOf', target: fraxDUSDCurveLP, params: '0x0B0BD5F8A6f4c72a09748fA915Af12Ca423B7240' })
const fraxDUSDCurveLPFraxBal = await api.call({ abi: 'erc20:balanceOf', params: fraxDUSDCurveLP, target: ADDRESSES.fraxtal.FRAX })
const fraxDUSDCurveLPSupply = await api.call({ abi: 'erc20:totalSupply', target: fraxDUSDCurveLP, })
const fraxBal = fraxDUSDCurveLPFraxBal * fraxDUSDCurveLPBal / fraxDUSDCurveLPSupply
api.add(ADDRESSES.fraxtal.FRAX, fraxBal)
}

const tvl = async (api) => {
await getAMOTvl(api)

const tokens = await api.call({ abi: 'address[]:listCollateral', target: dUSDCollateralVault })
return api.sumTokens({ owner: dUSDCollateralVault, tokens })
}

module.exports = {
methodology: 'Includes TVL for dLEND and TVL for dUSD.',
fraxtal: {
tvl,
}
};
Loading

0 comments on commit ddc617e

Please sign in to comment.