diff --git a/src/Size.sol b/src/Size.sol index a41e2897..38cca307 100644 --- a/src/Size.sol +++ b/src/Size.sol @@ -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 diff --git a/src/libraries/actions/Withdraw.sol b/src/libraries/actions/Withdraw.sol index 468bc71d..2b404f38 100644 --- a/src/libraries/actions/Withdraw.sol +++ b/src/libraries/actions/Withdraw.sol @@ -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; @@ -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 @@ -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);