Skip to content

Commit

Permalink
feat: nucleus vault yields (#1664)
Browse files Browse the repository at this point in the history
  • Loading branch information
DashanMcCain authored Dec 23, 2024
1 parent 991cca5 commit bfe41dd
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/adaptors/nucleus/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const utils = require('../utils');
const sdk = require('@defillama/sdk');

const vaultData = async () => {
const vaults = await utils.getData(
'https://backend.nucleusearn.io/v1/protocol/markets'
);
const tokens = await utils.getData(
'https://backend.nucleusearn.io/v1/protocol/tokens'
);

let pools = [];
await Promise.all(
Object.keys(vaults).map(async (vaultAddress) => {
try {
const vaultApyQuery = await utils.getData(
`https://backend.nucleusearn.io/v1/vaults/apy?token_address=${vaultAddress}&lookback_days=14`
);
const vaultSymbol = await sdk.api2.erc20.symbol(vaultAddress);

const ethereumApi = new sdk.ChainApi({ chain: 'ethereum' });
const vaultBalances = await ethereumApi.sumTokens({
owner: vaultAddress,
tokens: tokens,
});
const usdBalance = await ethereumApi.getUSDValue();
console.log('Vault TVL: ', usdBalance);

console.log('Vault Symbol: ', vaultSymbol);
const pool = {
pool: `${vaultAddress}-ethereum`,
chain: 'Ethereum',
project: 'nucleus',
symbol: vaultSymbol.output,
tvlUsd: usdBalance,
apy: vaultApyQuery.apy, // 14 days apy
};
pools.push(pool);
} catch (error) {
console.error(`Error processing vault: ${vaultAddress}`, error);
}
})
);

return pools;
};

module.exports = {
timetravel: false,
apy: vaultData,
url: 'https://app.nucleusearn.io/dashboard',
};

0 comments on commit bfe41dd

Please sign in to comment.