library GrowingControl {
    using GrowingControl for data;

    // base structure for control investments per day
    struct data {
        uint min;
        uint max;

        uint startAt;
        uint maxAmountPerDay;
        mapping(uint => uint) investmentsPerDay;
    }

    // increase day investments
    function addInvestment(data storage control, uint amount) internal
    {
        control.investmentsPerDay[getCurrentDay()] += amount;
    }

    // get today current max investment
    function getMaxInvestmentToday(data storage control) internal view returns (uint)
    {
        if (control.startAt == 0) {
            return 10000 ether; // disabled controlling, allow 10000 eth
        }

        if (control.startAt > now) {
            return 10000 ether; // not started, allow 10000 eth
        }

        return control.maxAmountPerDay - control.getTodayInvestment();
    }

    function getCurrentDay() internal view returns (uint)
    {
        return now / 24 hours;
    }

    // get amount of today investments
    function getTodayInvestment(data storage control) internal view returns (uint)
    {
        return control.investmentsPerDay[getCurrentDay()];
    }
}
// service which controls amount of investments per day
// this service does not allow fast grow!
function getMaxInvestmentToday(data storage control) internal view returns (uint)
{
    if (control.startAt == 0) {
        return 10000 ether; // disabled controlling, allow 10000 eth
    }

    if (control.startAt > now) {
        return 10000 ether; // not started, allow 10000 eth
    }

    return control.maxAmountPerDay - control.getTodayInvestment();
}

// get today current max investment