From 353e598ad1d883308678e5032b36521e2f5ca149 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sat, 19 May 2012 06:04:37 -0700 Subject: [PATCH] Flip the rate so that lower is better. --- src/Amount.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Amount.cpp b/src/Amount.cpp index 56a1211f6a..89fa2b753e 100644 --- a/src/Amount.cpp +++ b/src/Amount.cpp @@ -414,12 +414,12 @@ STAmount multiply(const STAmount& v1, const STAmount& v2, const uint160& currenc } uint64 getRate(const STAmount& offerOut, const STAmount& offerIn) -{ // Convert an offer into an index amount so they sort +{ // Convert an offer into an index amount so they sort (lower is better) // offerOut = how much comes out of the offer, from the offeror to the taker // offerIn = how much goes into the offer, from the taker to the offeror - if (offerOut.isZero()) return 0; - STAmount r = divide(offerOut, offerIn, uint160(1)); + if (offerOut.isZero()) throw std::runtime_error("Worthless offer"); + STAmount r = divide(offerIn, offerOut, uint160(1)); assert((r.getOffset() >= -100) && (r.getOffset() <= 155)); uint64 ret = r.getOffset() + 100; return (ret << (64 - 8)) | r.getValue();