From 656a18705d1b499dd75bb1ce074e42a3987e275b Mon Sep 17 00:00:00 2001 From: 0xpeluche <0xpeluche@proton.me> Date: Fri, 24 Jan 2025 12:20:22 +0100 Subject: [PATCH 1/2] Fix: Nucleus --- projects/nucleus/index.js | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/projects/nucleus/index.js b/projects/nucleus/index.js index 83a30e462c..a71a6fedc4 100644 --- a/projects/nucleus/index.js +++ b/projects/nucleus/index.js @@ -1,25 +1,13 @@ const { getConfig } = require("../helper/cache"); -async function getMarkets() { - return getConfig('nucleus-vaults', "https://backend.nucleusearn.io/v1/protocol/markets"); -} - -async function getTokens() { - return getConfig('nucleus-tokens', "https://backend.nucleusearn.io/v1/protocol/tokens"); -} - +const isEvm = (address) => /^0x[a-fA-F0-9]{40}$/.test(address) const tvl = async (api) => { - - const vaultMap = await getMarkets(); - const owners = Object.keys(vaultMap); - const tokens = await getTokens(); - - return api.sumTokens({ owners, tokens }) - }; + const vaults = Object.keys(await getConfig('nucleus-vaults', "https://backend.nucleusearn.io/v1/protocol/markets")) + const tokens = (await getConfig('nucleus-tokens', "https://backend.nucleusearn.io/v1/protocol/tokens")).filter(isEvm) + return api.sumTokens({ owners: vaults, tokens }) +} module.exports = { - ethereum: { - tvl, - }, - }; \ No newline at end of file + ethereum: { tvl } +} \ No newline at end of file From 0fe08b06fc62a63ca4da3d816f274f808561fa5a Mon Sep 17 00:00:00 2001 From: 0xpeluche <0xpeluche@proton.me> Date: Fri, 24 Jan 2025 13:48:40 +0100 Subject: [PATCH 2/2] Use only vault from Nucleus deployer --- projects/nucleus/index.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/projects/nucleus/index.js b/projects/nucleus/index.js index a71a6fedc4..2e27c53365 100644 --- a/projects/nucleus/index.js +++ b/projects/nucleus/index.js @@ -1,11 +1,28 @@ const { getConfig } = require("../helper/cache"); -const isEvm = (address) => /^0x[a-fA-F0-9]{40}$/.test(address) +const sanitizeAndValidateEvmAddresses = (addresses) => { + return addresses + .map((address) => address.replace(/_$/, "")) + .filter((address) => /^0x[a-fA-F0-9]{40}$/.test(address)); +}; + +const vaults = [ + '0x52E4d8989fa8b3E1C06696e7b16DEf5d7707A0d1', // bobaETH + '0xA8A3A5013104e093245164eA56588DBE10a3Eb48', // ssETH + '0x6C587402dC88Ef187670F744dFB9d6a09Ff7fd76', // FETH + '0x5d82Ac302C64B229dC94f866FD10EC6CcF8d47A2', // rariETH + '0x66E47E6957B85Cf62564610B76dD206BB04d831a', // earnBTC + '0x9Ed15383940CC380fAEF0a75edacE507cC775f22', // earnETH + '0x196ead472583bc1e9af7a05f860d9857e1bd3dcc', // unifiETH + '0x19e099B7aEd41FA52718D780dDA74678113C0b32', // tETH + '0x9fAaEA2CDd810b21594E54309DC847842Ae301Ce', // seiyanETH +] const tvl = async (api) => { - const vaults = Object.keys(await getConfig('nucleus-vaults', "https://backend.nucleusearn.io/v1/protocol/markets")) - const tokens = (await getConfig('nucleus-tokens', "https://backend.nucleusearn.io/v1/protocol/tokens")).filter(isEvm) - return api.sumTokens({ owners: vaults, tokens }) + // const vaults = Object.keys(await getConfig('nucleus-vaults', "https://backend.nucleusearn.io/v1/protocol/markets")) + const tokens = await getConfig('nucleus-tokens', "https://backend.nucleusearn.io/v1/protocol/tokens") + const sanitizeTokens = sanitizeAndValidateEvmAddresses(tokens) + return api.sumTokens({ owners: vaults, tokens: sanitizeTokens }) } module.exports = {