From 4ad5f123982adea3e97fa2d6582c0d21f999828d Mon Sep 17 00:00:00 2001 From: Soon Huat Date: Mon, 21 Mar 2022 11:58:19 +0800 Subject: [PATCH 1/2] handle order price, NaN and default 0 --- src/@utils/accessDetailsAndPricing.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/@utils/accessDetailsAndPricing.ts b/src/@utils/accessDetailsAndPricing.ts index 9504b26fe..c2741f145 100644 --- a/src/@utils/accessDetailsAndPricing.ts +++ b/src/@utils/accessDetailsAndPricing.ts @@ -294,10 +294,14 @@ export async function getOrderPriceAndFees( } // calculate full price, we assume that all the values are in ocean, otherwise this will be incorrect - orderPriceAndFee.price = new Decimal(orderPriceAndFee.price) - .add(new Decimal(orderPriceAndFee.consumeMarketOrderFee)) - .add(new Decimal(orderPriceAndFee.publisherMarketOrderFee)) - .add(new Decimal(orderPriceAndFee.providerFee.providerFeeAmount)) + orderPriceAndFee.price = new Decimal(+orderPriceAndFee.price || 0) + .add(new Decimal(+orderPriceAndFee.consumeMarketOrderFee || 0)) + .add(new Decimal(+orderPriceAndFee.publisherMarketOrderFee || 0)) + .add(new Decimal(+orderPriceAndFee?.providerFee?.providerFeeAmount || 0)) + .add(new Decimal(+orderPriceAndFee.publisherMarketPoolSwapFee || 0)) + .add(new Decimal(+orderPriceAndFee.publisherMarketFixedSwapFee || 0)) + .add(new Decimal(+orderPriceAndFee.consumeMarketPoolSwapFee || 0)) + .add(new Decimal(+orderPriceAndFee.consumeMarketFixedSwapFee || 0)) .toString() return orderPriceAndFee } From 9da987ea9d2d423718f2c42dd82fc243c2704e82 Mon Sep 17 00:00:00 2001 From: Soon Huat Date: Mon, 21 Mar 2022 15:35:06 +0800 Subject: [PATCH 2/2] optional value for all fee, prevent breaking when no value --- src/@utils/accessDetailsAndPricing.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/@utils/accessDetailsAndPricing.ts b/src/@utils/accessDetailsAndPricing.ts index c2741f145..f53c667e8 100644 --- a/src/@utils/accessDetailsAndPricing.ts +++ b/src/@utils/accessDetailsAndPricing.ts @@ -295,13 +295,13 @@ export async function getOrderPriceAndFees( // calculate full price, we assume that all the values are in ocean, otherwise this will be incorrect orderPriceAndFee.price = new Decimal(+orderPriceAndFee.price || 0) - .add(new Decimal(+orderPriceAndFee.consumeMarketOrderFee || 0)) - .add(new Decimal(+orderPriceAndFee.publisherMarketOrderFee || 0)) + .add(new Decimal(+orderPriceAndFee?.consumeMarketOrderFee || 0)) + .add(new Decimal(+orderPriceAndFee?.publisherMarketOrderFee || 0)) .add(new Decimal(+orderPriceAndFee?.providerFee?.providerFeeAmount || 0)) - .add(new Decimal(+orderPriceAndFee.publisherMarketPoolSwapFee || 0)) - .add(new Decimal(+orderPriceAndFee.publisherMarketFixedSwapFee || 0)) - .add(new Decimal(+orderPriceAndFee.consumeMarketPoolSwapFee || 0)) - .add(new Decimal(+orderPriceAndFee.consumeMarketFixedSwapFee || 0)) + .add(new Decimal(+orderPriceAndFee?.publisherMarketPoolSwapFee || 0)) + .add(new Decimal(+orderPriceAndFee?.publisherMarketFixedSwapFee || 0)) + .add(new Decimal(+orderPriceAndFee?.consumeMarketPoolSwapFee || 0)) + .add(new Decimal(+orderPriceAndFee?.consumeMarketFixedSwapFee || 0)) .toString() return orderPriceAndFee }