Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloud_functions: Added totalsOnly param to notional-tvl-cumulative #1075

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions event_database/cloud_functions/notional-tvl-cumulative.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,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
Expand Down Expand Up @@ -311,12 +313,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/*
Expand Down