Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x923be051F75b4F5494D45e2Ce2Dda6aBb6C1713B
Balance 0 ETH
Nonce 1
Code Size 3918 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

3918 bytes
0x608060405234801561001057600080fd5b50600436106101165760003560e01c8063cbca47db116100a2578063dd418ae211610071578063dd418ae214610271578063e3a0a14814610284578063ec20b45714610297578063ecbf2398146102aa578063fc0c546a146102d357610116565b8063cbca47db146101f6578063ccec371614610222578063d4ee1d9014610235578063d8cb4aa31461024857610116565b806379ba5097116100e957806379ba5097146101815780637dbfb36d146101895780638da5cb5b146101b457806396f1b6be146101c7578063a3b6120c146101cf57610116565b806321c7901e1461011b578063249eae4d146101415780634e71d92d1461015657806370a082311461016e575b600080fd5b61012e610129366004610d4e565b6102fa565b6040519081526020015b60405180910390f35b61015461014f366004610d98565b610319565b005b61015e610486565b6040519015158152602001610138565b61012e61017c366004610d4e565b610718565b610154610771565b61019c610197366004610e21565b6107e3565b6040516001600160a01b039091168152602001610138565b60065461019c906001600160a01b031681565b61012e610821565b61012e7f00000000000000000000000000000000000000000000000000000000607854f081565b61015e610204366004610d4e565b6001600160a01b031660009081526001602052604090205460ff1690565b610154610230366004610d4e565b61089e565b60075461019c906001600160a01b031681565b61012e610256366004610d4e565b6001600160a01b031660009081526020819052604090205490565b61012e61027f366004610e21565b6109f4565b610154610292366004610d4e565b610a29565b6101546102a5366004610d6f565b610a75565b61012e6102b8366004610d4e565b6001600160a01b031660009081526003602052604090205490565b61019c7f0000000000000000000000003758e00b100876c854636ef8db61988931bb802581565b6001600160a01b0381166000908152600260205260409020545b919050565b6006546001600160a01b0316331461034c5760405162461bcd60e51b815260040161034390610e51565b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000607854f042106103b75760405162461bcd60e51b8152602060048201526019602482015278546f6f206c61746520646f2061646420696e766573746f727360381b6044820152606401610343565b8281146103fe5760405162461bcd60e51b8152602060048201526015602482015274088c2e8c240d8cadccee8d040dcdee840dac2e8c6d605b1b6044820152606401610343565b60005b8381101561047f5761046d85858381811061042c57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906104419190610d4e565b84848481811061046157634e487b7160e01b600052603260045260246000fd5b90506020020135610b18565b8061047781610ee7565b915050610401565b5050505050565b60007f00000000000000000000000000000000000000000000000000000000607854f042116104f75760405162461bcd60e51b815260206004820152601b60248201527f496e697469616c2076657374696e6720696e2070726f677265737300000000006044820152606401610343565b3360009081526001602052604090205460ff166105175761051733610b9a565b601460006105487f00000000000000000000000000000000000000000000000000000000607854f062093a80610e79565b90505b428110156105825761055e600483610e79565b9150816064141561056e57610582565b61057b62093a8082610e79565b905061054b565b3360009081526003602052604090205482111561070e57336000908152600360205260408120546105b39084610ed0565b9050603b83111561061257336000908152600360205260409020546015111561061257336000908152602081905260409020600190556064831480156105f95750604f81115b1561061257336000908152602081905260409020600290555b33600090815260026020526040812054606490610630908490610eb1565b61063a9190610e91565b3360009081526003602052604081208054929350849290919061065e908490610e79565b909155505060405163a9059cbb60e01b8152336004820152602481018290527f0000000000000000000000003758e00b100876c854636ef8db61988931bb80256001600160a01b03169063a9059cbb90604401602060405180830381600087803b1580156106cb57600080fd5b505af11580156106df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107039190610e01565b945050505050610715565b6000925050505b90565b6001600160a01b03811660009081526003602052604081205460649061073e9082610ed0565b6001600160a01b0384166000908152600260205260409020546107619190610eb1565b61076b9190610e91565b92915050565b6007546001600160a01b031633146107c35760405162461bcd60e51b81526020600482015260156024820152742cb7ba9030b932903737ba102732bb9027bbb732b960591b6044820152606401610343565b600780546001600160a01b03199081169091556006805490911633179055565b60006004828154811061080657634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031692915050565b3360009081526001602052604081205460ff16156108815760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420616c726561647920696e697469616c697a656400000000006044820152606401610343565b61088a33610b9a565b503360009081526002602052604090205490565b6006546001600160a01b031633146108c85760405162461bcd60e51b815260040161034390610e51565b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381600087803b15801561090c57600080fd5b505af1158015610920573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109449190610e39565b90506000811161098a5760405162461bcd60e51b81526020600482015260116024820152704e6f7468696e6720746f2072657363756560781b6044820152606401610343565b60065460405163a9059cbb60e01b81526001600160a01b039182166004820152602481018390529083169063a9059cbb90604401600060405180830381600087803b1580156109d857600080fd5b505af11580156109ec573d6000803e3d6000fd5b505050505050565b600060058281548110610a1757634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6006546001600160a01b03163314610a535760405162461bcd60e51b815260040161034390610e51565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6006546001600160a01b03163314610a9f5760405162461bcd60e51b815260040161034390610e51565b7f00000000000000000000000000000000000000000000000000000000607854f04210610b0a5760405162461bcd60e51b8152602060048201526019602482015278546f6f206c61746520646f2061646420696e766573746f727360381b6044820152606401610343565b610b148282610b18565b5050565b6001600160a01b03821660009081526002602052604090205415610b7e5760405162461bcd60e51b815260206004820152601760248201527f4164647265737320616c7265616479206f6e206c6973740000000000000000006044820152606401610343565b6001600160a01b03909116600090815260026020526040902055565b60005b600454811015610cc65760058181548110610bc857634e487b7160e01b600052603260045260246000fd5b906000526020600020015460048281548110610bf457634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546040516370a0823160e01b81526001600160a01b038581166004830152909116906370a0823190602401602060405180830381600087803b158015610c4457600080fd5b505af1158015610c58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7c9190610e39565b610c869190610eb1565b6001600160a01b03831660009081526002602052604081208054909190610cae908490610e79565b90915550819050610cbe81610ee7565b915050610b9d565b506001600160a01b03166000908152600160208190526040909120805460ff19169091179055565b80356001600160a01b038116811461031457600080fd5b60008083601f840112610d16578182fd5b50813567ffffffffffffffff811115610d2d578182fd5b6020830191508360208083028501011115610d4757600080fd5b9250929050565b600060208284031215610d5f578081fd5b610d6882610cee565b9392505050565b60008060408385031215610d81578081fd5b610d8a83610cee565b946020939093013593505050565b60008060008060408587031215610dad578182fd5b843567ffffffffffffffff80821115610dc4578384fd5b610dd088838901610d05565b90965094506020870135915080821115610de8578384fd5b50610df587828801610d05565b95989497509550505050565b600060208284031215610e12578081fd5b81518015158114610d68578182fd5b600060208284031215610e32578081fd5b5035919050565b600060208284031215610e4a578081fd5b5051919050565b6020808252600e908201526d27b7363c903337b91027bbb732b960911b604082015260600190565b60008219821115610e8c57610e8c610f02565b500190565b600082610eac57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615610ecb57610ecb610f02565b500290565b600082821015610ee257610ee2610f02565b500390565b6000600019821415610efb57610efb610f02565b5060010190565b634e487b7160e01b600052601160045260246000fdfea26469706673582212204e81a1223ba69eb3f81c424de100b73003a96daad7593ebd72bdf074e52b312c64736f6c63430008020033

