Skip to content

Commit 96803b3

Browse files
committed
added admin functions, added support for etherscan verification
1 parent 1ddcbf9 commit 96803b3

File tree

5 files changed

+50657
-9968
lines changed

5 files changed

+50657
-9968
lines changed

contracts/liquidity-protection/LiquidityProtection.sol

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

hardhat.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import '@nomiclabs/hardhat-ethers';
2+
import '@nomiclabs/hardhat-etherscan';
23
import '@nomiclabs/hardhat-waffle';
34
import '@typechain/hardhat';
45
import fs from 'fs';
@@ -33,6 +34,10 @@ const config: HardhatUserConfig = {
3334
allowUnlimitedContractSize: true
3435
},
3536

37+
mainnet: {
38+
url: ''
39+
},
40+
3641
...configNetworks
3742
},
3843

@@ -80,6 +85,10 @@ const config: HardhatUserConfig = {
8085
timeout: 600000,
8186
color: true,
8287
bail: loadENVKey('BAIL')
88+
},
89+
90+
etherscan: {
91+
apiKey: ''
8392
}
8493
};
8594

0 commit comments

Comments
 (0)