11// SPDX-License-Identifier: MIT
2-
32pragma solidity 0.6.11 ;
43pragma experimental ABIEncoderV2;
54
@@ -16,14 +15,12 @@ import "./Dependencies/console.sol";
1615import "./BorrowerOperationsStorage.sol " ;
1716import "./Dependencies/Mynt/MyntLib.sol " ;
1817import "./Interfaces/IPermit2.sol " ;
19- import "./Dependencies/reentrancy/SharedReentrancyGuard.sol " ;
2018
2119contract BorrowerOperations is
2220 LiquityBase ,
2321 BorrowerOperationsStorage ,
2422 CheckContract ,
25- IBorrowerOperations ,
26- SharedReentrancyGuard
23+ IBorrowerOperations
2724{
2825 /** CONSTANT / IMMUTABLE VARIABLE ONLY */
2926 IPermit2 public immutable permit2;
@@ -161,6 +158,25 @@ contract BorrowerOperations is
161158 emit ZEROStakingAddressChanged (_zeroStakingAddress);
162159 }
163160
161+ /*
162+ * @notice set the user's block number for opening, and do check & reset to 0 for closing
163+ *
164+ * @dev This is the function will be called by the open, close, increase, decrease trove function
165+ */
166+ function notInTheSameBlockHandler (bool _isOpening ) private {
167+ if (_isOpening) {
168+ userBlockNumber[tx .origin ] = block .number ;
169+ } else {
170+ if (userBlockNumber[tx .origin ] > 0 ) {
171+ if (userBlockNumber[tx .origin ] == block .number ) {
172+ revert ("ZeroProtocolMutex: mutex locked " );
173+ }
174+
175+ userBlockNumber[tx .origin ] = 0 ;
176+ }
177+ }
178+ }
179+
164180 function setMassetManagerAddress (address _massetManagerAddress ) external onlyOwner {
165181 massetManager = IMassetManager (_massetManagerAddress);
166182 emit MassetManagerAddressChanged (_massetManagerAddress);
@@ -205,7 +221,7 @@ contract BorrowerOperations is
205221 vars.price = priceFeed.fetchPrice ();
206222 bool isRecoveryMode = _checkRecoveryMode (vars.price);
207223
208- if (isRecoveryMode) nonReentrantCheck (true );
224+ if (isRecoveryMode) notInTheSameBlockHandler (true );
209225
210226 _requireValidMaxFeePercentage (_maxFeePercentage, isRecoveryMode);
211227 _requireTroveisNotActive (contractsCache.troveManager, msg .sender );
@@ -590,7 +606,7 @@ contract BorrowerOperations is
590606 vars.isRecoveryMode = _checkRecoveryMode (vars.price);
591607
592608 if (vars.isRecoveryMode) {
593- nonReentrantCheck (_isDebtIncrease);
609+ notInTheSameBlockHandler (_isDebtIncrease);
594610 }
595611
596612 if (_isDebtIncrease) {
0 commit comments