Custom Algos
Dexible can accept custom order types so long as they extend the BaseSwap class. We recommend you look at the source code for other swaps before creating your own. Every algo requires the gasPolicy and slippage policies. Beyond that, the Limit, StopLimit, and TWAP algos have specific policy requirements as well (namely, LimitPrice, StopPrice, and BoundedDelay). If you truly want to start from scratch, you can apply policies to a Market algo to express to Dexible how you want the order to execute.
PriceRange Market Order
Suppose you want to simply specify a price range for an order. Unlike limit, you want to execute if the price is above or below a certain price point (often called price 'bands'). Here is what you can do:
Here we simply create a custom swap type "market" order, it will not behave like a market order because we've added specific policies that tell Dexible how to execute. It will restrict the execution to a specific price band.
Order Matters
The order of the policies array is the exact order of evaluation within Dexible's infrastructure. The first non-passing policy will stop evaluation for the order. In certain cases, the policy will force a cancel. We recommend putting those policies ahead of others to short circuit evaluation.
Extending Policies
We will add more policy types as we expand Dexible. If you find that you need a policy that is missing, please contact us and we will evaluate your use case and add policies accordingly.
Last updated