Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX]: Use mtimesDefault in place of stimes when multiplier can be zero #37

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading