cloud_functions: Added totalsOnly param to notional-tvl-cumulitive

Consumers may only care about the totals which results in a drastically
smaller response payload size.
This commit is contained in:
Kevin Peters 2022-04-12 20:20:40 +00:00 committed by Justin Schuldt
parent b8b90e1de4
commit 0eb4fb9aae
1 changed files with 11 additions and 6 deletions

View File

@ -225,10 +225,12 @@ func TvlCumulative(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
var numDays string
var totalsOnly string
switch r.Method {
case http.MethodGet:
queryParams := r.URL.Query()
numDays = queryParams.Get("numDays")
totalsOnly = queryParams.Get("totalsOnly")
}
var queryDays int
@ -295,12 +297,15 @@ func TvlCumulative(w http.ResponseWriter, r *http.Request) {
}
asset.Notional = roundToTwoDecimalPlaces(notional)
// create a new LockAsset in order to exclude TokenPrice and Amount
dailyTvl[date][chain][symbol] = LockedAsset{
Symbol: asset.Symbol,
Address: asset.Address,
CoinGeckoId: asset.CoinGeckoId,
Notional: asset.Notional,
if totalsOnly == "" {
// create a new LockAsset in order to exclude TokenPrice and Amount
dailyTvl[date][chain][symbol] = LockedAsset{
Symbol: asset.Symbol,
Address: asset.Address,
CoinGeckoId: asset.CoinGeckoId,
Notional: asset.Notional,
}
}
// add this asset's notional to the date/chain/*