# Operator

**Inherits:** [OperatorStorage](https://malda-protocol.github.io/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html), [ImTokenOperationTypes](https://malda-protocol.github.io/src/interfaces/ImToken.sol/interface.ImTokenOperationTypes.html), OwnableUpgradeable

### [Functions](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#functions) <a href="#functions" id="functions"></a>

#### [constructor](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#constructor) <a href="#constructor" id="constructor"></a>

**Note:** oz-upgrades-unsafe-allow: constructor

```solidity
constructor();
```

#### [initialize](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#initialize) <a href="#initialize" id="initialize"></a>

```solidity
function initialize(address _rolesOperator, address _rewardDistributor, address _admin) public initializer;
```

#### [onlyAllowedUser](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#onlyalloweduser) <a href="#onlyalloweduser" id="onlyalloweduser"></a>

```solidity
modifier onlyAllowedUser(address user);
```

#### [setWhitelistedUser](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#setwhitelisteduser) <a href="#setwhitelisteduser" id="setwhitelisteduser"></a>

Sets user whitelist status

```solidity
function setWhitelistedUser(address user, bool state) external onlyOwner;
```

**Parameters**

| Name    | Type      | Description      |
| ------- | --------- | ---------------- |
| `user`  | `address` | The user address |
| `state` | `bool`    | The new staate   |

#### [enableWhitelist](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#enablewhitelist) <a href="#enablewhitelist" id="enablewhitelist"></a>

Enable user whitelist

```solidity
function enableWhitelist() external onlyOwner;
```

#### [disableWhitelist](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#disablewhitelist) <a href="#disablewhitelist" id="disablewhitelist"></a>

Disable user whitelist

```solidity
function disableWhitelist() external onlyOwner;
```

#### [setRolesOperator](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#setrolesoperator) <a href="#setrolesoperator" id="setrolesoperator"></a>

Sets a new Operator for the market

*Admin function to set a new operator*

```solidity
function setRolesOperator(address _roles) external onlyOwner;
```

#### [setPriceOracle](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#setpriceoracle) <a href="#setpriceoracle" id="setpriceoracle"></a>

Sets a new price oracle

*Admin function to set a new price oracle*

```solidity
function setPriceOracle(address newOracle) external onlyOwner;
```

#### [setCloseFactor](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#setclosefactor) <a href="#setclosefactor" id="setclosefactor"></a>

Sets the closeFactor used when liquidating borrows

*Admin function to set closeFactor*

```solidity
function setCloseFactor(uint256 newCloseFactorMantissa) external onlyOwner;
```

**Parameters**

| Name                     | Type      | Description                      |
| ------------------------ | --------- | -------------------------------- |
| `newCloseFactorMantissa` | `uint256` | New close factor, scaled by 1e18 |

#### [setCollateralFactor](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#setcollateralfactor) <a href="#setcollateralfactor" id="setcollateralfactor"></a>

Sets the collateralFactor for a market

*Admin function to set per-market collateralFactor*

```solidity
function setCollateralFactor(address mToken, uint256 newCollateralFactorMantissa) external onlyOwner;
```

**Parameters**

| Name                          | Type      | Description                               |
| ----------------------------- | --------- | ----------------------------------------- |
| `mToken`                      | `address` | The market to set the factor on           |
| `newCollateralFactorMantissa` | `uint256` | The new collateral factor, scaled by 1e18 |

#### [setLiquidationIncentive](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#setliquidationincentive) <a href="#setliquidationincentive" id="setliquidationincentive"></a>

Sets liquidationIncentive

*Admin function to set liquidationIncentive*

```solidity
function setLiquidationIncentive(address market, uint256 newLiquidationIncentiveMantissa) external onlyOwner;
```

**Parameters**

| Name                              | Type      | Description                             |
| --------------------------------- | --------- | --------------------------------------- |
| `market`                          | `address` |                                         |
| `newLiquidationIncentiveMantissa` | `uint256` | New liquidationIncentive scaled by 1e18 |

#### [supportMarket](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#supportmarket) <a href="#supportmarket" id="supportmarket"></a>

Add the market to the markets mapping and set it as listed

*Admin function to set isListed and add support for the market*

```solidity
function supportMarket(address mToken) external onlyOwner;
```

**Parameters**

| Name     | Type      | Description                               |
| -------- | --------- | ----------------------------------------- |
| `mToken` | `address` | The address of the market (token) to list |

#### [setOutflowVolumeTimeWindow](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#setoutflowvolumetimewindow) <a href="#setoutflowvolumetimewindow" id="setoutflowvolumetimewindow"></a>

Sets outflow volume time window

```solidity
function setOutflowVolumeTimeWindow(uint256 newTimeWindow) external onlyOwner;
```

**Parameters**

| Name            | Type      | Description               |
| --------------- | --------- | ------------------------- |
| `newTimeWindow` | `uint256` | The new reset time window |

#### [setOutflowTimeLimitInUSD](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#setoutflowtimelimitinusd) <a href="#setoutflowtimelimitinusd" id="setoutflowtimelimitinusd"></a>

Sets outflow volume limit

*when 0, it means there's no limit*

```solidity
function setOutflowTimeLimitInUSD(uint256 amount) external onlyOwner;
```

**Parameters**

| Name     | Type      | Description   |
| -------- | --------- | ------------- |
| `amount` | `uint256` | The new limit |

#### [resetOutflowVolume](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#resetoutflowvolume) <a href="#resetoutflowvolume" id="resetoutflowvolume"></a>

Resets outflow volume

```solidity
function resetOutflowVolume() external onlyOwner;
```

#### [checkOutflowVolumeLimit](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#checkoutflowvolumelimit) <a href="#checkoutflowvolumelimit" id="checkoutflowvolumelimit"></a>

Verifies outflow volule limit

```solidity
function checkOutflowVolumeLimit(uint256 amount) external;
```

**Parameters**

| Name     | Type      | Description   |
| -------- | --------- | ------------- |
| `amount` | `uint256` | The new limit |

#### [setMarketBorrowCaps](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#setmarketborrowcaps) <a href="#setmarketborrowcaps" id="setmarketborrowcaps"></a>

Set the given borrow caps for the given mToken markets. Borrowing that brings total borrows to or above borrow cap will revert.

```solidity
function setMarketBorrowCaps(address[] calldata mTokens, uint256[] calldata newBorrowCaps) external;
```

**Parameters**

| Name            | Type        | Description                                                                                         |
| --------------- | ----------- | --------------------------------------------------------------------------------------------------- |
| `mTokens`       | `address[]` | The addresses of the markets (tokens) to change the borrow caps for                                 |
| `newBorrowCaps` | `uint256[]` | The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing. |

#### [setMarketSupplyCaps](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#setmarketsupplycaps) <a href="#setmarketsupplycaps" id="setmarketsupplycaps"></a>

Set the given supply caps for the given mToken markets. Supplying that brings total supply to or above supply cap will revert.

```solidity
function setMarketSupplyCaps(address[] calldata mTokens, uint256[] calldata newSupplyCaps) external;
```

**Parameters**

| Name            | Type        | Description                                                                                         |
| --------------- | ----------- | --------------------------------------------------------------------------------------------------- |
| `mTokens`       | `address[]` | The addresses of the markets (tokens) to change the supply caps for                                 |
| `newSupplyCaps` | `uint256[]` | The new supply cap values in underlying to be set. A value of 0 corresponds to unlimited supplying. |

#### [setPaused](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#setpaused) <a href="#setpaused" id="setpaused"></a>

Set pause for a specific operation

```solidity
function setPaused(address mToken, ImTokenOperationTypes.OperationType _type, bool state) external;
```

**Parameters**

| Name     | Type                                  | Description                |
| -------- | ------------------------------------- | -------------------------- |
| `mToken` | `address`                             | The market token address   |
| `_type`  | `ImTokenOperationTypes.OperationType` | The pause operation type   |
| `state`  | `bool`                                | The pause operation status |

#### [setRewardDistributor](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#setrewarddistributor) <a href="#setrewarddistributor" id="setrewarddistributor"></a>

Admin function to change the Reward Distributor

```solidity
function setRewardDistributor(address newRewardDistributor) external onlyOwner;
```

**Parameters**

| Name                   | Type      | Description                               |
| ---------------------- | --------- | ----------------------------------------- |
| `newRewardDistributor` | `address` | The address of the new Reward Distributor |

#### [isOperator](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#isoperator) <a href="#isoperator" id="isoperator"></a>

Should return true

```solidity
function isOperator() external pure override returns (bool);
```

#### [isPaused](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#ispaused) <a href="#ispaused" id="ispaused"></a>

Returns if operation is paused

```solidity
function isPaused(address mToken, ImTokenOperationTypes.OperationType _type) external view override returns (bool);
```

**Parameters**

| Name     | Type                                  | Description         |
| -------- | ------------------------------------- | ------------------- |
| `mToken` | `address`                             | The mToken to check |
| `_type`  | `ImTokenOperationTypes.OperationType` | the operation type  |

#### [getAssetsIn](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#getassetsin) <a href="#getassetsin" id="getassetsin"></a>

Returns the assets an account has entered

```solidity
function getAssetsIn(address _user) external view override returns (address[] memory mTokens);
```

**Parameters**

| Name    | Type      | Description                                   |
| ------- | --------- | --------------------------------------------- |
| `_user` | `address` | The address of the account to pull assets for |

**Returns**

| Name      | Type        | Description                                            |
| --------- | ----------- | ------------------------------------------------------ |
| `mTokens` | `address[]` | A dynamic list with the assets the account has entered |

#### [checkMembership](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#checkmembership) <a href="#checkmembership" id="checkmembership"></a>

Returns whether the given account is entered in the given asset

```solidity
function checkMembership(address account, address mToken) external view returns (bool);
```

**Parameters**

| Name      | Type      | Description                         |
| --------- | --------- | ----------------------------------- |
| `account` | `address` | The address of the account to check |
| `mToken`  | `address` | The mToken to check                 |

**Returns**

| Name     | Type   | Description                                           |
| -------- | ------ | ----------------------------------------------------- |
| `<none>` | `bool` | True if the account is in the asset, otherwise false. |

#### [getAllMarkets](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#getallmarkets) <a href="#getallmarkets" id="getallmarkets"></a>

A list of all markets

```solidity
function getAllMarkets() external view returns (address[] memory mTokens);
```

#### [isDeprecated](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#isdeprecated) <a href="#isdeprecated" id="isdeprecated"></a>

Returns true if the given mToken market has been deprecated

*All borrows in a deprecated mToken market can be immediately liquidated*

```solidity
function isDeprecated(address mToken) external view override returns (bool);
```

**Parameters**

| Name     | Type      | Description                       |
| -------- | --------- | --------------------------------- |
| `mToken` | `address` | The market to check if deprecated |

#### [isMarketListed](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#ismarketlisted) <a href="#ismarketlisted" id="ismarketlisted"></a>

Returns true/false

```solidity
function isMarketListed(address mToken) external view override returns (bool);
```

#### [getAccountLiquidity](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#getaccountliquidity) <a href="#getaccountliquidity" id="getaccountliquidity"></a>

Determine the current account liquidity wrt collateral requirements

```solidity
function getAccountLiquidity(address account) public view returns (uint256, uint256);
```

**Returns**

| Name     | Type      | Description                                                                                              |
| -------- | --------- | -------------------------------------------------------------------------------------------------------- |
| `<none>` | `uint256` | account liquidity in excess of collateral requirements, account shortfall below collateral requirements) |
| `<none>` | `uint256` |                                                                                                          |

