From 6882710056fbb28b9875680503c4c93045bfdadf Mon Sep 17 00:00:00 2001 From: patrick Date: Thu, 8 Dec 2022 13:35:11 -0500 Subject: [PATCH 1/3] Remove set as collateral --- src/aave-v2/MorphoGovernance.sol | 11 ----------- test/aave-v2/TestBorrow.t.sol | 3 ++- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/aave-v2/MorphoGovernance.sol b/src/aave-v2/MorphoGovernance.sol index 2015ac2fa..7d3e0f2b3 100644 --- a/src/aave-v2/MorphoGovernance.sol +++ b/src/aave-v2/MorphoGovernance.sol @@ -401,17 +401,6 @@ abstract contract MorphoGovernance is MorphoUtils { emit IsDeprecatedSet(_poolToken, _isDeprecated); } - /// @notice Sets a market's asset as collateral. - /// @param _poolToken The address of the market to (un)set as collateral. - /// @param _assetAsCollateral True to set the asset as collateral (True by default). - function setAssetAsCollateral(address _poolToken, bool _assetAsCollateral) - external - onlyOwner - isMarketCreated(_poolToken) - { - pool.setUserUseReserveAsCollateral(market[_poolToken].underlyingToken, _assetAsCollateral); - } - /// @notice Increases peer-to-peer deltas, to put some liquidity back on the pool. /// @dev The current Morpho supply on the pool might not be enough to borrow `_amount` before resuppling it. /// In this case, consider calling multiple times this function. diff --git a/test/aave-v2/TestBorrow.t.sol b/test/aave-v2/TestBorrow.t.sol index 6dea58d11..5efe02eae 100644 --- a/test/aave-v2/TestBorrow.t.sol +++ b/test/aave-v2/TestBorrow.t.sol @@ -258,7 +258,8 @@ contract TestBorrow is TestSetup { supplier1.approve(usdc, to6Decimals(amount)); supplier1.supply(aUsdc, to6Decimals(amount)); - morpho.setAssetAsCollateral(aDai, false); + vm.prank(address(morpho)); + pool.setUserUseReserveAsCollateral(dai, false); hevm.expectRevert(EntryPositionsManager.UnauthorisedBorrow.selector); borrower1.borrow(aUsdc, to6Decimals(amount)); From 02d6aac66c22e8bf24890c17345eb8b86355bbad Mon Sep 17 00:00:00 2001 From: patrick Date: Mon, 12 Dec 2022 17:36:15 -0500 Subject: [PATCH 2/3] Implement comments --- src/aave-v2/MorphoUtils.sol | 9 +-------- test/aave-v2/TestBorrow.t.sol | 18 ------------------ 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/src/aave-v2/MorphoUtils.sol b/src/aave-v2/MorphoUtils.sol index ffb4a6b16..6e7c50efe 100644 --- a/src/aave-v2/MorphoUtils.sol +++ b/src/aave-v2/MorphoUtils.sol @@ -273,18 +273,11 @@ abstract contract MorphoUtils is MorphoStorage { if (vars.poolToken != _poolToken) _updateIndexes(vars.poolToken); + // Assumes that the Morpho contract has enabled the asset as collateral in the underlying pool. (assetData.ltv, assetData.liquidationThreshold, , assetData.decimals, ) = pool .getConfiguration(vars.underlyingToken) .getParamsMemory(); - // LTV and liquidation threshold should be zero if Morpho has not enabled this asset as collateral. - if ( - !morphoPoolConfig.isUsingAsCollateral(pool.getReserveData(vars.underlyingToken).id) - ) { - assetData.ltv = 0; - assetData.liquidationThreshold = 0; - } - unchecked { assetData.tokenUnit = 10**assetData.decimals; } diff --git a/test/aave-v2/TestBorrow.t.sol b/test/aave-v2/TestBorrow.t.sol index 5efe02eae..fc56b15f3 100644 --- a/test/aave-v2/TestBorrow.t.sol +++ b/test/aave-v2/TestBorrow.t.sol @@ -247,24 +247,6 @@ contract TestBorrow is TestSetup { borrower1.borrow(aUsdc, amount); } - function testShouldNotBorrowWithDisabledCollateral() public { - uint256 amount = 100 ether; - - borrower1.approve(dai, type(uint256).max); - borrower1.supply(aDai, amount * 10); - - // Give Morpho a position on the pool to be able to unset the DAI asset as collateral. - // Without this position on the pool, it's not possible to do so. - supplier1.approve(usdc, to6Decimals(amount)); - supplier1.supply(aUsdc, to6Decimals(amount)); - - vm.prank(address(morpho)); - pool.setUserUseReserveAsCollateral(dai, false); - - hevm.expectRevert(EntryPositionsManager.UnauthorisedBorrow.selector); - borrower1.borrow(aUsdc, to6Decimals(amount)); - } - function testBorrowLargerThanDeltaShouldClearDelta() public { // Allows only 10 unmatch suppliers. From 6cf76cc395229b13784a66122bc2a3c038b09626 Mon Sep 17 00:00:00 2001 From: Patrick Kim Date: Tue, 13 Dec 2022 09:35:58 -0500 Subject: [PATCH 3/3] Update src/aave-v2/MorphoUtils.sol Co-authored-by: Romain Milon Signed-off-by: Patrick Kim --- src/aave-v2/MorphoUtils.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aave-v2/MorphoUtils.sol b/src/aave-v2/MorphoUtils.sol index 6e7c50efe..5e4c71151 100644 --- a/src/aave-v2/MorphoUtils.sol +++ b/src/aave-v2/MorphoUtils.sol @@ -273,7 +273,7 @@ abstract contract MorphoUtils is MorphoStorage { if (vars.poolToken != _poolToken) _updateIndexes(vars.poolToken); - // Assumes that the Morpho contract has enabled the asset as collateral in the underlying pool. + // Assumes that the Morpho contract has not disabled the asset as collateral in the underlying pool. (assetData.ltv, assetData.liquidationThreshold, , assetData.decimals, ) = pool .getConfiguration(vars.underlyingToken) .getParamsMemory();