Skip to content

Commit

Permalink
fix: prevent unsupported strategies leaking into rewards object (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
gowthamsundaresan authored Jan 21, 2025
1 parent ba63551 commit 78c08a4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/api/src/routes/operators/operatorController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,14 @@ async function calculateOperatorApy(operator: any) {

// Iterate through each strategy and calculate all its rewards
for (const strategyAddress of avs.avs.restakeableStrategies) {
// Omit strategy where the Operator doesn't have shares
if (
!operator.shares.find(
(share) => share.strategyAddress.toLowerCase() === strategyAddress.toLowerCase()
)
)
continue

const strategyTvl = tvlStrategiesEth[strategyAddress.toLowerCase()] || 0
if (strategyTvl === 0) continue

Expand Down Expand Up @@ -677,7 +685,7 @@ async function calculateOperatorApy(operator: any) {

avsApyMap.set(avs.avs.address, {
avsAddress: avs.avs.address,
maxApy: avs.avs.maxApy,
maxApy: Math.max(...Array.from(strategyApyMap.values()).map((data) => data.apy)),
strategyApys: Array.from(strategyApyMap.entries()).map(([strategyAddress, data]) => ({
strategyAddress,
apy: data.apy,
Expand Down

0 comments on commit 78c08a4

Please sign in to comment.