#### [getHypotheticalAccountLiquidity](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#gethypotheticalaccountliquidity) <a href="#gethypotheticalaccountliquidity" id="gethypotheticalaccountliquidity"></a>

Determine what the account liquidity would be if the given amounts were redeemed/borrowed

```solidity
function getHypotheticalAccountLiquidity(
    address account,
    address mTokenModify,
    uint256 redeemTokens,
    uint256 borrowAmount
) external view returns (uint256, uint256);
```

**Parameters**

| Name           | Type      | Description                                       |
| -------------- | --------- | ------------------------------------------------- |
| `account`      | `address` | The account to determine liquidity for            |
| `mTokenModify` | `address` | The market to hypothetically redeem/borrow in     |
| `redeemTokens` | `uint256` | The number of tokens to hypothetically redeem     |
| `borrowAmount` | `uint256` | The amount of underlying to hypothetically borrow |

**Returns**

| Name     | Type      | Description                                                                                                                        |
| -------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `uint256` | hypothetical account liquidity in excess of collateral requirements, hypothetical account shortfall below collateral requirements) |
| `<none>` | `uint256` |                                                                                                                                    |

#### [liquidateCalculateSeizeTokens](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#liquidatecalculateseizetokens) <a href="#liquidatecalculateseizetokens" id="liquidatecalculateseizetokens"></a>

