|
1 | 1 | const { getCuratorExport } = require("../helper/curators");
|
| 2 | +const axios = require('axios'); |
2 | 3 |
|
3 | 4 | const configs = {
|
4 | 5 | methodology: 'Counts all assets that are deposited in all vaults curated by Gauntlet.',
|
@@ -227,9 +228,34 @@ async function tvl(api) {
|
227 | 228 | }
|
228 | 229 | }
|
229 | 230 |
|
| 231 | +async function megavaultTvl(api) { |
| 232 | + const url = "https://indexer.dydx.trade/v4/vault/v1/megavault/historicalPnl?resolution=hour"; |
| 233 | + const { data } = await axios.get(url, { headers: { 'Accept': 'application/json' } }); |
| 234 | + const pnlArr = data.megavaultPnl; |
| 235 | + if (!pnlArr || !pnlArr.length) return; |
| 236 | + const currentTvl = Number(pnlArr[pnlArr.length - 1].equity); |
| 237 | + |
| 238 | + // Report as USD Coin using coingecko identifier |
| 239 | + api.add('coingecko:usd-coin', (currentTvl * 1e6).toFixed(0)); |
| 240 | +} |
| 241 | + |
| 242 | +async function combinedEthereumTvl(api) { |
| 243 | + // First, get the existing curator TVL |
| 244 | + const curatorExport = getCuratorExport(configs); |
| 245 | + if (curatorExport.ethereum && curatorExport.ethereum.tvl) { |
| 246 | + await curatorExport.ethereum.tvl(api); |
| 247 | + } |
| 248 | + |
| 249 | + // Then add MegaVault TVL |
| 250 | + console.log("Adding MegaVault TVL to ethereum..."); |
| 251 | + await megavaultTvl(api); |
| 252 | + console.log("MegaVault TVL added to ethereum"); |
| 253 | +} |
| 254 | + |
230 | 255 | module.exports = {
|
231 | 256 | ...getCuratorExport(configs),
|
232 | 257 | solana: { tvl },
|
| 258 | + ethereum: { tvl: combinedEthereumTvl }, |
233 | 259 | timetravel: false,
|
234 | 260 | methodology: configs.methodology,
|
235 | 261 | }
|
0 commit comments