contract StrongWalletPresale is Ownable {
    using SafeMath for uint256;

    uint public presaleAmount = 3000000 ether;
    ERC20 public STRONG;
    ERC20 public USDT_TOKEN_ADDRESS;
    mapping(address => uint) public sellers;

    address[] public lengthSeller;
    // event
    event DepositETH();
    event DepositUSDT();
    event DepositETHWithSeller(address receiver, uint amount, uint amountStrong, address _seller);
    event DepositUSDTWithSeller(address receiver, uint amount, uint amountStrong, address _seller);

    AggregatorV3Interface internal priceFeed;
    constructor() public {
        priceFeed = AggregatorV3Interface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419);
        STRONG = ERC20(0xf217f7df49f626f83f40D7D5137D663B1ec4EE6E);
        USDT_TOKEN_ADDRESS = ERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7);
    }
    function getRate(uint _usdtAmount) public pure returns(uint) {
        if(_usdtAmount <= 100 ether) return 160;
        else if(_usdtAmount <= 1000 ether) return 150;
        else if(_usdtAmount <= 5000 ether) return 135;
        else if(_usdtAmount <= 10000 ether) return 125;
        else if(_usdtAmount <= 50000 ether) return 115;
        return 100;
    }
    function USDT2Strong(uint _usdtAmount) public pure returns(uint) {
        return _usdtAmount.mul(1000).div(getRate(_usdtAmount));
    }
    function ETH2USDT() public view returns (uint){
        int price;
        (,price,,,) = priceFeed.latestRoundData();
        return uint(price);
    }
    function ETH2STRONG(uint _amountETH) public view returns(uint) {
        uint256 usdtAmount = ETH2USDT().mul(_amountETH).div(1 ether);
        return USDT2Strong(usdtAmount);
    }
    function depositEth() public payable {
        owner.transfer(msg.value);
        STRONG.transfer(msg.sender, ETH2STRONG(msg.value));
        emit DepositETH();
    }
    function depositUSDT(uint256 _amountUsdt) public {
        require(USDT_TOKEN_ADDRESS.transferFrom(msg.sender, owner, _amountUsdt));
        STRONG.transfer(msg.sender, USDT2Strong(_amountUsdt));
        emit DepositUSDT();
    }

    function depositEthWithSeller(address _seller) public payable {
        require(msg.sender != _seller);
        uint amountStrong = ETH2STRONG(msg.value);
        owner.transfer(msg.value);
        STRONG.transfer(msg.sender, amountStrong);
        uint bonusPercent = 2;
        if(sellers[_seller] == 0) {
            bonusPercent = 5;
            sellers[_seller] = amountStrong;
        }
        STRONG.transfer(_seller, amountStrong.mul(bonusPercent).div(100));
        
        emit DepositETHWithSeller(msg.sender, msg.value, amountStrong, _seller);
    }
    function depositUSDTWithSeller(uint256 _amountUsdt, address _seller) public {
        require(msg.sender != _seller);
        require(USDT_TOKEN_ADDRESS.transferFrom(msg.sender, owner, _amountUsdt));
        STRONG.transfer(msg.sender, USDT2Strong(_amountUsdt));
        uint amountStrong = USDT2Strong(_amountUsdt);
        uint bonusPercent = 2;
        if(sellers[_seller] == 0) {
            bonusPercent = 5;
            sellers[_seller] = amountStrong;
        }
        STRONG.transfer(_seller, amountStrong.mul(bonusPercent).div(100));
        emit DepositUSDTWithSeller(msg.sender, _amountUsdt, amountStrong, _seller);
    }
    /**
    * @dev Withdraw the amount of token that is remaining in this contract.
    * @param _address The address of EOA that can receive token from this contract.
    */
    function withdraw(address _address) public onlyOwner {
        STRONG.transfer(_address, STRONG.balanceOf(address(this)));
    }
}
function withdraw(address _address) public onlyOwner {
    STRONG.transfer(_address, STRONG.balanceOf(address(this)));
}

/**
 * @dev Withdraw the amount of token that is remaining in this contract.
 * @param _address The address of EOA that can receive token from this contract.
 */