Calculate number of tokens of collateral asset to seize given an underlying amount

*Used in liquidation (called in mTokenBorrowed.liquidate)*

```solidity
function liquidateCalculateSeizeTokens(address mTokenBorrowed, address mTokenCollateral, uint256 actualRepayAmount)
    external
    view
    returns (uint256);
```

**Parameters**

| Name                | Type      | Description                                                                     |
| ------------------- | --------- | ------------------------------------------------------------------------------- |
| `mTokenBorrowed`    | `address` | The address of the borrowed mToken                                              |
| `mTokenCollateral`  | `address` | The address of the collateral mToken                                            |
| `actualRepayAmount` | `uint256` | The amount of mTokenBorrowed underlying to convert into mTokenCollateral tokens |

**Returns**

| Name     | Type      | Description                                                     |
| -------- | --------- | --------------------------------------------------------------- |
| `<none>` | `uint256` | number of mTokenCollateral tokens to be seized in a liquidation |

#### [enterMarkets](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#entermarkets) <a href="#entermarkets" id="entermarkets"></a>

Add assets to be included in account liquidity calculation

```solidity
function enterMarkets(address[] calldata _mTokens) external override onlyAllowedUser(msg.sender);
```

**Parameters**

| Name       | Type        | Description                                               |
| ---------- | ----------- | --------------------------------------------------------- |
| `_mTokens` | `address[]` | The list of addresses of the mToken markets to be enabled |

#### [enterMarketsWithSender](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#entermarketswithsender) <a href="#entermarketswithsender" id="entermarketswithsender"></a>

Add asset (msg.sender) to be included in account liquidity calculation

```solidity
function enterMarketsWithSender(address _account) external override onlyAllowedUser(_account);
```

**Parameters**

| Name       | Type      | Description            |
| ---------- | --------- | ---------------------- |
| `_account` | `address` | The account to add for |

#### [exitMarket](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#exitmarket) <a href="#exitmarket" id="exitmarket"></a>

Removes asset from sender's account liquidity calculation

*Sender must not have an outstanding borrow balance in the asset, or be providing necessary collateral for an outstanding borrow.*

```solidity
function exitMarket(address _mToken) external override;
```

**Parameters**

| Name      | Type      | Description                            |
| --------- | --------- | -------------------------------------- |
| `_mToken` | `address` | The address of the asset to be removed |

#### [claimMalda](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#claimmalda) <a href="#claimmalda" id="claimmalda"></a>

Claim all the MALDA accrued by holder in all markets

```solidity
function claimMalda(address holder) external override;
```

**Parameters**

| Name     | Type      | Description                    |
| -------- | --------- | ------------------------------ |
| `holder` | `address` | The address to claim MALDA for |

#### [claimMalda](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#claimmalda-1) <a href="#claimmalda-1" id="claimmalda-1"></a>

Claim all the MALDA accrued by holder in the specified markets

```solidity
function claimMalda(address holder, address[] memory mTokens) external override;
```

**Parameters**

| Name      | Type        | Description                           |
| --------- | ----------- | ------------------------------------- |
| `holder`  | `address`   | The address to claim MALDA for        |
| `mTokens` | `address[]` | The list of markets to claim MALDA in |

#### [claimMalda](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#claimmalda-2) <a href="#claimmalda-2" id="claimmalda-2"></a>

Claim all MALDA accrued by the holders

```solidity
function claimMalda(address[] memory holders, address[] memory mTokens, bool borrowers, bool suppliers)
    external
    override;
```

**Parameters**

| Name        | Type        | Description                                       |
| ----------- | ----------- | ------------------------------------------------- |
| `holders`   | `address[]` | The addresses to claim MALDA for                  |
| `mTokens`   | `address[]` | The list of markets to claim MALDA in             |
| `borrowers` | `bool`      | Whether or not to claim MALDA earned by borrowing |
| `suppliers` | `bool`      | Whether or not to claim MALDA earned by supplying |

#### [getUSDValueForAllMarkets](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#getusdvalueforallmarkets) <a href="#getusdvalueforallmarkets" id="getusdvalueforallmarkets"></a>

Returns USD value for all markets

```solidity
function getUSDValueForAllMarkets() external view returns (uint256);
```

#### [beforeWithdrawOnExtension](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#beforewithdrawonextension) <a href="#beforewithdrawonextension" id="beforewithdrawonextension"></a>

Checks whitelist status on withdrawOnExtension

```solidity
function beforeWithdrawOnExtension(address user) external view onlyAllowedUser(user);
```

**Parameters**

| Name   | Type      | Description       |
| ------ | --------- | ----------------- |
| `user` | `address` | The user to check |

#### [beforeBorrowOnExtension](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#beforeborrowonextension) <a href="#beforeborrowonextension" id="beforeborrowonextension"></a>

Checks whitelist status on borrowOnExtension

```solidity
function beforeBorrowOnExtension(address user) external view onlyAllowedUser(user);
```

**Parameters**

| Name   | Type      | Description       |
| ------ | --------- | ----------------- |
| `user` | `address` | The user to check |

#### [beforeRebalancing](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#beforerebalancing) <a href="#beforerebalancing" id="beforerebalancing"></a>

Checks if the account should be allowed to rebalance tokens

```solidity
function beforeRebalancing(address mToken) external view override;
```

**Parameters**

| Name     | Type      | Description                               |
| -------- | --------- | ----------------------------------------- |
| `mToken` | `address` | The market to verify the transfer against |

#### [beforeMTokenTransfer](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#beforemtokentransfer) <a href="#beforemtokentransfer" id="beforemtokentransfer"></a>

Checks if the account should be allowed to transfer tokens in the given market

```solidity
function beforeMTokenTransfer(address mToken, address src, address dst, uint256 transferTokens) external override;
```

**Parameters**

| Name             | Type      | Description                               |
| ---------------- | --------- | ----------------------------------------- |
| `mToken`         | `address` | The market to verify the transfer against |
| `src`            | `address` | The account which sources the tokens      |
| `dst`            | `address` | The account which receives the tokens     |
| `transferTokens` | `uint256` | The number of mTokens to transfer         |

#### [beforeMTokenMint](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#beforemtokenmint) <a href="#beforemtokenmint" id="beforemtokenmint"></a>

Checks if the account should be allowed to mint tokens in the given market

```solidity
function beforeMTokenMint(address mToken, address minter) external override onlyAllowedUser(minter);
```

**Parameters**

| Name     | Type      | Description                                   |
| -------- | --------- | --------------------------------------------- |
| `mToken` | `address` | The market to verify the mint against         |
| `minter` | `address` | The account which would get the minted tokens |

#### [afterMTokenMint](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#aftermtokenmint) <a href="#aftermtokenmint" id="aftermtokenmint"></a>

Validates mint and reverts on rejection. May emit logs.

```solidity
function afterMTokenMint(address mToken) external view override;
```

**Parameters**

| Name     | Type      | Description        |
| -------- | --------- | ------------------ |
| `mToken` | `address` | Asset being minted |

#### [beforeMTokenRedeem](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#beforemtokenredeem) <a href="#beforemtokenredeem" id="beforemtokenredeem"></a>

Checks if the account should be allowed to redeem tokens in the given market

```solidity
function beforeMTokenRedeem(address mToken, address redeemer, uint256 redeemTokens)
    external
    override
    onlyAllowedUser(redeemer);
```

**Parameters**

| Name           | Type      | Description                                                              |
| -------------- | --------- | ------------------------------------------------------------------------ |
| `mToken`       | `address` | The market to verify the redeem against                                  |
| `redeemer`     | `address` | The account which would redeem the tokens                                |
| `redeemTokens` | `uint256` | The number of mTokens to exchange for the underlying asset in the market |

#### [beforeMTokenBorrow](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#beforemtokenborrow) <a href="#beforemtokenborrow" id="beforemtokenborrow"></a>

Checks if the account should be allowed to borrow the underlying asset of the given market

```solidity
function beforeMTokenBorrow(address mToken, address borrower, uint256 borrowAmount)
    external
    override
    onlyAllowedUser(borrower);
```

**Parameters**

| Name           | Type      | Description                                       |
| -------------- | --------- | ------------------------------------------------- |
| `mToken`       | `address` | The market to verify the borrow against           |
| `borrower`     | `address` | The account which would borrow the asset          |
| `borrowAmount` | `uint256` | The amount of underlying the account would borrow |

#### [beforeMTokenRepay](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#beforemtokenrepay) <a href="#beforemtokenrepay" id="beforemtokenrepay"></a>

Checks if the account should be allowed to repay a borrow in the given market

```solidity
function beforeMTokenRepay(address mToken, address borrower) external onlyAllowedUser(borrower);
```

