Skip to content

Commit

Permalink
Merge pull request #77 from EigenExplorer/76-update-withtvl-flag-to-i…
Browse files Browse the repository at this point in the history
…nclude-eth-conversion-for-all-strategies

Include tvlStrategiesEth value for withTvl flag
  • Loading branch information
uditdc authored May 30, 2024
2 parents 2a097d6 + c296e0f commit 10d4979
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/api/src/routes/strategies/strategiesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ export function sharesToTVL(
new Map(
strategyKeys.map((sk) => [sk as keyof EigenStrategiesContractAddress, 0])
)
const tvlStrategiesEth: Map<keyof EigenStrategiesContractAddress, number> =
new Map(
strategyKeys.map((sk) => [sk as keyof EigenStrategiesContractAddress, 0])
)

restakingStrategies.map((s) => {
const foundStrategyIndex = strategies.findIndex(
Expand Down Expand Up @@ -261,6 +265,14 @@ export function sharesToTVL(

if (strategyTokenPrice) {
const strategyTvl = strategyShares * strategyTokenPrice.eth

tvlStrategiesEth.set(
strategyKeys[
foundStrategyIndex
] as keyof EigenStrategiesContractAddress,
strategyTvl
)

tvlRestaking = tvlRestaking + strategyTvl
}
}
Expand All @@ -271,6 +283,7 @@ export function sharesToTVL(
tvlBeaconChain,
tvlWETH: tvlStrategies.has('WETH') ? tvlStrategies.get('WETH') : 0,
tvlRestaking,
tvlStrategies: Object.fromEntries(tvlStrategies.entries())
tvlStrategies: Object.fromEntries(tvlStrategies.entries()),
tvlStrategiesEth: Object.fromEntries(tvlStrategiesEth.entries())
}
}

0 comments on commit 10d4979

Please sign in to comment.