@@ -23,15 +23,15 @@ import {LiquidityPool} from "./LiquidityPool.sol";
2323contract LiquidityPoolAave is LiquidityPool {
2424 using SafeERC20 for IERC20 ;
2525
26- uint256 private constant MULTIPLIER = 1e18 ;
26+ uint256 private constant MULTIPLIER = 10000 ;
2727
2828 IAavePoolAddressesProvider immutable public AAVE_POOL_PROVIDER;
2929 IAavePool immutable public AAVE_POOL;
3030 IERC20 immutable public ATOKEN;
3131 uint8 immutable public ASSETS_DECIMALS;
3232
33- uint256 public minHealthFactor;
34- uint256 public defaultLTV;
33+ uint32 public minHealthFactor;
34+ uint32 public defaultLTV;
3535
3636 mapping (address token = > uint256 ltv ) public borrowTokenLTV;
3737
@@ -55,8 +55,8 @@ contract LiquidityPoolAave is LiquidityPool {
5555 address aavePoolProvider ,
5656 address admin ,
5757 address mpcAddress_ ,
58- uint256 minHealthFactor_ ,
59- uint256 defaultLTV_
58+ uint32 minHealthFactor_ ,
59+ uint32 defaultLTV_
6060 ) LiquidityPool (liquidityToken, admin, mpcAddress_) {
6161 ASSETS_DECIMALS = IERC20Metadata (liquidityToken).decimals ();
6262 require (aavePoolProvider != address (0 ), ZeroAddress ());
@@ -68,9 +68,8 @@ contract LiquidityPoolAave is LiquidityPool {
6868 IAavePoolDataProvider poolDataProvider = IAavePoolDataProvider (provider.getPoolDataProvider ());
6969 (,,,,,bool usageAsCollateralEnabled ,,,,) = poolDataProvider.getReserveConfigurationData (liquidityToken);
7070 require (usageAsCollateralEnabled, CollateralNotSupported ());
71- minHealthFactor = minHealthFactor_;
72- defaultLTV = defaultLTV_;
73- mpcAddress = mpcAddress_;
71+ _setHealthFactor (minHealthFactor_);
72+ _setDefaultLTV (defaultLTV_);
7473 }
7574
7675 function repay (address [] calldata borrowTokens ) external override {
@@ -86,7 +85,7 @@ contract LiquidityPoolAave is LiquidityPool {
8685
8786 function setBorrowTokenLTVs (
8887 address [] calldata tokens ,
89- uint256 [] calldata ltvs
88+ uint32 [] calldata ltvs
9089 ) external onlyRole (DEFAULT_ADMIN_ROLE) {
9190 require (tokens.length == ltvs.length , InvalidLength ());
9291 for (uint256 i = 0 ; i < tokens.length ; ++ i) {
@@ -98,20 +97,28 @@ contract LiquidityPoolAave is LiquidityPool {
9897 }
9998 }
10099
101- function setDefaultLTV (uint256 defaultLTV_ ) external onlyRole (DEFAULT_ADMIN_ROLE) {
102- uint256 oldDefaultLTV = defaultLTV;
100+ function setDefaultLTV (uint32 defaultLTV_ ) external onlyRole (DEFAULT_ADMIN_ROLE) {
101+ _setDefaultLTV (defaultLTV_);
102+ }
103+
104+ function setHealthFactor (uint32 minHealthFactor_ ) external onlyRole (DEFAULT_ADMIN_ROLE) {
105+ _setHealthFactor (minHealthFactor_);
106+ }
107+
108+ // Internal functions
109+
110+ function _setDefaultLTV (uint32 defaultLTV_ ) internal {
111+ uint32 oldDefaultLTV = defaultLTV;
103112 defaultLTV = defaultLTV_;
104113 emit DefaultLTVSet (oldDefaultLTV, defaultLTV_);
105114 }
106115
107- function setHealthFactor ( uint256 minHealthFactor_ ) external onlyRole (DEFAULT_ADMIN_ROLE) {
108- uint256 oldHealthFactor = minHealthFactor;
116+ function _setHealthFactor ( uint32 minHealthFactor_ ) internal {
117+ uint32 oldHealthFactor = minHealthFactor;
109118 minHealthFactor = minHealthFactor_;
110119 emit HealthFactorSet (oldHealthFactor, minHealthFactor_);
111120 }
112121
113- // Internal functions
114-
115122 function _checkTokenLTV (address borrowToken ) private view {
116123 uint256 ltv = borrowTokenLTV[borrowToken];
117124 if (ltv == 0 ) ltv = defaultLTV;
@@ -160,7 +167,7 @@ contract LiquidityPoolAave is LiquidityPool {
160167
161168 // - Check health factor for user after borrow (can be read from aave, getUserAccountData)
162169 (,,,,,uint256 currentHealthFactor ) = AAVE_POOL.getUserAccountData (address (this ));
163- require (currentHealthFactor >= minHealthFactor, HealthFactorTooLow ());
170+ require (currentHealthFactor / ( 1e18 / MULTIPLIER) >= minHealthFactor, HealthFactorTooLow ());
164171
165172 // check ltv for token
166173 _checkTokenLTV (borrowToken);
@@ -172,7 +179,7 @@ contract LiquidityPoolAave is LiquidityPool {
172179 AAVE_POOL.withdraw (address (ASSETS), amount, to);
173180 // health factor after withdraw
174181 (,,,,,uint256 currentHealthFactor ) = AAVE_POOL.getUserAccountData (address (this ));
175- require (currentHealthFactor >= minHealthFactor, HealthFactorTooLow ());
182+ require (currentHealthFactor / ( 1e18 / MULTIPLIER) >= minHealthFactor, HealthFactorTooLow ());
176183 emit WithdrawnFromAave (to, amount);
177184 }
178185
0 commit comments