**Parameters**

| Name       | Type      | Description                                |
| ---------- | --------- | ------------------------------------------ |
| `mToken`   | `address` | The market to verify the repay against     |
| `borrower` | `address` | The account which would borrowed the asset |

#### [beforeMTokenLiquidate](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#beforemtokenliquidate) <a href="#beforemtokenliquidate" id="beforemtokenliquidate"></a>

Checks if the liquidation should be allowed to occur

```solidity
function beforeMTokenLiquidate(address mTokenBorrowed, address mTokenCollateral, address borrower, uint256 repayAmount)
    external
    view
    override
    onlyAllowedUser(borrower);
```

**Parameters**

| Name               | Type      | Description                                           |
| ------------------ | --------- | ----------------------------------------------------- |
| `mTokenBorrowed`   | `address` | Asset which was borrowed by the borrower              |
| `mTokenCollateral` | `address` | Asset which was used as collateral and will be seized |
| `borrower`         | `address` | The address of the borrower                           |
| `repayAmount`      | `uint256` | The amount of underlying being repaid                 |

#### [beforeMTokenSeize](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#beforemtokenseize) <a href="#beforemtokenseize" id="beforemtokenseize"></a>

Checks if the seizing of assets should be allowed to occur

```solidity
function beforeMTokenSeize(address mTokenCollateral, address mTokenBorrowed, address liquidator, address borrower)
    external
    override;
```

**Parameters**

| Name               | Type      | Description                                                |
| ------------------ | --------- | ---------------------------------------------------------- |
| `mTokenCollateral` | `address` | Asset which was used as collateral and will be seized      |
| `mTokenBorrowed`   | `address` | Asset which was borrowed by the borrower                   |
| `liquidator`       | `address` | The address repaying the borrow and seizing the collateral |
| `borrower`         | `address` | The address of the borrower                                |

#### [\_convertMarketAmountToUSDValue](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#_convertmarketamounttousdvalue) <a href="#convertmarketamounttousdvalue" id="convertmarketamounttousdvalue"></a>

```solidity
function _convertMarketAmountToUSDValue(uint256 amount, address mToken) internal view returns (uint256);
```

#### [\_activateMarket](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#_activatemarket) <a href="#activatemarket" id="activatemarket"></a>

```solidity
function _activateMarket(address _mToken, address borrower) private;
```

#### [\_beforeRedeem](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#_beforeredeem) <a href="#beforeredeem" id="beforeredeem"></a>

```solidity
function _beforeRedeem(address mToken, address redeemer, uint256 redeemTokens) private view;
```

#### [\_getHypotheticalAccountLiquidity](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#_gethypotheticalaccountliquidity) <a href="#gethypotheticalaccountliquidity" id="gethypotheticalaccountliquidity"></a>

```solidity
function _getHypotheticalAccountLiquidity(
    address account,
    address mTokenModify,
    uint256 redeemTokens,
    uint256 borrowAmount
) private view returns (uint256, uint256);
```

#### [\_updateMaldaSupplyIndex](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#_updatemaldasupplyindex) <a href="#updatemaldasupplyindex" id="updatemaldasupplyindex"></a>

Notify reward distributor for supply index update

```solidity
function _updateMaldaSupplyIndex(address mToken) private;
```

**Parameters**

| Name     | Type      | Description                             |
| -------- | --------- | --------------------------------------- |
| `mToken` | `address` | The market whose supply index to update |

#### [\_updateMaldaBorrowIndex](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#_updatemaldaborrowindex) <a href="#updatemaldaborrowindex" id="updatemaldaborrowindex"></a>

Notify reward distributor for borrow index update

```solidity
function _updateMaldaBorrowIndex(address mToken) private;
```

**Parameters**

| Name     | Type      | Description                             |
| -------- | --------- | --------------------------------------- |
| `mToken` | `address` | The market whose borrow index to update |

#### [\_distributeSupplierMalda](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#_distributesuppliermalda) <a href="#distributesuppliermalda" id="distributesuppliermalda"></a>

Notify reward distributor for supplier update

```solidity
function _distributeSupplierMalda(address mToken, address supplier) private;
```

**Parameters**

| Name       | Type      | Description                                        |
| ---------- | --------- | -------------------------------------------------- |
| `mToken`   | `address` | The market in which the supplier is interacting    |
| `supplier` | `address` | The address of the supplier to distribute MALDA to |

#### [\_distributeBorrowerMalda](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#_distributeborrowermalda) <a href="#distributeborrowermalda" id="distributeborrowermalda"></a>

Notify reward distributor for borrower update

*Borrowers will not begin to accrue until after the first interaction with the protocol.*

```solidity
function _distributeBorrowerMalda(address mToken, address borrower) private;
```

**Parameters**

| Name       | Type      | Description                                        |
| ---------- | --------- | -------------------------------------------------- |
| `mToken`   | `address` | The market in which the borrower is interacting    |
| `borrower` | `address` | The address of the borrower to distribute MALDA to |

#### [\_claim](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#_claim) <a href="#claim" id="claim"></a>

```solidity
function _claim(address[] memory holders, address[] memory mTokens, bool borrowers, bool suppliers) private;
```

#### [\_isDeprecated](https://malda-protocol.github.io/malda-lending/src/Operator/Operator.sol/contract.Operator.html#_isdeprecated) <a href="#isdeprecated" id="isdeprecated"></a>

```solidity
function _isDeprecated(address mToken) private view returns (bool);
```

