Skip to content

Commit

Permalink
refactor: hande potential division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
trungnt1811 committed May 31, 2024
1 parent b0000d9 commit 45ff366
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions airdrop/chains/terra.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 45ff366

Please sign in to comment.