Operator

Git Source

Inherits: OperatorStorage, ImTokenOperationTypes, OwnableUpgradeable

Functions

constructor

Note: oz-upgrades-unsafe-allow: constructor

constructor();

initialize

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

onlyAllowedUser

modifier onlyAllowedUser(address user);

setWhitelistedUser

Sets user whitelist status

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

Parameters

NameTypeDescription
useraddressThe user address
stateboolThe new staate

enableWhitelist

Enable user whitelist

function enableWhitelist() external onlyOwner;

disableWhitelist

Disable user whitelist

function disableWhitelist() external onlyOwner;

setRolesOperator

Sets a new Operator for the market

Admin function to set a new operator

function setRolesOperator(address _roles) external onlyOwner;

setPriceOracle

Sets a new price oracle

Admin function to set a new price oracle

function setPriceOracle(address newOracle) external onlyOwner;

setCloseFactor

Sets the closeFactor used when liquidating borrows

Admin function to set closeFactor

function setCloseFactor(uint256 newCloseFactorMantissa) external onlyOwner;

Parameters

NameTypeDescription
newCloseFactorMantissauint256New close factor, scaled by 1e18

setCollateralFactor

Sets the collateralFactor for a market

Admin function to set per-market collateralFactor

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

Parameters

NameTypeDescription
mTokenaddressThe market to set the factor on
newCollateralFactorMantissauint256The new collateral factor, scaled by 1e18

setLiquidationIncentive

Sets liquidationIncentive

Admin function to set liquidationIncentive

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

Parameters

NameTypeDescription
marketaddress
newLiquidationIncentiveMantissauint256New liquidationIncentive scaled by 1e18

supportMarket

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

Admin function to set isListed and add support for the market

function supportMarket(address mToken) external onlyOwner;

Parameters

NameTypeDescription
mTokenaddressThe address of the market (token) to list

setOutflowVolumeTimeWindow

Sets outflow volume time window

function setOutflowVolumeTimeWindow(uint256 newTimeWindow) external onlyOwner;

Parameters

NameTypeDescription
newTimeWindowuint256The new reset time window

setOutflowTimeLimitInUSD

Sets outflow volume limit

when 0, it means there's no limit

function setOutflowTimeLimitInUSD(uint256 amount) external onlyOwner;

Parameters

NameTypeDescription
amountuint256The new limit

resetOutflowVolume

Resets outflow volume

function resetOutflowVolume() external onlyOwner;

checkOutflowVolumeLimit

Verifies outflow volule limit

function checkOutflowVolumeLimit(uint256 amount) external;

Parameters

NameTypeDescription
amountuint256The new limit

setMarketBorrowCaps

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

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

Parameters

NameTypeDescription
mTokensaddress[]The addresses of the markets (tokens) to change the borrow caps for
newBorrowCapsuint256[]The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing.

setMarketSupplyCaps

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

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

Parameters

NameTypeDescription
mTokensaddress[]The addresses of the markets (tokens) to change the supply caps for
newSupplyCapsuint256[]The new supply cap values in underlying to be set. A value of 0 corresponds to unlimited supplying.

setPaused

Set pause for a specific operation

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

Parameters

NameTypeDescription
mTokenaddressThe market token address
_typeImTokenOperationTypes.OperationTypeThe pause operation type
stateboolThe pause operation status

setRewardDistributor

Admin function to change the Reward Distributor

function setRewardDistributor(address newRewardDistributor) external onlyOwner;

Parameters

NameTypeDescription
newRewardDistributoraddressThe address of the new Reward Distributor

isOperator

Should return true

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

isPaused

Returns if operation is paused

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

Parameters

NameTypeDescription
mTokenaddressThe mToken to check
_typeImTokenOperationTypes.OperationTypethe operation type

getAssetsIn

Returns the assets an account has entered

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

Parameters

NameTypeDescription
_useraddressThe address of the account to pull assets for

Returns

NameTypeDescription
mTokensaddress[]A dynamic list with the assets the account has entered

checkMembership

Returns whether the given account is entered in the given asset

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

Parameters

NameTypeDescription
accountaddressThe address of the account to check
mTokenaddressThe mToken to check

Returns

NameTypeDescription
<none>boolTrue if the account is in the asset, otherwise false.

getAllMarkets

A list of all markets

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

isDeprecated

Returns true if the given mToken market has been deprecated

All borrows in a deprecated mToken market can be immediately liquidated

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

Parameters

NameTypeDescription
mTokenaddressThe market to check if deprecated

isMarketListed

Returns true/false

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

getAccountLiquidity

Determine the current account liquidity wrt collateral requirements

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

Returns

NameTypeDescription
<none>uint256account liquidity in excess of collateral requirements, account shortfall below collateral requirements)
<none>uint256

getHypotheticalAccountLiquidity

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

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

Parameters

NameTypeDescription
accountaddressThe account to determine liquidity for
mTokenModifyaddressThe market to hypothetically redeem/borrow in
redeemTokensuint256The number of tokens to hypothetically redeem
borrowAmountuint256The amount of underlying to hypothetically borrow

Returns

NameTypeDescription
<none>uint256hypothetical account liquidity in excess of collateral requirements, hypothetical account shortfall below collateral requirements)
<none>uint256

liquidateCalculateSeizeTokens

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

Used in liquidation (called in mTokenBorrowed.liquidate)

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

