Skip to content

Commit

Permalink
Fixing logic check on getTokenPriceInNativeAsset function
Browse files Browse the repository at this point in the history
  • Loading branch information
Luiz Gustavo Abou Hatem De Liz committed Jul 17, 2023
1 parent 2992c19 commit 9844c15
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { TokenPriceService } from '@balancer-labs/sor';
import axios from 'axios';
import { BALANCER_NETWORK_CONFIG } from '@/lib/constants/config';
import { Network, BalancerNetworkConfig } from '@/types';
import { isUndefined } from "lodash";

export class CoingeckoTokenPriceService implements TokenPriceService {
constructor(private readonly chainId: number) {}
Expand Down Expand Up @@ -31,7 +32,10 @@ export class CoingeckoTokenPriceService implements TokenPriceService {
},
});

if (data[tokenAddress.toLowerCase()][this.nativeAssetId] === undefined) {
if (
isUndefined(data[tokenAddress.toLowerCase()]) ||
isUndefined(data[tokenAddress.toLowerCase()][this.nativeAssetId])
) {
throw Error('No price returned from Coingecko');
}

Expand Down

0 comments on commit 9844c15

Please sign in to comment.