Skip to content

Commit

Permalink
Merge pull request #37 from geniusyield/fix-stimes
Browse files Browse the repository at this point in the history
[FIX]: Use `mtimesDefault` in place of `stimes` when multiplier can be zero
  • Loading branch information
ajuggler authored Jan 17, 2024
2 parents 7f97ddb + c03126a commit 2a292bf
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 2a292bf

Please sign in to comment.