From 196d424e5a1c75edb1fc7be2345e86bb5977bfea Mon Sep 17 00:00:00 2001 From: mingda Date: Mon, 30 Nov 2020 09:59:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86DVM=20&=20DPP=20admin/factory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/DODOPrivatePool/impl/DPPAdmin.sol | 5 +++-- contracts/DODOVendingMachine/impl/DVMAdmin.sol | 5 +++-- .../DODOVendingMachine/impl/DVMStorage.sol | 6 +++--- contracts/DODOVendingMachine/impl/DVMVault.sol | 2 -- contracts/Factory/DPPFactory.sol | 18 ++++++++++++++++++ contracts/Factory/DVMFactory.sol | 18 ++++++++++++++++++ 6 files changed, 45 insertions(+), 9 deletions(-) diff --git a/contracts/DODOPrivatePool/impl/DPPAdmin.sol b/contracts/DODOPrivatePool/impl/DPPAdmin.sol index 68b56bd..6b64bc8 100644 --- a/contracts/DODOPrivatePool/impl/DPPAdmin.sol +++ b/contracts/DODOPrivatePool/impl/DPPAdmin.sol @@ -104,7 +104,8 @@ contract DPPAdmin is InitializableOwnable { } // ============ Admin Version Control ============ - function version() external pure returns (uint256) { - return 100; // 1.0.0 + + function version() external pure returns (string memory) { + return "DPPAdmin 1.0.0"; // 1.0.0 } } diff --git a/contracts/DODOVendingMachine/impl/DVMAdmin.sol b/contracts/DODOVendingMachine/impl/DVMAdmin.sol index 6ac17a8..45cb869 100644 --- a/contracts/DODOVendingMachine/impl/DVMAdmin.sol +++ b/contracts/DODOVendingMachine/impl/DVMAdmin.sol @@ -57,7 +57,8 @@ contract DVMAdmin is InitializableOwnable { } // ============ Admin Version Control ============ - function version() external pure returns (uint256) { - return 100; // 1.0.0 + + function version() external pure returns (string memory) { + return "DVMAdmin 1.0.0"; // 1.0.0 } } diff --git a/contracts/DODOVendingMachine/impl/DVMStorage.sol b/contracts/DODOVendingMachine/impl/DVMStorage.sol index 1c269e3..075cc41 100644 --- a/contracts/DODOVendingMachine/impl/DVMStorage.sol +++ b/contracts/DODOVendingMachine/impl/DVMStorage.sol @@ -49,13 +49,13 @@ contract DVMStorage is InitializableOwnable, ReentrancyGuard { mapping(address => uint256) internal _SHARES_; mapping(address => mapping(address => uint256)) internal _ALLOWED_; + // ================= Permit ====================== - // ================= Permit ====================== bytes32 public DOMAIN_SEPARATOR; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); - bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; + bytes32 + public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; mapping(address => uint256) public nonces; - // =============================================== // ============ Variables for Pricing ============ diff --git a/contracts/DODOVendingMachine/impl/DVMVault.sol b/contracts/DODOVendingMachine/impl/DVMVault.sol index 49aa374..26f6abf 100644 --- a/contracts/DODOVendingMachine/impl/DVMVault.sol +++ b/contracts/DODOVendingMachine/impl/DVMVault.sol @@ -189,6 +189,4 @@ contract DVMVault is DVMStorage { _approve(owner, spender, value); } // =========================================================================== - - // function approveAndCall() } diff --git a/contracts/Factory/DPPFactory.sol b/contracts/Factory/DPPFactory.sol index c5a5150..81f8038 100644 --- a/contracts/Factory/DPPFactory.sol +++ b/contracts/Factory/DPPFactory.sol @@ -17,6 +17,8 @@ import {IDPPAdmin} from "../DODOPrivatePool/intf/IDPPAdmin.sol"; import {IPermissionManager} from "../lib/PermissionManager.sol"; contract DPPFactory is Ownable { + // ============ Templates ============ + address public _CLONE_FACTORY_; address public _DPP_TEMPLATE_; address public _DPP_ADMIN_TEMPLATE_; @@ -26,11 +28,24 @@ contract DPPFactory is Ownable { address public _VALUE_SOURCE_; address public _DODO_SMART_APPROVE_; + // ============ Registry ============ + // base -> quote -> DPP address list mapping(address => mapping(address => address[])) public _REGISTRY_; // creator -> DPP address list mapping(address => address[]) public _USER_REGISTRY_; + // ============ Events ============ + + event NewDPP( + address indexed baseToken, + address indexed quoteToken, + address indexed creator, + address dpp + ); + + // ============ Functions ============ + constructor( address cloneFactory, address dppTemplate, @@ -89,6 +104,7 @@ contract DPPFactory is Ownable { _REGISTRY_[baseToken][quoteToken].push(dppAddress); _USER_REGISTRY_[creator].push(dppAddress); + emit NewDPP(baseToken, quoteToken, creator, dppAddress); } function _createFeeRateModel(address owner, uint256 feeRate) @@ -126,6 +142,8 @@ contract DPPFactory is Ownable { _DPP_ADMIN_TEMPLATE_ = _newDPPAdminTemplate; } + // ============ View Functions ============ + function getPrivatePool(address baseToken, address quoteToken) external view diff --git a/contracts/Factory/DVMFactory.sol b/contracts/Factory/DVMFactory.sol index f0cf9c9..4bdf96f 100644 --- a/contracts/Factory/DVMFactory.sol +++ b/contracts/Factory/DVMFactory.sol @@ -16,6 +16,8 @@ import {IDVMAdmin} from "../DODOVendingMachine/intf/IDVMAdmin.sol"; import {IPermissionManager} from "../lib/PermissionManager.sol"; contract DVMFactory is Ownable { + // ============ Templates ============ + address public _CLONE_FACTORY_; address public _DVM_TEMPLATE_; address public _DVM_ADMIN_TEMPLATE_; @@ -23,11 +25,24 @@ contract DVMFactory is Ownable { address public _PERMISSION_MANAGER_TEMPLATE_; address public _DEFAULT_GAS_PRICE_SOURCE_; + // ============ Registry ============ + // base -> quote -> DVM address list mapping(address => mapping(address => address[])) public _REGISTRY_; // creator -> DVM address list mapping(address => address[]) public _USER_REGISTRY_; + // ============ Events ============ + + event NewDVM( + address indexed baseToken, + address indexed quoteToken, + address indexed creator, + address dvm + ); + + // ============ Functions ============ + constructor( address cloneFactory, address dvmTemplate, @@ -71,6 +86,7 @@ contract DVMFactory is Ownable { } _REGISTRY_[baseToken][quoteToken].push(newVendingMachine); _USER_REGISTRY_[creator].push(newVendingMachine); + emit NewDVM(baseToken, quoteToken, creator, newVendingMachine); } function _createFeeRateModel(address owner, uint256 feeRate) @@ -98,6 +114,8 @@ contract DVMFactory is Ownable { _DVM_ADMIN_TEMPLATE_ = _newDVMAdminTemplate; } + // ============ View Functions ============ + function getVendingMachine(address baseToken, address quoteToken) external view