@0xmonaco/react 0.6.3 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useMarket/types.d.ts +9 -2
- package/dist/hooks/useMarket/useMarket.js +54 -5
- package/dist/hooks/usePositions/index.d.ts +2 -0
- package/dist/hooks/usePositions/index.js +1 -0
- package/dist/hooks/usePositions/types.d.ts +11 -0
- package/dist/hooks/usePositions/types.js +0 -0
- package/dist/hooks/usePositions/usePositions.d.ts +2 -0
- package/dist/hooks/usePositions/usePositions.js +65 -0
- package/dist/hooks/useProfile/useProfile.js +2 -2
- package/dist/hooks/useTrade/types.d.ts +15 -1
- package/dist/hooks/useTrade/useTrade.js +20 -0
- package/dist/hooks/useTradeFeed/useTradeFeed.js +1 -1
- package/dist/hooks/useUserMovements/useUserMovements.d.ts +1 -1
- package/dist/hooks/useUserMovements/useUserMovements.js +4 -4
- package/dist/hooks/useUserOrders/useUserOrders.js +3 -3
- package/package.json +1 -1
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Candlestick, GetCandlesticksParams, GetTradingPairsParams, Interval, MarketMetadata,
|
|
1
|
+
import type { Candlestick, FundingState, GetCandlesticksParams, GetTradingPairsParams, GetTradingPairsResponse, IndexPrice, Interval, ListFundingHistoryParams, ListFundingHistoryResponse, MarketMetadata, MarkPrice, OpenInterest, PerpMarketConfig, PerpMarketSummary, TradingPair } from "@0xmonaco/types";
|
|
2
2
|
export interface UseMarketReturn {
|
|
3
3
|
/** Get all available trading pairs with optional filtering and pagination */
|
|
4
|
-
getPaginatedTradingPairs: (params?: GetTradingPairsParams) => Promise<
|
|
4
|
+
getPaginatedTradingPairs: (params?: GetTradingPairsParams) => Promise<GetTradingPairsResponse>;
|
|
5
5
|
/** Get a specific trading pair by symbol */
|
|
6
6
|
getTradingPairBySymbol: (symbol: string) => Promise<TradingPair | undefined>;
|
|
7
7
|
/**
|
|
@@ -20,4 +20,11 @@ export interface UseMarketReturn {
|
|
|
20
20
|
getCandlesticks: (tradingPairId: string, interval: Interval, params?: GetCandlesticksParams) => Promise<Candlestick[]>;
|
|
21
21
|
/** Get comprehensive market metadata including 24h statistics */
|
|
22
22
|
getMarketMetadata: (pairId: string) => Promise<MarketMetadata>;
|
|
23
|
+
getPerpMarketConfig: (tradingPairId: string) => Promise<PerpMarketConfig>;
|
|
24
|
+
getPerpMarketSummary: (tradingPairId: string) => Promise<PerpMarketSummary>;
|
|
25
|
+
getMarkPrice: (tradingPairId: string) => Promise<MarkPrice>;
|
|
26
|
+
getIndexPrice: (tradingPairId: string) => Promise<IndexPrice>;
|
|
27
|
+
getFundingState: (tradingPairId: string) => Promise<FundingState>;
|
|
28
|
+
listFundingHistory: (tradingPairId: string, params?: ListFundingHistoryParams) => Promise<ListFundingHistoryResponse>;
|
|
29
|
+
getOpenInterest: (tradingPairId: string) => Promise<OpenInterest>;
|
|
23
30
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
2
|
import { useMonacoSDK } from "../useMonaco";
|
|
3
|
+
function requireTradingPairId(tradingPairId) {
|
|
4
|
+
if (!tradingPairId?.trim())
|
|
5
|
+
throw new Error("Trading pair ID is required and cannot be empty");
|
|
6
|
+
}
|
|
3
7
|
export const useMarket = () => {
|
|
4
8
|
const { sdk } = useMonacoSDK();
|
|
5
9
|
const getPaginatedTradingPairs = useCallback(async (params) => {
|
|
6
10
|
if (!sdk)
|
|
7
11
|
throw new Error("SDK not available");
|
|
8
|
-
|
|
9
|
-
if (!response.success) {
|
|
10
|
-
throw new Error("Failed to fetch trading pairs");
|
|
11
|
-
}
|
|
12
|
-
return response.data;
|
|
12
|
+
return await sdk.market.getPaginatedTradingPairs(params);
|
|
13
13
|
}, [sdk]);
|
|
14
14
|
const getTradingPairBySymbol = useCallback(async (symbol) => {
|
|
15
15
|
if (!sdk)
|
|
@@ -34,10 +34,59 @@ export const useMarket = () => {
|
|
|
34
34
|
throw new Error("Pair ID is required and cannot be empty");
|
|
35
35
|
return await sdk.market.getMarketMetadata(pairId);
|
|
36
36
|
}, [sdk]);
|
|
37
|
+
const getPerpMarketConfig = useCallback(async (tradingPairId) => {
|
|
38
|
+
if (!sdk)
|
|
39
|
+
throw new Error("SDK not available");
|
|
40
|
+
requireTradingPairId(tradingPairId);
|
|
41
|
+
return await sdk.market.getPerpMarketConfig(tradingPairId);
|
|
42
|
+
}, [sdk]);
|
|
43
|
+
const getPerpMarketSummary = useCallback(async (tradingPairId) => {
|
|
44
|
+
if (!sdk)
|
|
45
|
+
throw new Error("SDK not available");
|
|
46
|
+
requireTradingPairId(tradingPairId);
|
|
47
|
+
return await sdk.market.getPerpMarketSummary(tradingPairId);
|
|
48
|
+
}, [sdk]);
|
|
49
|
+
const getMarkPrice = useCallback(async (tradingPairId) => {
|
|
50
|
+
if (!sdk)
|
|
51
|
+
throw new Error("SDK not available");
|
|
52
|
+
requireTradingPairId(tradingPairId);
|
|
53
|
+
return await sdk.market.getMarkPrice(tradingPairId);
|
|
54
|
+
}, [sdk]);
|
|
55
|
+
const getIndexPrice = useCallback(async (tradingPairId) => {
|
|
56
|
+
if (!sdk)
|
|
57
|
+
throw new Error("SDK not available");
|
|
58
|
+
requireTradingPairId(tradingPairId);
|
|
59
|
+
return await sdk.market.getIndexPrice(tradingPairId);
|
|
60
|
+
}, [sdk]);
|
|
61
|
+
const getFundingState = useCallback(async (tradingPairId) => {
|
|
62
|
+
if (!sdk)
|
|
63
|
+
throw new Error("SDK not available");
|
|
64
|
+
requireTradingPairId(tradingPairId);
|
|
65
|
+
return await sdk.market.getFundingState(tradingPairId);
|
|
66
|
+
}, [sdk]);
|
|
67
|
+
const listFundingHistory = useCallback(async (tradingPairId, params) => {
|
|
68
|
+
if (!sdk)
|
|
69
|
+
throw new Error("SDK not available");
|
|
70
|
+
requireTradingPairId(tradingPairId);
|
|
71
|
+
return await sdk.market.listFundingHistory(tradingPairId, params);
|
|
72
|
+
}, [sdk]);
|
|
73
|
+
const getOpenInterest = useCallback(async (tradingPairId) => {
|
|
74
|
+
if (!sdk)
|
|
75
|
+
throw new Error("SDK not available");
|
|
76
|
+
requireTradingPairId(tradingPairId);
|
|
77
|
+
return await sdk.market.getOpenInterest(tradingPairId);
|
|
78
|
+
}, [sdk]);
|
|
37
79
|
return {
|
|
38
80
|
getPaginatedTradingPairs,
|
|
39
81
|
getTradingPairBySymbol,
|
|
40
82
|
getCandlesticks,
|
|
41
83
|
getMarketMetadata,
|
|
84
|
+
getPerpMarketConfig,
|
|
85
|
+
getPerpMarketSummary,
|
|
86
|
+
getMarkPrice,
|
|
87
|
+
getIndexPrice,
|
|
88
|
+
getFundingState,
|
|
89
|
+
listFundingHistory,
|
|
90
|
+
getOpenInterest,
|
|
42
91
|
};
|
|
43
92
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { usePositions } from "./usePositions";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AddPositionMarginRequest, AttachPositionTpSlRequest, AttachPositionTpSlResponse, ClosePositionRequest, ClosePositionResponse, GetPositionResponse, ListPositionHistoryParams, ListPositionHistoryResponse, ListPositionsParams, ListPositionsResponse, PositionMarginResponse, PositionRisk, ReducePositionMarginRequest } from "@0xmonaco/types";
|
|
2
|
+
export interface UsePositionsReturn {
|
|
3
|
+
listPositions: (params?: ListPositionsParams) => Promise<ListPositionsResponse>;
|
|
4
|
+
getPosition: (positionId: string) => Promise<GetPositionResponse>;
|
|
5
|
+
closePosition: (positionId: string, request: ClosePositionRequest) => Promise<ClosePositionResponse>;
|
|
6
|
+
getPositionRisk: (positionId: string) => Promise<PositionRisk>;
|
|
7
|
+
addPositionMargin: (positionId: string, request: AddPositionMarginRequest) => Promise<PositionMarginResponse>;
|
|
8
|
+
reducePositionMargin: (positionId: string, request: ReducePositionMarginRequest) => Promise<PositionMarginResponse>;
|
|
9
|
+
attachPositionTpSl: (positionId: string, request: AttachPositionTpSlRequest) => Promise<AttachPositionTpSlResponse>;
|
|
10
|
+
listPositionHistory: (params?: ListPositionHistoryParams) => Promise<ListPositionHistoryResponse>;
|
|
11
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useMonacoSDK } from "../useMonaco";
|
|
3
|
+
function requirePositionId(positionId) {
|
|
4
|
+
if (!positionId?.trim())
|
|
5
|
+
throw new Error("Position ID is required and cannot be empty");
|
|
6
|
+
}
|
|
7
|
+
export const usePositions = () => {
|
|
8
|
+
const { sdk } = useMonacoSDK();
|
|
9
|
+
const listPositions = useCallback(async (params) => {
|
|
10
|
+
if (!sdk)
|
|
11
|
+
throw new Error("SDK not available");
|
|
12
|
+
return await sdk.positions.listPositions(params);
|
|
13
|
+
}, [sdk]);
|
|
14
|
+
const getPosition = useCallback(async (positionId) => {
|
|
15
|
+
if (!sdk)
|
|
16
|
+
throw new Error("SDK not available");
|
|
17
|
+
requirePositionId(positionId);
|
|
18
|
+
return await sdk.positions.getPosition(positionId);
|
|
19
|
+
}, [sdk]);
|
|
20
|
+
const closePosition = useCallback(async (positionId, request) => {
|
|
21
|
+
if (!sdk)
|
|
22
|
+
throw new Error("SDK not available");
|
|
23
|
+
requirePositionId(positionId);
|
|
24
|
+
return await sdk.positions.closePosition(positionId, request);
|
|
25
|
+
}, [sdk]);
|
|
26
|
+
const getPositionRisk = useCallback(async (positionId) => {
|
|
27
|
+
if (!sdk)
|
|
28
|
+
throw new Error("SDK not available");
|
|
29
|
+
requirePositionId(positionId);
|
|
30
|
+
return await sdk.positions.getPositionRisk(positionId);
|
|
31
|
+
}, [sdk]);
|
|
32
|
+
const addPositionMargin = useCallback(async (positionId, request) => {
|
|
33
|
+
if (!sdk)
|
|
34
|
+
throw new Error("SDK not available");
|
|
35
|
+
requirePositionId(positionId);
|
|
36
|
+
return await sdk.positions.addPositionMargin(positionId, request);
|
|
37
|
+
}, [sdk]);
|
|
38
|
+
const reducePositionMargin = useCallback(async (positionId, request) => {
|
|
39
|
+
if (!sdk)
|
|
40
|
+
throw new Error("SDK not available");
|
|
41
|
+
requirePositionId(positionId);
|
|
42
|
+
return await sdk.positions.reducePositionMargin(positionId, request);
|
|
43
|
+
}, [sdk]);
|
|
44
|
+
const attachPositionTpSl = useCallback(async (positionId, request) => {
|
|
45
|
+
if (!sdk)
|
|
46
|
+
throw new Error("SDK not available");
|
|
47
|
+
requirePositionId(positionId);
|
|
48
|
+
return await sdk.positions.attachPositionTpSl(positionId, request);
|
|
49
|
+
}, [sdk]);
|
|
50
|
+
const listPositionHistory = useCallback(async (params) => {
|
|
51
|
+
if (!sdk)
|
|
52
|
+
throw new Error("SDK not available");
|
|
53
|
+
return await sdk.positions.listPositionHistory(params);
|
|
54
|
+
}, [sdk]);
|
|
55
|
+
return {
|
|
56
|
+
listPositions,
|
|
57
|
+
getPosition,
|
|
58
|
+
closePosition,
|
|
59
|
+
getPositionRisk,
|
|
60
|
+
addPositionMargin,
|
|
61
|
+
reducePositionMargin,
|
|
62
|
+
attachPositionTpSl,
|
|
63
|
+
listPositionHistory,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -51,8 +51,8 @@ export const useProfile = () => {
|
|
|
51
51
|
try {
|
|
52
52
|
const [userProfileResult, balancesResult, movementsResult, ordersResult] = await Promise.allSettled([
|
|
53
53
|
sdk.profile.getProfile(),
|
|
54
|
-
sdk.profile.getUserBalances({
|
|
55
|
-
sdk.profile.getPaginatedUserMovements({ page: 1,
|
|
54
|
+
sdk.profile.getUserBalances({ page_size: DEFAULT_PAGE_SIZE, page: 1 }),
|
|
55
|
+
sdk.profile.getPaginatedUserMovements({ page: 1, page_size: DEFAULT_PAGE_SIZE }),
|
|
56
56
|
sdk.trading.getPaginatedOrders({ page: 1, page_size: DEFAULT_PAGE_SIZE }),
|
|
57
57
|
]);
|
|
58
58
|
const userProfile = getSettledValueOrThrow(userProfileResult);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, OrderSide, ReplaceOrderResponse, TimeInForce, TradingMode } from "@0xmonaco/types";
|
|
1
|
+
import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CreateConditionalOrderParams, CreateConditionalOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, OrderSide, PositionSide, ReplaceOrderResponse, TimeInForce, TradingMode } from "@0xmonaco/types";
|
|
2
2
|
export interface UseTradeReturn {
|
|
3
3
|
/** Place a limit order */
|
|
4
4
|
placeLimitOrder: (tradingPairId: string, side: OrderSide, quantity: string, price: string, options?: {
|
|
@@ -6,14 +6,28 @@ export interface UseTradeReturn {
|
|
|
6
6
|
useMasterBalance?: boolean;
|
|
7
7
|
expirationDate?: string;
|
|
8
8
|
timeInForce?: TimeInForce;
|
|
9
|
+
marginAccountId?: string;
|
|
10
|
+
positionSide?: PositionSide;
|
|
11
|
+
leverage?: string;
|
|
12
|
+
reduceOnly?: boolean;
|
|
9
13
|
}) => Promise<CreateOrderResponse>;
|
|
10
14
|
/** Place a market order */
|
|
11
15
|
placeMarketOrder: (tradingPairId: string, side: OrderSide, quantity: string, options?: {
|
|
12
16
|
tradingMode?: TradingMode;
|
|
13
17
|
slippageTolerance?: number;
|
|
18
|
+
marginAccountId?: string;
|
|
19
|
+
positionSide?: PositionSide;
|
|
20
|
+
leverage?: string;
|
|
21
|
+
reduceOnly?: boolean;
|
|
14
22
|
}) => Promise<CreateOrderResponse>;
|
|
15
23
|
/** Cancel an existing order */
|
|
16
24
|
cancelOrder: (orderId: string) => Promise<CancelOrderResponse>;
|
|
25
|
+
/** Create a standalone conditional TP/SL order */
|
|
26
|
+
createConditionalOrder: (params: CreateConditionalOrderParams) => Promise<CreateConditionalOrderResponse>;
|
|
27
|
+
/** Cancel an active conditional TP/SL order */
|
|
28
|
+
cancelConditionalOrder: (conditionalOrderId: string) => Promise<CancelConditionalOrderResponse>;
|
|
29
|
+
/** List conditional TP/SL orders */
|
|
30
|
+
listConditionalOrders: (params?: ListConditionalOrdersParams) => Promise<ListConditionalOrdersResponse>;
|
|
17
31
|
/** Batch cancel specific orders by their IDs */
|
|
18
32
|
batchCancel: (orderIds: string[]) => Promise<BatchCancelOrdersResponse>;
|
|
19
33
|
/** Cancel all active orders, optionally filtered by trading pair */
|
|
@@ -39,6 +39,23 @@ export const useTrade = () => {
|
|
|
39
39
|
throw new Error("Order ID is required and cannot be empty");
|
|
40
40
|
return await sdk.trading.cancelOrder(orderId);
|
|
41
41
|
}, [sdk]);
|
|
42
|
+
const createConditionalOrder = useCallback(async (params) => {
|
|
43
|
+
if (!sdk)
|
|
44
|
+
throw new Error("SDK not available");
|
|
45
|
+
return await sdk.trading.createConditionalOrder(params);
|
|
46
|
+
}, [sdk]);
|
|
47
|
+
const cancelConditionalOrder = useCallback(async (conditionalOrderId) => {
|
|
48
|
+
if (!sdk)
|
|
49
|
+
throw new Error("SDK not available");
|
|
50
|
+
if (!conditionalOrderId?.trim())
|
|
51
|
+
throw new Error("Conditional order ID is required and cannot be empty");
|
|
52
|
+
return await sdk.trading.cancelConditionalOrder(conditionalOrderId);
|
|
53
|
+
}, [sdk]);
|
|
54
|
+
const listConditionalOrders = useCallback(async (params) => {
|
|
55
|
+
if (!sdk)
|
|
56
|
+
throw new Error("SDK not available");
|
|
57
|
+
return await sdk.trading.listConditionalOrders(params);
|
|
58
|
+
}, [sdk]);
|
|
42
59
|
const batchCancel = useCallback(async (orderIds) => {
|
|
43
60
|
if (!sdk)
|
|
44
61
|
throw new Error("SDK not available");
|
|
@@ -100,6 +117,9 @@ export const useTrade = () => {
|
|
|
100
117
|
placeMarketOrder,
|
|
101
118
|
// Order management
|
|
102
119
|
cancelOrder,
|
|
120
|
+
createConditionalOrder,
|
|
121
|
+
cancelConditionalOrder,
|
|
122
|
+
listConditionalOrders,
|
|
103
123
|
batchCancel,
|
|
104
124
|
batchCancelAll,
|
|
105
125
|
replaceOrder,
|
|
@@ -19,7 +19,7 @@ export function useTradeFeed(tradingPairId) {
|
|
|
19
19
|
if (!sdk?.ws || !sdk?.trades || !tradingPairId) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
const fetchInitialTrades = () => sdk.trades.getTrades(tradingPairId, {
|
|
22
|
+
const fetchInitialTrades = () => sdk.trades.getTrades(tradingPairId, { page_size: MAX_TRADES });
|
|
23
23
|
const subscribeToWs = (handler) => sdk.ws.trades(tradingPairId, handler);
|
|
24
24
|
return subscribe(tradingPairId, fetchInitialTrades, subscribeToWs);
|
|
25
25
|
}, [sdk?.ws, sdk?.trades, tradingPairId, subscribe]);
|
|
@@ -10,7 +10,7 @@ import type { UseUserMovementsOptions, UseUserMovementsReturn } from "./types";
|
|
|
10
10
|
*
|
|
11
11
|
* @param options - Optional filter and pagination options
|
|
12
12
|
* @param options.maxMovements - Maximum number of movements to keep in state (default: 50)
|
|
13
|
-
* @param options.
|
|
13
|
+
* @param options.page_size - Number of items per page for the API call (default: maxMovements)
|
|
14
14
|
* @param options.entry_type - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
|
|
15
15
|
* @param options.transaction_type - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, etc.)
|
|
16
16
|
* @param options.asset_id - Filter by asset ID (UUID)
|
|
@@ -44,7 +44,7 @@ function ledgerMovementToEvent(movement, userId) {
|
|
|
44
44
|
*
|
|
45
45
|
* @param options - Optional filter and pagination options
|
|
46
46
|
* @param options.maxMovements - Maximum number of movements to keep in state (default: 50)
|
|
47
|
-
* @param options.
|
|
47
|
+
* @param options.page_size - Number of items per page for the API call (default: maxMovements)
|
|
48
48
|
* @param options.entry_type - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
|
|
49
49
|
* @param options.transaction_type - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, etc.)
|
|
50
50
|
* @param options.asset_id - Filter by asset ID (UUID)
|
|
@@ -52,14 +52,14 @@ function ledgerMovementToEvent(movement, userId) {
|
|
|
52
52
|
export function useUserMovements(options = {}) {
|
|
53
53
|
const { sdk } = useMonacoSDK();
|
|
54
54
|
const { authenticationStatus } = useMonacoContext();
|
|
55
|
-
const { maxMovements = 50,
|
|
55
|
+
const { maxMovements = 50, page_size, entry_type, transaction_type, asset_id } = options;
|
|
56
56
|
const [movements, setMovements] = useState([]);
|
|
57
57
|
const [loading, setLoading] = useState(false);
|
|
58
58
|
const [error, setError] = useState(null);
|
|
59
59
|
const [subscribed, setSubscribed] = useState(false);
|
|
60
60
|
const clearError = useCallback(() => setError(null), []);
|
|
61
61
|
const sliceSize = Number.isFinite(maxMovements) && maxMovements > 0 ? maxMovements : 50;
|
|
62
|
-
const requestLimit =
|
|
62
|
+
const requestLimit = page_size ?? Math.min(Math.max(Math.round(sliceSize), 1), 100);
|
|
63
63
|
// Derive userId reactively — authenticationStatus changes on login/logout, triggering a re-render
|
|
64
64
|
const userId = authenticationStatus === "authenticated" ? sdk?.getAuthState()?.user.id : undefined;
|
|
65
65
|
useEffect(() => {
|
|
@@ -73,7 +73,7 @@ export function useUserMovements(options = {}) {
|
|
|
73
73
|
// Fetch initial movements via REST API, then subscribe to WebSocket updates
|
|
74
74
|
let unsubscribe;
|
|
75
75
|
sdk.profile
|
|
76
|
-
.getPaginatedUserMovements({
|
|
76
|
+
.getPaginatedUserMovements({ page_size: requestLimit, entry_type, transaction_type, asset_id })
|
|
77
77
|
.then(async (response) => {
|
|
78
78
|
// Combine latest_movements (from Redis) with movements (from PostgreSQL)
|
|
79
79
|
// latest_movements contains real-time data that may not yet be in PostgreSQL
|
|
@@ -118,12 +118,12 @@ function orderFromEvent(event) {
|
|
|
118
118
|
if (event.eventType !== "OrderPlaced")
|
|
119
119
|
return null;
|
|
120
120
|
const { data } = event;
|
|
121
|
-
const
|
|
122
|
-
if (!
|
|
121
|
+
const tradingPairId = data.tradingPairId || data.symbol;
|
|
122
|
+
if (!tradingPairId)
|
|
123
123
|
return null;
|
|
124
124
|
return {
|
|
125
125
|
id: event.orderId,
|
|
126
|
-
|
|
126
|
+
trading_pair_id: tradingPairId,
|
|
127
127
|
order_type: (data.orderType || "LIMIT"),
|
|
128
128
|
side: (data.side || "BUY"),
|
|
129
129
|
price: data.price,
|