diff --git a/package-lock.json b/package-lock.json index cff6555ac7b9..ab79f3b205ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -886,9 +886,9 @@ } }, "node_modules/@defillama/sdk": { - "version": "5.0.49", - "resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-5.0.49.tgz", - "integrity": "sha512-CggIAtMd5lwOpIPoGPkTMqS2KYVIectlt1cOHUc/O/tcBOQ9XSy2OfF4JI8tIMuAJQSvYlPnEtxpFkUwuFt27A==", + "version": "5.0.51", + "resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-5.0.51.tgz", + "integrity": "sha512-9xph+m9PykFw23K49AUagVLj+iu9mHMUeoZwBmdpVT0GBQNpLadMjCWc9NEgivrguOqMC76MhxZBsZMOTlzXHw==", "dependencies": { "@aws-sdk/client-s3": "^3.400.0", "@supercharge/promise-pool": "^2.1.0", diff --git a/package.json b/package.json index cc900e75344a..8ca12aa6db0d 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "treasury": "cd utils;npm i; cd ..; node utils/testInteractive treasury", "entities": "cd utils;npm i; cd ..; node utils/testInteractive entities", "useTokenLabels": "node utils/scripts/useTokenLabels.js", + "biggest-files": "find ./projects -name '*.js' -not -path './projects/helper/*' -not -path './projects/curve/*' -not -path './projects/sigmao/*' -exec du -sh {} \\; | sort -rh | head -n 100", "postinstall": "echo 'run \"npm update @defillama/sdk\" if you want lastest sdk changes' " }, "author": "", diff --git a/projects/3a-dao/index.js b/projects/3a-dao/index.js index d229ba553b80..c17b741cd69b 100644 --- a/projects/3a-dao/index.js +++ b/projects/3a-dao/index.js @@ -2,6 +2,7 @@ const { getLogs } = require('../helper/cache/getLogs') const config = { polygon: { factory: '0x4760847023fa0833221ae76E01Db1E483A5D20e0', fromBlock: 49852705 }, + linea: { factory: '0x65c6FD9B3a2A892096881e28f07c732ed128893E', fromBlock: 3045954 }, } Object.keys(config).forEach(chain => { @@ -16,7 +17,7 @@ Object.keys(config).forEach(chain => { fromBlock, }) const vaults = logs.map(log => log.vault) - const tokens = await api.multiCall({ abi: 'address[]:collaterals', calls: vaults}) + const tokens = await api.multiCall({ abi: 'address[]:collaterals', calls: vaults }) const ownerTokens = tokens.map((token, i) => [token, vaults[i]]) return api.sumTokens({ ownerTokens }) } diff --git a/projects/Chocoinu/index.js b/projects/Chocoinu/index.ts similarity index 100% rename from projects/Chocoinu/index.js rename to projects/Chocoinu/index.ts diff --git a/projects/MeowMiner/index.js b/projects/MeowMiner/index.js index 1c633e803223..4b188db8248d 100644 --- a/projects/MeowMiner/index.js +++ b/projects/MeowMiner/index.js @@ -5,9 +5,9 @@ const LP_MEOW_WAVAX = "0xbbf8e4b9AD041edE1F5270CAf5b7B41F0e55f719" module.exports = { methodology: 'counts the number of MEOW tokens in the Meow Miner contract.', - start: 1000235, + start: 1710293916, avax: { tvl: () => ({}), - staking: sumTokensExport({ owner: MEOW_MINER_CONTRACT, tokens: [MEOW_TOKEN_CONTRACT], lps: [LP_MEOW_WAVAX], useDefaultCoreAssets: true, }) + staking: sumTokensExport({ owner: MEOW_MINER_CONTRACT, tokens: [MEOW_TOKEN_CONTRACT], lps: [LP_MEOW_WAVAX], useDefaultCoreAssets: true, }), } } \ No newline at end of file diff --git a/projects/Zenonswap/index.js b/projects/Zenonswap/index.js new file mode 100644 index 000000000000..9e2291bc8a66 --- /dev/null +++ b/projects/Zenonswap/index.js @@ -0,0 +1,3 @@ +const { uniTvlExport } = require('../helper/unknownTokens') + +module.exports = uniTvlExport('degen', '0x97B162AD1443737B0500A5E726344D608eB9e255') \ No newline at end of file diff --git a/projects/ainn-layer2/index.js b/projects/ainn-layer2/index.js new file mode 100644 index 000000000000..bf28a426dc74 --- /dev/null +++ b/projects/ainn-layer2/index.js @@ -0,0 +1,36 @@ +const sdk = require('@defillama/sdk'); +const { sumTokensExport } = require('../helper/sumTokens'); + +const BTCOwners = [ + "bc1q6dtp7ayaj5k2zv0z5ayhkdsvmtvdqgyaa9zs53", + "3H8cmLndtkBs7kiHByhHAddTzy8taUwYPt", + "bc1pepsapf26n8y2f4uftlmhy60ksghx6rqlxdcj4uacfqrkcg6pmncs52rzuu", + "bc1qcmmkxfp2rawrp6yx55rez9jcqdnxtam8jhu2v2d9kz46upf948wq2usauv", + "bc1qu4ru2sph5jatscx5xuf0ttka36yvuql7hl5h4c", + "1JA46eiDpfx589wawn5RvtEXgwc518QfhZ", + "bc1qaajdlp5yrj5f77wq2ndtfqnmsamvvxhpy95662zkzykn9qhvdgys580hcs", + "368vZZKUWDFZRLWMFNRJzHo1HnibNeAJir", + "33hE9Wq65kjbiLsGD1NYwwNatP6hbsZv5H", + "32GU8Jux7SbsEbaAaLUnEQmc6JemLF6BUb", + "3CP5WJ2JSLCew7SETWUe5FxpBGrekMBiwk", + "39Fvw2Ho1fEkyDsos5sNTN5iMJZKzTL526", + "3Kptt4TZZRcjuGH8ikoQ8mV1TVxq45dnuS", + "3G4sMXWAAVTvTXTksr8u9zuu7W8RKsicEz", + "335DRGzLLG2tu4H4PnFBHYAwcj5pvV8zei" +]; + + +module.exports = { + methodology: "Staking tokens via AINN Layer2 Dataset counts as TVL.", + bitcoin: { + tvl: sdk.util.sumChainTvls([ + sumTokensExport({ owners: BTCOwners }), + ]), + }, + zklink: { + tvl: sumTokensExport({ + owners: ["0xc698c23d7cDE4203EafD8F45d8bab8fA86D413d1"], + tokens: ["0xEbc45Ef3B6D7E31573DAa9BE81825624725939f9"] //wbtc + }), + }, +}; diff --git a/projects/aloe/index.js b/projects/aloe/index.js index 7a7171e76bc2..6748e3f8c32f 100644 --- a/projects/aloe/index.js +++ b/projects/aloe/index.js @@ -23,15 +23,25 @@ async function getVaults(api) { async function tvl(api) { const vaults = await getVaults(api); - return api.erc4626Sum({ calls: vaults, isOG4626: true }); + return api.erc4626Sum({ calls: vaults, tokenAbi: 'address:asset', balanceAbi: 'uint256:lastBalance' }); +} + +async function borrowed(api) { + const vaults = await getVaults(api); + const tokens = await api.multiCall({ calls: vaults, abi: "address:asset" }); + const stats = await api.multiCall({ + calls: vaults, + abi: "function stats() view returns (uint72 borrowIndex, uint256 totalAssets, uint256 totalBorrows, uint256 totalSupply)", + }); + api.addTokens(tokens, stats.map(x => x.totalBorrows)); } module.exports = { - doublecounted: true, + doublecounted: false, methodology: - "Sums up deposits and borrows across Aloe's ERC4626 lending vaults to get TVL. Does not include collateral value.", + "Sums up deposits and borrows across Aloe's ERC4626 lending vaults to get TVL and Borrowed amounts, respectively. Does not include collateral value.", }; Object.keys(config).forEach(chain => { - module.exports[chain] = { tvl } + module.exports[chain] = { tvl, borrowed } }) \ No newline at end of file diff --git a/projects/alpaca-finance-v2/moneyMarket.js b/projects/alpaca-finance-v2/moneyMarket.js index d469aacc7e88..86ea760f3a8d 100644 --- a/projects/alpaca-finance-v2/moneyMarket.js +++ b/projects/alpaca-finance-v2/moneyMarket.js @@ -1,4 +1,3 @@ -const sdk = require("@defillama/sdk"); const abi = require("./abi.json"); const { getConfig } = require("../helper/cache"); const { sumTokens2 } = require('../helper/unwrapLPs') @@ -7,12 +6,12 @@ async function getMoneyMarketData() { return (await getConfig("alpaca-finance-2.0", "https://raw.githubusercontent.com/alpaca-finance/alpaca-v2-money-market/main/.mainnet.json")).moneyMarket; } -async function lendingTvl(ts, _, _1, {api}) { +async function lendingTvl(api) { const { moneyMarketDiamond, markets } = await getMoneyMarketData(); return sumTokens2({ api, owner: moneyMarketDiamond, tokens: markets.map(i => i.token)}) } -async function borrowTvl(ts, _, _1, {api}) { +async function borrowTvl(api) { const { moneyMarketDiamond, markets } = await getMoneyMarketData(); const tokens = markets.map(i => i.token) diff --git a/projects/arbis.js b/projects/arbis.js index 5fa40183cfe2..8c1c1b645b79 100644 --- a/projects/arbis.js +++ b/projects/arbis.js @@ -1,14 +1,6 @@ const { staking } = require('./helper/staking') -const sdk = require('@defillama/sdk') -const { unwrapLPsAuto } = require('./helper/unwrapLPs') -const { getChainTransform } = require('./helper/portedTokens') -const chain = 'arbitrum' - - -async function tvl(_, _b, { [chain]: block}) { - const balances = {} - const transformAddress = await getChainTransform(chain) +async function tvl(api) { const vaults1 = [ '0x47a156668F1Ecc659Efbbf4910508Ace1b46a49b', '0xdc2d66044e894d0726570bdc03d2123ab8f2cd51', @@ -26,41 +18,12 @@ async function tvl(_, _b, { [chain]: block}) { '0xb970E280F9ddAA3349ab9F3ecf778970cDE46655', ] - const { output: tokens } = await sdk.api.abi.multiCall({ - abi: abi.stakedToken, - calls: vaults.map(i => ({ target: i})), - chain, block, - }) - - const { output: deposits } = await sdk.api.abi.multiCall({ - abi: abi.totalSupply, - calls: vaults.map(i => ({ target: i})), - chain, block, - }) - - const { output: tokens1 } = await sdk.api.abi.multiCall({ - abi: abi.depositToken, - calls: vaults1.map(i => ({ target: i})), - chain, block, - }) - - const { output: deposits1 } = await sdk.api.abi.multiCall({ - abi: abi.totalDeposits, - calls: vaults1.map(i => ({ target: i})), - chain, block, - }) - - tokens.forEach((data, i) => { - sdk.util.sumSingleBalance(balances, transformAddress(data.output), deposits[i].output) - }) - - tokens1.forEach((data, i) => { - sdk.util.sumSingleBalance(balances, transformAddress(data.output), deposits1[i].output) - }) - - await unwrapLPsAuto({ balances, block, chain, }) - - return balances + const tokens = await api.multiCall({ abi: abi.stakedToken, calls: vaults}) + const bals = await api.multiCall({ abi: abi.totalSupply, calls: vaults}) + api.add(tokens, bals) + const tokens1 = await api.multiCall({ abi: abi.depositToken, calls: vaults1}) + const bals1 = await api.multiCall({ abi: abi.totalDeposits, calls: vaults1}) + api.add(tokens1, bals1) } module.exports = { diff --git a/projects/archly-finance-v2/index.js b/projects/archly-finance-v2/index.js index 014775227e79..0b7b1cb5b862 100644 --- a/projects/archly-finance-v2/index.js +++ b/projects/archly-finance-v2/index.js @@ -25,6 +25,7 @@ const config = { metis: { lp: '0xA152A0Ee0Bc15A937D5365DEB8507D063467A68d' }, neon_evm: { lp: '0x9a08ab9b8b9A90bF9fe836D28E85808Db29Dc1aD' }, mode: { lp: '0xC6FA6454E76cF425a020fdb1EF61FeB0e551912C' }, + zora: { lp: '0x577B2E4C7Ddd23d2fA9D56b4456505e420851046' }, } module.exports = { diff --git a/projects/ash-perp/index.js b/projects/ash-perp/index.js new file mode 100644 index 000000000000..4fda2795d2f6 --- /dev/null +++ b/projects/ash-perp/index.js @@ -0,0 +1,26 @@ +const { cachedGraphQuery } = require('../helper/cache') +const { sumTokens } = require('../helper/sumTokens') + +const API_URL = 'https://api.ashperp.trade/graphql'; + +const TVLQuery = `query Vault { + vault { + _address + getAssetTokenId + } + }` + +async function tvl() { + const data = await cachedGraphQuery('ashperp', API_URL, TVLQuery) + const owners = Object.values(data).flat().map(i => i._address); + const token = Object.values(data).flat().map(i => i.getAssetTokenId); + return sumTokens({ owners, chain: 'elrond', tokens: [token]}) +} + +module.exports = { + misrepresentedTokens: true, + timetravel: false, + elrond: { + tvl + }, +} \ No newline at end of file diff --git a/projects/astaria-v2/index.js b/projects/astaria-v2/index.js new file mode 100644 index 000000000000..1e83bbd68756 --- /dev/null +++ b/projects/astaria-v2/index.js @@ -0,0 +1,8 @@ +const { treasuryExports } = require("../helper/treasury"); +const ADDRESSES = require('../helper/coreAssets.json') + +module.exports = treasuryExports({ + base: { + owners: ["0x0000000000A6F0986c92cf1EC4d2e77aFBE1466D"], + }, +}) \ No newline at end of file diff --git a/projects/aura-finance/index.js b/projects/aura-finance/index.js index 35a31a7a561d..d4ecb17a4387 100644 --- a/projects/aura-finance/index.js +++ b/projects/aura-finance/index.js @@ -67,6 +67,7 @@ const config = { polygon: { factory: '0x22625eedd92c81a219a83e1dc48f88d54786b017', fromBlock: 40687417, voterProxy: '0xC181Edc719480bd089b94647c2Dc504e2700a2B0' }, xdai: { factory: '0x83E443EF4f9963C77bd860f94500075556668cb8', fromBlock: 27088527, voterProxy: '0xC181Edc719480bd089b94647c2Dc504e2700a2B0' }, polygon_zkevm: { factory: '0x2498A2B0d6462d2260EAC50aE1C3e03F4829BA95', fromBlock: 203652, voterProxy: '0xC181Edc719480bd089b94647c2Dc504e2700a2B0' }, + avax: { factory: '0xf23b4DB826DbA14c0e857029dfF076b1c0264843', fromBlock: 32558551, voterProxy: '0xC181Edc719480bd089b94647c2Dc504e2700a2B0' }, } module.exports = { diff --git a/projects/autobark/index.js b/projects/autobark/index.js index 76c3acd3db4e..8a013d2486b2 100644 --- a/projects/autobark/index.js +++ b/projects/autobark/index.js @@ -6,13 +6,13 @@ const tokenAPI = "address:want" module.exports = { [chain]: { - tvl: async (_, _b, { [chain]: block }) => { + tvl: async (api) => { const pools = await getConfig('autobark','https://raw.githubusercontent.com/autobark-finance/autobark-app-pub/main/src/features/config/vault/dogechain_pools.js') const vaults = pools .split('\n') .filter(i => i.includes('earnedTokenAddress')) .map(i => i.split('\'').filter(i => i.startsWith('0x'))[0]) - return yieldHelper({ vaults, chain, block, tokenAPI, useDefaultCoreAssets: true, }) + return yieldHelper({ ...api, vaults, tokenAPI, useDefaultCoreAssets: true, }) } } } \ No newline at end of file diff --git a/projects/based-finance/index.js b/projects/based-finance/index.js index 565b4f73fc7b..03e8e23cf987 100644 --- a/projects/based-finance/index.js +++ b/projects/based-finance/index.js @@ -22,8 +22,8 @@ const treasuryTokens = [ wftmAddress, ]; -async function treasury(_, _b, { fantom: block }) { - return sumTokens2({ owner: treasuryAddress, tokens: treasuryTokens, block, chain, }) +async function treasury(api) { + return sumTokens2({ owner: treasuryAddress, tokens: treasuryTokens, api }) } module.exports = { diff --git a/projects/beefy/index.js b/projects/beefy/index.js index 135617808e67..0354c2068027 100644 --- a/projects/beefy/index.js +++ b/projects/beefy/index.js @@ -40,6 +40,7 @@ const chains = { heco: 128, polygon: 137, fantom: 250, + fraxtal: 252, zksync: 324, metis: 1088, polygon_zkevm: 1101, diff --git a/projects/bitgert/index.js b/projects/bitgert/index.js index 30d2be79aa9e..c91da9ff2175 100644 --- a/projects/bitgert/index.js +++ b/projects/bitgert/index.js @@ -4,12 +4,11 @@ const { sumTokens2, nullAddress } = require('../helper/unwrapLPs') module.exports = { bsc: { tvl: () => ({}), - staking: staking('0xd578bf8cc81a89619681c5969d99ea18a609c0c3', '0x8FFf93E810a2eDaaFc326eDEE51071DA9d398E83', 'bsc'), + staking: staking('0xd578bf8cc81a89619681c5969d99ea18a609c0c3', '0x8FFf93E810a2eDaaFc326eDEE51071DA9d398E83'), }, bitgert: { - staking: async (_, _b, { bitgert: block }) => sumTokens2({ - chain: 'bitgert', - block, + staking: async (api) => sumTokens2({ + api, owner: '0x8Ed91b2f3d9f6a5Ee426B4705F981090a7403795', tokens: [nullAddress], }) diff --git a/projects/blackwing/index.js b/projects/blackwing/index.js new file mode 100644 index 000000000000..6813f3adc291 --- /dev/null +++ b/projects/blackwing/index.js @@ -0,0 +1,31 @@ +const ADDRESSES = require('../helper/coreAssets.json') +const { sumTokensExport } = require("../helper/unwrapLPs"); + +const BLACKWING_VAULT_ARBITRUM = '0xc6aDE8A68026d582AB37B879D188caF7e405dD09' +const BLACKWING_VAULT_ETH = '0xc6aDE8A68026d582AB37B879D188caF7e405dD09' +const BLACKWING_VAULT_BSC = '0xD00789260984160a64DcF19A03896DfF73BF4514' + +const ARBITRUM_WEETH = "0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe"; +const ARBITRUM_EZETH = "0x2416092f143378750bb29b79eD961ab195CcEea5"; + +const ETHEREUM_MAINNET_RSWETH = '0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0'; +const ETHEREUM_MAINNET_RSETH = "0xa1290d69c65a6fe4df752f95823fae25cb99e5a7"; +const ETHEREUM_MAINNET_WEETH = "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee"; +const ETHEREUM_MAINNET_EZETH = "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110"; + +module.exports = { + arbitrum: { + tvl: sumTokensExport({ tokens: [ADDRESSES.arbitrum.USDC_CIRCLE, ADDRESSES.arbitrum.USDC, ADDRESSES.arbitrum.WETH, ARBITRUM_EZETH, ARBITRUM_WEETH,], owner: BLACKWING_VAULT_ARBITRUM, fetchCoValentTokens: true, }), + }, + ethereum: { + tvl: sumTokensExport({ + tokens: [ADDRESSES.ethereum.USDC, ADDRESSES.ethereum.WETH, ETHEREUM_MAINNET_RSWETH, ETHEREUM_MAINNET_RSETH, ETHEREUM_MAINNET_EZETH, ADDRESSES.ethereum.EETH, ETHEREUM_MAINNET_WEETH, ADDRESSES.ethereum.sUSDe, + ], owner: BLACKWING_VAULT_ETH, fetchCoValentTokens: true, + }) + }, + bsc: { + tvl: sumTokensExport({ + tokens: [ADDRESSES.bsc.USDT, ADDRESSES.bsc.WBNB,], owner: BLACKWING_VAULT_BSC, fetchCoValentTokens: true, + }) + } +} diff --git a/projects/blast/index.js b/projects/blast/index.js index d56380747eea..51cfcd862680 100644 --- a/projects/blast/index.js +++ b/projects/blast/index.js @@ -4,7 +4,7 @@ const { nullAddress } = require("../helper/treasury"); const farm = "0x5f6ae08b8aeb7078cf2f96afb089d7c9f51da47d"; -async function tvl(_, _a, _b, {api}){ +async function tvl(api) { const dsr = await api.call({ target: "0x373238337bfe1146fb49989fc222523f83081ddb", abi: "function pieOf(address) external view returns (int256)", @@ -23,5 +23,5 @@ async function tvl(_, _a, _b, {api}){ } module.exports = { - ethereum: {tvl} + ethereum: { tvl } } diff --git a/projects/brrr/index.js b/projects/brrr/index.js index cb9d4ee4a44e..d76a6add8ee8 100644 --- a/projects/brrr/index.js +++ b/projects/brrr/index.js @@ -1,7 +1,7 @@ const { sumTokensExport } = require('../helper/unwrapLPs') const ADDRESSES = require('../helper/coreAssets.json') -const NFT_CONTRACT = "0x47efb5793b3aa8e15808c6fa794e6d7c93394047"; +const NFT_CONTRACT = "0x58ebebd033dC43aa9ab41ff739C7052eB0A72cd7"; module.exports = { blast: { diff --git a/projects/c14/index.js b/projects/c14/index.js new file mode 100644 index 000000000000..cc348169e6d3 --- /dev/null +++ b/projects/c14/index.js @@ -0,0 +1,7 @@ +const { aaveExports } = require('../helper/aave'); +const methodologies = require('../helper/methodologies'); + +module.exports = { + methodology: methodologies.lendingMarket, + astrzk: aaveExports('astrzk', "0x12922D7d8762090Cb27E7e1e824EC9c373664704", undefined, ['0x7B47bfB3F6C4ff74bb39395676759d4aFbD9f071'], { v3: true }), +} \ No newline at end of file diff --git a/projects/core-markets/index.js b/projects/core-markets/index.js new file mode 100644 index 000000000000..4a6cdc2d6375 --- /dev/null +++ b/projects/core-markets/index.js @@ -0,0 +1,44 @@ +const ADDRESSES = require('../helper/coreAssets.json') +const { request, gql } = require("graphql-request"); + +const graphUrl = "https://api.studio.thegraph.com/query/62472/core-analytics-082/version/latest"; + +const BETA_START = 236678; + +const query = gql` + query stats($from: String!, $to: String!) { + dailyHistories( + where: { timestamp_gte: $from, timestamp_lte: $to, accountSource: "0xd6ee1fd75d11989e57B57AA6Fd75f558fBf02a5e" } + ) { + timestamp + platformFee + accountSource + tradeVolume + deposit + withdraw + } + } +`; + +async function getTVL(toTimestamp) { + const { dailyHistories } = await request(graphUrl, query, { + from: BETA_START.toString(), + to: toTimestamp.timestamp.toString(), + }); + + const total = dailyHistories.reduce((acc, cur) => acc + (Number(cur.deposit) - Number(cur.withdraw)), 0); + + return { + ["blast:" + ADDRESSES.blast.USDB]: total, + }; +} + +module.exports = { + timetravel: false, + start: BETA_START, + blast: { + tvl: async (timestamp) => { + return getTVL(timestamp); + }, + }, +}; diff --git a/projects/curve/abi.json b/projects/curve/abi.json index eca2ca186e86..4925ec11820d 100644 --- a/projects/curve/abi.json +++ b/projects/curve/abi.json @@ -17,6 +17,7 @@ "crypto": "function get_coins(address _pool) view returns (address[8])", "cryptoFactory": "function get_coins(address _pool) view returns (address[2])", "triCryptoFactory": "function get_coins(address _pool) view returns (address[3])", - "CurveStableswapFactoryNG": "function get_coins(address _pool) view returns (address[])" + "CurveStableswapFactoryNG": "function get_coins(address _pool) view returns (address[])", + "CurveL2TricryptoFactory": "function get_coins(address _pool) view returns (address[3])" } } \ No newline at end of file diff --git a/projects/curve/contracts.json b/projects/curve/contracts.json index e6f2e917dbb1..2418ed6a379e 100644 --- a/projects/curve/contracts.json +++ b/projects/curve/contracts.json @@ -61,7 +61,8 @@ "metapoolBases": { "2CRV": "0xbf7e49483881c76487b0989cd7d9a8239b20ca41" }, - "CurveStableswapFactoryNG": "0x9AF14D26075f142eb3F292D5065EB3faa646167b" + "CurveStableswapFactoryNG": "0x9AF14D26075f142eb3F292D5065EB3faa646167b", + "CurveL2TricryptoFactory": "0xbc0797015fcfc47d9c1856639cae50d0e69fbee8" }, "aurora": { "addressProvider": "0x0000000022D53366457F9d5E68Ec105046FC4383", diff --git a/projects/curve/index.js b/projects/curve/index.js index f2e4e63c6b1b..9ca4de4f05e6 100644 --- a/projects/curve/index.js +++ b/projects/curve/index.js @@ -100,6 +100,9 @@ async function getPools(block, chain) { if (contracts[chain].CurveStableswapFactoryNG) { registriesMapping.CurveStableswapFactoryNG = contracts[chain].CurveStableswapFactoryNG } + if (contracts[chain].CurveL2TricryptoFactory) { + registriesMapping.CurveL2TricryptoFactory = contracts[chain].CurveL2TricryptoFactory + } const poolList = {} await Promise.all(Object.entries(registriesMapping).map(async ([registry, addr]) => { poolList[registry] = await getPool({ chain, block, registry: addr }) @@ -156,7 +159,7 @@ async function unwrapPools({ poolList, registry, chain, block }) { const callParams = { target: registryAddress, calls: poolList.map(i => ({ params: i.output })), chain, block, } const { output: coins } = await sdk.api.abi.multiCall({ ...callParams, abi: abi.get_coins[registry] }) let nCoins = {} - if (!['cryptoFactory', 'triCryptoFactory'].includes(registry)) + if (!['cryptoFactory', 'triCryptoFactory', 'CurveL2TricryptoFactory'].includes(registry)) nCoins = (await sdk.api.abi.multiCall({ ...callParams, abi: abi.get_n_coins[registry] })).output let { wrapped = '', metapoolBases = {}, blacklist = [] } = contracts[chain] diff --git a/projects/decubate/index.js b/projects/decubate/index.js index b18c12bf431f..66419bee029b 100644 --- a/projects/decubate/index.js +++ b/projects/decubate/index.js @@ -1,27 +1,14 @@ -const sdk = require("@defillama/sdk"); +const { staking } = require('../helper/staking') -const DCBToken = "0xEAc9873291dDAcA754EA5642114151f3035c67A2"; -const stakingPool = "0xD1748192aE1dB982be2FB8C3e6d893C75330884a"; - -async function staking (timestamp, block, chainBlocks) { - let balances = {}; - - let {output: balance} = await sdk.api.erc20.balanceOf({ - target: DCBToken, - owner: stakingPool, - block: chainBlocks.bsc, - chain: "bsc" - }); - - sdk.util.sumSingleBalance(balances, `bsc:${DCBToken}`, balance) - - return balances; -} +const DCBToken = "0xEAc9873291dDAcA754EA5642114151f3035c67A2" +const stakingPools = [ + "0xD1748192aE1dB982be2FB8C3e6d893C75330884a", // Legacy staking pool contract + "0xe740758a8cd372c836857defe8011e4e80e48723" // New staking pools contract +] module.exports = { - bsc: { - tvl: async () => ({}), - staking - }, - -} + bsc: { + tvl: async () => ({}), + staking: staking(stakingPools, DCBToken,) + }, +} \ No newline at end of file diff --git a/projects/defiplaza.js b/projects/defiplaza.js index 930c5ba11a40..d915d241e951 100644 --- a/projects/defiplaza.js +++ b/projects/defiplaza.js @@ -41,4 +41,4 @@ module.exports = { }, }, timetravel: false, -}; +}; \ No newline at end of file diff --git a/projects/degendex-fi/index.js b/projects/degendex-fi/index.js new file mode 100644 index 000000000000..eb7456cdf826 --- /dev/null +++ b/projects/degendex-fi/index.js @@ -0,0 +1,6 @@ +const { uniTvlExport } = require("../helper/unknownTokens"); + +module.exports = uniTvlExport( + "degen", + "0x45c1f8AF23Ea55e51927EE9A4d456fa7BCc5F0Fe" +); diff --git a/projects/degenfund/index.js b/projects/degenfund/index.js new file mode 100644 index 000000000000..60254944649e --- /dev/null +++ b/projects/degenfund/index.js @@ -0,0 +1,15 @@ +const { sumUnknownTokens } = require('../helper/unknownTokens') + +module.exports = { + methodology: "Calculates the total value of staked DFund tokens in our staker smart contract.", + degen: { + tvl: () => ({}), + staking: tvl + } +} + +async function tvl(api) { + const bal = await api.call({ abi: "uint256:totalDfundStaked", target: '0xe11CD52De12a86400311e0D2884aC9B542eEd05e' }) + api.add('0x0B946D939bb93609Fcce42220180E5C81B642786', bal) + return sumUnknownTokens({ api, lps: ['0x9c0Dd6BA0E2c611585c75F06f024BC8826FdB446'], useDefaultCoreAssets: true }) +} \ No newline at end of file diff --git a/projects/dtx/index.js b/projects/dtx/index.js index 53e4b9f41999..7964aff6a357 100644 --- a/projects/dtx/index.js +++ b/projects/dtx/index.js @@ -1,16 +1,24 @@ const { sumERC4626VaultsExport } = require("../helper/erc4626") +const sdk = require('@defillama/sdk') +const { sumTokensExport } = require('../helper/unwrapLPs') +const ADDRESSES = require('../helper/coreAssets.json') + +const vaultTvl = sumERC4626VaultsExport({ + vaults: [ + "0x56e0f6DF03883611C9762e78d4091E39aD9c420E", + "0x3D4621fa5ff784dfB2fcDFd5B293224167F239db", + "0xe97D34E531E1b299047A94Fc6854289830362d8f", + "0xBa95FCe6c2683C29bD963dd201CA8ee8f3605801", + "0x037A168876d3027b1384FD1752fEAa52407726dB", + "0x3031F6c8958Cf093377c11b3871BD23AEA5e5865", + ], + isOG4626: true, +}) + +const otherTvl = sumTokensExport({ tokens: [ADDRESSES.blast.USDB, ADDRESSES.blast.WETH], owners: ['0x9AdF2b330697C6816176491E1fd5503BB746d1d8', '0x0E5b7DDbF37d92B21512Ae5A6CE66aEfA7A7828F']}) module.exports = { blast: { - tvl: sumERC4626VaultsExport({ - vaults: [ - "0x56e0f6DF03883611C9762e78d4091E39aD9c420E", - "0x3D4621fa5ff784dfB2fcDFd5B293224167F239db", - "0xe97D34E531E1b299047A94Fc6854289830362d8f", - "0xBa95FCe6c2683C29bD963dd201CA8ee8f3605801", - "0x037A168876d3027b1384FD1752fEAa52407726dB", - ], - isOG4626: true, - }), + tvl: sdk.util.sumChainTvls([vaultTvl, otherTvl]), }, } diff --git a/projects/envelop/index.js b/projects/envelop/index.js index 8e559f406283..3d665030d287 100644 --- a/projects/envelop/index.js +++ b/projects/envelop/index.js @@ -62,7 +62,8 @@ const config = { "0x4640024F4e00De23211ca505f3021d460c01a2a8", // Protocol // "0xD5E1cDfCf6A9fdc68997a90E8B5ee962e536a0D8", // Farming "0xFcE14427Eb7e5df0c5313249b19B56b81633Df8A", // Protocol - "0x018Ab23bae3eD9Ec598B1239f37B998fEDB75af3", // Protocol + "0x018Ab23bae3eD9Ec598B1239f37B998fEDB75af3", // Protocol, + "0xc2571eBbc8F2af4f832bB8a2D3A4b0932Ce24773", ], farming: ['0xD5E1cDfCf6A9fdc68997a90E8B5ee962e536a0D8'], NIFTSY: '0x432cdbC749FD96AA35e1dC27765b23fDCc8F5cf1', @@ -79,6 +80,7 @@ const config = { protocolContracts: [ // '0x5bECBAD9784e1b370AE34a154084F3e7a52f6cEe', // '0x85DC0Ed956c15cB40580712693033e36385204A3', + '0x6664c8118284b3F5ECB47c2105cAa544Ab0Cf75B', ], tokens: [ ADDRESSES.null, diff --git a/projects/etherfi-liquid/index.js b/projects/etherfi-liquid/index.js new file mode 100644 index 000000000000..2c0f897708d3 --- /dev/null +++ b/projects/etherfi-liquid/index.js @@ -0,0 +1,14 @@ +async function tvl(api) { + const bal = await api.call({ + abi: "uint256:totalAssets", + target: '0xea1a6307d9b18f8d1cbf1c3dd6aad8416c06a221', + }); + api.add("0x35fa164735182de50811e8e2e824cfb9b6118ac2", bal); +} + +module.exports = { + doublecounted: true, + ethereum: { + tvl, + }, +}; diff --git a/projects/fathom-CDP/index.js b/projects/fathom-CDP/index.js new file mode 100644 index 000000000000..d738ba16a476 --- /dev/null +++ b/projects/fathom-CDP/index.js @@ -0,0 +1,9 @@ +const WXDCHolders = [ + '0x9B4aCeFE2dB986Ca080Dc01d137e6566dBE0aA3a', // CDP Vault CollateralPoolId "0x5844430000000000000000000000000000000000000000000000000000000000" +]; +const { sumTokensExport } = require('../helper/unwrapLPs') +const ADDRESSES = require('../helper/coreAssets.json') + +module.exports = { + xdc: { tvl: sumTokensExport({ owners: WXDCHolders, tokens: [ADDRESSES.xdc.WXDC]}) }, +} diff --git a/projects/fathom-lending/index.js b/projects/fathom-lending/index.js new file mode 100644 index 000000000000..92bf5e6ae124 --- /dev/null +++ b/projects/fathom-lending/index.js @@ -0,0 +1,10 @@ +const PoolAddressesProviderRegistry = "0xDAb3B99eb3569466750c436d6F4c99d57850Cc89" +const { aaveExports } = require('../helper/aave') + +module.exports = { + xdc: aaveExports(undefined, PoolAddressesProviderRegistry, undefined, ['0x7fa488a5C88E9E35B0B86127Ec76B0c1F0933191'], { + v3: true, abis: { + getAllATokens: "function getAllFmTokens() view returns (tuple(string symbol, address tokenAddress)[])", + } + }), +}; \ No newline at end of file diff --git a/projects/fathom-vault/index.js b/projects/fathom-vault/index.js new file mode 100644 index 000000000000..3c9b194a7005 --- /dev/null +++ b/projects/fathom-vault/index.js @@ -0,0 +1,14 @@ +const FathomVaultFactoryAddress = "0x0c6e3fd64D5f33eac0DCCDd887A8c7512bCDB7D6"; +const FXD = '0x49d3f7543335cf38Fa10889CCFF10207e22110B5'; + +async function tvl(api) { + const vaults = await api.call({ target: FathomVaultFactoryAddress, abi: "address[]:getVaults", }); + const queue = (await api.multiCall({ abi: "address[]:getDefaultQueue", calls: vaults })).flat() + queue.push(...vaults) + + return api.sumTokens({ owners: queue, tokens: [FXD] }) +} + +module.exports = { + xdc: { tvl, }, +} diff --git a/projects/frogswap-farm/index.js b/projects/frogswap-farm/index.js new file mode 100644 index 000000000000..db4e97932e09 --- /dev/null +++ b/projects/frogswap-farm/index.js @@ -0,0 +1,10 @@ +const { masterchefExports } = require("../helper/unknownTokens"); + +module.exports = masterchefExports({ + chain: "degen", + masterchef: "0xaB42EE05ceb48AC8f4d5782E4512D987694802b9", + nativeTokens: ["0x7D4F462895AD2A6856cb6e94055B841C3cA55987"], + useDefaultCoreAssets: true, + poolInfoABI: "function poolInfo(uint256) view returns (address)", + getToken: (i) => i, +}); \ No newline at end of file diff --git a/projects/fyde/index.js b/projects/fyde/index.js index d6ebcb1a8007..2ed9adbc38ad 100644 --- a/projects/fyde/index.js +++ b/projects/fyde/index.js @@ -1,6 +1,7 @@ +const ADDRESSES = require('../helper/coreAssets.json') const FYDE_CONTRACT = "0x87Cc45fFF5c0933bb6aF6bAe7Fc013b7eC7df2Ee"; const RESTAKING_AGGREGATOR = "0x3f69F62e25441Cf72E362508f4d6711d53B05341"; -const WETH = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; +const WETH = ADDRESSES.ethereum.WETH; async function tvl(api) { const tokens = await api.fetchList({ lengthAbi: 'getAssetsListLength', itemAbi: 'assetsList', target: FYDE_CONTRACT }) diff --git a/projects/glif/index.js b/projects/glif/index.js index d303e1fdd6e0..fa3a77302a9b 100644 --- a/projects/glif/index.js +++ b/projects/glif/index.js @@ -1,29 +1,33 @@ const { nullAddress } = require("../helper/tokenMapping"); const { get } = require("../helper/http"); -const INFINITY_POOL_CONTRACT = "0x43dAe5624445e7679D16a63211c5ff368681500c"; // pool address -const totalAssetsABI = "function totalAssets() view returns (uint256)"; -const totalBorrowedABI = "function totalBorrowed() view returns (uint256)"; +const INDEXER_API = "https://events.glif.link/pool/0/tvl"; module.exports = { methodology: - "The GLIF Pools protocol is a liquid staking protocol for Filecoin that requires borrowers to collateralize FIL in order to borrow for their storage providing operation. This TVL calculation adds the total amount of FIL staked into the protocol, and the total amount of locked FIL collateral by borrowers, to arrive at TVL.", + "The GLIF Pools protocol is a liquid leasing protocol for Filecoin that requires borrowers to collateralize FIL in order to borrow for their storage providing operation. This TVL calculation adds the total amount of FIL deposited into the protocol, and the total amount of locked FIL collateral by borrowers, to arrive at TVL.", filecoin: { - tvl: async (api) => { - const [totalAssets, totalLockedByMiners] = await Promise.all([ - api.call({ abi: totalAssetsABI, target: INFINITY_POOL_CONTRACT }), - // this call is too costly to perform on chain in this environment, - // we wrapped the locked miners collateral in a server that derives the information directly on-chain - // but serves it in a more efficient manner to not overload defillama frontend - // github repo: https://github.com/glifio/pools-metrics - get("https://events.glif.link/metrics"), - ]); - - const totalAssetsBN = +totalAssets - const totalLockedByMinersBN = +totalLockedByMiners.totalMinerCollaterals - // then we add the totalLockedByMiners to the totalAssets, to account for the FIL locked by miners as borrow collateral + tvl: async (_, height, _1, { api }) => { + let url = INDEXER_API; + if (!!height && height >= 0) { + url += `?height=${height}`; + } + // this call is too costly to perform on chain in this environment, + // we wrapped the tvl in a server that derives the information directly on-chain + // but serves it in a more efficient manner to not overload defillama frontend + // github repo: https://github.com/glifio/pools-metrics + const { tvl } = await get(url); // this gets our tvl in attoFIL (wei denominated) without double counting - api.add(nullAddress, totalAssetsBN+totalLockedByMinersBN); + api.add(nullAddress, tvl); }, }, + timetravel: true, + start: 1677628800, // 2023-03-01 + hallmarks: [ + // timestamp, event + [1680206490, "Early deposits open"], // 2023-03-30 + [1685035830, "Protocol deployed"], // 2023-05-25 + [1691781060, "Exit ramp deployed"], // 2023-08-11 + [1711641600, "GLIF Points released"], // 2024-03-28 + ], }; diff --git a/projects/growthdefi/abis/clqdr.json b/projects/growthdefi/abis/clqdr.json deleted file mode 100644 index 3ea13f77ea04..000000000000 --- a/projects/growthdefi/abis/clqdr.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "totalReserve": "uint256:totalReserve" -} \ No newline at end of file diff --git a/projects/growthdefi/index.js b/projects/growthdefi/index.js index 1d1bb56c5402..2f226e0b8a0d 100644 --- a/projects/growthdefi/index.js +++ b/projects/growthdefi/index.js @@ -1,584 +1,52 @@ const ADDRESSES = require('../helper/coreAssets.json') -const sdk = require("@defillama/sdk"); -const abi = require("./abi.json"); -const clqdr = require("./abis/clqdr.json"); -const { unwrapUniswapLPs } = require("../helper/unwrapLPs"); +const abi = require("./abi.json") -const GRO_BSC = "0x336ed56d8615271b38ecee6f4786b55d0ee91b96"; -const LINSPIRIT = "0xc5713B6a0F26bf0fdC1c52B90cd184D950be515C"; - -const morChains = { +const config = { bsc: { + autoGem: "0xE02CE329281664A5d2BC0006342DC84f6c384663", + DAI: "0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3", pools: [ "0x13e7a6691fe00de975cf27868386f4ae9aed3cdc", "0xc2e8c3c427e0a5baaf512a013516aecb65bd75cb", ], - - ignoreAddresses: [], - }, - avax: { - pools: [], - - ignoreAddresses: [], + singlePSM: ADDRESSES.bsc.BUSD, }, fantom: { + DAI: ADDRESSES.fantom.DAI, pools: [ "0x30463d33735677b4e70f956e3dd61c6e94d70dfe", "0xaebd31E9FFcB222feE947f22369257cEcf1F96CA", ], - ignoreAddresses: [], - }, -}; - -const morChainsNonStk = { - bsc: { - pools: [], - mcds: [], - ignoreAddresses: [], }, avax: { - pools: [], - mcds: [], - ignoreAddresses: [], - }, - fantom: { - pools: [ - "0x814c66594a22404e101fecfecac1012d8d75c156", - "0x3f569724cce63f7f24c5f921d5ddcfe125add96b", - ], - mcds: [ - "0xe5fb3D583660e57b1f616f89Ae98dfb6e3c37f99", - "0x726d946BBF3d0E6f9e5078D4F5e1f0014c37288F", - ], - ignoreAddresses: [], - }, -}; - -const transformFrom = async (chain) => { - if (chain === "bsc") { - return addr => 'bsc:'+addr - } else if (chain === "avax") { - return addr => 'avax:'+addr - } else { - return addr => 'fantom:'+addr + DAI: ADDRESSES.avax.DAI, + singlePSM: ADDRESSES.avax.USDC_e, + autoGem: "0x65764167EC4B38D611F961515B51a40628614018", } -}; - -//*** MOR tvl portion as product of GrowthDefi Protocol ***// -const fetchMorChainTvl = async ( - timestamp, - ethBlock, - chainBlocks, - chain, - chainCustomProcessor -) => { - const chainConfig = morChains[chain]; - - const balances = {}; - - const stakeLpTokens = ( - await sdk.api.abi.multiCall({ - abi: abi.state, - calls: chainConfig.pools.map((pool) => ({ - target: pool, - })), - chain: chain, - block: chainBlocks[chain], - }) - ).output.map((stkLp) => stkLp.output._reserveToken); - - const stakeLpTokens_bal = ( - await sdk.api.abi.multiCall({ - abi: abi.totalReserve, - calls: chainConfig.pools.map((pool) => ({ - target: pool, - })), - chain: chain, - block: chainBlocks[chain], - }) - ).output.map((stkLp_bal) => stkLp_bal.output); - - const stkSymbol = ( - await sdk.api.abi.multiCall({ - abi: abi.symbol, - calls: stakeLpTokens.map((lp) => ({ - target: lp, - })), - chain: chain, - block: chainBlocks[chain], - }) - ).output; - - const lpPositions = []; - - await Promise.all( - stkSymbol.map(async (symbol, idx) => { - if (symbol.output.includes("LP")) { - lpPositions.push({ - token: stakeLpTokens[idx], - balance: stakeLpTokens_bal[idx], - }); - } else { - const processedTokens = await chainCustomProcessor( - stakeLpTokens[idx], - stakeLpTokens_bal[idx], - symbol.output, - chainBlocks - ); - - processedTokens.map(({ tokenAddress, tokenBalance }) => { - sdk.util.sumSingleBalance( - balances, - `${chain}:${tokenAddress}`, - tokenBalance - ); - }); - } - }) - ); - - const transformAddress = await transformFrom(chain); - - await unwrapUniswapLPs( - balances, - lpPositions, - chainBlocks[chain], - chain, - transformAddress - ); - - return balances; -}; - -//*** MOR tvl portion as product of GrowthDefi Protocol - for the non strategy contracts ***// -const fetchMorNonStkChainTvl = async ( - timestamp, - ethBlock, - chainBlocks, - chain, - chainCustomProcessor -) => { - const chainConfig = morChainsNonStk[chain]; - - const balances = {}; - - const stakeLpTokens = chainConfig.pools; - - const stakeLpTokens_bal = ( - await sdk.api.abi.multiCall({ - abi: "erc20:balanceOf", - calls: chainConfig.pools.map((pool, idx) => ({ - target: pool, - params: chainConfig.mcds[idx], - })), - chain: chain, - block: chainBlocks[chain], - }) - ).output.map((stkLp_bal) => stkLp_bal.output); - - const stkSymbol = ( - await sdk.api.abi.multiCall({ - abi: abi.symbol, - calls: stakeLpTokens.map((lp) => ({ - target: lp, - })), - chain: chain, - block: chainBlocks[chain], - }) - ).output; - - const lpPositions = []; - - await Promise.all( - stkSymbol.map(async (symbol, idx) => { - if (symbol.output.includes("LP")) { - lpPositions.push({ - token: stakeLpTokens[idx], - balance: stakeLpTokens_bal[idx], - }); - } else { - const processedTokens = await chainCustomProcessor( - stakeLpTokens[idx], - stakeLpTokens_bal[idx], - symbol.output, - chainBlocks - ); - - processedTokens.map(({ tokenAddress, tokenBalance }) => { - sdk.util.sumSingleBalance( - balances, - `${chain}:${tokenAddress}`, - tokenBalance - ); - }); - } - }) - ); - - const transformAddress = await transformFrom(chain); - - await unwrapUniswapLPs( - balances, - lpPositions, - chainBlocks[chain], - chain, - transformAddress - ); - - return balances; -}; - -//*** LQDR staked portion as product of GrowthDefi Protocol ***// -const fetchCLQDRStaking = async ( - timestamp, - ethBlock, - chainBlocks, - chain, - chainCustomProcessor -) => { - const balances = {}; - - const stakeLpTokens = ["0x814c66594a22404e101fecfecac1012d8d75c156"]; - - const stakeLpTokens_bal = ( - await sdk.api.abi.multiCall({ - abi: clqdr.totalReserve, - calls: stakeLpTokens.map((pool, idx) => ({ - target: pool, - })), - chain: chain, - block: chainBlocks[chain], - }) - ).output.map((stkLp_bal) => stkLp_bal.output); - - const stkSymbol = ( - await sdk.api.abi.multiCall({ - abi: abi.symbol, - calls: stakeLpTokens.map((lp) => ({ - target: lp, - })), - chain: chain, - block: chainBlocks[chain], - }) - ).output; - - await Promise.all( - stkSymbol.map(async (symbol, idx) => { - const processedTokens = await chainCustomProcessor( - "0x10b620b2dbAC4Faa7D7FFD71Da486f5D44cd86f9", - stakeLpTokens_bal[idx], - "LQDR", - chainBlocks - ); - - processedTokens.map(({ tokenAddress, tokenBalance }) => { - sdk.util.sumSingleBalance( - balances, - `${chain}:${tokenAddress}`, - tokenBalance - ); - }); - }) - ); - - return balances; -}; - -const psmConfig = { - avax: ["0x88cc23286f1356eb0163ad5bdbfa639416e4168d"], - bsc: [], - fantom: ["0xa561fa603bf0b43cb0d0911eeccc8b6777d3401b"], -}; - -const stableConfig = { - avax: [ADDRESSES.avax.USDC_e], - bsc: [ADDRESSES.bsc.BUSD], - fantom: [], -}; - -const autoGem = { - avax: "0x65764167EC4B38D611F961515B51a40628614018", - bsc: "0xE02CE329281664A5d2BC0006342DC84f6c384663", - fantom: "", -}; - -const DAI = { - avax: ADDRESSES.avax.DAI, - bsc: "0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3", - fantom: ADDRESSES.fantom.DAI, -}; - -//*** PSM staked portion as product of GrowthDefi Protocol ***// -const fetchPSMMultiple = async ( - timestamp, - ethBlock, - chainBlocks, - chain, - chainCustomProcessor -) => { - const balances = {}; - - const stakeLpTokens = psmConfig[chain]; - - const stakeLpTokens_bal = ( - await sdk.api.abi.multiCall({ - abi: "erc20:totalSupply", - calls: stakeLpTokens.map((pool, idx) => ({ - target: pool, - })), - chain: chain, - block: chainBlocks[chain], - }) - ).output.map((stkLp_bal) => stkLp_bal.output); - - const stkSymbol = ( - await sdk.api.abi.multiCall({ - abi: abi.symbol, - calls: stakeLpTokens.map((lp) => ({ - target: lp, - })), - chain: chain, - block: chainBlocks[chain], - }) - ).output; - - await Promise.all( - stkSymbol.map(async (symbol, idx) => { - const processedTokens = await chainCustomProcessor( - DAI[chain], - stakeLpTokens_bal[idx], - "DAI", - chainBlocks - ); - - processedTokens.map(({ tokenAddress, tokenBalance }) => { - sdk.util.sumSingleBalance( - balances, - `${chain}:${tokenAddress}`, - tokenBalance - ); - }); - }) - ); - - return balances; -}; - -//*** PSM staked portion as product of GrowthDefi Protocol ***// -const fetchPSMSingle = async ( - timestamp, - ethBlock, - chainBlocks, - chain, - chainCustomProcessor -) => { - const balances = {}; - - const stakeLpTokens = stableConfig[chain]; - - const stakeLpTokens_bal = ( - await sdk.api.abi.multiCall({ - abi: "erc20:balanceOf", - calls: stakeLpTokens.map((pool, idx) => ({ - target: pool, - params: autoGem[chain], - })), - chain: chain, - block: chainBlocks[chain], - }) - ).output.map((stkLp_bal) => stkLp_bal.output); - - const stkSymbol = ( - await sdk.api.abi.multiCall({ - abi: abi.symbol, - calls: stakeLpTokens.map((lp) => ({ - target: lp, - })), - chain: chain, - block: chainBlocks[chain], - }) - ).output; - - await Promise.all( - stkSymbol.map(async (symbol, idx) => { - const processedTokens = await chainCustomProcessor( - DAI[chain], - stakeLpTokens_bal[idx], - "DAI", - chainBlocks - ); - - processedTokens.map(({ tokenAddress, tokenBalance }) => { - sdk.util.sumSingleBalance( - balances, - `${chain}:${tokenAddress}`, - tokenBalance - ); - }); - }) - ); - - return balances; -}; - -/** - * BSC-specific tokens processing logic - * - * @param {*} address - * @param {*} balance - * @param {*} symbol - * @param {*} chainBlocks - * @returns - */ -const bscTokensProcessor = async (address, balance, symbol, chainBlocks) => { - let tokenAddress = address; - let tokenBalance = balance; - - // Replace govGRO token with GRO (as it's pegged 1:1) - if (symbol === "govGRO") { - tokenAddress = GRO_BSC; - } - - return [{ tokenAddress, tokenBalance }]; -}; - -/** - * Avax-specific tokens processing logic - * - * @param {*} address - * @param {*} balance - * @param {*} symbol - * @param {*} chainBlocks - * @returns - */ -const avaxTokensProcessor = async (address, balance, symbol, chainBlocks) => { - let tokenAddress = address; - let tokenBalance = balance; - - return [{ tokenAddress, tokenBalance }]; -}; - -const ftmTokensProcessor = async (address, balance, symbol, chainBlocks) => { - let tokenAddress = address; - let tokenBalance = balance; - - // Replace govGRO token with GRO (as it's pegged 1:1) - if (symbol === "slinSpirit") { - tokenAddress = LINSPIRIT; +} + +const tvl = async (api) => { + const { pools = [], autoGem, DAI, singlePSM } = config[api.chain] ?? {} + + const stakeLpTokens = (await api.multiCall({ abi: abi.state, calls: pools, })).map((stkLp) => stkLp._reserveToken); + const stakeLpTokens_bal = (await api.multiCall({ abi: abi.totalReserve, calls: pools, })) + api.add(stakeLpTokens, stakeLpTokens_bal) + if (autoGem) await api.sumTokens({ tokens: [singlePSM], owner: autoGem }) + + if (api.chain === 'avax') { + const bal = await api.call({ abi: 'uint256:totalReserve', target: '0x88Cc23286f1356EB0163Ad5bdbFa639416e4168d' }) + api.add(DAI, bal) + } else if (api.chain === 'fantom') { + const bal = await api.call({ abi: 'uint256:totalReserve', target: '0xA561fa603bf0B43Cb0d0911EeccC8B6777d3401B' }) + const want = await api.call({ abi: 'address:want', target: '0x3f569724cce63f7f24c5f921d5ddcfe125add96b' }) + const wantBal = await api.call({ abi: 'uint256:balance', target: '0x3f569724cce63f7f24c5f921d5ddcfe125add96b' }) + const lQDRBal = await api.call({ abi: 'erc20:balanceOf', target: '0x3ae658656d1c526144db371faef2fff7170654ee', params: '0x814c66594a22404e101fecfecac1012d8d75c156' }) + api.add('0x10b620b2dbAC4Faa7D7FFD71Da486f5D44cd86f9', lQDRBal) + api.add(DAI, bal) + api.add(want, wantBal) } - - return [{ tokenAddress, tokenBalance }]; -}; - -const morBscTvl = (timestamp, ethBlock, chainBlocks) => { - return fetchMorChainTvl( - timestamp, - ethBlock, - chainBlocks, - "bsc", - bscTokensProcessor - ); -}; - -const morAvaxTvl = (timestamp, ethBlock, chainBlocks) => { - return fetchMorChainTvl( - timestamp, - ethBlock, - chainBlocks, - "avax", - avaxTokensProcessor - ); }; -const morFTMTvl = (timestamp, ethBlock, chainBlocks) => { - return fetchMorChainTvl( - timestamp, - ethBlock, - chainBlocks, - "fantom", - ftmTokensProcessor - ); -}; - -const morFTMNonStkTvl = (timestamp, ethBlock, chainBlocks) => { - return fetchMorNonStkChainTvl( - timestamp, - ethBlock, - chainBlocks, - "fantom", - ftmTokensProcessor - ); -}; - -const clqdrStakeTvl = (timestamp, ethBlock, chainBlocks) => { - return fetchCLQDRStaking( - timestamp, - ethBlock, - chainBlocks, - "fantom", - ftmTokensProcessor - ); -}; - -const psmTVLMultipleFTM = (timestamp, ethBlock, chainBlocks) => { - return fetchPSMMultiple( - timestamp, - ethBlock, - chainBlocks, - "fantom", - ftmTokensProcessor - ); -}; - -const psmTVLMultipleAVAX = (timestamp, ethBlock, chainBlocks) => { - return fetchPSMMultiple( - timestamp, - ethBlock, - chainBlocks, - "avax", - ftmTokensProcessor - ); -}; - -const psmTVLSingleAVAX = (timestamp, ethBlock, chainBlocks) => { - return fetchPSMSingle( - timestamp, - ethBlock, - chainBlocks, - "avax", - ftmTokensProcessor - ); -}; - -const psmTVLSingleBSC = (timestamp, ethBlock, chainBlocks) => { - return fetchPSMSingle( - timestamp, - ethBlock, - chainBlocks, - "bsc", - ftmTokensProcessor - ); -}; -module.exports = { - misrepresentedTokens: true, - bsc: { - tvl: sdk.util.sumChainTvls([morBscTvl, psmTVLSingleBSC]), - }, - avax: { - tvl: sdk.util.sumChainTvls([ - morAvaxTvl, - psmTVLMultipleAVAX, - psmTVLSingleAVAX, - ]), - }, - fantom: { - tvl: sdk.util.sumChainTvls([ - morFTMTvl, - morFTMNonStkTvl, - clqdrStakeTvl, - psmTVLMultipleFTM, - ]), - }, - methodology: - "We count liquidity on MOR through MasterChef and Staking Contracts", -}; +Object.keys(config).forEach(chain => { + module.exports[chain] = { tvl } +}) \ No newline at end of file diff --git a/projects/hakka.js b/projects/hakka.js index 62d6a4117f49..a38048ed25f9 100644 --- a/projects/hakka.js +++ b/projects/hakka.js @@ -16,7 +16,7 @@ const intelligenceETH = ['0x0F2fd95c221770d108aCD5363D25b06Bdc43140B'] const intelligenceBSC = ['0xD8B3fF98025Cf203Ba6D7Bb2d25DBeEF9539E6FB', '0x517Ef6281a9b3dc4Ef6B0318Bc5EDFDCf677d29D', '0x0A3e364eE37bac9E6aFF9E864E65B4603D5BC5D4'] const BSC_BHS_ADDRESS = '0x75192D6f3d51554CC2eE7B40C3aAc5f97934ce7E' -async function ethereum(_, block) { +async function ethereum(api) { const toa = [ [nullAddress, thirdFloorAddress], // thirdFloor // guild bank @@ -26,16 +26,15 @@ async function ethereum(_, block) { [ADDRESSES.ethereum.USDC, hakkaGuildBank], ] - return sumTokens2({ tokensAndOwners: toa, block, }) + return sumTokens2({ tokensAndOwners: toa, api, }) } -async function bsc(_, _b, { bsc: block }) { - const chain = 'bsc' +async function bsc(api) { const toa = [ [ADDRESSES.bsc.BUSD, BSC_BHS_ADDRESS], // thirdFloor [ADDRESSES.bsc.USDT, BSC_BHS_ADDRESS], // thirdFloor ] - return sumTokens2({ tokensAndOwners: toa, block, chain }) + return sumTokens2({ tokensAndOwners: toa, api }) } module.exports = { @@ -51,6 +50,6 @@ module.exports = { }, bsc: { tvl: bsc, - staking: sumTokensExport({ owners: intelligenceBSC, tokens: [HAKKA_ADDRESSES[56]], chain: 'bsc' }), + staking: sumTokensExport({ owners: intelligenceBSC, tokens: [HAKKA_ADDRESSES[56]], }), } } diff --git a/projects/helper/aave.js b/projects/helper/aave.js index f41d7fca3e86..e2f2aeca05bd 100644 --- a/projects/helper/aave.js +++ b/projects/helper/aave.js @@ -104,8 +104,10 @@ async function getBorrowed(balances, block, chain, v2ReserveTokens, dataHelper, }) } -function aaveChainTvl(chain, addressesProviderRegistry, transformAddressRaw, dataHelperAddresses, borrowed, v3 = false, { abis = {}, oracle, blacklistedTokens = [], hasV2LPs = false, } = {}) { - return async (timestamp, ethBlock, { [chain]: block }) => { +function aaveChainTvl(_chain, addressesProviderRegistry, transformAddressRaw, dataHelperAddresses, borrowed, v3 = false, { abis = {}, oracle, blacklistedTokens = [], hasV2LPs = false, } = {}) { + return async (api) => { + const chain = api.chain + const block = api.block const balances = {} const { transformAddress, fixBalances, v2Atokens, v2ReserveTokens, dataHelper, updateBalances } = await getData({ oracle, chain, block, addressesProviderRegistry, dataHelperAddresses, transformAddressRaw, abis, }) if (borrowed) { @@ -125,10 +127,10 @@ function aaveChainTvl(chain, addressesProviderRegistry, transformAddressRaw, dat return balances } } -function aaveExports(chain, addressesProviderRegistry, transform = undefined, dataHelpers = undefined, { oracle, abis, v3 = false, blacklistedTokens = [], hasV2LPs = false, } = {}) { +function aaveExports(_chain, addressesProviderRegistry, transform = undefined, dataHelpers = undefined, { oracle, abis, v3 = false, blacklistedTokens = [], hasV2LPs = false, } = {}) { return { - tvl: aaveChainTvl(chain, addressesProviderRegistry, transform, dataHelpers, false, v3, { oracle, abis, blacklistedTokens, hasV2LPs, }), - borrowed: aaveChainTvl(chain, addressesProviderRegistry, transform, dataHelpers, true, v3, { oracle, abis, hasV2LPs, blacklistedTokens, }) + tvl: aaveChainTvl(_chain, addressesProviderRegistry, transform, dataHelpers, false, v3, { oracle, abis, blacklistedTokens, hasV2LPs, }), + borrowed: aaveChainTvl(_chain, addressesProviderRegistry, transform, dataHelpers, true, v3, { oracle, abis, hasV2LPs, blacklistedTokens, }) } } diff --git a/projects/helper/cache/getLogs.js b/projects/helper/cache/getLogs.js index 79614754976a..ac550173a79b 100644 --- a/projects/helper/cache/getLogs.js +++ b/projects/helper/cache/getLogs.js @@ -7,7 +7,7 @@ const cacheFolder = 'logs' async function getLogs({ target, topic, keys = [], fromBlock, toBlock, topics, - api, eventAbi, onlyArgs = false, extraKey, skipCache = false, onlyUseExistingCache = false, customCacheFunction, skipCacheRead = false}) { + api, eventAbi, onlyArgs = false, extraKey, skipCache = false, onlyUseExistingCache = false, customCacheFunction, skipCacheRead = false }) { if (!api) throw new Error('Missing sdk api object!') if (!target) throw new Error('Missing target!') if (!fromBlock) throw new Error('Missing fromBlock!') @@ -100,7 +100,7 @@ async function getLogs({ target, if (skipCache || skipCacheRead) return defaultRes - let cache = await getCache(cacheFolder, key) + let cache = await getCache(cacheFolder, key, { checkIfRecent: true }) // set initial structure if it is missing / reset if from block is moved to something older if (!cache.logs || fromBlock < cache.fromBlock) { return defaultRes @@ -110,7 +110,7 @@ async function getLogs({ target, } } -async function getLogs2({ factory, target, topic, keys = [], fromBlock, toBlock, topics, api, eventAbi, onlyArgs = true, extraKey, skipCache = false, onlyUseExistingCache = false, customCacheFunction, skipCacheRead = false, transform = i => i}) { +async function getLogs2({ factory, target, topic, keys = [], fromBlock, toBlock, topics, api, eventAbi, onlyArgs = true, extraKey, skipCache = false, onlyUseExistingCache = false, customCacheFunction, skipCacheRead = false, transform = i => i }) { const res = await getLogs({ target: target ?? factory, topic, keys, fromBlock, toBlock, topics, api, eventAbi, onlyArgs, extraKey, skipCache, onlyUseExistingCache, customCacheFunction, skipCacheRead }) return res.map(transform) } diff --git a/projects/helper/chain/wavesAdapter.js b/projects/helper/chain/wavesAdapter.js deleted file mode 100644 index ae1d2efbed11..000000000000 --- a/projects/helper/chain/wavesAdapter.js +++ /dev/null @@ -1,34 +0,0 @@ -const { getApiTvl } = require('../historicalApi') -const { fetchURL } = require('../utils') - -const MINUTE = 60 * 1000 -const host = 'https://tvl.waves.tech/api/v1/history' - -function wavesAdapter(uri, calcTvl) { - const endpoint = host + uri - return async (time) => { - return getApiTvl(time, async () => { - const data = (await fetchURL(`${endpoint}?limit=1000&since=${time * 1e3 - 10 * MINUTE}`)).data - const last = data[data.length - 1] - return calcTvl(last) - }, async () => { - const data = (await fetchURL(`${endpoint}?limit=1000&since=${time * 1e3 - 6 * 60 * MINUTE}`)).data - return data.map(item => ({ - date: item.createdAt / 1e3, - totalLiquidityUSD: calcTvl(item) - })) - }) - } -} - -function wavesExport(uri, calcTvl = item => item.totalLocked) { - return { - misrepresentedTokens: true, - timetravel: false, - waves: { tvl: wavesAdapter(uri, calcTvl) } - } -} - -module.exports = { - wavesAdapter, wavesExport, -} \ No newline at end of file diff --git a/projects/helper/chains.json b/projects/helper/chains.json index 536b913eabc8..59733c054331 100644 --- a/projects/helper/chains.json +++ b/projects/helper/chains.json @@ -132,6 +132,7 @@ "injective", "interlay", "iotex", + "islm", "jbc", "juno", "kadena", @@ -257,6 +258,7 @@ "step", "stride", "sui", + "svm", "sx", "syscoin", "telos", @@ -278,6 +280,7 @@ "umee", "vechain", "velas", + "venom", "vision", "vite", "vive", @@ -297,4 +300,4 @@ "zksync", "zora", "zyx" -] +] \ No newline at end of file diff --git a/projects/helper/coreAssets.json b/projects/helper/coreAssets.json index f612af8172bf..0a745fec252f 100644 --- a/projects/helper/coreAssets.json +++ b/projects/helper/coreAssets.json @@ -1254,7 +1254,9 @@ "WSTETH": "0x042b8f0484674ca266ac5d08e4ac6a3fe65bd3129795def2dca5c34ecc5f96d2", "LUSD": "0x070a76fd48ca0ef910631754d77dd822147fe98a569b826ec85e3c33fde586ac", "RETH": "0x0319111a5037cbec2b3e638cc34a3474e2d2608299f3e62866e9cc683208c610", - "UNO": "0x0719b5092403233201aa822ce928bd4b551d0cdb071a724edd7dc5e5f57b7f34" + "UNO": "0x0719b5092403233201aa822ce928bd4b551d0cdb071a724edd7dc5e5f57b7f34", + "NSTSTRK": "0x04619e9ce4109590219c5263787050726be63382148538f3f936c22aa87d2fc2", + "ZEND": "0x00585c32b625999e6e5e78645ff8df7a9001cf5cf3eb6b80ccdd16cb64bd3a34" }, "ton": { "TON": "0x0000000000000000000000000000000000000000", @@ -1288,6 +1290,7 @@ }, "core": { "WCORE": "0x40375c92d9faf44d2f9db9bd9ba41a3317a2404f", + "WCORE_1": "0x191e94fa59739e188dce837f7f6978d84727ad01", "USDT": "0x900101d06a7426441ae63e9ab3b9b0f63be145f1", "USDC": "0xa4151b2b3e269645181dccf2d426ce75fcbdeca9" }, @@ -1404,6 +1407,9 @@ }, "stacks": { "WSTX": "SP1Z92MPDQEWZXW36VX71Q25HKF5K2EPCJ304F275.wstx-token-v4a", + "WSTX_1": "SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.wstx-token::wstx", + "WSTX_2": "SP1Y5YSTAHZ88XYK1VPDH24GY0HPX5J4JECTMY4A1.wstx", + "ABTC": "SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-abtc", "WBTC": "SP3DX3H4FEYZJZ586MFBS25ZW3HZDMEW92260R2PR.Wrapped-Bitcoin::wrapped-bitcoin", "stSTX": "SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token::ststx", "USDT": "SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-susdt::bridged-usdt", @@ -1653,6 +1659,7 @@ }, "merlin": { "WBTC": "0xF6D226f9Dc15d9bB51182815b320D3fBE324e1bA", + "WBTC_1": "0xB880fd278198bd590252621d4CD071b1842E9Bcd", "VOYA": "0x480e158395cc5b41e5584347c495584ca2caf78d" }, "ftn": { @@ -1666,7 +1673,25 @@ "zklink": { "WETH": "0x8280a4e7D5B3B658ec4580d3Bc30f5e50454F169" }, - "kinto":{ + "kinto": { "WETH": "0x7526B5318Cbe690FBd3eC8DD7ad122f4F1b1d76F" + }, + "bevm": { + "WBTC": "0xB5136FEba197f5fF4B765E5b50c74db717796dcD" + }, + "degen": { + "WDEGEN": "0xeb54dacb4c2ccb64f8074eceea33b5ebb38e5387" + }, + "imx": { + "WIMX": "0x3A0C2Ba54D6CBd3121F01b96dFd20e99D1696C9D", + "ETH": "0x52a6c53869ce09a731cd772f245b97a4401d3348", + "USDC": "0x6de8acc0d406837030ce4dd28e7c08c5a96a30d2" + }, + "sapphire": { + "WOAS": "0x1ffd8a218fdc5b38210d64cbb45f40dc55a4e019", + "USDT": "0x9ca066f00e55b90623efe323feb2a649686538b6" + }, + "rss3_vsl": { + "WRSS": "0xe27d019909738d98ab7f850c05ee07806c30c71d" } } diff --git a/projects/helper/env.js b/projects/helper/env.js index ada404c4744c..334d3c95012f 100644 --- a/projects/helper/env.js +++ b/projects/helper/env.js @@ -12,20 +12,6 @@ const DEFAULTS = { MULTIVERSX_RPC: 'https://api.multiversx.com', ANKR_API_KEY: '79258ce7f7ee046decc3b5292a24eb4bf7c910d7e39b691384c7ce0cfb839a01', RENEC_RPC: "https://api-mainnet-beta.renec.foundation:8899/", - NAKA_RPC: 'https://node.nakachain.xyz', - ETHF_RPC: 'https://rpc.dischain.xyz/', - CORE_RPC: "https://rpc.coredao.org,https://rpc.ankr.com/core,https://1rpc.io/core,https://rpc-core.icecreamswap.com", - BITGERT_RPC: "https://flux-rpc2.brisescan.com,https://mainnet-rpc.brisescan.com,https://chainrpc.com,https://serverrpc.com,https://flux-rpc.brisescan.com", - BITCHAIN_RPC: "https://rpc.bitchain.biz/", - OZONE_RPC: "https://node1.ozonechain.io", - ZETA_RPC: "https://zetachain-evm.blockpi.network/v1/rpc/public,https://zetachain-mainnet-archive.allthatnode.com:8545", - DEFIVERSE_RPC: "https://rpc.defi-verse.org/", - ZKLINK_RPC: "https://rpc.zklink.io", - KINTO_RPC: "https://rpc.kinto-rpc.com", - DEFICHAIN_EVM_RPC: "https://dmc.mydefichain.com/mainnet,https://dmc01.mydefichain.com/mainnet", - RSS3_VSL_RPC: "https://rpc.rss3.io", - DEGEN_RPC: "https://rpc.degen.tips", - DEGEN_RPC_MULTICALL: "0xFBF562a98aB8584178efDcFd09755FF9A1e7E3a2", } const ENV_KEYS = [ diff --git a/projects/helper/formatAddressChecksum.js b/projects/helper/formatAddressChecksum.js deleted file mode 100644 index bb7700b05cc1..000000000000 --- a/projects/helper/formatAddressChecksum.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @dev This function will format an address string according to the avilability of EIP-1191 on the network. - * This EIP determines the way the address checksum is being calculated. - * For example, on RSK (which implemented EIP-1191) any js/ts call to the blockchain for getting/connecting to a contract - * will have to be done with a low case address, while on a non EIP-1191 netwrok it has to remain mix-case. - * For more information please read: https://developers.rsk.co/rsk/architecture/account-based/ - */ -function formatAddressChecksum(address, netwrokName) { - // Add here more EIP-1191 networks as needed - return ["rsk"].includes(netwrokName?.toLowerCase()) - ? address.toLowerCase() - : address; -} - -module.exports = { - formatAddressChecksum, -}; diff --git a/projects/helper/getChainList.js b/projects/helper/getChainList.js index badd8772e42e..3c40a4f96892 100644 --- a/projects/helper/getChainList.js +++ b/projects/helper/getChainList.js @@ -1,6 +1,6 @@ const fs = require('fs') const path = require('path') - +/* const projectsFolder = path.join(__dirname, '..') const files = fs.readdirSync(projectsFolder, { withFileTypes: true }) @@ -92,4 +92,9 @@ function checkFileExistsSync(filepath) { flag = false; } return flag; -} \ No newline at end of file +} + */ + +const chainNames = require('./chains.json') +chainNames.sort() +fs.writeFileSync(path.join(__dirname, './chains.json'), JSON.stringify(chainNames, null, 2)) \ No newline at end of file diff --git a/projects/helper/iziswap.js b/projects/helper/iziswap.js index de64489a87f5..0d58283654b3 100644 --- a/projects/helper/iziswap.js +++ b/projects/helper/iziswap.js @@ -1,27 +1,25 @@ const { sumTokens2 } = require("./unwrapLPs") +const { getCache, setCache, } = require('../helper/cache') const ADDRESSES = require('../helper/coreAssets.json') -function iziswapExport({ poolHelpers, blacklistedTokens = []}) { +function iziswapExport({ poolHelpers, blacklistedTokens = [] }) { return async (api) => { - const toa = [] - const chunkSize = 10 - const allPools = [] - const allPoolMetas = [] - - for(const manager of poolHelpers) { - let i = 1 + const isMerlin = api.chain === 'merlin' + const toa = [] + const chunkSize = isMerlin ? 3 : 10 + + for (const manager of poolHelpers) { let foundLastPool = false const poolMetaData = [] + const key = `${api.chain}-${manager}` + const { allPools = [], allPoolMetas = [], } = (await getCache('iziswap', key) ?? {}) + let i = allPools.length + 1 do { const calls = [] for (let j = i; j < i + chunkSize; j++) calls.push(j) i += chunkSize - const poolMetas = await api.multiCall({ - target: manager, - abi: abi.poolMetas, - calls, - }) + const poolMetas = await api.multiCall({ target: manager, abi: abi.poolMetas, calls, }) for (const output of poolMetas) { if (output.tokenX === ADDRESSES.null && output.fee === '0') { foundLastPool = true @@ -30,21 +28,17 @@ function iziswapExport({ poolHelpers, blacklistedTokens = []}) { poolMetaData.push(output) } } while (!foundLastPool) - + const poolCalls = poolMetaData.map(i => ({ params: [i.tokenX, i.tokenY, i.fee] })) - const pools = await api.multiCall({ - target: manager, - abi: abi.pool, - calls: poolCalls, - }) - + const pools = await api.multiCall({ target: manager, abi: abi.pool, calls: poolCalls, }) + allPools.push(...pools) - allPoolMetas.push(...poolMetaData) + allPoolMetas.push(...poolMetaData.map(i => ({ tokenX: i.tokenX, tokenY: i.tokenY }))) + allPools.forEach((output, i) => toa.push([allPoolMetas[i].tokenX, output], [allPoolMetas[i].tokenY, output],)) + await setCache('iziswap', key, { allPools, allPoolMetas, }) } - - allPools.forEach((output, i) => toa.push([allPoolMetas[i].tokenX, output], [allPoolMetas[i].tokenY, output],)) - return sumTokens2({ tokensAndOwners: toa, api, blacklistedTokens, permitFailure: true}) + return sumTokens2({ tokensAndOwners: toa, api, blacklistedTokens, permitFailure: !isMerlin, sumChunkSize: isMerlin ? 1 : 100,}) } } diff --git a/projects/helper/tokenMapping.js b/projects/helper/tokenMapping.js index 44208c87df1b..2c49645bd71a 100644 --- a/projects/helper/tokenMapping.js +++ b/projects/helper/tokenMapping.js @@ -34,6 +34,20 @@ const ibcMappings = { } const fixBalancesTokens = { + ethereum: { + '0x4d831e22f062b5327dfdb15f0b6a5df20e2e3dd0': { coingeckoId: 'stakestone-ether', decimals: 18 }, + }, + islm: { + '0xeC8CC083787c6e5218D86f9FF5f28d4cC377Ac54': { coingeckoId: 'islamic-coin', decimals: 18 }, + '0xc5e00d3b04563950941f7137b5afa3a534f0d6d6': { coingeckoId: 'dai', decimals: 18 }, + '0xeceeefcee421d8062ef8d6b4d814efe4dc898265': { coingeckoId: 'ethereum', decimals: 18 }, + '0x5fd55a1b9fc24967c4db09c513c3ba0dfa7ff687': { coingeckoId: 'wrapped-bitcoin', decimals: 8 }, + '0xd567b3d7b8fe3c79a1ad8da978812cfc4fa05e75': { coingeckoId: 'tether', decimals: 6 }, + '0x80b5a32e4f032b2a058b4f29ec95eefeeb87adcd': { coingeckoId: 'axlusdc', decimals: 6 }, + }, + svm: { + '0x5db252ead05C54B08A83414adCAbF46Eaa9E0337': { coingeckoId: 'bitcoin', decimals: 18 }, + }, // Sample Code ozone: { // '0x83048f0bf34feed8ced419455a4320a735a92e9d': { coingeckoId: "ozonechain", decimals: 18 }, // was mapped to wrong chain diff --git a/projects/heroblaze/index.js b/projects/heroblaze/index.js new file mode 100644 index 000000000000..9907b57864a1 --- /dev/null +++ b/projects/heroblaze/index.js @@ -0,0 +1,20 @@ +const { staking } = require("../helper/staking"); + +module.exports = { + methodology: + "TVL staking is calculated as the sum of the tokens staked in Hero Blaze BEP20 contracts", + misrepresentedTokens: true, + bsc: { + tvl: () => ({}), + staking: staking( + [ + "0x7f385F3d92501ba048B92F715D929Cbf15F98792", + "0xaA0856084Ea21541526307945231338adc809519", + "0x159eeaE61a592A157964f36e68407ED49a4AEf3c", + "0xeB700b4090e1eD4C9d34386f73b4E706C8fe334D", + "0x00A6e93E3ce5300e41E8ed25EBD69C328fD45E5a", + ], + "0x5e7f472B9481C80101b22D0bA4ef4253Aa61daBc" + ), + }, +}; diff --git a/projects/intentx.js b/projects/intentx.js index d31389bd6e07..79114c73f2c4 100644 --- a/projects/intentx.js +++ b/projects/intentx.js @@ -52,4 +52,4 @@ module.exports = { }, hallmarks: [[1700006400, "Open Beta Start"], [1704200400, "0.8.2 Migration"]], -}; \ No newline at end of file +}; diff --git a/projects/interport-finance/index.js b/projects/interport-finance/index.js index 975e2ea14d72..60e791a3b7e2 100644 --- a/projects/interport-finance/index.js +++ b/projects/interport-finance/index.js @@ -3,19 +3,21 @@ const { staking } = require('../helper/staking'); const usdtVault = '0xEc8DDCb498b44C35EFaD7e5e43E0Caf6D16A66E8'; const usdcVault = '0x5b45B414c6CD2a3341bE70Ba22BE786b0124003F'; +const usdbVault = '0x5b45B414c6CD2a3341bE70Ba22BE786b0124003F'; const defaultVaults = [usdtVault, usdcVault]; const config = { era: { vaults: ['0xc724832c5ed81599aE3E4EBC0eC4f87A285B5838'] }, base: { vaults: [usdcVault] }, op_bnb: { vaults: [usdtVault] }, fantom: { vaults: ['0xd0Adc0cdE959616666c4691985df91C60ca3C0F7', '0xb6AB8EeFAE1a2c22Ca6338E143cb7dE544800c6e'] }, + blast: { vaults: [usdbVault] }, } module.exports = { methodology: 'Interport TVL is calculated by summing the USDT and USDC balance of the vaults contracts, ITP token balance in the ITP Revenue Share contract and LP token balance in the LP Revenue Share contract.', }; -['ethereum', 'avax', 'bsc', 'fantom', 'arbitrum', 'polygon', 'polygon_zkevm', 'base', 'era', 'optimism', 'linea', 'eon', 'op_bnb', 'scroll', 'manta', 'inevm'].forEach(chain => { +['ethereum', 'avax', 'bsc', 'fantom', 'arbitrum', 'polygon', 'polygon_zkevm', 'base', 'era', 'optimism', 'linea', 'eon', 'op_bnb', 'scroll', 'manta', 'inevm', 'blast'].forEach(chain => { module.exports[chain] = { tvl: async (api) => { const vaults = config[chain]?.vaults || defaultVaults diff --git a/projects/iskra/index.js b/projects/iskra/index.js new file mode 100644 index 000000000000..072b4ce1ed99 --- /dev/null +++ b/projects/iskra/index.js @@ -0,0 +1,11 @@ +const { staking } = require("../helper/staking"); + +module.exports = { + klaytn: { + tvl: () => ({}), + staking: staking( + "0xb30d86d84f5b2df67ef962be0c6cf4c39901d416", + "0x17d2628d30f8e9e966c9ba831c9b9b01ea8ea75c" + ), + }, +}; diff --git a/projects/ithaca/index.js b/projects/ithaca/index.js new file mode 100644 index 000000000000..4f6229cbf4b4 --- /dev/null +++ b/projects/ithaca/index.js @@ -0,0 +1,19 @@ +const ADDRESSES = require('../helper/coreAssets.json') +const { sumTokensExport } = require("../helper/unwrapLPs"); + +const ITHACA_FUNDLOCK_CONTRACT = '0x4a20d341315b8ead4e5ebecc65d95080a47a7316'; +const WETH_CONTRACT = ADDRESSES.arbitrum.WETH; +const USDC_CONTRACT = ADDRESSES.arbitrum.USDC_CIRCLE; + +module.exports = { + timetravel: true, + misrepresentedTokens: false, + methodology: 'counts the number of WETH and USDC in Ithaca Fundlock contract', + start: 176036233, + arbitrum: { + tvl: sumTokensExport({ + owner: ITHACA_FUNDLOCK_CONTRACT, + tokens: [ WETH_CONTRACT, USDC_CONTRACT ], + }), + } +}; \ No newline at end of file diff --git a/projects/jetprotocol.js b/projects/jetprotocol.js index cc04fc43e141..4e31993ea1f6 100644 --- a/projects/jetprotocol.js +++ b/projects/jetprotocol.js @@ -47,4 +47,7 @@ module.exports = { }, methodology: "TVL consists of deposits made to the protocol and like other lending protocols, borrowed tokens are not counted. Coingecko is used to price tokens.", + hallmarks: [ + [Math.floor(new Date('2023-12-12')/1e3), 'Jet Protocol Holdings, LLC is shutting down'], // https://forum.jetprotocol.io/t/community-update-jet-protocol-holdings-llc-is-shutting-down/1560/21 + ], }; diff --git a/projects/kriya-dex-earn/index.js b/projects/kriya-dex-earn/index.js new file mode 100644 index 000000000000..f96382b54907 --- /dev/null +++ b/projects/kriya-dex-earn/index.js @@ -0,0 +1,26 @@ +const { fetchURL } = require("../helper/utils"); +const sui = require("../helper/chain/sui"); + +const vaultUrl = + "https://88ob93rfva.execute-api.ap-southeast-1.amazonaws.com/release/vaults"; + +async function vaultTVL(api) { + const vaults = (await fetchURL(vaultUrl))?.data; + for (const vault of vaults) { + const tokenX = Number(vault?.coinA); + const tokenY = Number(vault?.coinB); + + api.add(vault?.pool?.tokenXType, tokenX); + api.add(vault?.pool?.tokenYType, tokenY); + } +} + +module.exports = { + timetravel: true, + misrepresentedTokens: false, + methodology: + "Collets all the TVL from the KriyaDEX vaults. The TVL is denominated in USD.", + sui: { + tvl: vaultTVL, + }, +}; diff --git a/projects/lachainBridge.js b/projects/lachainBridge.js index 950a84c1a5d6..bbfe3461eece 100644 --- a/projects/lachainBridge.js +++ b/projects/lachainBridge.js @@ -1,7 +1,4 @@ const ADDRESSES = require('./helper/coreAssets.json') -const sdk = require("@defillama/sdk"); -const { sumTokens } = require('./helper/unwrapLPs') -const { getChainTransform } = require('./helper/portedTokens') const config = { polygon: { @@ -30,20 +27,13 @@ const config = { }, } -module.exports = {}; - -const nullAddress = ADDRESSES.null - Object.keys(config).forEach(chain => { const { nativeBridge, tokenBridge, tokens} = config[chain] + tokens.push(ADDRESSES.null) + const owners = nativeBridge.concat(tokenBridge) module.exports[chain] = { - tvl: async (_, _block, { [chain]: block}) => { - const balances = {} - const transform = await getChainTransform(chain) - const {output: balance} = await sdk.api.eth.getBalance({ target: nativeBridge[0], block, chain }) - sdk.util.sumSingleBalance(balances, transform(nullAddress), balance) - const toa = tokenBridge.map(o => tokens.map(t => [t,o])).flat() - return sumTokens(balances, toa, block, chain, transform) + tvl: async (api) => { + return api.sumTokens({ owners, tokens }) } } }) diff --git a/projects/lava/index.js b/projects/lava/index.js index 9c4e048426bb..f893c0705617 100644 --- a/projects/lava/index.js +++ b/projects/lava/index.js @@ -1,7 +1,7 @@ const methodologies = require("../helper/methodologies"); const DATA_PROVIDER_ADDRESS = { - arbitrum: "0x8CfA3a5105e87e6e5568b80F64d05eD5fc53F0a9", + arbitrum: "0x8Cb093763cD2EB1e418eaEFfFC4f20c1665304a2", base: "0x22d6Ab83EEe06B7EE815420a7F2e737D64E534ef", }; const getAllReservesTokensABI = @@ -93,8 +93,6 @@ module.exports = { base: getMetrics(), hallmarks: [ [Math.floor(new Date('2024-03-28')/1e3), 'Protocol was exploited'], + [Math.floor(new Date("2024-04-01") / 1e3), "Protocol was relaunched"], ], }; - -module.exports.arbitrum.borrowed = () => ({}) - diff --git a/projects/llamalend-curve/index.js b/projects/llamalend-curve/index.js index eca60f0a275d..f9790d294b95 100644 --- a/projects/llamalend-curve/index.js +++ b/projects/llamalend-curve/index.js @@ -1,16 +1,22 @@ +const chainContracts = { + ethereum: "0xeA6876DDE9e3467564acBeE1Ed5bac88783205E0", + arbitrum: "0xcaec110c784c9df37240a8ce096d352a75922dea" +} + const uniq = (arr) => Array.from(new Set(arr)) -module.exports={ - ethereum:{ +module.exports=Object.keys(chainContracts).reduce((all, chain)=> ({ + ...all, + [chain]:{ tvl: async (_t, _b, _c, {api})=>{ - const markets = await api.fetchList({ lengthAbi: 'market_count', itemAbi: 'controllers', target: "0xeA6876DDE9e3467564acBeE1Ed5bac88783205E0" }) + const markets = await api.fetchList({ lengthAbi: 'market_count', itemAbi: 'controllers', target: chainContracts[chain] }) const amms = await api.multiCall({ abi: 'address:amm', calls: markets }) const collat = await api.multiCall({ abi: 'address:collateral_token', calls: markets }) const borrowTokens = await api.multiCall({ abi: 'address:borrowed_token', calls: markets }) return api.sumTokens({ tokens: uniq(collat.concat(borrowTokens)), owners: uniq(amms.concat(markets)) }) }, borrowed: async (_t, _b, _c, {api})=>{ - const markets = await api.fetchList({ lengthAbi: 'market_count', itemAbi: 'controllers', target: "0xeA6876DDE9e3467564acBeE1Ed5bac88783205E0" }) + const markets = await api.fetchList({ lengthAbi: 'market_count', itemAbi: 'controllers', target: chainContracts[chain] }) const debt = await api.multiCall({ abi: 'uint:total_debt', calls: markets }) const borrowTokens = await api.multiCall({ abi: 'address:borrowed_token', calls: markets }) debt.forEach((d, i)=>{ @@ -19,4 +25,4 @@ module.exports={ return api.getBalances() } } -} \ No newline at end of file +}), {}) \ No newline at end of file diff --git a/projects/merchant-moe-lb/index.js b/projects/merchant-moe-lb/index.js new file mode 100644 index 000000000000..f86f584aba12 --- /dev/null +++ b/projects/merchant-moe-lb/index.js @@ -0,0 +1,34 @@ +const { sumTokens2 } = require('../helper/unwrapLPs') + +const factories = { + mantle: '0xa6630671775c4EA2743840F9A5016dCf2A104054', +} +async function tvl(api) { + const pools = await api.fetchList({ + target: factories[api.chain], + itemAbi: 'function getLBPairAtIndex(uint256) view returns (address)', + lengthAbi: 'uint256:getNumberOfLBPairs', + }) + const tokenA = await api.multiCall({ + abi: 'address:getTokenX', + calls: pools, + }) + const tokenB = await api.multiCall({ + abi: 'address:getTokenY', + calls: pools, + }) + const toa = [] + tokenA.map((_, i) => { + toa.push([tokenA[i], pools[i]]) + toa.push([tokenB[i], pools[i]]) + }) + return sumTokens2({ api, tokensAndOwners: toa, }) +} + +module.exports = { + methodology: 'We count the token balances in in different liquidity book contracts', +} + +Object.keys(factories).forEach(chain => { + module.exports[chain] = { tvl } +}) \ No newline at end of file diff --git a/projects/methlab-xyz/index.js b/projects/methlab-xyz/index.js index 44dce3eac3ba..4867d111643b 100644 --- a/projects/methlab-xyz/index.js +++ b/projects/methlab-xyz/index.js @@ -47,6 +47,6 @@ const abi = { module.exports = mergeExports([ module.exports, uniV3Export({ - mantle: { factory: "0x8f140Fc3e9211b8DC2fC1D7eE3292F6817C5dD5D", fromBlock: 59915640, blacklistedTokens: ['0x26a6b0dcdcfb981362afa56d581e4a7dba3be140'] }, + mantle: { factory: "0x8f140Fc3e9211b8DC2fC1D7eE3292F6817C5dD5D", fromBlock: 59915640 }, }) ]) \ No newline at end of file diff --git a/projects/mint-club-v2/index.js b/projects/mint-club-v2/index.js index be8d63e02235..c3f7252f2e09 100644 --- a/projects/mint-club-v2/index.js +++ b/projects/mint-club-v2/index.js @@ -8,13 +8,14 @@ module.exports = { const V2_BOND_CONTRACTS = { avax: "0x3Fd5B4DcDa968C8e22898523f5343177F94ccfd1", blast: "0x621c335b4BD8f2165E120DC70d3AfcAfc6628681", + degen: "0x3bc6B601196752497a68B2625DB4f2205C3b150b", } const ownTokens = { bsc: ['0x1f3Af095CDa17d63cad238358837321e95FC5915'] } -const chains = ['avax', 'ethereum', 'optimism', 'arbitrum', 'polygon', 'bsc', 'base', 'blast'] +const chains = ['avax', 'ethereum', 'optimism', 'arbitrum', 'polygon', 'bsc', 'base', 'blast', 'degen'] chains.forEach(chain => { const BOND_CONTRACT = V2_BOND_CONTRACTS[chain] ?? '0xc5a076cad94176c2996B32d8466Be1cE757FAa27' diff --git a/projects/moneyonchain.js b/projects/moneyonchain.js index 3040d12c4daa..ec4fe9dcb21d 100644 --- a/projects/moneyonchain.js +++ b/projects/moneyonchain.js @@ -9,24 +9,15 @@ // Various API endpoints: https://api.moneyonchain.com/api/report/ // stats from https://moneyonchain.com/stats/ -const sdk = require('@defillama/sdk') +const ADDRESSES = require('./helper/coreAssets.json') -async function tvl(_, _b, { rsk: block }) { +async function tvl(api) { const docCollateral = '0xf773b590af754d597770937fa8ea7abdf2668370' - const { output } = await sdk.api.eth.getBalances({ - targets: [docCollateral], - chain: 'rsk', block, - }); - let total = 0 - output.forEach(i => total += i.balance/1e18) - return { - 'rootstock': total - } + return api.sumTokens({ owner: docCollateral, tokens: [ADDRESSES.null]}) } module.exports = { methodology: `TVL accounts for Total rBTC in the system`, - timetravel: false, rsk: { tvl, } diff --git a/projects/mute/index.js b/projects/mute/index.js index b6166f0e415f..110a1a2b27d4 100644 --- a/projects/mute/index.js +++ b/projects/mute/index.js @@ -1,9 +1,6 @@ const { staking } = require('../helper/staking'); const { getUniTVL } = require('../helper/unknownTokens'); -const dMUTE_staking_contract = "0x4336e06Be4F62bD757c4248c48D4C0b32615A2Df" -const MUTE = "0x0e97C7a0F8B2C9885C8ac9fC6136e829CbC21d42" - const KOI = "0xa995ad25ce5eb76972ab356168f5e1d9257e4d05" const veKOI = "0x98dB4e3Df6502369dAD7AC99f3aEE5D064721C4C" @@ -11,7 +8,7 @@ module.exports = { misrepresentedTokens: true, era: { tvl: getUniTVL({ factory: '0x40be1cba6c5b47cdf9da7f963b6f761f4c60627d', useDefaultCoreAssets: true, hasStablePools: true, stablePoolSymbol: 'sMLP' }), - staking: staking([dMUTE_staking_contract, veKOI], [MUTE, KOI], ) + staking: staking([veKOI], [KOI], ) }, methodology: "Counts liquidity in pools and KOI token in the veKOI contract", }; diff --git a/projects/nftperp/index.js b/projects/nftperp/index.js index cccf4948fbe2..78cac076fafb 100644 --- a/projects/nftperp/index.js +++ b/projects/nftperp/index.js @@ -1,18 +1,25 @@ -const ADDRESSES = require('../helper/coreAssets.json'); -const { sumTokensExport } = require('../helper/sumTokens'); +const ADDRESSES = require("../helper/coreAssets.json") +const { sumTokensExport } = require("../helper/sumTokens") module.exports = { - arbitrum: { - tvl: sumTokensExport({ - tokensAndOwners: [ - // DEX - [ADDRESSES.arbitrum.WETH, '0x6fc05B7DFe545cd488E9D47d56CFaCA88F69A2e1'], - // Insurance fund - [ADDRESSES.arbitrum.WETH, '0x035E4480437002A30b61Df6788DFb6199c2C5210'], - ] - }) - }, - hallmarks: [ - [1688695200, "v1 shutdown"], - ], -}; + arbitrum: { + tvl: sumTokensExport({ + tokensAndOwners: [ + // DEX + [ADDRESSES.arbitrum.WETH, "0x9e8B6D29C0410B8c7E67bB151CA7C0f9F6cBa8bF"], + // Insurance fund + [ADDRESSES.arbitrum.WETH, "0x087E8C29d0743120A9b9d003F702FB7F450291ba"], + ], + }), + }, + blast: { + tvl: sumTokensExport({ + tokensAndOwners: [ + // DEX + [ADDRESSES.blast.WETH, "0xFfc0555EC5F5C44A6B529Cef94b9055799696272"], + // Insurance fund + [ADDRESSES.blast.WETH, "0xe2F4A2845D4183F7913EC66945b20E4c0c15DAFf"], + ], + }), + }, +} diff --git a/projects/nostra-staked-strk/index.js b/projects/nostra-staked-strk/index.js index 1a67e82ee759..bc704f61c0db 100644 --- a/projects/nostra-staked-strk/index.js +++ b/projects/nostra-staked-strk/index.js @@ -3,7 +3,7 @@ const { call } = require("../helper/chain/starknet"); const { stakedStrkAbi } = require("./abi"); const STAKED_STRK = - "0x04619e9ce4109590219c5263787050726be63382148538f3f936c22aa87d2fc2"; + ADDRESSES.starknet.NSTSTRK; const STRK = ADDRESSES.starknet.STRK; diff --git a/projects/pendle/v2.js b/projects/pendle/v2.js index e08f456273b0..c14c8069ae8d 100644 --- a/projects/pendle/v2.js +++ b/projects/pendle/v2.js @@ -3,6 +3,8 @@ const contracts = require("./contracts"); const { staking } = require("../helper/staking"); const { getLogs } = require("../helper/cache/getLogs"); const bridgedAssets = [ADDRESSES.ethereum.STETH, ADDRESSES.ethereum.EETH]; +const { getConfig } = require('../helper/cache') + const config = { ethereum: { factory: "0x27b1dacd74688af24a64bd3c9c1b143118740784", @@ -14,7 +16,7 @@ const config = { factory: "0xf5a7de2d276dbda3eef1b62a9e718eff4d29ddc8", factoryV3: "0x2FCb47B58350cD377f94d3821e7373Df60bD9Ced", fromBlock: 62979673, - fromBlockV3: 154873897 + fromBlockV3: 154873897 }, bsc: { factory: "0x2bEa6BfD8fbFF45aA2a893EB3B6d85D10EFcC70E", @@ -33,6 +35,10 @@ const config = { fromBlock: 108061448, fromBlockV3: 112783590, }, + mantle: { + factoryV3: "0xD228EC1f7D4313fe321fab511A872475D07F5bA6", + fromBlockV3: 61484384, + }, }; module.exports = {}; @@ -41,29 +47,33 @@ Object.keys(config).forEach((chain) => { const { factory, factoryV3, fromBlock, pts, fromBlockV3 } = config[chain]; module.exports[chain] = { tvl: async (api) => { - const logs = await getLogs({ - api, - target: factory, - topics: [ - "0x166ae5f55615b65bbd9a2496e98d4e4d78ca15bd6127c0fe2dc27b76f6c03143", - ], - eventAbi: - "event CreateNewMarket (address indexed market, address indexed PT, int256 scalarRoot, int256 initialAnchor)", - onlyArgs: true, - fromBlock, - }); + const logs = factory + ? await getLogs({ + api, + target: factory, + topics: [ + "0x166ae5f55615b65bbd9a2496e98d4e4d78ca15bd6127c0fe2dc27b76f6c03143", + ], + eventAbi: + "event CreateNewMarket (address indexed market, address indexed PT, int256 scalarRoot, int256 initialAnchor)", + onlyArgs: true, + fromBlock, + }) + : []; - const logsV3 = await getLogs({ - api, - target: factoryV3, - topic: [ - "0xae811fae25e2770b6bd1dcb1475657e8c3a976f91d1ebf081271db08eef920af", - ], - eventAbi: - "event CreateNewMarket (address indexed market, address indexed PT, int256 scalarRoot, int256 initialAnchor, uint256 lnFeeRateRoot)", - onlyArgs: true, - fromBlock: fromBlockV3, - }); + const logsV3 = factoryV3 + ? await getLogs({ + api, + target: factoryV3, + topic: [ + "0xae811fae25e2770b6bd1dcb1475657e8c3a976f91d1ebf081271db08eef920af", + ], + eventAbi: + "event CreateNewMarket (address indexed market, address indexed PT, int256 scalarRoot, int256 initialAnchor, uint256 lnFeeRateRoot)", + onlyArgs: true, + fromBlock: fromBlockV3, + }) + : []; const pt = logs.map((i) => i.PT).concat(logsV3.map((i) => i.PT)); if (pts) pt.push(...pts); @@ -78,6 +88,7 @@ Object.keys(config).forEach((chain) => { ), ]; + sy = await filterWhitelistedSY(api, sy); const [data, supply, decimals] = await Promise.all([ api.multiCall({ abi: "function assetInfo() view returns (uint8 assetType , address uAsset , uint8 decimals )", @@ -103,7 +114,7 @@ Object.keys(config).forEach((chain) => { }); let balances = api.getBalances(); - for(let bridgingToken of bridgedAssets){ + for (let bridgingToken of bridgedAssets) { const bridged = `${chain}:${bridgingToken}`; if (bridged in balances) { balances[bridgingToken] = balances[bridged]; @@ -115,6 +126,13 @@ Object.keys(config).forEach((chain) => { }; }); +// Prevent SY with malicious accounting from being included in TVL +async function filterWhitelistedSY(api, sys) { + const { results } = await getConfig('pendle/v2-'+api.chain, `https://api-v2.pendle.finance/core/v1/${api.chainId}/sys/whitelisted`); + const whitelistedSys = new Set(results.map((d) => d.address.toLowerCase())); + return sys.filter((s) => whitelistedSys.has(s)); +} + module.exports.ethereum.staking = staking( contracts.v2.vePENDLE, contracts.v2.PENDLE diff --git a/projects/pluto/index.js b/projects/pluto/index.js index c35c72c81d16..44407b6cd15c 100644 --- a/projects/pluto/index.js +++ b/projects/pluto/index.js @@ -1,2 +1,9 @@ -const { wavesExport } = require('../helper/chain/wavesAdapter') -module.exports = wavesExport("/pluto", item => item.totalLocked) \ No newline at end of file +const { sumTokens, } = require('../helper/chain/waves') + +// https://wavesexplorer.com/addresses/3P3a1jssxc2CGdyC7SGbTJc9ZvTjZ5jBMLZ +module.exports = { + timetravel: false, + waves: { + tvl: () => ({}), + } +} \ No newline at end of file diff --git a/projects/prisma/index.js b/projects/prisma/index.js index 0c7b4b4908a5..a2ca1c11690f 100644 --- a/projects/prisma/index.js +++ b/projects/prisma/index.js @@ -5,7 +5,8 @@ const config = { } module.exports.hallmarks = [ - [1698883200,"PRISMA token launch"] + [1698883200,"PRISMA token launch"], + [1711669800,"Prisma Exploit"] ], Object.keys(config).forEach(chain => { const { factory, fromBlock, } = config[chain] diff --git a/projects/puff-penthouse/index.js b/projects/puff-penthouse/index.js new file mode 100644 index 000000000000..ceae2c0c6d75 --- /dev/null +++ b/projects/puff-penthouse/index.js @@ -0,0 +1,13 @@ +const { sumTokensExport } = require('../helper/unwrapLPs') +const { staking } = require('../helper/staking') + +module.exports = { + mantle: { + staking: staking("0xBeCd6b3D8B06479c83533f0d7E6DF1b0e413AeEa", "0x26a6b0dcdCfb981362aFA56D581e4A7dBA3Be140"), + tvl: sumTokensExport({ + tokensAndOwners: [ + ["0xcDA86A272531e8640cD7F1a92c01839911B90bb0", "0x0CC41C11878254aF8E65ca61C03DD03735F2DC6d"] + ] + }), + }, +}; diff --git a/projects/puzzle-lend/index.js b/projects/puzzle-lend/index.js index 3afd009b4b16..11ece22dcc3b 100644 --- a/projects/puzzle-lend/index.js +++ b/projects/puzzle-lend/index.js @@ -1,3 +1,19 @@ -const { wavesExport } = require('../helper/chain/wavesAdapter') +const { sumTokens, dataSearch } = require('../helper/chain/waves') +const markets = ['3P4uA5etnZi4AmBabKinq2bMiWU8KcnHZdH', '3P8Df2b7ywHtLBHBe8PBVQYd3A5MdEEJAou', '3P4DK5VzDwL3vfc5ahUEhtoe5ByZNyacJ3X', '3PHpuQUPVUoR3AYzFeJzeWJfYLsLTmWssVH', '3PAd9Aqg3cQSzu26MFYWQYcjSXPVCJtuf5V'] -module.exports = wavesExport('/puzzlelend') \ No newline at end of file +module.exports = { + timetravel: false, + waves: { + tvl: api => sumTokens({ api, owners: markets, includeWaves: true, }), + borrowed, + } +} + +async function borrowed(api) { + for (const market of markets) { + const result = await dataSearch(market, "total_borrowed.*") + for (const { key, value } of result) { + api.add(key.replace('total_borrowed_', ''), value) + } + } +} \ No newline at end of file diff --git a/projects/puzzle.js b/projects/puzzle.js index b36cd4df5cb7..7f01ad3629d1 100644 --- a/projects/puzzle.js +++ b/projects/puzzle.js @@ -1,16 +1,35 @@ -const { toUSDTBalances } = require("./helper/balances"); -const { get } = require("./helper/http"); - -async function tvl() { - const pools = await get('https://puzzle-js-back.herokuapp.com/api/v1/pools') - const tvl = pools.reduce((acc, { statistics: { liquidity } = {} }) => acc + +(liquidity || 0), 0) - - return toUSDTBalances(tvl) -} +const { dataSearch } = require('./helper/chain/waves'); +const { getConfig } = require("./helper/cache"); +const { transformDexBalances, } = require("./helper/portedTokens"); module.exports = { timetravel: false, + misrepresentedTokens: true, waves: { tvl, } -}; +} + +async function tvl(api) { + const data = [] + const pools = await getConfig('puzzle-dex', 'https://puzzle-js-back.herokuapp.com/api/v1/pools') + for (const { contractAddress } of pools) { + const res = await dataSearch(contractAddress, "global_.*_balance") + let items = [] + res.forEach(({ key, value }) => { + const token = key.replace('global_', '').replace('_balance', '') + items.push({ token, value }) + }) + + if (res.length !== 2) + items.forEach(({ token, value }) => api.add(token, value)) + else + data.push({ + token0: items[0].token, + token1: items[1].token, + token0Bal: items[0].value, + token1Bal: items[1].value, + }) + } + return transformDexBalances({ api, data, }) +} \ No newline at end of file diff --git a/projects/realtoken-rmm-v3/index.js b/projects/realtoken-rmm-v3/index.js index eda380666e8a..2aed86eb2eee 100644 --- a/projects/realtoken-rmm-v3/index.js +++ b/projects/realtoken-rmm-v3/index.js @@ -1,6 +1,13 @@ -const { aaveExports, methodology } = require("../helper/aave"); +const { aaveExports } = require("../helper/aave"); +const methodologies = require("../helper/methodologies"); module.exports = { - methodology, - xdai: aaveExports('xdai', '0x11B45acC19656c6C52f93d8034912083AC7Dd756', undefined, ["0x11B45acC19656c6C52f93d8034912083AC7Dd756"],), + methodology: methodologies.lendingMarket, + xdai: aaveExports( + "xdai", + "0xC6c4b123e731819AC5f7F9E0fe3A118e9b1227Cd", + undefined, + ["0x11B45acC19656c6C52f93d8034912083AC7Dd756"], + { oracle: "0xb4AE809Ad7CEB7e5B579dEdD0De7c213aD5AB516" } + ), }; diff --git a/projects/reserve/index.js b/projects/reserve/index.js index 80ed41cfe714..04f20a8752ce 100644 --- a/projects/reserve/index.js +++ b/projects/reserve/index.js @@ -41,16 +41,16 @@ async function tvl(api) { // Common logic for calculating TVL (only mainnet has vault) const ownerTokens = config.vault ? [ + [ [ - [ - ADDRESSES.ethereum.USDC, //usdc - "0x8e870d67f660d95d5be530380d0ec0bd388289e1", //pax - ADDRESSES.ethereum.TUSD, //tusd - ADDRESSES.ethereum.BUSD, //busd - ], - config.vault, + ADDRESSES.ethereum.USDC, //usdc + "0x8e870d67f660d95d5be530380d0ec0bd388289e1", //pax + ADDRESSES.ethereum.TUSD, //tusd + ADDRESSES.ethereum.BUSD, //busd ], - ] + config.vault, + ], + ] : []; const blacklistedTokens = [config.rsr]; const fluxListWithOwner = []; @@ -85,26 +85,14 @@ async function tvl(api) { const allManagers = basketRes.flatMap(([tokens], i) => tokens.map(() => backingManagers[i]) ); - const allNames = await api.multiCall({ - abi: "string:name", - calls: allTokens, - }); - - const aTokenWrappers = allTokens.filter((_, i) => - allNames[i].startsWith("Static Aave") && (_.toLowerCase() !== '0x093cB4f405924a0C468b43209d5E466F1dd0aC7d'.toLowerCase() || chain !== 'ethereum') - ); - - const cUsdcV3Wrappers = allTokens.filter((_, i) => - allNames[i].startsWith("Wrapped cUSDCv3") - ); + const allNames = await api.multiCall({ abi: "string:name", calls: allTokens, }); - const morphoWrappers = allTokens.filter((_, i) => - allNames[i].startsWith("Tokenised Morpho") - ); - const stargateLpWrappers = allTokens.filter((_, i) => - allNames[i].startsWith("Wrapped Stargate") - ); + const aTokenWrappersV2 = allTokens.filter((_, i) => allNames[i].startsWith("Static Aave") && allNames[i].includes("interest")); + const aTokenWrappersV3 = allTokens.filter((_, i) => allNames[i].startsWith("Static Aave") && !allNames[i].includes("interest")); + const cUsdcV3Wrappers = allTokens.filter((_, i) => allNames[i].startsWith("Wrapped cUSDCv3")); + const morphoWrappers = allTokens.filter((_, i) => allNames[i].startsWith("Tokenised Morpho")); + const stargateLpWrappers = allTokens.filter((_, i) => allNames[i].startsWith("Wrapped Stargate")); const cTokenWrappers = allTokens.filter( (_, i) => /^Compound.*Vault$/.test(allNames[i]) // Starts with Compound, ends with Vault ); @@ -125,39 +113,24 @@ async function tvl(api) { convexTokensAndOwners.push([token, allManagers[i]]); }); - let cTokens = await api.multiCall({ - abi: "address:underlying", - calls: cTokenWrappers, - }); - - let aTokens = await api.multiCall({ - abi: api.chain === "base" ? "address:aToken" : "address:ATOKEN", - calls: aTokenWrappers, - }); - - let morphoUnderlyingTokens = await api.multiCall({ - abi: "address:asset", - calls: morphoWrappers, - }); - - let morphoUnderlyingBalances = await api.multiCall({ - abi: "uint256:totalAssets", - calls: morphoWrappers, - }); + let cTokens = await api.multiCall({ abi: "address:underlying", calls: cTokenWrappers, }); + let aTokensV2 = await api.multiCall({ abi: "address:ATOKEN", calls: aTokenWrappersV2, }); + let aTokensV3 = await api.multiCall({ abi: "address:aToken", calls: aTokenWrappersV3, }); + let morphoUnderlyingTokens = await api.multiCall({ abi: "address:asset", calls: morphoWrappers, }); + let morphoUnderlyingBalances = await api.multiCall({ abi: "uint256:totalAssets", calls: morphoWrappers, }); blacklistedTokens.push( - ...aTokenWrappers, + ...aTokenWrappersV2, + ...aTokenWrappersV3, ...stargateLpWrappers, ...cTokenWrappers, ...cUsdcV3Wrappers, ...morphoWrappers ); - if (chain === "ethereum") { - blacklistedTokens.push('0x093cB4f405924a0C468b43209d5E466F1dd0aC7d'); - ownerTokens.push([['0x98c23e9d8f34fefb1b7bd6a91b7ff122f4e16f5c'], '0x093cB4f405924a0C468b43209d5E466F1dd0aC7d']); - } + cTokens.forEach((v, i) => ownerTokens.push([[v], cTokenWrappers[i]])); - aTokens.forEach((v, i) => ownerTokens.push([[v], aTokenWrappers[i]])); + aTokensV2.forEach((v, i) => ownerTokens.push([[v], aTokenWrappersV2[i]])); + aTokensV3.forEach((v, i) => ownerTokens.push([[v], aTokenWrappersV3[i]])); morphoUnderlyingTokens.forEach((v, i) => api.add(v, morphoUnderlyingBalances[i]) ); diff --git a/projects/satoshi-protocol/index.js b/projects/satoshi-protocol/index.js new file mode 100644 index 000000000000..5dc4709f4106 --- /dev/null +++ b/projects/satoshi-protocol/index.js @@ -0,0 +1,12 @@ +const TROVE_MANAGER_BEACON_PROXY_ADDRESS = '0x0598Ef47508Ec11a503670Ac3B642AAE8EAEdEFA'; + +async function tvl(api) { + const token = await api.call({ abi: 'address:collateralToken', target: TROVE_MANAGER_BEACON_PROXY_ADDRESS}) + return api.sumTokens({ tokens: [token], owner: [TROVE_MANAGER_BEACON_PROXY_ADDRESS] }) +} + +module.exports = { + bevm: { + tvl, + } +} diff --git a/projects/savmswap/index.js b/projects/savmswap/index.js new file mode 100644 index 000000000000..af5911e947c1 --- /dev/null +++ b/projects/savmswap/index.js @@ -0,0 +1,3 @@ +const { uniTvlExport } = require('../helper/unknownTokens') + +module.exports = uniTvlExport('svm', '0x1842c9bD09bCba88b58776c7995A9A9bD220A925') \ No newline at end of file diff --git a/projects/shiftdollar/index.js b/projects/shiftdollar/index.js index 2d46a70db19b..149bf76342fb 100644 --- a/projects/shiftdollar/index.js +++ b/projects/shiftdollar/index.js @@ -16,6 +16,6 @@ const lps = [ const chain = 'cronos' module.exports = tombTvl(SHIFT, SFSHARE, rewardPool, boardroom, lps, chain, undefined, false, lps[0]) -module.exports[chain].tvl = async (_, _b, { [chain]: block}) => { - return sumTokens2({ chain, block, owner: factory, tokens: [USDC ]}) +module.exports[chain].tvl = async (api) => { + return sumTokens2({ api, owner: factory, tokens: [USDC ]}) } diff --git a/projects/sienna-lend/index.js b/projects/sienna-lend/index.js index 939d92585ffe..a791a7f3efcc 100644 --- a/projects/sienna-lend/index.js +++ b/projects/sienna-lend/index.js @@ -1,5 +1,6 @@ const { queryContract, } = require('../helper/chain/secret') -const { PromisePool } = require('@supercharge/promise-pool') +const { PromisePool } = require('@supercharge/promise-pool'); +const { sleep } = require('../helper/utils'); const LEND_OVERSEER_CONTRACT = "secret1pf88n9hm64mn58aw48jxfs2fsvzr07svnrrdlv"; @@ -30,7 +31,7 @@ async function getLendMarkets() { const data = [] - const { errors } = await PromisePool.withConcurrency(5) + const { errors } = await PromisePool.withConcurrency(3) .for(markets) .process(async (addr) => { @@ -40,6 +41,7 @@ async function getLendMarkets() { // const { token_info: { decimals }} = await queryContract({ contract: address, data: { token_info: {} } }) const scale = exchange_rate data.push({ address, total_borrows: total_borrows * scale, total_supply: total_supply * scale }) + await sleep(1000) }) if (errors && errors.length) diff --git a/projects/skeleton/index.js b/projects/skeleton/index.js index 5ed7340038fc..32427a5cafaa 100644 --- a/projects/skeleton/index.js +++ b/projects/skeleton/index.js @@ -1,43 +1,17 @@ -const ADDRESSES = require('../helper/coreAssets.json') -const sdk = require("@defillama/sdk"); const abi = require("./abi.json"); -const { getParamCalls } = require('../helper/utils') const masterChefContract = "0x4fff737de45da4886f711b2d683fb6A6cf62C60C"; -const USDC = ADDRESSES.fantom.USDC; -const chain = 'fantom' -const ftmTvl = async (_, _b, { fantom: block }) => { - const balances = {}; +const ftmTvl = async (api) => { + const poolData = await api.fetchList({ lengthAbi: abi.poolLength, itemAbi: abi.poolInfo, target: masterChefContract}) - const poolLength = ( - await sdk.api.abi.call({ - abi: abi.poolLength, - target: masterChefContract, - chain, block, - }) - ).output; - - const calls = getParamCalls(poolLength) - const { output: poolData } = await sdk.api.abi.multiCall({ - target: masterChefContract, - abi: abi.poolInfo, - calls, chain, block, - }) - const stratCalls = poolData.map(i => ({ target: i.output.strat })) - const { output: stratResponse } = await sdk.api.abi.multiCall({ - abi: abi.wantLockedTotal, - calls: stratCalls, - chain, block, - }) - stratResponse.forEach(({ output },i) => { - sdk.util.sumSingleBalance(balances, 'fantom:'+poolData[i].output.want, output) - }) - return balances + const strats = poolData.map(i => i.strat) + const want = poolData.map(i => i.want) + const bals = await api.multiCall({ abi: abi.wantLockedTotal, calls:strats }) + api.add(want, bals) }; module.exports = { - misrepresentedTokens: true, fantom: { tvl: ftmTvl, }, diff --git a/projects/solarbeam/index.js b/projects/solarbeam/index.js index 54c0b6b2f6cf..fd8bb980a4cf 100644 --- a/projects/solarbeam/index.js +++ b/projects/solarbeam/index.js @@ -1,166 +1,16 @@ +const { getLogs2 } = require('../helper/cache/getLogs') const ADDRESSES = require('../helper/coreAssets.json') const { getUniTVL } = require('../helper/unknownTokens') const sdk = require("@defillama/sdk"); -const BigNumber = require("bignumber.js"); -const wMOVR = "0x98878B06940aE243284CA214f92Bb71a2b032B8A" // their own barely used version - -const stableSwapPools = { - '3pool': { - name: '3pool', - address: '0x9785478135BaFe3dCafe4BBa4C8311674D4E826E', - assets: ['USDC', 'BUSD', 'USDT'], - lpToken: '3pool' - }, - 'frax-3pool': { - name: 'FRAX', - address: '0x4BB7177319BD1746c3082DDd41c7663E2dbF0f31', - assets: ['FRAX', '3pool'], - lpToken: 'frax-3pool', - basePool: '3pool', - basePoolIndex: 1 - }, - stksm: { - name: 'stKSM', - address: '0x77D4b212770A7cA26ee70b1E0f27fC36da191c53', - assets: ['xcKSM', 'stKSM'], - lpToken: 'stksm' - }, - 'kbtc-btc': { - name: ' BTC-kBTC', - address: '0xC5d0c8e241b59F989e37B5C35925C58F8c7F66A8', - assets: ['xcKBTC', 'WBTC'], - lpToken: 'kbtc-btc' - }, - 'mim-3pool': { - name: 'MIM', - address: '0x2a9Fe2514Ed1DaC1C1f5a6d7710C9F6599A27e98', - assets: ['MIM', '3pool'], - lpToken: 'mim-3pool', - basePool: '3pool', - basePoolIndex: 1 - }, - 'mai-3pool': { - name: 'MAI', - address: '0x358B4060849E9069482983DEc5E0db671c3337Ff', - assets: ['MAI', '3pool'], - lpToken: 'mai-3pool', - basePool: '3pool', - basePoolIndex: 1 - } -} - -const stableSwapTokens = { - USDC: { - address: ADDRESSES.moonriver.USDC, - decimals: 6, - symbol: 'USDC', - gecko: 'usd-coin' - }, - USDT: { - address: ADDRESSES.moonriver.USDT, - decimals: 6, - symbol: 'USDT', - gecko: 'tether' - }, - BUSD: { - address: '0x5D9ab5522c64E1F6ef5e3627ECCc093f56167818', - decimals: 18, - symbol: 'BUSD', - gecko: 'binance-usd' - }, - FRAX: { - symbol: 'FRAX', - name: 'FRAX', - address: '0x1A93B23281CC1CDE4C4741353F3064709A16197d', - decimals: 18, - gecko: 'frax' - }, - MIM: { - symbol: 'MIM', - name: 'Magic Internet Money', - address: '0x0caE51e1032e8461f4806e26332c030E34De3aDb', - decimals: 18, - gecko: 'magic-internet-money' - }, - MAI: { - symbol: 'MAI', - name: 'Mai Stablecoin', - address: '0xFb2019DfD635a03cfFF624D210AEe6AF2B00fC2C', - decimals: 18, - gecko: 'mimatic' - }, - xcKSM: { - symbol: 'xcKSM', - name: 'xcKSM', - address: '0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080', - decimals: 12, - gecko: 'kusama' - }, - stKSM: { - symbol: 'stKSM', - name: 'stKSM', - address: '0xFfc7780C34B450d917d557E728f033033CB4fA8C', - decimals: 12, - gecko: 'kusama' - }, - xcKBTC: { - symbol: 'xcKBTC', - name: 'Kintsugi Wrapped BTC', - address: '0xFFFfFfFfF6E528AD57184579beeE00c5d5e646F0', - decimals: 8, - gecko: 'bitcoin' - }, - WBTC: { - symbol: 'WBTC', - name: 'Wrapped BTC', - address: ADDRESSES.oasis.USDT, - decimals: 8, - gecko: 'bitcoin' - } -} - -async function stableDexTVL(timestamp, _block, chainBlocks) { - const block = chainBlocks.moonriver - let balances = {}; - let calls = []; - - for (const pool of Object.values(stableSwapPools)) { - for (const token of pool.assets) - if (stableSwapTokens[token]) { - calls.push({ - target: stableSwapTokens[token].address, - params: pool.address, - }); - } - } - - // Pool Balances - let balanceOfResults = await sdk.api.abi.multiCall({ - block, - calls: calls, - abi: "erc20:balanceOf", - chain: 'moonriver' - }); - - // Compute Balances - balanceOfResults.output.forEach((balanceOf) => { - let address = balanceOf.input.target; - let amount = balanceOf.output; - amount = BigNumber(amount).toFixed(); - balances[address] = BigNumber(balances[address] || 0) - .plus(amount) - .toFixed(); - }); - - - const finalBalances = {} - for (const tokenAddress in balances) { - const asset = Object.values(stableSwapTokens).find(r => r.address.toLowerCase() == tokenAddress.toLowerCase()); - sdk.util.sumSingleBalance(finalBalances, asset.gecko, (balances[tokenAddress]) / (10 ** asset.decimals)) - } - - return finalBalances; +async function stableDexTVL(api) { + const logs = await getLogs2({ + api, + factory: '0xa0a1EBf6bd49e455de2302a86584FD8A0eDD3344', + eventAbi: 'event NewSwapPool (address indexed deployer, address swapAddress, address[] pooledTokens)', + fromBlock: 1454692, + }) + return api.sumTokens({ ownerTokens: logs.map(i => [i.pooledTokens, i.swapAddress]) }) } const dexTVL = getUniTVL({ diff --git a/projects/solidlizard-lending/index.js b/projects/solidlizard-lending/index.js new file mode 100644 index 000000000000..dc5fd35a4c87 --- /dev/null +++ b/projects/solidlizard-lending/index.js @@ -0,0 +1,13 @@ +const { compoundExports2 } = require("../helper/compound"); +const { staking } = require("../helper/staking"); +const { pool2 } = require("../helper/pool2"); + +module.exports = { + methodology: + "Same as Compound Finance, we just count all the tokens supplied (not borrowed money) on the lending markets", + arbitrum: { + ...compoundExports2({ comptroller: '0x9FfBdfcc508e76ee2b719eF6218879E938eF056C'}), + staking: staking( "0x08153c4C19Cb438A3bdC6303aF962a30E9f5e0B1", "0xe6AF844d5740B6B297B6Dd7Fb2ce299Ee9E3d16F"), + pool2: pool2( "0x8082F587Ff2B24dadB2220026F4FCa9323Ed8080", "0xB70005C4980d78e8bE47D4C9ccCd7300D6a02501"), + }, +}; diff --git a/projects/solv-protocol-funds/index.js b/projects/solv-protocol-funds/index.js index 5d081436582a..df5f9b93a31a 100644 --- a/projects/solv-protocol-funds/index.js +++ b/projects/solv-protocol-funds/index.js @@ -8,10 +8,10 @@ const { getAmounts } = require("./iziswap") // The Graph const graphUrlList = { ethereum: 'https://api.studio.thegraph.com/query/40045/solv-payable-factory-prod/version/latest', - bsc: 'https://api.thegraph.com/subgraphs/name/slov-payable/solv-v3-earn-factory', + bsc: 'https://api.studio.thegraph.com/query/40045/solv-payable-factory-bsc/version/latest', arbitrum: 'https://api.studio.thegraph.com/query/40045/solv-payable-factory-arbitrum/version/latest', mantle: 'http://api.0xgraph.xyz/subgraphs/name/solv-payable-factory-mentle-0xgraph', - merlin: 'http://solv-subgraph-server-alb-694489734.us-west-1.elb.amazonaws.com:8000/subgraphs/name/solv-payable-factory-merlin/graphql', + merlin: 'http://solv-subgraph-server-alb-694489734.us-west-1.elb.amazonaws.com:8000/subgraphs/name/solv-payable-factory-merlin', } const slotListUrl = 'https://raw.githubusercontent.com/solv-finance-dev/solv-protocol-rwa-slot/main/slot.json'; @@ -36,14 +36,17 @@ async function borrowed(api) { let address = (await getConfig('solv-protocol/funds', addressUrl)); const depositAddress = filterDepositAddress(network, address); - + const graphData = await getGraphData(api.timestamp, network, api); if (graphData.pools.length > 0) { const poolLists = graphData.pools; - var pools = poolLists.filter((value) => { - return depositAddress.length == 0 || depositAddress.indexOf(value.vault) == -1; - }); + let pools = []; + for (const pool of poolLists) { + if (depositAddress.length == 0 && depositAddress.indexOf(pool.vault) == -1) { + pools.push(pool); + } + } const poolConcretes = await concrete(pools, api); const nav = await api.multiCall({ @@ -94,7 +97,6 @@ async function borrowed(api) { for (let i = 0; i < Object.keys(vaults).length; i++) { vaultbalances[Object.keys(vaults)[i]] = balances[i]; } - for (let i = 0; i < poolTotalValues.length; i++) { const decimals = poolDecimalList[i]; let balance = BigNumber(poolTotalValues[i]).div(BigNumber(10).pow(18 - decimals)).times(BigNumber(nav[i].nav_).div(BigNumber(10).pow(decimals))).toNumber(); diff --git a/projects/stafi/index.js b/projects/stafi/index.js index ffc88b3b76f8..8aba8f04f06b 100644 --- a/projects/stafi/index.js +++ b/projects/stafi/index.js @@ -7,14 +7,11 @@ const { fetchURL } = require('../helper/utils'); const wethAddress = ADDRESSES.ethereum.WETH -async function ethereum(timestamp, block) { - const supply = await sdk.api.erc20.totalSupply({ - target: '0x9559Aaa82d9649C7A7b220E7c461d2E74c9a3593', - block - }) - +async function ethereum(api) { + const totalSupply = await api.call({ target: '0x9559Aaa82d9649C7A7b220E7c461d2E74c9a3593', abi: 'uint256:totalSupply'}); + const rate = await api.call({ target: '0x9559Aaa82d9649C7A7b220E7c461d2E74c9a3593', abi: 'uint256:getExchangeRate'}); return { - [wethAddress]: supply.output + [wethAddress]: (totalSupply * rate)/1e18 } } diff --git a/projects/standard-smart-vaults/index.js b/projects/standard-smart-vaults/index.js index 062e42d626d3..b4386cde0295 100644 --- a/projects/standard-smart-vaults/index.js +++ b/projects/standard-smart-vaults/index.js @@ -9,6 +9,7 @@ const tokens = [ ADDRESSES.arbitrum.WBTC, ADDRESSES.arbitrum.ARB, ADDRESSES.arbitrum.LINK, + ADDRESSES.arbitrum.GMX, '0xfEb4DfC8C4Cf7Ed305bb08065D08eC6ee6728429' ] diff --git a/projects/starshares/index.js b/projects/starshares/index.js index 0bf32f223ee2..b6bfc6da42be 100644 --- a/projects/starshares/index.js +++ b/projects/starshares/index.js @@ -3,7 +3,10 @@ const { sumTokens2, nullAddress } = require('../helper/unwrapLPs') const contract = "0xC605C2cf66ee98eA925B1bb4FeA584b71C00cC4C" async function tvl(time, ethBlock, _b, {api}) { - return sumTokens2({ tokens: [nullAddress], owners: [contract, '0x563395A2a04a7aE0421d34d62ae67623cAF67D03', '0xa481b139a1a654ca19d2074f174f17d7534e8cec', '0x69B7F08B2952e2EE3CA4222190BCF07831f1096f'], api }) + await sumTokens2({ tokens: [nullAddress], owners: [contract, '0x563395A2a04a7aE0421d34d62ae67623cAF67D03', '0xa481b139a1a654ca19d2074f174f17d7534e8cec', '0x69B7F08B2952e2EE3CA4222190BCF07831f1096f'], api }) + if (Object.keys(api.getBalances()).length === 0) { + throw new Error("No tokens found") + } } module.exports = { diff --git a/projects/stfil/index.js b/projects/stfil/index.js index 3733f7218059..d2a1c4f88705 100644 --- a/projects/stfil/index.js +++ b/projects/stfil/index.js @@ -1,33 +1,17 @@ const ADDRESSES = require('../helper/coreAssets.json') -const {sumTokens2} = require('../helper/unwrapLPs'); const {get} = require('../helper/http'); +const BN = require("bn.js"); -const poolAddr = '0xC8E4EF1148D11F8C557f677eE3C73901CD796Bf6' // pool address -const tokens = [ - ADDRESSES.null, // FIL -] - -const getActiveMinersFromRPC = async () => { - const resp = await get('https://api.stfil.io/v1/node?delegate=1') - return resp.data.map(({node}) => { - let bytes = Buffer.alloc(20); - bytes.writeUint8(0xff, 0); - bytes.writeBigUint64BE(BigInt(node), 12); - return '0x' + bytes.toString('hex') - }); -} module.exports = { filecoin: { tvl: async (_, _1, _2, {api}) => { - let balances = {}; - await sumTokens2({balances, owner: poolAddr, tokens, api, }); - - let minerAddrs = await getActiveMinersFromRPC(); - await sumTokens2({balances, owners: minerAddrs, tokens, api, }); + const {data: {allMinerValue, poolStFilBalance}} = await get("https://api.stfil.io/v1/info"); + const allMinerValueBN = new BN(allMinerValue); + const poolStFilBalanceBN = new BN(poolStFilBalance); - return balances; + return api.add(ADDRESSES.null, allMinerValueBN.add(poolStFilBalanceBN)); } } } diff --git a/projects/superbots/index.js b/projects/superbots/index.js index a5dcb72c1ad7..09210ed463a6 100644 --- a/projects/superbots/index.js +++ b/projects/superbots/index.js @@ -1,6 +1,5 @@ const ADDRESSES = require('../helper/coreAssets.json') const { sumTokens2 } = require('../helper/unwrapLPs') -const { pool2 } = require('../helper/pool2') const { staking } = require('../helper/staking') const vault_tokens = [ @@ -33,17 +32,15 @@ const config = { } } -async function tvl(_, _b, { bsc: block }) { - return sumTokens2({ owners: vaults, tokens: vault_tokens, chain: 'bsc', block }) +async function tvl(api) { + return sumTokens2({ owners: vaults, tokens: vault_tokens, api }) } module.exports = { - timetravel: false, - misrepresentedTokens: true, bsc: { tvl, - staking: staking(config.bsc.stakingPool, config.bsc.ubxt, 'bsc'), - pool2: staking(config.bsc.stakingPool, config.bsc.ubxtLP, 'bsc'), + staking: staking(config.bsc.stakingPool, config.bsc.ubxt), + pool2: staking(config.bsc.stakingPool, config.bsc.ubxtLP), }, ethereum: { staking: staking(config.ethereum.stakingPool, config.ethereum.ubxt,), diff --git a/projects/sushiswap-v3/index.js b/projects/sushiswap-v3/index.js index e8a091c15794..3c4a95b4eb8a 100644 --- a/projects/sushiswap-v3/index.js +++ b/projects/sushiswap-v3/index.js @@ -1,5 +1,6 @@ const { uniV3Export } = require("../helper/uniswapV3"); -const { cachedGraphQuery } = require('../helper/cache') +const { cachedGraphQuery, getConfig, } = require('../helper/cache'); +const { sumTokens2 } = require("../helper/unwrapLPs"); const factory = "0xc35dadb65012ec5796536bd9864ed8773abc74c4" module.exports = uniV3Export({ @@ -72,6 +73,7 @@ module.exports = uniV3Export({ metis: { factory: '0x145d82bCa93cCa2AE057D1c6f26245d1b9522E6F', fromBlock: 9077930, }, bittorrent: { factory: '0xBBDe1d67297329148Fe1ED5e6B00114842728e65', fromBlock: 29265724, }, zeta: { factory: '0xB45e53277a7e0F1D35f2a77160e91e25507f1763', fromBlock: 1551069, }, + islm: { factory: '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', fromBlock: 6541826, }, }); const config = { @@ -96,3 +98,18 @@ Object.keys(config).forEach(chain => { } } }) + +const config1 = { + islm: { endpoint: 'https://evm-qwhwlq6ji.sushi.com/pool/api/pools?chainIds=11235&isWhitelisted=true&orderBy=liquidityUSD&orderDir=desc&protocols=SUSHISWAP_V3' }, +} + +Object.keys(config1).forEach(chain => { + const { endpoint } = config1[chain] + module.exports[chain] = { + tvl: async (api) => { + const pools = await getConfig('sushiswap-v3/' + chain, endpoint) + const ownerTokens = pools.map(i => [[i.token0.id.split(':')[1], i.token1.id.split(':')[1]], i.id.split(':')[1]]) + return sumTokens2({ api, ownerTokens }) + } + } +}) \ No newline at end of file diff --git a/projects/sushiswap/api.js b/projects/sushiswap/api.js index f0a132bd82ce..7dc40179f774 100644 --- a/projects/sushiswap/api.js +++ b/projects/sushiswap/api.js @@ -96,6 +96,8 @@ module.exports = { zeta: { tvl: getUniTVL({ factory: '0x33d91116e0370970444B0281AB117e161fEbFcdD', useDefaultCoreAssets: true, }), }, + blast: { tvl: getUniTVL({ factory: '0x42Fa929fc636e657AC568C0b5Cf38E203b67aC2b' })}, + core: { tvl: getUniTVL({ factory: '0xB45e53277a7e0F1D35f2a77160e91e25507f1763', useDefaultCoreAssets: true })}, } module.exports.polygon.tvl = getChainTVL('polygon') diff --git a/projects/swop/index.js b/projects/swop/index.js index c2d4edacf1b0..a70e7ddf3285 100644 --- a/projects/swop/index.js +++ b/projects/swop/index.js @@ -1,20 +1,19 @@ -// const { sumTokens, call } = require('../helper/chain/waves'); -// const { getConfig } = require("../helper/cache"); -const { get } = require("../helper/http"); -const { toUSDTBalances } = require("../helper/balances"); +const { sumTokens, call } = require('../helper/chain/waves'); +const { getConfig } = require("../helper/cache"); +// const { get } = require("../helper/http"); +// const { toUSDTBalances } = require("../helper/balances"); const swopfiBackendEndpoint = "https://backend.swop.fi"; -const getSwopFiTVL = async (_, _1, _2, { api }) => { - const poolsStats = await get(`${swopfiBackendEndpoint}/pools`); - return toUSDTBalances(poolsStats.overall.liquidity); - /* const { pools } = await getConfig('swop', `${swopfiBackendEndpoint}/pools`) - const owners = pools.map(i => i.id) - console.log(owners.length) +const getSwopFiTVL = async (api) => { + // const poolsStats = await get(`${swopfiBackendEndpoint}/pools`); + // return toUSDTBalances(poolsStats.overall.liquidity); + const { pools } = await getConfig('swop', `${swopfiBackendEndpoint}/pools`) + // const owners = pools.map(i => i.id) for (const pool of pools) { await sumTokens({ owners: [pool.id], api, includeWaves: true, blacklistedTokens: ['Ehie5xYpeN8op1Cctc6aGUrqx8jq3jtf1DSjXDbfm7aT'] }) - } */ + } } @@ -24,10 +23,10 @@ module.exports = { waves: { tvl: getSwopFiTVL, staking: async () => { - const stakingStats = await get(`${swopfiBackendEndpoint}/staking`); - return toUSDTBalances(stakingStats.swop.totalSwopUsdt); - /* const res = await call({target:'3PLHVWCqA9DJPDbadUofTohnCULLauiDWhS', key: 'total_GSwop_amount'}) - return { swop: res / 1e8 } */ + // const stakingStats = await get(`${swopfiBackendEndpoint}/staking`); + // return toUSDTBalances(stakingStats.swop.totalSwopUsdt); + const res = await call({ target: '3PLHVWCqA9DJPDbadUofTohnCULLauiDWhS', key: 'total_GSwop_amount' }) + return { swop: res / 1e8 } } } }; diff --git a/projects/terraswap/factoryTvl.js b/projects/terraswap/factoryTvl.js index b6e5a3121f6d..553e5ea64ab1 100644 --- a/projects/terraswap/factoryTvl.js +++ b/projects/terraswap/factoryTvl.js @@ -19,8 +19,9 @@ function getAssetInfo(asset) { async function getAllPairs(factory, chain) { let allPairs = [] let currentPairs; + const limit = factory === 'terra14x9fr055x5hvr48hzy2t4q7kvjvfttsvxusa4xsdcy702mnzsvuqprer8r' ? 29 : 30 // some weird native token issue at one of the pagination query do { - const queryStr = `{"pairs": { "limit": 30 ${allPairs.length ? `,"start_after":${JSON.stringify(allPairs[allPairs.length - 1].asset_infos)}` : ""} }}` + const queryStr = `{"pairs": { "limit": ${limit} ${allPairs.length ? `,"start_after":${JSON.stringify(allPairs[allPairs.length - 1].asset_infos)}` : ""} }}` currentPairs = (await queryContract({ contract: factory, chain, data: queryStr })).pairs allPairs.push(...currentPairs) } while (currentPairs.length > 0) diff --git a/projects/thorchain-lending/index.js b/projects/thorchain-lending/index.js new file mode 100644 index 000000000000..9d88b8ce10e2 --- /dev/null +++ b/projects/thorchain-lending/index.js @@ -0,0 +1,25 @@ +const { getCache, } = require('../helper/http') +const sdk = require("@defillama/sdk"); + +async function tvl(_, _1, _2) { + const pools = await getCache('https://midgard.ninerealms.com/v2/pools') + + const balances = {} + + pools.map(({ totalCollateral, assetPrice }) => { + if (totalCollateral > 0) { + sdk.util.sumSingleBalance(balances, 'thorchain', (Number(totalCollateral) / 1e8)* Number(assetPrice)) + } + }) + + return balances +} + +module.exports = { + hallmarks: [ + [1626656400, "Protocol paused"], + [1631754000, "Protocol resumed"], + ], + timetravel: false, + thorchain: { tvl, }, +} \ No newline at end of file diff --git a/projects/tracerdao/index.js b/projects/tracerdao/index.js index ad13ea73a6ec..31bc3327161e 100644 --- a/projects/tracerdao/index.js +++ b/projects/tracerdao/index.js @@ -1,10 +1,7 @@ const ADDRESSES = require('../helper/coreAssets.json') -const sdk = require("@defillama/sdk"); const abi = require("./abi.json"); -const { sumTokens2 } = require('../helper/unwrapLPs') const USDC = ADDRESSES.arbitrum.USDC; -const chain = 'arbitrum' // Both v1 and v2 factories const factoryPoolContractsConfig = [ @@ -18,36 +15,16 @@ const factoryPoolContractsConfig = [ }, ] -async function tvl(_, _b, { arbitrum: block }) { - let factories = [] - if (!block) factories = factoryPoolContractsConfig.map(i => i.contract) - else { - factoryPoolContractsConfig.filter(i => block > i.fromBlock).forEach(i => factories.push(i.contract)) +async function tvl(api) { + const owners = [] + for (const { contract } of factoryPoolContractsConfig) { + const pools = await api.fetchList({ lengthAbi: abi.numPools, itemAbi: abi.pools, target: contract}) + owners.push(...pools) } - const { output: numPools } = await sdk.api.abi.multiCall({ - calls: factories.map(i => ({ target: i })), - abi: abi.numPools, - chain, block, - }) - - const calls = [] - numPools.forEach(i => { - for (let j = 0; j < +i.output; j++) - calls.push({ target: i.input.target, params: j }) - }) - - const { output: pools } = await sdk.api.abi.multiCall({ - abi: abi.pools, - calls, - chain, block, - }) - - const owners = pools.map(i => i.output) - return sumTokens2({ owners, chain, block, tokens: [USDC] }) + return api.sumTokens({ owners, tokens: [USDC] }) } module.exports = { - misrepresentedTokens: true, arbitrum: { tvl, }, diff --git a/projects/treasury/pluto.js b/projects/treasury/pluto.js new file mode 100644 index 000000000000..1200f29cd989 --- /dev/null +++ b/projects/treasury/pluto.js @@ -0,0 +1,9 @@ +const { sumTokens, } = require('../helper/chain/waves') + +// https://wavesexplorer.com/addresses/3P3a1jssxc2CGdyC7SGbTJc9ZvTjZ5jBMLZ +module.exports = { + timetravel: false, + waves: { + tvl: api => sumTokens({ api, owners: ['3PKFFFsiKR7rgaeoLQZj6jLsxteZigccN8h'], }), + } +} \ No newline at end of file diff --git a/projects/treasury/puff.js b/projects/treasury/puff.js new file mode 100644 index 000000000000..9db4899e3151 --- /dev/null +++ b/projects/treasury/puff.js @@ -0,0 +1,14 @@ +const ADDRESSES = require('../helper/coreAssets.json') +const { nullAddress, treasuryExports } = require("../helper/treasury"); + +module.exports = treasuryExports({ + mantle: { + tokens: [ + nullAddress, + "0xcda86a272531e8640cd7f1a92c01839911b90bb0", + ], + owners: ["0x940e79c49d73ce46884f57087e0c78b608da57c6"], + ownTokens: ["0x26a6b0dcdcfb981362afa56d581e4a7dba3be140"], + uniV3nftsAndOwners: [["0xE9baC8f0100C3229AbddE01D692c6e5791d3b544", "0x940e79c49d73ce46884f57087e0c78b608da57c6"]], + }, +}) \ No newline at end of file diff --git a/projects/treasury/sideshift-ai.js b/projects/treasury/sideshift-ai.js new file mode 100644 index 000000000000..4fb7c838ee1b --- /dev/null +++ b/projects/treasury/sideshift-ai.js @@ -0,0 +1,11 @@ +const { nullAddress, treasuryExports } = require("../helper/treasury"); + +module.exports = treasuryExports({ + ethereum: { + tokens: [ + nullAddress, + ], + owners: ['0x8f456e525ed0115e22937c5c8afac061cc697f21'], + ownTokens: [], + }, +}) \ No newline at end of file diff --git a/projects/tzwrap/index.js b/projects/tzwrap/index.js index 877466b75cd2..b91c95a7995c 100644 --- a/projects/tzwrap/index.js +++ b/projects/tzwrap/index.js @@ -1,14 +1,7 @@ -const { sumTokens } = require('../helper/unwrapLPs') -const tokens= require('./tokens') - -async function tvl(_, block) { - const wrapContract = '0x5Dc76fD132354be5567ad617fD1fE8fB79421D82' - const toa = tokens.map(t => [t.ethereumContractAddress, wrapContract]) - return sumTokens({}, toa, block) -} +const { sumTokensExport } = require('../helper/unwrapLPs') module.exports = { ethereum: { - tvl + tvl: sumTokensExport({ owner: '0x5Dc76fD132354be5567ad617fD1fE8fB79421D82', fetchCoValentTokens: true, }) } -}; +} \ No newline at end of file diff --git a/projects/tzwrap/tokens.js b/projects/tzwrap/tokens.js deleted file mode 100644 index 4a9de541973c..000000000000 --- a/projects/tzwrap/tokens.js +++ /dev/null @@ -1,131 +0,0 @@ -const ADDRESSES = require('../helper/coreAssets.json') -// info taken from https://indexer.app.tzwrap.com/v1/configuration - -module.exports = [ - { - "ethereumSymbol": "LEO", - "ethereumName": "Bitfinex LEO Token", - "ethereumContractAddress": "0x2af5d2ad76741191d15dfe7bf6ac92d4bd912ca3", - "tezosWrappingContract": ADDRESSES.tezos.AAVE - }, - { - "ethereumSymbol": "BUSD", - "ethereumName": "Binance USD", - "ethereumContractAddress": ADDRESSES.ethereum.BUSD, - "tezosWrappingContract": ADDRESSES.tezos.WETH_e - }, - { - "ethereumSymbol": "LINK", - "ethereumName": "ChainLink Token", - "ethereumContractAddress": ADDRESSES.ethereum.LINK, - "tezosWrappingContract": ADDRESSES.tezos.WETH_e - }, - { - "ethereumSymbol": "DAI", - "ethereumName": "Dai Stablecoin", - "ethereumContractAddress": ADDRESSES.ethereum.DAI, - "tezosWrappingContract": ADDRESSES.tezos.WETH_e - }, - { - "ethereumSymbol": "SUSHI", - "ethereumName": "SushiToken", - "ethereumContractAddress": ADDRESSES.ethereum.SUSHI, - "tezosWrappingContract": ADDRESSES.tezos.AAVE - }, - { - "ethereumSymbol": "HT", - "ethereumName": "Huobi Token", - "ethereumContractAddress": "0x6f259637dcd74c767781e37bc6133cd6a68aa161", - "tezosWrappingContract": ADDRESSES.tezos.AAVE - }, - { - "ethereumSymbol": "OKB", - "ethereumName": "OKB", - "ethereumContractAddress": "0x75231f58b43240c9718dd58b4967c5114342a86c", - "tezosWrappingContract": ADDRESSES.tezos.AAVE - }, - { - "ethereumSymbol": "AAVE", - "ethereumName": "Aave Token", - "ethereumContractAddress": ADDRESSES.ethereum.AAVE, - "tezosWrappingContract": ADDRESSES.tezos.AAVE - }, - { - "ethereumSymbol": "PAX", - "ethereumName": "Paxos Standard", - "ethereumContractAddress": "0x8e870d67f660d95d5be530380d0ec0bd388289e1", - "tezosWrappingContract": ADDRESSES.tezos.AAVE - }, - { - "ethereumSymbol": "MKR", - "ethereumName": "Maker", - "ethereumContractAddress": ADDRESSES.ethereum.MKR, - "tezosWrappingContract": ADDRESSES.tezos.AAVE - }, - { - "ethereumSymbol": "HUSD", - "ethereumName": "HUSD", - "ethereumContractAddress": "0xdf574c24545e5ffecb9a659c229253d4111d87e1", - "tezosWrappingContract": ADDRESSES.tezos.AAVE - }, - { - "ethereumSymbol": "UNI", - "ethereumName": "Uniswap", - "ethereumContractAddress": ADDRESSES.ethereum.UNI, - "tezosWrappingContract": ADDRESSES.tezos.AAVE - }, - { - "ethereumSymbol": "WBTC", - "ethereumName": "Wrapped BTC", - "ethereumContractAddress": ADDRESSES.ethereum.WBTC, - "tezosWrappingContract": ADDRESSES.tezos.WETH_e - }, - { - "ethereumSymbol": "FTT", - "ethereumName": "FTX Token", - "ethereumContractAddress": "0x50d1c9771902476076ecfc8b2a83ad6b9355a4c9", - "tezosWrappingContract": ADDRESSES.tezos.AAVE - }, - { - "ethereumSymbol": "MATIC", - "ethereumName": "Matic Token", - "ethereumContractAddress": ADDRESSES.ethereum.MATIC, - "tezosWrappingContract": ADDRESSES.tezos.WETH_e - }, - { - "ethereumSymbol": "CRO", - "ethereumName": "Crypto.com Coin", - "ethereumContractAddress": "0xa0b73e1ff0b80914ab6fe0444e65848c4c34450b", - "tezosWrappingContract": ADDRESSES.tezos.AAVE - }, - { - "ethereumSymbol": "USDC", - "ethereumName": "USD Coin", - "ethereumContractAddress": ADDRESSES.ethereum.USDC, - "tezosWrappingContract": ADDRESSES.tezos.WETH_e - }, - { - "ethereumSymbol": "CEL", - "ethereumName": "Celsius Network", - "ethereumContractAddress": "0xaaaebe6fe48e54f431b0c390cfaf0b017d09d42d", - "tezosWrappingContract": ADDRESSES.tezos.AAVE - }, - { - "ethereumSymbol": "COMP", - "ethereumName": "Compound", - "ethereumContractAddress": "0xc00e94cb662c3520282e6f5717214004a7f26888", - "tezosWrappingContract": ADDRESSES.tezos.AAVE - }, - { - "ethereumSymbol": "WETH", - "ethereumName": "Wrapped Ether", - "ethereumContractAddress": ADDRESSES.ethereum.WETH, - "tezosWrappingContract": ADDRESSES.tezos.WETH_e - }, - { - "ethereumSymbol": "USDT", - "ethereumName": "Tether USD", - "ethereumContractAddress": ADDRESSES.ethereum.USDT, - "tezosWrappingContract": ADDRESSES.tezos.WETH_e - } -] \ No newline at end of file diff --git a/projects/vacusfinance/index.js b/projects/vacusfinance/index.js index eec2b7b6b114..d182b138ffab 100644 --- a/projects/vacusfinance/index.js +++ b/projects/vacusfinance/index.js @@ -70,12 +70,12 @@ async function gettotalTvl(block) { } } -async function tvl(_, _b, { [chain]: block }) { - return (await gettotalTvl(block)).tvl +async function tvl(api) { + return (await gettotalTvl(api.block)).tvl } -async function pool2(_, _b, { [chain]: block }) { - return (await gettotalTvl(block)).pool2 +async function pool2(api) { + return (await gettotalTvl(api.block)).pool2 } /* async function staking(_, _b, { [chain]: block }) { @@ -88,6 +88,7 @@ module.exports = { hallmarks: [ [1665187200, "Rug Pull"] ], + deadFrom: 1665187200, misrepresentedTokens: true, avax: { tvl, diff --git a/projects/web3world/index.js b/projects/web3world/index.js new file mode 100644 index 000000000000..d8032383da70 --- /dev/null +++ b/projects/web3world/index.js @@ -0,0 +1,22 @@ +const { post } = require('../helper/http') +const BigNumber = require('bignumber.js') + +async function fetch() { + const tvl = (await post("https://api.web3.world/v2/pools", { + limit: 1000, + offset: 0, + ordering: "tvldescending", + whiteListUri: "https://static.web3.world/assets/manifest.json", + }) + ).pools.map(p => p.tvl).reduce( + (a, c) => new BigNumber(a).plus(c)); + + return tvl; +} + +module.exports = { + venom: { + fetch + }, + fetch +}; diff --git a/projects/wise-lending/index.js b/projects/wise-lending/index.js index 2e86ad01d82a..6759c75ed0f1 100644 --- a/projects/wise-lending/index.js +++ b/projects/wise-lending/index.js @@ -1,7 +1,5 @@ -const lendingContract = '0x37e49bf3749513A02FA535F0CbC383796E8107E4' -const feeManager = '0x0bc24e61daad6293a1b3b53a7d01086bff0ea6e5' - async function tvl(api) { + const { lending: lendingContract, feeManager } = config[api.chain] const pools = await api.fetchList({ lengthAbi: 'uint256:getPoolTokenAddressesLength', itemAbi: 'function getPoolTokenAdressesByIndex(uint256) view returns (address)', target: feeManager }) const isATokens = await api.multiCall({ abi: 'function isAaveToken(address) view returns (bool)', calls: pools, target: feeManager }) const aTokens = pools.filter((_, i) => isATokens[i]) @@ -14,7 +12,13 @@ module.exports = { hallmarks: [ [1705017600,"Project Exploited"] ], - ethereum: { - tvl - } } + +const config = { + ethereum: { lending: '0x37e49bf3749513A02FA535F0CbC383796E8107E4', feeManager: '0x0bc24e61daad6293a1b3b53a7d01086bff0ea6e5' }, + arbitrum: { lending: '0x9034a49587bd2c1af27598e0f04f30db66c87ebf', feeManager: '0x90a022796798f9dbA1Da0f8645234B284d4E8EC6' }, +} + +Object.keys(config).forEach(chain => { + module.exports[chain] = { tvl } +}) diff --git a/projects/zest/index.js b/projects/zest/index.js new file mode 100644 index 000000000000..b9311b43187a --- /dev/null +++ b/projects/zest/index.js @@ -0,0 +1,15 @@ +const { sumTokens } = require('../helper/chain/stacks') + +async function tvl() { + return sumTokens({ + owners: [ + 'SP2VCQJGH7PHP2DJK7Z0V48AGBHQAW3R3ZW1QF4N.pool-vault', // STX and SIP10 tokens + ], + }) +} + +module.exports = { + stacks: { + tvl, + }, +}; diff --git a/projects/zircuit/index.js b/projects/zircuit/index.js index ceb3f54f9c95..9748f4386589 100644 --- a/projects/zircuit/index.js +++ b/projects/zircuit/index.js @@ -14,7 +14,11 @@ const TOKEN_CONTRACTS = [ '0x32bd822d615A3658A68b6fDD30c2fcb2C996D678', // mswETH ADDRESSES.ethereum.WSTETH, // wstETH '0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee', // weETH - '0xf951E335afb289353dc249e82926178EaC7DEd78' // swETH + '0xf951E335afb289353dc249e82926178EaC7DEd78', // swETH + '0x4c9EDD5852cd905f086C759E8383e09bff1E68B3', // USDe + '0x4d831e22F062b5327dFdB15f0b6a5dF20E2E3dD0', // cSTONE + '0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa', // mETH + '0xD9A442856C234a39a81a089C06451EBAa4306a72' // pufETH ]; module.exports = { diff --git a/projects/zklend/index.js b/projects/zklend/index.js index ae98bd9c9bd5..61e5138e09bd 100644 --- a/projects/zklend/index.js +++ b/projects/zklend/index.js @@ -18,6 +18,16 @@ async function tvl(api) { return sumTokens({ api, owner: market, tokens: assets }) } +async function staking(api) { + return sumTokens({ + api, + owner: market, + tokens: [ + ADDRESSES.starknet.ZEND + ] + }) +} + async function borrowed(api) { let data = await multiCall({ calls: assets, target: market, abi: marketAbi.get_total_debt_for_token }); data = data.map(i => +i) @@ -28,6 +38,7 @@ module.exports = { methodology: 'Value of user supplied asset on zkLend is considered as TVL', starknet: { tvl, - borrowed + borrowed, + staking, }, } diff --git a/test.js b/test.js index 037a97aec04c..994074ac0a09 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,7 @@ #!/usr/bin/env node const handleError = require('./utils/handleError') +const INTERNAL_CACHE_FILE = 'tvl-adapter-repo/sdkInternalCache.json' process.on('unhandledRejection', handleError) process.on('uncaughtException', handleError) @@ -47,7 +48,7 @@ async function getTvl( api.storedKey = storedKey if (!isFetchFunction) { let tvlBalances = await tvlFunction(api, ethBlock, chainBlocks, api); - if (!tvlBalances && Object.keys(api.getBalances()).length) tvlBalances = api.getBalances() + if (tvlBalances === undefined) tvlBalances = api.getBalances() const tvlResults = await computeTVL(tvlBalances, "now"); await diplayUnknownTable({ tvlResults, storedKey, tvlBalances, }) usdTvls[storedKey] = tvlResults.usdTvl; @@ -107,10 +108,12 @@ sdk.api.abi.call = async (...args) => { } catch (e) { console.log(e) } + await initCache() const chains = Object.keys(module).filter(item => typeof module[item] === 'object' && !Array.isArray(module[item])); checkExportKeys(module, passedFile, chains) const unixTimestamp = Math.round(Date.now() / 1000) - 60; - const { chainBlocks } = await getCurrentBlocks([]); // fetch only ethereum block for local test + // const { chainBlocks } = await getCurrentBlocks([]); // fetch only ethereum block for local test + const chainBlocks = {} const ethBlock = chainBlocks.ethereum; const usdTvls = {}; const tokensBalances = {}; @@ -212,6 +215,7 @@ sdk.api.abi.call = async (...args) => { }); console.log("\ntotal".padEnd(25, " "), humanizeNumber(usdTvls.tvl), "\n"); + await preExit() process.exit(0); })(); @@ -413,4 +417,33 @@ setTimeout(() => { console.log("Timeout reached, exiting..."); if (!process.env.NO_EXIT_ON_LONG_RUN_RPC) process.exit(1); -}, 10 * 60 * 1000) // 10 minutes \ No newline at end of file +}, 10 * 60 * 1000) // 10 minutes + + + +async function initCache() { + let currentCache = await sdk.cache.readCache(INTERNAL_CACHE_FILE) + if (process.env.NO_EXIT_ON_LONG_RUN_RPC) + sdk.log('cache size:', JSON.stringify(currentCache).length, 'chains:', Object.keys(currentCache).length) + const ONE_WEEK = 60 * 60 * 24 * 31 + if (!currentCache || !currentCache.startTime || (Date.now() / 1000 - currentCache.startTime > ONE_WEEK)) { + currentCache = { + startTime: Math.round(Date.now() / 1000), + } + await sdk.cache.writeCache(INTERNAL_CACHE_FILE, currentCache) + } + sdk.sdkCache.startCache(currentCache) +} + +async function saveSdkInternalCache() { + await sdk.cache.writeCache(INTERNAL_CACHE_FILE, sdk.sdkCache.retriveCache(), { skipR2CacheWrite: true }) +} + +async function preExit() { + try { + await saveSdkInternalCache() // save sdk cache to r2 + } catch (e) { + if (process.env.NO_EXIT_ON_LONG_RUN_RPC) + sdk.error(e) + } +} \ No newline at end of file