update nft vault && frag
This commit is contained in:
@@ -39,14 +39,22 @@ contract NFTCollateralVault is InitializableOwnable, IERC721Receiver, IERC1155Re
|
||||
|
||||
// ============ TransferFrom NFT ============
|
||||
function depositERC721(address nftContract, uint256[] memory tokenIds) public {
|
||||
|
||||
require(nftContract != address(0), "DODONftVault: ZERO_ADDRESS");
|
||||
for(uint256 i = 0; i < tokenIds.length; i++) {
|
||||
IERC721(nftContract).safeTransferFrom(msg.sender, address(this), tokenIds[i]);
|
||||
emit AddNftToken(nftContract, tokenIds[i], 1);
|
||||
}
|
||||
}
|
||||
|
||||
function depoistERC1155(address nftContract, uint256[] memory tokenIds, uint256[] memory amounts) public {
|
||||
|
||||
require(nftContract != address(0), "DODONftVault: ZERO_ADDRESS");
|
||||
require(tokenIds.length == amounts.length, "PARAMS_NOT_MATCH");
|
||||
IERC1155(nftContract).safeBatchTransferFrom(msg.sender, address(this), tokenIds, amounts, "");
|
||||
for(uint256 i = 0; i < tokenIds.length; i++) {
|
||||
emit AddNftToken(nftContract, tokenIds[i], amounts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ============ Ownable ============
|
||||
function directTransferOwnership(address newOwner) external onlyOwner {
|
||||
require(newOwner != address(0), "DODONftVault: ZERO_ADDRESS");
|
||||
@@ -62,10 +70,12 @@ contract NFTCollateralVault is InitializableOwnable, IERC721Receiver, IERC1155Re
|
||||
emit OwnershipTransferred(_OWNER_, nftProxy);
|
||||
}
|
||||
|
||||
function withdrawERC721(address nftContract, uint256 tokenId) external onlyOwner {
|
||||
function withdrawERC721(address nftContract, uint256[] memory tokenIds) external onlyOwner {
|
||||
require(nftContract != address(0), "DODONftVault: ZERO_ADDRESS");
|
||||
IERC721(nftContract).safeTransferFrom(address(this), _OWNER_, tokenId, "");
|
||||
emit RemoveNftToken(nftContract, tokenId, 1);
|
||||
for(uint256 i = 0; i < tokenIds.length; i++) {
|
||||
IERC721(nftContract).safeTransferFrom(address(this), _OWNER_, tokenIds[i]);
|
||||
emit RemoveNftToken(nftContract, tokenIds[i], 1);
|
||||
}
|
||||
}
|
||||
|
||||
function withdrawERC1155(address nftContract, uint256[] memory tokenIds, uint256[] memory amounts) external onlyOwner {
|
||||
|
||||
@@ -13,7 +13,7 @@ import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
|
||||
import {Address} from "../external/utils/Address.sol";
|
||||
import {ERC721URIStorage} from "../external/ERC721/ERC721URIStorage.sol";
|
||||
|
||||
contract DODODropsV1 is ERC721URIStorage, InitializableOwnable {
|
||||
contract MysteryBoxKAKA is ERC721URIStorage, InitializableOwnable {
|
||||
using SafeMath for uint256;
|
||||
using SafeERC20 for IERC20;
|
||||
using Address for address;
|
||||
@@ -26,6 +26,7 @@ contract Fragment is InitializableERC20 {
|
||||
uint256 public _BUYOUT_TIMESTAMP_;
|
||||
uint256 public _BUYOUT_PRICE_;
|
||||
uint256 public _DEFAULT_BUYOUT_FEE_;
|
||||
uint256 public _DISTRIBUTION_RATIO_;
|
||||
|
||||
address public _COLLATERAL_VAULT_;
|
||||
address public _VAULT_PRE_OWNER_;
|
||||
@@ -52,7 +53,8 @@ contract Fragment is InitializableERC20 {
|
||||
uint256 ownerRatio,
|
||||
uint256 buyoutTimestamp,
|
||||
address defaultMaintainer,
|
||||
uint256 defaultBuyoutFee
|
||||
uint256 defaultBuyoutFee,
|
||||
uint256 distributionRatio
|
||||
) external {
|
||||
require(!_FRAG_INITIALIZED_, "DODOFragment: ALREADY_INITIALIZED");
|
||||
_FRAG_INITIALIZED_ = true;
|
||||
@@ -65,6 +67,7 @@ contract Fragment is InitializableERC20 {
|
||||
_BUYOUT_TIMESTAMP_ = buyoutTimestamp;
|
||||
_DEFAULT_MAINTAINER_ = defaultMaintainer;
|
||||
_DEFAULT_BUYOUT_FEE_ = defaultBuyoutFee;
|
||||
_DISTRIBUTION_RATIO_ = distributionRatio;
|
||||
|
||||
// init FRAG meta data
|
||||
string memory prefix = "FRAG_";
|
||||
@@ -75,7 +78,10 @@ contract Fragment is InitializableERC20 {
|
||||
|
||||
// init FRAG distribution
|
||||
uint256 vaultPreOwnerBalance = DecimalMath.mulFloor(_totalSupply, ownerRatio);
|
||||
_transfer(address(this), _VAULT_PRE_OWNER_, vaultPreOwnerBalance);
|
||||
uint256 distributionBalance = DecimalMath.mulFloor(vaultPreOwnerBalance, distributionRatio);
|
||||
|
||||
if(distributionBalance > 0) _transfer(address(this), _DEFAULT_MAINTAINER_, distributionBalance);
|
||||
_transfer(address(this), _VAULT_PRE_OWNER_, vaultPreOwnerBalance.sub(distributionBalance));
|
||||
_transfer(address(this), _DVM_, _totalSupply.sub(vaultPreOwnerBalance));
|
||||
|
||||
// init DVM liquidity
|
||||
|
||||
@@ -18,7 +18,8 @@ interface IFragment {
|
||||
uint256 ownerRatio,
|
||||
uint256 buyoutTimestamp,
|
||||
address defaultMaintainer,
|
||||
uint256 defaultBuyoutFee
|
||||
uint256 defaultBuyoutFee,
|
||||
uint256 distributionRatio
|
||||
) external;
|
||||
|
||||
function buyout(address newVaultOwner) external;
|
||||
|
||||
@@ -101,7 +101,7 @@ contract DODONFTProxy is ReentrancyGuard, InitializableOwnable {
|
||||
address quoteToken,
|
||||
address vaultPreOwner,
|
||||
uint256[] calldata dvmParams, //0 - lpFeeRate, 1 - I, 2 - K
|
||||
uint256[] calldata fragParams, //0 - totalSupply, 1 - ownerRatio, 2 - buyoutTimestamp
|
||||
uint256[] calldata fragParams, //0 - totalSupply, 1 - ownerRatio, 2 - buyoutTimestamp, 3 - distributionRatio
|
||||
bool isOpenTwap
|
||||
) external returns (address newFragment, address newDvm) {
|
||||
newFragment = ICloneFactory(_CLONE_FACTORY_).clone(_FRAG_TEMPLATE_);
|
||||
@@ -130,7 +130,8 @@ contract DODONFTProxy is ReentrancyGuard, InitializableOwnable {
|
||||
_fragParams[1],
|
||||
_fragParams[2],
|
||||
_DEFAULT_MAINTAINER_,
|
||||
_DEFAULT_BUYOUT_FEE_
|
||||
_DEFAULT_BUYOUT_FEE_,
|
||||
_fragParams[3]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user