Skip to content

Commit

Permalink
Implement comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pakim249CAL committed Dec 12, 2022
1 parent 303288c commit 3409fe8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
12 changes: 1 addition & 11 deletions src/aave-v2/MorphoUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,6 @@ abstract contract MorphoUtils is MorphoStorage {
Types.AssetLiquidityData memory assetData;
Types.LiquidityStackVars memory vars;

DataTypes.UserConfigurationMap memory morphoPoolConfig = pool.getUserConfiguration(
address(this)
);
vars.poolTokensLength = marketsCreated.length;
vars.userMarkets = userMarkets[_user];

Expand All @@ -273,18 +270,11 @@ abstract contract MorphoUtils is MorphoStorage {

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

// An assumption is made here that Morpho has set this 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 3409fe8

Please sign in to comment.