Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c4-005 Users below crOpening cannot withdraw cash #124

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading