The MErc20Delegator delegate calls into the MErc20Delegate contract. This allows the implementation to be upgraded at a future point in time if needed.
Summary of Functions and Events in the MErc20Delegator Contract:
-
Constructor:
- Initializes the MErc20Delegator contract with the provided parameters.
- Sets the admin as the contract creator during initialization.
- Calls the "initialize" function on the implementation contract with the provided parameters.
- Sets the new implementation address.
- Sets the proper admin after initialization.
-
_setImplementation:
- Called by the admin to update the implementation of the delegator contract.
- If "allowResign" is true, it calls "_resignImplementation" on the old implementation.
- Updates the implementation address to the new implementation provided.
- Calls "_becomeImplementation" on the new implementation with the provided "becomeImplementationData".
- Emits a "NewImplementation" event.
-
mint:
- Sender supplies assets into the market and receives mTokens in exchange.
- Accrues interest regardless of the operation's success.
-
mintWithPermit:
- Supply assets without a 2-step approval process using EIP-2612 permit.
- Calls the underlying token's "permit()" function and assumes success.
-
redeem:
- Sender redeems mTokens in exchange for the underlying asset.
- Accrues interest regardless of the operation's success.
-
redeemUnderlying:
- Sender redeems mTokens for a specified amount of underlying asset.
- Accrues interest regardless of the operation's success.
-
borrow:
- Sender borrows assets from the protocol to their own address.
-
repayBorrow:
- Sender repays their own borrow.
-
repayBorrowBehalf:
- Sender repays a borrow on behalf of another borrower.
-
liquidateBorrow:
- Sender liquidates a borrower's collateral, transferring it to the liquidator.
-
transfer:
- Transfer
amount
mTokens frommsg.sender
todst
.
- Transfer
-
transferFrom:
- Transfer
amount
mTokens fromsrc
todst
with approval.
- Transfer
-
approve:
- Approve
spender
to transfer up toamount
frommsg.sender
.
- Approve
-
allowance:
- Get the current allowance from
owner
forspender
.
- Get the current allowance from
-
balanceOf:
- Get the mToken balance of the
owner
.
- Get the mToken balance of the
-
balanceOfUnderlying:
- Get the underlying balance of the
owner
, accruing interest.
- Get the underlying balance of the
-
getAccountSnapshot:
- Get a snapshot of the account's balances and the cached exchange rate.
-
borrowRatePerTimestamp:
- Returns the current per-timestamp borrow interest rate for this mToken.
-
supplyRatePerTimestamp:
- Returns the current per-timestamp supply interest rate for this mToken.
-
totalBorrowsCurrent:
- Returns the current total borrows plus accrued interest.
-
borrowBalanceCurrent:
- Accrue interest to the updated borrowIndex and calculate the account's borrow balance.
-
borrowBalanceStored:
- Return the borrow balance of an account based on stored data.
-
exchangeRateCurrent:
- Accrue interest and return the up-to-date exchange rate.
-
exchangeRateStored:
- Calculate the exchange rate from the underlying to the mToken without accruing interest.
-
getCash:
- Get the cash balance of this mToken in the underlying asset.
-
accrueInterest:
- Apply accrued interest to total borrows and reserves.
-
seize:
- Transfer collateral tokens (this market) to the liquidator during liquidation.
-
sweepToken:
- Sweep accidental ERC-20 transfers to this contract to the admin (timelock).
- callable only by the admin
-
Admin Functions:
- _setPendingAdmin: Begins the transfer of admin rights.
- _setComptroller: Sets a new comptroller for the market.
- _setReserveFactor: Accrues interest and sets a new reserve factor for the protocol.
- _acceptAdmin: Accepts transfer of admin rights.
- _addReserves: Accrues interest and adds reserves by transferring from admin.
- _reduceReserves: Accrues interest and reduces reserves by transferring to admin.
- _setInterestRateModel: Accrues interest and updates the interest rate model.
- _setProtocolSeizeShare: Accrues interest and sets a new protocol seize share.
-
Delegate Functions:
- delegateTo: Internal method to delegate execution to another contract.
- delegateToImplementation: Delegates execution to the implementation contract.
- delegateToViewImplementation: Delegates execution to an implementation contract with view functions.
-
Fallback Function:
- Delegates all other functions to the current implementation contract.