From c6f7ac0431de239c67a03a53d8318180c746aa19 Mon Sep 17 00:00:00 2001 From: mingda Date: Thu, 26 Nov 2020 00:41:38 +0800 Subject: [PATCH] remove operator --- contracts/DODOPrivatePool/impl/DPP.sol | 2 -- contracts/DODOPrivatePool/impl/DPPStorage.sol | 1 - contracts/DODOPrivatePool/impl/DPPVault.sol | 8 +------- test/utils/DPPContext.ts | 14 +++++++++----- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/contracts/DODOPrivatePool/impl/DPP.sol b/contracts/DODOPrivatePool/impl/DPP.sol index 38f469f..7a28f1e 100644 --- a/contracts/DODOPrivatePool/impl/DPP.sol +++ b/contracts/DODOPrivatePool/impl/DPP.sol @@ -18,7 +18,6 @@ contract DPP is DPPTrader { function init( address owner, address maintainer, - address operator, address baseTokenAddress, address quoteTokenAddress, address lpFeeRateModel, @@ -31,7 +30,6 @@ contract DPP is DPPTrader { ) external { initOwner(owner); _MAINTAINER_ = maintainer; - _OPERATOR_ = operator; _BASE_TOKEN_ = IERC20(baseTokenAddress); _QUOTE_TOKEN_ = IERC20(quoteTokenAddress); _LP_FEE_RATE_MODEL_ = IFeeRateModel(lpFeeRateModel); diff --git a/contracts/DODOPrivatePool/impl/DPPStorage.sol b/contracts/DODOPrivatePool/impl/DPPStorage.sol index 5cb37ed..4d7c976 100644 --- a/contracts/DODOPrivatePool/impl/DPPStorage.sol +++ b/contracts/DODOPrivatePool/impl/DPPStorage.sol @@ -43,7 +43,6 @@ contract DPPStorage is InitializableOwnable, ReentrancyGuard { // ============ Core Address ============ address public _MAINTAINER_; // collect maintainer fee - address public _OPERATOR_; IERC20 public _BASE_TOKEN_; IERC20 public _QUOTE_TOKEN_; diff --git a/contracts/DODOPrivatePool/impl/DPPVault.sol b/contracts/DODOPrivatePool/impl/DPPVault.sol index 83e859b..a70ef3d 100644 --- a/contracts/DODOPrivatePool/impl/DPPVault.sol +++ b/contracts/DODOPrivatePool/impl/DPPVault.sol @@ -71,13 +71,7 @@ contract DPPVault is DPPStorage { uint256 newK, uint256 baseOutAmount, uint256 quoteOutAmount - ) public { - require( - msg.sender == _OWNER_ || - (msg.sender == ISmartApprove(_DODO_SMART_APPROVE_).getSmartSwap() && - from == _OPERATOR_), - "RESET FORBIDDEN!" - ); + ) public onlyOwner { require(newK > 0 && newK <= 10**18, "K OUT OF RANGE!"); if (baseOutAmount > 0) _transferBaseOut(from, baseOutAmount); if (quoteOutAmount > 0) _transferQuoteOut(from, quoteOutAmount); diff --git a/test/utils/DPPContext.ts b/test/utils/DPPContext.ts index b5f961b..340d30d 100644 --- a/test/utils/DPPContext.ts +++ b/test/utils/DPPContext.ts @@ -67,6 +67,8 @@ export class DPPContext { var mtFeeRateModel = await contracts.newContract(contracts.CONST_FEE_RATE_MODEL_NAME) var permissionManager = await contracts.newContract(contracts.PERMISSION_MANAGER_NAME) var gasPriceSource = await contracts.newContract(contracts.EXTERNAL_VALUE_NAME) + var iSource = await contracts.newContract(contracts.EXTERNAL_VALUE_NAME) + var kSource = await contracts.newContract(contracts.EXTERNAL_VALUE_NAME) this.BASE = await contracts.newContract( contracts.MINTABLE_ERC20_CONTRACT_NAME, @@ -82,20 +84,22 @@ export class DPPContext { this.Maintainer = allAccounts[1]; this.SpareAccounts = allAccounts.slice(2, 10); - await this.DVM.methods.init( + await this.DPP.methods.init( this.Deployer, this.Maintainer, + this.Deployer, this.BASE.options.address, this.QUOTE.options.address, lpFeeRateModel.options.address, mtFeeRateModel.options.address, - permissionManager.options.address, + kSource.options.address, + iSource.options.address, gasPriceSource.options.address, - config.i, - config.k + this.Maintainer, + permissionManager.options.address, ).send(this.sendParam(this.Deployer)) - await gasPriceSource.methods.initOwner(this.Deployer).send(this.sendParam(this.Deployer)) + await gasPriceSource.methods.initOwner(this.DPP.options.address).send(this.sendParam(this.Deployer)) await gasPriceSource.methods.set(MAX_UINT256).send(this.sendParam(this.Deployer)) await lpFeeRateModel.methods.init(this.Deployer, config.lpFeeRate).send(this.sendParam(this.Deployer)) await mtFeeRateModel.methods.init(this.Deployer, config.mtFeeRate).send(this.sendParam(this.Deployer))