mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Fix unfunded offer not removed (RIPD-1298):
If the mantissas of two non-native amounts differ by less than 10, then subtracting them leaves a result of zero. This can cause situations where `a>b`, yet `a-b == 0`. One consequence of this is unfunded offers were incorrectly left in order books. The code would check if the offer would be consumed (`amount in offer > amount needed`), assume it wouldn't be, yet when `amount needed` was subtracted from `amount in offer` the result was zero and the offer was unfunded. This unfunded offer incorrectly remained on the order book. This patch fixes this bug.
This commit is contained in:
@@ -412,7 +412,15 @@ BookStep<TIn, TOut>::revImp (
|
||||
result.in = sum(savedIns);
|
||||
result.out = out;
|
||||
this->consumeOffer (sb, offer, ofrAdjAmt, stpAdjAmt, ownerGivesAdj);
|
||||
return false;
|
||||
|
||||
// When the mantissas of two iou amounts differ by less than ten, then
|
||||
// subtracting them leaves a result of zero. This can cause the check for
|
||||
// (stpAmt.out > remainingOut) to incorrectly think an offer will be funded
|
||||
// after subtracting remainingIn.
|
||||
if (amendmentRIPD1298(sb.parentCloseTime()))
|
||||
return offer.fully_consumed();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -561,6 +569,14 @@ BookStep<TIn, TOut>::fwdImp (
|
||||
|
||||
remainingIn = in - result.in;
|
||||
this->consumeOffer (sb, offer, ofrAdjAmt, stpAdjAmt, ownerGivesAdj);
|
||||
|
||||
// When the mantissas of two iou amounts differ by less than ten, then
|
||||
// subtracting them leaves a result of zero. This can cause the check for
|
||||
// (stpAmt.in > remainingIn) to incorrectly think an offer will be funded
|
||||
// after subtracting remainingIn.
|
||||
if (amendmentRIPD1298(sb.parentCloseTime()))
|
||||
processMore = processMore || offer.fully_consumed();
|
||||
|
||||
return processMore;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user