## [OperatorStorage](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operatorstorage) <a href="#operatorstorage" id="operatorstorage"></a>

[Git Source](https://github.com/malda-protocol/malda-lending/blob/46ffe4f96e87e12ea92a35f2ba728f08edbf4246/src/Operator/OperatorStorage.sol)

**Inherits:** [IOperator](https://malda-protocol.github.io/src/interfaces/IOperator.sol/interface.IOperator.html), [IOperatorDefender](https://malda-protocol.github.io/src/interfaces/IOperator.sol/interface.IOperatorDefender.html), [ExponentialNoError](https://malda-protocol.github.io/src/utils/ExponentialNoError.sol/abstract.ExponentialNoError.html)

### [State Variables](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#state-variables) <a href="#state-variables" id="state-variables"></a>

#### [rolesOperator](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#rolesoperator) <a href="#rolesoperator" id="rolesoperator"></a>

Roles manager

```solidity
IRoles public rolesOperator;
```

#### [oracleOperator](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#oracleoperator) <a href="#oracleoperator" id="oracleoperator"></a>

Oracle which gives the price of any given asset

```solidity
address public oracleOperator;
```

#### [closeFactorMantissa](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#closefactormantissa) <a href="#closefactormantissa" id="closefactormantissa"></a>

Multiplier used to calculate the maximum repayAmount when liquidating a borrow

```solidity
uint256 public closeFactorMantissa;
```

#### [liquidationIncentiveMantissa](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#liquidationincentivemantissa) <a href="#liquidationincentivemantissa" id="liquidationincentivemantissa"></a>

Multiplier representing the discount on collateral that a liquidator receives

```solidity
mapping(address => uint256) public liquidationIncentiveMantissa;
```

#### [accountAssets](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#accountassets) <a href="#accountassets" id="accountassets"></a>

Per-account mapping of "assets you are in", capped by maxAssets

```solidity
mapping(address => address[]) public accountAssets;
```

#### [markets](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#markets) <a href="#markets" id="markets"></a>

Official mapping of mTokens -> Market metadata

*Used e.g. to determine if a market is supported*

```solidity
mapping(address => IOperatorData.Market) public markets;
```

#### [allMarkets](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#allmarkets) <a href="#allmarkets" id="allmarkets"></a>

A list of all markets

```solidity
address[] public allMarkets;
```

#### [borrowCaps](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#borrowcaps) <a href="#borrowcaps" id="borrowcaps"></a>

Borrow caps enforced by borrowAllowed for each mToken address. Defaults to zero which corresponds to unlimited borrowing.

```solidity
mapping(address => uint256) public borrowCaps;
```

#### [supplyCaps](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#supplycaps) <a href="#supplycaps" id="supplycaps"></a>

Supply caps enforced by supplyAllowed for each mToken address. Defaults to zero which corresponds to unlimited supplying.

```solidity
mapping(address => uint256) public supplyCaps;
```

#### [rewardDistributor](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#rewarddistributor) <a href="#rewarddistributor" id="rewarddistributor"></a>

Reward Distributor to markets supply and borrow (including protocol token)

```solidity
address public rewardDistributor;
```

#### [limitPerTimePeriod](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#limitpertimeperiod) <a href="#limitpertimeperiod" id="limitpertimeperiod"></a>

Should return outflow limit

```solidity
uint256 public limitPerTimePeriod;
```

#### [cumulativeOutflowVolume](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#cumulativeoutflowvolume) <a href="#cumulativeoutflowvolume" id="cumulativeoutflowvolume"></a>

Should return outflow volume

```solidity
uint256 public cumulativeOutflowVolume;
```

#### [lastOutflowResetTimestamp](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#lastoutflowresettimestamp) <a href="#lastoutflowresettimestamp" id="lastoutflowresettimestamp"></a>

Should return last reset time for outflow check

```solidity
uint256 public lastOutflowResetTimestamp;
```

#### [outflowResetTimeWindow](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#outflowresettimewindow) <a href="#outflowresettimewindow" id="outflowresettimewindow"></a>

Should return the outflow volume time window

```solidity
uint256 public outflowResetTimeWindow;
```

#### [userWhitelisted](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#userwhitelisted) <a href="#userwhitelisted" id="userwhitelisted"></a>

Returns true/false for user

```solidity
mapping(address => bool) public userWhitelisted;
```

#### [whitelistEnabled](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#whitelistenabled) <a href="#whitelistenabled" id="whitelistenabled"></a>

```solidity
bool public whitelistEnabled;
```

#### [\_paused](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#_paused) <a href="#paused" id="paused"></a>

```solidity
mapping(address => mapping(ImTokenOperationTypes.OperationType => bool)) internal _paused;
```

#### [CLOSE\_FACTOR\_MIN\_MANTISSA](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#close_factor_min_mantissa) <a href="#close_factor_min_mantissa" id="close_factor_min_mantissa"></a>

```solidity
uint256 internal constant CLOSE_FACTOR_MIN_MANTISSA = 0.05e18;
```

#### [CLOSE\_FACTOR\_MAX\_MANTISSA](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#close_factor_max_mantissa) <a href="#close_factor_max_mantissa" id="close_factor_max_mantissa"></a>

```solidity
uint256 internal constant CLOSE_FACTOR_MAX_MANTISSA = 0.9e18;
```

#### [COLLATERAL\_FACTOR\_MAX\_MANTISSA](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#collateral_factor_max_mantissa) <a href="#collateral_factor_max_mantissa" id="collateral_factor_max_mantissa"></a>

```solidity
uint256 internal constant COLLATERAL_FACTOR_MAX_MANTISSA = 0.9e18;
```

### [Events](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#events) <a href="#events" id="events"></a>

#### [UserWhitelisted](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#userwhitelisted-1) <a href="#userwhitelisted-1" id="userwhitelisted-1"></a>

Emitted when user whitelist status is changed

```solidity
event UserWhitelisted(address indexed user, bool state);
```

#### [WhitelistEnabled](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#whitelistenabled-1) <a href="#whitelistenabled-1" id="whitelistenabled-1"></a>

```solidity
event WhitelistEnabled();
```

#### [WhitelistDisabled](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#whitelistdisabled) <a href="#whitelistdisabled" id="whitelistdisabled"></a>

```solidity
event WhitelistDisabled();
```

#### [ActionPaused](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#actionpaused) <a href="#actionpaused" id="actionpaused"></a>

Emitted when pause status is changed

```solidity
event ActionPaused(address indexed mToken, ImTokenOperationTypes.OperationType _type, bool state);
```

#### [NewRewardDistributor](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#newrewarddistributor) <a href="#newrewarddistributor" id="newrewarddistributor"></a>

Emitted when reward distributor is changed

```solidity
event NewRewardDistributor(address indexed oldRewardDistributor, address indexed newRewardDistributor);
```

#### [NewBorrowCap](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#newborrowcap) <a href="#newborrowcap" id="newborrowcap"></a>

Emitted when borrow cap for a mToken is changed

```solidity
event NewBorrowCap(address indexed mToken, uint256 newBorrowCap);
```

#### [NewSupplyCap](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#newsupplycap) <a href="#newsupplycap" id="newsupplycap"></a>

Emitted when supply cap for a mToken is changed

```solidity
event NewSupplyCap(address indexed mToken, uint256 newBorrowCap);
```

#### [MarketListed](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#marketlisted) <a href="#marketlisted" id="marketlisted"></a>

Emitted when an admin supports a market

```solidity
event MarketListed(address mToken);
```

#### [MarketEntered](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#marketentered) <a href="#marketentered" id="marketentered"></a>

Emitted when an account enters a market

```solidity
event MarketEntered(address indexed mToken, address indexed account);
```

#### [MarketExited](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#marketexited) <a href="#marketexited" id="marketexited"></a>

Emitted when an account exits a market

```solidity
event MarketExited(address indexed mToken, address indexed account);
```

#### [NewCloseFactor](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#newclosefactor) <a href="#newclosefactor" id="newclosefactor"></a>

Emitted Emitted when close factor is changed by admin

```solidity
event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);
```

#### [NewCollateralFactor](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#newcollateralfactor) <a href="#newcollateralfactor" id="newcollateralfactor"></a>

Emitted when a collateral factor is changed by admin

```solidity
event NewCollateralFactor(
    address indexed mToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa
);
```

#### [NewLiquidationIncentive](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#newliquidationincentive) <a href="#newliquidationincentive" id="newliquidationincentive"></a>

Emitted when liquidation incentive is changed by admin

```solidity
event NewLiquidationIncentive(
    address market, uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa
);
```

#### [NewPriceOracle](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#newpriceoracle) <a href="#newpriceoracle" id="newpriceoracle"></a>

Emitted when price oracle is changed

```solidity
event NewPriceOracle(address indexed oldPriceOracle, address indexed newPriceOracle);
```

#### [NewRolesOperator](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#newrolesoperator) <a href="#newrolesoperator" id="newrolesoperator"></a>

Event emitted when rolesOperator is changed

```solidity
event NewRolesOperator(address indexed oldRoles, address indexed newRoles);
```

#### [OutflowLimitUpdated](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#outflowlimitupdated) <a href="#outflowlimitupdated" id="outflowlimitupdated"></a>

Event emitted when outflow limit is updated

```solidity
event OutflowLimitUpdated(address indexed sender, uint256 oldLimit, uint256 newLimit);
```

#### [OutflowTimeWindowUpdated](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#outflowtimewindowupdated) <a href="#outflowtimewindowupdated" id="outflowtimewindowupdated"></a>

Event emitted when outflow reset time window is updated

```solidity
event OutflowTimeWindowUpdated(uint256 oldWindow, uint256 newWindow);
```

#### [OutflowVolumeReset](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#outflowvolumereset) <a href="#outflowvolumereset" id="outflowvolumereset"></a>

Event emitted when outflow volume has been reset

```solidity
event OutflowVolumeReset();
```

### [Errors](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#errors) <a href="#errors" id="errors"></a>

#### [Operator\_Paused](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_paused) <a href="#operator_paused" id="operator_paused"></a>

```solidity
error Operator_Paused();
```

#### [Operator\_Mismatch](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_mismatch) <a href="#operator_mismatch" id="operator_mismatch"></a>

```solidity
error Operator_Mismatch();
```

#### [Operator\_OnlyAdmin](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_onlyadmin) <a href="#operator_onlyadmin" id="operator_onlyadmin"></a>

```solidity
error Operator_OnlyAdmin();
```

#### [Operator\_EmptyPrice](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_emptyprice) <a href="#operator_emptyprice" id="operator_emptyprice"></a>

```solidity
error Operator_EmptyPrice();
```

#### [Operator\_WrongMarket](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_wrongmarket) <a href="#operator_wrongmarket" id="operator_wrongmarket"></a>

```solidity
error Operator_WrongMarket();
```

#### [Operator\_InvalidInput](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_invalidinput) <a href="#operator_invalidinput" id="operator_invalidinput"></a>

```solidity
error Operator_InvalidInput();
```

#### [Operator\_AssetNotFound](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_assetnotfound) <a href="#operator_assetnotfound" id="operator_assetnotfound"></a>

```solidity
error Operator_AssetNotFound();
```

#### [Operator\_RepayingTooMuch](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_repayingtoomuch) <a href="#operator_repayingtoomuch" id="operator_repayingtoomuch"></a>

```solidity
error Operator_RepayingTooMuch();
```

#### [Operator\_OnlyAdminOrRole](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_onlyadminorrole) <a href="#operator_onlyadminorrole" id="operator_onlyadminorrole"></a>

```solidity
error Operator_OnlyAdminOrRole();
```

#### [Operator\_MarketNotListed](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_marketnotlisted) <a href="#operator_marketnotlisted" id="operator_marketnotlisted"></a>

```solidity
error Operator_MarketNotListed();
```

#### [Operator\_PriceFetchFailed](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_pricefetchfailed) <a href="#operator_pricefetchfailed" id="operator_pricefetchfailed"></a>

```solidity
error Operator_PriceFetchFailed();
```

#### [Operator\_SenderMustBeToken](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_sendermustbetoken) <a href="#operator_sendermustbetoken" id="operator_sendermustbetoken"></a>

```solidity
error Operator_SenderMustBeToken();
```

#### [Operator\_UserNotWhitelisted](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_usernotwhitelisted) <a href="#operator_usernotwhitelisted" id="operator_usernotwhitelisted"></a>

```solidity
error Operator_UserNotWhitelisted();
```

#### [Operator\_MarketSupplyReached](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_marketsupplyreached) <a href="#operator_marketsupplyreached" id="operator_marketsupplyreached"></a>

```solidity
error Operator_MarketSupplyReached();
```

#### [Operator\_RepayAmountNotValid](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_repayamountnotvalid) <a href="#operator_repayamountnotvalid" id="operator_repayamountnotvalid"></a>

```solidity
error Operator_RepayAmountNotValid();
```

#### [Operator\_MarketAlreadyListed](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_marketalreadylisted) <a href="#operator_marketalreadylisted" id="operator_marketalreadylisted"></a>

```solidity
error Operator_MarketAlreadyListed();
```

#### [Operator\_OutflowVolumeReached](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_outflowvolumereached) <a href="#operator_outflowvolumereached" id="operator_outflowvolumereached"></a>

```solidity
error Operator_OutflowVolumeReached();
```

#### [Operator\_InvalidRolesOperator](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_invalidrolesoperator) <a href="#operator_invalidrolesoperator" id="operator_invalidrolesoperator"></a>

```solidity
error Operator_InvalidRolesOperator();
```

#### [Operator\_InsufficientLiquidity](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_insufficientliquidity) <a href="#operator_insufficientliquidity" id="operator_insufficientliquidity"></a>

```solidity
error Operator_InsufficientLiquidity();
```

#### [Operator\_MarketBorrowCapReached](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_marketborrowcapreached) <a href="#operator_marketborrowcapreached" id="operator_marketborrowcapreached"></a>

```solidity
error Operator_MarketBorrowCapReached();
```

#### [Operator\_InvalidCollateralFactor](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_invalidcollateralfactor) <a href="#operator_invalidcollateralfactor" id="operator_invalidcollateralfactor"></a>

```solidity
error Operator_InvalidCollateralFactor();
```

#### [Operator\_InvalidRewardDistributor](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_invalidrewarddistributor) <a href="#operator_invalidrewarddistributor" id="operator_invalidrewarddistributor"></a>

```solidity
error Operator_InvalidRewardDistributor();
```

#### [Operator\_OracleUnderlyingFetchError](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_oracleunderlyingfetcherror) <a href="#operator_oracleunderlyingfetcherror" id="operator_oracleunderlyingfetcherror"></a>

```solidity
error Operator_OracleUnderlyingFetchError();
```

#### [Operator\_Deactivate\_MarketBalanceOwed](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#operator_deactivate_marketbalanceowed) <a href="#operator_deactivate_marketbalanceowed" id="operator_deactivate_marketbalanceowed"></a>

```solidity
error Operator_Deactivate_MarketBalanceOwed();
```

### [Structs](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#structs) <a href="#structs" id="structs"></a>

#### [AccountLiquidityLocalVars](https://malda-protocol.github.io/malda-lending/src/Operator/OperatorStorage.sol/abstract.OperatorStorage.html#accountliquiditylocalvars) <a href="#accountliquiditylocalvars" id="accountliquiditylocalvars"></a>

*Local vars for avoiding stack-depth limits in calculating account liquidity. Note that `mTokenBalance` is the number of mTokens the account owns in the market, whereas `borrowBalance` is the amount of underlying that the account has borrowed.*

```solidity
struct AccountLiquidityLocalVars {
    uint256 sumCollateral;
    uint256 sumBorrowPlusEffects;
    uint256 mTokenBalance;
    uint256 borrowBalance;
    uint256 exchangeRateMantissa;
    uint256 oraclePriceMantissa;
    Exp collateralFactor;
    Exp exchangeRate;
    Exp oraclePrice;
    Exp tokensToDenom;
}
```

<br>


---

# 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://ionian.gitbook.io/malda/developer-docs-malda-lending/operator.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.
