-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
991cca5
commit bfe41dd
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}; |