nftproxy&®ister&&fix
This commit is contained in:
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
|
||||
import {ICloneFactory} from "../lib/CloneFactory.sol";
|
||||
import {IDVM} from "../DODOVendingMachine/intf/IDVM.sol";
|
||||
|
||||
// 这一部分最后写,先把前面的接口定下来
|
||||
// 业务流程(没有NFT的情况下)
|
||||
// 1. 上传媒体,创建NFTCollateralVault
|
||||
// 2. 把CollateralVault提供给FragmentFactory做碎片化
|
||||
// (已经有NFT的情况下)
|
||||
// 1. 将NFT打包成NFTCollateralVault
|
||||
// 2. 把CollateralVault提供给FragmentFactory做碎片化
|
||||
// 所以总体来说,factory只需要处理vault已经建立好之后的拼装工作即可
|
||||
|
||||
interface IFragmentFactory {
|
||||
function createFragment() external returns (address newVendingMachine);
|
||||
}
|
||||
|
||||
contract FragmentFactory is InitializableOwnable {
|
||||
// ============ Templates ============
|
||||
|
||||
address public immutable _CLONE_FACTORY_;
|
||||
address public immutable _MT_FEE_RATE_MODEL_;
|
||||
address public _DVM_TEMPLATE_;
|
||||
address public _FEE_DISTRIBUTOR_TEMPLATE_;
|
||||
address public _FRAGMENT_TEMPLATE_;
|
||||
|
||||
// ============ Registry ============
|
||||
|
||||
// base -> quote -> DVM address list
|
||||
mapping(address => mapping(address => address[])) public _REGISTRY_;
|
||||
// creator -> DVM address list
|
||||
mapping(address => address[]) public _USER_REGISTRY_;
|
||||
|
||||
// ============ Functions ============
|
||||
|
||||
constructor(
|
||||
address cloneFactory,
|
||||
address dvmTemplate,
|
||||
address feeDistributorTemplate,
|
||||
address fragmentTemplate,
|
||||
address mtFeeRateModel
|
||||
) public {
|
||||
_CLONE_FACTORY_ = cloneFactory;
|
||||
_DVM_TEMPLATE_ = dvmTemplate;
|
||||
_FEE_DISTRIBUTOR_TEMPLATE_ = feeDistributorTemplate;
|
||||
_FRAGMENT_TEMPLATE_ = fragmentTemplate;
|
||||
_MT_FEE_RATE_MODEL_ = mtFeeRateModel;
|
||||
}
|
||||
|
||||
function createFragment(
|
||||
address owner,
|
||||
address vault,
|
||||
address quoteToken,
|
||||
uint256 mtFeeRate,
|
||||
uint256 i,
|
||||
uint256 k,
|
||||
uint256 totalSupply,
|
||||
uint256 ownerRatio,
|
||||
uint256 buyoutTimestamp
|
||||
) external returns (address newFragment) {
|
||||
// newFragment = ICloneFactory(_CLONE_FACTORY_).clone(_FRAGMENT_TEMPLATE_);
|
||||
// newVendingMachine = ICloneFactory(_CLONE_FACTORY_).clone(_DVM_TEMPLATE_);
|
||||
// newFeeDistributor = ICloneFactory(_CLONE_FACTORY_).clone(_FEE_DISTRIBUTOR_TEMPLATE_);
|
||||
|
||||
// {
|
||||
// IFeeDistributor(newFeeDistributor).init(newFragment, quoteToken, newFragment);
|
||||
// }
|
||||
|
||||
// {
|
||||
// IDVM(newVendingMachine).init(
|
||||
// newFeeDistributor,
|
||||
// newFragment,
|
||||
// quoteToken,
|
||||
// 0,
|
||||
// mtFeeRateModel,
|
||||
// i,
|
||||
// k,
|
||||
// false
|
||||
// );
|
||||
// IFeeRateRegistry(mtFeeRateModel).set(newVendingMachine, mtFeeRate);
|
||||
// }
|
||||
|
||||
// {
|
||||
// IFragment(newFragment).init(owner, newVendingMachine, vault, totalSupply, ownerRatio, buyoutTimestamp);
|
||||
// }
|
||||
}
|
||||
}
|
||||
86
contracts/Factory/Registries/DODONFTRegistry.sol
Normal file
86
contracts/Factory/Registries/DODONFTRegistry.sol
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import {InitializableOwnable} from "../../lib/InitializableOwnable.sol";
|
||||
|
||||
interface IDODONFTRegistry {
|
||||
function addRegistry(
|
||||
address vault,
|
||||
address fragment,
|
||||
address feeDistributor,
|
||||
address dvm
|
||||
) external;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title DODONFT Registry
|
||||
* @author DODO Breeder
|
||||
*
|
||||
* @notice Register DODONFT Pools
|
||||
*/
|
||||
contract DODONFTRegistry is InitializableOwnable {
|
||||
|
||||
mapping (address => bool) public isAdminListed;
|
||||
|
||||
// ============ Registry ============
|
||||
|
||||
// Frag -> FeeDistributor
|
||||
mapping(address => address) public _FRAG_FEE_REGISTRY_;
|
||||
// DVM -> FeeDistributor
|
||||
mapping(address => address) public _DVM_FEE_REGISTRY_;
|
||||
// Vault -> Frag
|
||||
mapping(address => address) public _VAULT_FRAG_REGISTRY_;
|
||||
|
||||
// ============ Events ============
|
||||
|
||||
event NewRegistry(
|
||||
address vault,
|
||||
address fragment,
|
||||
address feeDistributor,
|
||||
address dvm
|
||||
);
|
||||
|
||||
event RemoveRegistry(address fragment);
|
||||
|
||||
|
||||
// ============ Admin Operation Functions ============
|
||||
|
||||
function addRegistry(
|
||||
address vault,
|
||||
address fragment,
|
||||
address feeDistributor,
|
||||
address dvm
|
||||
) external {
|
||||
require(isAdminListed[msg.sender], "ACCESS_DENIED");
|
||||
_FRAG_FEE_REGISTRY_[fragment] = feeDistributor;
|
||||
_DVM_FEE_REGISTRY_[dvm] = feeDistributor;
|
||||
_VAULT_FRAG_REGISTRY_[vault] = fragment;
|
||||
emit NewRegistry(vault, fragment, feeDistributor, dvm);
|
||||
}
|
||||
|
||||
function removeRegistry(
|
||||
address vault,
|
||||
address fragment,
|
||||
address dvm
|
||||
) external onlyOwner {
|
||||
_FRAG_FEE_REGISTRY_[fragment] = address(0);
|
||||
_DVM_FEE_REGISTRY_[dvm] = address(0);
|
||||
_VAULT_FRAG_REGISTRY_[vault] = address(0);
|
||||
emit RemoveRegistry(fragment);
|
||||
}
|
||||
|
||||
function addAmindList (address contractAddr) public onlyOwner {
|
||||
isAdminListed[contractAddr] = true;
|
||||
}
|
||||
|
||||
function removeWhiteList (address contractAddr) public onlyOwner {
|
||||
isAdminListed[contractAddr] = false;
|
||||
}
|
||||
}
|
||||
85
contracts/Factory/TokenFactory.sol
Normal file
85
contracts/Factory/TokenFactory.sol
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
//TODO:
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import {ICloneFactory} from "../lib/CloneFactory.sol";
|
||||
import {InitializableERC20} from "../external/ERC20/InitializableERC20.sol";
|
||||
import {InitializableMintableERC20} from "../external/ERC20/InitializableMintableERC20.sol";
|
||||
|
||||
/**
|
||||
* @title DODO TokenFactory
|
||||
* @author DODO Breeder
|
||||
*
|
||||
* @notice Help user to create erc20 && erc721 && erc1155 token
|
||||
*/
|
||||
contract TokenFacotry {
|
||||
// ============ Templates ============
|
||||
|
||||
address public immutable _CLONE_FACTORY_;
|
||||
address public immutable _ERC20_TEMPLATE_;
|
||||
address public immutable _MINTABLE_ERC20_TEMPLATE_;
|
||||
|
||||
// ============ Events ============
|
||||
|
||||
event NewERC20(address erc20, address creator, bool isMintable);
|
||||
|
||||
// ============ Registry ============
|
||||
// creator -> token address list
|
||||
mapping(address => address[]) public _USER_STD_REGISTRY_;
|
||||
|
||||
// ============ Functions ============
|
||||
|
||||
constructor(
|
||||
address cloneFactory,
|
||||
address erc20Template,
|
||||
address mintableErc20Template
|
||||
) public {
|
||||
_CLONE_FACTORY_ = cloneFactory;
|
||||
_ERC20_TEMPLATE_ = erc20Template;
|
||||
_MINTABLE_ERC20_TEMPLATE_ = mintableErc20Template;
|
||||
}
|
||||
|
||||
function createStdERC20(
|
||||
uint256 totalSupply,
|
||||
string memory name,
|
||||
string memory symbol,
|
||||
uint256 decimals
|
||||
) external returns (address newERC20) {
|
||||
newERC20 = ICloneFactory(_CLONE_FACTORY_).clone(_ERC20_TEMPLATE_);
|
||||
InitializableERC20(newERC20).init(msg.sender, totalSupply, name, symbol, decimals);
|
||||
_USER_STD_REGISTRY_[msg.sender].push(newERC20);
|
||||
emit NewERC20(newERC20, msg.sender, false);
|
||||
}
|
||||
|
||||
function createMintableERC20(
|
||||
uint256 initSupply,
|
||||
string memory name,
|
||||
string memory symbol,
|
||||
uint256 decimals
|
||||
) external returns (address newMintableERC20) {
|
||||
newMintableERC20 = ICloneFactory(_CLONE_FACTORY_).clone(_MINTABLE_ERC20_TEMPLATE_);
|
||||
InitializableMintableERC20(newMintableERC20).init(
|
||||
msg.sender,
|
||||
initSupply,
|
||||
name,
|
||||
symbol,
|
||||
decimals
|
||||
);
|
||||
emit NewERC20(newMintableERC20, msg.sender, true);
|
||||
}
|
||||
|
||||
|
||||
function getTokenByUser(address user)
|
||||
external
|
||||
view
|
||||
returns (address[] memory tokens)
|
||||
{
|
||||
return _USER_STD_REGISTRY_[user];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user