StopLimit Algo

Stop limit orders are used to catch a bounce in the price of an asset. Bounce, in this case, means the price hits a bottom and starts trending up. In this case, a "trigger" price tells the stop limit algo when to start swapping an asset. Once swapping begins, the "limit" price tells the algo when to stop swapping. That is, it protects you from a runup in price that exceeds your expectation. This is usually the case for a buy scenario where you don't want to pay too much for the asset after its price bounces.

let algo = sdk.algo.create({
   type: sdk.algo.types.STOP_LIMIT,
   trigger: Price.unitsToPrice({
        inToken: tokenIn, //WETH
        outToken: tokenOut, //MATIC
        inUnits: 1, //weth in
        outUnits: 1800 //MATIC out
    }),
    limitPrice: Price.unitsToPrice({
        inToken: tokenIn, //WETH
        outToken: tokenOut, //MATIC
        inUnits: 1, //weth in
        outUnits: 1500 //MATIC out
    }),
   gasPolicy: {
        type: sdk.gasPolicyTypes.RELATIVE,
        deviation: 0
   },
   slippagePercent: .5
});

In this example, the trigger to buy MATIC kicks off when the price is 1/1800 ETH per MATIC. If the price reaches 1/1500 ETH per MATIC, the order will stop until the price comes back below the limit.

Last updated