Skip to content

Commit

Permalink
Expose Factor in Query
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbean committed Jul 22, 2023
1 parent 9763a1d commit ca8d5db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Deal/DealAction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,10 @@ performAction d t@TestDeal{bonds=bndMap,accounts=accMap} (W.PayPrinBy (DS ds) an
t {accounts = accMapAfterPay, bonds = bndMapAfterPay}
where
availBal = A.accBalance $ accMap Map.! an
targetBnd = bndMap Map.! bndName
targetBndBal = L.bndBalance $ bndMap Map.! bndName

patchedDs = patchDateToStats d ds
payAmount = min availBal (queryDeal t patchedDs) -- `debug` ("Query with "++show (patchedDs))
payAmount = min targetBndBal $ min availBal (queryDeal t patchedDs) -- `debug` ("Query with "++show (patchedDs))

accMapAfterPay = Map.adjust
(A.draw payAmount d (TxnComments [PayPrin [bndName],UsingDS ds]))
Expand Down
3 changes: 3 additions & 0 deletions src/Deal/DealQuery.hs
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,13 @@ queryDeal t s =

FloorAndCap floor cap s -> max (queryDeal t floor) $ min (queryDeal t cap) (queryDeal t s)

Factor s f -> mulBR (queryDeal t s) f

FloorWith s floor -> max (queryDeal t s) (queryDeal t floor)
FloorWithZero s -> max (queryDeal t s) 0
CapWith s cap -> min (queryDeal t s) (queryDeal t cap)
Round ds rb -> roundingBy rb (queryDeal t ds)


_ -> 0.0 `debug` ("Failed to query balance of -> "++ show s)

Expand Down

0 comments on commit ca8d5db

Please sign in to comment.