OperatorStorage

Git Source

Inherits: IOperator, IOperatorDefender, ExponentialNoError

Title: OperatorStorage

Author: Merge Layers Inc.

Storage contract for Operator

State Variables

CLOSE_FACTOR_MIN_MANTISSA

closeFactorMantissa must be strictly greater than this value

uint256 internal constant CLOSE_FACTOR_MIN_MANTISSA = 0.05e18

CLOSE_FACTOR_MAX_MANTISSA

closeFactorMantissa must not exceed this value

uint256 internal constant CLOSE_FACTOR_MAX_MANTISSA = 0.9e18

COLLATERAL_FACTOR_MAX_MANTISSA

No collateralFactorMantissa may exceed this value

uint256 internal constant COLLATERAL_FACTOR_MAX_MANTISSA = 0.9e18

rolesOperator

Roles

IRoles public rolesOperator

blacklistOperator

Blacklist

IBlacklister public blacklistOperator

oracleOperator

Oracle which gives the price of any given asset

address public oracleOperator

closeFactorMantissa

Multiplier used to calculate the maximum repayAmount when liquidating a borrow

uint256 public closeFactorMantissa

liquidationIncentiveMantissa

Mapping of markets to liquidation incentive mantissa

mapping(address market => uint256 incentive) public liquidationIncentiveMantissa

accountAssets

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

mapping(address account => address[] assets) public accountAssets

markets

Mapping of mTokens to market data

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

mapping(address mToken => IOperatorData.Market market) public markets

allMarkets

A list of all markets

address[] public allMarkets

borrowCaps

Mapping of mTokens to borrow caps

mapping(address mToken => uint256 cap) public borrowCaps

supplyCaps

Mapping of mTokens to supply caps

mapping(address mToken => uint256 cap) public supplyCaps

minBorrowSize

Mapping of mTokens to minimum borrow size

mapping(address mToken => uint256 size) public minBorrowSize

limitPerTimePeriod

Should return outflow limit

uint256 public limitPerTimePeriod

cumulativeOutflowVolume

Should return outflow volume

uint256 public cumulativeOutflowVolume

lastOutflowResetTimestamp

Should return last reset time for outflow check

uint256 public lastOutflowResetTimestamp

outflowResetTimeWindow

Should return the outflow volume time window

uint256 public outflowResetTimeWindow

userWhitelisted

Mapping of users to whitelist status

mapping(address user => bool whitelisted) public userWhitelisted

whitelistEnabled

Whether whitelist is enabled

bool public whitelistEnabled

_paused

Mapping of mTokens to operation types to pause status

mapping(address mToken => mapping(ImTokenOperationTypes.OperationType actionType => bool paused)) internal _paused

__gap

uint256[50] private __gap

Events

UserWhitelisted

Emitted when user whitelist status is changed

event UserWhitelisted(address indexed user, bool state);

Parameters

NameTypeDescription
useraddressAddress of the user
stateboolWhitelist state

WhitelistEnabled

Emitted when whitelist is enabled

event WhitelistEnabled();

WhitelistDisabled

Emitted when whitelist is disabled

event WhitelistDisabled();

ActionPaused

Emitted when pause status is changed

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

Parameters

NameTypeDescription
mTokenaddressMarket address
_typeImTokenOperationTypes.OperationTypeOperation type paused
stateboolNew pause state

NewBorrowCap

Emitted when borrow cap for a mToken is changed

event NewBorrowCap(address indexed mToken, uint256 newBorrowCap);

Parameters

NameTypeDescription
mTokenaddressMarket address
newBorrowCapuint256New borrow cap

NewSupplyCap

Emitted when supply cap for a mToken is changed

event NewSupplyCap(address indexed mToken, uint256 newBorrowCap);

Parameters

NameTypeDescription
mTokenaddressMarket address
newBorrowCapuint256New supply cap

MarketListed

Emitted when an admin supports a market

event MarketListed(address mToken);

Parameters

NameTypeDescription
mTokenaddressMarket listed

MarketEntered

Emitted when an account enters a market

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

Parameters

NameTypeDescription
mTokenaddressMarket entered
accountaddressAccount entering

MarketExited

Emitted when an account exits a market

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

Parameters

NameTypeDescription
mTokenaddressMarket exited
accountaddressAccount exiting

NewCloseFactor

Emitted when close factor is changed by admin

event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);

Parameters

NameTypeDescription
oldCloseFactorMantissauint256Previous close factor
newCloseFactorMantissauint256New close factor

NewCollateralFactor

Emitted when a collateral factor is changed by admin

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

Parameters

NameTypeDescription
mTokenaddressMarket address
oldCollateralFactorMantissauint256Previous collateral factor
newCollateralFactorMantissauint256New collateral factor

NewLiquidationIncentive

Emitted when liquidation incentive is changed by admin

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

Parameters

