From 68d95f49ca3a60241f7359615052cebe01c4885e Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 20 Dec 2024 12:06:55 +0300 Subject: [PATCH] Revert "[HotFix]: Feat fix trade pair orederbook (#233)" (#234) This reverts commit c72172f076a055e954f3566c5eddf54f9fcfb782. --- src/entity/SpotMarketOrder.ts | 3 +-- .../BottomTables/SpotTable/SpotTableVM.tsx | 12 ++---------- .../RightBlock/CreateOrder/CreateOrderVM.tsx | 1 - src/stores/SpotOrderBookStore.ts | 1 - src/stores/SwapStore.ts | 1 - src/utils/formatSpotMarketOrders.ts | 3 +-- src/utils/groupOrders.ts | 1 - 7 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/entity/SpotMarketOrder.ts b/src/entity/SpotMarketOrder.ts index 13de1278..cd7ac9af 100644 --- a/src/entity/SpotMarketOrder.ts +++ b/src/entity/SpotMarketOrder.ts @@ -11,7 +11,6 @@ import { Token } from "./Token"; export type SpotMarketOrderParams = { quoteAssetId: string; - baseAssetId: string; } & Order; export class SpotMarketOrder { @@ -43,7 +42,7 @@ export class SpotMarketOrder { this.user = order.user; this.status = order.status; - this.baseToken = bcNetwork.getTokenByAssetId(order.baseAssetId); + this.baseToken = bcNetwork.getTokenByAssetId(order.asset); this.quoteToken = bcNetwork.getTokenByAssetId(order.quoteAssetId); this.orderType = order.orderType; diff --git a/src/screens/SpotScreen/BottomTables/SpotTable/SpotTableVM.tsx b/src/screens/SpotScreen/BottomTables/SpotTable/SpotTableVM.tsx index bee66f5b..a9519bf7 100644 --- a/src/screens/SpotScreen/BottomTables/SpotTable/SpotTableVM.tsx +++ b/src/screens/SpotScreen/BottomTables/SpotTable/SpotTableVM.tsx @@ -174,11 +174,7 @@ class SpotTableVM { next: ({ data }) => { if (!data) return; - const sortedOrder = formatSpotMarketOrders( - data.Order, - market.baseToken.assetId, - market.quoteToken.assetId, - ).sort(sortDesc); + const sortedOrder = formatSpotMarketOrders(data.Order, market.quoteToken.assetId).sort(sortDesc); this.setUserOrders(sortedOrder); if (!this.isOpenOrdersLoaded) { @@ -205,11 +201,7 @@ class SpotTableVM { next: ({ data }) => { if (!data) return; - const sortedOrdersHistory = formatSpotMarketOrders( - data.Order, - market.baseToken.assetId, - market.quoteToken.assetId, - ).sort(sortDesc); + const sortedOrdersHistory = formatSpotMarketOrders(data.Order, market.quoteToken.assetId).sort(sortDesc); this.setUserOrdersHistory(sortedOrdersHistory); if (!this.isHistoryOrdersLoaded) { diff --git a/src/screens/SpotScreen/RightBlock/CreateOrder/CreateOrderVM.tsx b/src/screens/SpotScreen/RightBlock/CreateOrder/CreateOrderVM.tsx index c4271e6d..c1901226 100644 --- a/src/screens/SpotScreen/RightBlock/CreateOrder/CreateOrderVM.tsx +++ b/src/screens/SpotScreen/RightBlock/CreateOrder/CreateOrderVM.tsx @@ -404,7 +404,6 @@ class CreateOrderVM { const formatOrder = (order: Order) => new SpotMarketOrder({ ...order, - baseAssetId: market.baseToken.assetId, quoteAssetId: market.quoteToken.assetId, }); diff --git a/src/stores/SpotOrderBookStore.ts b/src/stores/SpotOrderBookStore.ts index c11aae83..cb9c7dd5 100644 --- a/src/stores/SpotOrderBookStore.ts +++ b/src/stores/SpotOrderBookStore.ts @@ -149,7 +149,6 @@ class SpotOrderBookStore { const orders = formatSpotMarketOrders( "ActiveBuyOrder" in data ? data.ActiveBuyOrder : data.ActiveSellOrder, - market!.baseToken.assetId, market!.quoteToken.assetId, ); updateOrders(orders); diff --git a/src/stores/SwapStore.ts b/src/stores/SwapStore.ts index 389bd250..da160960 100644 --- a/src/stores/SwapStore.ts +++ b/src/stores/SwapStore.ts @@ -143,7 +143,6 @@ class SwapStore { const formatOrder = (order: Order) => new SpotMarketOrder({ ...order, - baseAssetId: baseToken.assetId, quoteAssetId: quoteToken.assetId, }); diff --git a/src/utils/formatSpotMarketOrders.ts b/src/utils/formatSpotMarketOrders.ts index c9ca2c64..7a10fbba 100644 --- a/src/utils/formatSpotMarketOrders.ts +++ b/src/utils/formatSpotMarketOrders.ts @@ -2,12 +2,11 @@ import { Order } from "@compolabs/spark-orderbook-ts-sdk"; import { SpotMarketOrder } from "@entity"; -export const formatSpotMarketOrders = (orders: Order[], baseAssetId: string, quoteAssetId: string) => { +export const formatSpotMarketOrders = (orders: Order[], quoteAssetId: string) => { return orders.map( (order) => new SpotMarketOrder({ ...order, - baseAssetId, quoteAssetId, }), ); diff --git a/src/utils/groupOrders.ts b/src/utils/groupOrders.ts index 0790d16e..9184fbb6 100644 --- a/src/utils/groupOrders.ts +++ b/src/utils/groupOrders.ts @@ -25,7 +25,6 @@ export const groupOrders = (orders: SpotMarketOrder[], decimals: number): SpotMa initialAmount: BN.ZERO.toString(), orderType: order.orderType, asset: order.baseToken.assetId, - baseAssetId: order.baseToken.assetId, quoteAssetId: order.quoteToken.assetId, timestamp: order.timestamp.toString(), market: order.market,