From 14e97ff83a17f01c0ec14b6338dfaf45add9c15c Mon Sep 17 00:00:00 2001 From: Udit Veerwani <25996904+uditdc@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:35:02 +0530 Subject: [PATCH] fix: prevent strategy apy calculation leaking between Avs (#311) Co-authored-by: Gowtham S --- .../src/routes/operators/operatorController.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/api/src/routes/operators/operatorController.ts b/packages/api/src/routes/operators/operatorController.ts index d77bd1fc..88ff24b8 100644 --- a/packages/api/src/routes/operators/operatorController.ts +++ b/packages/api/src/routes/operators/operatorController.ts @@ -563,13 +563,6 @@ async function calculateOperatorApy(operator: any) { }[] } > = new Map() - const strategyApyMap: Map< - string, - { - apy: number - tokens: Map - } - > = new Map() const tokenPrices = await fetchTokenPrices() const strategiesWithSharesUnderlying = await getStrategiesWithShareUnderlying() @@ -592,6 +585,14 @@ async function calculateOperatorApy(operator: any) { return [] for (const avs of avsWithEligibleRewardSubmissions) { + const strategyApyMap: Map< + string, + { + apy: number + tokens: Map + } + > = new Map() + const shares = withOperatorShares(avs.avs.operators).filter( (s) => avs.avs.restakeableStrategies?.indexOf(s.strategyAddress.toLowerCase()) !== -1 )