Skip to content

Commit

Permalink
Revert "[HotFix]: Feat fix trade pair orederbook (#233)" (#234)
Browse files Browse the repository at this point in the history
This reverts commit c72172f.
  • Loading branch information
Anton-rock authored Dec 20, 2024
1 parent c72172f commit 68d95f4
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/entity/SpotMarketOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { Token } from "./Token";

export type SpotMarketOrderParams = {
quoteAssetId: string;
baseAssetId: string;
} & Order;

export class SpotMarketOrder {
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 2 additions & 10 deletions src/screens/SpotScreen/BottomTables/SpotTable/SpotTableVM.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ class CreateOrderVM {
const formatOrder = (order: Order) =>
new SpotMarketOrder({
...order,
baseAssetId: market.baseToken.assetId,
quoteAssetId: market.quoteToken.assetId,
});

Expand Down
1 change: 0 additions & 1 deletion src/stores/SpotOrderBookStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ class SpotOrderBookStore {

const orders = formatSpotMarketOrders(
"ActiveBuyOrder" in data ? data.ActiveBuyOrder : data.ActiveSellOrder,
market!.baseToken.assetId,
market!.quoteToken.assetId,
);
updateOrders(orders);
Expand Down
1 change: 0 additions & 1 deletion src/stores/SwapStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ class SwapStore {
const formatOrder = (order: Order) =>
new SpotMarketOrder({
...order,
baseAssetId: baseToken.assetId,
quoteAssetId: quoteToken.assetId,
});

Expand Down
3 changes: 1 addition & 2 deletions src/utils/formatSpotMarketOrders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
);
Expand Down
1 change: 0 additions & 1 deletion src/utils/groupOrders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 68d95f4

Please sign in to comment.