文件 1 的 6:Address.sol
pragma solidity ^0.7.3;
library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly { size := extcodesize(account) }
return size > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 2 的 6:IERC20.sol
pragma solidity ^0.7.3;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function totalSupply() external view returns (uint256);
function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);
}
文件 3 的 6:Ownable.sol
pragma solidity ^0.7.3;
interface IOwnable {
function owner() external view returns (address);
}
contract Ownable {
address public _owner;
event OwnershipTransferInitiated(address indexed previousOwner, address indexed newOwner);
event OwnershipTransferCompleted(address indexed previousOwner, address indexed newOwner);
function initializeOwner() public {
require(_owner == address(0));
_owner = msg.sender;
emit OwnershipTransferCompleted(address(0), _owner);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == msg.sender, "Ownable: caller is not the owner");
_;
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferInitiated(_owner, newOwner);
_owner = newOwner;
}
}
文件 4 的 6:SafeERC20.sol
pragma solidity ^0.7.3;
import "./IERC20.sol";
import "./SafeMath.sol";
import "./Address.sol";
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
文件 5 的 6:SafeMath.sol
pragma solidity ^0.7.3;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
文件 6 的 6:ieo.sol
pragma solidity ^0.7.3;
pragma experimental ABIEncoderV2;
import "./Ownable.sol";
import './IERC20.sol';
import './SafeMath.sol';
import "./SafeERC20.sol";
contract ieoCoinContract is Ownable {
using SafeERC20 for IERC20;
using SafeMath for uint256;
uint public priceDecimals;
uint256 public registerAmount;
uint8 private TOKEN_DECIMALS;
uint8 private PRICE_DECIMALS;
IERC20 public COIN;
IERC20 public MINI;
uint256 private fee;
uint256 private feeBase;
uint applyCoinId;
address public daoAddress;
uint256 public registeFee;
constructor(IERC20 _MINI )public{
initializeOwner();
MINI = _MINI;
priceDecimals = 4;
TOKEN_DECIMALS = 18;
PRICE_DECIMALS = 6;
registerAmount = 1 * (10 ** uint256(TOKEN_DECIMALS));
fee = 5;
feeBase = 1000;
applyCoinId = 1;
addapplyCoin(msg.sender ,"ETH",18);
registeFee = 0;
_owner = msg.sender;
}
struct ieoCoinInfoHead{
address coinAddress;
string symbol;
uint decimals;
uint collectType;
uint256 ieoAmount;
uint256 price;
bool bBuyLimit;
uint256 uBuyLimitNumber;
bool bPartner;
uint256 partnerNumber;
bool bDAO;
uint256 uDAONumber;
uint openType;
uint blockNumber;
uint openTime;
bool bDEX;
uint256 uDexNumber;
uint256 poolCoinAmount;
bool usdtType;
}
struct ieoCoinInfo{
ieoCoinInfoHead ieoCoinHead;
uint uTimestamp;
address coinId;
uint256 ieoAmountTotal;
uint256 registerAmount;
uint256 collectAmount;
uint256 allCollectAmount;
uint256 ieoAmountComplete;
uint256 daoCollectAmount;
uint256 dexCollectAmount;
bool bExpired;
uint buyNonce;
bool bTop;
address createUserAddress;
bool bPayDAO;
uint256 txid;
bool UsdtType;
}
event CreateIeoCoin(address user,address coinAddress,uint time,uint256 txid,uint256 amount);
event BuyCoin(address user,uint256 amount,address applyAddress, uint256 makeCoinAmount,uint256 txid);
event TakeOut(address user,uint256 amount,uint collectType ) ;
event Withdraw(address user,IERC20 COIN,uint256 amount ,address coinId,uint256 txid);
event SetIeoCoinDao(address coinId,address daoAddress,uint256 amount);
event AddLiquidity(address user,address coinid,uint256 balance,uint256 txid);
event TakeOutFee(address user,uint256 amount);
mapping(address=>ieoCoinInfo) ieoCoin;
struct userInfo{
uint uTimestamp;
address coinAddress;
uint256 makeCoinAmount;
uint256 takeCoinAmount;
address userAddress;
}
mapping(address=> mapping(address=> userInfo)) usercoin;
struct applyCoinInfo{
uint uTimestamp;
address contractAddress;
string symbol;
uint decimals;
}
mapping(address => applyCoinInfo) applyCoin;
mapping(uint => address) applyCoinAddress;
uint [] applyCoinList;
function setUsdtType(address coinid,bool _UsdtType) public onlyOwner returns(bool){
require(coinid != address(0));
ieoCoin[coinid].UsdtType = _UsdtType;
return true;
}
function getapplyCoinListLenght() public view returns(uint){
return applyCoinList.length;
}
function getapplyCoinListData(uint index) public view returns(uint){
require(applyCoinList.length > index);
return applyCoinList[index];
}
function getapplyCoinAddress(uint coinid) public view returns(address){
return applyCoinAddress[coinid];
}
function getapplyCoin(address contractAddress) public view returns(applyCoinInfo memory){
return applyCoin[contractAddress];
}
function addapplyCoin(address contractAddress,string memory symbol,uint decimals) public onlyOwner returns(bool){
require(applyCoin[contractAddress].contractAddress == address(0));
applyCoinInfo memory newapplyCoinInfo = applyCoinInfo({
uTimestamp: block.timestamp,
contractAddress: contractAddress,
symbol: symbol,
decimals: decimals
});
applyCoin[contractAddress] = newapplyCoinInfo;
applyCoinList.push(applyCoinId);
applyCoinAddress[applyCoinId] = contractAddress;
applyCoinId++;
return true;
}
function getfee() public view returns(uint){
return fee;
}
function setfee(uint _fee) public onlyOwner returns(bool){
require(_fee>=0);
fee = _fee;
return true;
}
function getUserInfo(address userAddress,address coinId) public view returns(userInfo memory){
return usercoin[userAddress][coinId];
}
function getieoCoin( address id ) public view returns(ieoCoinInfo memory){
require( id != address(0) );
return ieoCoin[id];
}
function getregisterAmount() public view returns(uint256){
return registerAmount;
}
function setregisterAmount(uint256 amount) public onlyOwner returns(bool){
require(amount>=0);
registerAmount = amount;
return true;
}
function createIeoCoin(ieoCoinInfoHead memory ieoCoinHead,uint256 txid) public payable returns(bool){
require(ieoCoinHead.coinAddress != address(0));
require(ieoCoinHead.ieoAmount > 0);
address coinId = ieoCoinHead.coinAddress;
require(ieoCoin[coinId].ieoCoinHead.coinAddress == address(0));
require(msg.value >= registerAmount );
ieoCoinInfo memory newieoCoinInfo = ieoCoinInfo({
ieoCoinHead: ieoCoinHead,
uTimestamp: block.timestamp,
coinId: coinId,
ieoAmountTotal: (ieoCoin[coinId].ieoAmountTotal).add(ieoCoinHead.ieoAmount),
registerAmount: msg.value,
collectAmount: 0,
allCollectAmount: 0,
ieoAmountComplete: 0,
daoCollectAmount: 0,
dexCollectAmount: 0,
bExpired: false,
buyNonce: 0,
bTop: false,
createUserAddress: msg.sender,
bPayDAO: false,
txid: txid,
UsdtType: ieoCoinHead.usdtType
});
ieoCoin[coinId] = newieoCoinInfo;
ieoCoin[coinId].coinId = coinId;
ieoCoin[coinId].ieoCoinHead.poolCoinAmount = (ieoCoin[coinId].ieoCoinHead.ieoAmount).mul(ieoCoin[coinId].ieoCoinHead.uDexNumber);
ieoCoin[coinId].ieoCoinHead.poolCoinAmount = (ieoCoin[coinId].ieoCoinHead.poolCoinAmount).div(100);
uint256 amount = ieoCoinHead.ieoAmount.add( ieoCoin[coinId].ieoCoinHead.poolCoinAmount );
COIN = IERC20(ieoCoinHead.coinAddress) ;
COIN.safeTransferFrom(msg.sender, address(this), amount);
registeFee = registeFee.add(msg.value);
emit CreateIeoCoin(msg.sender,ieoCoinHead.coinAddress,block.timestamp,txid,amount);
return true;
}
function checkBuyStatus(address coinid) private returns(bool){
bool bStatus = false;
if(block.number > ieoCoin[coinid].ieoCoinHead.blockNumber ){
uint num = (block.number).sub( ieoCoin[coinid].ieoCoinHead.blockNumber ) ;
if( num.mul(15) > ieoCoin[coinid].ieoCoinHead.openTime ){
bStatus = true;
}
else{
bStatus = false;
}
}
else{
bStatus = false;
}
return bStatus;
}
function buyCoin(address coinid,uint256 amount) public payable returns(bool){
require(ieoCoin[coinid].bExpired == false);
require(ieoCoin[coinid].ieoCoinHead.ieoAmount >= ieoCoin[coinid].ieoAmountComplete );
require(ieoCoin[coinid].ieoCoinHead.coinAddress != address(0));
require(checkBuyStatus(coinid) == false ) ;
address applyAddress = applyCoinAddress[ieoCoin[coinid].ieoCoinHead.collectType];
uint decimals = applyCoin[applyAddress].decimals;
uint to_decimals = ieoCoin[coinid].ieoCoinHead.decimals;
uint256 makeCoinAmount;
makeCoinAmount = (amount.mul(10 ** to_decimals)).div(10 ** decimals);
makeCoinAmount = makeCoinAmount.mul( ieoCoin[coinid].ieoCoinHead.price );
makeCoinAmount = makeCoinAmount.div(10 ** uint256(PRICE_DECIMALS));
require(ieoCoin[coinid].ieoCoinHead.ieoAmount >= makeCoinAmount.add(ieoCoin[coinid].ieoAmountComplete) );
address APPLYCOIN = applyCoin[applyAddress].contractAddress ;
if( ieoCoin[coinid].ieoCoinHead.bBuyLimit ){
require(usercoin[msg.sender][coinid].takeCoinAmount <= ieoCoin[coinid].ieoCoinHead.uBuyLimitNumber);
}
if( ieoCoin[coinid].ieoCoinHead.bPartner ){
require(MINI.balanceOf(msg.sender) >= ieoCoin[coinid].ieoCoinHead.partnerNumber);
}
uint256 feeAmount;
if(ieoCoin[coinid].ieoCoinHead.collectType == 1){
require(msg.value >= amount );
feeAmount = amount.mul(fee).div(feeBase);
address payable myOwner = address(uint160(_owner));
myOwner.transfer(feeAmount);
}
else{
require(IERC20(APPLYCOIN).balanceOf(msg.sender) >= amount);
feeAmount = amount.mul(fee).div(feeBase);
IERC20(APPLYCOIN).safeTransferFrom(msg.sender, address(this), amount.sub(feeAmount));
IERC20(APPLYCOIN).safeTransferFrom(msg.sender, _owner, feeAmount);
}
ieoCoin[coinid].collectAmount = (amount.sub(feeAmount)).add(ieoCoin[coinid].collectAmount);
ieoCoin[coinid].allCollectAmount = ieoCoin[coinid].collectAmount;
ieoCoin[coinid].ieoAmountComplete = makeCoinAmount.add(ieoCoin[coinid].ieoAmountComplete);
setDaoAndDexCollect(coinid);
ieoCoin[coinid].buyNonce ++;
userInfo memory newuserinfo = userInfo({
uTimestamp: block.timestamp,
coinAddress: coinid,
makeCoinAmount: makeCoinAmount.add(usercoin[msg.sender][coinid].makeCoinAmount),
takeCoinAmount: amount.add(usercoin[msg.sender][coinid].takeCoinAmount),
userAddress: msg.sender
});
usercoin[msg.sender][coinid] = newuserinfo;
uint256 txid = ieoCoin[coinid].txid;
emit BuyCoin(msg.sender,amount,APPLYCOIN,makeCoinAmount,txid);
return true;
}
function setDaoAndDexCollect(address coinid) private returns(bool){
uint256 collectAmount = ieoCoin[coinid].collectAmount;
uint256 daocollectAmount = collectAmount.mul(ieoCoin[coinid].ieoCoinHead.uDAONumber);
daocollectAmount = daocollectAmount.div( 100 );
ieoCoin[coinid].daoCollectAmount = daocollectAmount;
uint256 dexCollectAmount = collectAmount.mul(ieoCoin[coinid].ieoCoinHead.uDexNumber);
dexCollectAmount = dexCollectAmount.div(100);
ieoCoin[coinid].dexCollectAmount = dexCollectAmount;
return true;
}
function takeOut(address coinid) public returns(bool){
require(ieoCoin[coinid].collectAmount >= 0);
require(ieoCoin[coinid].createUserAddress == msg.sender );
require(checkBuyStatus(coinid) == true);
uint256 collectAmount = ieoCoin[coinid].collectAmount;
address applyAddress = applyCoinAddress[ieoCoin[coinid].ieoCoinHead.collectType];
address APPLYCOIN = applyCoin[applyAddress].contractAddress ;
ieoCoin[coinid].collectAmount = 0;
if( ieoCoin[coinid].ieoCoinHead.bDAO ){
collectAmount = collectAmount.sub(ieoCoin[coinid].daoCollectAmount);
ieoCoin[coinid].collectAmount = collectAmount ;
}
if( ieoCoin[coinid].ieoCoinHead.bDEX ){
collectAmount = collectAmount.sub(ieoCoin[coinid].dexCollectAmount);
ieoCoin[coinid].collectAmount = collectAmount;
}
if( collectAmount > 0 ){
if( ieoCoin[coinid].ieoCoinHead.collectType == 1 ){
address payable createUserAddress = address(uint160(ieoCoin[coinid].createUserAddress));
createUserAddress.transfer(collectAmount);
}
else{
IERC20(APPLYCOIN).safeTransfer(msg.sender,collectAmount);
}
}
ieoCoin[coinid].collectAmount = 0;
ieoCoin[coinid].bExpired = true;
uint256 balance = (ieoCoin[coinid].ieoCoinHead.ieoAmount).sub(ieoCoin[coinid].ieoAmountComplete) ;
uint decimals = applyCoin[applyAddress].decimals;
uint to_decimals = ieoCoin[coinid].ieoCoinHead.decimals;
uint256 dexCoinAmount = ieoCoin[coinid].dexCollectAmount;
dexCoinAmount = (dexCoinAmount.mul(10 ** to_decimals)).div(10 ** decimals);
dexCoinAmount = dexCoinAmount.mul(ieoCoin[coinid].ieoCoinHead.price);
dexCoinAmount = dexCoinAmount.div(10 ** uint256(PRICE_DECIMALS));
balance = balance.add( (ieoCoin[coinid].ieoCoinHead.poolCoinAmount).sub(dexCoinAmount) ) ;
COIN = IERC20(ieoCoin[coinid].ieoCoinHead.coinAddress);
COIN.safeTransfer(msg.sender, balance);
emit TakeOut(msg.sender,ieoCoin[coinid].collectAmount,ieoCoin[coinid].ieoCoinHead.collectType);
return true;
}
function withdraw(address coinid,uint256 amount) public returns(bool){
require(msg.sender != address(0));
require(usercoin[msg.sender][coinid].makeCoinAmount > 0);
require(usercoin[msg.sender][coinid].userAddress == msg.sender);
require(usercoin[msg.sender][coinid].makeCoinAmount >= amount);
usercoin[msg.sender][coinid].makeCoinAmount = (usercoin[msg.sender][coinid].makeCoinAmount).sub(amount);
COIN = IERC20(ieoCoin[coinid].ieoCoinHead.coinAddress);
COIN.safeTransfer(msg.sender,amount );
emit Withdraw(msg.sender,COIN, amount,coinid,ieoCoin[coinid].txid );
return true;
}
function getieoUserInfo(address user,address coinid) public view returns(uint256,uint256){
require(user != address(0));
require(ieoCoin[coinid].ieoCoinHead.coinAddress != address(0));
uint256 makeCoinAmount = usercoin[user][coinid].makeCoinAmount;
uint256 takeCoinAmount = usercoin[user][coinid].takeCoinAmount;
return (makeCoinAmount,takeCoinAmount);
}
function getieoCoinSallInfo(address coinid) public view returns(uint256,uint256){
require(ieoCoin[coinid].ieoCoinHead.coinAddress != address(0));
uint256 buyNonce = ieoCoin[coinid].buyNonce;
uint256 ieoAmountComplete = ieoCoin[coinid].ieoAmountComplete;
return (buyNonce,ieoAmountComplete);
}
function getieoCoinInfoByDao(address coinid) public view returns(address,bool,uint256,uint256,address,bool){
require(ieoCoin[coinid].ieoCoinHead.coinAddress != address(0));
bool bDAO = ieoCoin[coinid].ieoCoinHead.bDAO;
uint256 uDAONumber = ieoCoin[coinid].ieoCoinHead.uDAONumber;
uint256 daoCollectAmount = ieoCoin[coinid].daoCollectAmount;
address contractAddress = ieoCoin[coinid].ieoCoinHead.coinAddress;
address createAddress = ieoCoin[coinid].createUserAddress;
bool bExpired = ieoCoin[coinid].bExpired;
return(contractAddress,bDAO,uDAONumber,daoCollectAmount,createAddress,bExpired);
}
function getieoCoinInfoByDex(address coinId) public view returns(address,bool,uint256,uint256,address){
require(ieoCoin[coinId].ieoCoinHead.coinAddress != address(0));
bool bDEX = ieoCoin[coinId].ieoCoinHead.bDEX;
uint256 uDexNumber = ieoCoin[coinId].ieoCoinHead.uDexNumber;
uint256 dexCollectAmount = ieoCoin[coinId].dexCollectAmount;
address contractAddress = ieoCoin[coinId].ieoCoinHead.coinAddress;
address createUserAddress = ieoCoin[coinId].createUserAddress;
return(contractAddress,bDEX,uDexNumber,dexCollectAmount,createUserAddress);
}
function setdaoAddress(address _address) public onlyOwner returns(bool){
require(_address != address(0));
daoAddress = _address;
return true;
}
function setIeoCoinDao(address coinId,uint256 amount,uint256 uDAONumber) public returns(bool){
require(msg.sender == daoAddress);
require(ieoCoin[coinId].daoCollectAmount > 0);
require(ieoCoin[coinId].daoCollectAmount >= amount );
address applyAddress = applyCoinAddress[ieoCoin[coinId].ieoCoinHead.collectType];
address APPLYCOIN = applyCoin[applyAddress].contractAddress ;
if( ieoCoin[coinId].ieoCoinHead.bDAO ){
ieoCoin[coinId].bPayDAO = true;
ieoCoin[coinId].ieoCoinHead.uDAONumber = uDAONumber;
ieoCoin[coinId].daoCollectAmount = (ieoCoin[coinId].daoCollectAmount).sub(amount);
}
if( ieoCoin[coinId].daoCollectAmount == 0 ){
ieoCoin[coinId].bExpired = true;
}
if( ieoCoin[coinId].ieoCoinHead.collectType == 1 ){
address payable createUserAddress = address(uint160(ieoCoin[coinId].createUserAddress));
createUserAddress.transfer(amount);
}
else{
IERC20(APPLYCOIN).safeTransfer((ieoCoin[coinId].createUserAddress),amount);
}
emit SetIeoCoinDao(coinId,daoAddress,amount);
return true;
}
function addLiquidity(address coinid) public onlyOwner returns(bool){
require(checkBuyStatus(coinid) == true);
require(ieoCoin[coinid].dexCollectAmount > 0);
uint256 dexCollectAmount = ieoCoin[coinid].dexCollectAmount;
address applyAddress = applyCoinAddress[ieoCoin[coinid].ieoCoinHead.collectType];
address APPLYCOIN = applyCoin[applyAddress].contractAddress ;
if( ieoCoin[coinid].ieoCoinHead.bDEX ){
ieoCoin[coinid].dexCollectAmount = 0 ;
}
if( ieoCoin[coinid].ieoCoinHead.collectType == 1 ){
address payable myOwner = address(uint160(_owner));
myOwner.transfer(dexCollectAmount);
}
else{
IERC20(APPLYCOIN).safeTransfer(_owner,dexCollectAmount);
}
uint decimals = applyCoin[applyAddress].decimals;
uint to_decimals = ieoCoin[coinid].ieoCoinHead.decimals;
uint256 balance = (dexCollectAmount.mul(10 ** to_decimals)).div(10 ** decimals);
balance = balance.mul(ieoCoin[coinid].ieoCoinHead.price) ;
balance = balance.div(10 ** uint256(PRICE_DECIMALS));
COIN = IERC20(ieoCoin[coinid].ieoCoinHead.coinAddress);
COIN.safeTransfer(_owner, balance);
emit AddLiquidity(msg.sender,coinid,balance,ieoCoin[coinid].txid);
return true;
}
function takeOutFee() public onlyOwner returns(bool){
require(registeFee > 0);
msg.sender.transfer(registeFee);
emit TakeOutFee(msg.sender,registeFee);
registeFee = 0 ;
return true;
}
function getregisteFee() public view returns(uint256) {
return registeFee;
}
function getCoinType(address coinid) public view returns(bool){
require(coinid != address(0));
return ieoCoin[coinid].UsdtType;
}
}
{
"compilationTarget": {
"localhost/ieo.sol": "ieoCoinContract"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"contract IERC20","name":"_MINI","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"coinid","type":"address"},{"indexed":false,"internalType":"uint256","name":"balance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"txid","type":"uint256"}],"name":"AddLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"applyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"makeCoinAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"txid","type":"uint256"}],"name":"BuyCoin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"coinAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"time","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"txid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CreateIeoCoin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferInitiated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"coinId","type":"address"},{"indexed":false,"internalType":"address","name":"daoAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SetIeoCoinDao","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collectType","type":"uint256"}],"name":"TakeOut","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TakeOutFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"COIN","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"coinId","type":"address"},{"indexed":false,"internalType":"uint256","name":"txid","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"COIN","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINI","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"coinid","type":"address"}],"name":"addLiquidity","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"name":"addapplyCoin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"coinid","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"buyCoin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"coinAddress","type":"address"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"decimals","type":"uint256"},{"internalType":"uint256","name":"collectType","type":"uint256"},{"internalType":"uint256","name":"ieoAmount","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bool","name":"bBuyLimit","type":"bool"},{"internalType":"uint256","name":"uBuyLimitNumber","type":"uint256"},{"internalType":"bool","name":"bPartner","type":"bool"},{"internalType":"uint256","name":"partnerNumber","type":"uint256"},{"internalType":"bool","name":"bDAO","type":"bool"},{"internalType":"uint256","name":"uDAONumber","type":"uint256"},{"internalType":"uint256","name":"openType","type":"uint256"},{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"uint256","name":"openTime","type":"uint256"},{"internalType":"bool","name":"bDEX","type":"bool"},{"internalType":"uint256","name":"uDexNumber","type":"uint256"},{"internalType":"uint256","name":"poolCoinAmount","type":"uint256"},{"internalType":"bool","name":"usdtType","type":"bool"}],"internalType":"struct ieoCoinContract.ieoCoinInfoHead","name":"ieoCoinHead","type":"tuple"},{"internalType":"uint256","name":"txid","type":"uint256"}],"name":"createIeoCoin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"daoAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"coinid","type":"address"}],"name":"getCoinType","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"address","name":"coinId","type":"address"}],"name":"getUserInfo","outputs":[{"components":[{"internalType":"uint256","name":"uTimestamp","type":"uint256"},{"internalType":"address","name":"coinAddress","type":"address"},{"internalType":"uint256","name":"makeCoinAmount","type":"uint256"},{"internalType":"uint256","name":"takeCoinAmount","type":"uint256"},{"internalType":"address","name":"userAddress","type":"address"}],"internalType":"struct ieoCoinContract.userInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"getapplyCoin","outputs":[{"components":[{"internalType":"uint256","name":"uTimestamp","type":"uint256"},{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct ieoCoinContract.applyCoinInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"coinid","type":"uint256"}],"name":"getapplyCoinAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getapplyCoinListData","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getapplyCoinListLenght","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getfee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"id","type":"address"}],"name":"getieoCoin","outputs":[{"components":[{"components":[{"internalType":"address","name":"coinAddress","type":"address"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"decimals","type":"uint256"},{"internalType":"uint256","name":"collectType","type":"uint256"},{"internalType":"uint256","name":"ieoAmount","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bool","name":"bBuyLimit","type":"bool"},{"internalType":"uint256","name":"uBuyLimitNumber","type":"uint256"},{"internalType":"bool","name":"bPartner","type":"bool"},{"internalType":"uint256","name":"partnerNumber","type":"uint256"},{"internalType":"bool","name":"bDAO","type":"bool"},{"internalType":"uint256","name":"uDAONumber","type":"uint256"},{"internalType":"uint256","name":"openType","type":"uint256"},{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"uint256","name":"openTime","type":"uint256"},{"internalType":"bool","name":"bDEX","type":"bool"},{"internalType":"uint256","name":"uDexNumber","type":"uint256"},{"internalType":"uint256","name":"poolCoinAmount","type":"uint256"},{"internalType":"bool","name":"usdtType","type":"bool"}],"internalType":"struct ieoCoinContract.ieoCoinInfoHead","name":"ieoCoinHead","type":"tuple"},{"internalType":"uint256","name":"uTimestamp","type":"uint256"},{"internalType":"address","name":"coinId","type":"address"},{"internalType":"uint256","name":"ieoAmountTotal","type":"uint256"},{"internalType":"uint256","name":"registerAmount","type":"uint256"},{"internalType":"uint256","name":"collectAmount","type":"uint256"},{"internalType":"uint256","name":"allCollectAmount","type":"uint256"},{"internalType":"uint256","name":"ieoAmountComplete","type":"uint256"},{"internalType":"uint256","name":"daoCollectAmount","type":"uint256"},{"internalType":"uint256","name":"dexCollectAmount","type":"uint256"},{"internalType":"bool","name":"bExpired","type":"bool"},{"internalType":"uint256","name":"buyNonce","type":"uint256"},{"internalType":"bool","name":"bTop","type":"bool"},{"internalType":"address","name":"createUserAddress","type":"address"},{"internalType":"bool","name":"bPayDAO","type":"bool"},{"internalType":"uint256","name":"txid","type":"uint256"},{"internalType":"bool","name":"UsdtType","type":"bool"}],"internalType":"struct ieoCoinContract.ieoCoinInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"coinid","type":"address"}],"name":"getieoCoinInfoByDao","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"coinId","type":"address"}],"name":"getieoCoinInfoByDex","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"coinid","type":"address"}],"name":"getieoCoinSallInfo","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"coinid","type":"address"}],"name":"getieoUserInfo","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getregisteFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getregisterAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initializeOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registeFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registerAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"coinId","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"uDAONumber","type":"uint256"}],"name":"setIeoCoinDao","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"coinid","type":"address"},{"internalType":"bool","name":"_UsdtType","type":"bool"}],"name":"setUsdtType","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"setdaoAddress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"setfee","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setregisterAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"coinid","type":"address"}],"name":"takeOut","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"takeOutFee","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"coinid","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]