Skip to content

Commit

Permalink
fix: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lekhovitsky committed May 2, 2023
1 parent 328a266 commit a1dfdbb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions contracts/credit/CreditManagerV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard,
uint256 balanceBefore = _balanceOf(token, address(withdrawalManager));
_creditAccountSafeTransfer(creditAccount, token, address(withdrawalManager), amount);
amount = _balanceOf(token, address(withdrawalManager)) - balanceBefore;
if (amount > 1) {
withdrawalManager.addImmediateWithdrawal(to, token, amount);
}
withdrawalManager.addImmediateWithdrawal(to, token, amount);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion contracts/interfaces/IWithdrawalManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ interface IWithdrawalManager is IWithdrawalManagerEvents, IVersion {
/// @param account Account to add immediate withdrawal for
/// @param token Token to withdraw
/// @param amount Amount to withdraw
/// @custom:expects `amount` is greater than 1
/// @custom:expects Credit manager transferred `amount` of `token` to this contract prior to calling this function
function addImmediateWithdrawal(address account, address token, uint256 amount) external;

Expand Down
9 changes: 6 additions & 3 deletions contracts/support/WithdrawalManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import {ACLTrait} from "../traits/ACLTrait.sol";
/// There are two kinds of withdrawals: immediate and scheduled.
/// - Immediate withdrawals can be claimed, well, immediately, and exist to support liquidation of accounts
/// whose owners are blacklisted in credit manager's underlying.
/// Also, when scheduled withdrawals are claimed, they turn into immediate withdrawals.
/// - Scheduled withdrawals can be claimed after a certain delay, and exist to support partial withdrawals
/// from credit accounts. One credit account can have up to two immature withdrawals at the same time.
/// Additional rules for scheduled withdrawals:
/// + if account is closed, both mature and immature withdrawals are claimed (turned into immediate withdrawals)
/// + if account is closed, both mature and immature withdrawals are claimed
/// + if account is liquidated, immature withdrawals are cancelled and mature ones are claimed
/// + if account is liquidated in emergency mode, both mature and immature withdrawals are cancelled
/// + in emergency mode, claiming is disabled
Expand Down Expand Up @@ -91,8 +92,10 @@ contract WithdrawalManager is IWithdrawalManager, ACLTrait {

/// @dev Increases account's immediately withdrawable balance of token
function _addImmediateWithdrawal(address account, address token, uint256 amount) internal {
immediateWithdrawals[account][token] += amount;
emit AddImmediateWithdrawal(account, token, amount);
if (amount > 1) {
immediateWithdrawals[account][token] += amount;
emit AddImmediateWithdrawal(account, token, amount);
}
}

/// --------------------- ///
Expand Down

0 comments on commit a1dfdbb

Please sign in to comment.