From 0534eb74943ac93425403ec538808a90dfe8e316 Mon Sep 17 00:00:00 2001 From: eli-d <64763513+eli-d@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:55:07 +1030 Subject: [PATCH] avoid nil deref/div by zero in apr resolver --- cmd/graphql.ethereum/graph/schema.resolvers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/graphql.ethereum/graph/schema.resolvers.go b/cmd/graphql.ethereum/graph/schema.resolvers.go index 92ad5517..f996f04e 100644 --- a/cmd/graphql.ethereum/graph/schema.resolvers.go +++ b/cmd/graphql.ethereum/graph/schema.resolvers.go @@ -995,7 +995,7 @@ func (r *seawaterPoolResolver) Apr(ctx context.Context, obj *seawater.Pool) (mod } var tvlString string if len(tvlOverTime.Daily) == 0 { - tvlString = "0" + tvlString = "1" } else { tvlString = tvlOverTime.Daily[0] } @@ -1023,7 +1023,7 @@ func (r *seawaterPoolResolver) Apr(ctx context.Context, obj *seawater.Pool) (mod return model.Apr{}, fmt.Errorf("liquidity campaigns: %v", err) } // Sum all rewards for all campaigns on this pool - var allCampaignRewards *big.Rat + allCampaignRewards := new(big.Rat) for _, campaign := range activeLiquidityCampaigns { // Get current price of the token distributed by this campaign pool, err := r.Resolver.Query().GetPool(ctx, campaign.Token.String())