# RiskGuard

Centralized risk policy for Dual Investment entries. Validates health factor, per‑user size caps, and per‑market utilization limits; supports emergency and per‑market pauses.

## Responsibilities

* Gate borrow‑path entries (collateral‑only entries skip borrow checks).
* Enforce `minHealthFactor`, user position caps (as ratio of liquidity), and market utilization ceilings.
* Provide owner controls for emergency pause and market‑level controls.

## Key Functions

* `checkPositionEntry(user, cTokenIn, positionValueUSD, useCollateral) -> (bool, reason)`
  * Borrow path: checks controller `borrowAllowed`, liquidity, health factor, and policy limits.
* `updateUserPositionValue(user, oldValue, newValue)` \[onlyOwner]
* `updateMarketUtilization(market, change, isIncrease)` \[onlyOwner]
* Views: `getMaxPositionValueForUser(user)`, `getUserHealthFactor(user)`.
* Admin: `setMinHealthFactor`, `setMaxPositionSizeRatio`, `setMarketMaxUtilization`, `setWhitelistedUser`, `setEmergencyPause`, `setMarketPaused`.

## Notes

* Conservative guards in try/catch avoid blocking when external controller calls revert.


---

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