@@ -78,7 +78,7 @@ public double getMarketPrice(String currencyCode) throws ExecutionException, Int
78
78
} else if (!marketPrice .isExternallyProvidedPrice ()) {
79
79
throw new IllegalArgumentException ("Price is not available externally: " + currencyCode ); // TODO: return more complex Price type including price double and isExternal boolean
80
80
}
81
- return mapPriceFeedServicePrice ( marketPrice .getPrice (), marketPrice . getCurrencyCode () );
81
+ return marketPrice .getPrice ();
82
82
}
83
83
84
84
/**
@@ -87,8 +87,7 @@ public double getMarketPrice(String currencyCode) throws ExecutionException, Int
87
87
public List <MarketPriceInfo > getMarketPrices () throws ExecutionException , InterruptedException , TimeoutException {
88
88
return priceFeedService .requestAllPrices ().values ().stream ()
89
89
.map (marketPrice -> {
90
- double mappedPrice = mapPriceFeedServicePrice (marketPrice .getPrice (), marketPrice .getCurrencyCode ());
91
- return new MarketPriceInfo (marketPrice .getCurrencyCode (), mappedPrice );
90
+ return new MarketPriceInfo (marketPrice .getCurrencyCode (), marketPrice .getPrice ());
92
91
})
93
92
.collect (Collectors .toList ());
94
93
}
@@ -102,12 +101,13 @@ public MarketDepthInfo getMarketDepth(String currencyCode) throws ExecutionExcep
102
101
// Offer price can be null (if price feed unavailable), thus a null-tolerant comparator is used.
103
102
Comparator <Offer > offerPriceComparator = Comparator .comparing (Offer ::getPrice , Comparator .nullsLast (Comparator .naturalOrder ()));
104
103
104
+ // TODO: remove this!!!
105
105
// Trading xmr-traditional is considered as buying/selling XMR, but trading xmr-crypto is
106
106
// considered as buying/selling crypto. Because of this, when viewing a xmr-crypto pair,
107
107
// the buy column is actually the sell column and vice versa. To maintain the expected
108
108
// ordering, we have to reverse the price comparator.
109
- boolean isCrypto = CurrencyUtil .isCryptoCurrency (currencyCode );
110
- if (isCrypto ) offerPriceComparator = offerPriceComparator .reversed ();
109
+ // boolean isCrypto = CurrencyUtil.isCryptoCurrency(currencyCode);
110
+ // if (isCrypto) offerPriceComparator = offerPriceComparator.reversed();
111
111
112
112
// Offer amounts are used for the secondary sort. They are sorted from high to low.
113
113
Comparator <Offer > offerAmountComparator = Comparator .comparing (Offer ::getAmount ).reversed ();
@@ -130,11 +130,11 @@ public MarketDepthInfo getMarketDepth(String currencyCode) throws ExecutionExcep
130
130
double amount = (double ) offer .getAmount ().longValueExact () / LongMath .pow (10 , HavenoUtils .XMR_SMALLEST_UNIT_EXPONENT );
131
131
accumulatedAmount += amount ;
132
132
double priceAsDouble = (double ) price .getValue () / LongMath .pow (10 , price .smallestUnitExponent ());
133
- buyTM .put (mapPriceFeedServicePrice ( priceAsDouble , currencyCode ) , accumulatedAmount );
133
+ buyTM .put (priceAsDouble , accumulatedAmount );
134
134
}
135
135
};
136
136
137
- // Create buyer hashmap {key:price, value:count}, uses TreeMap to sort by key (asc)
137
+ // Create seller hashmap {key:price, value:count}, uses TreeMap to sort by key (asc)
138
138
accumulatedAmount = 0 ;
139
139
LinkedHashMap <Double ,Double > sellTM = new LinkedHashMap <Double ,Double >();
140
140
for (Offer offer : sellOffers ){
@@ -143,7 +143,7 @@ public MarketDepthInfo getMarketDepth(String currencyCode) throws ExecutionExcep
143
143
double amount = (double ) offer .getAmount ().longValueExact () / LongMath .pow (10 , HavenoUtils .XMR_SMALLEST_UNIT_EXPONENT );
144
144
accumulatedAmount += amount ;
145
145
double priceAsDouble = (double ) price .getValue () / LongMath .pow (10 , price .smallestUnitExponent ());
146
- sellTM .put (mapPriceFeedServicePrice ( priceAsDouble , currencyCode ) , accumulatedAmount );
146
+ sellTM .put (priceAsDouble , accumulatedAmount );
147
147
}
148
148
};
149
149
@@ -157,20 +157,5 @@ public MarketDepthInfo getMarketDepth(String currencyCode) throws ExecutionExcep
157
157
158
158
return new MarketDepthInfo (currencyCode , buyPrices , buyDepth , sellPrices , sellDepth );
159
159
}
160
-
161
- /**
162
- * PriceProvider returns different values for crypto and traditional,
163
- * e.g. 1 XMR = X USD
164
- * but 1 DOGE = X XMR
165
- * Here we convert all to:
166
- * 1 XMR = X (FIAT or CRYPTO)
167
- */
168
- private double mapPriceFeedServicePrice (double price , String currencyCode ) {
169
- if (CurrencyUtil .isTraditionalCurrency (currencyCode )) {
170
- return price ;
171
- }
172
- return price == 0 ? 0 : 1 / price ;
173
- // TODO PriceProvider.getAll() could provide these values directly when the original values are not needed for the 'desktop' UI anymore
174
- }
175
160
}
176
161
0 commit comments