> For the complete documentation index, see [llms.txt](https://peridot-finance.gitbook.io/peridot-protocol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://peridot-finance.gitbook.io/peridot-protocol/technical-architecture/evm/dual-investment/compoundborrowrouter.md).

# 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)`
