From a34e65be3077eeed4a2e1b02b6b43d5d8e63b5c2 Mon Sep 17 00:00:00 2001 From: eli-d <64763513+eli-d@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:33:02 +1030 Subject: [PATCH] don't fail on pools with no tvl --- cmd/graphql.ethereum/graph/schema.resolvers.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/graphql.ethereum/graph/schema.resolvers.go b/cmd/graphql.ethereum/graph/schema.resolvers.go index 25407085..0d19245e 100644 --- a/cmd/graphql.ethereum/graph/schema.resolvers.go +++ b/cmd/graphql.ethereum/graph/schema.resolvers.go @@ -990,10 +990,16 @@ func (r *seawaterPoolResolver) Apr(ctx context.Context, obj *seawater.Pool) (mod } // Get most recent TVL tvlOverTime, err := r.TvlOverTime(ctx, obj) - if err != nil || len(tvlOverTime.Daily) == 0 { + if err != nil { return model.Apr{}, fmt.Errorf("no tvl: %v", err) } - tvl, _ := new(big.Rat).SetString(tvlOverTime.Daily[0]) + var tvlString string + if len(tvlOverTime.Daily) == 0 { + tvlString = "0" + } else { + tvlString = tvlOverTime.Daily[0] + } + tvl, _ := new(big.Rat).SetString(tvlString) // Get total fees from this pool yield, err := r.TotalFee(ctx, obj) if err != nil {