1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

Merge pull request #1216 from oceanprotocol/feature/v4-c2d-order-price-and-fee

handle order price, NaN and default 0
This commit is contained in:
Bogdan Fazakas 2022-03-22 11:03:51 +02:00 committed by GitHub
commit 91ecdcdf05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}