Skip to content

Commit 635703a

Browse files
committed
fix: prevent strategy earnings double-counting when multiple log filters match in same block
1 parent acbd667 commit 635703a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/templates/strategy/strategy-earnings.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,12 @@ export const processStrategyEarnings = async (
214214
})
215215
}
216216
const balanceTrackingUpdate = async () => {
217-
// ctx.log.info(`balanceTrackingUpdate`)
217+
// Skip if we've already updated balances for this block. Multiple matching
218+
// logs/traces in the same block would otherwise call processDepositWithdrawal
219+
// multiple times, and the `current.earningsChange += earningsChange` accumulator
220+
// in that function would double-count. The eth_call at this block returns the
221+
// same value regardless of how many events fired, so one pass per block is correct.
222+
if (didUpdate) return
218223
didUpdate = true
219224
const balances = await getBalances()
220225
await processDepositWithdrawal(ctx, strategyData, block, strategyYields, balances)

0 commit comments

Comments
 (0)