diff --git a/event_database/cloud_functions/notional-tvl.go b/event_database/cloud_functions/notional-tvl.go index b5e0c1c52..60e7ed138 100644 --- a/event_database/cloud_functions/notional-tvl.go +++ b/event_database/cloud_functions/notional-tvl.go @@ -358,6 +358,14 @@ func TVL(w http.ResponseWriter, r *http.Request) { tokenPrices := fetchTokenPrices(ctx, coinIdSet) notionalLocked := map[string]map[string]LockedAsset{} + + // initialize the struct that will hold the total for all chains, all assets + notionalLocked["*"] = map[string]LockedAsset{} + notionalLocked["*"]["*"] = LockedAsset{ + Symbol: "*", + Name: "all", + Notional: 0, + } for chain, tokens := range tokensLocked { notionalLocked[chain] = map[string]LockedAsset{} notionalLocked[chain]["*"] = LockedAsset{ @@ -394,6 +402,12 @@ func TVL(w http.ResponseWriter, r *http.Request) { } } + // add the chain total to the overall total + if all, ok := notionalLocked["*"]["*"]; ok { + all.Notional += notionalLocked[chain]["*"].Notional + notionalLocked["*"]["*"] = all + } + // round the the amount for chain/* if asset, ok := notionalLocked[chain]["*"]; ok { asset.Notional = roundToTwoDecimalPlaces(asset.Notional)