1
1
import { useAccount , useOrderEntry , useSymbolsInfo , useWithdraw } from '@orderly.network/hooks' ;
2
- import { OrderlyOrder , OrderSide , OrderType } from '@orderly.network/types' ;
2
+ import { AlgoOrderRootType , OrderlyOrder , OrderSide , OrderType } from '@orderly.network/types' ;
3
3
import { Separator } from '@radix-ui/themes' ;
4
4
import { useNotifications } from '@web3-onboard/react' ;
5
5
import { FC , useCallback , useState } from 'react' ;
@@ -93,7 +93,7 @@ export const CreateOrder: FC<{
93
93
94
94
return (
95
95
< form
96
- className = "flex flex-1 flex-col gap-6 min-w-[16rem] max-w-[24rem]"
96
+ className = "flex flex-1 flex-col gap-4 min-w-[16rem] max-w-[24rem]"
97
97
onSubmit = { ( event ) => {
98
98
event . preventDefault ( ) ;
99
99
submitForm ( ) ;
@@ -130,20 +130,29 @@ export const CreateOrder: FC<{
130
130
< select
131
131
className = "flex flex-1 py-2 text-center font-bold"
132
132
onChange = { ( event ) => {
133
- setValue ( 'order_type' , event . target . value ) ;
133
+ if ( event . target . value === 'BRACKET_MARKET' ) {
134
+ setValue ( 'order_type' , OrderType . MARKET ) ;
135
+ setValue ( 'algo_type' , AlgoOrderRootType . BRACKET ) ;
136
+ } else {
137
+ setValue ( 'order_type' , event . target . value ) ;
138
+ setValue ( 'algo_type' , undefined ) ;
139
+ }
134
140
} }
135
141
>
136
142
< option value = "MARKET" > Market</ option >
137
143
< option value = "LIMIT" > Limit</ option >
138
144
< option value = "STOP_LIMIT" > Stop Limit</ option >
145
+ < option value = "BRACKET_MARKET" > Bracket Market</ option >
139
146
</ select >
140
147
141
148
< label
142
- className = { `flex-col ${ match ( formattedOrder . order_type )
143
- . with ( OrderType . STOP_LIMIT , ( ) => 'flex' )
144
- . otherwise ( ( ) => 'hidden' ) } `}
149
+ className = { `flex flex-col max-h-fit overflow-hidden transition-duration-300 transition-property-[all] transition-ease-out ${ match (
150
+ formattedOrder . order_type
151
+ )
152
+ . with ( OrderType . STOP_LIMIT , ( ) => 'h-[6rem] my-0' )
153
+ . otherwise ( ( ) => 'h-0 my--2' ) } `}
145
154
>
146
- < span className = "font-bold font-size-5 " > Trigger Price ({ quote } )</ span >
155
+ < span className = "font-bold font-size-4 " > Trigger Price ({ quote } )</ span >
147
156
< TokenInput
148
157
className = { `${ hasError ( 'trigger_price' ) ? 'border-[var(--color-red)]' : '' } ` }
149
158
decimals = { quoteDecimals }
@@ -157,8 +166,14 @@ export const CreateOrder: FC<{
157
166
{ renderFormError ( hasError ( 'trigger_price' ) ) }
158
167
</ label >
159
168
160
- < label className = "flex flex-col" >
161
- < span className = "font-bold font-size-5" > Price ({ quote } )</ span >
169
+ < label
170
+ className = { `flex flex-col max-h-fit overflow-hidden transition-duration-300 transition-property-[all] transition-ease-out ${ match (
171
+ formattedOrder . order_type
172
+ )
173
+ . with ( OrderType . MARKET , ( ) => 'h-0 my--2' )
174
+ . otherwise ( ( ) => 'h-[6rem] my-0' ) } `}
175
+ >
176
+ < span className = "font-bold font-size-4" > Price ({ quote } )</ span >
162
177
< TokenInput
163
178
className = { `${ hasError ( 'price' ) ? 'border-[var(--color-red)]' : '' } ` }
164
179
decimals = { quoteDecimals }
@@ -175,8 +190,50 @@ export const CreateOrder: FC<{
175
190
{ renderFormError ( hasError ( 'price' ) ) }
176
191
</ label >
177
192
193
+ < label
194
+ className = { `flex flex-col max-h-fit overflow-hidden transition-duration-300 transition-property-[all] transition-ease-out ${ match (
195
+ formattedOrder . algo_type
196
+ )
197
+ . with ( AlgoOrderRootType . BRACKET , ( ) => 'h-[6rem] my-0' )
198
+ . otherwise ( ( ) => 'h-0 my--2' ) } `}
199
+ >
200
+ < span className = "font-bold font-size-4" > Take Profit Price ({ quote } )</ span >
201
+ < TokenInput
202
+ className = { `${ hasError ( 'tp_trigger_price' ) ? 'border-[var(--color-red)]' : '' } ` }
203
+ decimals = { quoteDecimals }
204
+ placeholder = "Take Profit Price"
205
+ name = "tp_trigger_price"
206
+ hasError = { ! ! hasError ( 'tp_trigger_price' ) }
207
+ onValueChange = { ( value ) => {
208
+ setValue ( 'tp_trigger_price' , value . toString ( ) ) ;
209
+ } }
210
+ />
211
+ { renderFormError ( hasError ( 'tp_trigger_price' ) ) }
212
+ </ label >
213
+
214
+ < label
215
+ className = { `flex flex-col max-h-fit overflow-hidden transition-duration-300 transition-property-[all] transition-ease-out ${ match (
216
+ formattedOrder . algo_type
217
+ )
218
+ . with ( AlgoOrderRootType . BRACKET , ( ) => 'h-[6rem] my-0' )
219
+ . otherwise ( ( ) => 'h-0 my--2' ) } `}
220
+ >
221
+ < span className = "font-bold font-size-4" > Stop Loss Price ({ quote } )</ span >
222
+ < TokenInput
223
+ className = { `${ hasError ( 'sl_trigger_price' ) ? 'border-[var(--color-red)]' : '' } ` }
224
+ decimals = { quoteDecimals }
225
+ placeholder = "Stop Loss Price"
226
+ name = "sl_trigger_price"
227
+ hasError = { ! ! hasError ( 'sl_trigger_price' ) }
228
+ onValueChange = { ( value ) => {
229
+ setValue ( 'sl_trigger_price' , value . toString ( ) ) ;
230
+ } }
231
+ />
232
+ { renderFormError ( hasError ( 'sl_trigger_price' ) ) }
233
+ </ label >
234
+
178
235
< label className = "flex flex-col" >
179
- < span className = "font-bold font-size-5 " > Quantity ({ base } )</ span >
236
+ < span className = "font-bold font-size-4 " > Quantity ({ base } )</ span >
180
237
< TokenInput
181
238
className = { `${ hasError ( 'order_quantity' ) ? 'border-[var(--color-red)]' : '' } ` }
182
239
decimals = { baseDecimals }
@@ -212,7 +269,7 @@ export const CreateOrder: FC<{
212
269
< button
213
270
type = "submit"
214
271
disabled = { loading }
215
- className = { `relative py-2 font-size-5 bg-[var(--accent-9)] hover:bg-[var(--accent-10)] border-rd-1 border-0 ${ account . address == null ? 'hidden' : '' } ` }
272
+ className = { `relative py-2 font-size-4 bg-[var(--accent-9)] hover:bg-[var(--accent-10)] border-rd-1 border-0 ${ account . address == null ? 'hidden' : '' } ` }
216
273
>
217
274
{ loading && < Spinner overlay = { true } /> } Create Order
218
275
</ button >
0 commit comments