# Peridottroller

`SimplePeridottroller` is the protocol’s risk engine. It aggregates collateral and debt across markets, enforces borrow and redeem checks, and coordinates liquidations and rewards.

{% hint style="info" %}
Responsibilities

* Compute account liquidity and shortfall in USD terms.
* Enforce collateral factors and market caps.
* Gate borrows and redeems for all markets.
* Manage liquidations and seize flows.
* Accrue and mint `PeridotToken` rewards.
  {% endhint %}

## Key Functions

* `add_market(market)`\
  Register a new `ReceiptVault` market.
* `enter_market(user, market)`\
  Adds a market to the user's collateral set.
* `account_liquidity(user) -> (liquidity, shortfall)`\
  Returns USD liquidity/shortfall for the user.
* `hypothetical_liquidity(user, market, redeem_tokens, borrow_amount)`\
  Dry-run to check post-action liquidity.
* `hypothetical_liquidity_with_hint(user, market, redeem_tokens, borrow_amount, hint)`\
  Same as above, with same-market collateral hint to avoid re-entry.
* `liquidate(borrower, liquidator, repay_market, seize_market, repay_amount)`\
  Core liquidation entrypoint.
* `get_price_usd(token)`\
  Oracle price in USD (scaled).
* `claim(user)`\
  Mint accrued `PeridotToken` rewards.

## Events

* `MarketAdded`
* `MarketRemoved`
* `Liquidation`
* `PeridotTokenSet`
* `RewardsClaimed`
