Shared Changes
Some changes have been made to files that are shared between all/many of the modules below.
computeExchangeRatehas been modified to support the case where ETokens exist on the pool but no actual deposits have been made yet. The exchange rate is defined to be 1:1 in this state. This change allows anINITIAL_RESERVESEToken balance to be allocated to the reserves at market activation time.- Increase the gas allocated to the
balanceOfmethod to 200k.- Some honest tokens that implement complex logic in the balanceOf method can exceed the previous 20k limit, for example stETH.
- Even if every entered market exceeded this gas limit, the total gas usage (2m) would still be below the block gas limit, so liquidations would not be prevented.
reentrancyLockhas been marked asinternalto be explicit about storage visibility.- New events and constants will show up in all diffs, even though each are only used by a subset of modules.
- Some modules haven’t been upgraded in a while, so they will have some scaling by
assetCache.underlyingDecimalsScalerin their shared utilities. These are unused (modules that used them have already been upgraded).
DToken
flashLoanfeature: This new function support gas-efficient flash loans. The underlying tokens are transferred to themsgSender, and then a callback is invoked onmsgSender. After this callback completes, the contract verifies that the loaned tokens have been transferred back.approveDebtwas marked asnonReentrantfor consistency’s sake (we don’t believe this is actually required for security).transferwas marked asreentrantOK(no-op). The reentrancy check is done in thetransferFrommethod.
EToken
donateToReservesfeature: This allows users to donate some of their ETokens to the reserves. This may be useful for certain wrapper contracts, and potentially could be a better way to burn “dust” in an account (for gas refund purposes).approveSubAccountwas marked asnonReentrantfor consistency’s sake (we don’t believe this is actually required for security).transferandtransferFromMaxwere marked asreentrantOK(no-op). The reentrancy check is done in thetransferFrommethod.
Exec
The changes to this module break the external interface: The UI already seamlessly supports both old and new versions, and we will be coordinating with bot runners to upgrade to the new interface.
batchDispatchno longer returns results from a batch execution, since this was an unnecessary gas expense. Batches are typically only used by EOAs, since smart contracts can simply make multiple calls.batchDispatchExtrahas been deleted.batchDispatchSimulatehas been added. This method executes the items in the batch but then throws a customBatchDispatchSimulationerror that contains the batch item execution results. This way users can see their batch results even if the batch would subsequently have failed due to collateral violation.
Governance
- New
setChainlinkPriceFeedfunction allows the configuration of a chainlink feed for an asset. setPricingConfignow allows the setting of a new CHAINLINK pricing type.convertReservesperforms a couple additional checks:- The reserves cannot be depleted below
INITIAL_RESERVES - If the account receiving the reserves has outstanding debts in this token, check the account’s liquidity to prevent an account from entering borrow isolation due to a self-collateralised loan.
- The reserves cannot be depleted below
- Since this module has not been upgraded recently, it also has a minor gas optimisation in
unpackTrailingParamMsgSenderandunpackTrailingParamsthat was previously deployed to the other modules, as well as some changes to constants and interfaces that don’t affect this module.
Liquidation
- No changes, other than the shared changes described above.
Markets
- When creating a market, start its initial reserves off at
INITIAL_RESERVESto prevent initial deposit rounding issues. - New view methods:
dTokenToUnderlyinggetChainlinkPriceFeedConfig
RiskManager
- Support CHAINLINK pricing type.
- The
getPriceandgetPriceFullmethods have been changed to useinternalLoadAssetCacheROso that they don’t fail when invoked by a method that has acquired the reentrancy guard (ie during a liquidation).
Swap
- No changes, other than the shared changes described above.