diff --git a/spark-frontend/src/screens/TradeScreen/OrderbookAndTradesInterface/SpotOrderBook/SpotOrderBookImpl.tsx b/spark-frontend/src/screens/TradeScreen/OrderbookAndTradesInterface/SpotOrderBook/SpotOrderBookImpl.tsx index c2d12b18..5cbf05cc 100644 --- a/spark-frontend/src/screens/TradeScreen/OrderbookAndTradesInterface/SpotOrderBook/SpotOrderBookImpl.tsx +++ b/spark-frontend/src/screens/TradeScreen/OrderbookAndTradesInterface/SpotOrderBook/SpotOrderBookImpl.tsx @@ -94,7 +94,7 @@ const SpotOrderBookImpl: React.FC = observer(() => { }; const renderOrders = (orders: SpotMarketOrder[], type: "sell" | "buy") => { - const orderMode = type === "sell" ? ORDER_MODE.BUY : ORDER_MODE.SELL; + const orderMode = type === "buy" ? ORDER_MODE.BUY : ORDER_MODE.SELL; const volumePercent = (ord: SpotMarketOrder) => type === "sell" ? ord.baseSize.div(vm.totalSell) : ord.quoteSize.div(vm.totalBuy); const color = type === "sell" ? theme.colors.redLight : theme.colors.greenLight; diff --git a/spark-frontend/src/screens/TradeScreen/OrderbookAndTradesInterface/SpotOrderBook/SpotOrderbookVM.tsx b/spark-frontend/src/screens/TradeScreen/OrderbookAndTradesInterface/SpotOrderBook/SpotOrderbookVM.tsx index ceb9886f..e3c47604 100644 --- a/spark-frontend/src/screens/TradeScreen/OrderbookAndTradesInterface/SpotOrderBook/SpotOrderbookVM.tsx +++ b/spark-frontend/src/screens/TradeScreen/OrderbookAndTradesInterface/SpotOrderBook/SpotOrderbookVM.tsx @@ -76,7 +76,7 @@ class SpotOrderbookVM { if (a.price === null && b.price === null) return 0; if (a.price === null && b.price !== null) return 1; if (a.price === null && b.price === null) return -1; - return a.price < b.price ? 1 : -1; + return a.price.lt(b.price) ? 1 : -1; }) .reverse() .slice(this.orderFilter === 0 ? -this.oneSizeOrders : -this.amountOfOrders) @@ -90,7 +90,7 @@ class SpotOrderbookVM { if (a.price === null && b.price === null) return 0; if (a.price === null && b.price !== null) return 1; if (a.price === null && b.price === null) return -1; - return a.price < b.price ? 1 : -1; + return a.price.lt(b.price) ? 1 : -1; }) .slice(this.orderFilter === 0 ? -this.oneSizeOrders : -this.amountOfOrders); } @@ -124,12 +124,12 @@ class SpotOrderbookVM { fetchOrders({ baseToken: market.baseToken.assetId, type: "SELL", limit: 20 }), ]); - //bid + //bid = max of buy const maxBuyPriceOrder = buy.reduce((max: Nullable, current) => { - return max === null || current.price > max.price ? current : max; + return current.price.gt(max?.price ?? 0) ? current : max; }, null); - //ask + //ask = min of sell const minSellPriceOrder = sell.reduce((min: Nullable, current) => { return min === null || current.price < min.price ? current : min; }, null); @@ -147,7 +147,7 @@ class SpotOrderbookVM { return; } - this.setOrderbook({ buy, sell, spreadPercent: "0.00", spreadPrice: "" }); + this.setOrderbook({ buy, sell, spreadPercent: "0.00", spreadPrice: "0.00" }); }; private setOrderbook = (orderbook: TOrderbookData) => (this.orderbook = orderbook);