Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add test demonstrating the 1 wei issue * Add isBorrowingLogic to Morpho Aave V2 adaptor * Add Health Factor checks to Morpho Aave V3 borrows and withdraws. Also add tests * Add health factor checks to Aave V2 morpho withdraws and borrows. Also add tests * Add missing modifier to new test
- Loading branch information
1 parent
569d676
commit ac9547f
Showing
8 changed files
with
351 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity 0.8.16; | ||
|
||
interface IMorphoLensV2 { | ||
function getUserHealthFactor(address user) external view returns (uint256); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/modules/adaptors/Morpho/MorphoAaveV3HealthFactorLogic.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity 0.8.16; | ||
|
||
import { Math } from "src/utils/Math.sol"; | ||
import { IMorphoV3 } from "src/interfaces/external/Morpho/IMorphoV3.sol"; | ||
|
||
/** | ||
* @title Morpho Aave V3 Health Factor Logic contract. | ||
* @notice Implements health factor logic used by both | ||
* the Morpho Aave V3 A Token and debt Token adaptors. | ||
* @author crispymangoes | ||
*/ | ||
contract MorphoAaveV3HealthFactorLogic { | ||
using Math for uint256; | ||
|
||
/** | ||
* @notice Code pulled directly from Morpho Position Maanager. | ||
* https://etherscan.io/address/0x4592e45e0c5DbEe94a135720cCfF2e4353dAc6De#code | ||
*/ | ||
function _getUserHealthFactor(IMorphoV3 morpho, address user) internal view returns (uint256) { | ||
IMorphoV3.LiquidityData memory liquidityData = morpho.liquidityData(user); | ||
|
||
return | ||
liquidityData.debt > 0 | ||
? uint256(1e18).mulDivDown(liquidityData.maxDebt, liquidityData.debt) | ||
: type(uint256).max; | ||
} | ||
} |
Oops, something went wrong.