@0xmonaco/react 0.0.0-develop-20260415185155 → 0.0.0-develop-20260420223958
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 +8 -1
- package/dist/hooks/useMarket/useMarket.js +53 -0
- 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/useTrade/types.d.ts +15 -1
- package/dist/hooks/useTrade/useTrade.js +20 -0
- package/package.json +3 -3
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Candlestick, GetCandlesticksParams, GetTradingPairsParams, GetTradingPairsResponse, Interval, MarketMetadata, TradingPair } from "@0xmonaco/types";
|
|
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
4
|
getPaginatedTradingPairs: (params?: GetTradingPairsParams) => Promise<GetTradingPairsResponse>;
|
|
@@ -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,5 +1,9 @@
|
|
|
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) => {
|
|
@@ -30,10 +34,59 @@ export const useMarket = () => {
|
|
|
30
34
|
throw new Error("Pair ID is required and cannot be empty");
|
|
31
35
|
return await sdk.market.getMarketMetadata(pairId);
|
|
32
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]);
|
|
33
79
|
return {
|
|
34
80
|
getPaginatedTradingPairs,
|
|
35
81
|
getTradingPairBySymbol,
|
|
36
82
|
getCandlesticks,
|
|
37
83
|
getMarketMetadata,
|
|
84
|
+
getPerpMarketConfig,
|
|
85
|
+
getPerpMarketSummary,
|
|
86
|
+
getMarkPrice,
|
|
87
|
+
getIndexPrice,
|
|
88
|
+
getFundingState,
|
|
89
|
+
listFundingHistory,
|
|
90
|
+
getOpenInterest,
|
|
38
91
|
};
|
|
39
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
|
+
};
|
|
@@ -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,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/react",
|
|
3
|
-
"version": "0.0.0-develop-
|
|
3
|
+
"version": "0.0.0-develop-20260420223958",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"lint": "biome lint ."
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@0xmonaco/core": "0.0.0-develop-
|
|
24
|
-
"@0xmonaco/types": "0.0.0-develop-
|
|
23
|
+
"@0xmonaco/core": "0.0.0-develop-20260420223958",
|
|
24
|
+
"@0xmonaco/types": "0.0.0-develop-20260420223958"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/react": "^19.1.12",
|