ETH Price: $3,407.75 (+2.48%)

Transaction Decoder

Block:
23316497 at Sep-08-2025 06:10:47 AM +UTC
Transaction Fee:
0.000065389595362602 ETH $0.22
Gas Used:
494,902 Gas / 0.132126351 Gwei

Account State Difference:

  Address   Before After State Difference Code
(Titan Builder)
18.028671737918944257 Eth18.028671812154244257 Eth0.0000000742353
0x4B732Ebd...8713C6c21
0.000178294334270542 Eth
Nonce: 22
0.00011290473890794 Eth
Nonce: 23
0.000065389595362602

Execution Trace

LILPEPE_Presale.buyWithUSDT( usdAmount=14000000 )
  • TetherToken.allowance( _owner=0x4B732EbdC49eCe61CEf44a5f1Ef115A8713C6c21, _spender=0x5584197Ce066aAbc11919aCe52B6DF5948b1e930 ) => ( remaining=999999999999999999999999999999 )
  • TetherToken.transferFrom( _from=0x4B732EbdC49eCe61CEf44a5f1Ef115A8713C6c21, _to=0x157bE393bb119f678EE5d817529Eb67feE136065, _value=14000000 )
    File 1 of 2: LILPEPE_Presale
    //SPDX-License-Identifier: MIT
    pragma solidity ^0.8.20;
    
    abstract contract ReentrancyGuard {
        uint256 private constant _NOT_ENTERED = 1;
        uint256 private constant _ENTERED = 2;
    
        uint256 private _status;
    
        constructor() {
            _status = _NOT_ENTERED;
        }
    
        modifier nonReentrant() {
            _nonReentrantBefore();
            _;
            _nonReentrantAfter();
        }
    
        function _nonReentrantBefore() private {
            require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
    
            _status = _ENTERED;
        }
    
        function _nonReentrantAfter() private {
            _status = _NOT_ENTERED;
        }
    }
    
    abstract contract Context {
        function _msgSender() internal view virtual returns (address) {
            return msg.sender;
        }
    
        function _msgData() internal view virtual returns (bytes calldata) {
            return msg.data;
        }
    }
    
    abstract contract Ownable is Context {
        address private _owner;
    
        event OwnershipTransferred(
            address indexed previousOwner,
            address indexed newOwner
        );
    
        constructor() {
            _transferOwnership(_msgSender());
        }
    
        modifier onlyOwner() {
            _checkOwner();
            _;
        }
    
        function owner() public view virtual returns (address) {
            return _owner;
        }
    
        function _checkOwner() internal view virtual {
            require(owner() == _msgSender(), "Ownable: caller is not the owner");
        }
    
        function renounceOwnership() public virtual onlyOwner {
            _transferOwnership(address(0));
        }
    
        function transferOwnership(address newOwner) public virtual onlyOwner {
            require(
                newOwner != address(0),
                "Ownable: new owner is the zero address"
            );
            _transferOwnership(newOwner);
        }
    
        function _transferOwnership(address newOwner) internal virtual {
            address oldOwner = _owner;
            _owner = newOwner;
            emit OwnershipTransferred(oldOwner, newOwner);
        }
    }
    
    library Address {
        function isContract(address account) internal view returns (bool) {
            return account.code.length > 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
                functionCallWithValue(
                    target,
                    data,
                    0,
                    "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"
            );
            (bool success, bytes memory returndata) = target.call{value: value}(
                data
            );
            return
                verifyCallResultFromTarget(
                    target,
                    success,
                    returndata,
                    errorMessage
                );
        }
    
        function functionStaticCall(address target, bytes memory data)
            internal
            view
            returns (bytes memory)
        {
            return
                functionStaticCall(
                    target,
                    data,
                    "Address: low-level static call failed"
                );
        }
    
        function functionStaticCall(
            address target,
            bytes memory data,
            string memory errorMessage
        ) internal view returns (bytes memory) {
            (bool success, bytes memory returndata) = target.staticcall(data);
            return
                verifyCallResultFromTarget(
                    target,
                    success,
                    returndata,
                    errorMessage
                );
        }
    
        function functionDelegateCall(address target, bytes memory data)
            internal
            returns (bytes memory)
        {
            return
                functionDelegateCall(
                    target,
                    data,
                    "Address: low-level delegate call failed"
                );
        }
    
        function functionDelegateCall(
            address target,
            bytes memory data,
            string memory errorMessage
        ) internal returns (bytes memory) {
            (bool success, bytes memory returndata) = target.delegatecall(data);
            return
                verifyCallResultFromTarget(
                    target,
                    success,
                    returndata,
                    errorMessage
                );
        }
    
        function verifyCallResultFromTarget(
            address target,
            bool success,
            bytes memory returndata,
            string memory errorMessage
        ) internal view returns (bytes memory) {
            if (success) {
                if (returndata.length == 0) {
                    require(isContract(target), "Address: call to non-contract");
                }
                return returndata;
            } else {
                _revert(returndata, errorMessage);
            }
        }
    
        function verifyCallResult(
            bool success,
            bytes memory returndata,
            string memory errorMessage
        ) internal pure returns (bytes memory) {
            if (success) {
                return returndata;
            } else {
                _revert(returndata, errorMessage);
            }
        }
    
        function _revert(bytes memory returndata, string memory errorMessage)
            private
            pure
        {
            if (returndata.length > 0) {
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
    
    interface IERC20 {
        event Transfer(address indexed from, address indexed to, uint256 value);
    
        event Approval(
            address indexed owner,
            address indexed spender,
            uint256 value
        );
    
        function totalSupply() external view returns (uint256);
    
        function balanceOf(address account) external view returns (uint256);
    
        function transfer(address to, uint256 amount) external returns (bool);
    
        function allowance(address owner, address spender)
            external
            view
            returns (uint256);
    
        function approve(address spender, uint256 amount) external returns (bool);
    
        function transferFrom(
            address from,
            address to,
            uint256 amount
        ) external returns (bool);
    }
    
    interface IERC20Metadata is IERC20 {
        function name() external view returns (string memory);
    
        function symbol() external view returns (string memory);
    
        function decimals() external view returns (uint8);
    }
    
    interface Aggregator {
        function latestRoundData()
            external
            view
            returns (
                uint80 roundId,
                int256 answer,
                uint256 startedAt,
                uint256 updatedAt,
                uint80 answeredInRound
            );
    }
    
    contract LILPEPE_Presale is ReentrancyGuard, Ownable {
        uint256 public overalllRaised;
        uint256 public presaleId;
        uint256 public USDT_MULTIPLIER;
        uint256 public ETH_MULTIPLIER;
        address public fundReceiver;
        uint256 public uniqueBuyers;
    
        struct PresaleData {
            uint256 startTime;
            uint256 endTime;
            uint256 price;
            uint256 nextStagePrice;
            uint256 Sold;
            uint256 tokensToSell;
            uint256 UsdtHardcap;
            uint256 amountRaised;
            bool Active;
            bool isEnableClaim;
        }
    
        struct VestingData {
            uint256 vestingStartTime;
            uint256 initialClaimPercent;
            uint256 vestingTime;
            uint256 vestingPercentage;
            uint256 totalClaimCycles;
        }
    
        struct UserData {
            uint256 investedAmount;
            uint256 claimAt;
            uint256 claimAbleAmount;
            uint256 claimedVestingAmount;
            uint256 claimedAmount;
            uint256 claimCount;
            uint256 activePercentAmount;
        }
    
        IERC20Metadata public USDTInterface;
        IERC20Metadata public USDCInterface;
        Aggregator internal aggregatorInterface;
    
        mapping(uint256 => bool) public paused;
        mapping(uint256 => PresaleData) public presale;
        mapping(uint256 => VestingData) public vesting;
        mapping(address => mapping(uint256 => UserData)) public userClaimData;
        mapping(address => bool) public isExcludeMinToken;
        mapping(address => bool) public isBlackList;
        mapping(address => bool) public isExist;
    
        uint256 public MinTokenTobuy;
        uint256 public currentSale;
        address public SaleToken;
    
        event PresaleCreated(
            uint256 indexed _id,
            uint256 _totalTokens,
            uint256 _startTime,
            uint256 _endTime
        );
    
        event PresaleUpdated(
            bytes32 indexed key,
            uint256 prevValue,
            uint256 newValue,
            uint256 timestamp
        );
    
        event TokensBought(
            address indexed user,
            uint256 indexed id,
            address indexed purchaseToken,
            uint256 tokensBought,
            uint256 amountPaid,
            uint256 timestamp
        );
    
        event TokensClaimed(
            address indexed user,
            uint256 indexed id,
            uint256 amount,
            uint256 timestamp
        );
    
        event PresaleTokenAddressUpdated(
            address indexed prevValue,
            address indexed newValue,
            uint256 timestamp
        );
    
        event PresalePaused(uint256 indexed id, uint256 timestamp);
        event PresaleUnpaused(uint256 indexed id, uint256 timestamp);
    
        constructor(
            address _oracle,
            address _usdt,
            address _usdc,
            address _SaleToken,
            uint256 _MinTokenTobuy
        ) {
            aggregatorInterface = Aggregator(_oracle);
            SaleToken = _SaleToken;
            MinTokenTobuy = _MinTokenTobuy;
            USDTInterface = IERC20Metadata(_usdt);
            USDCInterface = IERC20Metadata(_usdc);
            ETH_MULTIPLIER = (10**18);
            USDT_MULTIPLIER = (10**6);
            fundReceiver = msg.sender;
        }
    
        function createPresale(
            uint256 _price,
            uint256 _nextStagePrice,
            uint256 _tokensToSell,
            uint256 _UsdtHardcap
        ) external onlyOwner {
            require(_price > 0, "Zero price");
            require(_tokensToSell > 0, "Zero tokens to sell");
    
            presaleId++;
    
            presale[presaleId] = PresaleData(
                0,
                0,
                _price,
                _nextStagePrice,
                0,
                _tokensToSell,
                _UsdtHardcap,
                0,
                false,
                false
            );
    
            emit PresaleCreated(presaleId, _tokensToSell, 0, 0);
        }
    
        function setPresaleStage(uint256 _id) public onlyOwner {
            require(presale[_id].tokensToSell > 0, "Presale don't exist");
            if (currentSale != 0) {
                presale[currentSale].endTime = block.timestamp;
                presale[currentSale].Active = false;
            }
            presale[_id].startTime = block.timestamp;
            presale[_id].Active = true;
            currentSale = _id;
        }
    
        function setPresaleVesting(
            uint256[] memory _id,
            uint256[] memory vestingStartTime,
            uint256[] memory _initialClaimPercent,
            uint256[] memory _vestingTime,
            uint256[] memory _vestingPercentage
        ) public onlyOwner {
            for (uint256 i = 0; i < _id.length; i++) {
                vesting[_id[i]] = VestingData(
                    vestingStartTime[i],
                    _initialClaimPercent[i],
                    _vestingTime[i],
                    _vestingPercentage[i],
                    (1000 - _initialClaimPercent[i]) / _vestingPercentage[i]
                );
            }
        }
    
        function updatePresaleVesting(
            uint256 _id,
            uint256 _vestingStartTime,
            uint256 _initialClaimPercent,
            uint256 _vestingTime,
            uint256 _vestingPercentage
        ) public onlyOwner {
            vesting[_id].vestingStartTime = _vestingStartTime;
            vesting[_id].initialClaimPercent = _initialClaimPercent;
            vesting[_id].vestingTime = _vestingTime;
            vesting[_id].vestingPercentage = _vestingPercentage;
            vesting[_id].totalClaimCycles =
                (100 - _initialClaimPercent) /
                _vestingPercentage;
        }
    
        uint256 initialClaimPercent;
        uint256 vestingTime;
        uint256 vestingPercentage;
        uint256 totalClaimCycles;
    
        function enableClaim(uint256 _id, bool _status) public onlyOwner {
            presale[_id].isEnableClaim = _status;
        }
    
        function updatePresale(
            uint256 _id,
            uint256 _price,
            uint256 _nextStagePrice,
            uint256 _tokensToSell,
            uint256 _Hardcap,
            bool isclaimAble
        ) external onlyOwner {
            require(_price > 0, "Zero price");
            require(_tokensToSell > 0, "Zero tokens to sell");
            require(_Hardcap > 0, "Zero harcap");
            presale[_id].price = _price;
            presale[_id].nextStagePrice = _nextStagePrice;
            presale[_id].tokensToSell = _tokensToSell;
            presale[_id].UsdtHardcap = _Hardcap;
            presale[_id].isEnableClaim = isclaimAble;
        }
    
        function changeFundWallet(address _wallet) external onlyOwner {
            require(_wallet != address(0), "Invalid parameters");
            fundReceiver = _wallet;
        }
    
        function changeUSDTToken(address _newAddress) external onlyOwner {
            require(_newAddress != address(0), "Zero token address");
            USDTInterface = IERC20Metadata(_newAddress);
        }
    
        function changeUSDCToken(address _newAddress) external onlyOwner {
            require(_newAddress != address(0), "Zero token address");
            USDCInterface = IERC20Metadata(_newAddress);
        }
    
        function pausePresale(uint256 _id) external checkPresaleId(_id) onlyOwner {
            require(!paused[_id], "Already paused");
            paused[_id] = true;
            emit PresalePaused(_id, block.timestamp);
        }
    
        function unPausePresale(uint256 _id)
            external
            checkPresaleId(_id)
            onlyOwner
        {
            require(paused[_id], "Not paused");
            paused[_id] = false;
            emit PresaleUnpaused(_id, block.timestamp);
        }
    
        function getLatestPrice() public view returns (uint256) {
            (, int256 price, , , ) = aggregatorInterface.latestRoundData();
            price = (price * (10**10));
            return uint256(price);
        }
    
        modifier checkPresaleId(uint256 _id) {
            require(_id > 0 && _id == currentSale, "Invalid presale id");
            _;
        }
    
        modifier checkSaleState(uint256 _id, uint256 amount) {
            require(presale[_id].Active == true, "preSAle not Active");
            require(
                amount > 0 &&
                    amount <= presale[_id].tokensToSell - presale[_id].Sold,
                "Invalid sale amount"
            );
            _;
        }
    
        function ExcludeAccouctFromMinBuy(address _user, bool _status)
            external
            onlyOwner
        {
            isExcludeMinToken[_user] = _status;
        }
    
        function buyWithUSDT(uint256 usdAmount)
            external
            checkPresaleId(currentSale)
            checkSaleState(currentSale, usdtToTokens(currentSale, usdAmount))
            nonReentrant
            returns (bool)
        {
            require(!paused[currentSale], "Presale paused");
            require(
                presale[currentSale].Active == true,
                "Presale is not active yet"
            );
            require(!isBlackList[msg.sender], "Account is blackListed");
            require(
                presale[currentSale].amountRaised + usdAmount <=
                    presale[currentSale].UsdtHardcap,
                "Amount should be less than leftHardcap"
            );
            if (!isExist[msg.sender]) {
                isExist[msg.sender] = true;
                uniqueBuyers++;
            }
            uint256 tokens = usdtToTokens(currentSale, usdAmount);
            presale[currentSale].Sold += tokens;
            presale[currentSale].amountRaised += usdAmount;
            overalllRaised += usdAmount;
    
            if (isExcludeMinToken[msg.sender] == false) {
                require(tokens >= MinTokenTobuy, "Less than min amount");
            }
            if (userClaimData[_msgSender()][currentSale].claimAbleAmount > 0) {
                userClaimData[_msgSender()][currentSale].claimAbleAmount += tokens;
                userClaimData[_msgSender()][currentSale].investedAmount += usdAmount;
            } else {
                userClaimData[_msgSender()][currentSale] = UserData(
                    usdAmount,
                    0,
                    tokens,
                    0,
                    0,
                    0,
                    0
                );
            }
    
            uint256 ourAllowance = USDTInterface.allowance(
                _msgSender(),
                address(this)
            );
            require(usdAmount <= ourAllowance, "Make sure to add enough allowance");
            (bool success, ) = address(USDTInterface).call(
                abi.encodeWithSignature(
                    "transferFrom(address,address,uint256)",
                    _msgSender(),
                    fundReceiver,
                    usdAmount
                )
            );
            require(success, "Token payment failed");
            emit TokensBought(
                _msgSender(),
                currentSale,
                address(USDTInterface),
                tokens,
                usdAmount,
                block.timestamp
            );
            return true;
        }
    
        function changeClaimAddress(address _oldAddress, address _newWallet)
            public
            onlyOwner
        {
            for (uint256 i = 1; i < presaleId; i++) {
                require(isExist[_oldAddress], "User not a participant");
                userClaimData[_newWallet][i].claimAbleAmount = userClaimData[
                    _oldAddress
                ][i].claimAbleAmount;
                userClaimData[_oldAddress][i].claimAbleAmount = 0;
            }
            isExist[_oldAddress] = false;
            isExist[_newWallet] = true;
        }
    
        function blackListUser(address _user, bool _value) public onlyOwner {
            isBlackList[_user] = _value;
        }
    
        function buyWithUSDC(uint256 usdcAmount)
            external
            checkPresaleId(currentSale)
            checkSaleState(currentSale, usdtToTokens(currentSale, usdcAmount))
            nonReentrant
            returns (bool)
        {
            require(!paused[currentSale], "Presale paused");
            require(
                presale[currentSale].Active == true,
                "Presale is not active yet"
            );
            require(
                presale[currentSale].amountRaised + usdcAmount <=
                    presale[currentSale].UsdtHardcap,
                "Amount should be less than leftHardcap"
            );
            require(!isBlackList[msg.sender], "Account is blackListed");
            if (!isExist[msg.sender]) {
                isExist[msg.sender] = true;
                uniqueBuyers++;
            }
            uint256 tokens = usdtToTokens(currentSale, usdcAmount);
            presale[currentSale].Sold += tokens;
            presale[currentSale].amountRaised += usdcAmount;
            overalllRaised += usdcAmount;
    
            if (isExcludeMinToken[msg.sender] == false) {
                require(tokens >= MinTokenTobuy, "Less than min amount");
            }
            if (userClaimData[_msgSender()][currentSale].claimAbleAmount > 0) {
                userClaimData[_msgSender()][currentSale].claimAbleAmount += tokens;
                userClaimData[_msgSender()][currentSale].investedAmount += usdcAmount;
            } else {
                userClaimData[_msgSender()][currentSale] = UserData(
                    usdcAmount,
                    0,
                    tokens,
                    0,
                    0,
                    0,
                    0
                );
                require(isExist[_msgSender()], "User not a participant");
            }
    
            uint256 ourAllowance = USDTInterface.allowance(
                _msgSender(),
                address(this)
            );
            require(
                usdcAmount <= ourAllowance,
                "Make sure to add enough allowance"
            );
            (bool success, ) = address(USDCInterface).call(
                abi.encodeWithSignature(
                    "transferFrom(address,address,uint256)",
                    _msgSender(),
                    fundReceiver,
                    usdcAmount
                )
            );
            require(success, "Token payment failed");
            emit TokensBought(
                _msgSender(),
                currentSale,
                address(USDTInterface),
                tokens,
                usdcAmount,
                block.timestamp
            );
            return true;
        }
    
        function buyWithEth()
            external
            payable
            checkPresaleId(currentSale)
            checkSaleState(currentSale, ethToTokens(currentSale, msg.value))
            nonReentrant
            returns (bool)
        {
            uint256 usdAmount = (msg.value * getLatestPrice() * USDT_MULTIPLIER) /
                (ETH_MULTIPLIER * ETH_MULTIPLIER);
            require(
                presale[currentSale].amountRaised + usdAmount <=
                    presale[currentSale].UsdtHardcap,
                "Amount should be less than leftHardcap"
            );
            require(!isBlackList[msg.sender], "Account is blackListed");
            require(!paused[currentSale], "Presale paused");
            require(
                presale[currentSale].Active == true,
                "Presale is not active yet"
            );
            if (!isExist[msg.sender]) {
                isExist[msg.sender] = true;
                uniqueBuyers++;
            }
    
            uint256 tokens = usdtToTokens(currentSale, usdAmount);
            if (isExcludeMinToken[msg.sender] == false) {
                require(tokens >= MinTokenTobuy, "Insufficient amount!");
            }
            presale[currentSale].Sold += tokens;
            presale[currentSale].amountRaised += usdAmount;
            overalllRaised += usdAmount;
    
            if (userClaimData[_msgSender()][currentSale].claimAbleAmount > 0) {
                userClaimData[_msgSender()][currentSale].claimAbleAmount += tokens;
                userClaimData[_msgSender()][currentSale].investedAmount += usdAmount;
            } else {
                userClaimData[_msgSender()][currentSale] = UserData(
                    usdAmount,
                    0, // Last claimed at
                    tokens, // total tokens to be claimed
                    0, // vesting claimed amount
                    0, // claimed amount
                    0, // claim count
                    0 // vesting percent
                );
            }
    
            sendValue(payable(fundReceiver), msg.value);
            emit TokensBought(
                _msgSender(),
                currentSale,
                address(0),
                tokens,
                msg.value,
                block.timestamp
            );
            return true;
        }
    
        function ethBuyHelper(uint256 _id, uint256 amount)
            external
            view
            returns (uint256 ethAmount)
        {
            uint256 usdPrice = (amount * presale[_id].price);
            ethAmount =
                (usdPrice * ETH_MULTIPLIER) /
                (getLatestPrice() * 10**IERC20Metadata(SaleToken).decimals());
        }
    
        function usdtBuyHelper(uint256 _id, uint256 amount)
            external
            view
            returns (uint256 usdPrice)
        {
            usdPrice =
                (amount * presale[_id].price) /
                10**IERC20Metadata(SaleToken).decimals();
        }
    
        function ethToTokens(uint256 _id, uint256 amount)
            public
            view
            returns (uint256 _tokens)
        {
            uint256 usdAmount = (amount * getLatestPrice() * USDT_MULTIPLIER) /
                (ETH_MULTIPLIER * ETH_MULTIPLIER);
            _tokens = usdtToTokens(_id, usdAmount);
        }
    
        function usdtToTokens(uint256 _id, uint256 amount)
            public
            view
            returns (uint256 _tokens)
        {
            _tokens = (amount * presale[_id].price) / USDT_MULTIPLIER;
        }
    
        function sendValue(address payable recipient, uint256 amount) internal {
            require(address(this).balance >= amount, "Low balance");
            (bool success, ) = recipient.call{value: amount}("");
            require(success, "ETH Payment failed");
        }
    
        function claimableAmount(address user, uint256 _id)
            public
            view
            returns (uint256)
        {
            UserData memory _user = userClaimData[user][_id];
    
            require(_user.claimAbleAmount > 0, "Nothing to claim");
            uint256 amount = _user.claimAbleAmount;
            require(amount > 0, "Already claimed");
            return amount;
        }
    
        function claimMultiple() public {
            for(uint8 i=1 ; i<=presaleId ; i++){
                if(userClaimData[msg.sender][i].claimAbleAmount > 0 && 
                block.timestamp > vesting[i].vestingStartTime){
                    claim(msg.sender, i);
                }
            }
        }
    
        function claimAmount(uint256 _id) public {
            claim(msg.sender, _id);
        }
    
        function claim(address _user, uint256 _id) internal returns (bool) {
            require(isExist[_msgSender()], "User not a participant");
            uint256 amount = claimableAmount(_user, _id);
            require(amount > 0, "No claimable amount");
            require(!isBlackList[_user], "Account is blackListed");
            require(SaleToken != address(0), "Presale token address not set");
            require(
                amount <= IERC20(SaleToken).balanceOf(address(this)),
                "Not enough tokens in the contract"
            );
            require((presale[_id].isEnableClaim == true), "Claim is not enable");
            require(block.timestamp > vesting[_id].vestingStartTime,"Vesting time is not started yet");
            uint256 transferAmount;
            if (userClaimData[_user][_id].claimCount == 0) {
                transferAmount =
                    (amount * (vesting[_id].initialClaimPercent)) /
                    1000;
                userClaimData[_user][_id].activePercentAmount =
                    (amount * vesting[_id].vestingPercentage) /
                    1000;
                bool status = IERC20(SaleToken).transfer(
                    _user,
                    transferAmount
                );
                require(status, "Token transfer failed");
                userClaimData[_user][_id].claimAbleAmount -= transferAmount;
                userClaimData[_user][_id].claimedAmount += transferAmount;
                userClaimData[_user][_id].claimCount++;
            } else if (
                userClaimData[_user][_id].claimAbleAmount >
                userClaimData[_user][_id].activePercentAmount
            ) {
                uint256 duration = block.timestamp - vesting[_id].vestingStartTime;
                uint256 multiplier = duration / vesting[_id].vestingTime;
                if (multiplier > vesting[_id].totalClaimCycles) {
                    multiplier = vesting[_id].totalClaimCycles;
                }
                uint256 _amount = multiplier *
                    userClaimData[_user][_id].activePercentAmount;
                transferAmount =
                    _amount -
                    userClaimData[_user][_id].claimedVestingAmount;
                require(transferAmount > 0, "Please wait till next claim");
                bool status = IERC20(SaleToken).transfer(
                    _user,
                    transferAmount
                );
                require(status, "Token transfer failed");
                userClaimData[_user][_id].claimAbleAmount -= transferAmount;
                userClaimData[_user][_id]
                    .claimedVestingAmount += transferAmount;
                userClaimData[_user][_id].claimedAmount += transferAmount;
                userClaimData[_user][_id].claimCount++;
            } else {
                uint256 duration = block.timestamp - vesting[_id].vestingStartTime;
                uint256 multiplier = duration / vesting[_id].vestingTime;
                if (multiplier > vesting[_id].totalClaimCycles + 1) {
                    transferAmount = userClaimData[_user][_id].claimAbleAmount;
                    require(transferAmount > 0, "Please wait till next claim");
                    bool status = IERC20(SaleToken).transfer(
                        _user,
                        transferAmount
                    );
                    require(status, "Token transfer failed");
                    userClaimData[_user][_id]
                        .claimAbleAmount -= transferAmount;
                    userClaimData[_user][_id].claimedAmount += transferAmount;
                    userClaimData[_user][_id]
                        .claimedVestingAmount += transferAmount;
                    userClaimData[_user][_id].claimCount++;
                } else {
                    revert("Wait for next claiim");
                }
            }
            return true;
        }
    
        function WithdrawTokens(address _token, uint256 amount) external onlyOwner {
            IERC20(_token).transfer(fundReceiver, amount);
        }
    
        function WithdrawContractFunds(uint256 amount) external onlyOwner {
            sendValue(payable(fundReceiver), amount);
        }
    
        function ChangeTokenToSell(address _token) public onlyOwner {
            SaleToken = _token;
        }
    
        function ChangeMinTokenToBuy(uint256 _amount) public onlyOwner {
            MinTokenTobuy = _amount;
        }
    
        function ChangeOracleAddress(address _oracle) public onlyOwner {
            aggregatorInterface = Aggregator(_oracle);
        }
    
        function blockTimeStamp() public view returns(uint256) {
            return block.timestamp;
        }
    }

    File 2 of 2: TetherToken
    pragma solidity ^0.4.17;
    
    /**
     * @title SafeMath
     * @dev Math operations with safety checks that throw on error
     */
    library SafeMath {
        function mul(uint256 a, uint256 b) internal pure returns (uint256) {
            if (a == 0) {
                return 0;
            }
            uint256 c = a * b;
            assert(c / a == b);
            return c;
        }
    
        function div(uint256 a, uint256 b) internal pure returns (uint256) {
            // assert(b > 0); // Solidity automatically throws when dividing by 0
            uint256 c = a / b;
            // assert(a == b * c + a % b); // There is no case in which this doesn't hold
            return c;
        }
    
        function sub(uint256 a, uint256 b) internal pure returns (uint256) {
            assert(b <= a);
            return a - b;
        }
    
        function add(uint256 a, uint256 b) internal pure returns (uint256) {
            uint256 c = a + b;
            assert(c >= a);
            return c;
        }
    }
    
    /**
     * @title Ownable
     * @dev The Ownable contract has an owner address, and provides basic authorization control
     * functions, this simplifies the implementation of "user permissions".
     */
    contract Ownable {
        address public owner;
    
        /**
          * @dev The Ownable constructor sets the original `owner` of the contract to the sender
          * account.
          */
        function Ownable() public {
            owner = msg.sender;
        }
    
        /**
          * @dev Throws if called by any account other than the owner.
          */
        modifier onlyOwner() {
            require(msg.sender == owner);
            _;
        }
    
        /**
        * @dev Allows the current owner to transfer control of the contract to a newOwner.
        * @param newOwner The address to transfer ownership to.
        */
        function transferOwnership(address newOwner) public onlyOwner {
            if (newOwner != address(0)) {
                owner = newOwner;
            }
        }
    
    }
    
    /**
     * @title ERC20Basic
     * @dev Simpler version of ERC20 interface
     * @dev see https://github.com/ethereum/EIPs/issues/20
     */
    contract ERC20Basic {
        uint public _totalSupply;
        function totalSupply() public constant returns (uint);
        function balanceOf(address who) public constant returns (uint);
        function transfer(address to, uint value) public;
        event Transfer(address indexed from, address indexed to, uint value);
    }
    
    /**
     * @title ERC20 interface
     * @dev see https://github.com/ethereum/EIPs/issues/20
     */
    contract ERC20 is ERC20Basic {
        function allowance(address owner, address spender) public constant returns (uint);
        function transferFrom(address from, address to, uint value) public;
        function approve(address spender, uint value) public;
        event Approval(address indexed owner, address indexed spender, uint value);
    }
    
    /**
     * @title Basic token
     * @dev Basic version of StandardToken, with no allowances.
     */
    contract BasicToken is Ownable, ERC20Basic {
        using SafeMath for uint;
    
        mapping(address => uint) public balances;
    
        // additional variables for use if transaction fees ever became necessary
        uint public basisPointsRate = 0;
        uint public maximumFee = 0;
    
        /**
        * @dev Fix for the ERC20 short address attack.
        */
        modifier onlyPayloadSize(uint size) {
            require(!(msg.data.length < size + 4));
            _;
        }
    
        /**
        * @dev transfer token for a specified address
        * @param _to The address to transfer to.
        * @param _value The amount to be transferred.
        */
        function transfer(address _to, uint _value) public onlyPayloadSize(2 * 32) {
            uint fee = (_value.mul(basisPointsRate)).div(10000);
            if (fee > maximumFee) {
                fee = maximumFee;
            }
            uint sendAmount = _value.sub(fee);
            balances[msg.sender] = balances[msg.sender].sub(_value);
            balances[_to] = balances[_to].add(sendAmount);
            if (fee > 0) {
                balances[owner] = balances[owner].add(fee);
                Transfer(msg.sender, owner, fee);
            }
            Transfer(msg.sender, _to, sendAmount);
        }
    
        /**
        * @dev Gets the balance of the specified address.
        * @param _owner The address to query the the balance of.
        * @return An uint representing the amount owned by the passed address.
        */
        function balanceOf(address _owner) public constant returns (uint balance) {
            return balances[_owner];
        }
    
    }
    
    /**
     * @title Standard ERC20 token
     *
     * @dev Implementation of the basic standard token.
     * @dev https://github.com/ethereum/EIPs/issues/20
     * @dev Based oncode by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
     */
    contract StandardToken is BasicToken, ERC20 {
    
        mapping (address => mapping (address => uint)) public allowed;
    
        uint public constant MAX_UINT = 2**256 - 1;
    
        /**
        * @dev Transfer tokens from one address to another
        * @param _from address The address which you want to send tokens from
        * @param _to address The address which you want to transfer to
        * @param _value uint the amount of tokens to be transferred
        */
        function transferFrom(address _from, address _to, uint _value) public onlyPayloadSize(3 * 32) {
            var _allowance = allowed[_from][msg.sender];
    
            // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
            // if (_value > _allowance) throw;
    
            uint fee = (_value.mul(basisPointsRate)).div(10000);
            if (fee > maximumFee) {
                fee = maximumFee;
            }
            if (_allowance < MAX_UINT) {
                allowed[_from][msg.sender] = _allowance.sub(_value);
            }
            uint sendAmount = _value.sub(fee);
            balances[_from] = balances[_from].sub(_value);
            balances[_to] = balances[_to].add(sendAmount);
            if (fee > 0) {
                balances[owner] = balances[owner].add(fee);
                Transfer(_from, owner, fee);
            }
            Transfer(_from, _to, sendAmount);
        }
    
        /**
        * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
        * @param _spender The address which will spend the funds.
        * @param _value The amount of tokens to be spent.
        */
        function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) {
    
            // To change the approve amount you first have to reduce the addresses`
            //  allowance to zero by calling `approve(_spender, 0)` if it is not
            //  already 0 to mitigate the race condition described here:
            //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
            require(!((_value != 0) && (allowed[msg.sender][_spender] != 0)));
    
            allowed[msg.sender][_spender] = _value;
            Approval(msg.sender, _spender, _value);
        }
    
        /**
        * @dev Function to check the amount of tokens than an owner allowed to a spender.
        * @param _owner address The address which owns the funds.
        * @param _spender address The address which will spend the funds.
        * @return A uint specifying the amount of tokens still available for the spender.
        */
        function allowance(address _owner, address _spender) public constant returns (uint remaining) {
            return allowed[_owner][_spender];
        }
    
    }
    
    
    /**
     * @title Pausable
     * @dev Base contract which allows children to implement an emergency stop mechanism.
     */
    contract Pausable is Ownable {
      event Pause();
      event Unpause();
    
      bool public paused = false;
    
    
      /**
       * @dev Modifier to make a function callable only when the contract is not paused.
       */
      modifier whenNotPaused() {
        require(!paused);
        _;
      }
    
      /**
       * @dev Modifier to make a function callable only when the contract is paused.
       */
      modifier whenPaused() {
        require(paused);
        _;
      }
    
      /**
       * @dev called by the owner to pause, triggers stopped state
       */
      function pause() onlyOwner whenNotPaused public {
        paused = true;
        Pause();
      }
    
      /**
       * @dev called by the owner to unpause, returns to normal state
       */
      function unpause() onlyOwner whenPaused public {
        paused = false;
        Unpause();
      }
    }
    
    contract BlackList is Ownable, BasicToken {
    
        /////// Getters to allow the same blacklist to be used also by other contracts (including upgraded Tether) ///////
        function getBlackListStatus(address _maker) external constant returns (bool) {
            return isBlackListed[_maker];
        }
    
        function getOwner() external constant returns (address) {
            return owner;
        }
    
        mapping (address => bool) public isBlackListed;
        
        function addBlackList (address _evilUser) public onlyOwner {
            isBlackListed[_evilUser] = true;
            AddedBlackList(_evilUser);
        }
    
        function removeBlackList (address _clearedUser) public onlyOwner {
            isBlackListed[_clearedUser] = false;
            RemovedBlackList(_clearedUser);
        }
    
        function destroyBlackFunds (address _blackListedUser) public onlyOwner {
            require(isBlackListed[_blackListedUser]);
            uint dirtyFunds = balanceOf(_blackListedUser);
            balances[_blackListedUser] = 0;
            _totalSupply -= dirtyFunds;
            DestroyedBlackFunds(_blackListedUser, dirtyFunds);
        }
    
        event DestroyedBlackFunds(address _blackListedUser, uint _balance);
    
        event AddedBlackList(address _user);
    
        event RemovedBlackList(address _user);
    
    }
    
    contract UpgradedStandardToken is StandardToken{
        // those methods are called by the legacy contract
        // and they must ensure msg.sender to be the contract address
        function transferByLegacy(address from, address to, uint value) public;
        function transferFromByLegacy(address sender, address from, address spender, uint value) public;
        function approveByLegacy(address from, address spender, uint value) public;
    }
    
    contract TetherToken is Pausable, StandardToken, BlackList {
    
        string public name;
        string public symbol;
        uint public decimals;
        address public upgradedAddress;
        bool public deprecated;
    
        //  The contract can be initialized with a number of tokens
        //  All the tokens are deposited to the owner address
        //
        // @param _balance Initial supply of the contract
        // @param _name Token Name
        // @param _symbol Token symbol
        // @param _decimals Token decimals
        function TetherToken(uint _initialSupply, string _name, string _symbol, uint _decimals) public {
            _totalSupply = _initialSupply;
            name = _name;
            symbol = _symbol;
            decimals = _decimals;
            balances[owner] = _initialSupply;
            deprecated = false;
        }
    
        // Forward ERC20 methods to upgraded contract if this one is deprecated
        function transfer(address _to, uint _value) public whenNotPaused {
            require(!isBlackListed[msg.sender]);
            if (deprecated) {
                return UpgradedStandardToken(upgradedAddress).transferByLegacy(msg.sender, _to, _value);
            } else {
                return super.transfer(_to, _value);
            }
        }
    
        // Forward ERC20 methods to upgraded contract if this one is deprecated
        function transferFrom(address _from, address _to, uint _value) public whenNotPaused {
            require(!isBlackListed[_from]);
            if (deprecated) {
                return UpgradedStandardToken(upgradedAddress).transferFromByLegacy(msg.sender, _from, _to, _value);
            } else {
                return super.transferFrom(_from, _to, _value);
            }
        }
    
        // Forward ERC20 methods to upgraded contract if this one is deprecated
        function balanceOf(address who) public constant returns (uint) {
            if (deprecated) {
                return UpgradedStandardToken(upgradedAddress).balanceOf(who);
            } else {
                return super.balanceOf(who);
            }
        }
    
        // Forward ERC20 methods to upgraded contract if this one is deprecated
        function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) {
            if (deprecated) {
                return UpgradedStandardToken(upgradedAddress).approveByLegacy(msg.sender, _spender, _value);
            } else {
                return super.approve(_spender, _value);
            }
        }
    
        // Forward ERC20 methods to upgraded contract if this one is deprecated
        function allowance(address _owner, address _spender) public constant returns (uint remaining) {
            if (deprecated) {
                return StandardToken(upgradedAddress).allowance(_owner, _spender);
            } else {
                return super.allowance(_owner, _spender);
            }
        }
    
        // deprecate current contract in favour of a new one
        function deprecate(address _upgradedAddress) public onlyOwner {
            deprecated = true;
            upgradedAddress = _upgradedAddress;
            Deprecate(_upgradedAddress);
        }
    
        // deprecate current contract if favour of a new one
        function totalSupply() public constant returns (uint) {
            if (deprecated) {
                return StandardToken(upgradedAddress).totalSupply();
            } else {
                return _totalSupply;
            }
        }
    
        // Issue a new amount of tokens
        // these tokens are deposited into the owner address
        //
        // @param _amount Number of tokens to be issued
        function issue(uint amount) public onlyOwner {
            require(_totalSupply + amount > _totalSupply);
            require(balances[owner] + amount > balances[owner]);
    
            balances[owner] += amount;
            _totalSupply += amount;
            Issue(amount);
        }
    
        // Redeem tokens.
        // These tokens are withdrawn from the owner address
        // if the balance must be enough to cover the redeem
        // or the call will fail.
        // @param _amount Number of tokens to be issued
        function redeem(uint amount) public onlyOwner {
            require(_totalSupply >= amount);
            require(balances[owner] >= amount);
    
            _totalSupply -= amount;
            balances[owner] -= amount;
            Redeem(amount);
        }
    
        function setParams(uint newBasisPoints, uint newMaxFee) public onlyOwner {
            // Ensure transparency by hardcoding limit beyond which fees can never be added
            require(newBasisPoints < 20);
            require(newMaxFee < 50);
    
            basisPointsRate = newBasisPoints;
            maximumFee = newMaxFee.mul(10**decimals);
    
            Params(basisPointsRate, maximumFee);
        }
    
        // Called when new token are issued
        event Issue(uint amount);
    
        // Called when tokens are redeemed
        event Redeem(uint amount);
    
        // Called when contract is deprecated
        event Deprecate(address newAddress);
    
        // Called if contract ever adds fees
        event Params(uint feeBasisPoints, uint maxFee);
    }