From c6011d29efe96d40f86a2d7d539ae3c0845ce386 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 14 Jan 2022 17:25:20 +0000 Subject: [PATCH] fail safe against empty creator liquidity, just read out weights --- .../Asset/AssetActions/Pool/index.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/Asset/AssetActions/Pool/index.tsx b/src/components/Asset/AssetActions/Pool/index.tsx index 97bd22b8a..9689f44f0 100644 --- a/src/components/Asset/AssetActions/Pool/index.tsx +++ b/src/components/Asset/AssetActions/Pool/index.tsx @@ -175,22 +175,23 @@ export default function Pool(): ReactElement { setSwapFee(swapFee) // Get weights + function getWeight(weight: string) { + return isValidNumber(weight) + ? new Decimal(weight).mul(10).toString() + : '0' + } const weightDt = dataLiquidity.pool.datatokenWeight - const weightDtDecimal = isValidNumber(weightDt) - ? new Decimal(weightDt).mul(10).toString() - : '0' + const weightDtDecimal = getWeight(weightDt) setWeightDt(weightDtDecimal) - const weightOceanDecimal = isValidNumber(weightDt) - ? new Decimal(100).minus(new Decimal(weightDt).mul(10)).toString() - : '0' + const weightOcean = dataLiquidity.pool.baseTokenWeight + const weightOceanDecimal = getWeight(weightOcean) setWeightOcean(weightOceanDecimal) // // Get everything the creator put into the pool // - - const creatorPoolTokens = dataLiquidity.pool.shares[0].shares + const creatorPoolTokens = dataLiquidity.pool.shares[0]?.shares setCreatorPoolTokens(creatorPoolTokens) const creatorOceanBalance =