@@ -219,6 +219,11 @@ export const runWizard = async () => {
219219 timeWindowMs : 60_000 ,
220220 } ;
221221
222+ let expectedProfitBasedStopLoss = {
223+ enabled : false ,
224+ percent : 0 ,
225+ }
226+
222227 if ( experienceLevel !== "beginner" ) {
223228 features = await multiselect ( {
224229 message : "What features do you want to setup? [spacebar] to select" ,
@@ -228,7 +233,8 @@ export const runWizard = async () => {
228233 { value : "executionRateLimiter" , label : "Execution rate limiter" } ,
229234 { value : "iterationsRateLimiter" , label : "Iterations rate" } ,
230235 { value : "aggregatorErrorsRateLimiter" , label : "Aggregator errors rate limiter" } ,
231- { value : "autoReset" , label : "Auto reset" } ,
236+ { value : "autoReset" , label : "Auto reset" , hint : "experimental" } ,
237+ { value : "expectedProfitBasedStopLoss" , label : "Stop Loss" , hint : "experimental" } ,
232238 ] ,
233239 required : false ,
234240 } ) ;
@@ -451,6 +457,32 @@ export const runWizard = async () => {
451457 } ;
452458 }
453459 }
460+
461+ if ( features . includes ( "expectedProfitBasedStopLoss" ) ) {
462+ const expectedProfitBasedStopLossPercent = await text ( {
463+ message :
464+ "What is the expected profit based stop loss percent?\n· If expected profit reaches this percent then swap back to the initial token & reset.\n· The provided number will always be negative (e.g. 0.5 = -0.5)" ,
465+ initialValue : "0" ,
466+ validate : ( value ) => {
467+ if ( value . length === 0 ) return "Please enter a expected profit based stop loss percent" ;
468+ const expectedProfitBasedStopLossPercent = Math . abs ( parseFloat ( value ) ) ;
469+ if ( isNaN ( expectedProfitBasedStopLossPercent ) ) return "Please enter a valid number" ;
470+ if ( expectedProfitBasedStopLossPercent === 0 ) return "Please enter a non-zero number" ;
471+ } ,
472+ } ) ;
473+
474+ if ( isCancel ( expectedProfitBasedStopLossPercent ) ) {
475+ cancel ( "Operation cancelled" ) ;
476+ return process . exit ( 0 ) ;
477+ }
478+
479+ if ( typeof expectedProfitBasedStopLossPercent === "string" ) {
480+ expectedProfitBasedStopLoss = {
481+ enabled : true ,
482+ percent : Math . abs ( parseFloat ( expectedProfitBasedStopLossPercent ) ) ,
483+ } ;
484+ }
485+ }
454486 }
455487
456488 // Arb Protocol BuyBack
@@ -517,6 +549,10 @@ export const runWizard = async () => {
517549 enabled : boolean ;
518550 timeWindowMs : number ;
519551 } ;
552+ expectedProfitBasedStopLoss ?: {
553+ enabled : boolean ;
554+ percent : number ;
555+ }
520556 } ;
521557 } ;
522558
@@ -537,6 +573,7 @@ export const runWizard = async () => {
537573 ? priorityFeeMicroLamports
538574 : undefined ,
539575 autoReset,
576+ expectedProfitBasedStopLoss
540577 } ,
541578 maxConcurrent : 1 ,
542579 tui : {
0 commit comments