From 891c893f9ca28c40e90dc85e786f1ca899429dcf Mon Sep 17 00:00:00 2001 From: mismirnov Date: Fri, 17 Jan 2025 16:10:12 +0300 Subject: [PATCH] Few fixes; --- cmd/api/handler/stats.go | 4 ++-- pkg/tvl/module.go | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/api/handler/stats.go b/cmd/api/handler/stats.go index 0e971859..7f9e1c07 100644 --- a/cmd/api/handler/stats.go +++ b/cmd/api/handler/stats.go @@ -547,8 +547,8 @@ func (sh StatsHandler) MessagesCount24h(c echo.Context) error { // Tvs godoc // -// @Summary Get total TVS of the network -// @Description Get total TVS of the network +// @Summary Get TVS of the network +// @Description Get TVS of the network // @Tags stats // @ID stats-tvs // @Produce json diff --git a/pkg/tvl/module.go b/pkg/tvl/module.go index 04d1f08e..091b4bf5 100644 --- a/pkg/tvl/module.go +++ b/pkg/tvl/module.go @@ -95,11 +95,16 @@ func (m *Module) save(ctx context.Context, rollup *storage.Rollup, timeframe sto tvlResponse := tvl[0].Result.Data.Json tvlModels := make([]*storage.Tvl, 0) for _, t := range tvlResponse { + if _, ok := t[0].(float64); !ok { + return fmt.Errorf("incorrect value type of TVL timestamp") + } + for i := 1; i <= 3; i++ { if _, ok := t[i].(float64); !ok { return fmt.Errorf("incorrect value type of TVL") } } + rollupTvl := t[1].(float64) + t[2].(float64) + t[3].(float64) tvlTs := time.Unix(int64(t[0].(float64)), 0) if tvlTs.After(syncTimestamp) { @@ -118,7 +123,10 @@ func (m *Module) save(ctx context.Context, rollup *storage.Rollup, timeframe sto if err := m.tvl.SaveBulk(ctx, tvlModels...); err != nil { m.Log.Err(err).Msg("saving tvls") + return err } + + return nil } if len(rollup.DeFiLama) > 0 { @@ -147,6 +155,7 @@ func (m *Module) save(ctx context.Context, rollup *storage.Rollup, timeframe sto if err := m.tvl.SaveBulk(ctx, tvlModels...); err != nil { m.Log.Err(err).Msg("saving tvls") + return err } }