Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Nucleus #13237

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }
}
Loading