OperatorStorage
Inherits: IOperator, IOperatorDefender, ExponentialNoError
State Variables
rolesOperator
Roles manager
IRoles public rolesOperator;
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
Multiplier representing the discount on collateral that a liquidator receives
mapping(address => uint256) public liquidationIncentiveMantissa;
accountAssets
Per-account mapping of "assets you are in", capped by maxAssets
mapping(address => address[]) public accountAssets;
markets
Official mapping of mTokens -> Market metadata
Used e.g. to determine if a market is supported
mapping(address => IOperatorData.Market) public markets;
allMarkets
A list of all markets
address[] public allMarkets;
borrowCaps
Borrow caps enforced by borrowAllowed for each mToken address. Defaults to zero which corresponds to unlimited borrowing.
mapping(address => uint256) public borrowCaps;
supplyCaps
Supply caps enforced by supplyAllowed for each mToken address. Defaults to zero which corresponds to unlimited supplying.
mapping(address => uint256) public supplyCaps;
rewardDistributor
Reward Distributor to markets supply and borrow (including protocol token)
address public rewardDistributor;
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
Returns true/false for user
mapping(address => bool) public userWhitelisted;
whitelistEnabled
bool public whitelistEnabled;
_paused
mapping(address => mapping(ImTokenOperationTypes.OperationType => bool)) internal _paused;
CLOSE_FACTOR_MIN_MANTISSA
uint256 internal constant CLOSE_FACTOR_MIN_MANTISSA = 0.05e18;
CLOSE_FACTOR_MAX_MANTISSA
uint256 internal constant CLOSE_FACTOR_MAX_MANTISSA = 0.9e18;
COLLATERAL_FACTOR_MAX_MANTISSA
uint256 internal constant COLLATERAL_FACTOR_MAX_MANTISSA = 0.9e18;
Events
UserWhitelisted
Emitted when user whitelist status is changed
event UserWhitelisted(address indexed user, bool state);
WhitelistEnabled
event WhitelistEnabled();
WhitelistDisabled
event WhitelistDisabled();
ActionPaused
Emitted when pause status is changed
event ActionPaused(address indexed mToken, ImTokenOperationTypes.OperationType _type, bool state);
NewRewardDistributor
Emitted when reward distributor is changed
event NewRewardDistributor(address indexed oldRewardDistributor, address indexed newRewardDistributor);
NewBorrowCap
Emitted when borrow cap for a mToken is changed
event NewBorrowCap(address indexed mToken, uint256 newBorrowCap);
NewSupplyCap
Emitted when supply cap for a mToken is changed
event NewSupplyCap(address indexed mToken, uint256 newBorrowCap);
MarketListed
Emitted when an admin supports a market
event MarketListed(address mToken);
MarketEntered
Emitted when an account enters a market
event MarketEntered(address indexed mToken, address indexed account);
MarketExited
Emitted when an account exits a market
event MarketExited(address indexed mToken, address indexed account);
NewCloseFactor
Emitted Emitted when close factor is changed by admin
event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);
NewCollateralFactor
Emitted when a collateral factor is changed by admin
event NewCollateralFactor(
address indexed mToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa
);
NewLiquidationIncentive
Emitted when liquidation incentive is changed by admin
event NewLiquidationIncentive(
address market, uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa
);
NewPriceOracle
Emitted when price oracle is changed
event NewPriceOracle(address indexed oldPriceOracle, address indexed newPriceOracle);
NewRolesOperator
Event emitted when rolesOperator is changed
event NewRolesOperator(address indexed oldRoles, address indexed newRoles);
OutflowLimitUpdated
Event emitted when outflow limit is updated
event OutflowLimitUpdated(address indexed sender, uint256 oldLimit, uint256 newLimit);
OutflowTimeWindowUpdated
Event emitted when outflow reset time window is updated
event OutflowTimeWindowUpdated(uint256 oldWindow, uint256 newWindow);
OutflowVolumeReset
Event emitted when outflow volume has been reset
event OutflowVolumeReset();
Errors
Operator_Paused
error Operator_Paused();
Operator_Mismatch
error Operator_Mismatch();
Operator_OnlyAdmin
error Operator_OnlyAdmin();
Operator_EmptyPrice
error Operator_EmptyPrice();
Operator_WrongMarket
error Operator_WrongMarket();
Operator_InvalidInput
error Operator_InvalidInput();
Operator_AssetNotFound
error Operator_AssetNotFound();
Operator_RepayingTooMuch
error Operator_RepayingTooMuch();
Operator_OnlyAdminOrRole
error Operator_OnlyAdminOrRole();
Operator_MarketNotListed
error Operator_MarketNotListed();
Operator_PriceFetchFailed
error Operator_PriceFetchFailed();
Operator_SenderMustBeToken
error Operator_SenderMustBeToken();
Operator_UserNotWhitelisted
error Operator_UserNotWhitelisted();
Operator_MarketSupplyReached
error Operator_MarketSupplyReached();
Operator_RepayAmountNotValid
error Operator_RepayAmountNotValid();
Operator_MarketAlreadyListed
error Operator_MarketAlreadyListed();
Operator_OutflowVolumeReached
error Operator_OutflowVolumeReached();
Operator_InvalidRolesOperator
error Operator_InvalidRolesOperator();
Operator_InsufficientLiquidity
error Operator_InsufficientLiquidity();
Operator_MarketBorrowCapReached
error Operator_MarketBorrowCapReached();
Operator_InvalidCollateralFactor
error Operator_InvalidCollateralFactor();
Operator_InvalidRewardDistributor
error Operator_InvalidRewardDistributor();
Operator_OracleUnderlyingFetchError
error Operator_OracleUnderlyingFetchError();
Operator_Deactivate_MarketBalanceOwed
error Operator_Deactivate_MarketBalanceOwed();
Structs
AccountLiquidityLocalVars
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.
struct AccountLiquidityLocalVars {
uint256 sumCollateral;
uint256 sumBorrowPlusEffects;
uint256 mTokenBalance;
uint256 borrowBalance;
uint256 exchangeRateMantissa;
uint256 oraclePriceMantissa;
Exp collateralFactor;
Exp exchangeRate;
Exp oraclePrice;
Exp tokensToDenom;
}