diff --git a/package-lock.json b/package-lock.json index cff6555ac7b..ab79f3b205b 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 cc900e75344..8ca12aa6db0 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 d229ba553b8..c17b741cd69 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/MeowMiner/index.js b/projects/MeowMiner/index.js index 483be2acf95..5ef8c54a5a3 100644 --- a/projects/MeowMiner/index.js +++ b/projects/MeowMiner/index.js @@ -5,8 +5,8 @@ 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: sumTokensExport({ owner: MEOW_MINER_CONTRACT, tokens: [MEOW_TOKEN_CONTRACT], lps: [LP_MEOW_WAVAX], useDefaultCoreAssets: true, }) + tvl: 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 00000000000..9e2291bc8a6 --- /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 00000000000..bf28a426dc7 --- /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/airpuff/index.js b/projects/airpuff/index.js index 7a668daf46a..75421aa7ce0 100644 --- a/projects/airpuff/index.js +++ b/projects/airpuff/index.js @@ -14,6 +14,11 @@ const contractAbis = { }, // balanceOf: "function balanceOf(address) external view returns (uint256)", getPrice: "function answer() external view returns (uint256)", + getTotalSupply: "function totalSupply() external view returns (uint256)", + getTotalAssets: "function totalAssets() external view returns (uint256)", + getVectorSharePrice: "function getVectorSharePrice() external view returns (uint256)", + getMswEthPrice: "function exchangeRateToNative() external view returns (uint256)", + getMswBalance: "function getAllEigeinPieCycleDepositAmounts() external view returns (uint256)", }; module.exports = { @@ -23,9 +28,13 @@ module.exports = { tvl: async (api) => { const lendingMain = { eth: "0xdeF3AA48bad043e53207d359dcDFdE46F50b6C02", //ETH + sUSD: "0x7c2a7009ffE52a69a8C877b47B07D5dB59C0e3b3", // Not lending pool, staking pool }; await api.sumTokens({ - tokensAndOwners: [[ADDRESSES.ethereum.WETH, lendingMain.eth]], + tokensAndOwners: [ + [ADDRESSES.ethereum.WETH, lendingMain.eth], + [ADDRESSES.ethereum.sUSDe, lendingMain.sUSD], + ], }); const eETH = { @@ -97,6 +106,23 @@ module.exports = { oracle: "0x1bEB65b15689cCAeb5dA191c9fd5F94513923Cab", }; + const svETH = { + vault: "0xaF33b6372354149c33893B6fA6959Be0607D53dE", + reStakingToken: "0x6733F0283711F225A447e759D859a70b0c0Fd2bC", + oracle: "svETH", + }; + + const svETH1x = { + vault: "0x060Feab7904378e2A487974e7Ba98251aD65247F", + reStakingToken: "0x6733F0283711F225A447e759D859a70b0c0Fd2bC", + oracle: "svETH", + }; + + const svETHPrice = await api.call({ + abi: contractAbis.getVectorSharePrice, + target: svETH.vault, + }); + const strategies = [ezETH, weETH, rsETH, ezETH1x, weETH1x, rsETH1x, bedRockETH, bedRockETH1x]; for (const strategy of strategies) { @@ -106,15 +132,72 @@ module.exports = { params: [strategy.vault], }); - const lrETHPriceInETH = await api.call({ - target: strategy.oracle, - abi: contractAbis.readOraclePrice, + let lrETHPriceInETH; + + if (strategy.oracle == "svETH") { + lrETHPriceInETH = svETHPrice; + } else { + lrETHPriceInETH = await api.call({ + target: strategy.oracle, + abi: contractAbis.readOraclePrice, + }); + lrETHPriceInETH = lrETHPriceInETH.value; + } + + const balInETH = (bal * lrETHPriceInETH) / 1e18; + + api.add(ADDRESSES.ethereum.WETH, balInETH); + } + //strategy with no oracle, but can calculate price using erc4626 totalSupply and totalAssets + const LiquidETH = { + vault: "0xE543eBa28a3793d5ae747A2164A306DB1767cDAe", + reStakingToken: "0xeA1A6307D9b18F8d1cbf1c3Dd6aad8416C06a221", + }; + + const erc4626Strategies = [LiquidETH]; + + for (const erc4626strategy of erc4626Strategies) { + const bal = await api.call({ + abi: contractAbis.balanceOf, + target: erc4626strategy.reStakingToken, + params: [erc4626strategy.vault], }); - const balInETH = (bal * lrETHPriceInETH.value) / 1e18; + const totalAssets = await api.call({ + abi: contractAbis.getTotalAssets, + target: erc4626strategy.reStakingToken, + }); + + const totalSupply = await api.call({ + abi: contractAbis.getTotalSupply, + target: erc4626strategy.reStakingToken, + }); + + const price = totalAssets / totalSupply; + + const balInETH = bal * price; api.add(ADDRESSES.ethereum.WETH, balInETH); } + + const mswETH = { + valut: "0x7c505E03460aEF7FE88e218CC5fcEeCCcA4C4394", + reStakingToken: "0x32bd822d615A3658A68b6fDD30c2fcb2C996D678", + }; + + const mswETHPrice = await api.call({ + abi: contractAbis.getMswEthPrice, + target: mswETH.reStakingToken, + }); + + const mswETHBal = await api.call({ + abi: contractAbis.getMswBalance, + target: mswETH.valut, + }); + + const mswETHBalInETH = (mswETHBal * mswETHPrice) / 1e18; + + api.add(ADDRESSES.ethereum.WETH, mswETHBalInETH); }, }, diff --git a/projects/alpaca-finance-v2/moneyMarket.js b/projects/alpaca-finance-v2/moneyMarket.js index d469aacc7e8..86ea760f3a8 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 5fa40183cfe..8c1c1b645b7 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/ash-perp/index.js b/projects/ash-perp/index.js new file mode 100644 index 00000000000..4fda2795d2f --- /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 00000000000..1e83bbd6875 --- /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/autobark/index.js b/projects/autobark/index.js index 76c3acd3db4..8a013d2486b 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 565b4f73fc7..03e8e23cf98 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 135617808e6..0354c206802 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 30d2be79aa9..c91da9ff217 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/blast/index.js b/projects/blast/index.js index d56380747ee..51cfcd86268 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 cb9d4ee4a44..d76a6add8ee 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/butternetwork/index.js b/projects/butternetwork/index.js index 7091f623e53..020b29e4a7e 100644 --- a/projects/butternetwork/index.js +++ b/projects/butternetwork/index.js @@ -51,6 +51,15 @@ const config = { // ETH: ADDRESSES.map.ETH, MAP: ADDRESSES.map.WMAPO } + }, + merlin: { + mosContract: "0xfeB2b97e4Efce787c08086dC16Ab69E063911380", + tokens: { + WBTC: ADDRESSES.merlin.WBTC, + WBTC_1: ADDRESSES.merlin.WBTC_1, + SolvBTC: "0x41D9036454BE47d3745A823C4aaCD0e29cFB0f71", + iUSD: "0x0A3BB08b3a15A19b4De82F8AcFc862606FB69A2D" + } } } diff --git a/projects/degenfund/index.js b/projects/degenfund/index.js new file mode 100644 index 00000000000..60254944649 --- /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 53e4b9f4199..7964aff6a35 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/etherfi-liquid/index.js b/projects/etherfi-liquid/index.js new file mode 100644 index 00000000000..2c0f897708d --- /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 00000000000..d738ba16a47 --- /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 00000000000..92bf5e6ae12 --- /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 00000000000..3c9b194a700 --- /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/growthdefi/abis/clqdr.json b/projects/growthdefi/abis/clqdr.json deleted file mode 100644 index 3ea13f77ea0..00000000000 --- 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 1d1bb56c540..2f226e0b8a0 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 62d6a4117f4..a38048ed25f 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 e4d1879a8f3..e2f2aeca05b 100644 --- a/projects/helper/aave.js +++ b/projects/helper/aave.js @@ -127,10 +127,10 @@ function aaveChainTvl(_chain, addressesProviderRegistry, transformAddressRaw, da 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 79614754976..ac550173a79 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 ae1d2efbed1..00000000000 --- 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 536b913eabc..59733c05433 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/env.js b/projects/helper/env.js index ada404c4744..334d3c95012 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 bb7700b05cc..00000000000 --- 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 badd8772e42..3c40a4f9689 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/tokenMapping.js b/projects/helper/tokenMapping.js index e88b3129e91..2c49645bd71 100644 --- a/projects/helper/tokenMapping.js +++ b/projects/helper/tokenMapping.js @@ -37,6 +37,17 @@ 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/iskra/index.js b/projects/iskra/index.js new file mode 100644 index 00000000000..072b4ce1ed9 --- /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/kriya-dex-earn/index.js b/projects/kriya-dex-earn/index.js new file mode 100644 index 00000000000..f96382b5490 --- /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 950a84c1a5d..bbfe3461eec 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/merchant-moe-lb/index.js b/projects/merchant-moe-lb/index.js new file mode 100644 index 00000000000..f86f584aba1 --- /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/mint-club-v2/index.js b/projects/mint-club-v2/index.js index c3f7252f2e0..275ad16d168 100644 --- a/projects/mint-club-v2/index.js +++ b/projects/mint-club-v2/index.js @@ -9,13 +9,14 @@ const V2_BOND_CONTRACTS = { avax: "0x3Fd5B4DcDa968C8e22898523f5343177F94ccfd1", blast: "0x621c335b4BD8f2165E120DC70d3AfcAfc6628681", degen: "0x3bc6B601196752497a68B2625DB4f2205C3b150b", + zora: "0xc5a076cad94176c2996B32d8466Be1cE757FAa27" } const ownTokens = { bsc: ['0x1f3Af095CDa17d63cad238358837321e95FC5915'] } -const chains = ['avax', 'ethereum', 'optimism', 'arbitrum', 'polygon', 'bsc', 'base', 'blast', 'degen'] +const chains = ['avax', 'ethereum', 'optimism', 'arbitrum', 'polygon', 'bsc', 'base', 'blast', 'degen', 'zora'] chains.forEach(chain => { const BOND_CONTRACT = V2_BOND_CONTRACTS[chain] ?? '0xc5a076cad94176c2996B32d8466Be1cE757FAa27' diff --git a/projects/moneyonchain.js b/projects/moneyonchain.js index 3040d12c4da..ec4fe9dcb21 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/pluto/index.js b/projects/pluto/index.js index c35c72c81d1..44407b6cd15 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/puff-penthouse/index.js b/projects/puff-penthouse/index.js new file mode 100644 index 00000000000..ceae2c0c6d7 --- /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 3afd009b4b1..11ece22dcc3 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 b36cd4df5cb..7f01ad3629d 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/reserve/index.js b/projects/reserve/index.js index 80ed41cfe71..04f20a8752c 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/savmswap/index.js b/projects/savmswap/index.js new file mode 100644 index 00000000000..af5911e947c --- /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 2d46a70db19..149bf76342f 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 939d92585ff..a791a7f3efc 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 5ed7340038f..32427a5cafa 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 54c0b6b2f6c..fd8bb980a4c 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 00000000000..dc5fd35a4c8 --- /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/superbots/index.js b/projects/superbots/index.js index a5dcb72c1ad..09210ed463a 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 e8a091c1579..3c4a95b4eb8 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/swop/index.js b/projects/swop/index.js index c2d4edacf1b..a70e7ddf328 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/tracerdao/index.js b/projects/tracerdao/index.js index ad13ea73a6e..31bc3327161 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/hegic.js b/projects/treasury/hegic.js index 92729ba1cf7..212b5fc1a5a 100644 --- a/projects/treasury/hegic.js +++ b/projects/treasury/hegic.js @@ -5,7 +5,6 @@ const treasuryARB = "0xf15968a096fc8f47650001585d23bee819b5affb"; const treasuryETH = "0xd884aca1897ac45515cee6d5fd48f341b4023ace" const treasuryETH2 = "0x117f55bf3c2e3bcdc7f308504480ee53f754a7ca" const hegic = "0x584bC13c7D411c00c01A62e8019472dE68768430" -const WHITE = "0x5f0e628b693018f639d10e4a4f59bd4d8b2b6b44" module.exports = treasuryExports({ arbitrum: { @@ -22,6 +21,6 @@ module.exports = treasuryExports({ ADDRESSES.ethereum.USDC ], owners: [treasuryETH, treasuryETH2], - ownTokens: [hegic, WHITE], + ownTokens: [hegic], }, }) \ No newline at end of file diff --git a/projects/treasury/pluto.js b/projects/treasury/pluto.js new file mode 100644 index 00000000000..1200f29cd98 --- /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 00000000000..9db4899e315 --- /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/tzwrap/index.js b/projects/tzwrap/index.js index 877466b75cd..b91c95a7995 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 4a9de541973..00000000000 --- 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 eec2b7b6b11..d182b138ffa 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/venombridge/index.js b/projects/venombridge/index.js new file mode 100644 index 00000000000..cb94ba79253 --- /dev/null +++ b/projects/venombridge/index.js @@ -0,0 +1,21 @@ +const sdk = require("@defillama/sdk") +const { sumTokensExport } = require('../helper/unwrapLPs') + +module.exports = { + timetravel: false, + venom: { + tvl: venomTvl, + }, +} + +const chains = ['ethereum', 'bsc', 'fantom', 'polygon', 'avax'] +const tvl = sumTokensExport({ owner: '0x4aB740157721105aE503fbad756a578171512525', fetchCoValentTokens: true, }) + +chains.forEach(chain => module.exports[chain] = { tvl }) + +async function venomTvl() { + const promises = chains.map(chain => sdk.api.erc20.totalSupply({ chain, target: '0x46f84dc6564cdd93922f7bfb88b03d35308d87c9' })) + const totalSupplies = await Promise.all(promises) + const bal = totalSupplies.reduce((acc, supply) => acc + supply.output / 1e9, 0) + return { 'venom': bal } +} \ No newline at end of file diff --git a/projects/visor/config.js b/projects/visor/config.js index b7e82fbae5d..e6f5f87f2c5 100644 --- a/projects/visor/config.js +++ b/projects/visor/config.js @@ -74,6 +74,7 @@ const HYPE_REGISTRY = { ["0xc27ddd78fc49875fe6f844b72bbf31dfbb099881", 163300], // Lynex ], base: [ + ["0x829432679F69DBd8b2575f006EC0129894a39D86", 12465470], // Uniswap ["0x339685503dD534D27ce4a064314c2E5c7144aa92", 7783229], // Pancakeswap ["0x6d5c54F535b073B9C2206Baf721Af2856E5cD683", 3785552], // Sushiswap ["0x1E86A593E55215957C4755f1BE19a229AF3286f6", 2798768], // SynthSwap @@ -105,7 +106,11 @@ const HYPE_REGISTRY = { imx: [ ["0x683292172E2175bd08e3927a5e72FC301b161300", 3951377], // Quickswap ], + scroll: [ + ["0x683292172E2175bd08e3927a5e72FC301b161300", 4651930], // Uniswap + ], blast: [ + ["0xFc13Ebe7FEB9595D70195E9168aA7F3acE153621", 1727054], // Uniswap ["0xC27DDd78FC49875Fe6F844B72bbf31DFBB099881", 1005700], // Blaster ], }; diff --git a/projects/web3world/index.js b/projects/web3world/index.js new file mode 100644 index 00000000000..d8032383da7 --- /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 2e86ad01d82..6759c75ed0f 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/zircuit/index.js b/projects/zircuit/index.js index cd9416c316e..9748f438658 100644 --- a/projects/zircuit/index.js +++ b/projects/zircuit/index.js @@ -17,7 +17,8 @@ const TOKEN_CONTRACTS = [ '0xf951E335afb289353dc249e82926178EaC7DEd78', // swETH '0x4c9EDD5852cd905f086C759E8383e09bff1E68B3', // USDe '0x4d831e22F062b5327dFdB15f0b6a5dF20E2E3dD0', // cSTONE - '0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa' // mETH + '0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa', // mETH + '0xD9A442856C234a39a81a089C06451EBAa4306a72' // pufETH ]; module.exports = { diff --git a/test.js b/test.js index b0b355d9354..994074ac0a0 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) @@ -107,6 +108,7 @@ 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; @@ -213,6 +215,7 @@ sdk.api.abi.call = async (...args) => { }); console.log("\ntotal".padEnd(25, " "), humanizeNumber(usdTvls.tvl), "\n"); + await preExit() process.exit(0); })(); @@ -414,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