@@ -6,12 +6,10 @@ export const actionTypeSchema = z.enum([
66 'transferToPerp' ,
77 'spotBuy' ,
88 'spotSell' ,
9- 'spotCancelOrder' ,
10- 'spotCancelAll' ,
119 'perpLong' ,
1210 'perpShort' ,
13- 'perpCancelOrder ' ,
14- 'perpCancelAll ' ,
11+ 'cancelOrder ' ,
12+ 'cancelAllOrdersForSymbol ' ,
1513] ) ;
1614
1715export const depositParamsSchema = z . object ( {
@@ -51,12 +49,12 @@ export const spotTradeParamsSchema = z.object({
5149 ) ,
5250} ) ;
5351
54- export const spotCancelOrderParamsSchema = z . object ( {
52+ export const cancelOrderParamsSchema = z . object ( {
5553 symbol : z . string ( ) . describe ( 'Trading pair symbol (e.g., "PURR/USDC")' ) ,
5654 orderId : z . number ( ) . describe ( 'Order ID to cancel' ) ,
5755} ) ;
5856
59- export const spotCancelAllParamsSchema = z . object ( {
57+ export const cancelAllOrdersForSymbolParamsSchema = z . object ( {
6058 symbol : z . string ( ) . describe ( 'Trading pair symbol to cancel all orders for (e.g., "PURR/USDC")' ) ,
6159} ) ;
6260
@@ -66,22 +64,19 @@ export const perpTradeParamsSchema = z.object({
6664 size : z . string ( ) . describe ( 'Order size in base asset' ) ,
6765 leverage : z . number ( ) . min ( 1 ) . max ( 50 ) . optional ( ) . describe ( 'Leverage multiplier (default: 2x)' ) ,
6866 isCross : z . boolean ( ) . optional ( ) . describe ( 'Cross leverage (default: true)' ) ,
67+ reduceOnly : z
68+ . boolean ( )
69+ . optional ( )
70+ . describe (
71+ 'Reduce-only: if true, order will only reduce existing position and cannot increase it (default: false). Use this to close positions without worrying about exact size.' ,
72+ ) ,
6973 orderType : orderTypeSchema
7074 . optional ( )
7175 . describe (
7276 'Order type: { type: "limit", tif: "Gtc" | "Ioc" | "Alo" } or { type: "market" }. Default: { type: "limit", tif: "Gtc" }' ,
7377 ) ,
7478} ) ;
7579
76- export const perpCancelOrderParamsSchema = z . object ( {
77- symbol : z . string ( ) . describe ( 'Perpetual symbol (e.g., "ETH")' ) ,
78- orderId : z . number ( ) . describe ( 'Order ID to cancel' ) ,
79- } ) ;
80-
81- export const perpCancelAllParamsSchema = z . object ( {
82- symbol : z . string ( ) . describe ( 'Perpetual symbol to cancel all orders for (e.g., "ETH")' ) ,
83- } ) ;
84-
8580export const abilityParamsSchema = z
8681 . object ( {
8782 action : actionTypeSchema . describe ( 'Action type to execute' ) ,
@@ -105,26 +100,18 @@ export const abilityParamsSchema = z
105100 spot : spotTradeParamsSchema
106101 . optional ( )
107102 . describe ( 'Spot trading parameters (required for spotBuy/spotSell)' ) ,
108- // Spot cancel order params
109- spotCancelOrder : spotCancelOrderParamsSchema
110- . optional ( )
111- . describe ( 'Cancel specific spot order (required for spotCancelOrder action)' ) ,
112- // Spot cancel all params
113- spotCancelAll : spotCancelAllParamsSchema
114- . optional ( )
115- . describe ( 'Cancel all spot orders for a symbol (required for spotCancelAll action)' ) ,
116103 // Perp trading params
117104 perp : perpTradeParamsSchema
118105 . optional ( )
119106 . describe ( 'Perpetual trading parameters (required for perpLong/perpShort)' ) ,
120- // Perp cancel order params
121- perpCancelOrder : perpCancelOrderParamsSchema
107+ // Cancel order params
108+ cancelOrder : cancelOrderParamsSchema
122109 . optional ( )
123- . describe ( 'Cancel specific perp order (required for perpCancelOrder action)' ) ,
124- // Perp cancel all params
125- perpCancelAll : perpCancelAllParamsSchema
110+ . describe ( 'Cancel specific order (required for cancelOrder action)' ) ,
111+ // Cancel all orders for symbol params
112+ cancelAllOrdersForSymbol : cancelAllOrdersForSymbolParamsSchema
126113 . optional ( )
127- . describe ( 'Cancel all perp orders for a symbol (required for perpCancelAll action)' ) ,
114+ . describe ( 'Cancel all orders for a symbol (required for cancelAllOrdersForSymbol action)' ) ,
128115 // Arbitrum RPC URL
129116 arbitrumRpcUrl : z . string ( ) . optional ( ) . describe ( 'Arbitrum RPC URL (required for precheck)' ) ,
130117 } )
@@ -134,11 +121,9 @@ export const abilityParamsSchema = z
134121 if ( data . action === 'transferToSpot' || data . action === 'transferToPerp' )
135122 return ! ! data . transfer ;
136123 if ( data . action === 'spotBuy' || data . action === 'spotSell' ) return ! ! data . spot ;
137- if ( data . action === 'spotCancelOrder' ) return ! ! data . spotCancelOrder ;
138- if ( data . action === 'spotCancelAll' ) return ! ! data . spotCancelAll ;
139124 if ( data . action === 'perpLong' || data . action === 'perpShort' ) return ! ! data . perp ;
140- if ( data . action === 'perpCancelOrder ' ) return ! ! data . perpCancelOrder ;
141- if ( data . action === 'perpCancelAll ' ) return ! ! data . perpCancelAll ;
125+ if ( data . action === 'cancelOrder ' ) return ! ! data . cancelOrder ;
126+ if ( data . action === 'cancelAllOrdersForSymbol ' ) return ! ! data . cancelAllOrdersForSymbol ;
142127 return false ;
143128 } ,
144129 {
@@ -182,6 +167,4 @@ export const executeSuccessSchema = z.object({
182167 . any ( )
183168 . optional ( )
184169 . describe ( 'Cancel result (for spotCancelOrder/spotCancelAll action)' ) ,
185- openOrders : z . array ( z . any ( ) ) . optional ( ) . describe ( 'Open orders after execution' ) ,
186- positions : z . any ( ) . optional ( ) . describe ( 'Positions after execution' ) ,
187170} ) ;
0 commit comments