Skip to content

Commit

Permalink
c4-005 Users below crOpening cannot withdraw cash (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviggiano committed Jul 15, 2024
1 parent e6be75f commit 6583a50
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/Size.sol
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ contract Size is ISize, SizeView, Initializable, AccessControlUpgradeable, Pausa
function withdraw(WithdrawParams calldata params) external payable override(ISize) whenNotPaused {
state.validateWithdraw(params);
state.executeWithdraw(params);
state.validateUserIsNotBelowOpeningLimitBorrowCR(msg.sender);
}

/// @inheritdoc ISize
Expand Down
4 changes: 4 additions & 0 deletions src/libraries/actions/Withdraw.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {Math} from "@src/libraries/Math.sol";
import {Errors} from "@src/libraries/Errors.sol";
import {Events} from "@src/libraries/Events.sol";

import {RiskLibrary} from "@src/libraries/RiskLibrary.sol";

struct WithdrawParams {
// The token to withdraw
address token;
Expand All @@ -25,6 +27,7 @@ struct WithdrawParams {
/// @notice Contains the logic for withdrawing tokens from the protocol
library Withdraw {
using DepositTokenLibrary for State;
using RiskLibrary for State;

function validateWithdraw(State storage state, WithdrawParams calldata params) external view {
// validte msg.sender
Expand Down Expand Up @@ -61,6 +64,7 @@ library Withdraw {
if (amount > 0) {
state.withdrawUnderlyingCollateralToken(msg.sender, params.to, amount);
}
state.validateUserIsNotBelowOpeningLimitBorrowCR(msg.sender);
}

emit Events.Withdraw(params.token, params.to, amount);
Expand Down

0 comments on commit 6583a50

Please sign in to comment.