From 1ba0139683cde11505f5ec5ebb40c66cad4ecfef Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 2 Oct 2013 16:13:14 -0700 Subject: [PATCH] Claim saInRemaining. --- src/ripple_app/paths/RippleCalc.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ripple_app/paths/RippleCalc.cpp b/src/ripple_app/paths/RippleCalc.cpp index 3df36c8fc..bd6395c7f 100644 --- a/src/ripple_app/paths/RippleCalc.cpp +++ b/src/ripple_app/paths/RippleCalc.cpp @@ -718,7 +718,12 @@ TER RippleCalc::calcNodeDeliverFwd ( STAmount saOutPassFunded = std::min (saOutFunded, saCurDeliverMax - saCurDeliverAct); // Offer maximum out - limit by most to deliver. STAmount saInFunded = STAmount::mulRound (saOutPassFunded, saOfrRate, saTakerPays, true); // Offer maximum in - Limited by by payout. STAmount saInTotal = STAmount::mulRound (saInFunded, saInFeeRate, true); // Offer maximum in with fees. - STAmount saInSum = std::min (saInTotal, saInReq - saInAct - saInFees); // In limited by remaining. + STAmount saInRemaining = saInReq - saInAct - saInFees; + + if (saInRemaining.isNegative()) + saInRemaining.zero(); + + STAmount saInSum = std::min (saInTotal, saInRemaining); // In limited by remaining. STAmount saInPassAct = std::min (saTakerPays, STAmount::divRound (saInSum, saInFeeRate, true)); // In without fees. STAmount saOutPassMax = std::min (saOutPassFunded, STAmount::divRound (saInPassAct, saOfrRate, saTakerGets, true)); // Out limited by in remaining.