@@ -104,6 +104,9 @@ contract LiquidityProtection is ILiquidityProtection, Utils, Owned, ReentrancyGu
104104 IERC20 private immutable _govToken;
105105 ITokenGovernance private immutable _govTokenGovernance;
106106
107+ bool private _addingEnabled = true ;
108+ bool private _removingEnabled = true ;
109+
107110 /**
108111 * @dev initializes a new LiquidityProtection contract
109112 */
@@ -155,6 +158,13 @@ contract LiquidityProtection is ILiquidityProtection, Utils, Owned, ReentrancyGu
155158 _;
156159 }
157160
161+ // ensures that remove liquidity is enabled
162+ modifier removeLiquidityEnabled () {
163+ _removeLiquidityEnabled ();
164+
165+ _;
166+ }
167+
158168 // error message binary size optimization
159169 function _poolSupported (IConverterAnchor poolAnchor ) internal view {
160170 require (_settings.isPoolSupported (poolAnchor), "ERR_POOL_NOT_SUPPORTED " );
@@ -167,7 +177,15 @@ contract LiquidityProtection is ILiquidityProtection, Utils, Owned, ReentrancyGu
167177
168178 // error message binary size optimization
169179 function _addLiquidityEnabled (IConverterAnchor poolAnchor , IReserveToken reserveToken ) internal view {
170- require (! _settings.addLiquidityDisabled (poolAnchor, reserveToken), "ERR_ADD_LIQUIDITY_DISABLED " );
180+ require (
181+ _addingEnabled && ! _settings.addLiquidityDisabled (poolAnchor, reserveToken),
182+ "ERR_ADD_LIQUIDITY_DISABLED "
183+ );
184+ }
185+
186+ // error message binary size optimization
187+ function _removeLiquidityEnabled () internal view {
188+ require (_removingEnabled);
171189 }
172190
173191 // error message binary size optimization
@@ -474,6 +492,7 @@ contract LiquidityProtection is ILiquidityProtection, Utils, Owned, ReentrancyGu
474492 )
475493 external
476494 view
495+ removeLiquidityEnabled
477496 validPortion (portion)
478497 returns (
479498 uint256 ,
@@ -533,7 +552,13 @@ contract LiquidityProtection is ILiquidityProtection, Utils, Owned, ReentrancyGu
533552 * @dev removes protected liquidity from a pool and also burns governance tokens from the caller if the caller
534553 * removes network tokens
535554 */
536- function removeLiquidity (uint256 id , uint32 portion ) external override nonReentrant validPortion (portion) {
555+ function removeLiquidity (uint256 id , uint32 portion )
556+ external
557+ override
558+ nonReentrant
559+ removeLiquidityEnabled
560+ validPortion (portion)
561+ {
537562 _removeLiquidity (msg .sender , id, portion);
538563 }
539564
@@ -1449,4 +1474,26 @@ contract LiquidityProtection is ILiquidityProtection, Utils, Owned, ReentrancyGu
14491474 ) private pure returns (uint256 ) {
14501475 return x.mul (y).div (z);
14511476 }
1477+
1478+ /**
1479+ * @dev enables/disabled deposits
1480+ *
1481+ * Requirements:
1482+ *
1483+ * - the caller must be the owner of the contract
1484+ */
1485+ function enableDepositing (bool state ) external ownerOnly {
1486+ _addingEnabled = state;
1487+ }
1488+
1489+ /**
1490+ * @dev enables/disabled removals
1491+ *
1492+ * Requirements:
1493+ *
1494+ * - the caller must be the owner of the contract
1495+ */
1496+ function enableRemoving (bool state ) external ownerOnly {
1497+ _removingEnabled = state;
1498+ }
14521499}
0 commit comments