From ed47a18b62eb4f2e197fbcdda42a1f96b2843fb5 Mon Sep 17 00:00:00 2001 From: 0xngmi <0xngmi@protonmail.com> Date: Fri, 10 May 2024 19:07:33 +0100 Subject: [PATCH 1/7] add diva vault --- projects/diva/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/projects/diva/index.js b/projects/diva/index.js index 31d7d6eb9692..7554ff1bd58c 100644 --- a/projects/diva/index.js +++ b/projects/diva/index.js @@ -1,15 +1,23 @@ const ADDRESSES = require('../helper/coreAssets.json') const { sumTokensExport } = require('../helper/unwrapLPs') +const sdk = require("@defillama/sdk") module.exports = { methodology: 'ETH and stETH in vaults', ethereum: { - tvl: sumTokensExport({ owners: [ + tvl: sdk.util.sumChainTvls([sumTokensExport({ owners: [ "0x1ce8aafb51e79f6bdc0ef2ebd6fd34b00620f6db", "0x16770d642e882e1769ce4ac8612b8bc0601506fc" ], tokens: [ ADDRESSES.ethereum.WETH, ADDRESSES.ethereum.STETH - ]}), + ]}), async (api) => { + return { + [ADDRESSES.ethereum.WETH]: await api.call({ + target: "0x6c1edce139291af5b84fb1e496c9747f83e876c9", + abi: "uint256:totalAssets" + }) + } + }]), } }; \ No newline at end of file From c135f13570ed7202d7ed7716cfc6bed2fb321795 Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Fri, 10 May 2024 20:29:50 +0200 Subject: [PATCH 2/7] track keller v3 --- projects/keller-v3/index.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 projects/keller-v3/index.js diff --git a/projects/keller-v3/index.js b/projects/keller-v3/index.js new file mode 100644 index 000000000000..fccb07e00211 --- /dev/null +++ b/projects/keller-v3/index.js @@ -0,0 +1,5 @@ +const { uniV3Export } = require('../helper/uniswapV3') + +module.exports = uniV3Export({ + scroll: { factory: "0x952aC46B2586737df679e836d9B980E43E12B2d8", fromBlock: 4627488 }, +}) \ No newline at end of file From da01473f655847413cf87a55a349a428c4b08f68 Mon Sep 17 00:00:00 2001 From: Evan | zkLink Labs Date: Sat, 11 May 2024 02:33:27 +0800 Subject: [PATCH 3/7] add free.tech bridge address to zklink-nova (#10170) --- projects/zkLink/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/zkLink/index.js b/projects/zkLink/index.js index 5dde9d4146c9..81401a80c285 100644 --- a/projects/zkLink/index.js +++ b/projects/zkLink/index.js @@ -117,6 +117,7 @@ const config = { merlin: { owners: [ "0xf5b90fE755Aa2e3CcC69d9548cbeB7b38c661D73", // nova bridge address + "0xE12382e046DB998DE89aF19Ca799CbB757106781", // free.tech bridge: https://solvbtc.free.tech/ ], tokens: [ "0xB880fd278198bd590252621d4CD071b1842E9Bcd", //MBTC From 0c99801198ddd5be701cce08eb6ccb1e17057063 Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Sat, 11 May 2024 10:51:55 +0200 Subject: [PATCH 4/7] fix raydium --- .../utils/solana/layouts/raydium-layout.js | 14 ++- projects/marinade-native/index.js | 24 ++-- projects/raydium.js | 115 ++++++++++++------ 3 files changed, 100 insertions(+), 53 deletions(-) diff --git a/projects/helper/utils/solana/layouts/raydium-layout.js b/projects/helper/utils/solana/layouts/raydium-layout.js index 7c3b3cafd8c3..55f4669c9b11 100644 --- a/projects/helper/utils/solana/layouts/raydium-layout.js +++ b/projects/helper/utils/solana/layouts/raydium-layout.js @@ -185,6 +185,18 @@ const RAYDIUM_STABLE_STATE_LAYOUT_V1 = struct([ seq(u64("padding"), 64, "padding"), ]) +const KeyLayoutv4 = struct([ + publicKey('vaultA'), + publicKey('vaultB'), + publicKey('mintA'), + publicKey('mintB'), +]) + +const TokenAmountLayout = struct([ + u64('amount'), +]) + + module.exports = { - RAYDIUM_LIQUIDITY_STATE_LAYOUT_CLMM, RAYDIUM_STABLE_STATE_LAYOUT_V1, + RAYDIUM_LIQUIDITY_STATE_LAYOUT_CLMM, RAYDIUM_STABLE_STATE_LAYOUT_V1, KeyLayoutv4, TokenAmountLayout, } \ No newline at end of file diff --git a/projects/marinade-native/index.js b/projects/marinade-native/index.js index ecb86f706c54..8f84c77ce062 100644 --- a/projects/marinade-native/index.js +++ b/projects/marinade-native/index.js @@ -2,25 +2,15 @@ const { StakeProgram } = require("@solana/web3.js") const { getConnection } = require('../helper/solana') async function tvl() { - let hasNext = true - let offset = 0 - let length = 9 - let nativeTvl = 0 - do { - const _stakeAccounts = await getConnection().getProgramAccounts(StakeProgram.programId, { - filters: [{ - memcmp: { bytes: 'stWirqFCf2Uts1JBL1Jsd3r6VBWhgnpdPxCTe1MFjrq', offset: 4 + 8 } - }], - dataSlice: { offset, length } - }) - nativeTvl += _stakeAccounts.reduce((tvl, { account }) => { return tvl + account.lamports / 1e9 }, 0) - - hasNext = _stakeAccounts.length === length - offset += length - } while (hasNext) + const stakeAccounts = await getConnection().getProgramAccounts(StakeProgram.programId, { + filters: [{ + memcmp: { bytes: 'stWirqFCf2Uts1JBL1Jsd3r6VBWhgnpdPxCTe1MFjrq', offset: 4 + 8 } + }], + dataSlice: { offset: 0, length: 1 } // we dont care about the data, just the lamports + }) return { - solana: nativeTvl + solana: stakeAccounts.reduce((tvl, { account }) => { return tvl + account.lamports / 1e9 }, 0) } } diff --git a/projects/raydium.js b/projects/raydium.js index cad0631e7c30..b179ff1d78fd 100644 --- a/projects/raydium.js +++ b/projects/raydium.js @@ -1,6 +1,10 @@ const { getConnection, sumTokens2, decodeAccount, } = require("./helper/solana"); const { PublicKey, } = require("@solana/web3.js"); -const sdk = require('@defillama/sdk'); +const sdk = require('@defillama/sdk') + +const { TokenAmountLayout, KeyLayoutv4 } = require("./helper/utils/solana/layouts/raydium-layout"); +const { transformDexBalances } = require("./helper/portedTokens"); +const { sleep } = require("./helper/utils"); const CLMM = 'CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK' const AmmV4 = '675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8' @@ -31,49 +35,90 @@ async function tvlCLMM() { } -async function ammV4Tvl() { - const owner = '5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1' - return sumTokens2({ owner, getAllTokenAccounts: true }) +async function ammV4Tvl(api) { + const connection = getConnection() + const auth = '5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1' + + await sleep(10000) + const allPoolVaultAmount = await connection.getProgramAccounts(new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'), { filters: [{ dataSize: 165 }, { memcmp: { offset: 32, bytes: auth } }], dataSlice: { offset: 64, length: TokenAmountLayout.span } }) + await sleep(30000) + const allPoolKeyInfo = await connection.getProgramAccounts(new PublicKey(AmmV4), { filters: [{ dataSize: 752 }], dataSlice: { offset: 336, length: KeyLayoutv4.span } }) + + const vaultIdToAmount = {} + for (const item of allPoolVaultAmount) { + vaultIdToAmount[item.pubkey.toString()] = TokenAmountLayout.decode(item.account.data).amount.toString() + } + + let i = 0 + let j = 0 + let data = [] + const emptyKey = PublicKey.default.toString() + for (const item of allPoolKeyInfo) { + const poolKey = KeyLayoutv4.decode(item.account.data) + if (poolKey.vaultA.toString() === emptyKey) continue + const vaultA = poolKey.vaultA.toString() + const vaultB = poolKey.vaultB.toString() + if (isNaN(vaultIdToAmount[vaultA]) || isNaN(vaultIdToAmount[vaultB])) continue + + data.push({ + token0: poolKey.mintA.toString(), + token1: poolKey.mintB.toString(), + token0Bal: vaultIdToAmount[vaultA], + token1Bal: vaultIdToAmount[vaultB], + }) + j++ + if (i > 5000) { + await transformDexBalances({ api, data }) + data = [] + i = 0 + } + i++ + } + await transformDexBalances({ api, data }) + return api.getBalances() } async function ammV2V3() { - return sumTokens2({ tokenAccounts: [ - // v2 - '8tA74jqYPNmr8pcvZE3FBxmLMDqFMvZryny8XojCD5CE', - '7t51g6PFAfnBtWqooQhHErneVqQb4SN1QuPnG7iGa87M', - '5fHS778vozoDDYzzJz2xYG39whTzGGW6bF71GVxRyMXi', - 'CzVe191iLM2E31DBW7isXpZBPtcufRRsaxNRc8uShcEs', - 'G2zmxUhRGn12fuePJy9QsmJKem6XCRnmAEkf8G6xcRTj', - 'H617sH2JNjMqPhRxsu43C8vDYfjZrFuoMEKdJyMu7V3t', - 'CJukFFmH9FZ98uzFkUNgqRn8xUmSBTUETEDUMxZXk6p8', - 'DoZyq9uo3W4WWBZJvPCvfB5cCBFvjU9oq3DdYjNgJNRX', - 'Gej1jXVRMdDKWSxmEZ78KJp5jruGJfR9dV3beedXe3BG', - 'FUDEbQKfMTfAaKS3dGdPEacfcC9bRpa5gmmDW8KNoUKp', - '3NAqRJFepsd2dae98Yj7uALQxiV1YRcZJoUcuXErK1FF', - '9RPGJb7pSyiLKKACmeoSgqeypiEymZneBHWbHerQC9Qm', - '7r5YjMLMnmoYkD1bkyYq374yiTBG9XwBHMwi5ZVDptre', - '6vMeQvJcC3VEGvtZ2TDXcShZerevxkqfW43yjX14vmSz', - 'CvcqJtGdS9C1jKKFzgCi5p8qsnR5BZCohWvYMBJXcnJ8', - 'AiYm8jzb2WB4HTTFTHX1XCS7uVSQM5XWnMsure5sMeQY', - // v3 - 'DujWhSxnwqFd3TrLfScyUhJ3FdoaHrmoiVE6kU4ETQyL', - 'D6F5CDaLDCHHWfE8kMLbMNAFULXLfM572AGDx2a6KeXc', - 'Eg6sR9H28cFaek5DVdgxxDcRKKbS85XvCFEzzkdmYNhq', - '8g2nHtayS2JnRxaAY5ugsYC8CwiZutQrNWA9j2oH8UVM', - 'DTQTBTSy3tiy7kZZWgaczWxs9snnTVTi8DBYBzjaVwbj', - 'Bk2G4zhjB7VmRsaBwh2ijPwq6tavMHALEq4guogxsosT', - 'ENjXaFNDiLTh44Gs89ZtfUH2i5MGLLkfYbSY7TmP4Du3', - '9uzWJD2WqJYSmB6UHSyPMskFGoP5L6hB7FxqUdYP4Esm', - 'Fy6SnHwAkxoGMhUH2cLu2biqAnHmaAwFDDww9k6gq5ws', - 'GoRindEPofTJ3axsonTnbyf7cFwdFdG1A3MG9ENyBZsn', - ] }) + return sumTokens2({ + tokenAccounts: [ + // v2 + '8tA74jqYPNmr8pcvZE3FBxmLMDqFMvZryny8XojCD5CE', + '7t51g6PFAfnBtWqooQhHErneVqQb4SN1QuPnG7iGa87M', + '5fHS778vozoDDYzzJz2xYG39whTzGGW6bF71GVxRyMXi', + 'CzVe191iLM2E31DBW7isXpZBPtcufRRsaxNRc8uShcEs', + 'G2zmxUhRGn12fuePJy9QsmJKem6XCRnmAEkf8G6xcRTj', + 'H617sH2JNjMqPhRxsu43C8vDYfjZrFuoMEKdJyMu7V3t', + 'CJukFFmH9FZ98uzFkUNgqRn8xUmSBTUETEDUMxZXk6p8', + 'DoZyq9uo3W4WWBZJvPCvfB5cCBFvjU9oq3DdYjNgJNRX', + 'Gej1jXVRMdDKWSxmEZ78KJp5jruGJfR9dV3beedXe3BG', + 'FUDEbQKfMTfAaKS3dGdPEacfcC9bRpa5gmmDW8KNoUKp', + '3NAqRJFepsd2dae98Yj7uALQxiV1YRcZJoUcuXErK1FF', + '9RPGJb7pSyiLKKACmeoSgqeypiEymZneBHWbHerQC9Qm', + '7r5YjMLMnmoYkD1bkyYq374yiTBG9XwBHMwi5ZVDptre', + '6vMeQvJcC3VEGvtZ2TDXcShZerevxkqfW43yjX14vmSz', + 'CvcqJtGdS9C1jKKFzgCi5p8qsnR5BZCohWvYMBJXcnJ8', + 'AiYm8jzb2WB4HTTFTHX1XCS7uVSQM5XWnMsure5sMeQY', + // v3 + 'DujWhSxnwqFd3TrLfScyUhJ3FdoaHrmoiVE6kU4ETQyL', + 'D6F5CDaLDCHHWfE8kMLbMNAFULXLfM572AGDx2a6KeXc', + 'Eg6sR9H28cFaek5DVdgxxDcRKKbS85XvCFEzzkdmYNhq', + '8g2nHtayS2JnRxaAY5ugsYC8CwiZutQrNWA9j2oH8UVM', + 'DTQTBTSy3tiy7kZZWgaczWxs9snnTVTi8DBYBzjaVwbj', + 'Bk2G4zhjB7VmRsaBwh2ijPwq6tavMHALEq4guogxsosT', + 'ENjXaFNDiLTh44Gs89ZtfUH2i5MGLLkfYbSY7TmP4Du3', + '9uzWJD2WqJYSmB6UHSyPMskFGoP5L6hB7FxqUdYP4Esm', + 'Fy6SnHwAkxoGMhUH2cLu2biqAnHmaAwFDDww9k6gq5ws', + 'GoRindEPofTJ3axsonTnbyf7cFwdFdG1A3MG9ENyBZsn', + ] + }) } module.exports = { timetravel: false, + misrepresentedTokens: true, hallmarks: [[1667865600, "FTX collapse"]], solana: { tvl: sdk.util.sumChainTvls([tvlCLMM, ammStableTvl, ammV4Tvl, ammV2V3]), - staking: () => sumTokens2({ tokenAccounts: ['8tnpAECxAT9nHBqR1Ba494Ar5dQMPGhL31MmPJz1zZvY']}) + staking: () => sumTokens2({ tokenAccounts: ['8tnpAECxAT9nHBqR1Ba494Ar5dQMPGhL31MmPJz1zZvY'] }) }, }; \ No newline at end of file From 8d601a8a12041ae0b7eae20d4f4d49e79db0f5f7 Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Sat, 11 May 2024 11:16:41 +0200 Subject: [PATCH 5/7] fix broken adapters --- projects/puffer/index.js | 2 +- projects/xWinFinance/index.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/projects/puffer/index.js b/projects/puffer/index.js index 4746fa05f8a5..f246b75efdb5 100644 --- a/projects/puffer/index.js +++ b/projects/puffer/index.js @@ -1,7 +1,7 @@ const PUF_ETH = '0xD9A442856C234a39a81a089C06451EBAa4306a72'; async function tvl(api) { - return api.erc4626Sum({ calls: [PUF_ETH], isOG4626: true }) + return api.erc4626Sum({ calls: [PUF_ETH], isOG4626: true, permitFailure: true, }) } module.exports = { diff --git a/projects/xWinFinance/index.js b/projects/xWinFinance/index.js index 78a402af0747..91612e871e8c 100644 --- a/projects/xWinFinance/index.js +++ b/projects/xWinFinance/index.js @@ -25,7 +25,7 @@ Object.keys(config).forEach(chain => { const { portfolioURL, strategyUrl, privateKey, } = config[chain] module.exports[chain] = { tvl: async (api) => { - const vaults = (await getConfig('xWinFinance/vaults/' + api.chain, strategyUrl)).map(i => i.contractaddress) + let vaults = (await getConfig('xWinFinance/vaults/' + api.chain, strategyUrl)).map(i => i.contractaddress) const privateVaults = await getConfig('xWinFinance/privateVaults', PrivateURL) vaults.push(...privateVaults[privateKey]) @@ -34,14 +34,18 @@ Object.keys(config).forEach(chain => { vaults.push(...portfolioVaults.map(i => i.contractaddress)) } - const bals = await api.multiCall({ abi: 'uint256:getVaultValues', calls: vaults }) + + const isValidVault = await api.multiCall({ abi: 'uint256:getVaultValues', calls: vaults, permitFailure: true }) + vaults = vaults.filter((_, i) => isValidVault[i]) + + const bals = await api.multiCall({ abi: 'uint256:getVaultValues', calls: vaults, permitFailure: true }) const tokens = await api.multiCall({ abi: 'address:baseToken', calls: vaults }) const decimals = await api.multiCall({ abi: 'erc20:decimals', calls: tokens }) //Get Vault Values returns 18 decimals even if the base token is not //For loop that removes the extra zeros if the base token is not 18 decimals. - bals.forEach((bal, i) => bals[i] = bal / 10 ** (18 - decimals[i])) + bals.forEach((bal, i) => bals[i] = (bal ?? 0) / 10 ** (18 - decimals[i])) api.addTokens(tokens, bals) } From 8746f4080916ce59ddb93a718d284aeeba06bb55 Mon Sep 17 00:00:00 2001 From: cerraio <147749662+cerraio@users.noreply.github.com> Date: Sat, 11 May 2024 02:20:03 -0700 Subject: [PATCH 6/7] add batcher script (#10174) * add batcher script * Update index.js --- projects/cerra/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/cerra/index.js b/projects/cerra/index.js index 1361646e6990..5c3d308b1bbb 100644 --- a/projects/cerra/index.js +++ b/projects/cerra/index.js @@ -2,9 +2,10 @@ const { sumTokens2 } = require("../helper/chain/cardano"); const LENDING_SCRIPT = "addr1z878lgw0676mfkusf0f2h9wl3w5q2zu0klrlcamv6g2werc0pqnxu0fg7wvwgjtgzvg6lg6avzczmwf84aclygrvlkhqfmh5zc"; const AMM_SCRIPT = "addr1zyl8u7cw93g99g2e68cq3k27ad7rd8p6yy3yg9vesgahrus0pqnxu0fg7wvwgjtgzvg6lg6avzczmwf84aclygrvlkhq2a0paj"; +const BATCHER_SCRIPT = "addr1wye2x4ygs0e3u7wp8d2q82uj60gvfe2wjgc284evk8a5cfqw2hvmv"; async function tvl() { - return sumTokens2({ scripts: [LENDING_SCRIPT, AMM_SCRIPT] }) + return sumTokens2({ scripts: [LENDING_SCRIPT, AMM_SCRIPT, BATCHER_SCRIPT] }) } module.exports = { From 3c59ce9d95991cd7d2fc602b1d25e9824f4e9550 Mon Sep 17 00:00:00 2001 From: mrben1 Date: Sat, 11 May 2024 21:21:46 +1200 Subject: [PATCH 7/7] Added ape.store tvm (#10172) --- projects/apestore/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 projects/apestore/index.js diff --git a/projects/apestore/index.js b/projects/apestore/index.js new file mode 100644 index 000000000000..1efd12a64c89 --- /dev/null +++ b/projects/apestore/index.js @@ -0,0 +1,16 @@ +const { sumTokensExport } = require("../helper/unwrapLPs"); +const coreAssets = require("../helper/coreAssets.json"); + +const routers = [ + "0xF6Af6C034E92694A4c79569B03543d580df402D7", + "0x992D40d9ED8937Bb0Ad3c0Ba99713072Ae0a05b3", + "0x135De7F9223C76b7d0278FFe854eC480D37FE906" +]; + +const tokens = [coreAssets.null]; + +module.exports = { + base: { + tvl: sumTokensExport({ owners: routers, tokens }) + }, +}; \ No newline at end of file