> For the complete documentation index, see [llms.txt](https://docs.tren.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tren.finance/protocol/hooks/router.md).

# Router

<figure><img src="/files/pR4RQm1QaF1K7JTXKRor" alt=""><figcaption></figcaption></figure>

We’ll take a look at how the Router Hook works in the example used for the Looping Leverage Hook. In the step where the FlashBorrowed XY is used to acquire PT-USDe, the Router Hook kicks in. Here, the Router Hook finds the optimal pathway for wapping XY to PT-USDe. It’s easy to think of the Router Hook as an aggregator, in that it analyses pathways to find the best and most cost-efficient pathway before executing the transaction.

A key difference from a typical aggregator however, is the Router Hook’s ability to determine and execute the groundwork necessary before making a swap. For example, if there was a request to swap aUSDT to XY:

1. Check if there is sufficent liquidity to directly swap from aUSDT
2. If not, go to Aave to withdraw USDT from the aUSDT
3. Swap USDT to XY

### **Benefits**

**Dynamic Flexibility**: The Router Hook allows for real-time decision-making, optimizing routes and execution paths based on evolving market conditions and liquidity depth

**Improved Efficiency**: Automating routing decisions and optimizing transaction pathways reduces operational complexity and potentially minimizes gas costs.

**Composability**: The Router Hook facilitates seamless integrations across protocols, enabling complex multi-step workflows and enhancing interoperability within DeFi.

**User-Friendly Automation**: Users benefit from streamlined processes where optimal pathways are executed without requiring manual intervention or technical expertise.
