From 90a16e3bd4f5bbe352cce98b74497a8a50036c70 Mon Sep 17 00:00:00 2001 From: owen05 Date: Fri, 18 Dec 2020 15:42:16 +0800 Subject: [PATCH] update v2.0 event --- contracts/DODOPrivatePool/impl/DPPTrader.sol | 6 ++++++ contracts/DODOVendingMachine/impl/DVMAdmin.sol | 12 ++---------- contracts/DODOVendingMachine/impl/DVMStorage.sol | 14 ++++++++++++++ contracts/DODOVendingMachine/intf/IDVM.sol | 4 ++++ contracts/Factory/DPPFactory.sol | 6 ++---- contracts/Factory/DVMFactory.sol | 6 ++---- contracts/Factory/UnownedDVMFactory.sol | 5 ++--- 7 files changed, 32 insertions(+), 21 deletions(-) diff --git a/contracts/DODOPrivatePool/impl/DPPTrader.sol b/contracts/DODOPrivatePool/impl/DPPTrader.sol index 009a4e4..facfbcc 100644 --- a/contracts/DODOPrivatePool/impl/DPPTrader.sol +++ b/contracts/DODOPrivatePool/impl/DPPTrader.sol @@ -34,6 +34,8 @@ contract DPPTrader is DPPVault { uint256 quoteAmount ); + event RChange(PMMPricing.RState newRState); + // ============ Modifiers ============ modifier isBuyAllow(address trader) { @@ -77,6 +79,7 @@ contract DPPTrader is DPPVault { if (_RState_ != newRState) { _RState_ = newRState; _BASE_TARGET_ = newBaseTarget; + emit RChange(newRState); } emit DODOSwap( @@ -113,6 +116,7 @@ contract DPPTrader is DPPVault { if (_RState_ != newRState) { _RState_ = newRState; _QUOTE_TARGET_ = newQuoteTarget; + emit RChange(newRState); } emit DODOSwap( @@ -161,6 +165,7 @@ contract DPPTrader is DPPVault { if (_RState_ != newRState) { _RState_ = newRState; _QUOTE_TARGET_ = newQuoteTarget; + emit RChange(newRState); } emit DODOSwap( address(_QUOTE_TOKEN_), @@ -187,6 +192,7 @@ contract DPPTrader is DPPVault { if (_RState_ != newRState) { _RState_ = newRState; _BASE_TARGET_ = newBaseTarget; + emit RChange(newRState); } emit DODOSwap( address(_BASE_TOKEN_), diff --git a/contracts/DODOVendingMachine/impl/DVMAdmin.sol b/contracts/DODOVendingMachine/impl/DVMAdmin.sol index 4c6e76a..480db3d 100644 --- a/contracts/DODOVendingMachine/impl/DVMAdmin.sol +++ b/contracts/DODOVendingMachine/impl/DVMAdmin.sol @@ -15,12 +15,6 @@ import {IExternalValue} from "../../lib/ExternalValue.sol"; contract DVMAdmin is InitializableOwnable { address public _DVM_; - // ============ Events ============ - - event SetLpFeeRate(uint256 newLpFeeRate); - - event SetMtFeeRate(uint256 newMtFeeRate); - function init(address owner, address dvm) external { initOwner(owner); _DVM_ = dvm; @@ -31,8 +25,7 @@ contract DVMAdmin is InitializableOwnable { // } function setLpFeeRateValue(uint256 newLpFeeRate) external onlyOwner { - IExternalValue(IDVM(_DVM_)._LP_FEE_RATE_MODEL_()).set(newLpFeeRate); - emit SetLpFeeRate(newLpFeeRate); + IDVM(_DVM_).setLpFeeRateValue(newLpFeeRate); } // function setMtFeeRateModel(address newMtFeeRateModel) external onlyOwner { @@ -40,8 +33,7 @@ contract DVMAdmin is InitializableOwnable { // } function setMtFeeRateValue(uint256 newMtFeeRate) external onlyOwner { - IExternalValue(IDVM(_DVM_)._MT_FEE_RATE_MODEL_()).set(newMtFeeRate); - emit SetMtFeeRate(newMtFeeRate); + IDVM(_DVM_).setMtFeeRateValue(newMtFeeRate); } // function setTradePermissionManager(address newTradePermissionManager) external onlyOwner { diff --git a/contracts/DODOVendingMachine/impl/DVMStorage.sol b/contracts/DODOVendingMachine/impl/DVMStorage.sol index 080dfe6..ec868fd 100644 --- a/contracts/DODOVendingMachine/impl/DVMStorage.sol +++ b/contracts/DODOVendingMachine/impl/DVMStorage.sol @@ -80,6 +80,10 @@ contract DVMStorage is InitializableOwnable, ReentrancyGuard { event SetSell(bool allow); + event SetLpFeeRate(uint256 newValue); + + event SetMtFeeRate(uint256 newValue); + // ============ Setting Functions ============ function setLpFeeRateModel(address newLpFeeRateModel) external onlyOwner { @@ -92,6 +96,16 @@ contract DVMStorage is InitializableOwnable, ReentrancyGuard { _MT_FEE_RATE_MODEL_ = IFeeRateModel(newMtFeeRateModel); } + function setLpFeeRateValue(uint256 newLpFeeRate) external onlyOwner { + _LP_FEE_RATE_MODEL_.setFeeRate(newLpFeeRate); + emit SetLpFeeRate(newLpFeeRate); + } + + function setMtFeeRateValue(uint256 newMtFeeRate) external onlyOwner { + _MT_FEE_RATE_MODEL_.setFeeRate(newMtFeeRate); + emit SetMtFeeRate(newMtFeeRate); + } + function setTradePermissionManager(address newTradePermissionManager) external onlyOwner { emit SetTradePermissionManager(address(_TRADE_PERMISSION_), newTradePermissionManager); _TRADE_PERMISSION_ = IPermissionManager(newTradePermissionManager); diff --git a/contracts/DODOVendingMachine/intf/IDVM.sol b/contracts/DODOVendingMachine/intf/IDVM.sol index 05423d2..b1fedc3 100644 --- a/contracts/DODOVendingMachine/intf/IDVM.sol +++ b/contracts/DODOVendingMachine/intf/IDVM.sol @@ -41,7 +41,11 @@ interface IDVM { //=========== admin ========== function setLpFeeRateModel(address newLpFeeRateModel) external; + function setLpFeeRateValue(uint256 newLpFeeRate) external; + function setMtFeeRateModel(address newMtFeeRateModel) external; + + function setMtFeeRateValue(uint256 newMtFeeRate) external; function setTradePermissionManager(address newTradePermissionManager) external; diff --git a/contracts/Factory/DPPFactory.sol b/contracts/Factory/DPPFactory.sol index 34291f9..0d6f625 100644 --- a/contracts/Factory/DPPFactory.sol +++ b/contracts/Factory/DPPFactory.sol @@ -41,9 +41,7 @@ contract DPPFactory is InitializableOwnable { address baseToken, address quoteToken, address creator, - address dpp, - uint256 lpFeeRate, - uint256 mtFeeRate + address dpp ); // ============ Functions ============ @@ -106,7 +104,7 @@ contract DPPFactory is InitializableOwnable { _REGISTRY_[baseToken][quoteToken].push(dppAddress); _USER_REGISTRY_[creator].push(dppAddress); - emit NewDPP(baseToken, quoteToken, creator, dppAddress, lpFeeRate, mtFeeRate); + emit NewDPP(baseToken, quoteToken, creator, dppAddress); } function _createFeeRateModel(address owner, uint256 feeRate) diff --git a/contracts/Factory/DVMFactory.sol b/contracts/Factory/DVMFactory.sol index 1ef98d6..7cce3cf 100644 --- a/contracts/Factory/DVMFactory.sol +++ b/contracts/Factory/DVMFactory.sol @@ -50,9 +50,7 @@ contract DVMFactory is InitializableOwnable { address baseToken, address quoteToken, address creator, - address dvm, - uint256 lpFeeRate, - uint256 mtFeeRate + address dvm ); // ============ Functions ============ @@ -100,7 +98,7 @@ contract DVMFactory is InitializableOwnable { } _REGISTRY_[baseToken][quoteToken].push(newVendingMachine); _USER_REGISTRY_[creator].push(newVendingMachine); - emit NewDVM(baseToken, quoteToken, creator, newVendingMachine, lpFeeRate, mtFeeRate); + emit NewDVM(baseToken, quoteToken, creator, newVendingMachine); } function _createFeeRateModel(address owner, uint256 feeRate) diff --git a/contracts/Factory/UnownedDVMFactory.sol b/contracts/Factory/UnownedDVMFactory.sol index 5ff04ac..900e00b 100644 --- a/contracts/Factory/UnownedDVMFactory.sol +++ b/contracts/Factory/UnownedDVMFactory.sol @@ -53,8 +53,7 @@ contract UnownedDVMFactory { address baseToken, address quoteToken, address creator, - address dvm, - uint256 lpFeeRate + address dvm ); // ============ Functions ============ @@ -103,7 +102,7 @@ contract UnownedDVMFactory { } _REGISTRY_[baseToken][quoteToken].push(newVendingMachine); _USER_REGISTRY_[creator].push(newVendingMachine); - emit NewUnOwnedDVM(baseToken, quoteToken, creator, newVendingMachine, lpFeeRate); + emit NewUnOwnedDVM(baseToken, quoteToken, creator, newVendingMachine); } function _createFeeRateModel(address owner, uint256 feeRate)