Skip to content

Commit

Permalink
Fix: Nucleus (#13237)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpeluche authored Jan 27, 2025
1 parent a610cd0 commit 618f48a
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions projects/nucleus/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
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 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 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")
const sanitizeTokens = sanitizeAndValidateEvmAddresses(tokens)
return api.sumTokens({ owners: vaults, tokens: sanitizeTokens })
}

module.exports = {
ethereum: {
tvl,
},
};
ethereum: { tvl }
}

0 comments on commit 618f48a

Please sign in to comment.