Verified Source Code Partial Match

Compiler: v0.8.2+commit.661d1103 EVM: istanbul Optimization: Yes (200 runs)
UniqVesting.sol 239 lines
// SPDX-License-Identifier: Ulicense
pragma solidity 0.8.2;


// Presale and good ERC20 contracts interaction interface
interface IContracts {
    function balanceOf(address) external returns (uint256);

    function transfer(address, uint256) external returns (bool);
}


// Broken ERC20 transfer for rescue ERC20 tokens
interface IErc20 {
    function balanceOf(address) external returns (uint256);

    // some tokens (like USDT) not return bool as standard require
    function transfer(address, uint256) external;
}


/// @title Uniqly vesting contract
/// @author rav3n_pl
contract UniqVesting {
    // user is eligible to receive bonus NFT tokens (default=0)
    mapping(address => uint256) internal _bonus;

    /// it will be used by future contract
    function bonus(address user) external view returns (uint256) {
        return _bonus[user];
    }

    // user has counted tokens from presale contract/s (default=false)
    mapping(address => bool) internal _initialized;

    function initialized(address user) external view returns (bool) {
        return _initialized[user];
    }

    // total amount of token bought by presale contracts (default=0)
    mapping(address => uint256) internal _tokensTotal;

    function tokensTotal(address user) external view returns (uint256) {
        return _tokensTotal[user];
    }

    // percentage already withdrawn by user (default=0)
    mapping(address => uint256) internal _pctWithdrawn;

    function pctWithdrawn(address user) external view returns (uint256) {
        return _pctWithdrawn[user];
    }

    /// ERC20 token contract address
    address public immutable token;

    address[] internal _presales;

    /// set of addresses of presale contracts
    function presales(uint256 num) external view returns (address) {
        return _presales[num];
    }

    uint256[] internal _rates;

    /// rates ETH/token for each contract
    function rates(uint256 num) external view returns (uint256) {
        return _rates[num];
    }

    /// timestamp that users can start withdrawals
    uint256 public immutable dateStart;
    /// address of contract owner
    address public owner;

    /**
    @dev contract constructor
    @param _token address of ERC20 token contract
    @param _presale address[] of collection contract addresses
    @param _rate uint256[] ETH/token conversion rate for each contract
    @param _dateStart uint256 timestamp from when users can start withdrawing tokens 
    */
    constructor(
        address _token,
        address[] memory _presale,
        uint256[] memory _rate,
        uint256 _dateStart
    ) {
        token = _token;
        _presales = _presale;
        _rates = _rate;
        dateStart = _dateStart;
        owner = msg.sender;
    }

    /**
    @dev user can call to calculate total tokens w/o taking them
    @return total number of tokens eligible to withdraw
    */
    function calc() external returns (uint256) {
        require(!_initialized[msg.sender], "Account already initialized");
        _init(msg.sender);
        return _tokensTotal[msg.sender];
    }

    /**
    @dev Number of tokens eligible to withdraw
    works only if user used calc() or claim() earlier
    @return number of tokens available for user
     */
    function balanceOf(address user) external view returns (uint256) {
        return (_tokensTotal[user] * (100 - _pctWithdrawn[user])) / 100;
    }

    // internal account init function checking and calculating amounts from contracts
    function _init(address user) internal {
        // for each presale contract
        for (uint256 i = 0; i < _presales.length; i++) {
            // count number of tokens
            _tokensTotal[user] +=
                IContracts(_presales[i]).balanceOf(user) *
                _rates[i];
        }
        // don't do this again
        _initialized[user] = true;
    }

    /**
    @dev user call this function to withdraw tokens
    @return bool true if any token transfer made
    */
    function claim() external returns (bool) {
        // can't work before timestamp
        require(block.timestamp > dateStart, "Initial vesting in progress");
        // check for token amount if need
        if (!_initialized[msg.sender]) {
            _init(msg.sender);
        }
        // initial percent is 20
        uint256 pct = 20;
        uint256 time = dateStart + 1 weeks;
        // every week to date
        while (time < block.timestamp) {
            pct += 4;
            // can't be more than 100
            if (pct == 100) {
                break;
            }
            time += 1 weeks;
        }
        // do we have any % of tokens to withdraw?
        if (pct > _pctWithdrawn[msg.sender]) {
            uint256 thisTime = pct - _pctWithdrawn[msg.sender];
            // is user a patient one?
            // you've got a prize/s in near future!
            if (pct > 59) {
                // 60% for 1st bonus, even when initial 20% claimed
                // but no bonus at all if claimed more than 20%
                if (_pctWithdrawn[msg.sender] < 21) {
                    _bonus[msg.sender] = 1;
                    // second bonus after 100% and max 20% withdrawn
                    if (pct == 100 && thisTime > 79) {
                        _bonus[msg.sender] = 2;
                    }
                }
            }
            // how many tokens it would be...
            uint256 amt = (_tokensTotal[msg.sender] * thisTime) / 100;
            // yes, no reentrance please
            _pctWithdrawn[msg.sender] += thisTime;
            // transfer tokens counted
            return IContracts(token).transfer(msg.sender, amt);
        }
        // did nothing
        return false;
    }

    modifier onlyOwner {
        require(msg.sender == owner, "Only for Owner");
        _;
    }

    // change ownership in two steps to be sure about owner address
    address public newOwner;

    // only current owner can delegate new one
    function giveOwnership(address _newOwner) external onlyOwner {
        newOwner = _newOwner;
    }

    // new owner need to accept ownership
    function acceptOwnership() external {
        require(msg.sender == newOwner, "You are not New Owner");
        newOwner = address(0);
        owner = msg.sender;
    }

    /**
    @dev Add investor to vesting contract that not used collection contract
    @param addr - address to add
    @param amount - tokens due
    */
    function addInvestor(address addr, uint256 amount) external onlyOwner {
        require(block.timestamp < dateStart, "Too late do add investors");
        _addInvestor(addr, amount);
    }

    /**
    @dev Add investors in bulk
    @param addr table of addresses
    @param amount table of amounts
    */
    function addInvestors(address[] calldata addr, uint256[] calldata amount)
        external
        onlyOwner
    {
        require(block.timestamp < dateStart, "Too late do add investors");
        require(addr.length == amount.length, "Data length not match");
        for (uint256 i = 0; i < addr.length; i++) {
            _addInvestor(addr[i], amount[i]);
        }
    }

    // internal function adding investors
    function _addInvestor(address addr, uint256 amt) internal {
        require(_tokensTotal[addr] == 0, "Address already on list");
        _tokensTotal[addr] = amt;
    }

    /**
    @dev Function to recover accidentally send ERC20 tokens
    @param _token ERC20 token address
    */
    function rescueERC20(address _token) external onlyOwner {
        uint256 amt = IErc20(_token).balanceOf(address(this));
        require(amt > 0, "Nothing to rescue");
        IErc20(_token).transfer(owner, amt);
    }
}

Read Contract

balanceOf 0x70a08231 → uint256
bonus 0xd8cb4aa3 → uint256
dateStart 0xa3b6120c → uint256
initialized 0xcbca47db → bool
newOwner 0xd4ee1d90 → address
owner 0x8da5cb5b → address
pctWithdrawn 0xecbf2398 → uint256
presales 0x7dbfb36d → address
rates 0xdd418ae2 → uint256
token 0xfc0c546a → address
tokensTotal 0x21c7901e → uint256

Write Contract 7 functions

These functions modify contract state and require a wallet transaction to execute.

acceptOwnership 0x79ba5097
No parameters
addInvestor 0xec20b457
address addr
uint256 amount
addInvestors 0x249eae4d
address[] addr
uint256[] amount
calc 0x96f1b6be
No parameters
returns: uint256
claim 0x4e71d92d
No parameters
returns: bool
giveOwnership 0xe3a0a148
address _newOwner
rescueERC20 0xccec3716
address _token

Recent Transactions

No transactions found for this address