Skip to content

Commit

Permalink
fix: draft for cm limit tokens support
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmikko committed Feb 17, 2023
1 parent 46efcb0 commit 2c3ef4c
Show file tree
Hide file tree
Showing 13 changed files with 1,668 additions and 1,063 deletions.
7 changes: 4 additions & 3 deletions contracts/credit/CreditConfigurator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ contract CreditConfigurator is ICreditConfigurator, ACLNonReentrantTrait {
} else {
/// DEPLOYED FOR NEW CREDIT MANAGER

/// Sets limits, fees and fastCheck parameters for the Credit Manager
/// Sets limits and fees for the Credit Manager
_setParams(
DEFAULT_FEE_INTEREST,
DEFAULT_FEE_LIQUIDATION,
Expand Down Expand Up @@ -235,8 +235,9 @@ contract CreditConfigurator is ICreditConfigurator, ACLNonReentrantTrait {

(, uint16 ltUnderlying) = creditManager.collateralTokens(0);
// Sanity check for the liquidation threshold. The LT should be less than underlying
if (liquidationThreshold > ltUnderlying)
revert IncorrectLiquidationThresholdException(); // F:[CC-5]
if (liquidationThreshold > ltUnderlying) {
revert IncorrectLiquidationThresholdException();
} // F:[CC-5]

uint16 currentLT = creditManager.liquidationThresholds(token);

Expand Down
18 changes: 11 additions & 7 deletions contracts/credit/CreditFacade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ contract CreditFacade is ICreditFacade, ReentrancyGuard {

blacklistHelper = _blacklistHelper;
isBlacklistableUnderlying = _blacklistHelper != address(0);
if (_blacklistHelper != address(0))
if (_blacklistHelper != address(0)) {
emit BlacklistHelperSet(_blacklistHelper);
}

expirable = _expirable;
}
Expand Down Expand Up @@ -476,8 +477,9 @@ contract CreditFacade is ICreditFacade, ReentrancyGuard {
// If the borrower is blacklisted, transfer the account to a special recovery contract,
// so that the attempt to transfer remaining funds to a blacklisted borrower does not
// break the liquidation. The borrower can retrieve the funds from the recovery contract afterwards.
if (helperBalance > 0)
creditManager.transferAccountOwnership(borrower, blacklistHelper); // F:[FA-56]
if (helperBalance > 0) {
creditManager.transferAccountOwnership(borrower, blacklistHelper);
} // F:[FA-56]

// Liquidates the CA and sends the remaining funds to the borrower or blacklist helper
remainingFunds = creditManager.closeCreditAccount(
Expand All @@ -494,8 +496,9 @@ contract CreditFacade is ICreditFacade, ReentrancyGuard {

/// Credit Facade increases the borrower's claimable balance in BlacklistHelper, so the
/// borrower can recover funds to a different address
if (helperBalance > 0 && remainingFunds > 1)
if (helperBalance > 0 && remainingFunds > 1) {
_increaseClaimableBalance(borrower, helperBalance);
}
}

/// @dev Checks whether borrower is blacklisted in the underlying token and, if so,
Expand Down Expand Up @@ -680,7 +683,7 @@ contract CreditFacade is ICreditFacade, ReentrancyGuard {
// Since this action can enable new tokens, Credit Manager
// needs to check that the max enabled token limit is not
// breached
creditManager.checkAndOptimizeEnabledTokens(creditAccount); // F: [FA-21C]
creditManager.checkEnabledTokensLength(creditAccount); // F: [FA-21C]
}

function addCollateral(
Expand Down Expand Up @@ -1139,8 +1142,9 @@ contract CreditFacade is ICreditFacade, ReentrancyGuard {
}

// Checks that the borrower is not blacklisted, if the underlying is blacklistable
if (_isBlacklisted(onBehalfOf) != 0)
if (_isBlacklisted(onBehalfOf) != 0) {
revert NotAllowedForBlacklistedAddressException();
}

// F:[FA-5] covers case when degenNFT == address(0)
if (degenNFT != address(0)) {
Expand Down Expand Up @@ -1265,7 +1269,7 @@ contract CreditFacade is ICreditFacade, ReentrancyGuard {
// Since this action potentially increases the number of enabled tokens,
// the Credit Manager is requested to check that the max limit for enabled tokens
// is not violated
creditManager.checkAndOptimizeEnabledTokens(creditAccount); // F: [FA-39A]
creditManager.checkEnabledTokensLength(creditAccount); // F: [FA-39A]
}

/// @dev IMPLEMENTATION: enableToken
Expand Down
Loading

0 comments on commit 2c3ef4c

Please sign in to comment.