# CompoundBorrowRouter

Performs safe borrowing from cToken markets and routes borrowed underlyings to authorized destinations (e.g., `VaultExecutor`).

## Responsibilities

* Enforce health factor / liquidity constraints before borrowing.
* Integrate with Peridottroller risk checks and price oracle for USD projections.
* Route funds to a destination or pull from user if underlying was credited to them.

## Key Functions

* `borrowAndRoute(cToken, borrowAmount, destination, user)` \[onlyAuthorizedDestination]
  * Requires no shortfall; checks health factor after borrow ≥ min threshold; borrows and routes.
* `canUserBorrow(user, cToken, borrowAmount) -> (bool, reason)`
  * Dry‑run: controller `borrowAllowed`, liquidity, projected health factor.
* `getUserHealthFactor(user)` view.
* Admin: `setAuthorizedDestination(addr, authorized)`, `setMinHealthFactor(factor1e18)`, `setMaxLTV(bps1e18)`, `emergencyRepay`, `emergencyWithdraw`.

## Events

* `BorrowAndRoute(user, cToken, destination, borrowAmount, healthBefore, healthAfter)`


---

# 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://peridot-finance.gitbook.io/peridot-protocol/technical-architecture/evm/dual-investment/compoundborrowrouter.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.
