# Smart Order Router (SOR)

Dexible's **Smart Order Router** aggregates [liquidity](https://dexible.io/academy/defi/what-is-liquidity) across 60+ [liquidity sources](https://dexible.io/academy/defi/what-is-a-liquidity-source) ([all AMM-based DEXs)](https://dexible.io/academy/defi/what-is-an-automated-market-maker) and routes your trade to the best pools to maximize output. Our SOR algorithm considers estimated gas and DEX fees when calculating the best route.

## Order Evaluation and Execution

Dexible operates an **infrastructure** that constantly monitors market conditions against a database on order criteria. Each order is evaluated continuously to determine if these criteria, essentially true/false statements, evaluate to meet the preconditions for execution. This is done on every round of an order.&#x20;

When market conditions are satisfied, Dexible submits a portion of a large order to a settlement smart contract for execution using a bank of "relays" that monitor and manage active transactions.

These market conditions are evaluated on what would traditionally be considered the rules of a trading algorithm.&#x20;

{% hint style="info" %}
Dexible provides an algo trading experience that isn't fixed; rather, it flexibly defines algos by the user's set of configured "**policies**"
{% endhint %}

## Policy-Based Evaluation

Dexible relies on a configured set of "policies" to determine when a round should be executed. These policies include things like `GasCost`, `LimitPrice`, `StopPrice`, or `BoundedDelay`. Each of these tells Dexible whether certain conditions are met and allows Dexible to evaluate a set of policies before executing the details of an order.

{% hint style="info" %}
From a trader's perspective, using the UI, these policies are hidden. These policies are the internal implementation on the Dexible API.&#x20;
{% endhint %}

So when a trader tunes their gas price parameter to make it **fixed**, they're actually modifying a `GasCost` policy. When you set a limit price, you are tuning the `LimitPrice` policy. All these policies are added to the order and evaluated once the order is submitted to Dexible.

In this way, Dexible can remain extremely flexible. Every user order is effectively its own algo. Additionally, adding new algos just means either adding more policy types or combining them in more interest ways.

{% hint style="info" %}
For maximum customization for trading algos, we strongly recommend using the Dexible SDK since it allows you to specify policy-level attributes for an order's algo.
{% endhint %}

## Expanding Algo Definitions

Dexible will soon introduce more policy configurations to its UI platform. Stay tuned as we add more algo types and eventually offer a more advanced algo editor for those that want to get way down in the weeds.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dexible.gitbook.io/dexible/master/smart-order-router-sor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