Parameters

NameTypeDescription
mTokenBorrowedaddressThe address of the borrowed mToken
mTokenCollateraladdressThe address of the collateral mToken
actualRepayAmountuint256The amount of mTokenBorrowed underlying to convert into mTokenCollateral tokens

Returns

NameTypeDescription
<none>uint256number of mTokenCollateral tokens to be seized in a liquidation

enterMarkets

Add assets to be included in account liquidity calculation

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

Parameters

NameTypeDescription
_mTokensaddress[]The list of addresses of the mToken markets to be enabled

enterMarketsWithSender

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

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

Parameters

NameTypeDescription
_accountaddressThe account to add for

exitMarket

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.

function exitMarket(address _mToken) external override;

Parameters

NameTypeDescription
_mTokenaddressThe address of the asset to be removed

claimMalda

Claim all the MALDA accrued by holder in all markets

function claimMalda(address holder) external override;

Parameters

NameTypeDescription
holderaddressThe address to claim MALDA for

claimMalda

Claim all the MALDA accrued by holder in the specified markets

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

Parameters

NameTypeDescription
holderaddressThe address to claim MALDA for
mTokensaddress[]The list of markets to claim MALDA in

claimMalda

Claim all MALDA accrued by the holders

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

Parameters

NameTypeDescription
holdersaddress[]The addresses to claim MALDA for
mTokensaddress[]The list of markets to claim MALDA in
borrowersboolWhether or not to claim MALDA earned by borrowing
suppliersboolWhether or not to claim MALDA earned by supplying

getUSDValueForAllMarkets

Returns USD value for all markets

function getUSDValueForAllMarkets() external view returns (uint256);

beforeWithdrawOnExtension

Checks whitelist status on withdrawOnExtension

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

Parameters

NameTypeDescription
useraddressThe user to check

beforeBorrowOnExtension

Checks whitelist status on borrowOnExtension

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

Parameters

NameTypeDescription
useraddressThe user to check

beforeRebalancing

Checks if the account should be allowed to rebalance tokens

function beforeRebalancing(address mToken) external view override;

Parameters

NameTypeDescription
mTokenaddressThe market to verify the transfer against

beforeMTokenTransfer

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

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

Parameters

NameTypeDescription
mTokenaddressThe market to verify the transfer against
srcaddressThe account which sources the tokens
dstaddressThe account which receives the tokens
transferTokensuint256The number of mTokens to transfer

beforeMTokenMint

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

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

Parameters

NameTypeDescription
mTokenaddressThe market to verify the mint against
minteraddressThe account which would get the minted tokens

afterMTokenMint

Validates mint and reverts on rejection. May emit logs.

function afterMTokenMint(address mToken) external view override;

Parameters

NameTypeDescription
mTokenaddressAsset being minted

beforeMTokenRedeem

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

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

Parameters

NameTypeDescription
mTokenaddressThe market to verify the redeem against
redeemeraddressThe account which would redeem the tokens
redeemTokensuint256The number of mTokens to exchange for the underlying asset in the market

beforeMTokenBorrow

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

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

Parameters

NameTypeDescription
mTokenaddressThe market to verify the borrow against
borroweraddressThe account which would borrow the asset
borrowAmountuint256The amount of underlying the account would borrow

beforeMTokenRepay

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

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

Parameters

NameTypeDescription
mTokenaddressThe market to verify the repay against
borroweraddressThe account which would borrowed the asset

beforeMTokenLiquidate

Checks if the liquidation should be allowed to occur

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

Parameters

NameTypeDescription
mTokenBorrowedaddressAsset which was borrowed by the borrower
mTokenCollateraladdressAsset which was used as collateral and will be seized
borroweraddressThe address of the borrower
repayAmountuint256The amount of underlying being repaid

beforeMTokenSeize

Checks if the seizing of assets should be allowed to occur

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

Parameters

NameTypeDescription
mTokenCollateraladdressAsset which was used as collateral and will be seized
mTokenBorrowedaddressAsset which was borrowed by the borrower
liquidatoraddressThe address repaying the borrow and seizing the collateral
borroweraddressThe address of the borrower

_convertMarketAmountToUSDValue

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

_activateMarket

function _activateMarket(address _mToken, address borrower) private;

_beforeRedeem

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

_getHypotheticalAccountLiquidity

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

_updateMaldaSupplyIndex

Notify reward distributor for supply index update

function _updateMaldaSupplyIndex(address mToken) private;

Parameters

NameTypeDescription
mTokenaddressThe market whose supply index to update

_updateMaldaBorrowIndex

Notify reward distributor for borrow index update

function _updateMaldaBorrowIndex(address mToken) private;

Parameters

NameTypeDescription
mTokenaddressThe market whose borrow index to update

_distributeSupplierMalda

Notify reward distributor for supplier update

function _distributeSupplierMalda(address mToken, address supplier) private;

Parameters

NameTypeDescription
mTokenaddressThe market in which the supplier is interacting
supplieraddressThe address of the supplier to distribute MALDA to

_distributeBorrowerMalda

Notify reward distributor for borrower update

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

function _distributeBorrowerMalda(address mToken, address borrower) private;

Parameters

NameTypeDescription
mTokenaddressThe market in which the borrower is interacting
borroweraddressThe address of the borrower to distribute MALDA to

_claim

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

_isDeprecated

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