From c03126a474bcbc10fcd1a680e10a018c18cb733b Mon Sep 17 00:00:00 2001 From: sourabhxyz Date: Tue, 16 Jan 2024 08:52:37 +0530 Subject: [PATCH] [FIX]: Use `mtimesDefaul` in place of `stimes` when multiplier can be zero --- .../src/GeniusYield/MarketMaker/Strategies.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/geniusyield-market-maker/src/GeniusYield/MarketMaker/Strategies.hs b/geniusyield-market-maker/src/GeniusYield/MarketMaker/Strategies.hs index 3a05074..4ce7ce8 100644 --- a/geniusyield-market-maker/src/GeniusYield/MarketMaker/Strategies.hs +++ b/geniusyield-market-maker/src/GeniusYield/MarketMaker/Strategies.hs @@ -9,7 +9,8 @@ import qualified Data.Map.Strict as M import Data.Maybe (fromJust, mapMaybe) import Data.Ratio (denominator, numerator, (%)) -import Data.Semigroup (Semigroup (stimes)) +import Data.Semigroup (Semigroup (stimes), + mtimesDefault) import Deriving.Aeson import GeniusYield.AnnSet.Internal (orderInfo, toAscList) @@ -204,7 +205,7 @@ fixedSpreadVsMarketPriceStrategy neededAtleast = stimes numNewBuyOrders neededAtleastPerOrder valueSufficient = totalValueOnUtxos `valueGreaterOrEqual` neededAtleast actualNumNewBuyOrders = if valueSufficient then numNewBuyOrders else fromIntegral $ subtractTillZero totalValueOnUtxos neededAtleastPerOrder 0 - totalValueOnUtxosAfterBuyOrds = totalValueOnUtxos `valueMinus` stimes actualNumNewBuyOrders neededAtleastPerOrder + totalValueOnUtxosAfterBuyOrds = totalValueOnUtxos `valueMinus` mtimesDefault actualNumNewBuyOrders neededAtleastPerOrder unless valueSufficient $ logWarn providers $ printf "Bot has to place %d buy order(s), but lack funds, total balance (excluding collateral) should be at least: %s but available funds are: %s. Only placing %d buy order(s)." numNewBuyOrders (show neededAtleast) (show totalValueOnUtxos) actualNumNewBuyOrders