NameTypeDescription
marketaddressMarket address
oldLiquidationIncentiveMantissauint256Previous incentive
newLiquidationIncentiveMantissauint256New incentive

NewPriceOracle

Emitted when price oracle is changed

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

Parameters

NameTypeDescription
oldPriceOracleaddressPrevious price oracle
newPriceOracleaddressNew price oracle

NewRolesOperator

Event emitted when rolesOperator is changed

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

Parameters

NameTypeDescription
oldRolesaddressPrevious roles operator
newRolesaddressNew roles operator

OutflowLimitUpdated

Event emitted when outflow limit is updated

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

Parameters

NameTypeDescription
senderaddressCaller updating limit
oldLimituint256Previous limit
newLimituint256New limit

OutflowTimeWindowUpdated

Event emitted when outflow reset time window is updated

event OutflowTimeWindowUpdated(uint256 oldWindow, uint256 newWindow);

Parameters

NameTypeDescription
oldWindowuint256Previous window
newWindowuint256New window

OutflowVolumeReset

Event emitted when outflow volume has been reset

event OutflowVolumeReset();

MinBorrowSizeSet

Event emitted when min borrow size set for markets

event MinBorrowSizeSet(address[] markets, uint256[] amounts);

Parameters

NameTypeDescription
marketsaddress[]Markets being updated
amountsuint256[]Borrow size amounts

Errors

Operator_Paused

Error when action is paused

error Operator_Paused();

Operator_Mismatch

Error when data mismatch occurs

error Operator_Mismatch();

Operator_OnlyAdmin

Error when caller is not admin

error Operator_OnlyAdmin();

Operator_EmptyPrice

Error when oracle price is empty

error Operator_EmptyPrice();

Operator_WrongMarket

Error when wrong market is referenced

error Operator_WrongMarket();

Operator_InvalidInput

Error when input is invalid

error Operator_InvalidInput();

Operator_AssetNotFound

Error when asset is not found

error Operator_AssetNotFound();

Operator_RepayingTooMuch

Error when repay amount exceeds allowed

error Operator_RepayingTooMuch();

Operator_OnlyAdminOrRole

Error when caller lacks admin or role permissions

error Operator_OnlyAdminOrRole();

Operator_MarketNotListed

Error when market is not listed

error Operator_MarketNotListed();

Operator_UserBlacklisted

Error when user is blacklisted

error Operator_UserBlacklisted();

Operator_PriceFetchFailed

Error when price fetch fails

error Operator_PriceFetchFailed();

Operator_SenderMustBeToken

Error when sender must be token

error Operator_SenderMustBeToken();

Operator_UserNotWhitelisted

Error when user is not whitelisted

error Operator_UserNotWhitelisted();

Operator_MarketSupplyReached

Error when market supply cap reached

error Operator_MarketSupplyReached();

Operator_RepayAmountNotValid

Error when repay amount invalid

error Operator_RepayAmountNotValid();

Operator_MarketAlreadyListed

Error when market already listed

error Operator_MarketAlreadyListed();

Operator_OutflowVolumeReached

Error when outflow volume reached

error Operator_OutflowVolumeReached();

Operator_InvalidRolesOperator

Error when roles operator invalid

error Operator_InvalidRolesOperator();

Operator_InsufficientLiquidity

Error when insufficient liquidity

error Operator_InsufficientLiquidity();

Operator_MarketBorrowSizeNotMet

Error when borrow size not met

error Operator_MarketBorrowSizeNotMet();

Operator_MarketBorrowCapReached

Error when borrow cap reached

error Operator_MarketBorrowCapReached();

Operator_InvalidCollateralFactor

Error when collateral factor invalid

error Operator_InvalidCollateralFactor();

Operator_InvalidBlacklistOperator

Error when blacklist operator invalid

error Operator_InvalidBlacklistOperator();

Operator_OracleUnderlyingFetchError

Error when oracle underlying fetch fails

error Operator_OracleUnderlyingFetchError();

Operator_Deactivate_MarketBalanceOwed

Error when market has balance owed during deactivation

error Operator_Deactivate_MarketBalanceOwed();

Structs

AccountLiquidityLocalVars

Local vars for avoiding stack-depth limits in calculating account liquidity.

struct AccountLiquidityLocalVars {
    uint256 sumCollateral;
    uint256 sumBorrowPlusEffects;
    /// @notice Number of mTokens the account owns in the market
    uint256 mTokenBalance;
    /// @notice Amount of underlying that the account has borrowed
    uint256 borrowBalance;
    uint256 exchangeRateMantissa;
    uint256 oraclePriceMantissa;
    uint256 collateralFactorMantissa;
    uint256 liquidationIncentiveMantissa;
    uint256 borrowLimitMantissa;
    Exp collateralFactor;
    Exp exchangeRate;
    Exp oraclePrice;
    Exp tokensToDenom;
}