Created
February 4, 2022 17:08
-
-
Save 0xmikko/d74c943e6ee4f0c1e3dcca67cfb3ac4a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function _fullCheck(address creditAccount) internal { | |
uint256 borrowAmountPlusInterestRateUSD = priceOracle.convertToUSD( | |
calcCreditAccountAccruedInterest(creditAccount), | |
underlyingToken | |
); | |
uint256 total; | |
uint256 tokenMask; | |
uint256 eTokens = enabledTokens[creditAccount]; | |
uint256 len = allowedTokens.length; | |
for (uint256 i = 0; i < len; ) { | |
tokenMask = 1 << i; // T:[CF-18] | |
if (eTokens & tokenMask > 0) { | |
address token = allowedTokens[i]; | |
uint256 balance = IERC20(token).balanceOf(creditAccount); // T:[CF-28] | |
// balance ==0 : T: [CF-28] | |
if (balance > 1) { | |
total += | |
priceOracle.convertToUSD(balance, token) * | |
liquidationThresholds[token]; // T:[CF-28] | |
} else { | |
_checkAndDisableToken(creditAccount, token); | |
} | |
if (total > borrowAmountPlusInterestRateUSD) break; | |
} | |
unchecked { | |
i++; | |
} | |
} // T:[CF-18] | |
// Require Hf > 1 | |
require( | |
total >= borrowAmountPlusInterestRateUSD, | |
Errors.CF_OPERATION_LOW_HEALTH_FACTOR | |
); // T:[CF-25, 33, 34] | |
fastCheckCounter[creditAccount] = 1; // T:[CF-34] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment