Exec module
-
liquidity
,detailedLiquidity
,getPrice
, andgetPriceFull
- These functions have had their re-entrancy guards removed, since all they do is
delegatecall
to methods inRiskManager
that are views (as of the previous update). Ideally we would like to mark these functions as views themselves, however the solidity compiler does not allow a function that usesdelegatecall
to be a view. - To get around this compiler limitation, a
staticDelegate
modifier is added: This is an empty modifier that has no effect on the compiled code, but instead signals to our build system that such methods are safe to be invoked withstaticcall
and so their exported interfaces are adjusted to be views.
- These functions have had their re-entrancy guards removed, since all they do is
-
usePermit
,usePermitAllowed
,usePermitPacked
- These are new functions that allow a user to invoke
permit()
on token contracts so that signed permit messages can be applied within batch transactions, and users don’t need to issue separate approval transactions. - There are three variations because in order to support the most common variants implemented by tokens.
- Although these methods allow an external user to cause the Euler contract to call an arbitrary external address, there are restrictions in place to prevent this from causing harm:
- The target address must’ve been activated on Euler so it needs to be at least a partially compliant ERC-20 token with a uniswap pair, and cannot be an internal Euler contract
- The only function signatures allowed are the 3 identified common permit signatures
- The
owner
/holder
parameter must be the address that is invoking the function, and thespender
parameter is always the Euler contract address.
- These are new functions that allow a user to invoke
-
doStaticCall
- This is a new view method that calls
staticcall
on an arbitrary address with arbitrary arguments - It is useful for querying the state of the blockchain within a batch transaction that is invoked off-chain (ie using the
callStatic
ethers method), to determine what the updated chain state would be after applying a batch. This will be useful for our “Transaction Builder 2.0” re-design project.
- This is a new view method that calls
EToken module
-
convertBalanceToUnderlying
andconvertUnderlyingToBalance
view functions were added- These allow convenient conversion between internal EToken accounting units and underlying units, which will be helpful for integrations
-
transferFromMax
- A wrapper method that allows users to transfer their entire EToken balances
- Useful in batch transactions after a swap, where you don’t necessarily know the precise balance you will have at transaction creation time.
RiskManager module
- Self collateralisation
- The
computeLiquidityRaw
function has been refactored to implement special collateralisation logic for the case where an account has assets and liabilities on the same asset. In the normal case, rational users would not do this, since they will be paying more interest than they are receiving and have no exposure to price movements. However, with liquidity mining users who take out loans will receive EUL tokens as compensation, which can compensate for this loss due to interest. - A new constant
SELF_COLLATERAL_FACTOR
was added, which represents the effective collateral factor available for self-collaterised loans. This defaults to 0.95 (20x leverage). - In order to simplify the analysis of liquidations, self-collateralised loans are always borrow isolated, even if the asset itself is not borrow isolated.
- The
Liquidation
- When a self-collateralised loan is liquidated, the entire self-collateralised debt is allowed to be repaid. This simplifies the analysis of the liquidation.
- A divide by 0 error will no longer be thrown during a liquidation if the borrow factor is set to 0.
Swap
- Bugfix: During a swap, when the new eToken amount was being credited, the
poolSize
member of AssetCache was updated assuming the token had 18 decimals. In cases where the underlying asset has fewer decimals, this caused theAssetStatus
log entry to contain an incorrect value forpoolSize
. Additionally, this incorrect value was used as an input to compute the new interest rate on the asset. Fortunately this effect is typically very small and the interest rate is corrected the next time any operation is performed on the asset.
Updates to shared code/libraries
-
An optimisation to
unpackTrailingParamMsgSender
andunpackTrailingParams
will save a small amount of gas when calling functions in most modules. -
There was a bugfix to
transferBorrow
, but all the contracts that actually use this code were already deployed.