From 9844c1505f253ad6336778db4e917bbdb1e75959 Mon Sep 17 00:00:00 2001 From: Luiz Gustavo Abou Hatem De Liz Date: Mon, 17 Jul 2023 10:15:49 -0300 Subject: [PATCH] Fixing logic check on getTokenPriceInNativeAsset function --- .../modules/sor/token-price/coingeckoTokenPriceService.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/balancer-js/src/modules/sor/token-price/coingeckoTokenPriceService.ts b/balancer-js/src/modules/sor/token-price/coingeckoTokenPriceService.ts index 0edd232ab..d80b97ea0 100644 --- a/balancer-js/src/modules/sor/token-price/coingeckoTokenPriceService.ts +++ b/balancer-js/src/modules/sor/token-price/coingeckoTokenPriceService.ts @@ -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) {} @@ -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'); }