Skip to content

Commit

Permalink
Few fixes;
Browse files Browse the repository at this point in the history
  • Loading branch information
mismirnov committed Jan 17, 2025
1 parent bcd85fb commit 891c893
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/api/handler/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions pkg/tvl/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
}

Expand Down

0 comments on commit 891c893

Please sign in to comment.