From 45ff366639d1e7ef0e9344e0068b2d8527714f9f Mon Sep 17 00:00:00 2001 From: trung Date: Sat, 1 Jun 2024 00:10:20 +0700 Subject: [PATCH] refactor: hande potential division by zero --- airdrop/chains/terra.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/airdrop/chains/terra.go b/airdrop/chains/terra.go index ac283c85..4d81a4f0 100644 --- a/airdrop/chains/terra.go +++ b/airdrop/chains/terra.go @@ -73,6 +73,10 @@ func Terra() ([]banktypes.Balance, []config.Reward, int, error) { if token.LT(tokenIn20Usd) { continue } + + if totalTokenDelegate.IsZero() { + return nil, nil, 0, fmt.Errorf("total token delegate is zero, cannot proceed with airdrop calculation") + } eveAirdrop := (eveAirdrop.MulInt64(int64(config.GetTerraConfig().Percent))).QuoInt64(100).Mul(token).QuoTruncate(totalTokenDelegate) eveBech32Address, err := utils.ConvertBech32Address(delegator.Delegation.DelegatorAddress) if err != nil {