aave / aave-v3-core

This repository contains the core smart contracts of the Aave V3 protocol.
https://aave.com
Other
880 stars 574 forks source link

Unclear expected behaviour when changing asset EMode category #263

Closed LHerskind closed 2 years ago

LHerskind commented 3 years ago

Identified by: Aave team

Scope: Unclear expected behaviour when removing a borrowed asset from an EMode category. How should we handle a position, which has borrowed an asset while in EMode, but that asset is removed from the category afterwards?

Scenario:

Currently, the position is unchanged by the removal, but it would not be possible to enter a similar position for any other user.

A test for this case is available at emode.spec.ts in https://github.com/aave/aave-v3-core/tree/discuss/263-unclear-behaviour-drop-emode

The-3D commented 3 years ago

We have two possible scenarios; following the example above (USDC removed from the eMode), either USDC is being used as collateral (enjoying higher borrowing power when in eMode) or being borrowed. When USDC is being used as collateral, removing it from the eMode category automatically drops the health factor of all the users using USDC as collateral as it immediately starts using the ltv and liq threshold in normal mode. Although not ideal, this is expected behavior; it's the equivalent of dropping the liq threshold of an asset that is already being used to borrow.

When USDC is being borrowed in eMode, there is no way of removing it from the borrowed assets for the user. User will still be in eMode, he will not be able to borrow USDC anymore, but its USDC borrowed position will remain. I believe this doesnt pose a risk for the protocol. Borrowed assets are less risky for the protocol itself in terms of insolvency, and since it will not be possible to borrow anymore, the new eMode category for USDC will be respected for all the new users. It's important to note that while an asset might be removed from eMode, it will not change its underlying nature (of being a derivative of the base asset of that specific category). Even if USDC is removed from the eMode, it's still an USD pegged stablecoin so it doesnt fundamentally change the nature of the asset. What could happen is that USDC might fail to keep the peg, either up (which could potentially cause the existing eMode borrowers to be liquidated) or down (which wouldnt bring additonal risk at all).

The-3D commented 2 years ago

@LHerskind let me know if you agree with this one

foodaka commented 2 years ago

So basically if a user has the borrowed position with USDC emode and the USDC is removed, the liquidation threshold will drop to 75/80% causing a partial liquidation of the current users position?

LHerskind commented 2 years ago

If USDC is removed from eMode and then increase quickly in value after the removal, the positions may enter bad debt very quickly as the "safety-margin" is a lot smaller than we are used to.

So basically if a user has the borrowed position with USDC emode and the USDC is removed, the liquidation threshold will drop to 75/80% causing a partial liquidation of the current users position?

Depends on whether he borrowed or used it as collateral. As written, if USDC is used as collateral yes the liquidation threshold will drop MAYBE causing liquidations depending on the other assets in the user position.

The-3D commented 2 years ago

The behavior described has been discussed internally and included the technical paper. Since it's impossible to act on any individual position, the removal of an asset from eMode has to be carefully considered for its implications by governors of the protocol.