From 5dd59ee7c112eeb5efea029d0ab7cb2d854ac561 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 27 Apr 2019 15:23:42 +0500 Subject: [PATCH] prevent average costbasis zero div --- src/cc/prices.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 5d608beb2..4e0235cd3 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -1342,9 +1342,15 @@ UniValue PricesInfo(uint256 bettxid, int32_t refheight) } int64_t equity = totalbets + totalprofits; - costbasis /= (totalbets / PRICES_NORMFACTOR); - int64_t liqprice = costbasis - costbasis / leverage; - + if (totalbets / PRICES_NORMFACTOR != 0) //prevent zero div + costbasis /= (totalbets / PRICES_NORMFACTOR); + else + costbasis = 0; + int64_t liqprice; + if (leverage != 0) + liqprice = costbasis - costbasis / leverage; + else + liqprice = 0; if (equity >= 0) result.push_back(Pair("rekt", 0));