Skip to content

Commit

Permalink
Merge pull request #1542 from morpho-dao/fix/spearbit-25
Browse files Browse the repository at this point in the history
Remove set as collateral (Spearbit #25)
  • Loading branch information
pakim249CAL committed Dec 13, 2022
2 parents c627b74 + 6cf76cc commit 74af574
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 36 deletions.
11 changes: 0 additions & 11 deletions src/aave-v2/MorphoGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -357,17 +357,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.
Expand Down
9 changes: 1 addition & 8 deletions src/aave-v2/MorphoUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -285,18 +285,11 @@ abstract contract MorphoUtils is MorphoStorage {

if (vars.poolToken != _poolToken) _updateIndexes(vars.poolToken);

// 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();

// 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;
}
Expand Down
17 changes: 0 additions & 17 deletions test/aave-v2/TestBorrow.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -247,23 +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));

morpho.setAssetAsCollateral(aDai, false);

hevm.expectRevert(EntryPositionsManager.UnauthorisedBorrow.selector);
borrower1.borrow(aUsdc, to6Decimals(amount));
}

function testBorrowLargerThanDeltaShouldClearDelta() public {
// Allows only 10 unmatch suppliers.

Expand Down

0 comments on commit 74af574

Please sign in to comment.