# 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.


---

# 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://docs.tren.finance/protocol/hooks/router.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.
