diff --git a/package-lock.json b/package-lock.json index 9262e7eddef6..a541388890c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -886,9 +886,9 @@ } }, "node_modules/@defillama/sdk": { - "version": "5.0.73", - "resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-5.0.73.tgz", - "integrity": "sha512-uLZeOFNWPKVyZAMtO7dXSJreHKWqETHpbPMZzpNR47icGl4nS2o/SX8xW82BmdLU7cp25EG9sN/sKkht/KnWvA==", + "version": "5.0.74", + "resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-5.0.74.tgz", + "integrity": "sha512-qk/UrP5A55Co7pnj7WE3Cloc7zZSFESUTb5fXRaowH9K5oWi/JRJ4LQZOI38sami586q9/sWLwJrKBlU+lQIVw==", "dependencies": { "@aws-sdk/client-s3": "^3.400.0", "@elastic/elasticsearch": "^8.13.1", diff --git a/projects/accumulated-finance/index.js b/projects/accumulated-finance/index.js index 48eebdbcd496..95eed412e761 100644 --- a/projects/accumulated-finance/index.js +++ b/projects/accumulated-finance/index.js @@ -37,24 +37,31 @@ const config = { } ], "zeta": [ - { - "zeta": { - "baseToken": '0xf091867ec603a6628ed83d274e835539d82e9cc8', - "LST": '0xcba2aeec821b0b119857a9ab39e09b034249681a' - } - }, - { - "bsc": { - "baseToken": "0xf091867ec603a6628ed83d274e835539d82e9cc8", - "LST": "0xcf123d8638266629fb02fc415ad47bd47de01a6b" + { + "zeta": { + "baseToken": '0xf091867ec603a6628ed83d274e835539d82e9cc8', + "LST": '0xcba2aeec821b0b119857a9ab39e09b034249681a' + } + }, + { + "bsc": { + "baseToken": "0xf091867ec603a6628ed83d274e835539d82e9cc8", + "LST": "0xcf123d8638266629fb02fc415ad47bd47de01a6b" + }, }, - }, - { - "ethereum": { - "baseToken": "0xf091867ec603a6628ed83d274e835539d82e9cc8", - "LST": "0xf38feedb0c85c1e1d6864c7513ac646d28bb0cfc" + { + "ethereum": { + "baseToken": "0xf091867ec603a6628ed83d274e835539d82e9cc8", + "LST": "0xf38feedb0c85c1e1d6864c7513ac646d28bb0cfc" + } + }, + ], + "sei": [ + { + "sei": { + "LST": "0xcba2aeec821b0b119857a9ab39e09b034249681a" + }, } - }, ] } diff --git a/projects/agentfi/index.js b/projects/agentfi/index.js index 7f9e0ce4fbca..527b2990e335 100644 --- a/projects/agentfi/index.js +++ b/projects/agentfi/index.js @@ -19,10 +19,8 @@ async function tvl(api) { const blasterswapv2 = dexBalancerAgents.map(i => [uniV2Lp.blasterswap, i.agentAddress]) const ringv2 = dexBalancerAgents.map(i => [uniV2Lp.ring, i.agentAddress]) - const blasterswapV3 = concentratedLiquidityAgents.map(i => [uniV3NftManager.blasterswap, i.agentAddress]) - const blasterswap2V3 = concentratedLiquidityAgents.map(i => [uniV3NftManager.blasterswap2, i.agentAddress]) - const thrusterV3 = concentratedLiquidityAgents.map(i => [uniV3NftManager.thruster, i.agentAddress]) - + const agents = concentratedLiquidityAgents.map(i => i.agentAddress) + await sumTokens2({ api, owners: agents, uniV3ExtraConfig: { nftAddress: [uniV3NftManager.blasterswap, uniV3NftManager.blasterswap2, uniV3NftManager.thruster]}}) await getTvlForDexBalancer(dexBalancerAgents.map(i => i.agentAddress), api) await getTvlForLooperWithOrbit(looperAgentsAddresses, api) @@ -33,11 +31,6 @@ async function tvl(api) { ...blasterswapv2, ...ringv2, ], - uniV3nftsAndOwners: [ - ...blasterswapV3, - ...blasterswap2V3, - ...thrusterV3 - ], resolveLP: true, api, }) diff --git a/projects/airdao-bridge/index.js b/projects/airdao-bridge/index.js new file mode 100644 index 000000000000..1b956ea39f8f --- /dev/null +++ b/projects/airdao-bridge/index.js @@ -0,0 +1,24 @@ +const { sumTokensExport, nullAddress } = require("../helper/unwrapLPs"); +const ADDRESSES = require('../helper/coreAssets.json') + +const CHAINS = { + ethereum: { + locker: "0x0De2669e8A7A6F6CC0cBD3Cf2D1EEaD89e243208", + tokens: [ADDRESSES.ethereum.USDC, ADDRESSES.ethereum.USDT, ADDRESSES.ethereum.WETH] + }, + bsc: { + locker: "0x92fa52d3043725D00Eab422440C4e9ef3ba180d3", + tokens: [ADDRESSES.bsc.USDC, ADDRESSES.bsc.USDT, ADDRESSES.bsc.WBNB, ADDRESSES.bsc.BUSD] + }, +} + +module.exports = { + methodology: + "Adds up the total value locked as collateral on the Bridge platform" +} + +Object.keys(CHAINS).forEach(chain => { + module.exports[chain] = { + tvl: sumTokensExport({ owner: CHAINS[chain].locker, tokens: CHAINS[chain].tokens }) + } +}) diff --git a/projects/alexar/index.js b/projects/alexar/index.js index d58c0311cda0..f35001a02d13 100644 --- a/projects/alexar/index.js +++ b/projects/alexar/index.js @@ -11,13 +11,13 @@ const chainMapping = { }; const chainListSupply = ['juno', 'cosmos', 'comdex', 'carbon', 'crescent', 'injective', 'kujira', 'osmosis', 'persistence', 'stargaze', 'secret', 'stargaze', 'umee', 'evmos', 'terra2']; -const chainListTotal = ['avax', 'bsc', 'moonbeam', 'polygon', 'fantom', 'arbitrum', 'aurora', 'celo', 'kava', 'mantle', 'ethereum',]; +const chainListTotal = ['avax', 'bsc', 'moonbeam', 'polygon', 'fantom', 'arbitrum', 'aurora', 'celo', 'kava', 'mantle', 'ethereum', 'base']; chainListSupply.concat(chainListTotal).forEach(chain => { module.exports[chain] = { tvl }; async function tvl(api) { - const config = await getConfig('alexar', 'https://api.axelarscan.io/cross-chain/tvl') + const config = await getConfig('alexar', 'https://api.axelarscan.io/api/getTVL') const tokensAndOwners = [] const owners = [] const mappedChain = chainMapping[chain] || chain; @@ -25,9 +25,12 @@ chainListSupply.concat(chainListTotal).forEach(chain => { if (!assetTvl) return; const isEVM = assetTvl.gateway_address?.startsWith('0x') + const data = assetTvl.contract_data if (isEVM) { - if (assetTvl.contract_data.symbol.startsWith('axl')) return; - tokensAndOwners.push([assetTvl.contract_data.address, assetTvl.gateway_address]) + if (data.symbol.startsWith('axl')) return; + tokensAndOwners.push([data.address, assetTvl.gateway_address]) + if (data.token_manager_address) + tokensAndOwners.push([data.address, data.token_manager_address]) } else { if (assetTvl.denom_data.symbol.startsWith('axl')) return; owners.push(...assetTvl.source_escrow_addresses) diff --git a/projects/alien-finance/index.js b/projects/alien-finance/index.js index 1b189a2e47bf..ba6bff29a842 100644 --- a/projects/alien-finance/index.js +++ b/projects/alien-finance/index.js @@ -1,4 +1,6 @@ -const owner = "0x50454acC07bf8fC78100619a1b68e9E8d28cE022" +const DAPP_POOL = "0x50454acC07bf8fC78100619a1b68e9E8d28cE022" +const BLAST_POOL = "0x02B7BF59e034529d90e2ae8F8d1699376Dd05ade" +const BLAST_POOL_LAUNCH = 1719390003 module.exports = { blast: { @@ -8,11 +10,22 @@ module.exports = { }; async function tvl(api) { - const tokens = await api.call({ abi: 'address[]:getAllMarkets', target: owner}) - return api.sumTokens({ owner, tokens}) + const dappPoolTokens = await api.call({ abi: 'address[]:getAllMarkets', target: DAPP_POOL}); + const blastPoolTokens = api.timestamp > BLAST_POOL_LAUNCH ? await api.call({ abi: 'address[]:getAllMarkets', target: BLAST_POOL}) : []; + + return api.sumTokens({ tokensAndOwners: [ + ...dappPoolTokens.map(token => [token, DAPP_POOL]), + ...blastPoolTokens.map(token => [token, BLAST_POOL]), + ] }) } async function borrowed(api) { - const tokens = await api.call({ abi: 'address[]:getAllMarkets', target: owner}) - const bals = await api.multiCall({ abi: 'function getTotalBorrow(address) view returns (uint256)', calls: tokens, target: owner}) - api.add(tokens, bals) -} \ No newline at end of file + const dappPoolTokens = await api.call({ abi: 'address[]:getAllMarkets', target: DAPP_POOL}); + const dappPoolBorrow = await api.multiCall({ abi: 'function getTotalBorrow(address) view returns (uint256)', calls: dappPoolTokens, target: DAPP_POOL}) + api.add(dappPoolTokens, dappPoolBorrow) + + if (api.timestamp > BLAST_POOL_LAUNCH) { + const blastPoolTokens = await api.call({ abi: 'address[]:getAllMarkets', target: BLAST_POOL}); + const blastPoolBorrow = await api.multiCall({ abi: 'function getTotalBorrow(address) view returns (uint256)', calls: blastPoolTokens, target: BLAST_POOL}) + api.add(blastPoolTokens, blastPoolBorrow) + } +} diff --git a/projects/anzen-v2/index.js b/projects/anzen-v2/index.js index bf999d4aeae7..be764330c274 100644 --- a/projects/anzen-v2/index.js +++ b/projects/anzen-v2/index.js @@ -5,6 +5,7 @@ const sdk = require('@defillama/sdk') const USDz = '0xa469b7ee9ee773642b3e93e842e5d9b5baa10067'; const Base_USDz = '0x04d5ddf5f3a8939889f11e97f8c4bb48317f1938'; const Blast_USDz = '0x52056ed29fe015f4ba2e3b079d10c0b87f46e8c6'; +const Manta_USDz = '0x73d23f3778a90be8846e172354a115543df2a7e4'; const SPCT = '0xf30a29f1c540724fd8c5c4be1af604a6c6800d29'; // Secured collateral const mainnet_tvl = async (api) => { @@ -22,6 +23,11 @@ const blast_tvl = async (api) => { api.add(Blast_USDz, supply) } +const manta_tvl = async (api) => { + const supply = await api.call({ abi: 'erc20:totalSupply', target: Manta_USDz }) + api.add(Manta_USDz, supply) +} + const collateral_assets = async (api) => { const supply = await api.call({ abi: 'erc20:totalSupply', target: SPCT }) api.add(SPCT, supply) @@ -38,4 +44,7 @@ module.exports = { blast: { tvl: blast_tvl, }, + manta: { + tvl: manta_tvl, + }, }; diff --git a/projects/augmented-finance/index.js b/projects/augmented-finance/index.js index a849bc956e3a..50fd9f66764c 100644 --- a/projects/augmented-finance/index.js +++ b/projects/augmented-finance/index.js @@ -9,7 +9,7 @@ const config = { module.exports = { methodology: methodologies.lendingMarket, - // deadFrom: 2024-02-22 + deadFrom: "2024-02-22" }; Object.keys(config).forEach(chain => { diff --git a/projects/augur/index.js b/projects/augur/index.js index b04181bee363..e270d9d8d669 100644 --- a/projects/augur/index.js +++ b/projects/augur/index.js @@ -26,4 +26,7 @@ module.exports = { ethereum: { tvl, }, + hallmarks:[ + [1613091600, "Election market resolves"] + ] } diff --git a/projects/aurus/index.js b/projects/aurus/index.js new file mode 100644 index 000000000000..e7094e6b1b56 --- /dev/null +++ b/projects/aurus/index.js @@ -0,0 +1,15 @@ +const ASSETS = [ + '0xe4a6f23fb9e00fca037aa0ea0a6954de0a6c53bf', // TXAU - gold + '0x34abce75d2f8f33940c721dca0f562617787bff3', // TXAG - silver + '0x19b22dbadc298c359a1d1b59e35f352a2b40e33c' // TXPT - platinum +] + +module.exports = { + methodology: "TVL corresponds to the total amount of Assets minted", + ethereum: { + tvl: async (api) => { + const totalSupplies = await api.multiCall({calls: ASSETS, abi: 'erc20:totalSupply'}) + api.add(ASSETS, totalSupplies) + } + } +} diff --git a/projects/avalon-finance/index.js b/projects/avalon-finance/index.js index e266be25e823..2e4399c8058d 100644 --- a/projects/avalon-finance/index.js +++ b/projects/avalon-finance/index.js @@ -13,7 +13,8 @@ const mainMarket = { } const innovativeMarket = { - merlin: aaveExports('', '0x91b212e9FaF20117Eae59d6289CB38749DDFc070', undefined, ['0x883cb2E2d9c5D4D9aF5b0d37fc39Fa2284405682'],{v3: true}), + merlin: aaveExports('', '0x91b212e9FaF20117Eae59d6289CB38749DDFc070', undefined, ['0x883cb2E2d9c5D4D9aF5b0d37fc39Fa2284405682'], { v3: true }), + btr: aaveExports('', '0x90EA8C92AddE4D3f323Dad9E36f0E0395dbc929d', undefined, ['0x4c25c261Fe47bC216113D140BaF72B05E151bcE4'], { v3: true }), } module.exports = mergeExports(mainMarket, innovativeMarket) diff --git a/projects/betfolio/index.js b/projects/betfolio/index.js index c328ab6abe96..e321d4922496 100644 --- a/projects/betfolio/index.js +++ b/projects/betfolio/index.js @@ -6,8 +6,11 @@ const config = { } async function getContracts() { - const { data: { list } } = await getConfig('betfolio', 'https://api.betfolio.co/api/v1/user/predictionList?limit=1000&duration=&type=') - return list.map(i => i.contract_address) + const [list0Res, list1Res] = await Promise.all([ + getConfig('betfolio', 'https://api.betfolio.co/api/v1/user/predictionList?limit=1000&duration=&type='), + getConfig('betfolioSoloPrediction', 'https://api.betfolio.co/api/v1/user/getSoloPredictions?limit=1000&type=All&theme=All&solo_type=All') + ]); + return [...list0Res.data.list, ...list1Res.data.list].map(i => i.contract_address) } Object.keys(config).forEach(chain => { diff --git a/projects/binance/config.js b/projects/binance/config.js index 0b44ea3fd7f1..4b945b4df62a 100644 --- a/projects/binance/config.js +++ b/projects/binance/config.js @@ -463,6 +463,7 @@ const assetList = [ ['USDC', 'ARB', '0xf977814e90da44bfa03b6295a0616a897441acec'], ['USDC', 'AVAX', '0x4aefa39caeadd662ae31ab0ce7c8c2c9c0a013e8'], ['USDC', 'AVAX', '0x9f8c163cba728e99993abe7495f06c0a3c8ac8b9'], + ['AVAX', 'AVAX', '0x835678a611b28684005a5e2233695fb6cbbb0007'], ['USDC', 'BEP2', 'bnb1fnd0k5l4p3ck2j9x9dp36chk059w977pszdgdz'], ['USDC', 'BEP2', 'bnb1u2agwjat20494fmc6jnuau0ls937cfjn4pjwtn'], ['USDC', 'BEP20', '0x0e4158c85ff724526233c1aeb4ff6f0c46827fbe'], @@ -593,6 +594,30 @@ const assetList = [ ['XRP', 'XRP', 'rhWj9gaovwu2hZxYW7p388P8GRbuXFLQkK'], ['XRP', 'XRP', 'rpmxpWis42eYV4oMhyxJNSzrLRdacJVooa'], ['XRP', 'XRP', 'rs8ZPbYqgecRcDzQpJYAMhSxSi5htsjnza'], + ['USDT', 'ETH', '0x835678a611b28684005a5e2233695fb6cbbb0007'], + ['ETH', 'ETH', '0x835678a611b28684005a5e2233695fb6cbbb0007'], + ['ETH', 'ARB', '0xf92402bb795fd7cd08fb83839689db79099c8c9c'], + ['AVAX', 'AVAX', '0x978b21a854dbefcd6d51dfd269875d158046240b'], + ['USDC', 'AVAX', '0x978b21a854dbefcd6d51dfd269875d158046240b'], + ['USDT', 'AVAX', '0x978b21a854dbefcd6d51dfd269875d158046240b'], + ['AVAX', 'AVAX', '0xcddc5d0ebeb71a08fff26909aa6c0d4e256b4fe1'], + ['USDC', 'AVAX', '0xcddc5d0ebeb71a08fff26909aa6c0d4e256b4fe1'], + ['USDT', 'AVAX', '0xcddc5d0ebeb71a08fff26909aa6c0d4e256b4fe1'], + ['AVAX', 'AVAX', '0x6d8be5cdf0d7dee1f04e25fd70b001ae3b907824'], + ['USDC', 'AVAX', '0x6d8be5cdf0d7dee1f04e25fd70b001ae3b907824'], + ['USDT', 'AVAX', '0x6d8be5cdf0d7dee1f04e25fd70b001ae3b907824'], + ['AVAX', 'AVAX', '0x3bce63c6c9abf7a47f52c9a3a7950867700b0158'], + ['USDC', 'AVAX', '0x3bce63c6c9abf7a47f52c9a3a7950867700b0158'], + ['USDT', 'AVAX', '0x3bce63c6c9abf7a47f52c9a3a7950867700b0158'], + ['AVAX', 'AVAX', '0xaba2d404c5c41da5964453a368aff2604ae80a14'], + ['USDC', 'AVAX', '0xaba2d404c5c41da5964453a368aff2604ae80a14'], + ['USDT', 'AVAX', '0xaba2d404c5c41da5964453a368aff2604ae80a14'], + ['ETH', 'BASE', '0x3304e22ddaa22bcdc5fca2269b418046ae7b566a'], + ['USDC', 'BASE', '0x3304e22ddaa22bcdc5fca2269b418046ae7b566a'], + ['ETH', 'ETH', '0x1b46970cfe6a271e884f636663c257a5a571fb2c'], + ['MATIC', 'MATIC', '0x505e71695e9bc45943c58adec1650577bca68fd9'], + ['USDT', 'MATIC', '0x505e71695e9bc45943c58adec1650577bca68fd9'], + ['USDT', 'TRX', 'TRGCqsUXeynKTgynp2j9g3sg7Nux2KtB3u'], ] function getAddresses(chain) { diff --git a/projects/bitindi-dex/index.js b/projects/bitindi-dex/index.js index 1361308727f0..f2d20355d2a1 100644 --- a/projects/bitindi-dex/index.js +++ b/projects/bitindi-dex/index.js @@ -1,5 +1,4 @@ const { uniTvlExport } = require('../helper/unknownTokens') module.exports = uniTvlExport('bitindi', '0x87cef801D44D6eDa8106087e7676153c30e36950', true) module.exports.bitindi.tvl = () => ({}) - - // deadFrom: '2023-12-20', \ No newline at end of file +module.exports.deadFrom = '2023-12-20' \ No newline at end of file diff --git a/projects/bitindi/index.js b/projects/bitindi/index.js index 1f778d86113b..934a9979f192 100644 --- a/projects/bitindi/index.js +++ b/projects/bitindi/index.js @@ -1,4 +1,3 @@ -const ADDRESSES = require('../helper/coreAssets.json') const { staking } = require('../helper/staking') module.exports = { @@ -11,5 +10,5 @@ module.exports = { staking: () => ({}), // staking: staking('0x140c312c8841B0a7152946C0Bc2BD343bA51bbcc', ADDRESSES.bitindi.WBNI), }, - // deadFrom: '2023-12-20', + deadFrom: '2023-12-20', }; diff --git a/projects/blasterswap-vaults/index.js b/projects/blasterswap-vaults/index.js new file mode 100644 index 000000000000..236a7a7ecc61 --- /dev/null +++ b/projects/blasterswap-vaults/index.js @@ -0,0 +1,11 @@ +const { stakings } = require("../helper/staking.js"); + +const vaults = ['0x0464a36beCf9967111D2dCAb57CAf4a2376f6E3F', '0xC52fb7E613e401a0195C2fdB369618580D58C91D', '0x013249266842e078999088807033D80531A84260']; +const tokens = ['0xb1a5700fa2358173fe465e6ea4ff52e36e88e2ad', '0xd43D8aDAC6A4C7d9Aeece7c3151FcA8f23752cf8', '0x5ffd9EbD27f2fcAB044c0f0a26A45Cb62fa29c06']; + +module.exports = { + blast: { + tvl: () => ({}), + staking: stakings(vaults, tokens) + }, +} diff --git a/projects/bmx/index.js b/projects/bmx/index.js index 3be3d0e83662..727c569a4754 100644 --- a/projects/bmx/index.js +++ b/projects/bmx/index.js @@ -1,12 +1,27 @@ const { staking } = require("../helper/staking"); const { gmxExports } = require("../helper/gmx"); -const sdk = require('@defillama/sdk') -const vaultAddress = "0xec8d8D4b215727f3476FF0ab41c406FA99b4272C"; +const vaultAddresses = { + base: "0xec8d8D4b215727f3476FF0ab41c406FA99b4272C", + mode: "0xff745bdB76AfCBa9d3ACdCd71664D4250Ef1ae49" +}; +const stakingAddresses = { + base: "0x3085F25Cbb5F34531229077BAAC20B9ef2AE85CB", + mode: "0x773F34397d5F378D993F498Ee646FFe4184E00A3" +}; +const tokenAddresses = { + base: "0x548f93779fBC992010C07467cBaf329DD5F059B7", + mode: "0x66eEd5FF1701E6ed8470DC391F05e27B1d0657eb" +}; module.exports = { - methodology: "BMX liquidity is calculated by the value of tokens in the BLT pool.", + methodology: "BMX Classic liquidity is calculated by the value of tokens in the BLT/MLT pool. TVL also includes BMX staked.", base: { - tvl: gmxExports({ vault: vaultAddress }) + tvl: gmxExports({ vault: vaultAddresses.base }), + staking: staking(stakingAddresses.base, tokenAddresses.base) }, + mode: { + tvl: gmxExports({ vault: vaultAddresses.mode }), + staking: staking(stakingAddresses.mode, tokenAddresses.mode) + } }; diff --git a/projects/bouncebit-EasyBTC/index.js b/projects/bouncebit-EasyBTC/index.js new file mode 100644 index 000000000000..c6507609f9cd --- /dev/null +++ b/projects/bouncebit-EasyBTC/index.js @@ -0,0 +1,38 @@ +const { sumTokens, sumTokensExport } = require('../helper/sumTokens'); +const ADDRESSES = require('../helper/coreAssets.json') + +const ETH_EasyBTC_USD_Contract = '0xFe32277D00e57D864B8BC687d0a442D663Aa1dF6' + +const BNB_EasyBTC_USD_Contract = '0xF3FB36F32Dad91627f688e7332472d69F6C985c6' +const BNB_EasyBTC_BTC_Contract = '0x38D239a8D33BF7424A1Df6d39cb8523cCc25DE0e' + +const STAKE_ABI = + "function totalStaked() view returns (uint256)"; + +async function ETHTvl(api, ...args) { + const EasyBTC_USD_Staked = await api.call({ abi: STAKE_ABI, target: ETH_EasyBTC_USD_Contract}) + // usdt + api.add(ADDRESSES.ethereum.USDT, EasyBTC_USD_Staked) + return sumTokens({ + api + }) +} + +async function BNBTvl(api, ...args) { + const EasyBTC_USD_Staked = await api.call({ abi: STAKE_ABI, target: BNB_EasyBTC_USD_Contract}) + const EasyBTC_BTC_Staked = await api.call({ abi: STAKE_ABI, target: BNB_EasyBTC_BTC_Contract}) + // usdt + api.add(ADDRESSES.bsc.USDT, EasyBTC_USD_Staked) + // btc + api.add(ADDRESSES.bsc.BTCB, EasyBTC_BTC_Staked) + return sumTokens({ api }) +} + +module.exports = { + ethereum: { + tvl: ETHTvl, + }, + bsc: { + tvl: BNBTvl, + } +}; diff --git a/projects/buzz-farming/index.js b/projects/buzz-farming/index.js new file mode 100644 index 000000000000..158f1ddda7db --- /dev/null +++ b/projects/buzz-farming/index.js @@ -0,0 +1,22 @@ +const {sumTokensExport} = require('../helper/sumTokens'); +const ADDRESSES = require('../helper/coreAssets.json') + +const ADDRESSES_BSQUARED_BSTONE = '0x7537C1F80c9E157ED7AFD93a494be3e1f04f1462'; +const ADDRESSES_BSQUARED_FDUSD = '0xC2Fe4f673455Ef92299770a09CDB5E8756A525D5'; +const ADDRESSES_BSQUARED_MATIC = '0xc3ee2Df14B1Bc526c24ED802f1873d49664a0d5c'; +const ADDRESSES_BSQUARED_ORDI = '0xa0f4470B714677AEEcE0d20074c540b3Cf6a477E'; +const ADDRESSES_BSQUARED_SATS = '0x7eBFcE05E418C380a2b6EB0F65995cA04ef4bc00'; +const ADDRESSES_BSQUARED_FBTC = '0x5d247f32b792a61f7b4078cf7752a878aff152e2'; +const ADDRESSES_BSQUARED_UBTC = '0x796e4d53067ff374b89b2ac101ce0c1f72ccaac2'; +const ADDRESSES_BSQUARED_USDA = '0x46fecc5bef70615ee3bfdbd2b278944368b78cf5'; +const ADDRESSES_BSQUARED_ETH = '0xd48d3a551757ac47655fce25bde1b0b6b1cb2a5a'; + +const tokenList = [ADDRESSES.null, ADDRESSES.bsquared.USDT, ADDRESSES.bsquared.USDC, ADDRESSES.bsquared.WBTC, ADDRESSES_BSQUARED_BSTONE, ADDRESSES_BSQUARED_FDUSD, ADDRESSES_BSQUARED_MATIC, ADDRESSES_BSQUARED_ORDI, ADDRESSES_BSQUARED_SATS, ADDRESSES_BSQUARED_FBTC, ADDRESSES_BSQUARED_UBTC, ADDRESSES_BSQUARED_USDA, ADDRESSES_BSQUARED_ETH,]; + + +module.exports = { + hallmarks: [], + methodology: "Buzz Farming collaborates with well-known BTCFi projects such as Babylon, Lombard, and Bedrock, as well as prominent blockchains, offering users a variety of multifaceted profit strategies. Users can conveniently select and operate investment strategies through Buzz Farming.", + + bsquared: {tvl: sumTokensExport({owner: '0xe677F4B6104726D76DeBc681d7a862CE269aA8F3', tokens: tokenList})}, +} diff --git a/projects/bybit/index.js b/projects/bybit/index.js index 401232ace72b..dfbdf54ffa97 100644 --- a/projects/bybit/index.js +++ b/projects/bybit/index.js @@ -16,7 +16,9 @@ const config = { 'bc1q9w4g79ndel72lygvwtqzem67z6uqv4yncvqjz3yn8my9swnwflxsutg4cx', 'bc1qjysjfd9t9aspttpjqzv68k0ydpe7pvyd5vlyn37868473lell5tqkz456m', '1GrwDkr33gT6LuumniYjKEGjTLhsL5kmqC', - 'bc1qs5vdqkusz4v7qac8ynx0vt9jrekwuupx2fl5udp9jql3sr03z3gsr2mf0f' + 'bc1qs5vdqkusz4v7qac8ynx0vt9jrekwuupx2fl5udp9jql3sr03z3gsr2mf0f', + // added on the 15th of july 2024. + 'bc1qa2eu6p5rl9255e3xz7fcgm6snn4wl5kdfh7zpt05qp5fad9dmsys0qjg0e' ] }, bsc: { diff --git a/projects/cian-lst/index.js b/projects/cian-lst/index.js index aba79f511887..8c63ebd9051c 100644 --- a/projects/cian-lst/index.js +++ b/projects/cian-lst/index.js @@ -3,7 +3,7 @@ const config = { "0xcDd374F491fBF3f4FcF6E9023c99043774005137", "0xB8c0c50D255B93f5276549cbA7F4bf78751A5D34", "0x88508306E43FCe43F7f2c1e7D73c88cf6a523f6C", - "0xD34f59E172cF3915f56C96A3037Ac554A7399D77", + "0xD34f59E172cF3915f56C96A3037Ac554A7399D77", // PYUSD Optimized Long-Short (variant 1) ], optimism: ["0x907883da917ca9750ad202ff6395C4C6aB14e60E"], bsc: ["0xEa5f10A0E612316A47123D818E2b597437D19a17"], @@ -19,7 +19,7 @@ module.exports = { Object.keys(config).forEach((chain) => { module.exports[chain] = { tvl: async (api) => { - return api.erc4626Sum({ calls: config[chain], isOG4626: true }); + return api.erc4626Sum({ calls: config[chain], isOG4626: true, permitFailure:true }); }, }; }); diff --git a/projects/clearpool-rwa/index.js b/projects/clearpool-rwa/index.js new file mode 100644 index 000000000000..9d2fecc999b8 --- /dev/null +++ b/projects/clearpool-rwa/index.js @@ -0,0 +1,21 @@ +const { sumTokens2 } = require("../helper/unwrapLPs") + +const config = { + ethereum: [ + '0x7a486f809c952a6f8dec8cb0ff68173f2b8ed56c', // USDX + ], + flare: [ + '0x4a771cc1a39fdd8aa08b8ea51f7fd412e73b3d2b', // USDX + ] +} + +Object.keys(config).forEach(chain => { + const tokens = config[chain] + module.exports[chain] = { + tvl: async (api) => { + const supply = await api.multiCall({ abi: 'erc20:totalSupply', calls: tokens}) + api.add(tokens, supply) + return sumTokens2({ api }) + } + } +}) \ No newline at end of file diff --git a/projects/clearpool/index.js b/projects/clearpool/index.js index 0fd614a23b10..4ba744f8f8a7 100644 --- a/projects/clearpool/index.js +++ b/projects/clearpool/index.js @@ -1,14 +1,15 @@ -const abi = require("./abi.json"); +const abi = require("./abi.json") -const { stakings } = require("../helper/staking"); -const { getLogs } = require("../helper/cache/getLogs"); +const { stakings } = require("../helper/staking") +const { getLogs } = require("../helper/cache/getLogs") +const { sumTokens2 } = require("../helper/unwrapLPs") -const singleStakingContracts = ["0x629E39da1Db5654fe59cAE31d48CAEBB8dC2A9c6"]; -const CPOOL = "0x66761fa41377003622aee3c7675fc7b5c1c2fac5"; +const singleStakingContracts = ["0x629E39da1Db5654fe59cAE31d48CAEBB8dC2A9c6"] +const CPOOL = "0x66761fa41377003622aee3c7675fc7b5c1c2fac5" module.exports = { methodology: "We count liquidity by Stables deposited on the pools contracts", -}; +} const CHAIN = { ARBITRUM: "arbitrum", @@ -20,7 +21,11 @@ const CHAIN = { FLARE: "flare", BASE: "base", MANTLE: "mantle", -}; +} + +const blacklistedTokens = { + flare: ['0x4a771cc1a39fdd8aa08b8ea51f7fd412e73b3d2b'], +} const config = { [CHAIN.ETHEREUM]: { @@ -97,55 +102,47 @@ const config = { fromBlock: 23711495, }, }, -}; +} const getEventAndABI = (protocol) => { - let borrowFn = ""; - let abi = ""; + let borrowFn + let abi switch (protocol) { case "dynamic": - (abi = - "event PoolCreated(address indexed pool, address indexed owner, address indexed token)"), - (borrowFn = "uint256:borrows"); - break; + abi = "event PoolCreated(address indexed pool, address indexed owner, address indexed token)"; + borrowFn = "uint256:borrows"; break; case "vaults": - (abi = - "event PoolCreated(uint256 depositCap, uint256 repaymentFrequency, uint256 minimumNoticePeriod, uint256 minDeposit, uint256 lendAPR, address indexed asset, address indexed borrower, address pool, address bondNft, bool indexed kycRequired)"), - (borrowFn = "uint256:poolSize"); - break; + abi = "event PoolCreated(uint256 depositCap, uint256 repaymentFrequency, uint256 minimumNoticePeriod, uint256 minDeposit, uint256 lendAPR, address indexed asset, address indexed borrower, address pool, address bondNft, bool indexed kycRequired)"; + borrowFn = "uint256:poolSize"; break; case "treasury": - (abi = - "event PoolCreated(address asset, address treasuryYieldAddress, address manager, bool kycRequired)"), - (borrowFn = "uint256:cash"); - break; + abi = "event PoolCreated(address asset, address treasuryYieldAddress, address manager, bool kycRequired)"; + borrowFn = "uint256:cash"; break; case "prime": - abi = - "event PoolCreated(address pool, address indexed borrower, bool isBulletLoan, address indexed asset, uint256 size, uint256 rateMantissa, uint256 tenor, uint256 depositWindow, uint256 spreadRate, uint256 originationRate, uint256 incrementPerRoll, uint256 penaltyRatePerYear)"; - borrowFn = "uint256:currentSize"; - break; + abi = "event PoolCreated(address pool, address indexed borrower, bool isBulletLoan, address indexed asset, uint256 size, uint256 rateMantissa, uint256 tenor, uint256 depositWindow, uint256 spreadRate, uint256 originationRate, uint256 incrementPerRoll, uint256 penaltyRatePerYear)" + borrowFn = "uint256:currentSize"; break; } - return { borrowFn, abi }; -}; + return { borrowFn, abi } +} const prepareProtocolsPerChain = (chain) => { - let contracts = []; - const protocols = Object.keys(config[chain]); + let contracts = [] + const protocols = Object.keys(config[chain]) protocols.forEach((protocol) => { - const { fromBlock, factory } = config[chain][protocol]; - const { abi, borrowFn } = getEventAndABI(protocol); + const { fromBlock, factory } = config[chain][protocol] + const { abi, borrowFn } = getEventAndABI(protocol) contracts.push({ fromBlock, factory, abi, borrowFn, protocol, - }); - }); - return contracts; -}; + }) + }) + return contracts +} Object.keys(config).forEach((chain) => { - const dataPerChain = prepareProtocolsPerChain(chain); + const dataPerChain = prepareProtocolsPerChain(chain) const _getLogs = async (api, factory, fromBlock, abi, protocol) => { const logs = await getLogs({ api, @@ -153,43 +150,43 @@ Object.keys(config).forEach((chain) => { fromBlock, eventAbi: abi, onlyArgs: true, - }); + }) const pools = logs.map((log) => protocol == "treasury" ? log.treasuryYieldAddress : log.pool - ); + ) const tokens = logs.map((log) => protocol == "dynamic" ? log.token : log.asset - ); - return { pools, tokens }; - }; + ) + return { pools, tokens } + } const tvl = async (api) => { - let allTokens = []; - let allPools = []; + let allTokens = [] + let allPools = [] const promiseArray = dataPerChain.map( - async ({ factory, fromBlock, abi, borrowFn, protocol }) => { + async ({ factory, fromBlock, abi, protocol }) => { const { pools, tokens } = await _getLogs( api, factory, fromBlock, abi, protocol - ); - allTokens.push(...tokens); - allPools.push(...pools); + ) + allTokens.push(...tokens) + allPools.push(...pools) } - ); + ) - await Promise.all(promiseArray); + await Promise.all(promiseArray) - return api.sumTokens({ tokensAndOwners2: [allTokens, allPools] }); - }; + return sumTokens2({ api, tokensAndOwners2: [allTokens, allPools], blacklistedTokens: blacklistedTokens[chain]}) + } const borrowed = async (api) => { - const balances = []; - const allTokens = []; + const balances = [] + const allTokens = [] const promiseArray = dataPerChain.map( async ({ factory, fromBlock, abi, borrowFn, protocol }) => { @@ -199,17 +196,20 @@ Object.keys(config).forEach((chain) => { fromBlock, abi, protocol - ); - const bals = await api.multiCall({ abi: borrowFn, calls: pools }); - balances.push(...bals); - allTokens.push(...tokens); + ) + const bals = await api.multiCall({ abi: borrowFn, calls: pools }) + balances.push(...bals) + allTokens.push(...tokens) } - ); - await Promise.all(promiseArray); + ) + await Promise.all(promiseArray) - return api.addTokens(allTokens, balances); - }; - module.exports[chain] = { tvl, borrowed }; -}); + api.addTokens(allTokens, balances) + if (blacklistedTokens[chain]) { + blacklistedTokens[chain].forEach((token) => api.removeTokenBalance(token)) + } + } + module.exports[chain] = { tvl, borrowed } +}) -module.exports.ethereum.staking = stakings(singleStakingContracts, CPOOL); +module.exports.ethereum.staking = stakings(singleStakingContracts, CPOOL) diff --git a/projects/crust-finance-v2/index.js b/projects/crust-finance-v2/index.js new file mode 100644 index 000000000000..245f21840747 --- /dev/null +++ b/projects/crust-finance-v2/index.js @@ -0,0 +1,8 @@ +const { uniV3Export } = require("../helper/uniswapV3"); + +module.exports = uniV3Export({ + mantle: { + factory: "0xEaD128BDF9Cff441eF401Ec8D18a96b4A2d25252", + fromBlock: 62692352, + }, +}) \ No newline at end of file diff --git a/projects/cygnus-finance/index.js b/projects/cygnus-finance/index.js index f8ea66b61188..a4a696fe38b8 100644 --- a/projects/cygnus-finance/index.js +++ b/projects/cygnus-finance/index.js @@ -1,14 +1,45 @@ -const CGUSD_CONTRACT = "0xCa72827a3D211CfD8F6b00Ac98824872b72CAb49"; -const START_TIME = 1708351200; +const { call } = require("../helper/chain/ton") +const { get } = require('../helper/http') -async function tvl(api) { - await api.erc4626Sum({ calls: [CGUSD_CONTRACT], balanceAbi: 'getTotalPooledAssets', tokenAbi: "asset" }); +const CGUSD_CONTRACT = "0xCa72827a3D211CfD8F6b00Ac98824872b72CAb49" +const START_TIME = 1708351200 + +async function baseTvl(api) { + await api.erc4626Sum({ calls: [CGUSD_CONTRACT], balanceAbi: 'getTotalPooledAssets', tokenAbi: "asset" }) +} + +// helper function of getting jetton metadata +async function getJettonMetadata(addr) { + const res = await get(`https://tonapi.io/v2/jettons/${addr}`) + return res +} + +async function tonTvl() { + const MINTER_ADDRESS = "EQCfvQW-thWpqKgyqtXCFbYayDlHqS0-frkyP6VD70paLFZa" + const CGUSDT_ADDRESS = 'EQBIBw3mF_TDMJqWAZihVsyUBMWpWw_deftZLiCxTmrCUOKy' + + + const minterResult = await call({ target: MINTER_ADDRESS, abi: "get_minter_data", stack: [] }) + // exchange rate from cgUSDT to USDT: decimal 9 + const cgusdtTousdt = (minterResult[5]) / 10 ** 9 + + // cgUSDT total supply: decimal 6 + const jettonResult = await getJettonMetadata(CGUSDT_ADDRESS) + const cgUsdtTotalSupply = jettonResult['total_supply'] + + // caculate tvl + const tvl = (cgUsdtTotalSupply) / 10 ** 6 * cgusdtTousdt + return { "coingecko:tether": tvl } } + module.exports = { - methodology: "Calculates the total cgUSD Supply", + methodology: "Calculates the total cgUSD and cgUSDT Supply", start: START_TIME, base: { - tvl, + tvl: baseTvl, }, + ton: { + tvl: tonTvl + } }; diff --git a/projects/dexfinance-vault/abi.js b/projects/dexfinance-vault/abi.js new file mode 100644 index 000000000000..079d42ce2799 --- /dev/null +++ b/projects/dexfinance-vault/abi.js @@ -0,0 +1,25 @@ +exports.abi = { + factory: { + vaultsLength: "function vaultsCount() view returns (uint256)", + vaults: "function vaults(uint256 index) view returns (address)", + farmCalculationConnector: + "function farmCalculationConnector(address) view returns (address)", + }, + vault: { + liquidity: "function liquidity(address) view returns (uint256 liquidity_)", + farmsLength: "uint256:farmsCount", + farmConnector: "function farmConnector(address) view returns (address)", + farms: + "function farms(uint256 index) view returns (tuple(address beacon, uint256 percent, bytes data))", + }, + farm: { + stakingToken: "function stakingToken() view returns (address)", + farm: "address:farm", + type: "string:stakingTokenType", + tokenId: "uint256:tokenId", + stakingTokenLiquidity: + "function stakingTokenLiquidity(uint256 tokenId_) view returns (uint256 liquidity_)", + stakingTokenData: + "function stakingTokenData() view returns ((string stakingTokenType, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, (uint256 sqrtPriceX96LowInit, uint256 sqrtPriceX96UpInit, uint256 sqrtPriceX96LowLimit, uint256 sqrtPriceX96UpLimit, uint256 sqrtPriceX96ApproxPricePercent, uint256 sqrtPriceX96ShiftPercentLow, uint256 sqrtPriceX96ShiftPercentUp, uint256 sqrtPriceX96DefaultShiftPercentLow, uint256 sqrtPriceX96DefaultShiftPercentUp) pricesData, (address tokenIn, address tokenOut)[] swapsToken0ToNative, (address tokenIn, address tokenOut)[] swapsToken1ToNative, (address tokenIn, address tokenOut)[] swapsNativeToToken0, (address tokenIn, address tokenOut)[] swapsNativeToToken1))", + } +}; diff --git a/projects/dexfinance-vault/index.js b/projects/dexfinance-vault/index.js new file mode 100644 index 000000000000..6132575bf44f --- /dev/null +++ b/projects/dexfinance-vault/index.js @@ -0,0 +1,133 @@ +const { sumTokens2, addUniV3LikePosition } = require("../helper/unwrapLPs"); +const { abi } = require("./abi"); + +const CONFIG = { + optimism: { + factory: "0xd4f1a99212e5be72426bde45abadef66d7d6edf3", + }, + fantom: { + factory: "0x9b7e30644a9b37eebaa7158129b03f5a3088659d", + }, + pulse: { + factory: "0xac297968C97EF5686c79640960D106f65C307a37", + USDEX_PLUS: "0xaa2c47a35c1298795b5271490971ec4874c8e53d", + }, + base: { + factory: "0x714c94b9820d7d73e61510e4c18b91f995a895c1", + }, + arbitrum: { + factory: "0xe31fceaf93667365ce1e9edad3bed4a7dd0fc01a", + USDEX_PLUS: "0x4117EC0A779448872d3820f37bA2060Ae0B7C34B", + gDEX: "0x92a212d9f5eef0b262ac7d84aea64a0d0758b94f" + }, + avax: { + factory: "0x6b714e6296b8b977e1d5ecb595197649e10a3db1", + }, + bsc: { + factory: "0x3ace08b10b5c08a17d1c46277d65c81249e65f44", + }, + manta: { + factory: "0x714C94B9820D7D73e61510e4C18B91F995A895C1", + USDEX_PLUS: '0x6da9ebd271a0676f39c088a2b5fd849d5080c0af', + }, +}; + +const getVaults = async (api, factory) => { + const vaults = await api.fetchList({ lengthAbi: abi.factory.vaultsLength, itemAbi: abi.factory.vaults, target: factory, }); + const farmsAll = await api.fetchList({ lengthAbi: abi.vault.farmsLength, itemAbi: abi.vault.farms, targets: vaults, groupedByInput: true }) + const items = [] + vaults.map((vault, i) => items.push(farmsAll[i].map((farm) => ({ vault, farm })))) + return items.flat() +}; + +const getVaultsConnectors = async (api, factory, vaultFarms) => { + const connectorsCalls = vaultFarms.map(({ farm, vault }) => ({ params: farm.beacon, target: vault, })); + const calculationConnectorCalls = vaultFarms.map(({ farm }) => farm.beacon); + const connectors = await api.multiCall({ abi: abi.vault.farmConnector, calls: connectorsCalls }) + const calculationConnectors = await api.multiCall({ abi: abi.factory.farmCalculationConnector, calls: calculationConnectorCalls, target: factory }) + + vaultFarms.forEach((item, i) => { + delete item.farm.data + item.connector = connectors[i] + item.calculationConnector = calculationConnectors[i] + }) +} + +const getVaultsDatas = async (api, vaultFarms) => { + const calls = vaultFarms.map(({ connector }) => connector) + const liquidityCalls = vaultFarms.map(({ calculationConnector, connector }) => ({ target: calculationConnector, params: [connector] })) + + const [types, stakingTokens, liquidities] = + await Promise.all([ + api.multiCall({ calls, abi: abi.farm.type }), + api.multiCall({ calls, abi: abi.farm.stakingToken }), + api.multiCall({ calls: liquidityCalls, abi: abi.vault.liquidity }), + ]); + + vaultFarms.forEach((item, i) => { + item.type = types[i] + item.stakingToken = stakingTokens[i] + item.liquidity = liquidities[i] + }) +}; + +const groupBy = (array, keyFn) => { + return array.reduce((acc, item) => { + const key = keyFn(item); + if (!acc[key]) { + acc[key] = []; + } + acc[key].push(item); + return acc; + }, {}); +}; + +const lpv2Balances = async (api, farms) => { + farms.forEach(({ stakingToken, liquidity }) => { + api.add(stakingToken, liquidity); + }); +}; + +async function addERC721Data(api, vaultFarms) { + const positionIds = await api.multiCall({ abi: abi.farm.tokenId, calls: vaultFarms.map(i => i.connector) }) + const nftPositionMapping = {} + vaultFarms.forEach((item, i) => { + if (!+positionIds[i]) + return; + + const nft = item.stakingToken.toLowerCase() + if (!nftPositionMapping[nft]) nftPositionMapping[nft] = [] + nftPositionMapping[nft].push(positionIds[i]) + }) + for (const [nftAddress, positionIds] of Object.entries(nftPositionMapping)) + await sumTokens2({ api, uniV3ExtraConfig: { nftAddress, positionIds, } }) +} + +const tvl = async (api) => { + const { factory, USDEX_PLUS, gDEX } = CONFIG[api.chain]; + const vaultFarms = await getVaults(api, factory); + await getVaultsConnectors(api, factory, vaultFarms); + await getVaultsDatas(api, vaultFarms); + const sortedFarms = groupBy(vaultFarms, ({ type }) => `${type}`); + + const lpv2Farms = Object.keys(sortedFarms) + .filter((key) => !key.includes("ERC721")) + .flatMap((key) => sortedFarms[key]); + + const lpv3Farms = Object.keys(sortedFarms) + .filter((key) => key.includes("ERC721")) + .flatMap((key) => sortedFarms[key]); + + await Promise.all([ + lpv2Balances(api, lpv2Farms), + addERC721Data(api, lpv3Farms) + ]) + + await sumTokens2({ api, resolveLP: true }); + if (USDEX_PLUS) api.removeTokenBalance(USDEX_PLUS); + if (gDEX) api.removeTokenBalance(gDEX); +}; + +Object.keys(CONFIG).forEach((chain) => { + module.exports[chain] = { tvl, }; +}) \ No newline at end of file diff --git a/projects/dopex-clamm/index.js b/projects/dopex-clamm/index.js index 1ef388f526a5..2c0ee7ac8663 100644 --- a/projects/dopex-clamm/index.js +++ b/projects/dopex-clamm/index.js @@ -1,94 +1,89 @@ -const { blockQuery } = require("../helper/http"); -const wildCreditABI = require('../wildcredit/abi.json'); -const { getLogs } = require('../helper/cache/getLogs') -const DopexV2ClammFeeStrategy = '0xC808AcB06077174333b31Ae123C33c6559730035' - -const query = (skip = 0, limit = 1000) => `query ($block: Int) { - strikes( - block: {number: $block} - first: ${limit} - skip: ${skip} - where: {totalLiquidity_gt: 100} - orderBy: totalLiquidity - orderDirection: desc - ) { - pool - token0 { id } - token1 { id } - tickLower - tickUpper - totalLiquidity +const { gql, request } = require('graphql-request'); + +const endpoint = 'https://api.0xgraph.xyz/subgraphs/name/dopex-v2-clamm-public'; +const abi = "function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)" + +const query = gql` + query strikes($limit: Int!, $skip: Int!) { + strikes( + first: $limit + skip: $skip + where: { totalLiquidity_gt: "100" } + orderBy: totalLiquidity + orderDirection: desc + ) { + pool + token0 {id} + token1 {id} + tickLower + tickUpper + totalLiquidity + } + } +`; + +async function fetchStrikes(limit, skip, allData = []) { + const variables = { limit, skip }; + const { strikes } = await request(endpoint, query, variables); + allData.push(...strikes); + + if (strikes.length === limit) { + return fetchStrikes(limit, skip + limit, allData); + } + + return allData; +} + +function addV3PositionBalances(strike, sqrtPricesMap) { + const tickToPrice = (tick) => 1.0001 ** tick + const token0 = strike.token0.id + const token1 = strike.token1.id + const liquidity = strike.totalLiquidity + const bottomTick = +strike.tickLower + const topTick = +strike.tickUpper + const tick = +sqrtPricesMap[strike.pool.toLowerCase()].tick + const sa = tickToPrice(bottomTick / 2) + const sb = tickToPrice(topTick / 2) + + let amount0 = 0 + let amount1 = 0 + + if (tick < bottomTick) { + amount0 = liquidity * (sb - sa) / (sa * sb) + } else if (tick < topTick) { + const price = tickToPrice(tick) + const sp = price ** 0.5 + + amount0 = liquidity * (sb - sp) / (sp * sb) + amount1 = liquidity * (sp - sa) + } else { + amount1 = liquidity * (sb - sa) } -}` + + return { token0, amount0, token1, amount1 } +} async function tvl(api) { - const allData = [] - let hasMore = true - let skip = 0 - let limit = 1000 - do { - const { strikes } = await blockQuery("http://api.0xgraph.xyz/subgraphs/name/dopex-v2-clamm-public", query(skip, limit), { api }) - skip += limit - allData.push(...strikes) - hasMore = strikes.length === limit - } while (hasMore) + const limit = 1000; + const allData = await fetchStrikes(limit, 0); let pools = allData.map(strike => strike.pool.toLowerCase()) pools = [...new Set(pools)] - const sqrtPrices = await api.multiCall({ calls: pools, abi: wildCreditABI.slot0, }) + const sqrtPrices = await api.multiCall({ calls: pools, abi }) const sqrtPricesMap = sqrtPrices.reduce((acc, item, i) => { return { ...acc, [pools[i]]: item, } }, {}); - allData.map(addV3PositionBalances) - - // const logs = await getLogs({ - // api, - // target: DopexV2ClammFeeStrategy, - // eventAbi: 'event OptionMarketRegistered (address optionMarket)', - // onlyArgs: true, - // fromBlock: 149751550, - // }) - // const markets = logs.map(log => log.optionMarket) - // const callAssets = await api.multiCall({ abi: 'address:callAsset', calls: markets }) - // const putAssets = await api.multiCall({ abi: 'address:putAsset', calls: markets }) - // const ownerTokens = markets.map((v, i) => [[callAssets[i], putAssets[i]], v]) - // return api.sumTokens({ ownerTokens}) - - return api.getBalances() - - - function addV3PositionBalances(strike) { - const tickToPrice = (tick) => 1.0001 ** tick - - const token0 = strike.token0.id - const token1 = strike.token1.id - const liquidity = strike.totalLiquidity - const bottomTick = +strike.tickLower - const topTick = +strike.tickUpper - const tick = +sqrtPricesMap[strike.pool.toLowerCase()].tick - const sa = tickToPrice(bottomTick / 2) - const sb = tickToPrice(topTick / 2) - - let amount0 = 0 - let amount1 = 0 - - if (tick < bottomTick) { - amount0 = liquidity * (sb - sa) / (sa * sb) - } else if (tick < topTick) { - const price = tickToPrice(tick) - const sp = price ** 0.5 - - amount0 = liquidity * (sb - sp) / (sp * sb) - amount1 = liquidity * (sp - sa) - } else { - amount1 = liquidity * (sb - sa) - } - api.add(token0, amount0) - api.add(token1, amount1) - } + allData.forEach((strike) => { + const { token0, amount0, token1, amount1 } = addV3PositionBalances(strike, sqrtPricesMap); + api.add(token0, amount0); + api.add(token1, amount1); + }); } + module.exports = { doublecounted: true, // tokens are stored in UNI-V3 pools arbitrum: { tvl, }, }; + + diff --git a/projects/dsu-money/index.js b/projects/dsu-money/index.js index cb047b6c10c5..9f6726577852 100644 --- a/projects/dsu-money/index.js +++ b/projects/dsu-money/index.js @@ -12,6 +12,7 @@ module.exports = { arbitrum: { tvl: sumTokensExport({ tokensAndOwners: [ [ADDRESSES.arbitrum.USDC, '0x0d49c416103cbd276d9c3cd96710db264e3a0c27'], + [ADDRESSES.arbitrum.USDC_CIRCLE, '0x0d49c416103cbd276d9c3cd96710db264e3a0c27'], ]}) } } diff --git a/projects/ducata/index.js b/projects/ducata/index.js new file mode 100644 index 000000000000..47b8fe04f383 --- /dev/null +++ b/projects/ducata/index.js @@ -0,0 +1,11 @@ +const { onChainTvl } = require('../helper/balancer') + +const vault = "0x25898DEe0634106C2FcBB51B3DB5b14aA1c238a4"; +const launchBlock = 230182440; + +module.exports = { + methodology: 'TVL counts the external assets deposited in the vaults', + arbitrum: { + tvl: onChainTvl(vault, launchBlock), + } + }; \ No newline at end of file diff --git a/projects/electrowizy/index.js b/projects/electrowizy/index.js index 3abb551ff082..1bc784f1e6aa 100644 --- a/projects/electrowizy/index.js +++ b/projects/electrowizy/index.js @@ -2,6 +2,6 @@ const { sumERC4626VaultsExport } = require('../helper/erc4626') module.exports = { polygon: { - tvl: sumERC4626VaultsExport({ vaults: ['0x41692d4141A98401F3F0CB729D4886AcBD811a66'], balanceAbi: 'uint256:totalStaked', tokenAbi: 'address:stakingToken' }), + tvl: sumERC4626VaultsExport({ vaults: [ '0x663819aB31cB6204a2A732996549B702DeC38aa9'], balanceAbi: 'uint256:totalStaked', tokenAbi: 'address:stakingToken' }), } -} \ No newline at end of file +} diff --git a/projects/ensuro/index.js b/projects/ensuro/index.js index e6c1a9a1addb..47ac5caf0486 100644 --- a/projects/ensuro/index.js +++ b/projects/ensuro/index.js @@ -7,6 +7,7 @@ const addressBook = { aave_v3_usdc: "0x625E7708f30cA75bfd92586e17077590C60eb4cD", // aPolUSDC aave_v2_usdc: "0x1a13F4Ca1d028320A707D99520AbFefca3998b7F", // amUSDC compound_v3_usdc: "0xF25212E676D1F7F89Cd72fFEe66158f541246445", // Compound USDC + mountain_usdm: "0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C", // Mountain USDM reserves: [ // eTokens {name: "eToken Junior Koala", address: "0x8d2Ee82c4172B2138B06b8037d769cBfAf9C0274"}, @@ -21,6 +22,8 @@ const addressBook = { {name: "eToken Junior DLT", address: "0x9078dDdeA2F82c27791EF78A9ec9ab0f66bfb6F9"}, {name: "eToken Junior Otonomi", address: "0x32a9CBeb2cA148E55F327c6B4673351dD03eD858"}, {name: "eToken Junior Bliss", address: "0x71d390C243706b713B5D2b077E942223f7A55d00"}, + {name: "eToken Junior InsureHero", address: "0x15F76F59A29C7c12b4a67751CA525bf9167C1AaB"}, + {name: "eToken Junior Clerity", address: "0x1c7F0c8ba10Db7f2e1c7B5B0A024b66b6baceb45"}, // PremiumsAccounts {name: "PremiumsAccount Koala", address: "0xCCf5C404d32eB6E777088AB13837a1b8dCBA9328"}, {name: "PremiumsAccount Innov Zone", address: "0x4f43B8F252887F814ED689346fdb5Bd266394520"}, @@ -32,6 +35,8 @@ const addressBook = { {name: "PremiumsAccount DLT", address: "0x8908d99a4E2fF6b7Bf4563593B02AcBc7bBfaBC1"}, {name: "PremiumsAccount Otonomi", address: "0xE43587386E6e8FA127dd008770cdC07dE2Df91E9"}, {name: "PremiumsAccount Bliss", address: "0x11b490292799a0edFE37797592F77151C4483442"}, + {name: "PremiumsAccount InsureHero", address: "0x41B5a105C850014eC594879E8511994F25092460"}, + {name: "PremiumsAccount Clerity", address: "0xD26d5015C57C197AE5e7BC866B49837d22364eAB"}, // MultiStrategy Vault - Vault that aggregates assets of several reserves {name: "MultiStrategy Vault", address: "0x1EE585dcea25cbDa16BE8cfeFa381A1F32acA418"}, ], @@ -40,7 +45,7 @@ const addressBook = { async function tvl(api) { const addresses = addressBook[api.chain]; - const ownerTokens = addresses.reserves.map(i => [[addresses.usdc, addresses.aave_v3_usdc, addresses.compound_v3_usdc], i.address]) + const ownerTokens = addresses.reserves.map(i => [[addresses.usdc, addresses.aave_v3_usdc, addresses.compound_v3_usdc, addresses.mountain_usdm], i.address]) return sumTokens2({ api, ownerTokens, }); } diff --git a/projects/etherfi-liquid/index.js b/projects/etherfi-liquid/index.js index ba6a87b35187..2ffb2b3b8dda 100644 --- a/projects/etherfi-liquid/index.js +++ b/projects/etherfi-liquid/index.js @@ -4,8 +4,8 @@ const sdk = require('@defillama/sdk') async function tvl(api) { const optimismApi = new sdk.ChainApi({ chain: 'optimism', timestamp: api.timestamp }) const balETH = await api.call({ - abi: "uint256:totalAssets", - target: '0xea1a6307d9b18f8d1cbf1c3dd6aad8416c06a221', + abi: "uint256:totalSupply", + target: '0xf0bb20865277aBd641a307eCe5Ee04E79073416C', }); await optimismApi.getBlock() const wethBal = await optimismApi.call({ diff --git a/projects/everdex/index.js b/projects/everdex/index.js index c412a4a9f8fb..cf025fc2d024 100644 --- a/projects/everdex/index.js +++ b/projects/everdex/index.js @@ -11,6 +11,10 @@ const tokensAndOwners = [ [ADDRESSES.bfc.UnifiedDAI, '0xa455434802d8B530C77d2B7547eF93C798896581'], [ADDRESSES.bfc.UnifiedUSDC, '0xa455434802d8B530C77d2B7547eF93C798896581'], [ADDRESSES.bfc.UnifiedUSDT, '0xa455434802d8B530C77d2B7547eF93C798896581'], + + // BitcoinUSD - USDC Pool + [ADDRESSES.bfc.BitcoinUSD, '0x840Cf4522ED96CBBEB0924672Ea170456eea3a4c'], + [ADDRESSES.bfc.UnifiedUSDC, '0x840Cf4522ED96CBBEB0924672Ea170456eea3a4c'] ] async function tvl() { diff --git a/projects/everyfinance/index.js b/projects/everyfinance/index.js new file mode 100644 index 000000000000..d782e9014c63 --- /dev/null +++ b/projects/everyfinance/index.js @@ -0,0 +1,20 @@ +const { sumTokens2 } = require("../helper/unwrapLPs"); + +const config = { + ethereum: { managers: ['0xbebbaE6f1062E4Cd5652B9d8e1B8aECBEE993A9E', '0x19d6D19a034BB886507DC08dF99716f418bD61a3', '0xbE721812442C648c191Bc267659374036fd68918'] }, + bsc: { managers: ['0xbebbaE6f1062E4Cd5652B9d8e1B8aECBEE993A9E', '0x19d6D19a034BB886507DC08dF99716f418bD61a3', '0x8849FCE3fB3d82BBF14e1FC9D7E82EAfEB4b2904'] }, + polygon: { managers: ['0x8849FCE3fB3d82BBF14e1FC9D7E82EAfEB4b2904', '0xbE49a740c48F9D4347De8994c488333d492a4e19', '0x9C1A18A734dFAe6e6f89942f358e7270BecdB002'] }, +} + +Object.keys(config).forEach(chain => { + const { managers, } = config[chain] + module.exports[chain] = { + tvl: async (api) => { + const safeHouses = await api.multiCall({ abi: 'address:safeHouse', calls: managers }) + const assetBooks = await api.multiCall({ abi: 'address:assetBook', calls: safeHouses }) + const tokens = await api.fetchList({ lengthAbi: 'getAssetsListSize', itemAbi: 'assetsList', calls: assetBooks, groupedByInput: true, }) + const ownerTokens = tokens.map((t, i) => [t, safeHouses[i]]) + return sumTokens2({ api, ownerTokens, permitFailure: true }) + } + } +}) \ No newline at end of file diff --git a/projects/fathom-CDP/index.js b/projects/fathom-CDP/index.js index d738ba16a476..3c762b4e483e 100644 --- a/projects/fathom-CDP/index.js +++ b/projects/fathom-CDP/index.js @@ -1,9 +1,10 @@ -const WXDCHolders = [ - '0x9B4aCeFE2dB986Ca080Dc01d137e6566dBE0aA3a', // CDP Vault CollateralPoolId "0x5844430000000000000000000000000000000000000000000000000000000000" +const Vaults = [ + '0x9B4aCeFE2dB986Ca080Dc01d137e6566dBE0aA3a', // CDP Vault CollateralPoolId "0x5844430000000000000000000000000000000000000000000000000000000000" XDC + '0x14F2d15cdB7255A7c96973Ce54a269Ac1988cfcf' // CDP Vault CollateralPoolId "0x43474f0000000000000000000000000000000000000000000000000000000000" CGO ]; const { sumTokensExport } = require('../helper/unwrapLPs') const ADDRESSES = require('../helper/coreAssets.json') module.exports = { - xdc: { tvl: sumTokensExport({ owners: WXDCHolders, tokens: [ADDRESSES.xdc.WXDC]}) }, + xdc: { tvl: sumTokensExport({ owners: Vaults, tokens: [ADDRESSES.xdc.WXDC, '0x8f9920283470f52128bf11b0c14e798be704fd15']}) }, } diff --git a/projects/fixes-coins/index.js b/projects/fixes-coins/index.js new file mode 100644 index 000000000000..4cf80a4fc277 --- /dev/null +++ b/projects/fixes-coins/index.js @@ -0,0 +1,91 @@ +// Fixes Inscription Protocol - 𝔉rc20 Treasury Pool: https://fixes.world/ +const { post } = require("../helper/http"); + +let queryTVLCode = ` +import LiquidStaking from 0xd6f80565193ad727 +import stFlowToken from 0xd6f80565193ad727 +// Fixes Imports +import FRC20AccountsPool from 0xd2abb5dbf5e08666 +import FixesFungibleTokenInterface from 0xd2abb5dbf5e08666 +import FixesTokenLockDrops from 0xd2abb5dbf5e08666 +import FixesTradablePool from 0xd2abb5dbf5e08666 +import FRC20Indexer from 0xd2abb5dbf5e08666 + +access(all) +fun main(): UFix64 { + // singleton resource and constants + let acctsPool = FRC20AccountsPool.borrowAccountsPool() + let frc20Indexer = FRC20Indexer.getIndexer() + let stFlowTokenKey = "@".concat(Type<@stFlowToken.Vault>().identifier) + + // dictionary of addresses + let addrsDict = acctsPool.getAddresses(type: FRC20AccountsPool.ChildAccountType.FungibleToken) + // dictionary of tickers and total locked token balances + let tickerTotal: {String: UFix64} = {} + // This is the soft burned LP value which is fully locked in the BlackHole Vault + var flowLockedInBondingCurve = 0.0 + addrsDict.forEachKey(fun (key: String): Bool { + if let addr = addrsDict[key] { + // sum up all locked token balances in LockDrops Pool + if let dropsPool = FixesTokenLockDrops.borrowDropsPool(addr) { + let lockedTokenSymbol = dropsPool.getLockingTokenTicker() + tickerTotal[lockedTokenSymbol] = (tickerTotal[lockedTokenSymbol] ?? 0.0) + dropsPool.getTotalLockedTokenBalance() + } + // sum up all burned LP value in Tradable Pool + if let tradablePool = FixesTradablePool.borrowTradablePool(addr) { + flowLockedInBondingCurve = flowLockedInBondingCurve + tradablePool.getFlowBalanceInPool() + } + } + return true + }) + // sum up all locked token balances in LockDrops Pool + var totalLockingTokenTVL = 0.0 + tickerTotal.forEachKey(fun (key: String): Bool { + let lockedAmount = tickerTotal[key]! + if key == "" { + // this is locked FLOW + totalLockingTokenTVL = totalLockingTokenTVL + lockedAmount + } else if key == "fixes" { + // this is locked FIXES + let price = frc20Indexer.getBenchmarkValue(tick: "fixes") + totalLockingTokenTVL = totalLockingTokenTVL + lockedAmount * price + } else if key == stFlowTokenKey { + // this is locked stFlow + totalLockingTokenTVL = totalLockingTokenTVL + LiquidStaking.calcFlowFromStFlow(stFlowAmount: lockedAmount) + } + return true + }) + return totalLockingTokenTVL + flowLockedInBondingCurve +} +`; + +const queryCodeBase64 = Buffer.from(queryTVLCode, "utf-8").toString("base64"); + +async function tvl() { + try { + const response = await post( + "https://rest-mainnet.onflow.org/v1/scripts", + { script: queryCodeBase64 }, + { + headers: { "content-type": "application/json" }, + } + ); + let resEncoded = response; + let resString = Buffer.from(resEncoded, "base64").toString("utf-8"); + let resJson = JSON.parse(resString); + let flowTokenTVL = Number(resJson.value); + + return { flow: flowTokenTVL }; + } catch (error) { + throw new Error("Couln't query scripts of Fixes coins", error); + } +} + +module.exports = { + timetravel: false, + methodology: + "Counting the $FLOW token locked in Fixes Coins' Bonding Curve, and Fixes Coins' LockDrop Pool.", + flow: { + tvl, + }, +}; diff --git a/projects/flex-powercity-io/index.js b/projects/flex-powercity-io/index.js new file mode 100644 index 000000000000..6e6c7f8899a3 --- /dev/null +++ b/projects/flex-powercity-io/index.js @@ -0,0 +1,28 @@ +const ADDRESSES = require('../helper/coreAssets.json') +const { getLiquityTvl } = require("../helper/liquity.js"); +const { sumTokensExport } = require("../helper/unknownTokens.js"); + +// TroveManager holds total system collateral (deposited HEX) +const TROVE_MANAGER_ADDRESS = "0xC2D0720721d48cE85e20Dc9E01B8449D7eDd14CE"; +const HEX_ADDRESS = ADDRESSES.pulse.HEX; + +// Staking holds LQTY tokens and receive share of protocol revenue +const STAKING_ADDRESS = "0xCeC2c718ceFdb3A515D3CC22e430b46933922CE4"; +const FLEX_ADDRESS = "0x9c6fA17D92898B684676993828143596894AA2A6"; + +const HEXDC_FARMING_ADDRESS = "0x63D134B47692d154C78053117D803e22cB1F7593"; +const LP_HEXDC_HEX_ADDRESS = "0x9756F095DfA27D4c2EAE0937a7b8a6603D99Affb"; + +const FLEX_FARMING_ADDRESS = "0x74F8A9dFefe855Dc97a4A4962b7c6cEc074aED62"; +const LP_FLEX_HEX_ADDRESS = "0x476d63aB94B4E86614Df0C3D5A27E9e22631D062"; +const lps = [LP_HEXDC_HEX_ADDRESS, LP_FLEX_HEX_ADDRESS] + +module.exports = { + start: 1714534195, + methodology: "Total Value Locked includes all Troves, Stability Pool, Staking Pool and LP Farming Pools", + pulse: { + tvl: getLiquityTvl(TROVE_MANAGER_ADDRESS, { collateralToken: HEX_ADDRESS }), + staking: sumTokensExport({ owner: STAKING_ADDRESS, tokens: [FLEX_ADDRESS], lps, useDefaultCoreAssets: true, }), + pool2: sumTokensExport({ owners: [HEXDC_FARMING_ADDRESS, FLEX_FARMING_ADDRESS], tokens: lps, useDefaultCoreAssets: true, }), + } +} \ No newline at end of file diff --git a/projects/fluid/index.js b/projects/fluid/index.js index e4505e99cbfa..1f4e067c8cc9 100644 --- a/projects/fluid/index.js +++ b/projects/fluid/index.js @@ -1,36 +1,79 @@ -const ADDRESSES = require('../helper/coreAssets.json') -const methodologies = require("../helper/methodologies") +const ADDRESSES = require("../helper/coreAssets.json"); +const methodologies = require("../helper/methodologies"); const abi = { - "getOverallTokensData": "function getOverallTokensData(address[] tokens_) view returns ((uint256 borrowRate, uint256 supplyRate, uint256 fee, uint256 lastStoredUtilization, uint256 storageUpdateThreshold, uint256 lastUpdateTimestamp, uint256 supplyExchangePrice, uint256 borrowExchangePrice, uint256 supplyRawInterest, uint256 supplyInterestFree, uint256 borrowRawInterest, uint256 borrowInterestFree, uint256 totalSupply, uint256 totalBorrow, uint256 revenue, (uint256 version, (address token, uint256 kink, uint256 rateAtUtilizationZero, uint256 rateAtUtilizationKink, uint256 rateAtUtilizationMax) rateDataV1, (address token, uint256 kink1, uint256 kink2, uint256 rateAtUtilizationZero, uint256 rateAtUtilizationKink1, uint256 rateAtUtilizationKink2, uint256 rateAtUtilizationMax) rateDataV2) rateData)[] overallTokensData_)" -} + getOverallTokensDataLegacy: + "function getOverallTokensData(address[] tokens_) view returns ((uint256 borrowRate, uint256 supplyRate, uint256 fee, uint256 lastStoredUtilization, uint256 storageUpdateThreshold, uint256 lastUpdateTimestamp, uint256 supplyExchangePrice, uint256 borrowExchangePrice, uint256 supplyRawInterest, uint256 supplyInterestFree, uint256 borrowRawInterest, uint256 borrowInterestFree, uint256 totalSupply, uint256 totalBorrow, uint256 revenue, (uint256 version, (address token, uint256 kink, uint256 rateAtUtilizationZero, uint256 rateAtUtilizationKink, uint256 rateAtUtilizationMax) rateDataV1, (address token, uint256 kink1, uint256 kink2, uint256 rateAtUtilizationZero, uint256 rateAtUtilizationKink1, uint256 rateAtUtilizationKink2, uint256 rateAtUtilizationMax) rateDataV2) rateData)[] overallTokensData_)", + getOverallTokensData: + "function getOverallTokensData(address[] tokens_) view returns ((uint256 borrowRate, uint256 supplyRate, uint256 fee, uint256 lastStoredUtilization, uint256 storageUpdateThreshold, uint256 lastUpdateTimestamp, uint256 supplyExchangePrice, uint256 borrowExchangePrice, uint256 supplyRawInterest, uint256 supplyInterestFree, uint256 borrowRawInterest, uint256 borrowInterestFree, uint256 totalSupply, uint256 totalBorrow, uint256 revenue, uint256 maxUtilization, (uint256 version, (address token, uint256 kink, uint256 rateAtUtilizationZero, uint256 rateAtUtilizationKink, uint256 rateAtUtilizationMax) rateDataV1, (address token, uint256 kink1, uint256 kink2, uint256 rateAtUtilizationZero, uint256 rateAtUtilizationKink1, uint256 rateAtUtilizationKink2, uint256 rateAtUtilizationMax) rateDataV2) rateData)[] overallTokensData_)", +}; -module.exports = { - methodology: methodologies.lendingMarket, +const config = { + liquidity: "0x52aa899454998be5b000ad077a46bbe360f4e497", ethereum: { - tvl: async (api) => { - const tokens = await api.call({ target: "0x741c2Cd25f053a55fd94afF1afAEf146523E1249", abi: "function listedTokens() public view returns (address[] memory listedTokens_)" }) - api.add("0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee", await api.call({ - target: "0xF047ab4c75cebf0eB9ed34Ae2c186f3611aEAfa6", - abi: "function balance(address, address) public view returns (uint256 balance)", - params: ["0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee", "0x52aa899454998be5b000ad077a46bbe360f4e497"] - })) - return api.sumTokens({ - owner: "0x52aa899454998be5b000ad077a46bbe360f4e497", tokens: [ - ADDRESSES.null, - ...tokens.filter(t => t.toLowerCase() !== "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee") - ] - }) + liquidityResolver: (block) => { + if (block < 19992056) { + return "0x741c2Cd25f053a55fd94afF1afAEf146523E1249"; + } + return "0xD7588F6c99605Ab274C211a0AFeC60947668A8Cb"; }, - borrowed: async (api) => { - const fluidLiquidityResolver = "0x645C84DeA082328e456892D2E68d434b61AD7dBF"; - const tokens = await api.call({ - target: "0x741c2Cd25f053a55fd94afF1afAEf146523E1249", - abi: "function listedTokens() public view returns (address[] memory listedTokens_)", - }); + weETH: "0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee", + zircuit: "0xF047ab4c75cebf0eB9ed34Ae2c186f3611aEAfa6", + }, + arbitrum: { + liquidityResolver: (block) => "0x46859d33E662d4bF18eEED88f74C36256E606e44", + }, +}; - const borrowed = await api.call({ target: fluidLiquidityResolver, abi: abi.getOverallTokensData, params: [tokens], }) - api.add(tokens, borrowed.map(x => x.totalBorrow)); - }, +async function getListedTokens(api) { + return await api.call({ + target: config[api.chain].liquidityResolver(api.block), + abi: "function listedTokens() public view returns (address[] memory listedTokens_)", + }); +} + +async function tvl(api) { + const tokens = await getListedTokens(api); + const chain = api.chain; + + if (chain == "ethereum") { + // add WeETH deployed to Zircuit + api.add( + config.ethereum.weETH, + await api.call({ + target: config.ethereum.zircuit, + abi: "function balance(address, address) public view returns (uint256 balance)", + params: [config.ethereum.weETH, config.liquidity], + }) + ); } + + return api.sumTokens({ + owner: config.liquidity, + tokens: [ + ADDRESSES.null, + ...tokens.filter( + (t) => t.toLowerCase() !== "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + ), + ], + }); +} + +async function borrowed(api) { + const tokens = await getListedTokens(api); + const borrowed = await api.call({ + target: config[api.chain].liquidityResolver(api.block), + abi: api.block < 19992056 ? abi.getOverallTokensDataLegacy : abi.getOverallTokensData, + params: [tokens], + }); + api.add( + tokens, + borrowed.map((x) => x.totalBorrow) + ); } -// node test.js projects/fluid/index.js \ No newline at end of file + +module.exports = { + methodology: methodologies.lendingMarket, + ethereum: { tvl, borrowed }, + arbitrum: { tvl, borrowed }, +}; +// node test.js projects/fluid/index.js diff --git a/projects/franklinTempleton-finance/index.js b/projects/franklinTempleton-finance/index.js new file mode 100644 index 000000000000..bbbaf4b88308 --- /dev/null +++ b/projects/franklinTempleton-finance/index.js @@ -0,0 +1,28 @@ +const { toUSDTBalances } = require('../helper/balances'); + +const BENJI_STELLAR = {ticker: "BENJI", address: 'GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5'} +const BENJI_POLYGON = '0x408a634b8a8f0de729b48574a3a7ec3fe820b00a' + +const stellarTvl = async (api) => { + const stellarApi = `https://api.stellar.expert/explorer/public/asset/${BENJI_STELLAR.ticker}-${BENJI_STELLAR.address}` + const response = await fetch(stellarApi) + const {supply, toml_info} = await response.json() + const adjustedSupply = toUSDTBalances((supply / Math.pow(10, toml_info.decimals))) + const [[tokenAddress, tokenBalance]] = Object.entries(adjustedSupply); + return api.add(tokenAddress, tokenBalance, { skipChain: true }) +} + +const polygonTvl = async (api) => { + const [decimals, totalSupply] = await Promise.all([ + api.call({target: BENJI_POLYGON, abi:'erc20:decimals'}), + api.call({target: BENJI_POLYGON, abi:'erc20:totalSupply'}) + ]) + const adjustedSupply = toUSDTBalances((totalSupply / Math.pow(10, decimals))) + const [[tokenAddress, tokenBalance]] = Object.entries(adjustedSupply); + api.add(tokenAddress, tokenBalance, {skipChain: true} ) +} + +module.exports = { + stellar: {tvl: stellarTvl}, + polygon: {tvl: polygonTvl}, +} diff --git a/projects/free-protocol/index.js b/projects/free-protocol/index.js index 7a71b7d233e8..dafeb2b17b0c 100644 --- a/projects/free-protocol/index.js +++ b/projects/free-protocol/index.js @@ -83,4 +83,7 @@ module.exports = { ] }) }, + kroma: { + tvl: () => ({}) + } }; \ No newline at end of file diff --git a/projects/freestyle/index.js b/projects/freestyle/index.js new file mode 100644 index 000000000000..4aadb02a6e11 --- /dev/null +++ b/projects/freestyle/index.js @@ -0,0 +1,46 @@ +const ADDRESSES = require('../helper/coreAssets.json') +const { request, } = require("graphql-request"); + +const freestyleConfig = { + base: { + token: ADDRESSES.base.USDC, + start: 1700006400, + graphUrl: "https://api.studio.thegraph.com/query/62454/analytics_base_8_2/version/latest", + accountSource: '0x6D63921D8203044f6AbaD8F346d3AEa9A2719dDD' + }, +} + +async function tvl(api) { + const { token, graphUrl, start, accountSource } = freestyleConfig[api.chain] + + const query = ` + query stats($from: String!, $to: String!) { + dailyHistories( + where: { + timestamp_gte: $from + timestamp_lte: $to + accountSource: "${accountSource}" + } + ) { + timestamp + platformFee + accountSource + tradeVolume + deposit + withdraw + } + } + ` + const { dailyHistories } = await request(graphUrl, query, { + from: start.toString(), + to: api.timestamp.toString(), + }); + + let total = dailyHistories.reduce((acc, cur) => acc + (Number(cur.deposit) - Number(cur.withdraw)), 0); + + api.add(token, total) +} + +Object.keys(freestyleConfig).forEach(chain => { + module.exports[chain] = { tvl } +}) \ No newline at end of file diff --git a/projects/fx-Protocol/index.js b/projects/fx-Protocol/index.js index ad6d12f9e219..a4f998796bb1 100644 --- a/projects/fx-Protocol/index.js +++ b/projects/fx-Protocol/index.js @@ -5,6 +5,7 @@ const treasuries = [ "0x781BA968d5cc0b40EB592D5c8a9a3A4000063885", "0x38965311507D4E54973F81475a149c09376e241e", "0x63Fe55B3fe3f74B42840788cFbe6229869590f83", + "0xdFac83173A96b06C5D6176638124d028269cfCd2" ]; module.exports = { diff --git a/projects/genesis-lrt/index.js b/projects/genesis-lrt/index.js index e9ad2da8098f..9f7799cc3976 100644 --- a/projects/genesis-lrt/index.js +++ b/projects/genesis-lrt/index.js @@ -1,7 +1,6 @@ const ADDRESSES = require('../helper/coreAssets.json') async function tvl(api) { - if (api.timestamp > 1715181240) return {} const staked = await api.call({ abi: 'uint256:totalAssets', target: '0xf073bAC22DAb7FaF4a3Dd6c6189a70D54110525C' }) api.add(ADDRESSES.null, staked) } @@ -11,5 +10,5 @@ module.exports = { [1714953600,"Genesis Merges with InceptionLRT"] ], doublecounted: true, - ethereum: { tvl, }, -} \ No newline at end of file + ethereum: { tvl: tvl, } +} diff --git a/projects/glyph-v4/index.js b/projects/glyph-v4/index.js new file mode 100644 index 000000000000..1313cce07367 --- /dev/null +++ b/projects/glyph-v4/index.js @@ -0,0 +1,5 @@ +const { uniV3Export } = require('../helper/uniswapV3') + +module.exports = uniV3Export({ + core: { factory: '0x74EfE55beA4988e7D92D03EFd8ddB8BF8b7bD597', fromBlock: 15770796, isAlgebra: true }, +}) \ No newline at end of file diff --git a/projects/gyroscope/index.js b/projects/gyroscope/index.js index fa3a803dc369..39e7a22c3d2d 100644 --- a/projects/gyroscope/index.js +++ b/projects/gyroscope/index.js @@ -93,6 +93,13 @@ const config = { fromBlock: 5147666, }, ], + xdai: [ + { + name: "Gyro E-CLP V2 Factory", + factory: "0x5d3Be8aaE57bf0D1986Ff7766cC9607B6cC99b89", + fromBlock: 33759936, + }, + ], }; Object.keys(config).forEach((chain) => { diff --git a/projects/helper/balancer.js b/projects/helper/balancer.js index e8f6beeadef0..8ab6be241de3 100644 --- a/projects/helper/balancer.js +++ b/projects/helper/balancer.js @@ -1,7 +1,7 @@ const { sumTokens2 } = require('./unwrapLPs'); const { getLogs } = require('./cache/getLogs') -function onChainTvl(vault, fromBlock, { blacklistedTokens = [], preLogTokens = [], onlyUseExistingCache } = {}) { +function onChainTvl(vault, fromBlock, { blacklistedTokens = [], preLogTokens = [], onlyUseExistingCache, permitFailure } = {}) { return async (api) => { const logs = await getLogs({ api, @@ -29,7 +29,7 @@ function onChainTvl(vault, fromBlock, { blacklistedTokens = [], preLogTokens = [ const pools = logs.map(i => i.poolAddress) blacklistedTokens = [...blacklistedTokens, ...pools] - return sumTokens2({ api, owner: vault, tokens, blacklistedTokens, }) + return sumTokens2({ api, owner: vault, tokens, blacklistedTokens, permitFailure }) } } diff --git a/projects/helper/cache/sumUnknownTokens.js b/projects/helper/cache/sumUnknownTokens.js index c3cdbfcdce95..b23f98858d50 100644 --- a/projects/helper/cache/sumUnknownTokens.js +++ b/projects/helper/cache/sumUnknownTokens.js @@ -365,6 +365,7 @@ async function getTokenPrices({ async function sumUnknownTokens({ api, tokensAndOwners = [], balances, coreAssets = [], owner, tokens, chain = 'ethereum', block, restrictTokenRatio, blacklist = [], skipConversion = false, onlyLPs, minLPRatio, log_coreAssetPrices = [], log_minTokenValue = 1e6, owners = [], lps = [], useDefaultCoreAssets = false, cache = {}, resolveLP = false, abis, + ownerTokens, }) { if (api) { chain = api.chain ?? chain @@ -381,6 +382,8 @@ async function sumUnknownTokens({ api, tokensAndOwners = [], balances, tokensAndOwners = owners.map(o => tokens.map(t => [t, o])).flat() else if (owner) tokensAndOwners = tokens.map(t => [t, owner]) + else if (ownerTokens.length) + ownerTokens.forEach(([tokens, owner]) => tokens.forEach(i => tokensAndOwners.push([i, owner]))) tokensAndOwners = tokensAndOwners.filter(t => !blacklist.includes(t[0])) await sumTokens2({ api, balances, chain, block, tokensAndOwners, skipFixBalances: true, resolveLP, abis }) const { updateBalances, } = await getTokenPrices({ cache, coreAssets, lps: [...tokensAndOwners.map(t => t[0]), ...lps,], chain, block, restrictTokenRatio, blacklist, log_coreAssetPrices, log_minTokenValue, minLPRatio, abis, }) diff --git a/projects/helper/coreAssets.json b/projects/helper/coreAssets.json index 0d22e9243e3b..9fd47702a747 100644 --- a/projects/helper/coreAssets.json +++ b/projects/helper/coreAssets.json @@ -151,7 +151,8 @@ "YIN": "0x794baab6b878467f93ef17e2f2851ce04e3e34c8", "BNB": "0x5c4b7ccbf908e64f32e12c6650ec0c96d717f03f", "BUSD": "0x9c9e5fd8bbc25984b178fdce6117defa39d2db39", - "WORK": "0x6002410dda2fb88b4d0dc3c1d562f7761191ea80" + "WORK": "0x6002410dda2fb88b4d0dc3c1d562f7761191ea80", + "FRAX": "0x45c32fA6DF82ead1e2EF74d17b76547EDdFaFF89" }, "xdai": { "WXDAI": "0xe91d153e0b41518a2ce8dd3d7944fa863463a97d", @@ -273,7 +274,8 @@ "GMX": "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a", "WSTETH": "0x5979D7b546E38E414F7E9822514be443A4800529", "plvGLP": "0x5326e71ff593ecc2cf7acae5fe57582d6e74cff1", - "USDe": "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34" + "USDe": "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34", + "FRAX": "0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F" }, "fuse": { "WFUSE": "0x0be9e53fd7edac9f859882afdda116645287c629", @@ -378,7 +380,9 @@ "DAI": "0x90ca507a5d4458a4c6c6249d186b6dcb02a5bccd", "NCT": "0x02de4766c272abc10bc88c220d214a26960a7e92", "cMCO2": "0x32a9fe697a32135bfd313a6ac28792dae4d9979d", - "USDT": "0x617f3112bf5397d0467d315cc709ef968d9ba546" + "USDT": "0x617f3112bf5397d0467d315cc709ef968d9ba546", + "STEUR": "0x004626A008B1aCdC4c74ab51644093b155e59A23", + "USDT_1": "0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e" }, "boba": { "WETH": "0xd203de32170130082896b4111edf825a4774c18e", @@ -1570,7 +1574,8 @@ "SAT": "0x17102AC78a02a98fC78B0c29B7b0506f035A99E5", "BIFI": "0x047938C3aD13c1eB821C8e310B2B6F889b6d0003", "WBTC": "0x7b8FAC5F29E101BaaB33c5f9c39d4F85ba2cc7C1", - "BTCB": "0xd267F821F1b8344B5A63626c8c824697194A173E" + "BTCB": "0xd267F821F1b8344B5A63626c8c824697194A173E", + "BitcoinUSD": "0x6906Ccda405926FC3f04240187dd4fAd5DF6d555" }, "scroll": { "WETH": "0x5300000000000000000000000000000000000004", @@ -1638,7 +1643,8 @@ }, "airdao": { "SAMB": "0x2b2d892c3fe2b4113dd7ac0d2c1882af202fb28f", - "BUSD": "0x7a477aa8ed4884509387dba81ba6f2b7c97597e2" + "BUSD": "0x7a477aa8ed4884509387dba81ba6f2b7c97597e2", + "USDC": "0xFF9F502976E7bD2b4901aD7Dd1131Bb81E5567de" }, "acala": { "DOT": "0x0000000000000000000100000000000000000002", @@ -1668,7 +1674,8 @@ "BLAST": "0xb1a5700fA2358173Fe465e6eA4Ff52E36e88E2ad" }, "chz": { - "WCHZ": "0x721ef6871f1c4efe730dce047d40d1743b886946" + "WCHZ": "0x721ef6871f1c4efe730dce047d40d1743b886946", + "WCHZ_1": "0x677F7e16C7Dd57be1D4C8aD1244883214953DC47" }, "bitrock": { "WBR": "0x413f0e3a440aba7a15137f4278121450416882d5", @@ -1836,7 +1843,8 @@ "WBTC": "0x03C7054BCB39f7b2e5B2c7AcB37583e32D70Cfa3" }, "fraxtal": { - "WETH": "0xA8a59D73388D0c4344a7b0Ba287ddb654227c38a" + "WETH": "0xA8a59D73388D0c4344a7b0Ba287ddb654227c38a", + "FRAX": "0xfc00000000000000000000000000000000000001" }, "aeternity": { "WAE": "ct_J3zBY8xxjsRr3QojETNw48Eb38fjvEuJKkQ6KzECvubvEcvCa", @@ -1853,4 +1861,4 @@ "WETH": "0xf037540e51d71b2d2b1120e8432ba49f29edfbd0", "USDC.e": "0xfbda5f676cb37624f28265a144a48b0d6e87d3b6" } -} \ No newline at end of file +} diff --git a/projects/helper/env.js b/projects/helper/env.js index efebeaec62d2..a5dd7389b105 100644 --- a/projects/helper/env.js +++ b/projects/helper/env.js @@ -23,7 +23,6 @@ const DEFAULTS = { SEI_RPC_MULTICALL: '0xcA11bde05977b3631167028862bE2a173976CA11', SEI_RPC: 'https://evm-rpc.sei-apis.com/', ETLK_RPC_MULTICALL: "0xcA11bde05977b3631167028862bE2a173976CA11", - AETERNITY_HTTP_ENDPOINT: 'https://mainnet.aeternity.io', } const ENV_KEYS = [ diff --git a/projects/helper/heroku-api.js b/projects/helper/heroku-api.js index 57aa8cb64295..1cbe02f416ca 100644 --- a/projects/helper/heroku-api.js +++ b/projects/helper/heroku-api.js @@ -1,5 +1,5 @@ const { get } = require('./http') -const endpoint = "https://sushi-analytics.llama.fi/temp" +const endpoint = "https://sushi-analytics.llama.fi" let data async function getData() { diff --git a/projects/helper/portedTokens.js b/projects/helper/portedTokens.js index d45aca7a97d5..1db3a4f770c1 100644 --- a/projects/helper/portedTokens.js +++ b/projects/helper/portedTokens.js @@ -104,6 +104,7 @@ async function getChainTransform(chain) { if ([...ibcChains, 'ton', 'mvc', 'defichain', 'waves'].includes(chain)) return chainStr if (chain === 'cardano' && addr === 'ADA') return 'coingecko:cardano' if (chain === 'near' && addr.endsWith('.near')) return chainStr + if (chain === 'aeternity' && addr.startsWith('ct_')) return chainStr if (chain === 'tron' && addr.startsWith('T')) return chainStr if (chain === 'stacks' && addr.startsWith('SP')) return chainStr if (chain === 'tezos' && addr.startsWith('KT1')) return chainStr diff --git a/projects/helper/tokenMapping.js b/projects/helper/tokenMapping.js index 15bd6e253b09..e55a3e9bd9cf 100644 --- a/projects/helper/tokenMapping.js +++ b/projects/helper/tokenMapping.js @@ -40,12 +40,29 @@ const fixBalancesTokens = { ozone: { // '0x83048f0bf34feed8ced419455a4320a735a92e9d': { coingeckoId: "ozonechain", decimals: 18 }, // was mapped to wrong chain }, + xdc: { + '0x8f9920283470f52128bf11b0c14e798be704fd15': { coingeckoId: 'comtech-gold', decimals: 18 }, + }, real: { '0x4644066f535ead0cde82d209df78d94572fcbf14': { coingeckoId: 're-al', decimals: 18 }, '0xaec9e50e3397f9ddc635c6c429c8c7eca418a143': { coingeckoId: 'arcana-2', decimals: 18 }, '0xce1581d7b4ba40176f0e219b2cac30088ad50c7a': { coingeckoId: 'pearl', decimals: 18 }, }, + airdao: { + [ADDRESSES.null]: { coingeckoId: 'amber', decimals: 18 }, + [ADDRESSES.airdao.USDC]: { coingeckoId: 'usd-coin', decimals: 18 }, + }, + lukso: { + [ADDRESSES.null]: { coingeckoId: "lukso-token-2", decimals: 18 }, + [ADDRESSES.lukso.WLYX]: { coingeckoId: 'lukso-token-2', decimals: 18 }, + }, + bfc: { + '0x6906Ccda405926FC3f04240187dd4fAd5DF6d555': { coingeckoId: "bitcoin-usd-btcfi", decimals: 18, }, + }, + pulse: { + '0x30fcb23a906493371b1721c8feb8815804808d74': { coingeckoId: 'savings-dai', decimals: 18 }, + } } ibcChains.forEach(chain => fixBalancesTokens[chain] = { ...ibcMappings, ...(fixBalancesTokens[chain] || {}) }) diff --git a/projects/helper/unwrapLPs.js b/projects/helper/unwrapLPs.js index dd4afd596d8e..dc96b0908fc2 100644 --- a/projects/helper/unwrapLPs.js +++ b/projects/helper/unwrapLPs.js @@ -193,6 +193,8 @@ async function sumLPWithOnlyOneTokenOtherThanKnown(balances, lpToken, owner, tok const PANCAKE_NFT_ADDRESS = '0x46A15B0b27311cedF172AB29E4f4766fbE7F4364' async function unwrapUniswapV3NFTs({ balances = {}, nftsAndOwners = [], block, chain = 'ethereum', owner, nftAddress, owners, blacklistedTokens = [], whitelistedTokens = [], uniV3ExtraConfig = {} }) { + nftAddress = nftAddress ?? uniV3ExtraConfig.nftAddress + const commonConfig = { balances, owner, owners, chain, block, blacklistedTokens, whitelistedTokens, uniV3ExtraConfig, } // https://docs.uniswap.org/contracts/v3/reference/deployments if (!nftsAndOwners.length) { if (!nftAddress) @@ -209,15 +211,13 @@ async function unwrapUniswapV3NFTs({ balances = {}, nftsAndOwners = [], block, c default: throw new Error('missing default uniswap nft address chain: ' + chain) } - if ((!owners || !owners.length) && owner) - owners = [owner] - owners = getUniqueAddresses(owners, chain) - if (Array.isArray(nftAddress)) - nftsAndOwners = nftAddress.map(nft => owners.map(o => [nft, o])).flat() - else - nftsAndOwners = owners.map(o => [nftAddress, o]) - } - await Promise.all(nftsAndOwners.map(([nftAddress, owner]) => unwrapUniswapV3NFT({ balances, owner, nftAddress, block, chain, blacklistedTokens, whitelistedTokens, uniV3ExtraConfig, }))) + if (Array.isArray(nftAddress)) { + await Promise.all(nftAddress.map((addr) => unwrapUniswapV3NFT({ ...commonConfig, nftAddress: addr, }))) + } else + await unwrapUniswapV3NFT({ ...commonConfig, nftAddress, }) + + } else + await Promise.all(nftsAndOwners.map(([nftAddress, owner]) => unwrapUniswapV3NFT({ ...commonConfig, owner, nftAddress, }))) return balances } @@ -225,23 +225,37 @@ const factories = {} const getFactoryKey = (chain, nftAddress) => `${chain}:${nftAddress}`.toLowerCase() -async function unwrapUniswapV3NFT({ balances, owner, nftAddress, block, chain = 'ethereum', blacklistedTokens = [], whitelistedTokens = [], uniV3ExtraConfig = {}, }) { +async function unwrapUniswapV3NFT({ balances, owner, owners, nftAddress, block, chain = 'ethereum', blacklistedTokens = [], whitelistedTokens = [], uniV3ExtraConfig = {}, }) { blacklistedTokens = getUniqueAddresses(blacklistedTokens, chain) whitelistedTokens = getUniqueAddresses(whitelistedTokens, chain) let nftIdFetcher = uniV3ExtraConfig.nftIdFetcher ?? nftAddress - const nftPositions = (await sdk.api.erc20.balanceOf({ target: nftIdFetcher, owner, block, chain })).output const factoryKey = getFactoryKey(chain, nftAddress) if (!factories[factoryKey]) factories[factoryKey] = sdk.api.abi.call({ target: nftAddress, abi: wildCreditABI.factory, block, chain }) let factory = (await factories[factoryKey]).output if (factory.toLowerCase() === '0xa08ae3d3f4da51c22d3c041e468bdf4c61405aab') // thruster finance has a bug where they set the pool deployer instead of the factory factory = '0x71b08f13B3c3aF35aAdEb3949AFEb1ded1016127' - const positionIds = (await sdk.api.abi.multiCall({ - block, chain, abi: wildCreditABI.tokenOfOwnerByIndex, target: nftIdFetcher, - calls: Array(Number(nftPositions)).fill(0).map((_, index) => ({ params: [owner, index] })), - })).output.map(positionIdCall => positionIdCall.output) + let positionIds = uniV3ExtraConfig.positionIds + if (!positionIds) { + if (!owners && owner) owners = [owner] + owners = getUniqueAddresses(owners, chain) + const { output: lengths } = await sdk.api.abi.multiCall({ + block, chain, abi: wildCreditABI.balanceOf, + calls: owners.map((params) => ({ target: nftIdFetcher, params, })), + }) + const positionIDCalls = [] + for (let i = 0; i < owners.length; i++) { + const length = lengths[i].output + positionIDCalls.push(...createIncrementArray(length).map(j => ({ params: [owners[i], j] }))) + } + + positionIds = (await sdk.api.abi.multiCall({ + block, chain, abi: wildCreditABI.tokenOfOwnerByIndex, target: nftIdFetcher, + calls: positionIDCalls, + })).output.map(positionIdCall => positionIdCall.output) + } const positions = (await sdk.api.abi.multiCall({ block, chain, abi: wildCreditABI.positions, target: nftAddress, @@ -846,7 +860,11 @@ async function sumTokens2({ fetchCoValentTokens = false, tokenConfig = {}, sumChunkSize = undefined, - uniV3ExtraConfig = {}, + uniV3ExtraConfig = { + // positionIds + // nftAddress + // nftIdFetcher + }, resolveICHIVault = false, solidlyVeNfts = [], }) { diff --git a/projects/hinkal/registryTokens.js b/projects/hinkal/registryTokens.js index 97c239cdddd6..338d3f06a32e 100644 --- a/projects/hinkal/registryTokens.js +++ b/projects/hinkal/registryTokens.js @@ -251,6 +251,7 @@ const ETHEREUM_REGISTRY_TOKENS = [ ADDRESSES.ethereum.UNI, "0xEEda34A377dD0ca676b9511EE1324974fA8d980D", "0x0d86883faf4ffd7aeb116390af37746f45b6f378", + "0x73a15fed60bf67631dc6cd7bc5b6e8da8190acf5", ]; const ARBITRUM_REGISTRY_TOKENS = [ diff --git a/projects/imf-money/index.js b/projects/imf-money/index.js new file mode 100644 index 000000000000..486c45d8afed --- /dev/null +++ b/projects/imf-money/index.js @@ -0,0 +1,10 @@ +const { sumTokensExport } = require('../helper/unwrapLPs') +const PEPE_TOKEN_CONTRACT = '0x6982508145454Ce325dDbE47a25d4ec3d2311933'; +const LOCKED_MONEY_CONTRACT = '0x30F75834cB406b7093208Fda7F689938aCBD1EeB'; //wallet that has all the locked money + +module.exports = { + methodology: 'Sums the value of deposited memes', + ethereum: { + tvl: sumTokensExport({ owner: LOCKED_MONEY_CONTRACT, token: PEPE_TOKEN_CONTRACT}), + } +}; diff --git a/projects/impermax/impermaxHelper.js b/projects/impermax/impermaxHelper.js index 1517fd2b98c7..0817f51d849b 100644 --- a/projects/impermax/impermaxHelper.js +++ b/projects/impermax/impermaxHelper.js @@ -105,6 +105,8 @@ function impermaxHelper(exportsObj, config, blacklistedPools) { case 'era': case 'fantom': case 'scroll': + case 'base': + case 'mantle': default: impermaxSymbol = 'STKD-UNI-V2' return underlyings.filter((_, i) => uSymbols[i] === impermaxSymbol) @@ -125,4 +127,5 @@ function impermaxHelper(exportsObj, config, blacklistedPools) { module.exports = { impermaxHelper -} \ No newline at end of file +} + diff --git a/projects/impermax/index.js b/projects/impermax/index.js index 2ec9d1774178..27efed1a61a1 100644 --- a/projects/impermax/index.js +++ b/projects/impermax/index.js @@ -11,12 +11,13 @@ const config = { '0xBB92270716C8c424849F17cCc12F4F24AD4064D6', '0x7F7AD5b16c97Aa9C2B0447C2676ce7D5CEFEbCd3', '0x7ED6eF7419cD9C00693d7A4F81c2a151F49c7aC2', + '0x60f57cF15a34fA0Aa25eF37eB827E1a0948966c5' ] }, arbitrum: { factories: [ '0x8C3736e2FE63cc2cD89Ee228D9dBcAb6CE5B767B', - '0x8C3736e2FE63cc2cD89Ee228D9dBcAb6CE5B767B', + '0x9708e0b216a88d38d469b255ce78c1369ad898e6', '0x97bc7fefb84a4654d4d3938751b5fe401e8771c2', ] }, @@ -54,6 +55,19 @@ const config = { '0xFBD17F3AA7d6506601D2bF7e15a6C96081296a01', // scroll stablefactory ] }, + base: { + factories: [ + '0x66ca66E002a9CEE8dEfE25dB6f0c6225117C2d9f', + '0x8aDc5F73e63b3Af3fd0648281fE451738D8B9D86', + '0x47183bB55AD0F891887E099Cec3570d3C667cD00' + ] + }, + mantle: { + factories: [ + '0x3047523D5ed0df1545B1C440BdAaB095f1f3cf5C' + ] + } + } const blacklistedPools = { @@ -96,8 +110,10 @@ const blacklistedPools = { '0xb97b6ed451480fe6466a558e9c54eaac32e6c696', // OXD-FTM ], scroll: [], + base: [], + mantle: [] } module.exports = {} -impermaxHelper(module.exports, config, blacklistedPools) \ No newline at end of file +impermaxHelper(module.exports, config, blacklistedPools) diff --git a/projects/inception-lrt/index.js b/projects/inception-lrt/index.js index ecdda208cd49..3731811b65e8 100644 --- a/projects/inception-lrt/index.js +++ b/projects/inception-lrt/index.js @@ -7,14 +7,13 @@ async function tvl_eth(api) { const strategies = await api.multiCall({ abi: 'address:strategy', calls: vaults}) const tokens = await api.multiCall({ abi: 'address:underlyingToken', calls: strategies}) // const result = total_deposited.map((deposited, index) => deposited - total_withdraw[index]); - if (api.timestamp > 1715181240) { - const staked = await api.call({ abi: 'uint256:totalAssets', target: '0xf073bAC22DAb7FaF4a3Dd6c6189a70D54110525C' }) - api.add(ADDRESSES.null, staked) - } api.add(tokens, total_deposited) } module.exports = { + hallmarks: [ + [1714953600,"Genesis Merges with InceptionLRT"] + ], doublecounted: true, ethereum: { tvl: tvl_eth, } , } diff --git a/projects/juice-finance/index.js b/projects/juice-finance/index.js index ea92ee9dbc7b..de38553ff988 100644 --- a/projects/juice-finance/index.js +++ b/projects/juice-finance/index.js @@ -4,6 +4,17 @@ const { sumTokens2 } = require("../helper/unwrapLPs"); // Tokens const EZETH = ADDRESSES.blast.ezETH; +const PRO = { + lendingPool: { + usdb: "0x788654040D7E9a8Bb583D7d8CCEA1Ebf1AE4aC06", + weth: "0x60ED5493B35f833189406dFec0b631A6B5B57f66", + }, + collateralManager: { + usdb: "0xaCe661Bf726Bd8aFE6F6594C559A5136489E64f9", + weth: "0x4dEE8034019f03F1a025dbFB4bBC159D7BaA7a0A", + }, +} + // Lending pools const LENDING_POOL_USDB = "0x4A1d9220e11a47d8Ab22Ccd82DA616740CF0920a"; const LENDING_POOL_WETH = "0x44f33bC796f7d3df55040cd3C631628B560715C2"; @@ -25,8 +36,14 @@ const wethCollateralManagers = [ COLLATERAL_MANAGER_V2, WETH_COLLATERAL_MANAGER, MUNCHABLE_WETH_COLLATERAL_MANAGER, + PRO.collateralManager.weth, ].map((a) => [ADDRESSES.blast.WETH, a]); +const usdbCollateralManagers = [ + USDB_COLLATERAL_MANAGER, + PRO.collateralManager.usdb, +].map((a) => [ADDRESSES.blast.USDB, a]); + async function tvl(api) { const thrusterV2LPs = [['0x4E4B4A3111d128628c427E78a2abAd1635fE6542', '0x4Ca392f74A4C86F5E521f1d8E915b36ed425B331']]; @@ -49,11 +66,13 @@ async function tvl(api) { stateMutability: "view", type: "function", }, - calls: [LENDING_POOL_USDB, LENDING_POOL_WETH], + calls: [LENDING_POOL_USDB, PRO.lendingPool.usdb, LENDING_POOL_WETH, PRO.lendingPool.weth], }); api.add(ADDRESSES.blast.USDB, tokens[0]); - api.add(ADDRESSES.blast.WETH, tokens[1]); + api.add(ADDRESSES.blast.USDB, tokens[1]); + api.add(ADDRESSES.blast.WETH, tokens[2]); + api.add(ADDRESSES.blast.WETH, tokens[3]); await sumTokens2({ api, @@ -61,7 +80,7 @@ async function tvl(api) { tokensAndOwners: [ [EZETH, EZETH_COLLATERAL_MANAGER], [ADDRESSES.blast.weETH, WEETH_COLLATERAL_MANAGER], - [ADDRESSES.blast.USDB, USDB_COLLATERAL_MANAGER], + ...usdbCollateralManagers, ...wethCollateralManagers, ], }); diff --git a/projects/kalax/index.js b/projects/kalax/index.js index 971b519abef4..ed945f180c71 100644 --- a/projects/kalax/index.js +++ b/projects/kalax/index.js @@ -1,7 +1,7 @@ const { sumTokens2 } = require("../helper/unwrapLPs") const KALAX = "0x2F67F59b3629Bf24962290DB9edE0CD4127e606D" -const farms = ['0xE63153C3360aCa0F4e7Ca7A1FC61c2215FAEF5A1', '0xFe899401A1d86cC1113020fb40878c76239142a5'] +const farms = ['0xE63153C3360aCa0F4e7Ca7A1FC61c2215FAEF5A1', '0xFe899401A1d86cC1113020fb40878c76239142a5',"0x1CB8f6cecf7c8FBB9863417f8371Cb2A076C9115"] async function tvl(api) { let pools = (await api.multiCall({ abi: abiInfo.poolInfos, calls: farms })).flat() diff --git a/projects/kawa/index.js b/projects/kawa/index.js new file mode 100644 index 000000000000..37def13d6d68 --- /dev/null +++ b/projects/kawa/index.js @@ -0,0 +1,5 @@ +const { compoundExports2 } = require('../helper/compound'); + +module.exports = { + sei: compoundExports2({ comptroller: '0xD527237E176647cbF8A7c7bCeFEfBf9130Bec948', cether: '0x20E56093357d91Ce85B0E3c2f0E4bdc676E94eDB', }) +} \ No newline at end of file diff --git a/projects/kayen/index.js b/projects/kayen/index.js index b37cf8f7ccac..94b62888fc57 100644 --- a/projects/kayen/index.js +++ b/projects/kayen/index.js @@ -7,7 +7,6 @@ module.exports = { tvl: getUniTVL({ factory: "0xE2918AA38088878546c1A18F2F9b1BC83297fdD3", useDefaultCoreAssets: true, - fetchBalances: true, }), }, }; \ No newline at end of file diff --git a/projects/kernel/abi.js b/projects/kernel/abi.js new file mode 100644 index 000000000000..d70d466c834c --- /dev/null +++ b/projects/kernel/abi.js @@ -0,0 +1,5 @@ +exports.abi = { + numApprovedTokens: "function numApprovedTokens() view returns (uint256)", + approvedTokens: "function approvedTokens(uint256) view returns (address)", + tokens: "function tokens(address) view returns (address vaultToken, address rateProvider, uint256 cap, uint256 deposited, bool paused)" +}; \ No newline at end of file diff --git a/projects/kernel/index.js b/projects/kernel/index.js new file mode 100644 index 000000000000..fce117aa7b38 --- /dev/null +++ b/projects/kernel/index.js @@ -0,0 +1,30 @@ +const abi = { + tokens: "function tokens(address) view returns (address vaultToken, address rateProvider, uint256 cap, uint256 deposited, bool paused)" +} + +const ASSETS = [ + "0xf02C96DbbB92DC0325AD52B3f9F2b951f972bf00", // krETH + "0x513D27c94C0D81eeD9DC2a88b4531a69993187cF", // ksETH + "0x0bB9aB78aAF7179b7515e6753d89822b91e670C4", // kUSD +] + +const tvl = async (api) => { + const tokens = await api.fetchList({ lengthAbi: 'numApprovedTokens', itemAbi: 'approvedTokens', calls: ASSETS, groupedByInput: true, }); + const assets = [] + const balanceCalls = [] + tokens.forEach((tokens, i) => { + assets.push(...tokens) + balanceCalls.push(...tokens.map(token => ({ target: ASSETS[i], params: token }))) + }) + const balances = (await api.multiCall({ calls: balanceCalls, abi: abi.tokens })).map(i => i.deposited) + api.add(assets, balances) +}; + +module.exports = { + doublecounted: true, + methodology: 'The TVL represents the sum of each LST deposited in the protocol', + ethereum: { + tvl, + }, +}; + diff --git a/projects/kosmos/index.js b/projects/kosmos/index.js new file mode 100644 index 000000000000..d4510b19f89d --- /dev/null +++ b/projects/kosmos/index.js @@ -0,0 +1,11 @@ +const ADDRESSES = require('../helper/coreAssets.json') +const { sumTokensExport } = require("../helper/unwrapLPs"); + +const bondTellers = ["0x04B07dFBB78d32FF500466c35B4Fe5D615cbe911", "0x8d4439F8AC1e5CCF37F9ACb527E59720E0ccA3E3"]; + +module.exports = { + airdao: { tvl: sumTokensExport({ owners: bondTellers, + tokens: [ADDRESSES.null, ADDRESSES.airdao.USDC, '0x096B5914C95C34Df19500DAff77470C845EC749D'] + }) }, + methodology: `The TVL of Kosmos is equal to the total value of underlying assets locked in the BondTellers contracts.`, +}; diff --git a/projects/kriya-clmm/index.js b/projects/kriya-clmm/index.js new file mode 100644 index 000000000000..089aa59221e3 --- /dev/null +++ b/projects/kriya-clmm/index.js @@ -0,0 +1,25 @@ +const sui = require("../helper/chain/sui"); + +const EVENT_FILTER = + "0xf6c05e2d9301e6e91dc6ab6c3ca918f7d55896e1f1edd64adc0e615cde27ebf1::create_pool::PoolCreatedEvent"; + +async function kriyaTVL(api) { + const poolIds = await sui.queryEvents({ + eventType: EVENT_FILTER, + transform: (i) => i.pool_id, + }); + const pools = await sui.getObjects(poolIds); + pools.forEach((i) => { + const [token0, token1] = i.type.split("<")[1].replace(">", "").split(", "); + api.add(token0, i.fields.reserve_x); + api.add(token1, i.fields.reserve_y); + }); +} + +module.exports = { + timetravel: false, + methodology: "Collects TVL for all CLMM pools created on Kriya", + sui: { + tvl: kriyaTVL, + }, +}; diff --git a/projects/landshare/index.js b/projects/landshare/index.js index a4a86020c323..9a34857342bc 100644 --- a/projects/landshare/index.js +++ b/projects/landshare/index.js @@ -1,34 +1,13 @@ - -const { toUSDTBalances } = require('../helper/balances'); -const { get } = require('../helper/http'); - -const LandshareApi = "https://api.landshare.io/api/properties"; - -async function landshareTVL() { - const rentals = await get(LandshareApi + "/rentals"); - const flips = await get(LandshareApi + "/flips"); - - const totalRentals = rentals.reduce((acc, item) => { - acc = acc + item.value - return acc; - }, 0); - - const totalFlips = flips.reduce((acc, item) => { - acc = acc + item; - return acc; - }, 0); - - const total = totalRentals + totalFlips; - - return toUSDTBalances(total); -} +const { pool2 } = require('../helper/pool2') +const { staking } = require('../helper/staking') +const LANDSHARE_TOKEN_CONTRACT = '0xA73164DB271931CF952cBaEfF9E8F5817b42fA5C' +const LANDSHARE_STAKING_CONTRACT = '0x3f9458892fB114328Bc675E11e71ff10C847F93b' +const LANDSHARE_LP_TOKEN_CONTRACT = '0x13f80c53b837622e899e1ac0021ed3d1775caefa' module.exports = { - timetravel: false, - misrepresentedTokens: true, bsc: { - tvl: landshareTVL, - } -}; - -// node test.js projects/landshare/index.js + tvl: () => ({}), + staking: staking(LANDSHARE_STAKING_CONTRACT, LANDSHARE_TOKEN_CONTRACT), + pool2: pool2(LANDSHARE_STAKING_CONTRACT, LANDSHARE_LP_TOKEN_CONTRACT), + }, +} \ No newline at end of file diff --git a/projects/linehub-perps/index.js b/projects/linehub-perps/index.js index e3267bf1eec5..cf4d3d161f6c 100644 --- a/projects/linehub-perps/index.js +++ b/projects/linehub-perps/index.js @@ -4,7 +4,7 @@ const { nullAddress } = require("../helper/unwrapLPs"); async function LineaTvl(api) { const tokens = [nullAddress, ADDRESSES.linea.USDC]; - const owners = ["0xC94cFd8F4fB8Ef3EB360Ec92e2A9Ca969Cadf095"]; + const owners = ["0xC94cFd8F4fB8Ef3EB360Ec92e2A9Ca969Cadf095", "0x00744A65cFC59ACBa312Ade7ABf77379A041Ae26"]; return api.sumTokens({ owners, tokens }); } diff --git a/projects/manta-cedefi-stake/index.js b/projects/manta-cedefi-stake/index.js new file mode 100644 index 000000000000..103f0e0a58ec --- /dev/null +++ b/projects/manta-cedefi-stake/index.js @@ -0,0 +1,14 @@ +const { sumTokensExport } = require("../helper/unwrapLPs") + +const tokens = [ + "0x1468177DbCb2a772F3d182d2F1358d442B553089", // "mBTC" + "0xACCBC418a994a27a75644d8d591afC22FaBA594e", // "mETH" + "0x649d4524897cE85A864DC2a2D5A11Adb3044f44a", // "mUSD" +] +const mTokenStakeContract = "0x1B9bcc6644CC9b5e1F89aBaAb66904F5a562d4a1" + +module.exports = { + manta: { + tvl: sumTokensExport({ owner: mTokenStakeContract, tokens }), + }, +} \ No newline at end of file diff --git a/projects/marginly/config.js b/projects/marginly/config.js index 6b358afbed61..daaa5d6f1083 100644 --- a/projects/marginly/config.js +++ b/projects/marginly/config.js @@ -11,6 +11,11 @@ module.exports = { fromBlock: 208756175, version: "v1.5", }, + { + factory: "0x4a805A6dbaCF824D5A39b9f3559aeFb831C1df95", + fromBlock: 220673210, + version: "v1.5", + }, ], }, blast: { diff --git a/projects/mento/index.js b/projects/mento/index.js index 264d520f0182..addb839a4b0b 100644 --- a/projects/mento/index.js +++ b/projects/mento/index.js @@ -3,18 +3,18 @@ const { nullAddress, } = require('../helper/unwrapLPs') const { sumTokensExport, } = require('../helper/sumTokens') module.exports = { - methodology: 'TVL counts Celo deposited as collateral to mint cUSD.', + methodology: 'TVL counts all assets deposited as collateral to mint Mento stablecoins.', celo: { tvl: sumTokensExport({ - owners: ['0x9380fA34Fd9e4Fd14c06305fd7B6199089eD4eb9', '0x246f4599eFD3fA67AC44335Ed5e749E518Ffd8bB', '0x298FbD6dad2Fc2cB56d7E37d8aCad8Bf07324f67',], - tokens: [nullAddress], + owners: ['0x9380fA34Fd9e4Fd14c06305fd7B6199089eD4eb9', '0x246f4599eFD3fA67AC44335Ed5e749E518Ffd8bB', '0x298FbD6dad2Fc2cB56d7E37d8aCad8Bf07324f67', '0x87647780180b8f55980c7d3ffefe08a9b29e9ae1'], + tokens: [nullAddress, ADDRESSES.celo.STEUR, ADDRESSES.celo.USDT_1], chain: 'celo', }) }, ethereum: { tvl: sumTokensExport({ - owners: ['0xe1955eA2D14e60414eBF5D649699356D8baE98eE', '0x8331C987D9Af7b649055fa9ea7731d2edbD58E6B', '0x26ac3A7b8a675b741560098fff54F94909bE5E73', '0x16B34Ce9A6a6F7FC2DD25Ba59bf7308E7B38E186', ], - tokens: [nullAddress, ADDRESSES.ethereum.USDC, ADDRESSES.ethereum.DAI, ], + owners: ['0xe1955eA2D14e60414eBF5D649699356D8baE98eE', '0x8331C987D9Af7b649055fa9ea7731d2edbD58E6B', '0x26ac3A7b8a675b741560098fff54F94909bE5E73', '0x16B34Ce9A6a6F7FC2DD25Ba59bf7308E7B38E186', '0xd0697f70E79476195B742d5aFAb14BE50f98CC1E'], + tokens: [nullAddress, ADDRESSES.ethereum.USDC, ADDRESSES.ethereum.DAI, ADDRESSES.ethereum.SDAI, ADDRESSES.ethereum.STETH ], chain: 'ethereum', }) }, diff --git a/projects/meridian-trade/index.js b/projects/meridian-trade/index.js index f4c28ef79e8d..bc3b1d327421 100644 --- a/projects/meridian-trade/index.js +++ b/projects/meridian-trade/index.js @@ -1,9 +1,13 @@ const { gmxExports } = require('../helper/gmx') -const Vault = '0x853a8cE6B6338f5B0A14BCfc97F9D68396099C9C'; +const base_vault = '0x853a8cE6B6338f5B0A14BCfc97F9D68396099C9C'; +const meter_vault = '0x95cd3F1DE20A29B473FcC1773069316a424c746D'; module.exports = { base: { - tvl: gmxExports({ vault: Vault, blacklistedTokens: ['0x5e06ea564efcb3158a85dbf0b9e017cb003ff56f'] }) + tvl: gmxExports({ vault: base_vault, blacklistedTokens: ['0x5e06ea564efcb3158a85dbf0b9e017cb003ff56f'] }), }, + meter: { + tvl: gmxExports({ vault: meter_vault }) + } }; diff --git a/projects/midas/index.js b/projects/midas/index.js new file mode 100644 index 000000000000..bf220ae80cc9 --- /dev/null +++ b/projects/midas/index.js @@ -0,0 +1,18 @@ +async function tvl(api) { + const MTBILL_TOKEN_CONTRACT = "0xDD629E5241CbC5919847783e6C96B2De4754e438"; + const mtbillSupply = await await api.call({ abi: "erc20:totalSupply", target: MTBILL_TOKEN_CONTRACT, }); + + const rate = await api.call({ + target: "0x32d1463EB53b73C095625719Afa544D5426354cB", // IB01/USD + abi: "function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)", + }); + api.addCGToken('tether', (mtbillSupply / 1e18) * (rate.answer / 1e8)) +} + +const chains = ["ethereum"]; + +chains.forEach((chain) => { + module.exports[chain] = { tvl }; +}); + +module.exports.misrepresentedTokens = true \ No newline at end of file diff --git a/projects/minswap/index.js b/projects/minswap/index.js index 9867ef3f774a..3c27ddf9dafb 100644 --- a/projects/minswap/index.js +++ b/projects/minswap/index.js @@ -1,12 +1,15 @@ const { getAdaInAddress, sumTokensExport, sumTokens2 } = require("../helper/chain/cardano"); -const POOL_SCRIPT_HASH = "script1uychk9f04tqngfhx4qlqdlug5ntzen3uzc62kzj7cyesjk0d9me" -const ORDER_SCRIPT_HASH = "script15ew2tzjwn364l2pszu7j5h9w63v2crrnl97m074w9elrkxhah0e" +const V1_POOL_SCRIPT_HASH = "script1uychk9f04tqngfhx4qlqdlug5ntzen3uzc62kzj7cyesjk0d9me" +const V1_ORDER_SCRIPT_HASH = "script15ew2tzjwn364l2pszu7j5h9w63v2crrnl97m074w9elrkxhah0e" + +const V2_POOL_SCRIPT_HASH = "script1agrmwv7exgffcdu27cn5xmnuhsh0p0ukuqpkhdgm800xksw7e2w" +const V2_ORDER_SCRIPT_HASH = "script1c03gcdkrg3e3twj62menmf4xmhqhwz58d2xe7r9n497yc6r9qhd" async function tvl() { // DEX V1 - const liquidityPoolLocked = await getAdaInAddress(POOL_SCRIPT_HASH) - const batchOrderLocked = await getAdaInAddress(ORDER_SCRIPT_HASH) + const v1LiquidityPoolLocked = await getAdaInAddress(V1_POOL_SCRIPT_HASH) + const v1BatchOrderLocked = await getAdaInAddress(V1_ORDER_SCRIPT_HASH) // Stable Pools const stablePoolsLiquidity = await sumTokens2({ @@ -24,8 +27,12 @@ async function tvl() { ], }) + // DEX V2 + const v2LiquidityPoolLocked = await getAdaInAddress(V2_POOL_SCRIPT_HASH) + const v2BatchOrderLocked = await getAdaInAddress(V2_ORDER_SCRIPT_HASH) + return { - cardano: (liquidityPoolLocked * 2) + batchOrderLocked, + cardano: ((v1LiquidityPoolLocked + v2LiquidityPoolLocked) * 2) + v1BatchOrderLocked + v2BatchOrderLocked, ...stablePoolsLiquidity }; } @@ -41,5 +48,7 @@ module.exports = { }, hallmarks:[ [1647949370, "Vulnerability Found"], + [1712565661, "Stableswap Launch"], + [1720584000, "V2 Launch"] ], }; diff --git a/projects/morpho-blue/index.js b/projects/morpho-blue/index.js index a06864916b6e..d6139ec2e203 100644 --- a/projects/morpho-blue/index.js +++ b/projects/morpho-blue/index.js @@ -3,7 +3,6 @@ const abi = require("../helper/abis/morpho.json"); module.exports = { methodology: `Collateral (supply minus borrows) in the balance of the Morpho contracts`, - doublecounted: true, }; const config = { diff --git a/projects/napier/index.js b/projects/napier/index.js index af81a748b58f..9db00cf28f38 100644 --- a/projects/napier/index.js +++ b/projects/napier/index.js @@ -1,5 +1,5 @@ -const { getLogs } = require("../helper/cache/getLogs"); +const { getLogs2 } = require("../helper/cache/getLogs"); // https://docs.napier.finance/contract-and-integrations/deployed-contracts const config = { @@ -19,24 +19,24 @@ Object.keys(config).map((network) => { const { tranche_factory, pool_factory } = config[network]; module.exports[network] = { tvl: async (api) => { - const trancheDeployedLogs = tranche_factory.address ? await getLogs({ + const trancheDeployedLogs = tranche_factory.address ? await getLogs2({ api, target: tranche_factory.address, eventAbi: "event TrancheDeployed(uint256 indexed maturity, address indexed principalToken, address indexed yieldToken)", - onlyArgs: true, fromBlock: tranche_factory.deployedAt, + extraKey: 'v1' }) : []; const tranches = trancheDeployedLogs.map((event) => event.principalToken); // fetch deployed pools - const poolDeployedLogs = pool_factory.address ? await getLogs({ + const poolDeployedLogs = pool_factory.address ? await getLogs2({ api, target: pool_factory.address, eventAbi: "event Deployed(address indexed basePool, address indexed underlying, address indexed pool)", - onlyArgs: true, fromBlock: pool_factory.deployedAt, + extraKey: 'v1' }) : []; const pools = poolDeployedLogs.map((event) => event.pool) diff --git a/projects/nexus/index.js b/projects/nexus/index.js index 19945adcaefc..7a63c3a30703 100644 --- a/projects/nexus/index.js +++ b/projects/nexus/index.js @@ -1,22 +1,14 @@ -const { sumTokens2 } = require('../helper/unwrapLPs'); - -const pools = [ - '0xcafeaBED7e0653aFe9674A3ad862b78DB3F36e60' // current pool -]; -const yieldPools = [ - '0x27f23c710dd3d878fe9393d93465fed1302f2ebd' -] -const getAssetsABI = "function getAssets() view returns (tuple(address assetAddress, bool isCoverAsset, bool isAbandoned)[])" async function tvl(api) { - const assets = await api.multiCall({ abi: getAssetsABI, calls: pools}) - const ownerTokens = assets.map((v, i) => [v.map(i => i.assetAddress), pools[i]]) - const assets2 = await api.multiCall({ abi: 'address[]:getTrackedAssets', calls: yieldPools }) - assets2.forEach((v, i) => ownerTokens.push([v, yieldPools[i]])) - return sumTokens2({ api, ownerTokens, blacklistedTokens: yieldPools}) + const MasterProxy = '0x01BFd82675DBCc7762C84019cA518e701C0cD07e' + // const bytes2 = ethers.utils.formatBytes32String('P1').slice(0, 4) // '0x5031 + const P1Address = await api.call({ abi: 'function getLatestAddress(bytes2) view returns (address)', target: MasterProxy, params: '0x5031' }) + const ethValue = await api.call({ abi: 'uint256:getPoolValueInEth', target: P1Address}) + api.addGasToken(ethValue) } module.exports = { + misrepresentedTokens: true, start: 1558569600, // 05/23/2019 @ 12:00am (UTC) ethereum: { tvl } } diff --git a/projects/nimbora-yield-aggregator/index.js b/projects/nimbora-yield-aggregator/index.js new file mode 100644 index 000000000000..e2b6102614e8 --- /dev/null +++ b/projects/nimbora-yield-aggregator/index.js @@ -0,0 +1,42 @@ +const ADDRESSES = require('../helper/coreAssets.json') +const { call, parseAddress } = require('../helper/chain/starknet') +const { getConfig } = require('../helper/cache') +const { get } = require('../helper/http') + +const totalAssetsAbi = { + "name": "total_assets", + "type": "function", + "inputs": [], + "outputs": [ + { + "name": "totalAssets", + "type": "Uint256" + } + ], + "stateMutability": "view" +} + +async function fetcher() { + return get('https://stats.nimbora.io/aggregator/strategies', { + headers: { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' + } + }) +} + +async function tvl(api) { + const strategyData = await getConfig('nimbora-yield-aggregator', undefined, { fetcher }) + for (let index = 0; index < strategyData.length; index++) { + const strategyInfo = strategyData[index]; + const underlying = parseAddress(strategyInfo.underlying); + const strategyTvl = await call({ target: strategyInfo.vault, abi: totalAssetsAbi }); + api.add(underlying, strategyTvl) + } +} + +module.exports = { + methodology: 'Computed by summing the total assets held by each vault aggregator.', + starknet: { + tvl + }, +} diff --git a/projects/olympus/index.js b/projects/olympus/index.js index 1dec65c9657b..2a83b091b661 100644 --- a/projects/olympus/index.js +++ b/projects/olympus/index.js @@ -4,6 +4,7 @@ const { blockQuery } = require("../helper/http"); const { getEnv } = require("../helper/env"); const { staking } = require('../helper/staking'); const { sumTokens2 } = require("../helper/unwrapLPs"); +const { sumTokens } = require("../helper/sumTokens"); const OlympusStakings = [ // Old Staking Contract @@ -14,8 +15,15 @@ const OlympusStakings = [ ]; const OHM_V1 = "0x383518188c0c6d7730d91b2c03a03c837814a899" // this is OHM v1 -const OHM = "0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5" // this is OHM v1 +const OHM = "0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5" +const GOHM = "0x0ab87046fBb341D058F17CBC4c1133F25a20a52f" +const TREASURY_MULTISIG = "0x245cc372c84b3645bf0ffe6538620b04a217988b"; + +const olympusTokens = [ + GOHM, // GOHM + OHM, +]; /** Map any staked assets without price feeds to those with price feeds. * All balances are 1: 1 to their unstaked counterpart that has the price feed. **/ @@ -90,82 +98,80 @@ function sumBalancesByTokenAddress(arr) { * #3. Sum values returned ***/ function buildTvl(isOwnTokensMode = false){ -return async function tvl(api) { -const subgraphUrls = { - ethereum: `7jeChfyUTWRyp2JxPGuuzxvGt3fDKMkC9rLjm7sfLcNp`, - arbitrum: - "2XQDRQ9AXhp5us6PsNyRM5BxKWeXhy3BNQLynA6YmmjA", - fantom: - sdk.graph.modifyEndpoint('3qSJTWdWJETFzht814HVV9rVafwRLQp3k9mZhCF39bYd'), - polygon: - "JCVMW1dbqectgaSLRuKSen6FKe9RPMJRQhNYZa4iTgFb", -}; - - //filter out problematic pools that dont have a decimals function. - const poolsWithoutDecimals = ["0x88051b0eea095007d3bef21ab287be961f3d8598"]; - - const indexedBlockForEndpoint = await blockQuery( - subgraphUrls[api.chain], - getLatestBlockIndexed, - { api } - ); - const blockNum = indexedBlockForEndpoint.lastBlock[0].block; - const { tokenRecords } = await blockQuery( - subgraphUrls[api.chain], - protocolQuery(blockNum), - { api } - ); - - const filteredTokenRecords = tokenRecords.filter( - (t) => !poolsWithoutDecimals.includes(t.tokenAddress) - ); - - const aDay = 24 * 3600; - const now = Date.now() / 1e3; - if (now - blockNum[0].timestamp > 3 * aDay) { - throw new Error("outdated"); + return async function tvl(api) { + const subgraphUrls = { + ethereum: `7jeChfyUTWRyp2JxPGuuzxvGt3fDKMkC9rLjm7sfLcNp`, + arbitrum: + "2XQDRQ9AXhp5us6PsNyRM5BxKWeXhy3BNQLynA6YmmjA", + fantom: + sdk.graph.modifyEndpoint('3qSJTWdWJETFzht814HVV9rVafwRLQp3k9mZhCF39bYd'), + polygon: + "JCVMW1dbqectgaSLRuKSen6FKe9RPMJRQhNYZa4iTgFb", + }; + + //filter out problematic pools that dont have a decimals function. + const poolsWithoutDecimals = ["0x88051b0eea095007d3bef21ab287be961f3d8598"]; + + const indexedBlockForEndpoint = await blockQuery( + subgraphUrls[api.chain], + getLatestBlockIndexed, + { api } + ); + const blockNum = indexedBlockForEndpoint.lastBlock[0].block; + const { tokenRecords } = await blockQuery( + subgraphUrls[api.chain], + protocolQuery(blockNum), + { api } + ); + + const filteredTokenRecords = tokenRecords.filter( + (t) => !poolsWithoutDecimals.includes(t.tokenAddress) + ); + + const aDay = 24 * 3600; + const now = Date.now() / 1e3; + if (now - blockNum[0].timestamp > 3 * aDay) { + throw new Error("outdated"); + } + // const filteredTokenRecords = poolsOnly + // ? tokenRecords.filter((t) => t.category === "Protocol-Owned Liquidity") + // : tokenRecords; + + /** + * iterates over filtered list from subgraph and returns any addresses + * that need to be normalized for pricing . + * See addressMap above + **/ + const normalizedFilteredTokenRecords = filteredTokenRecords.map((token) => { + const normalizedAddress = addressMap[token.tokenAddress] + ? addressMap[token.tokenAddress] + : token.tokenAddress; + return { ...token, tokenAddress: normalizedAddress }; + }); + + const tokensToBalances = sumBalancesByTokenAddress( + normalizedFilteredTokenRecords + ).filter(i => { + if (api.chain !== 'arbitrum') return true; + return !['0x89dc7e71e362faf88d92288fe2311d25c6a1b5e0000200000000000000000423', '0xce6195089b302633ed60f3f427d1380f6a2bfbc7000200000000000000000424'].includes(i.tokenAddress) + }) + const tokens = tokensToBalances.map(i => i.tokenAddress) + + + const decimals = await api.multiCall({ abi: 'erc20:decimals', calls: tokens }) + const ownTokens = new Set(olympusTokens.map(i => i.toLowerCase())) + tokensToBalances.map(async (token, i) => { + if (ownTokens.has(token.tokenAddress.toLowerCase())) { + if (!isOwnTokensMode) return; + } else if (isOwnTokensMode) return; + api.add(token.tokenAddress, token.balance * 10 ** decimals[i]) + }) + return await sumTokens2({ api, resolveLP: true, }) } - // const filteredTokenRecords = poolsOnly - // ? tokenRecords.filter((t) => t.category === "Protocol-Owned Liquidity") - // : tokenRecords; - - /** - * iterates over filtered list from subgraph and returns any addresses - * that need to be normalized for pricing . - * See addressMap above - **/ - const normalizedFilteredTokenRecords = filteredTokenRecords.map((token) => { - const normalizedAddress = addressMap[token.tokenAddress] - ? addressMap[token.tokenAddress] - : token.tokenAddress; - return { ...token, tokenAddress: normalizedAddress }; - }); - - const tokensToBalances = sumBalancesByTokenAddress( - normalizedFilteredTokenRecords - ).filter(i => { - if (api.chain !== 'arbitrum') return true; - return !['0x89dc7e71e362faf88d92288fe2311d25c6a1b5e0000200000000000000000423', '0xce6195089b302633ed60f3f427d1380f6a2bfbc7000200000000000000000424'].includes(i.tokenAddress) - }) - const tokens = tokensToBalances.map(i => i.tokenAddress) - - - const decimals = await api.multiCall({ abi: 'erc20:decimals', calls: tokens }) - const ownTokens = new Set([ - '0x0ab87046fBb341D058F17CBC4c1133F25a20a52f', // GOHM - '0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5', // OHM - ].map(i => i.toLowerCase())) - tokensToBalances.map(async (token, i) => { - if (ownTokens.has(token.tokenAddress.toLowerCase())) { - if (!isOwnTokensMode) return; - } else if (isOwnTokensMode) return; - api.add(token.tokenAddress, token.balance * 10 ** decimals[i]) - }) - return await sumTokens2({ api, resolveLP: true, }) -} } async function ownTokens(api) { + api.sumTokens({ owners: [TREASURY_MULTISIG], tokens: olympusTokens }) return buildTvl(true)(api); } diff --git a/projects/opal/index.js b/projects/opal/index.js new file mode 100644 index 000000000000..5bc6a7b3c159 --- /dev/null +++ b/projects/opal/index.js @@ -0,0 +1,20 @@ +const config = { + ethereum: [ + "0x86b130298719F753808E96cA6540b684a2d21466",// wstETH + "0xD2358c5d01065b13F2Ad1107d5a4531Cd98aC7A1",// rETH + "0x0c8e1e97d9f41a21D6Ef98E644a5516d9b7F593f",// wETH + "0x2165AEA91B33631A772d1723b88a98C1Ca820116",// weETH + "0x4aCc76B4B3E4529D7cE88Ca921D7a4112f25A6dA", // USDC + ] +} + +Object.keys(config).forEach(chain => { + const pools = config[chain] + module.exports[chain] = { + tvl: async (api) => { + const uPools = await api.fetchList({ lengthAbi: 'getUnderlyingPoolsLength', itemAbi: 'function getUnderlyingPool(uint8) view returns (address)', targets: pools, groupedByInput: true, }) + const ownerTokens = uPools.map((tokens, i) => [tokens, pools[i]]) + return api.sumTokens({ ownerTokens }) + } + } +}) \ No newline at end of file diff --git a/projects/palmy/index.js b/projects/palmy/index.js new file mode 100644 index 000000000000..bc3629e90212 --- /dev/null +++ b/projects/palmy/index.js @@ -0,0 +1,10 @@ +const { aaveExports, methodology, } = require("../helper/aave"); + +module.exports = { + methodology, + oas: aaveExports("oas", '0xf4A3dDC5F629d9CB14DF4e7d5f78326153eA02A3', undefined, undefined, { + abis: { + getAllATokens: "function getAllLTokens() view returns (tuple(string symbol, address tokenAddress)[])" + }, + }), +}; diff --git a/projects/paxos-gold/index.js b/projects/paxos-gold/index.js new file mode 100644 index 000000000000..ed819b2e470c --- /dev/null +++ b/projects/paxos-gold/index.js @@ -0,0 +1,11 @@ +const PAXG = '0x45804880de22913dafe09f4980848ece6ecbaf78' + +module.exports = { + methodology: "TVL corresponds to the total amount of PAXG minted", + ethereum: { + tvl: async (api) => { + const totalSupply = await api.call({target: PAXG, abi: 'erc20:totalSupply'}) + api.add(PAXG, totalSupply) + } + } +} diff --git a/projects/pell/index.js b/projects/pell/index.js index e5c090319422..1ba12511bec8 100644 --- a/projects/pell/index.js +++ b/projects/pell/index.js @@ -1,7 +1,7 @@ const { sumTokens2 } = require('../helper/unwrapLPs') const { getConfig } = require('../helper/cache') -const chains = ['merlin', 'bouncebit', 'btr', 'bsc', 'bsquared', 'core', 'bevm'] +const chains = ['merlin', 'bouncebit', 'btr', 'bsc', 'bsquared', 'core', 'bevm', 'mantle', 'scroll', 'bob'] chains.forEach(chain => { module.exports[chain] = { diff --git a/projects/penpad/index.js b/projects/penpad/index.js index 4a835dafc80c..a9546f324e14 100644 --- a/projects/penpad/index.js +++ b/projects/penpad/index.js @@ -26,11 +26,19 @@ module.exports = { [ '0xcA0bFd5f735924e34Cc567146989e467fFbbCe1a', '0x25D710AC957A54bdD6578b5DC8187a355c805edb', - ], // weETH + ], // weETH (Scroll Bridged) [ '0x3C1BCa5a656e69edCD0D4E36BEbb3FcDAcA60Cf1', '0x1C04CedF3Aac5fE35A7811689Ac6Da25b01BDc81', ], // WBTC + [ + '0x01f0a31698c4d065659b9bdc21b3610292a1c506', + '0x016d036ec56eed17b5f9dfa212e27f8e260cc7d0', + ], // weETH (Stargate Bridged) + [ + '0x3ba89d490ab1c0c9cc2313385b30710e838370a4', + '0xde12ec22c5c4eeeeaf8afdc4ec735d75cf9d15a5', + ], // SolvBTC.b ], }), }, diff --git a/projects/phoenix/index.js b/projects/phoenix/index.js index 91d4012115ab..21c4ed56d542 100644 --- a/projects/phoenix/index.js +++ b/projects/phoenix/index.js @@ -2,7 +2,7 @@ const tvl = () => ({}) module.exports = { start: 1631376000, // beijing time 2021-9-11 0:0: - // deadFrom: '2022-09-15', + deadFrom: '2022-09-15', hallmarks: [ [Math.floor(new Date('2022-09-15')/1e3), 'Project is dead: https://twitter.com/Phoenix__PHX/status/1570389804734640129'], ], diff --git a/projects/psyoptions/index.js b/projects/psyoptions/index.js index c77d0b9ec4ce..43371f809786 100644 --- a/projects/psyoptions/index.js +++ b/projects/psyoptions/index.js @@ -127,6 +127,9 @@ async function tvl() { module.exports = { misrepresentedTokens: true, + hallmarks: [ + [1717977600,"Withdrawal Only Mode Announced"] + ], timetravel: false, solana: { tvl, diff --git a/projects/pump-markets/index.js b/projects/pump-markets/index.js index 0568500afd70..0a138e98d506 100644 --- a/projects/pump-markets/index.js +++ b/projects/pump-markets/index.js @@ -8,4 +8,16 @@ module.exports = { tokens: [ADDRESSES.blast.USDB, ADDRESSES.blast.WETH], }), }, + ethereum: { + tvl: sumTokensExport({ + owner: "0x360CFF6ca6278954933A8556D1938B4cF3D747B5", + tokens: [ADDRESSES.ethereum.USDC, ADDRESSES.ethereum.USDT, ADDRESSES.ethereum.WETH], + }), + }, + arbitrum: { + tvl: sumTokensExport({ + owner: "0x360CFF6ca6278954933A8556D1938B4cF3D747B5", + tokens: [ADDRESSES.arbitrum.USDC, ADDRESSES.arbitrum.USDT, ADDRESSES.arbitrum.WETH], + }), + }, }; diff --git a/projects/quasar-swap/index.js b/projects/quasar-swap/index.js index de27a9823122..881d4a937d72 100644 --- a/projects/quasar-swap/index.js +++ b/projects/quasar-swap/index.js @@ -31,7 +31,7 @@ module.exports = { block, }), }, */ - //deadFrom: "2024-01-01", + deadFrom: "2024-01-01", nova: { tvl: () => ({}), staking: () => ({}), diff --git a/projects/real-veRWA/index.js b/projects/real-veRWA/index.js new file mode 100644 index 000000000000..e86393a00163 --- /dev/null +++ b/projects/real-veRWA/index.js @@ -0,0 +1,11 @@ +const { staking } = require('../helper/staking') +const RWAToken = '0x4644066f535Ead0cde82D209dF78d94572fCbf14' +const veRWA = '0xa7B4E29BdFf073641991b44B283FD77be9D7c0F4' + +module.exports = { + misrepresentedTokens: true, + real: { + tvl: () => ({}), + staking: staking(veRWA, RWAToken), + } +} \ No newline at end of file diff --git a/projects/renzo/index.js b/projects/renzo/index.js index 74f234f11f32..94b80e7611f8 100644 --- a/projects/renzo/index.js +++ b/projects/renzo/index.js @@ -2,6 +2,7 @@ const ADDRESSES = require('../helper/coreAssets.json') const L1_EZ_ETH_ADDRESS = "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110"; const L2_EZ_ETH_ADDRESS = ADDRESSES.blast.ezETH; const L1_LOCKBOX_ADDRESS = "0xC8140dA31E6bCa19b287cC35531c2212763C2059"; +const L1_PZ_ETH_ADDRESS = "0x8c9532a60E0E7C6BbD2B2c1303F63aCE1c3E9811"; async function L2Tvl(api) { return { @@ -12,7 +13,9 @@ async function L2Tvl(api) { async function ethTvl(api) { const totalTvl = await api.call({ target: L1_EZ_ETH_ADDRESS, abi: "erc20:totalSupply" }); const lockBoxBalance = await api.call({ target: L1_EZ_ETH_ADDRESS, abi: "erc20:balanceOf", params: [L1_LOCKBOX_ADDRESS] }) - api.add(L1_EZ_ETH_ADDRESS, totalTvl - lockBoxBalance) + const pzEthBalance = await api.call({target: L1_PZ_ETH_ADDRESS, abi: "erc20:totalSupply"}); + api.add(L1_EZ_ETH_ADDRESS, totalTvl - lockBoxBalance); + api.add(L1_PZ_ETH_ADDRESS, pzEthBalance); } const chains = ["mode", "blast", "bsc", "linea", "arbitrum", "base"] diff --git a/projects/rumi/index.js b/projects/rumi/index.js index 7ace8c1690dc..737b047b6459 100644 --- a/projects/rumi/index.js +++ b/projects/rumi/index.js @@ -20,5 +20,5 @@ module.exports = { arbitrum: { tvl: () => ({}), }, - // deadFrom: '2023-12-11', + deadFrom: '2023-12-11', }; \ No newline at end of file diff --git a/projects/satori/index.js b/projects/satori/index.js index 84a21cc679c6..cd0d499a0ea2 100644 --- a/projects/satori/index.js +++ b/projects/satori/index.js @@ -2,6 +2,9 @@ const ADDRESSES = require("../helper/coreAssets.json"); const { sumTokensExport } = require("../helper/unwrapLPs"); const USDT_TOKEN_CONTRACT = ADDRESSES.astarzk.USDT; +const EZETH_BASE = "0x2416092f143378750bb29b79eD961ab195CcEea5"; +const EZETH_LINEA = "0x2416092f143378750bb29b79eD961ab195CcEea5"; +const ZK = "0x5A7d6b2F92C77FAD6CCaBd7EE0624E64907Eaf3E"; const WALLET_ADDR = [ "0x62e724cB4d6C6C7317e2FADe4A03001Fe7856940", "0xA59a2365D555b24491B19A5093D3c99b119c2aBb", @@ -21,7 +24,7 @@ module.exports = { "0x0842b33529516abe86CA8EA771aC4c84FDd0eeE0", "0x48756b37Fd643bB40F669804730024F02900C476", ], - tokens: [ADDRESSES.era.USDC], + tokens: [ADDRESSES.era.USDC, ZK], }), }, linea: { @@ -30,7 +33,7 @@ module.exports = { "0xfb371E70eEB32f4054F40514924e77213ca18425", "0xF96116e124eB3F62Ddc6a9cfbdc58d7F8A37c50A", ], - tokens: [ADDRESSES.linea.USDC], + tokens: [ADDRESSES.linea.USDC, EZETH_LINEA], }), }, scroll: { @@ -48,7 +51,7 @@ module.exports = { "0x668a9711b8d04362876dc5b6177ed362084d5aed", "0x5f075a6a11B2e25DF664Ce7419c274943017B595", ], - tokens: [ADDRESSES.base.USDC], + tokens: [ADDRESSES.base.USDC, EZETH_BASE], }), }, xlayer: { @@ -60,4 +63,4 @@ module.exports = { tokens: [ADDRESSES.xlayer.USDC], }), }, -} \ No newline at end of file +}; diff --git a/projects/satoshi-dex/api.js b/projects/satoshi-dex/api.js new file mode 100644 index 000000000000..f1853181b203 --- /dev/null +++ b/projects/satoshi-dex/api.js @@ -0,0 +1,31 @@ + +const { transformDexBalances } = require('../helper/portedTokens') +const { call } = require('../helper/chain/stacks-api') + +const core = 'SP1W7FX8P1G721KQMQ2MA2G1G4WCVVPD9JZMGXK8R.univ2-core' + +async function tvl() { + const data = [] + const pairCount = +(await call({ target: core, abi: 'get-nr-pools' })).toString() + for (let i = 1; i <= pairCount; i++) { + const { + token0, token1, reserve0, reserve1, + } = await call({ target: core, abi: 'do-get-pool', inputArgs: [{ type: 'uint', value: i }] }) + data.push({ + token0: token0.value, + token1: token1.value, + token0Bal: reserve0.value, + token1Bal: reserve1.value, + }) + } + + return transformDexBalances({ chain: 'stacks', data }) +} + + +module.exports = { + stacks: { + tvl: tvl, + } +} + \ No newline at end of file diff --git a/projects/satoshi-dex/index.js b/projects/satoshi-dex/index.js new file mode 100644 index 000000000000..a5b769fc0b41 --- /dev/null +++ b/projects/satoshi-dex/index.js @@ -0,0 +1,8 @@ +const { getExports } = require('../helper/heroku-api') + +module.exports = { + timetravel: false, + misrepresentedTokens: true, + methodology: 'The calculated TVL is the current USD sum of all pools from core contract', + ...getExports("satoshi-dex", ['stacks']), +} diff --git a/projects/sigmaswap/index.js b/projects/sigmaswap/index.js new file mode 100644 index 000000000000..4e4d03f9a65e --- /dev/null +++ b/projects/sigmaswap/index.js @@ -0,0 +1,14 @@ +const { sumTokens2, nullAddress } = require("../helper/unwrapLPs"); + +const contract = "0xE58a7D7E726CD266c103cC7C2763f4a3005d78B1"; + +async function tvl(api) { + return sumTokens2({ tokens: [nullAddress], owner: contract, api }); +} + +module.exports = { + methodology: `We count the LYX on ${contract}`, + lukso: { + tvl, + }, +}; diff --git a/projects/size-credit/index.js b/projects/size-credit/index.js new file mode 100644 index 000000000000..24b220db467d --- /dev/null +++ b/projects/size-credit/index.js @@ -0,0 +1,23 @@ +const { sumTokensExport } = require('../helper/unwrapLPs') +const ADDRESSES = require('../helper/coreAssets.json') + +const AUSDC_CONTRACT = '0x4e65fe4dba92790696d040ac24aa414708f5c0ab' +const SZDEBT_CONTRACT = '0xb0a00c4b3d77c896f46dc6b204695e22de7a185d' +const SIZE_PROXY_CONTRACT = '0xC2a429681CAd7C1ce36442fbf7A4a68B11eFF940' +const tokens = [ + ADDRESSES.base.WETH, + AUSDC_CONTRACT, +] + +async function borrowed(api) { + const totalDebt = await api.call({ abi: 'erc20:totalSupply', target: SZDEBT_CONTRACT, }); + + return api.add(ADDRESSES.base.USDbC, totalDebt) +} + +module.exports = { + base: { + tvl: sumTokensExport({ tokens, owner: SIZE_PROXY_CONTRACT }), + borrowed + } +} diff --git a/projects/sofa-org/index.js b/projects/sofa-org/index.js index 380b0d6d94be..14109d2f9dbe 100644 --- a/projects/sofa-org/index.js +++ b/projects/sofa-org/index.js @@ -13,7 +13,13 @@ const config = { "0x9C5D3C3AbD633b8eA68C5a51325f8630DC620AD9", "0x2F1C60bA96ec6925fA9bBbFC9Eb7908bD35Bc224", "0x72e0906558e4Ee528974cD7803bfF12d9f2869C3", - "0x9377f17ABde96887943e5Fcc92Db034c76820529" + "0x9377f17ABde96887943e5Fcc92Db034c76820529", + "0x6f4DBcfC81Dd22AE3EDeC5f9724E43cba8C92E50", + "0xA8fcc1BA1D4893a4894206986B65F652D5FE04AB", + "0xA76Ee91c6E51D248782d7C81826dF91522a6EF96", + "0x7E11ce3e893081B111b720dF29669dEf14e81cDE", + "0x8E882A56604F2b5735EA979bD6fa06C064d2f3f9", + "0xf7Be091BCBbB79f3D9029A25Dc94bC8FDd134EaC" ] }, ethereum: { @@ -45,4 +51,4 @@ Object.keys(config).forEach(chain => { return api.sumTokens({ tokensAndOwners2: [[tokens, tokens2, atokens].flat(), [vaults, aVaults, aVaults].flat()] }) } } -}) \ No newline at end of file +}) diff --git a/projects/sorta-fi/index.js b/projects/sorta-fi/index.js new file mode 100644 index 000000000000..8b0ad4dbab83 --- /dev/null +++ b/projects/sorta-fi/index.js @@ -0,0 +1,26 @@ +const { compoundExports2 } = require("../helper/compound"); +const sdk = require('@defillama/sdk') +const { stakings } = require('../helper/staking') + +const contract = '0xE2D74A5f8101E6829409e4Fa8bBADCE2e0012C70' + +function tvl(borrowed = false) { + return async (api, ...args) => { + + const key = borrowed ? 'borrowed' : 'tvl' + const comptrollers = await api.call({ abi: 'address[]:getControllers', target: contract }) + const tvls = comptrollers.map(i => compoundExports2({ comptroller: i })[key]) + return sdk.util.sumChainTvls(tvls)(api, ...args) + } +} + +const stakingContract = '0xd828eB62B026e3eFf70b867FfD8C86C0AEA9dBd8' +const token = '0x73c36aE64842Eaf4D9209dE10fdA21017b5f0709' + +module.exports = { + arbitrum: { + tvl: tvl(), + borrowed: tvl(true), + staking: stakings([stakingContract], token), + } +} diff --git a/projects/sparkdex-v2/index.js b/projects/sparkdex-v2/index.js new file mode 100644 index 000000000000..15b857585c40 --- /dev/null +++ b/projects/sparkdex-v2/index.js @@ -0,0 +1,12 @@ +const { getUniTVL } = require("../helper/unknownTokens"); + +module.exports = { + misrepresentedTokens: true, + flare: { + tvl: getUniTVL({ + factory: "0x16b619B04c961E8f4F06C10B42FDAbb328980A89", + useDefaultCoreAssets: true, + fetchBalances: true, + }), + }, +}; diff --git a/projects/sparkdex-v3/index.js b/projects/sparkdex-v3/index.js new file mode 100644 index 000000000000..b97ba79390f6 --- /dev/null +++ b/projects/sparkdex-v3/index.js @@ -0,0 +1,6 @@ +const { uniV3Export } = require("../helper/uniswapV3"); + +module.exports = uniV3Export({ + flare: { factory: '0xb3fB4f96175f6f9D716c17744e5A6d4BA9da8176', fromBlock: + 26046709, }, +}) diff --git a/projects/splice-fi/index.js b/projects/splice-fi/index.js index 9848b6456fc9..d12f0e3d2cfc 100644 --- a/projects/splice-fi/index.js +++ b/projects/splice-fi/index.js @@ -1,31 +1,33 @@ -const { getLogs } = require("../helper/cache/getLogs"); +const { getLogs, getLogs2 } = require("../helper/cache/getLogs"); const config = { - mode: { + mode: [{ factoryV3: "0x9e6d12097339ddd5402FDD39fc0Ef86Eec54AB39", fromBlockV3: 7764229, - }, - blast: { + }], + blast: [{ factoryV3: "0x96A6C433078059577F0CEB707d596A5F81d64375", fromBlockV3: 1850297, - }, + }, { + factoryV3: "0xf87E18913f7143E7C7eFee714813ABbC8e0E34bf", + fromBlockV3: 1850297, + },], } Object.keys(config).forEach((chain) => { - const { factoryV3, fromBlockV3 } = config[chain]; + const factories = config[chain]; module.exports[chain] = { tvl: async (api) => { - 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 = (await Promise.all(factories.map(i => getLogs2({ + api, + target: i.factoryV3, + topic: [ + "0xae811fae25e2770b6bd1dcb1475657e8c3a976f91d1ebf081271db08eef920af", + ], + eventAbi: + "event CreateNewMarket (address indexed market, address indexed PT, int256 scalarRoot, int256 initialAnchor, uint256 lnFeeRateRoot)", + fromBlock: i.fromBlockV3, + })))).flat() const pt = logsV3.map((i) => i.PT) let sy = [ diff --git a/projects/steer/index.js b/projects/steer/index.js index 753bca2cb0b1..0f1e897d6f0d 100644 --- a/projects/steer/index.js +++ b/projects/steer/index.js @@ -6,25 +6,25 @@ const { stakings } = require("../helper/staking"); const supportedChains = [ { name: 'Polygon', - subgraphEndpoint: sdk.graph.modifyEndpoint('uQxLz6EarmJcr2ymRRmTnrRPi8cCqas4XcPQb71HBvw'), + subgraphEndpoint: 'https://api.goldsky.com/api/public/project_clohj3ta78ok12nzs5m8yag0b/subgraphs/steer-protocol-polygon/1.1.1/gn', chainId: 137, identifier: 'polygon' }, { name: 'Arbitrum', - subgraphEndpoint: sdk.graph.modifyEndpoint('HVC4Br5yprs3iK6wF8YVJXy4QZWBNXTCFp8LPe3UpcD4'), + subgraphEndpoint: 'https://api.goldsky.com/api/public/project_clohj3ta78ok12nzs5m8yag0b/subgraphs/steer-protocol-arbitrum/1.1.0/gn', chainId: 42161, identifier: 'arbitrum' }, { name: 'Optimism', - subgraphEndpoint: sdk.graph.modifyEndpoint('GgW1EwNARL3dyo3acQ3VhraQQ66MHT7QnYuGcQc5geDG'), + subgraphEndpoint: 'https://subgraph-proxy-server-xf2uthetka-as.a.run.app/gateway-arbitrum/GgW1EwNARL3dyo3acQ3VhraQQ66MHT7QnYuGcQc5geDG', chainId: 10, identifier: 'optimism' }, { name: 'Binance', - subgraphEndpoint: sdk.graph.modifyEndpoint('GLDP56fPGDz3MtmhtfTkz5CxWiqiNLACVrsJ9RqQeL4U'), + subgraphEndpoint: 'https://subgraph-proxy-server-xf2uthetka-as.a.run.app/gateway-arbitrum/GLDP56fPGDz3MtmhtfTkz5CxWiqiNLACVrsJ9RqQeL4U', chainId: 56, identifier: 'bsc' }, @@ -36,7 +36,7 @@ const supportedChains = [ }, { name: 'Avalanche', - subgraphEndpoint: sdk.graph.modifyEndpoint('GZotTj3rQJ8ZqVyodtK8TcnKcUxMgeF7mCJHGPYbu8dA'), + subgraphEndpoint: 'https://subgraph-proxy-server-xf2uthetka-as.a.run.app/gateway-arbitrum/GZotTj3rQJ8ZqVyodtK8TcnKcUxMgeF7mCJHGPYbu8dA', chainId: 43114, identifier: 'avax' }, @@ -102,7 +102,7 @@ const supportedChains = [ }, { name: 'Fantom', - subgraphEndpoint: sdk.graph.modifyEndpoint('8k6x2Uho5PEqjxHx5SeSE334MEaxSZqMZhH6p5XYvqjM'), + subgraphEndpoint: 'https://subgraph-proxy-server-xf2uthetka-as.a.run.app/gateway-arbitrum/9uyX2WDuaxmcYh11ehUhU68M9uSCp5FXVQV2w4LqbpbV', chainId: 250, identifier: 'fantom' }, @@ -151,7 +151,7 @@ const supportedChains = [ // { // name: 'Celo', - // subgraphEndpoint: sdk.graph.modifyEndpoint('DDwt4z55qLHPNmasiQXFH3nRjgCBrBhsiz3uEqKRJoa'), + // subgraphEndpoint: 'https://subgraph-proxy-server-xf2uthetka-as.a.run.app/gateway-arbitrum/BPaFHyfVrhv3pdjGodpQcWggAg1Bcrvc9SFc2t2BXeho', // chainId: 42220, // identifier: 'celo' // }, @@ -188,7 +188,8 @@ module.exports.arbitrum.staking = stakings( "0x0b619438d1E8b8c205656502de59Af2Af71C43e0", "0xaCdC6fC8F84fbA26f065489a7bf5837D7CDf546F", "0xff46e1B60dD9De89Aa04902D5c3c5ca01f8576A4", - "0x1E6a358a1721e0D2B84f39FD328FC03A1b6e863B" + "0x1E6a358a1721e0D2B84f39FD328FC03A1b6e863B", + "0x3338B85fB1607C519962571B67061e02408475Bb" ], "0x1C43D05be7E5b54D506e3DdB6f0305e8A66CD04e", "arbitrum" diff --git a/projects/stfil/index.js b/projects/stfil/index.js index d2a1c4f88705..2fd958767c1b 100644 --- a/projects/stfil/index.js +++ b/projects/stfil/index.js @@ -1,18 +1,16 @@ -const ADDRESSES = require('../helper/coreAssets.json') -const {get} = require('../helper/http'); -const BN = require("bn.js"); +const ADDRESSES = require("../helper/coreAssets.json"); +const stFIL = "0x3C3501E6c353DbaEDDFA90376975Ce7aCe4Ac7a8"; +const WFIL = ADDRESSES.filecoin.WFIL; -module.exports = { - filecoin: { - tvl: async (_, _1, _2, {api}) => { - - const {data: {allMinerValue, poolStFilBalance}} = await get("https://api.stfil.io/v1/info"); - const allMinerValueBN = new BN(allMinerValue); - const poolStFilBalanceBN = new BN(poolStFilBalance); - - return api.add(ADDRESSES.null, allMinerValueBN.add(poolStFilBalanceBN)); - } - } -} +const tvl = async (api) => { + const stFILSupply = await api.call({ target: stFIL, abi: 'erc20:totalSupply' }) + api.add(WFIL, stFILSupply) +}; +module.exports = { + methodology: 'stFIL tokens are minted upon filecoin deposit at 1:1 ratio', + filecoin: { + tvl, + }, +}; diff --git a/projects/strater/index.js b/projects/strater/index.js index 5e92b64b0262..292c71ff13d1 100644 --- a/projects/strater/index.js +++ b/projects/strater/index.js @@ -36,6 +36,8 @@ const STAPREAL_VAULT_ID = const STAPEARL_PAIR_METADTA_ID = "0x243096d976a44de24fde33f087665f8265543a533b5cdbae60fc72a939669867"; +const ST_SBUCK_VAULT_OBJECT_ID = "0xe83e455a9e99884c086c8c79c13367e7a865de1f953e75bcf3e529cdf03c6224" + function asIntN(int, bits = 32) { return Number(BigInt.asIntN(bits, BigInt(int))); } @@ -92,8 +94,18 @@ async function tvl(api) { const stapearlUSDTAmount = (stapearlLpAmount * stapearlReserveY) / stapearlLpSupply; + // saving vault + const savingVaultcObj = await sui.getObject(ST_SBUCK_VAULT_OBJECT_ID) + let savingVaultTVL = Number(savingVaultcObj.fields.free_balance) + Number(savingVaultcObj.fields.time_locked_profit.fields.locked_balance) + Number(savingVaultcObj.fields.time_locked_profit.fields.unlocked_balance) + const strategies = savingVaultcObj.fields.strategies.fields.contents + for(const strategy of strategies){ + const botrrowedAmount = Number(strategy.fields.value.fields.borrowed) + savingVaultTVL += botrrowedAmount + } + api.add(ADDRESSES.sui.USDC, stapearlUSDCAmount); api.add(ADDRESSES.sui.USDT, stapearlUSDTAmount); + api.add(ADDRESSES.sui.BUCK, savingVaultTVL) } module.exports = { diff --git a/projects/streamflow/index.js b/projects/streamflow/index.js index 0c829ce41adf..993db79e4731 100644 --- a/projects/streamflow/index.js +++ b/projects/streamflow/index.js @@ -10,6 +10,7 @@ const chains = [ "bsc", "polygon", "ethereum", + "sui", ]; const chainMapping = { bsc: 'bnb' @@ -32,7 +33,7 @@ async function getCachedApiRespnse() { async function tvl(api) { return { - tether: getValueForKey(await getCachedApiRespnse(), api.chain, TVL_KEY), + tether: 0 } } async function vesting(api) { diff --git a/projects/sturdy-v2/index.js b/projects/sturdy-v2/index.js index b831810d8d3f..e525b2a71a1d 100644 --- a/projects/sturdy-v2/index.js +++ b/projects/sturdy-v2/index.js @@ -4,6 +4,9 @@ const abi = require("./abi.json"); const config = { ethereum: '0x69764E3e0671747A7768A1C1AfB7C0C39868CC9e', mode: '0xF0382A9Eca5276d7B4BbcC503e4159C046c120ec', + linea: "0xd67Da8636Ae87b0cECBDa2e66dB58d4839722B52", + optimism: "0x9dc7B2130e478C5810Dc0cDbD46B9D479b2e1aC4", + sei: "0x4534F53A81416a83F6bAF5ac63c94aEd1fea1303", } module.exports = { diff --git a/projects/sumer/index.js b/projects/sumer/index.js index 02958bea500d..aaf4cf6016e3 100644 --- a/projects/sumer/index.js +++ b/projects/sumer/index.js @@ -4,4 +4,5 @@ module.exports = { meter: compoundExports2({ comptroller: '0xcB4cdDA50C1B6B0E33F544c98420722093B7Aa88' }), base: compoundExports2({ comptroller: '0x611375907733D9576907E125Fb29704712F0BAfA' }), arbitrum: compoundExports2({ comptroller: '0xBfb69860C91A22A2287df1Ff3Cdf0476c5aab24A' }), + ethereum: compoundExports2({ comptroller: '0x60A4570bE892fb41280eDFE9DB75e1a62C70456F' }), } \ No newline at end of file diff --git a/projects/superhero-dex/index.js b/projects/superhero-dex/index.js new file mode 100644 index 000000000000..e1aa3ba05f11 --- /dev/null +++ b/projects/superhero-dex/index.js @@ -0,0 +1,26 @@ +const { get } = require('../helper/http') +const { transformDexBalances } = require("../helper/portedTokens"); + +async function tvl(api) { + const allPools = []; + const pairs = await get('https://dex-backend-mainnet.prd.service.aepps.com/pairs') + for (const pair of pairs) { + const [pairLiquidityInfo] = await get('https://dex-backend-mainnet.prd.service.aepps.com/history?pairAddress=' + pair.address + '&limit=100&order=desc&toBlockTime=' + api.timestamp * 1000); + allPools.push({ + token0: pair.token0, + token0Bal: pairLiquidityInfo?.reserve0 || 0, + token1: pair.token1, + token1Bal: pairLiquidityInfo?.reserve1 || 0, + }) + } + + return transformDexBalances({ chain: 'aeternity', data: allPools, }); +} + + +module.exports = { + methodology: 'TVL is calculated based on tokens that are locked in the Superhero DEX pools.', + aeternity: { + tvl, + }, +}; \ No newline at end of file diff --git a/projects/swaap-v2/index.js b/projects/swaap-v2/index.js index 85b4c305395d..c2a7fecc9211 100644 --- a/projects/swaap-v2/index.js +++ b/projects/swaap-v2/index.js @@ -6,7 +6,7 @@ const {onChainTvl} = require("../helper/balancer"); */ const config = { ethereum: { vault: '0xd315a9c38ec871068fec378e4ce78af528c76293', fromBlock: 17598578, }, - arbitrum: { vault: '0xd315a9c38ec871068fec378e4ce78af528c76293', fromBlock: 137451745,}, + arbitrum: { vault: '0xd315a9c38ec871068fec378e4ce78af528c76293', fromBlock: 137451745, permitFailure: true }, polygon: { vault: '0xd315a9c38ec871068fec378e4ce78af528c76293', fromBlock: 44520023,}, optimism: { vault: '0xd315a9c38ec871068fec378e4ce78af528c76293', fromBlock: 120693792, }, bsc: { vault: '0x03c01acae3d0173a93d819efdc832c7c4f153b06', fromBlock: 39148730,}, @@ -22,8 +22,8 @@ const config = { Object.keys(config).forEach(chain => { - const { vault, fromBlock } = config[chain] + const { vault, fromBlock, permitFailure } = config[chain] module.exports[chain] = { - tvl: onChainTvl(vault, fromBlock) + tvl: onChainTvl(vault, fromBlock, { permitFailure }) } }) \ No newline at end of file diff --git a/projects/symbiosis-finance/config.js b/projects/symbiosis-finance/config.js index 89c49ce315b9..bc211d0e2eef 100644 --- a/projects/symbiosis-finance/config.js +++ b/projects/symbiosis-finance/config.js @@ -32,7 +32,8 @@ const TOKENS = { USDC: ADDRESSES.cronos.USDC }, fraxtal: { - WETH: ADDRESSES.fraxtal.WETH + WETH: ADDRESSES.fraxtal.WETH, + FRAX: ADDRESSES.fraxtal.FRAX } } @@ -45,6 +46,7 @@ module.exports = { ADDRESSES.ethereum.USDT, ADDRESSES.ethereum.WETH, ADDRESSES.ethereum.WBTC, + ADDRESSES.ethereum.FRAX, TOKENS.ethereum.XDAO, TOKENS.ethereum.LADYS, TOKENS.ethereum.pufETH, @@ -89,6 +91,7 @@ module.exports = { tokens: [ ADDRESSES.polygon.USDC, ADDRESSES.polygon.WETH_1, + ADDRESSES.polygon.FRAX, TOKENS.polygon.XDAO, ], holders: [ @@ -181,6 +184,7 @@ module.exports = { ADDRESSES.arbitrum.USDC, // USDC.e ADDRESSES.arbitrum.USDC_CIRCLE, ADDRESSES.arbitrum.WETH, + ADDRESSES.arbitrum.FRAX, TOKENS.arbitrum.XDAO, TOKENS.arbitrum.LADYS, ], @@ -399,6 +403,7 @@ module.exports = { name: 'fraxtal', tokens: [ TOKENS.fraxtal.WETH, + TOKENS.fraxtal.FRAX, ], holders: [ '0x292fC50e4eB66C3f6514b9E402dBc25961824D62', // portal v2 diff --git a/projects/synfutures-v3/index.js b/projects/synfutures-v3/index.js index 8137beac85a8..ce88eaf6cd1d 100644 --- a/projects/synfutures-v3/index.js +++ b/projects/synfutures-v3/index.js @@ -1,29 +1,26 @@ -const { sumTokensExport } = require('../helper/unwrapLPs') -const ADDRESSES = require('../helper/coreAssets.json') const { sumTokens2 } = require('../helper/unwrapLPs') -const { getLogs, getAddress } = require('../helper/cache/getLogs'); -const { ethers } = require('ethers'); - +const { getLogs2, } = require('../helper/cache/getLogs') const config = { - blast: { gate: '0x6A372dBc1968f4a07cf2ce352f410962A972c257', tokens: [ADDRESSES.blast.USDB, ADDRESSES.blast.WETH], fromBlock: 193856 }, + blast: { gate: '0x6A372dBc1968f4a07cf2ce352f410962A972c257', fromBlock: 193856 }, + base: { gate: '0x208B443983D8BcC8578e9D86Db23FbA547071270', fromBlock: 16297319 }, } Object.keys(config).forEach(chain => { - const { gate, tokens, fromBlock } = config[chain] + const { gate, fromBlock } = config[chain] module.exports[chain] = { tvl: async (api) => { // calculate the balance of all instruments - const logs = await getLogs({ + const logs = await getLogs2({ api, target: gate, - topics: ['0x2f642d4751a7e76430c4c9b3abe8ab9fd9ed0daa08cae14b5594765049008e02'], fromBlock, eventAbi: 'event NewInstrument(bytes32 index, address instrument, address base, address quote, string symbol, uint total)', }) - const tokensAndOwners = logs.map(i => ([i.args.quote, i.args.instrument])) - tokens.forEach(token => tokensAndOwners.push([token, gate])) - return sumTokens2({ api, tokensAndOwners: tokensAndOwners }) + const ownerTokens = logs.map(i => ([[i.quote], i.instrument])) + const allTokens = logs.map(i => i.quote) + ownerTokens.push([allTokens, gate]) + return sumTokens2({ api, ownerTokens }) } } }) diff --git a/projects/synonym-finance/index.js b/projects/synonym-finance/index.js index a3ed39f2656a..75f00c60cfdc 100644 --- a/projects/synonym-finance/index.js +++ b/projects/synonym-finance/index.js @@ -1,25 +1,39 @@ +const sdk = require("@defillama/sdk"); const bytes32ToAddress = (bytes32Address) => "0x" + bytes32Address.substr(-40); const hub = '0x1e3f1f1cA8C62aABCB3B78D87223E988Dfa3780E' -async function tvl(api) { - const { tokens, tokenMappings } = await getTokenInfos(api) +async function tvl({timestamp, chain}) { + const api = new sdk.ChainApi({ timestamp, chain: 'arbitrum' }) + const { tokens, tokenMappings } = await getTokenInfos(api, chain) const bals = await api.multiCall({ abi: 'erc20:balanceOf', calls: tokens.map(token => ({ target: token, params: hub })) }) api.add(tokenMappings, bals, { skipChain: true }) return api.getBalances() } -async function borrowed(api) { - const { tokens, tokenMappings } = await getTokenInfos(api) +async function borrowed({timestamp, chain }) { + const api = new sdk.ChainApi({ timestamp, chain: 'arbitrum' }) + const { tokens, tokenMappings } = await getTokenInfos(api, chain) const bals = (await api.multiCall({ abi: "function getGlobalAmounts(address assetAddress) view returns ((uint256 deposited, uint256 borrowed))", calls: tokens, target: hub })).map(i => i.borrowed) api.add(tokenMappings, bals, { skipChain: true }) return api.getBalances() } -module.exports = { - arbitrum: { tvl, borrowed, }, -} +const chains = [ + 'arbitrum', + 'ethereum', + 'optimism', + 'base', + 'scroll', +] + +chains.forEach(chain => { + module.exports[chain] = { + tvl, + borrowed + } +}) -async function getTokenInfos(api) { +async function getTokenInfos(api, requestedChain) { const registry = await api.call({ abi: 'address:getAssetRegistry', target: hub }) const tokenBridge = await api.call({ abi: 'address:tokenBridge', target: hub }) const assets = await api.call({ abi: 'address[]:getRegisteredAssets', target: registry }) @@ -31,12 +45,18 @@ async function getTokenInfos(api) { bridgedAssets.push(asset) else arbiAssets.push(asset) - }) + + if (requestedChain === 'arbitrum') { + return { tokens: arbiAssets, tokenMappings: arbiAssets.map(asset => 'arbitrum:' + asset) } + } + const natives = await api.multiCall({ abi: 'function nativeContract() view returns (bytes32)', calls: bridgedAssets }) const chainId = await api.multiCall({ abi: 'function chainId() view returns (uint16)', calls: bridgedAssets }) - const tokens = arbiAssets - const tokenMappings = arbiAssets.map(asset => 'arbitrum:' + asset) + + const tokens = [] + const tokenMappings = [] + bridgedAssets.forEach((asset, i) => { let chain; switch (chainId[i]) { @@ -46,8 +66,11 @@ async function getTokenInfos(api) { case '34': chain = 'scroll'; break; default: console.log('Unsupported chain ' + chainId[i] + bytes32ToAddress(natives[i])); return; } - tokenMappings.push(chain + ':' + bytes32ToAddress(natives[i])) - tokens.push(asset) + + if (chain === requestedChain) { + tokens.push(asset) + tokenMappings.push(chain + ':' + bytes32ToAddress(natives[i])) + } }) return { tokens, tokenMappings } diff --git a/projects/term-finance/index.js b/projects/term-finance/index.js index 77b168a9d3b7..87415e3dec9b 100644 --- a/projects/term-finance/index.js +++ b/projects/term-finance/index.js @@ -47,6 +47,7 @@ const emitters = { "0x9D6a563cf79d47f32cE46CD7b1fb926eCd0f6160", // 0.2.4 "0xf268E547BC77719734e83d0649ffbC25a8Ff4DB3", // 0.4.1 "0xc60e0f5cD9EE7ACd22dB42F7f56A67611ab6429F", // 0.6.0 + "0x4C6Aeb4E8dBBAF53c13AF495c847D4eC68994bD4", // 0.9.0 ], "avax": [ "0xb81afB6724ba9d19a3572Fb29ed7ef633fD50093", // 0.6.0 diff --git a/projects/tether-gold/index.js b/projects/tether-gold/index.js new file mode 100644 index 000000000000..0a36aa839213 --- /dev/null +++ b/projects/tether-gold/index.js @@ -0,0 +1,11 @@ +const XAUt = '0x68749665ff8d2d112fa859aa293f07a622782f38' + +module.exports = { + methodology: "TVL corresponds to the total amount of XAUt minted", + ethereum: { + tvl: async (api) => { + const totalSupply = await api.call({target: XAUt, abi: 'erc20:totalSupply'}) + api.add(XAUt, totalSupply) + } + } +} diff --git a/projects/thetanuts/index.js b/projects/thetanuts/index.js index 62aad31bf8b5..ecf12f8b4401 100644 --- a/projects/thetanuts/index.js +++ b/projects/thetanuts/index.js @@ -1,5 +1,5 @@ const ADDRESSES = require('../helper/coreAssets.json') -const { sumTokensExport } = require('../helper/unwrapLPs') +const { sumTokensExport, sumTokens2 } = require('../helper/unwrapLPs') // Ethereum Vaults const ethCallVault = '0x9014f8E90423766343Ed4fe41668563526dF6715' @@ -240,11 +240,11 @@ const config = { [PTrsETH_26SEP24, aPTrsETH_26SEP24,], [PTweETH_26SEP24, aPTweETH_26SEP24,], ], - LLVOwners: [ - [univ3nft_arb, arbC_LLV,], - [univ3nft_arb, arbP_LLV,], - [univ3nft_arb, ethC_LLV,], - [univ3nft_arb, ethP_LLV,], + uniV3Owners: [ + arbC_LLV, + arbP_LLV, + ethC_LLV, + ethP_LLV, ] }, fantom: { @@ -310,8 +310,11 @@ const config = { } Object.keys(config).forEach(chain => { - const { tokensAndOwners, LLVOwners } = config[chain] + const { tokensAndOwners, uniV3Owners } = config[chain] module.exports[chain] = { - tvl: sumTokensExport({ tokensAndOwners, resolveUniV3 : LLVOwners != null && LLVOwners.length > 0 ? true : false, uniV3nftsAndOwners : LLVOwners }) + tvl: async (api) => { + if (uniV3Owners) await sumTokens2({ api, owners: uniV3Owners, resolveUniV3: true}) + return sumTokens2({ api, tokensAndOwners}) + } } }) diff --git a/projects/tonbridge.js b/projects/tonbridge.js index a7cd42ef9ee0..730263b45cda 100644 --- a/projects/tonbridge.js +++ b/projects/tonbridge.js @@ -13,13 +13,13 @@ const tokenMap = { //'f48054939064d686a9ad68d96d9ab79e409b095557c06ab7f073097dade7057f': 'dartflex', //'00ca16398f314a9b3bed582dc69582515d866ededb6c4e18190f63b305cedf91': NA 'a49cd4e158a9a15555e624759e2e4e766d22600b7800d891e46f9291f044a93d': 'everscale', - 'b2e341c01da068d43cfa0eae6dae36b12b476e55cf2c3eeb002689f44b9ddef9': 'aave', - 'bc77ba7f3cbbebcca393e85ed479ef44df63cdee4fb572c3e0f904fb9fc63e25': 'compound-governance-token', - '7dd7ae82835848dc6b490515ec4034968a8ceff893a6d5f31ab3cdfcfb79bbb6': 'curve-dao-token', - '6b2baa777b89da66dddaf9f1602142987b13ca565bbb170da929ea945f5ce9fb': 'stasis-eurs', + // 'b2e341c01da068d43cfa0eae6dae36b12b476e55cf2c3eeb002689f44b9ddef9': 'aave', + // 'bc77ba7f3cbbebcca393e85ed479ef44df63cdee4fb572c3e0f904fb9fc63e25': 'compound-governance-token', + // '7dd7ae82835848dc6b490515ec4034968a8ceff893a6d5f31ab3cdfcfb79bbb6': 'curve-dao-token', + // '6b2baa777b89da66dddaf9f1602142987b13ca565bbb170da929ea945f5ce9fb': 'stasis-eurs', //'387609364f765017fa3fa5815e08d420e054c88a86426cd6d5aaf2a1ee46ff5a': 'torn', - 'e114f1f7d21ac6566d988c983315e0cdd5bee7b43c08918537d1117dea7e4534': 'yearn-finance', - '3c66e3e0ce0a909ce8779b31509db773e544132d8fa6f6641c00bce257c79d9c': '1inch', + // 'e114f1f7d21ac6566d988c983315e0cdd5bee7b43c08918537d1117dea7e4534': 'yearn-finance', + // '3c66e3e0ce0a909ce8779b31509db773e544132d8fa6f6641c00bce257c79d9c': '1inch', //'bf1c7c0e8a187d9d5ba6069bf768b69a982df8b22ef8430b31dcc4f97263507e': 'dartflex' }; diff --git a/projects/treasury/venus.js b/projects/treasury/venus.js index e4ff6d42dead..2098881e8064 100644 --- a/projects/treasury/venus.js +++ b/projects/treasury/venus.js @@ -1,25 +1,63 @@ -const ADDRESSES = require('../helper/coreAssets.json') -const { nullAddress,treasuryExports } = require("../helper/treasury"); +const ADDRESSES = require("../helper/coreAssets.json"); +const { nullAddress, treasuryExports } = require("../helper/treasury"); const venusTreasury = "0xF322942f644A996A617BD29c16bd7d231d9F35E9"; const XVS = "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c63"; const venusBTC = "0x882C173bC7Ff3b7786CA16dfeD3DFFfb9Ee7847B"; -const VAI = "0x4BD17003473389A42DAF6a0a729f6Fdb328BbBd7" - +const VAI = "0x4BD17003473389A42DAF6a0a729f6Fdb328BbBd7"; module.exports = treasuryExports({ bsc: { - tokens: [ - nullAddress, - ADDRESSES.bsc.USDT,//bsc-usdc - ADDRESSES.bsc.USDC,//usdc - ADDRESSES.bsc.BTCB,//BTCB - '0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3',//DAI - ADDRESSES.bsc.BETH,//BETH - - ], + tokens: [ + nullAddress, + ADDRESSES.bsc.USDT, //bsc-usdc + ADDRESSES.bsc.USDC, //usdc + ADDRESSES.bsc.BTCB, //BTCB + "0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3", //DAI + ADDRESSES.bsc.BETH, //BETH + ADDRESSES.bsc.WBNB, + venusBTC, + "0x2170Ed0880ac9A755fd29B2688956BD959F933F8", //eth + "0xecA88125a5ADbe82614ffC12D0DB554E2e2867C8", // venusUSDC + "0xf508fCD89b8bd15579dc79A6827cB4686A3592c8", // venusETH + "0xfD5840Cd36d94D7229439859C0112a4185BC0255", // venusUSDT + "0xB248a295732e0225acd3337607cc01068e3b9c10", // venusXRP + "0x95c78222B3D6e262426483D42CfA53685A67Ab9D", // venusBUSD + "0xA07c5b74C9B40447a954e1466938b865b6BBea36", // venusBNB + "0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82", //cake + "0xF4C8E32EaDEC4BFe97E0F595AdD0f4450a863a11", //thena + "0x4338665CBB7B2485A8855A139b75D5e34AB0DB94", //ltc + "0xfb5B838b6cfEEdC2873aB27866079AC55363D37E", //floki + "0x20eE7B720f4E4c4FFcB00C4065cdae55271aECCa", //nft + "0xBf5140A22578168FD562DCcF235E5D43A02ce9B1", //uni + "0x47BEAd2563dCBf3bF2c9407fEa4dC236fAbA485A", //sxp + "0x7083609fCE4d1d8Dc0C979AAb8c869Ea2C873402", //dot + "0x1D2F0da169ceB9fC7B3144628dB156f3F6c60dBE", //xrp + "0x3EE2200Efb3400fAbB9AacF31297cBdD1d435D47", //ada + "0xF8A0BF9cF54Bb92F17374d9e9A321E6a111a51bD", //link + "0xbA2aE424d960c26247Dd6c32edC70B295c744C43", //doge + "0x40af3827F39D0EAcBF4A168f8D4ee67c121D11c9", //tusd + "0x0D8Ce2A99Bb6e3B7Db580eD848240e4a0F9aE153", //fil + "0xCC42724C6683B7E57334c4E856f4c9965ED682bD", //matic + "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56", //busd + "0x52F24a5e03aee338Da5fd9Df68D2b6FAe1178827", //ankrbnb + "0xCE7de646e7208a4Ef112cb6ed5038FA6cC6b12e3", //trx + "0x352Cb5E19b12FC216548a2677bD0fce83BaE434B", //btt + "0x8fF795a6F4D97E7887C79beA79aba5cc76444aDf", //bch + "0xd17479997F34dd9156Deef8F95A52D81D265be9c", //usdd + "0x302cD8973bE5CA2334B4ff7e7b01BA41455559b3", //ethw + "0x1bdd3Cf7F79cfB8EdbB955f20ad99211551BA275", //bnbx + "0x965F527D9159dCe6288a2219DB51fc6Eef120dD1", //bsw + "0xc2E9d07F66A89c44062459A47a0D2Dc038E4fb16", //stkbnb + "0xaeF0d72a118ce24feE3cD1d43d383897D05B4e99", //win + "0x0782b6d8c4551B9760e74c0545a9bCD90bdc41E5", //lisusd + "0x12BB890508c125661E03b09EC06E404bc9289040", //raca + "0x4B0F1812e5Df2A09796481Ff14017e6005508003", //twt + "0x8F0528cE5eF7B51152A59745bEfDD91D97091d2F", //alpaca + "0x12f31B73D812C6Bb0d735a218c086d44D5fe5f89", //ageur + ], owners: [venusTreasury], - ownTokens: [XVS, venusBTC, VAI], + ownTokens: [XVS, VAI], }, -}) \ No newline at end of file +}); diff --git a/projects/uniswap/index.js b/projects/uniswap/index.js index f663be83487c..28d12b541b61 100644 --- a/projects/uniswap/index.js +++ b/projects/uniswap/index.js @@ -85,8 +85,8 @@ module.exports = { manta: { factory: "0x06D830e15081f65923674268121FF57Cc54e4e23", fromBlock: 1191705 }, avax: { factory: "0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD", fromBlock: 27832972 }, taiko: { factory: "0x75FC67473A91335B5b8F8821277262a13B38c9b3", fromBlock: 961 }, - sei: { factory: "0x75FC67473A91335B5b8F8821277262a13B38c9b3", fromBlock: 79245151 } - + sei: { factory: "0x75FC67473A91335B5b8F8821277262a13B38c9b3", fromBlock: 79245151 }, + mantle: { factory: "0x0d922Fb1Bc191F64970ac40376643808b4B74Df9", fromBlock: 63795918 } }), filecoin: { tvl: filecoinTvl }, } diff --git a/projects/usual/index.js b/projects/usual/index.js new file mode 100644 index 000000000000..6d5c7e3c2aaa --- /dev/null +++ b/projects/usual/index.js @@ -0,0 +1,12 @@ + +const { sumTokensExport } = require('../helper/unwrapLPs') + +const USYC = '0x136471a34f6ef19fe571effc1ca711fdb8e49f2b' +const treasury = '0xdd82875f0840AAD58a455A70B88eEd9F59ceC7c7' + +module.exports = { + methodology: 'TVL represents the value in RWA held by the protocol', + ethereum: { + tvl: sumTokensExport({ token: USYC, owner: treasury}) + } +} \ No newline at end of file diff --git a/projects/vela-exchange/index.js b/projects/vela-exchange/index.js index e7652239c761..f1ae88d8b58c 100644 --- a/projects/vela-exchange/index.js +++ b/projects/vela-exchange/index.js @@ -5,57 +5,40 @@ const { graphQuery } = require('../helper/http') const VELA = '0x088cd8f5eF3652623c22D48b1605DCfE860Cd704' -const arbitrumEndpoint = sdk.graph.modifyEndpoint('6H9PEiNPZgwXfpbijjesZh96LFBzUvkHmEutMoYQ9fvp') -const baseEndpoint = sdk.graph.modifyEndpoint('2qsbZ4X5TJM7NupC2eRJv167kBDFCDBd37KnK7PQtdga') -async function staking_arbitrum_(api) { +const arbitrumEndpoint = 'https://api.goldsky.com/api/public/project_clu01p4nr68r301pze2tj4sh7/subgraphs/vela-arbitrum/mainnet/gn' +const baseEndpoint = 'https://api.goldsky.com/api/public/project_clu01p4nr68r301pze2tj4sh7/subgraphs/vela-base/mainnet/gn' +async function velaStaking(api, endpoint) { const query = ` - query { - poolInfos(where: { - id: "all" - }) { - pid1 - pid2 - pid3 - } + query { + poolInfos(where: { + id: "all" + }) { + pid1 + pid2 + pid3 } - `; - const graphRes = (await graphQuery(arbitrumEndpoint, query)).poolInfos.find(x => true); - api.add(VELA, graphRes?.pid2) - api.add(VELA, graphRes?.pid3) -} - -async function staking_base_(api) { - - const query = ` - query { - poolInfos(where: { - id: "all" - }) { - pid1 - pid2 - pid3 - } - } - `; - const graphRes = (await graphQuery(baseEndpoint, query)).poolInfos.find(x => true); - api.add(VELA, graphRes?.pid2) - api.add(VELA, graphRes?.pid3) + } + `; + const graphRes = (await graphQuery(endpoint, query)).poolInfos.find(x => true); + api.add(VELA, graphRes?.pid2); + api.add(VELA, graphRes?.pid3); } module.exports = { methodology: "Counts USDC deposited to trade and to mint VLP. Staking counts VELA and esVELA deposited to earn esVELA", arbitrum: { - tvl: staking('0xC4ABADE3a15064F9E3596943c699032748b13352', [ADDRESSES.arbitrum.USDC_CIRCLE, ADDRESSES.arbitrum.USDC]), - staking: staking_arbitrum_ + tvl: staking('0xC4ABADE3a15064F9E3596943c699032748b13352', [ADDRESSES.arbitrum.USDC_CIRCLE,ADDRESSES.arbitrum.USDC, "0x724dc807b04555b71ed48a6896b6f41593b8c637"]), + staking: async (api) => velaStaking(api,arbitrumEndpoint) }, base: { start: 3566528, tvl: staking("0xC4ABADE3a15064F9E3596943c699032748b13352", ADDRESSES.base.USDbC), - staking: staking_base_ + staking: async (api) => velaStaking(api,baseEndpoint) }, hallmarks: [ [Math.floor(new Date('2023-04-13') / 1e3), 'Refunded tokens to VLP holders & traders'], - [1693926000, 'Launched on Base Chain'] + [1693926000, 'Launched on Base Chain'], + [1721314800, 'Implemented Aave VLP supply integration'] ], } diff --git a/projects/venus-isolated-pools/index.js b/projects/venus-isolated-pools/index.js index 4622bd4693b7..d4585e82f706 100644 --- a/projects/venus-isolated-pools/index.js +++ b/projects/venus-isolated-pools/index.js @@ -9,7 +9,11 @@ const config = { ethereum: { endpoint: sdk.graph.modifyEndpoint('Htf6Hh1qgkvxQxqbcv4Jp5AatsaiY5dNLVcySkpCaxQ8'), corePools: ['0x67aA3eCc5831a65A5Ba7be76BED3B5dc7DB60796'], - } + }, + /*arbitrum: { + endpoint: sdk.graph.modifyEndpoint('2zqpTYBL3X1E2eb129bKno1pJdx6xBawr8urp61w33Z8'), + corePools: ['0x317c1A5739F39046E20b08ac9BeEa3f10fD43326'] + },*/ } Object.keys(config).forEach(chain => { diff --git a/projects/venus.js b/projects/venus.js index d60ffe1c2dee..6f552d30a8cf 100644 --- a/projects/venus.js +++ b/projects/venus.js @@ -11,4 +11,5 @@ module.exports = fullCoumpoundExports("0xfd36e2c2a6789db23113685031d7f1632915838 }) module.exports.ethereum = compoundExports2({ comptroller: '0x67aA3eCc5831a65A5Ba7be76BED3B5dc7DB60796'}) -module.exports.op_bnb = compoundExports2({ comptroller: '0xd6e3e2a1d8d95cae355d15b3b9f8e5c2511874dd'}) \ No newline at end of file +module.exports.op_bnb = compoundExports2({ comptroller: '0xd6e3e2a1d8d95cae355d15b3b9f8e5c2511874dd'}) +module.exports.arbitrum = compoundExports2({ comptroller: '0x317c1A5739F39046E20b08ac9BeEa3f10fD43326'}) \ No newline at end of file diff --git a/projects/vesu/abi.js b/projects/vesu/abi.js new file mode 100644 index 000000000000..fbb644f722f1 --- /dev/null +++ b/projects/vesu/abi.js @@ -0,0 +1,94 @@ +const allAbi = [ + + { + type: "function", + name: "decimals", + inputs: [], + outputs: [ + { + type: "core::integer::u8", + }, + ], + state_mutability: "view", + }, + + { + "type": "function", + "name": "asset_config_unsafe", + "inputs": [ + { + "name": "pool_id", + "type": "felt" + }, + { + "name": "asset", + "type": "felt" + } + ], + "outputs": [ + { + "type": "(vesu::data_model::AssetConfig, core::integer::u256)" + } + ], + "state_mutability": "view", + "customInput": "address" + }, + { + "type": "struct", + "name": "vesu::data_model::AssetConfig", + "members": [ + { + "name": "total_collateral_shares", + "type": "core::integer::u256" + }, + { + "name": "total_nominal_debt", + "type": "core::integer::u256" + }, + { + "name": "reserve", + "type": "core::integer::u256" + }, + { + "name": "max_utilization", + "type": "core::integer::u256" + }, + { + "name": "floor", + "type": "core::integer::u256" + }, + { + "name": "scale", + "type": "core::integer::u256" + }, + { + "name": "is_legacy", + "type": "core::bool" + }, + { + "name": "last_updated", + "type": "core::integer::u64" + }, + { + "name": "last_rate_accumulator", + "type": "core::integer::u256" + }, + { + "name": "last_full_utilization_rate", + "type": "core::integer::u256" + }, + { + "name": "fee_rate", + "type": "core::integer::u256" + } + ] + }, +] + +const abi = {} +allAbi.forEach(i => abi[i.name] = i) + +module.exports = { + abi, + allAbi +} \ No newline at end of file diff --git a/projects/vesu/index.js b/projects/vesu/index.js new file mode 100644 index 000000000000..2e85366489a4 --- /dev/null +++ b/projects/vesu/index.js @@ -0,0 +1,36 @@ +const { multiCall, sumTokens } = require("../helper/chain/starknet"); +const { abi, allAbi } = require("./abi"); + +const INTERNAL_SCALE = 10 ** 18; +const SINGLETON = "0x02545b2e5d519fc230e9cd781046d3a64e092114f07e44771e0d719d148725ef"; +const POOL_ID = "0x4dc4f0ca6ea4961e4c8373265bfd5317678f4fe374d76f3fd7135f57763bf28"; +const ASSETS = [ + "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", + "0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac", + "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8", + "0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8", + "0x042b8f0484674ca266ac5d08e4ac6a3fe65bd3129795def2dca5c34ecc5f96d2", + "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d", +]; + +async function tvl(api) { + return sumTokens({ api, owner: SINGLETON, tokens: ASSETS }); +} + +const borrowed = async (api) => { + const calls = ASSETS.map((asset) => ({ target: SINGLETON, params: [POOL_ID, asset] })); + const assetStates = await multiCall({ calls, abi: abi.asset_config_unsafe, allAbi }); + return assetStates.forEach((res, index) => { + const { total_nominal_debt, scale, last_rate_accumulator } = res['0'] + const totalDebt = Number(total_nominal_debt) * Number(last_rate_accumulator) / INTERNAL_SCALE; + const scaledTotalDebt = totalDebt * Number(scale) / INTERNAL_SCALE; + api.add(ASSETS[index], scaledTotalDebt); + }); +}; + +module.exports = { + starknet: { + tvl, + borrowed, + }, +}; diff --git a/projects/vnx-rwa/index.js b/projects/vnx-rwa/index.js new file mode 100644 index 000000000000..11f015f84518 --- /dev/null +++ b/projects/vnx-rwa/index.js @@ -0,0 +1,112 @@ +const { getTokenSupply } = require("../helper/solana"); +const fetch = require('node-fetch'); + +const ASSETS = { + EVM: { + ethereum: [ + "0x6d57b2e05f26c26b549231c866bdd39779e4a488", // VNXAU + "0x6bA75D640bEbfe5dA1197bb5A2aff3327789b5d3", // VEUR + "0x79d4f0232A66c4c91b89c76362016A1707CFBF4f" // VCHF + ], + polygon: [ + "0xC8bB8eDa94931cA2F20EF43eA7dBD58E68400400", // VNXAU + "0xE4095d9372E68d108225c306A4491cacfB33B097", // VEUR + "0xCdB3867935247049e87c38eA270edD305D84c9AE" // VCHF + ], + avax: [ + "0x7678e162f38ec9ef2Bfd1d0aAF9fd93355E5Fa0b", // VEUR, + "0x228a48df6819CCc2eCa01e2192ebAFfFdAD56c19" // VCHF, + ], + q: [ + "0xe4fadbbf24f118b1e63d65f1aac2a825a07f7619", // VNXAU + "0x513f99dee650f529d7c65bb5679f092b64003520", // VEUR + "0x65b9d36281e97418793f3430793f88440dab68d7" // VCHF + ] + }, + nonEVM: { + solana: [ + "9TPL8droGJ7jThsq4momaoz6uhTcvX2SeMqipoPmNa8R",// VNXAU + "C4Kkr9NZU3VbyedcgutU6LKmi6MKz81sx6gRmk5pX519",// VNXAU + "AhhdRu5YZdjVkKR3wbnUDaymVQL2ucjMQ63sZ3LFHsch" // VCHF + ], + stellar: [ + "VNXAU-GCKIYYQVIFBIFDRN7BNDNHL3UZSFHT5NHDAISG2N3MWCZY3WNXL3LXN3", // VNXAU + "VEUR-GDXLSLCOPPHTWOQXLLKSVN4VN3G67WD2ENU7UMVAROEYVJLSPSEWXIZN", // VEUR + "VCHF-GDXLSLCOPPHTWOQXLLKSVN4VN3G67WD2ENU7UMVAROEYVJLSPSEWXIZN" // VCHF + ] + } +}; + +const MAPPINGS = { + stellar: { + 'VNXAU-GCKIYYQVIFBIFDRN7BNDNHL3UZSFHT5NHDAISG2N3MWCZY3WNXL3LXN3': '0x6d57b2e05f26c26b549231c866bdd39779e4a488', + 'VEUR-GDXLSLCOPPHTWOQXLLKSVN4VN3G67WD2ENU7UMVAROEYVJLSPSEWXIZN': '0x6bA75D640bEbfe5dA1197bb5A2aff3327789b5d3', + 'VCHF-GDXLSLCOPPHTWOQXLLKSVN4VN3G67WD2ENU7UMVAROEYVJLSPSEWXIZN': '0x79d4f0232A66c4c91b89c76362016A1707CFBF4f' + }, + q: { + '0xe4fadbbf24f118b1e63d65f1aac2a825a07f7619': '0x6d57b2e05f26c26b549231c866bdd39779e4a488', + '0x513f99dee650f529d7c65bb5679f092b64003520': '0x6bA75D640bEbfe5dA1197bb5A2aff3327789b5d3', + '0x65b9d36281e97418793f3430793f88440dab68d7': '0x79d4f0232A66c4c91b89c76362016A1707CFBF4f' + } +}; + +const fetchStellarSupply = async (asset) => { + const stellarApi = `https://api.stellar.expert/explorer/public/asset/${asset}`; + const response = await fetch(stellarApi); + const { supply } = await response.json(); + return supply / 1e7 * 1e18; // supply / stellar dec * eth dec +}; + +const solanaTvl = async (api, assets) => { + const supplies = await Promise.all(assets.map(getTokenSupply)); + const scaledSupplies = supplies.map((supply) => supply * 1e9); + api.add(assets, scaledSupplies); +}; + +const stellarTvl = async (api, assets) => { + const supplies = await Promise.all(assets.map(fetchStellarSupply)); + supplies.forEach((supply, index) => { + const ethereumAsset = MAPPINGS.stellar[assets[index]]; + api.add(ethereumAsset, supply, { skipChain: true }); + }); +}; + +const evmTvl = (chain, assets) => { + return async (api) => { + const totalSupplies = await api.multiCall({ calls: assets, abi: 'erc20:totalSupply' }); + if (chain === 'q') { + totalSupplies.forEach((supply, index) => { + const ethereumAsset = MAPPINGS.q[assets[index]]; + api.add(ethereumAsset, supply, { skipChain: true }); + }); + } else { + api.add(assets, totalSupplies); + } + }; +}; + +const nonEvmTvl = (chain, assets) => { + return async (api) => { + if (chain === "solana") { + await solanaTvl(api, assets); + } else if (chain === "stellar") { + await stellarTvl(api, assets); + } + }; +}; + +const getTvlFunction = (key, chain, assets) => { + if (key === 'EVM') { + return evmTvl(chain, assets); + } else if (key === 'nonEVM') { + return nonEvmTvl(chain, assets); + } +}; + +Object.entries(ASSETS).forEach(([key, chains]) => { + Object.entries(chains).forEach(([chain, assets]) => { + module.exports[chain] = { + tvl: getTvlFunction(key, chain, assets) + }; + }); +}); diff --git a/projects/wonton/index.js b/projects/wonton/index.js new file mode 100644 index 000000000000..24e0de3b7b1b --- /dev/null +++ b/projects/wonton/index.js @@ -0,0 +1,16 @@ +const ADDRESSES = require("../helper/coreAssets.json") +const { sumTokensExport } = require("../helper/chain/ton") +const HIGHLOAD_CONTRACT = "UQD8ucMJDu-VfMbemse1GaSefy8DUB18VxpvbnWiHQGlGMED" +const POOL_CONTRACT = "UQDzfsiEm9p5KCPA8xNiXHLX42WShhvXEwVadworVgFvCyV8" + +module.exports = { + methodology: + "Counts all TON sitting in pre-bonding and high-load smart contact as the TVL. ", + timetravel: false, + ton: { + tvl: sumTokensExport({ + owners: [HIGHLOAD_CONTRACT, POOL_CONTRACT], + tokens: ADDRESSES.ton.TON, + }) + }, +}; diff --git a/projects/xave-finance/index.js b/projects/xave-finance/index.js index 2e432364bc44..8daa2f6d9a9a 100644 --- a/projects/xave-finance/index.js +++ b/projects/xave-finance/index.js @@ -42,7 +42,8 @@ async function tvl(api) { const data = await api.multiCall({ abi: "function liquidity() view returns (uint256 total_, uint256[] memory individual_)", calls: pools.map((v) => ({ target: v })), - }); + permitFailure: true + }) // Curve.derivatives(0) const derivatives0 = await api.multiCall({ @@ -67,6 +68,8 @@ async function tvl(api) { }); data.forEach((d, i) => { + if (!d) return + const divisor0 = ethers.parseUnits( "1", parseInt(derivatives0Decimals[i]) diff --git a/projects/yakafinance/index.js b/projects/yakafinance/index.js new file mode 100644 index 000000000000..aa2ce19a7ed1 --- /dev/null +++ b/projects/yakafinance/index.js @@ -0,0 +1,3 @@ +const { uniTvlExport } = require("../helper/unknownTokens"); + +module.exports = uniTvlExport('sei', '0xd45dAff288075952822d5323F1d571e73435E929') \ No newline at end of file diff --git a/projects/yel/Helpers/Result.js b/projects/yel/Helpers/Result.js deleted file mode 100644 index 3fe155707387..000000000000 --- a/projects/yel/Helpers/Result.js +++ /dev/null @@ -1,23 +0,0 @@ -const BigNumber = require("bignumber.js"); -module.exports = class Result { - constructor(obj) { - this.result = obj; - } - - append(obj) { - for (const key in obj) { - if (this.result.hasOwnProperty(key)) { - BigNumber.config({EXPONENTIAL_AT: 100}); - const sum = (new BigNumber(this.result[key])).plus(new BigNumber(obj[key])); - this.result[key] = sum.valueOf(); - } else { - this.result[key] = obj[key]; - } - } - return this; - } - - render() { - return this.result; - } -} diff --git a/projects/yel/Providers/Base/LP.js b/projects/yel/Providers/Base/LP.js deleted file mode 100644 index 4a827a67e9e9..000000000000 --- a/projects/yel/Providers/Base/LP.js +++ /dev/null @@ -1,122 +0,0 @@ -const sdk = require("@defillama/sdk"); -const abi = require("../../config/abi.json"); -const addr = require("../../config/addresses.json"); -const BigNumber = require("bignumber.js"); - -module.exports = class LP { - /** - * @type {"bsc"|"fantom"|"polygon"|"ethereum"} - */ - - - constructor(lpFarmingContract, network) { - this.network = "ethereum"; - this.lpFarmingContract = ""; - this.totalAmount1 = 0; - this.totalAmount0 = 0; - this.lpTokenContract = ""; - this.lpToken1 = ""; - this.lpToken0 = ""; - this.lpTotalSupply = 0; - this.fraction1 = 1; - this.fraction0 = 1; - this.totalLockedLPs = 0; - this.token1InLP = 0; - this.token0InLP = 0; - this.network = network; - this.lpFarmingContract = lpFarmingContract; - } - - async getTokensAmountInLp() { - try { - const resp = await sdk.api.abi.call({ - abi: abi.getReserves, - chain: this.network, - target: this.lpTokenContract, - }); - this.totalAmount1 = resp.output[1]; - this.totalAmount0 = resp.output[0]; - } catch (e) { - console.warn(e); - } - } - - /** - * @param {1|0}index - */ - async getLpToken(index) { - const execAbi = index === 1 ? abi.externalFarming.token1 : abi.externalFarming.token0; - try { - const resp = await sdk.api.abi.call({ - abi: execAbi, - chain: this.network, - target: this.lpTokenContract, - }); - let tokenAddr = resp.output - if (resp.output.toLocaleLowerCase() === addr.tokens.bsc.yel) { - tokenAddr = addr.tokens.ethereum.yel; - } - if (index === 0) { - this.lpToken0 = tokenAddr; - } else { - this.lpToken1 = tokenAddr; - } - } catch (e) { - console.warn(e); - } - } - - async getLPTotalSupply() { - try { - const resp = await sdk.api.abi.call({ - abi: abi.externalFarming.totalSupply, - chain: this.network, - target: this.lpTokenContract, - }); - this.lpTotalSupply = resp.output; - } catch (e) { - console.warn(e); - } - return this; - } - - getCoefToken0ToToken1() { - BigNumber.config({ EXPONENTIAL_AT: 100 }); - this.fraction1 = new BigNumber(this.totalAmount1).div(this.lpTotalSupply).toNumber(); - this.fraction0 = new BigNumber(this.totalAmount0).div(this.lpTotalSupply).toNumber(); - } - - getTotalLockedTokens() { - BigNumber.config({ EXPONENTIAL_AT: 100 }); - this.token1InLP = new BigNumber(this.totalLockedLPs) - .multipliedBy(new BigNumber(this.fraction1)) - .toFixed(0); - this.token0InLP = new BigNumber(this.totalLockedLPs) - .multipliedBy(new BigNumber(this.fraction0)) - .toFixed(0); - } - - async calculateTokensLocked() { - await this.getTokensAmountInLp(); - await Promise.all([ - this.getLpToken(1), - this.getLpToken(0) - ]) - await this.getLPTotalSupply(); - this.getCoefToken0ToToken1(); - this.getTotalLockedTokens(); - } - - getLockedTokens() { - const prefix = this.network === "ethereum" ? "" : this.network + ":"; - const result = {}; - - if (this.lpToken0.toLocaleLowerCase() !== addr.tokens.ethereum.yel.toLocaleLowerCase()) { - result[prefix + this.lpToken0] = this.token0InLP; - } - if (this.lpToken1.toLocaleLowerCase() !== addr.tokens.ethereum.yel.toLocaleLowerCase()) { - result[prefix + this.lpToken1] = this.token1InLP; - } - return result - } -} diff --git a/projects/yel/Providers/YelEnhancedLpFarm.js b/projects/yel/Providers/YelEnhancedLpFarm.js deleted file mode 100644 index 5ab3a790c448..000000000000 --- a/projects/yel/Providers/YelEnhancedLpFarm.js +++ /dev/null @@ -1,56 +0,0 @@ -const LP = require("./Base/LP"); -const sdk = require("@defillama/sdk"); -const abi = require("../config/abi.json"); - -module.exports = class YelEnhancedLpFarm extends LP { - constructor(farmingContract, network) { - super(farmingContract, network); - } - - async getLPTokenAddress() { - try { - const resp = await sdk.api.abi.call({ - abi: abi.externalFarming.lpToken, - chain: this.network, - target: this.lpFarmingContract, - }); - this.lpTokenContract = resp.output; - } catch (e) { - console.warn(e); - } - return this; - } - - async getLPTotalCount() { - try { - const resp = await sdk.api.abi.call({ - abi: abi.externalFarming.totalLP, - chain: this.network, - target: this.lpFarmingContract, - }); - this.totalLockedLPs = resp.output; - } catch (e) { - console.warn(e); - } - } - - async unwrap() { - await this.getLPTokenAddress(); - await this.getLPTotalCount(); - await this.calculateTokensLocked(); - } - - getTokensInLP() { - const prefix = this.network === "ethereum" ? "" : this.network+":" - return { - [prefix+this.lpToken0]: this.token0InLP, - [prefix+this.lpToken1]: this.token1InLP, - } - } - - static async tokensInLP(contract, network) { - const obj = new YelEnhancedLpFarm(contract, network) - await obj.unwrap(); - return obj.getTokensInLP(); - } -} diff --git a/projects/yel/Providers/YelEnhancedSingleStake.js b/projects/yel/Providers/YelEnhancedSingleStake.js deleted file mode 100644 index 644e344ab272..000000000000 --- a/projects/yel/Providers/YelEnhancedSingleStake.js +++ /dev/null @@ -1,25 +0,0 @@ -const sdk = require("@defillama/sdk"); -const abi = require("../config/abi.json"); - -module.exports = class YelEnhancedSingleStake { - static async getStakedTokens(contractAddress, network, key) { - key = key || 'stakingTokenTotalAmount'; - try { - const resp = await sdk.api.abi.call({ - abi: abi.poolInfo, - params: [0], - chain: network, - target: contractAddress, - }); - const staked = resp.output[key]; - const token = resp.output['stakingToken']; - const prefix = network === "ethereum" ? "" : network+":" - return { - [prefix + token] : staked - } - } catch (e) { - console.warn(e); - return {}; - } - } -} diff --git a/projects/yel/Providers/YelLPFarm.js b/projects/yel/Providers/YelLPFarm.js deleted file mode 100644 index d75fbec14934..000000000000 --- a/projects/yel/Providers/YelLPFarm.js +++ /dev/null @@ -1,55 +0,0 @@ -const sdk = require("@defillama/sdk"); -const abi = require("../config/abi.json"); -const LP = require("./Base/LP"); -const addr = require("../config/addresses.json"); - - -module.exports = class YelLPFarm extends LP { - constructor(farmingContract, network) { - super(farmingContract, network); - } - - async getPoolInfo() { - try { - const resp = await sdk.api.abi.call({ - abi: abi.poolInfo, - chain: this.network, - params: [1], - target: this.lpFarmingContract, - }); - this.totalLockedLPs = resp.output[1]; - this.lpTokenContract = resp.output[0]; - } catch (e) { - console.warn(e); - } - } - - async unwrap() { - await this.getPoolInfo(); - await this.calculateTokensLocked(); - } - - async getLockedYel() { - const result = {}; - - if (this.lpToken0.toLocaleLowerCase() === addr.tokens.ethereum.yel.toLocaleLowerCase()) { - result[this.lpToken0] = this.token0InLP; - } - if (this.lpToken1.toLocaleLowerCase() === addr.tokens.ethereum.yel.toLocaleLowerCase()) { - result[this.lpToken1] = this.token1InLP; - } - return result - } - - static async nonYELTokensInLP(contract, network) { - const obj = new YelLPFarm(contract, network) - await obj.unwrap(); - return obj.getLockedTokens(); - } - - static async yelTokensInLp(contract, network) { - const obj = new YelLPFarm(contract, network) - await obj.unwrap(); - return obj.getLockedYel(); - } -} diff --git a/projects/yel/Providers/YelSingleStaking.js b/projects/yel/Providers/YelSingleStaking.js deleted file mode 100644 index c12c803cc97a..000000000000 --- a/projects/yel/Providers/YelSingleStaking.js +++ /dev/null @@ -1,16 +0,0 @@ -const sdk = require("@defillama/sdk"); -const abi = require("../config/abi.json"); -const addr = require("../config/addresses.json") -module.exports = class YelSingleStaking { - static async getStakedYel(farmingContract, network) { - const resp = await sdk.api.abi.call({ - abi: abi.poolInfo, - chain: network, - params: [0], - target: farmingContract, - }) - return { - [addr.tokens.ethereum.yel]: resp.output[1] - } - } -} diff --git a/projects/yel/config/abi.json b/projects/yel/config/abi.json deleted file mode 100644 index e3893b937aaf..000000000000 --- a/projects/yel/config/abi.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "getReserves": "function getReserves() view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast)", - "poolInfo": "function poolInfo(uint256) view returns (address stakingToken, uint256 stakingTokenTotalAmount, uint256 accYelPerShare, uint32 lastRewardTime, uint16 allocPoint)", - "externalFarming": { - "totalLP": "uint256:totalLP", - "lpToken": "address:lpToken", - "token1": "address:token1", - "token0": "address:token0", - "totalSupply": "uint256:totalSupply" - } -} \ No newline at end of file diff --git a/projects/yel/config/addresses.json b/projects/yel/config/addresses.json deleted file mode 100644 index b36487349ef3..000000000000 --- a/projects/yel/config/addresses.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "tokens": { - "ethereum" : { - "weth": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", - "ifarm" : "0x1571ed0bed4d987fe2b498ddbae7dfa19519f651", - "yel": "0x7815bDa662050D84718B988735218CFfd32f75ea" - }, - "bsc" : { - "wbnb" : "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", - "yel": "0xd3b71117e6c1558c1553305b44988cd944e97300" - }, - "fantom" : { - "wftm" : "0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83", - "yel": "0xd3b71117e6c1558c1553305b44988cd944e97300" - }, - "polygon" : { - "wmatic" : "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", - "yel": "0xd3b71117e6c1558c1553305b44988cd944e97300" - } - }, - "yelFarmingContract" : { - "ethereum" : "0xe7c8477C0c7AAaD6106EBDbbED3a5a2665b273b9", - "bsc" : "0x954b15065e4FA1243Cd45a020766511b68Ea9b6E", - "fantom" : "0x954b15065e4FA1243Cd45a020766511b68Ea9b6E", - "polygon" : "0x954b15065e4FA1243Cd45a020766511b68Ea9b6E" - }, - "yelEnhancedPools" : { - "ethereum": { - "ifarm": "0x5dD8532613B9a6162BA795208D1A01613df26dc5" - }, - "bsc": { - "bnbBanana": "0x660f09cF84F8f366Bc653942b54B114d0Ec9E8a2" - }, - "fantom": { - "ftmBoo": "0x61EB6f6bC4Ec28203e9973B44967dA263B3Ec0e3", - "anySwap": "0x3a6eE00959751A1981D731a5aC15B660a9a8BAd4" - }, - "polygon" : { - "dQuick" : "0x0379C1BbE394f835366D2EFDBf2AF09fBa0689A4" - } - } -} diff --git a/projects/yel/index.js b/projects/yel/index.js index c2fee76ff28f..2b470a01b09d 100644 --- a/projects/yel/index.js +++ b/projects/yel/index.js @@ -1,134 +1,58 @@ -const sdk = require("@defillama/sdk"); -const Result = require("./Helpers/Result"); -const YelLPFarm = require("./Providers/YelLPFarm"); -const addr = require("./config/addresses.json"); -const YelEnhancedLpFarm = require("./Providers/YelEnhancedLpFarm"); -const YelSingleStaking = require("./Providers/YelSingleStaking"); -const YelEnhancedSingleStake = require("./Providers/YelEnhancedSingleStake"); - -async function ethereumStaking() { - const [ - ifarmEnhanced, - yelSSEth, - ] = await Promise.all([ - YelEnhancedSingleStake.getStakedTokens(addr.yelEnhancedPools.ethereum.ifarm, 'ethereum'), - YelSingleStaking.getStakedYel(addr.yelFarmingContract.ethereum, 'ethereum'), - ]) - return (new Result(ifarmEnhanced)) - .append(yelSSEth) - .render(); -} - -async function bscStaking() { - return await YelSingleStaking.getStakedYel(addr.yelFarmingContract.bsc, 'bsc'); -} - -async function ftmStaking() { - const [ - anySwap, - yelSSFantom - ] = await Promise.all([ - YelEnhancedSingleStake.getStakedTokens(addr.yelEnhancedPools.fantom.anySwap, 'fantom', 2), - YelSingleStaking.getStakedYel(addr.yelFarmingContract.fantom, 'fantom'), - ]) - return (new Result(anySwap)) - .append(yelSSFantom) - .render(); -} - -async function maticStaking() { - const [ - yelInLpPolygon, - dQuick - ] = await Promise.all([ - YelEnhancedSingleStake.getStakedTokens(addr.yelEnhancedPools.polygon.dQuick, 'polygon', 2), - YelSingleStaking.getStakedYel(addr.yelFarmingContract.polygon, 'polygon'), - ]) - return (new Result(dQuick)) - .append(yelInLpPolygon) - .render(); -} - -async function ethereumPool2() { - const [ - yelInLpEth, - wethInLp, - ] = await Promise.all([ - YelLPFarm.yelTokensInLp(addr.yelFarmingContract.ethereum, 'ethereum'), - YelLPFarm.nonYELTokensInLP(addr.yelFarmingContract.ethereum, 'ethereum'), - ]) - return (new Result(yelInLpEth)) - .append(wethInLp) - .render(); -} - -async function bscPool2() { - const [ - bnbInYel, - yelInLpBsc, - bananaBnb, - ] = await Promise.all([ - YelLPFarm.nonYELTokensInLP(addr.yelFarmingContract.bsc, 'bsc'), - YelLPFarm.yelTokensInLp(addr.yelFarmingContract.bsc, 'bsc'), - YelEnhancedLpFarm.tokensInLP(addr.yelEnhancedPools.bsc.bnbBanana, 'bsc'), - ]) - return (new Result(bnbInYel)) - .append(bananaBnb) - .append(yelInLpBsc) - .render(); -} - -async function ftmPool2() { - const [ - ftmInYel, - yelInLpFantom, - ftmBoo, - ] = await Promise.all([ - YelLPFarm.nonYELTokensInLP(addr.yelFarmingContract.fantom, 'fantom'), - YelLPFarm.yelTokensInLp(addr.yelFarmingContract.fantom, 'fantom'), - YelEnhancedLpFarm.tokensInLP(addr.yelEnhancedPools.fantom.ftmBoo, 'fantom') - ]) - return (new Result(ftmInYel)) - .append(ftmBoo) - .append(yelInLpFantom) - .render(); -} - -async function maticPool2() { - const [ - maticInYel, - yelInLpPolygon, - ] = await Promise.all([ - YelLPFarm.nonYELTokensInLP(addr.yelFarmingContract.polygon, 'polygon'), - YelLPFarm.yelTokensInLp(addr.yelFarmingContract.polygon, 'polygon'), - ]) - return (new Result(maticInYel)) - .append(yelInLpPolygon) - .render(); -} - -async function tvl() { - return {}; -} - -module.exports = { - ethereum: { - staking: ethereumStaking, - pool2: ethereumPool2, - tvl, - }, - bsc: { - staking: bscStaking, - pool2: ethereumPool2 +const { sumUnknownTokens } = require('../helper/unknownTokens') +const { sumTokens2 } = require('../helper/unwrapLPs') +const ADDRESSES = require('../helper/coreAssets.json') + +const config = { + ethereum: { + farms: ['0x5dD8532613B9a6162BA795208D1A01613df26dc5', '0xe7c8477C0c7AAaD6106EBDbbED3a5a2665b273b9'], lps: ['0xc83ce8612164ef7a13d17ddea4271dd8e8eebe5d'], ownTokens: ['0x7815bDa662050D84718B988735218CFfd32f75ea'] + }, + bsc: { + farms: ['0x954b15065e4FA1243Cd45a020766511b68Ea9b6E',], lps: ['0xa5ac78a856345ab1fc8a4550208f42ca34b54e56', '0x8290d3CA64f712de9FB7220353dAa55bf388F3A3'], ownTokens: ['0xd3b71117e6c1558c1553305b44988cd944e97300'] + }, + fantom: { + farms: ['0x954b15065e4FA1243Cd45a020766511b68Ea9b6E', '0x3a6eE00959751A1981D731a5aC15B660a9a8BAd4'], lps: ['0x8BFf7b8B6a14e576a3634d6c0466A19A6E9b170a'], ownTokens: ['0xd3b71117e6c1558c1553305b44988cd944e97300'] + }, + polygon: { + farms: ['0x954b15065e4FA1243Cd45a020766511b68Ea9b6E', '0x0379C1BbE394f835366D2EFDBf2AF09fBa0689A4'], lps: ['0x8bAb87ECF28Bf45507Bd745bc70532e968b5c2De'], ownTokens: ['0xd3b71117e6c1558c1553305b44988cd944e97300'] + }, + blast: { + ownTokensAndOwners: [['0x949185D3BE66775Ea648F4a306740EA9eFF9C567', '0x7d2f5881F0C4B840fcFA2c49F4052d1A004eAf0d']], + tokensAndOwners: [ + [ADDRESSES.blast.WETH, '0x795a85CD543D0E2d29F7e11e33a20a38A4b5121e'], + [ADDRESSES.blast.BLAST, '0x7D8490333315EaAa5e93F3C6983d1e8128D7f50f'], + ], + } +} + +Object.keys(config).forEach(chain => { + const { farms = [], lps = [], ownTokens = [], ownTokensAndOwners, tokensAndOwners, } = config[chain] + module.exports[chain] = { + tvl: async (api) => { + if (api.chain === 'bsc') { + const lpStaked = await api.call({ abi: 'uint256:totalLP', target: '0x660f09cF84F8f366Bc653942b54B114d0Ec9E8a2' }) + api.add('0xF65C1C0478eFDe3c19b49EcBE7ACc57BB6B1D713', lpStaked) + } else if (api.chain === 'fantom') { + const lpStaked = await api.call({ abi: 'uint256:totalLP', target: '0x61EB6f6bC4Ec28203e9973B44967dA263B3Ec0e3' }) + api.add('0xEc7178F4C41f346b2721907F5cF7628E388A7a58', lpStaked) + } + if (farms.length) { + const res = await api.fetchList({ lengthAbi: 'poolLength', itemAbi: 'function poolInfo(uint256) view returns (address stakingToken, uint256, uint256, uint32, uint16)', calls: farms, groupedByInput: true }) + const ownerTokens = res.map((r, i) => ([r.map(i => i.stakingToken), farms[i]])) + await sumTokens2({ api, ownerTokens, blacklistedTokens: [...lps, ...ownTokens], resolveLP: true, }) + } + + if (tokensAndOwners) return api.sumTokens({ tokensAndOwners }) }, - fantom: { - staking: ftmStaking, - pool2: ftmPool2 + pool2: async (api) => { + if (farms.length && lps.length) + await sumUnknownTokens({ api, owners: farms, tokens: lps, resolveLP: true, useDefaultCoreAssets: true, lps, }) + }, - polygon: { - staking: maticStaking, - pool2: maticPool2 + staking: async (api) => { + if (farms.length && ownTokens.length) + await sumUnknownTokens({ api, owners: farms, tokens: ownTokens, useDefaultCoreAssets: true, lps, }) + + if (ownTokensAndOwners) return api.sumTokens({ tokensAndOwners: ownTokensAndOwners }) }, - methodology: "TVL is accounted from YEL liquidity mining farms, enhanced pools, partner farms and other protocols. Basically, that’s all the funds held at YEL Finance smart-contracts.", -}; -// node test.js projects/yel/index.js \ No newline at end of file + } +}) \ No newline at end of file diff --git a/projects/yieldbank/index.js b/projects/yieldbank/index.js index 3576a0da1f4b..82203489f1f0 100644 --- a/projects/yieldbank/index.js +++ b/projects/yieldbank/index.js @@ -6,7 +6,7 @@ async function tvl(api) { const tokens = await api.multiCall({ abi: 'address:want', calls: vaults }) const bals = await api.multiCall({ abi: 'uint256:balance', calls: vaults }) api.addTokens(tokens, bals) - return sumUnknownTokens({ api, resolveLP: true, useDefaultCoreAssets: false }) + return sumUnknownTokens({ api, resolveLP: true, useDefaultCoreAssets: false }) } module.exports = { @@ -16,5 +16,5 @@ module.exports = { tvl: () => ({}), staking: () => ({}) }, -// deadFrom: "2023-12-01", + deadFrom: "2023-12-01", } diff --git a/projects/yieldflow/index.js b/projects/yieldflow/index.js index 533ea1b3ed01..867f5af47660 100644 --- a/projects/yieldflow/index.js +++ b/projects/yieldflow/index.js @@ -36,42 +36,43 @@ const managers = [ '0xCF49168017096dB97Eb14552bd0af6eE9a27e76A', '0x899DF9d131D2276Db3c5f392ce2b396d9b1BFa8c', - '0xC3ec6F076fE7395B0C263f7E37B084EC4Fd06eaF', - '0x034a5fC7518d2D1b6a8C9CaccD273ee37C669E95', - '0xE0D19D57BAFF656d2910BFFBec81E33f1368A0Ee', - '0x2de0b61a2778169f095A8a7DAD7B566A9973E977', - '0x440b228411a4D83820e0c63cD71E769a6660E037', - '0x717FADe04FF819a58128Be591caC8C801F28Cd5b', - '0x1655cfD162b4148E1715B6302DA4EF075Fa72ADf', - '0x604Ef6Dc8c7abf78008749b57a4135C87d69fc35', - '0xa63fa8FE58A5E197f092742619D8F4C7fE4924e8', + '0xC3ec6F076fE7395B0C263f7E37B084EC4Fd06eaF', + '0x034a5fC7518d2D1b6a8C9CaccD273ee37C669E95', + '0xE0D19D57BAFF656d2910BFFBec81E33f1368A0Ee', + '0x2de0b61a2778169f095A8a7DAD7B566A9973E977', + '0x440b228411a4D83820e0c63cD71E769a6660E037', + '0x717FADe04FF819a58128Be591caC8C801F28Cd5b', + '0x1655cfD162b4148E1715B6302DA4EF075Fa72ADf', + '0x604Ef6Dc8c7abf78008749b57a4135C87d69fc35', + '0xa63fa8FE58A5E197f092742619D8F4C7fE4924e8', - '0xC22c7f332cA100725Bf4eA832f2D169e471923D6', - '0x1E5F83Fc7f167fF44D58e59142DeE2358346331B', - '0x8702800D715461Fb7D9C89C74DDB7bE73F5a37C6', - '0xb6F1E82e7AE822DE9eD64967D04359Fe4D58A569', - '0xE0213546258ABd7EF0D689D26Cf6d6BCEeE20e8a', - '0xf732Fc726B3a4bE9f6c86a710Fd3367259DB456e', + '0xC22c7f332cA100725Bf4eA832f2D169e471923D6', + '0x1E5F83Fc7f167fF44D58e59142DeE2358346331B', + '0x8702800D715461Fb7D9C89C74DDB7bE73F5a37C6', + '0xb6F1E82e7AE822DE9eD64967D04359Fe4D58A569', + '0xE0213546258ABd7EF0D689D26Cf6d6BCEeE20e8a', + '0xf732Fc726B3a4bE9f6c86a710Fd3367259DB456e', - '0x16A3EBd3D55b27FF6e2839DA2078889cA148C040', - '0xf4447cCFeE677A5b0BaD6bcD5f92A1929c171b48', - '0x538A753B616F5aAD60852ca039572e5C4B72cA85', + '0x16A3EBd3D55b27FF6e2839DA2078889cA148C040', + '0xf4447cCFeE677A5b0BaD6bcD5f92A1929c171b48', + '0x538A753B616F5aAD60852ca039572e5C4B72cA85', - '0x780A252d7C797cFB255fe2EAa4E1a257a897B6ed', - '0xffF3c0063f2Fc1Af569C359480b5b62841357169', - '0xEFF4A3260263A927D0707190C931bE13292bD4Ba', + '0x780A252d7C797cFB255fe2EAa4E1a257a897B6ed', + '0xffF3c0063f2Fc1Af569C359480b5b62841357169', + '0xEFF4A3260263A927D0707190C931bE13292bD4Ba', - '0xD4c68a094De7e1336E261c6EDD595F64cd70A064', - '0x88609B69feDc0EEF4326c3390a8ae1b2073DcF03', - '0xdcC4391042d462158C847f73F4232ce47A8F999c', + '0xD4c68a094De7e1336E261c6EDD595F64cd70A064', + '0x88609B69feDc0EEF4326c3390a8ae1b2073DcF03', + '0xdcC4391042d462158C847f73F4232ce47A8F999c', ] async function tvl(api) { - const positionManagers = await api.multiCall({ abi: 'address:positionManager', calls: managers}) - const tokenIds = await api.multiCall({ abi: abi.getCurrentTokenId, calls: managers}) - const liquidities = await api.multiCall({ abi: abi.getPositions, calls: positionManagers.map((v, i) => ({ target: v, params: tokenIds[i]})) }) - const tokenAmounts = await api.multiCall({ abi: abi.getAmountsForTicks, calls: liquidities.map((v, i) => ({ target: managers[i], params: [v.tickLower, v.tickUpper, v.liquidity]})) }) - + const { managers } = config[api.chain] + const positionManagers = await api.multiCall({ abi: 'address:positionManager', calls: managers }) + const tokenIds = await api.multiCall({ abi: abi.getCurrentTokenId, calls: managers }) + const liquidities = await api.multiCall({ abi: abi.getPositions, calls: positionManagers.map((v, i) => ({ target: v, params: tokenIds[i] })) }) + const tokenAmounts = await api.multiCall({ abi: abi.getAmountsForTicks, calls: liquidities.map((v, i) => ({ target: managers[i], params: [v.tickLower, v.tickUpper, v.liquidity] })) }) + liquidities.forEach((v, i) => { api.add(v.token0, tokenAmounts[i][0]) api.add(v.token1, tokenAmounts[i][1]) @@ -81,5 +82,22 @@ async function tvl(api) { module.exports = { doublecounted: true, - arbitrum: { tvl }, -}; +} + +const config = { + arbitrum: { managers }, + ethereum: { + managers: [ + '0x65D1788F9d9A800c5Fc9b9CB8e49A1b488C736c7', + '0x01Af749E58c076c301B1F57D0BCBBf2D49B503bD', + '0x47Dd57DFe9e01616e4Adc28015243Ea6A2C09cEC', + '0x0a4a169a6b2ac75c86e2F0e42822fdEA13fB1CC8', + '0xafFA16b152232dAd8BF3AaDF6bb6F895A836F917', + '0xFB04d48e4CE9C042188Ef933ff4cf58921Ab59B8' + ] + } +} + +Object.keys(config).forEach(chain => { + module.exports[chain] = { tvl } +}) \ No newline at end of file