Skip to content

Commit

Permalink
even more graceful pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
p0mvn committed Mar 7, 2024
1 parent a8e0008 commit 02c32f5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tokens/usecase/tokens_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,18 @@ func (t *tokensUseCase) GetPrices(ctx context.Context, baseDenoms []string, quot
// Returns error if base denom is not found in the token metadata.
// Sets the price to zero in case of failing to compute the price between base and quote but these being valid tokens.
func (t *tokensUseCase) getPricesForBaseDenom(ctx context.Context, pricingStrategy domain.PricingStrategy, baseDenom string, quoteDenoms []string) (map[string]any, error) {

byQuoteDenomForGivenBaseResult := make(map[string]any, len(quoteDenoms))
// Validate base denom is a valid denom
// This will error if denom is unlisted.
// Return zeroes for all quotes if base denom is not found
_, err := t.GetMetadataByChainDenom(ctx, baseDenom)
if err != nil {
return nil, err
for _, quoteDenom := range quoteDenoms {
byQuoteDenomForGivenBaseResult[quoteDenom] = osmomath.ZeroBigDec()
}
return byQuoteDenomForGivenBaseResult, err
}

byQuoteDenomForGivenBaseResult := make(map[string]any, len(quoteDenoms))

// Create a channel to communicate the results
resultsChan := make(chan priceResult, len(quoteDenoms))

Expand Down

0 comments on commit 02c32f5

Please sign in to comment.