From 90667040fe5b06e15449d6e1cd15b0d59a2dec5c Mon Sep 17 00:00:00 2001 From: mihaisc Date: Wed, 5 Aug 2020 15:24:07 +0300 Subject: [PATCH 1/3] getCheapestPool return proper value --- src/utils/dtUtils.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/dtUtils.ts b/src/utils/dtUtils.ts index 858c26e..bb0e300 100644 --- a/src/utils/dtUtils.ts +++ b/src/utils/dtUtils.ts @@ -10,6 +10,12 @@ export async function getCheapestPool( dataTokenAddress ) Logger.log('DT Pool found', tokenPools) + if(tokenPools===undefined || tokenPools.length===0){ + return { + poolAddress: '', + poolPrice: '0' + } + } let cheapestPoolAddress let cheapestPoolPrice = new Decimal(999999999999) From 6c1bfcbfd9f857d7e80959ac05a34e1085e2b3d9 Mon Sep 17 00:00:00 2001 From: mihaisc Date: Wed, 5 Aug 2020 15:24:19 +0300 Subject: [PATCH 2/3] format --- src/utils/dtUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/dtUtils.ts b/src/utils/dtUtils.ts index bb0e300..47711bc 100644 --- a/src/utils/dtUtils.ts +++ b/src/utils/dtUtils.ts @@ -10,7 +10,7 @@ export async function getCheapestPool( dataTokenAddress ) Logger.log('DT Pool found', tokenPools) - if(tokenPools===undefined || tokenPools.length===0){ + if (tokenPools === undefined || tokenPools.length === 0) { return { poolAddress: '', poolPrice: '0' From 56e6dc688e218b45df627e99cf5d2f119f035036 Mon Sep 17 00:00:00 2001 From: mihaisc Date: Thu, 6 Aug 2020 12:13:17 +0300 Subject: [PATCH 3/3] correct price when no pools --- src/utils/dtUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/dtUtils.ts b/src/utils/dtUtils.ts index 47711bc..625c46d 100644 --- a/src/utils/dtUtils.ts +++ b/src/utils/dtUtils.ts @@ -13,7 +13,7 @@ export async function getCheapestPool( if (tokenPools === undefined || tokenPools.length === 0) { return { poolAddress: '', - poolPrice: '0' + poolPrice: '' } } let cheapestPoolAddress @@ -27,7 +27,7 @@ export async function getCheapestPool( '1' ) const decimalPoolPrice = new Decimal(poolPrice) - Logger.log('Pool price ', tokenPools[i], poolPrice) + Logger.log('Pool price ', tokenPools[i], decimalPoolPrice.toString()) if (decimalPoolPrice < cheapestPoolPrice) { cheapestPoolPrice = decimalPoolPrice cheapestPoolAddress = tokenPools[i]