Skip to content

Instantly share code, notes, and snippets.

@0xmikko
Created February 4, 2022 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xmikko/d74c943e6ee4f0c1e3dcca67cfb3ac4a to your computer and use it in GitHub Desktop.
Save 0xmikko/d74c943e6ee4f0c1e3dcca67cfb3ac4a to your computer and use it in GitHub Desktop.
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