From dcc32ea2eb487e5b52be70ddab499e54e0be12d2 Mon Sep 17 00:00:00 2001 From: Eela Nagaraj <7308464+eelanagaraj@users.noreply.github.com> Date: Sat, 24 Apr 2021 19:59:35 +0200 Subject: [PATCH] Fix 0-GoldWithdraw edge case (#160) --- analyzer/txtracer.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/analyzer/txtracer.go b/analyzer/txtracer.go index 90983597..6bf1e44a 100644 --- a/analyzer/txtracer.go +++ b/analyzer/txtracer.go @@ -299,7 +299,11 @@ func (tr *Tracer) TxOpsFromLogs(tx *types.Transaction, receipt *types.Receipt, t case "GoldWithdrawn": // withdraw() [GoldWithdrawn + transfer] => lockPending->main event := eventRaw.(*contracts.LockedGoldGoldWithdrawn) - transfers = append(transfers, *NewWithdrawGold(event.Account, lockedGoldAddr, event.Value, tobinTax)) + // Edge case: withdrawing 0 CELO means there isn't a matching transfer; + // Only store balance-changing (>0) GoldLocked logs. + if event.Value.Cmp(big.NewInt(0)) > 0 { + transfers = append(transfers, *NewWithdrawGold(event.Account, lockedGoldAddr, event.Value, tobinTax)) + } case "AccountSlashed": // slash() [AccountSlashed + transfer] => account:lockNonVoting -> beneficiary:lockNonVoting + governance:main