From 87f4e3b4ddd1def43582ba618568584e9d831dd1 Mon Sep 17 00:00:00 2001 From: Nicholas Addison Date: Thu, 30 Sep 2021 21:49:26 +1000 Subject: [PATCH] fix: HH rewards task catch error if can't ALCX price from Uniswap --- tasks/utils/snap-utils.ts | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tasks/utils/snap-utils.ts b/tasks/utils/snap-utils.ts index fc7b66b0..bc6347d2 100644 --- a/tasks/utils/snap-utils.ts +++ b/tasks/utils/snap-utils.ts @@ -917,15 +917,20 @@ export const getAlcxTokens = async ( totalComp = totalComp.add(compLiquidatorBal) console.log(`Liquidator ${quantityFormatter(compLiquidatorBal)}`) - const alcxUsdc = await quoteSwap( - signer, - ALCX, - alUSD, - totalComp, - toBlock, - [ALCX.address, uniswapEthToken, DAI.address, alUSD.address], - [10000, 3000, 500], - ) - console.log(`Total ${quantityFormatter(totalComp)} ${quantityFormatter(alcxUsdc.outAmount)} alUSD`) - console.log(`ALCX/USDC exchange rate: ${alcxUsdc.exchangeRate}`) + try { + const alcxUsdc = await quoteSwap( + signer, + ALCX, + alUSD, + totalComp, + toBlock, + [ALCX.address, uniswapEthToken, DAI.address, alUSD.address], + [10000, 3000, 500], + ) + console.log(`Total ${quantityFormatter(totalComp)} ${quantityFormatter(alcxUsdc.outAmount)} alUSD`) + console.log(`ALCX/USDC exchange rate: ${alcxUsdc.exchangeRate}`) + } catch (err) { + console.log(`Total ${quantityFormatter(totalComp)}`) + console.error(`Failed to get ALCX to alUSD rate.`) + } }