Dexible SDK v2.0
  • Dexible API & SDK v2.0
  • Overview
    • How Dexible Works
      • Costs
      • Verification and Validation
  • Modules
  • Major SDK Components
    • DEX Filters
    • Token
    • Quotes
    • Algos
      • Market
      • Limit
      • Stop Price Algos
      • Take Profit
      • TrailingStop
      • TWAP
    • Swap Order
  • Policies
  • Policy Overview
    • Custom Algos
  • Reporting
    • Summary Reports
    • Auditable Records
Powered by GitBook
On this page

Was this helpful?

  1. Major SDK Components
  2. Algos

Take Profit

Sometimes you want to set a specific percentage of profit for an order. This is what TakeProfit will allow you to do. It establishes a point at which an order converts to a market order and exits your position with profit. Here is an example:

const tp = new TakeProfitSwap({
    amountIn:  units.inBNETH("18000"),
    tokenIn: matic,
    tokenOut: usdc,
    slippage: new Slippage(.5, false),
    profitPercentage: 10,
    startingPrice: new Price({
        inAmount: units.inBNETH("1000"),
        inToken: matic,
        outAmount: units.inBNETH("950"),
        outToken: usdc
    })
});

Here you are telling Dexible to execute when the market price reaches 10% above the starting price of .95 USDC per MATIC, which is 1.045 USDC. At that point, Dexible will swap 18k MATIC tokens at market rate.

PreviousStop Price AlgosNextTrailingStop

Last updated 2 years ago

Was this helpful?