Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0x74b2c2BC8Ce10bCfd0731b370C923ed949Dd37Db
Balance 0 ETH
Nonce 1
Code Size 4948 bytes
Indexed Transactions 0 (1 on-chain, 1.2% indexed)
External Etherscan · Sourcify

Contract Bytecode

4948 bytes
0x608060405234801561001057600080fd5b506004361061012c5760003560e01c806378e97925116100ad578063cee2a9cf11610071578063cee2a9cf14610305578063e2bbb15814610338578063f1c8f9641461034b578063f2fde38b1461035e578063fc0c546a1461037157600080fd5b806378e97925146102b25780638da5cb5b146102bb5780638dbb1e3a146102cc578063999ffd97146102df578063aa5f7e26146102f257600080fd5b8063441a3e70116100f4578063441a3e701461025c57806351eb05a61461027157806358225dc2146102845780636d89dbc514610297578063715018a6146102aa57600080fd5b8063081e3eda146101315780631526fe271461014d57806321ce919d146101bd57806329b8caff146102125780633feb5f2b1461021b575b600080fd5b61013a60035481565b6040519081526020015b60405180910390f35b61019061015b36600461110b565b600560208190526000918252604090912080546001820154600283015460038401546004850154949095015492949193909286565b604080519687526020870195909552938501929092526060840152608083015260a082015260c001610144565b6101f76101cb3660046110c2565b600660209081526000928352604080842090915290825290208054600182015460029092015490919083565b60408051938452602084019290925290820152606001610144565b61013a60075481565b61024461022936600461110b565b6008602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610144565b61026f61026a366004611123565b610384565b005b61026f61027f36600461110b565b6105dd565b61013a610292366004611123565b61066d565b61026f6102a5366004611123565b6106c2565b61026f61077e565b61013a60045481565b6000546001600160a01b0316610244565b61013a6102da366004611123565b6107b4565b61013a6102ed3660046110c2565b6107c7565b61026f61030036600461110b565b610897565b6103286103133660046110a8565b60096020526000908152604090205460ff1681565b6040519015158152602001610144565b61026f610346366004611123565b610a2a565b61026f610359366004611144565b610c0f565b61026f61036c3660046110a8565b610c78565b600254610244906001600160a01b031681565b600260015414156103b05760405162461bcd60e51b81526004016103a79061121c565b60405180910390fd5b6002600155816104025760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e203000000060448201526064016103a7565b60035481106104235760405162461bcd60e51b81526004016103a7906111f3565b60008181526005602090815260408083203384526006835281842085855290925290912080548411156104985760405162461bcd60e51b815260206004820152601a60248201527f496e73756666696369656e74207374616b656420616d6f756e7400000000000060448201526064016103a7565b6104a1836105dd565b60008160010154426104b391906112aa565b905060006104d660646104d06104c9888661066d565b8990610d13565b90610d1f565b9050600061050c846002015461050664e8d4a510006104d089600501548960000154610d1390919063ffffffff16565b90610d2b565b905060006105248261051e8a86610d2b565b90610d37565b42600187015585549091506105399089610d2b565b855585546105479089610d2b565b865560018601546105589083610d37565b6001870155600254610574906001600160a01b03163383610d43565b6005860154855461058f9164e8d4a51000916104d091610d13565b6002860155604080518981526020810189905233917ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568910160405180910390a2505060018055505050505050565b6000818152600560205260409020600481015442116105fa575050565b805461060a574260049091015550565b600061061a8260040154426107b4565b90506000610635836003015483610d1390919063ffffffff16565b835490915061065c90610651906104d08464e8d4a51000610d13565b600585015490610d37565b600584015550504260049091015550565b6000828152600560205260408120600201548190610690906104d0856064610d13565b9050601981116106a457600a9150506106bc565b603281116106b65760059150506106bc565b60009150505b92915050565b6000546001600160a01b031633146106ec5760405162461bcd60e51b81526004016103a7906111be565b600060045442116106ff57600454610701565b425b6040805160c08101825260008082526020808301828152838501898152606085018981526080860188815260a087018681526003805488526005968790529887209751885593516001880155915160028701555185870155516004850155519201919091558154929350610774836112ed565b9190505550505050565b6000546001600160a01b031633146107a85760405162461bcd60e51b81526004016103a7906111be565b6107b26000610dab565b565b60006107c08284610d2b565b9392505050565b60008181526005602081815260408084206001600160a01b03871685526006835281852086865290925283209181015460048201549192914211801561080d5750825415155b156108655760006108228460040154426107b4565b9050600061083d856003015483610d1390919063ffffffff16565b855490915061086090610859906104d08464e8d4a51000610d13565b8490610d37565b925050505b61088d826002015461050664e8d4a510006104d0858760000154610d1390919063ffffffff16565b9695505050505050565b600260015414156108ba5760405162461bcd60e51b81526004016103a79061121c565b600260015560035481106108e05760405162461bcd60e51b81526004016103a7906111f3565b60008181526005602052604090206108f7826105dd565b33600090815260066020908152604080832085845290915290206001810154620151809061092590426112aa565b116109725760405162461bcd60e51b815260206004820152601e60248201527f496e73756666696369656e7420636f6d706f756e64206475726174696f6e000060448201526064016103a7565b60006109a0826002015461050664e8d4a510006104d087600501548760000154610d1390919063ffffffff16565b83549091506109af9082610d37565b835581546109bd9082610d37565b80835542600184015560058401546109e09164e8d4a51000916104d09190610d13565b6002830155604080518281526020810186905233917f0e311a2c6dbfb0153ec3a8a5bdca09070b3e5f60768fdc10a20453f38d186873910160405180910390a25050600180555050565b60026001541415610a4d5760405162461bcd60e51b81526004016103a79061121c565b60026001556003548110610a735760405162461bcd60e51b81526004016103a7906111f3565b600254610a8b906001600160a01b0316333085610dfb565b6000818152600560205260409020610aa2826105dd565b8054610aae9084610d37565b81553360008181526006602090815260408083208684528252808320938352600990915290205460ff16158015610ae55750600084115b15610b395760078054600090815260086020526040812080546001600160a01b0319163317905581549190610b19836112ed565b9091555050336000908152600960205260409020805460ff191660011790555b6000610b67826002015461050664e8d4a510006104d087600501548760000154610d1390919063ffffffff16565b8254909150610b769086610d37565b8255426001830155600254610b95906001600160a01b03163383610d43565b60058301548254610bb09164e8d4a51000916104d091610d13565b60028301556001830154610bc49082610d37565b6001840155604080518681526020810186905233917f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15910160405180910390a2505060018055505050565b6000546001600160a01b03163314610c395760405162461bcd60e51b81526004016103a7906111be565b6003548110610c5a5760405162461bcd60e51b81526004016103a7906111f3565b60009081526005602052604090206002810192909255600390910155565b6000546001600160a01b03163314610ca25760405162461bcd60e51b81526004016103a7906111be565b6001600160a01b038116610d075760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103a7565b610d1081610dab565b50565b60006107c0828461128b565b60006107c0828461126b565b60006107c082846112aa565b60006107c08284611253565b6040516001600160a01b038316602482015260448101829052610da690849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610e39565b505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b0380851660248301528316604482015260648101829052610e339085906323b872dd60e01b90608401610d6f565b50505050565b6000610e8e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610f0b9092919063ffffffff16565b805190915015610da65780806020019051810190610eac91906110eb565b610da65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103a7565b6060610f1a8484600085610f22565b949350505050565b606082471015610f835760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016103a7565b6001600160a01b0385163b610fda5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103a7565b600080866001600160a01b03168587604051610ff6919061116f565b60006040518083038185875af1925050503d8060008114611033576040519150601f19603f3d011682016040523d82523d6000602084013e611038565b606091505b5091509150611048828286611053565b979650505050505050565b606083156110625750816107c0565b8251156110725782518084602001fd5b8160405162461bcd60e51b81526004016103a7919061118b565b80356001600160a01b03811681146110a357600080fd5b919050565b6000602082840312156110b9578081fd5b6107c08261108c565b600080604083850312156110d4578081fd5b6110dd8361108c565b946020939093013593505050565b6000602082840312156110fc578081fd5b815180151581146107c0578182fd5b60006020828403121561111c578081fd5b5035919050565b60008060408385031215611135578182fd5b50508035926020909101359150565b600080600060608486031215611158578081fd5b505081359360208301359350604090920135919050565b600082516111818184602087016112c1565b9190910192915050565b60208152600082518060208401526111aa8160408501602087016112c1565b601f01601f19169190910160400192915050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600f908201526e125b9d985b1a59081c1bdbdb081a59608a1b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6000821982111561126657611266611308565b500190565b60008261128657634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156112a5576112a5611308565b500290565b6000828210156112bc576112bc611308565b500390565b60005b838110156112dc5781810151838201526020016112c4565b83811115610e335750506000910152565b600060001982141561130157611301611308565b5060010190565b634e487b7160e01b600052601160045260246000fdfea26469706673582212207dc5205ab65dd5cf5a8260a9e173d5035c255e9223672c8fc373bab37f4803df64736f6c63430008040033

Verified Source Code Partial Match

Compiler: v0.8.4+commit.c7e474f2 EVM: istanbul Optimization: Yes (200 runs)
AethraStaking.sol 1038 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    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");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    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");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}


pragma solidity ^0.8.0;

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    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));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        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) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

pragma solidity 0.8.4;

contract AethraStaking is Ownable, ReentrancyGuard {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    IERC20 public token; // Token to be staked
    uint256 public poolLength; // Number of pools
    uint256 public startTime;

    struct PoolInfo {
        uint256 totalStaked; // Total amount of token staked in the pool
        uint256 totalRewarded; // Total rewards for the pool
        uint256 duration; // Duration in seconds
        uint256 emission;
        uint256 lastRewardBlock;
        uint256 accPointPerShare;
    }

    struct UserInfo {
        uint256 staked; // Amount of token staked
        uint256 lastStakedTime; // Last time staked
        uint256 rewardDebt; // Reward debt.
    }

    mapping(uint256 => PoolInfo) public poolInfo; // Pool information
    mapping(address => mapping(uint256 => UserInfo)) public userInfo; // User information

    uint256 public totalInvestors;
    mapping(uint256 => address) public investors;
    mapping(address => bool) public isInvestor;

    event Deposit(address indexed user, uint256 amount, uint256 pid); // Event for deposit
    event Withdraw(address indexed user, uint256 amount, uint256 pid); // Event for withdraw
    event Compound(address indexed user, uint256 amount, uint256 pid); // Event for compound

    constructor(
        address _token,
        uint256 _startTime
    ) {
        token = IERC20(_token);
        startTime = _startTime;
    }

    /**
     * @notice Adds a new staking pool with the specified parameters.
     * @dev This function can only be called by the contract owner.
     * @param _duration The duration of the staking pool in seconds.
     * @param _emission The token emission per second for the staking pool.
     */
    function addPool(uint256 _duration, uint256 _emission) external onlyOwner {
        uint256 lastRewardBlock = block.timestamp > startTime ? block.timestamp : startTime;
        poolInfo[poolLength] = PoolInfo({
            totalStaked: 0,
            totalRewarded: 0,
            duration: _duration,
            emission: _emission,
            lastRewardBlock: lastRewardBlock,
            accPointPerShare: 0
        });
        poolLength ++;
    }

    /**
     * @notice Updates the parameters of an existing staking pool.
     * @dev This function can only be called by the contract owner.
     * @param _duration The new duration of the staking pool in seconds.
     * @param _emission The token emission per second for the staking pool.
     * @param _pid The id of the staking pool.
     */
    function setPool(uint256 _duration, uint256 _emission, uint256 _pid) external onlyOwner {
        require(_pid < poolLength, "Invalid pool id");
        poolInfo[_pid].duration = _duration;
        poolInfo[_pid].emission = _emission;
    }

	function getMultiplier(uint256 _from, uint256 _to) public pure returns (uint256) {
        return _to.sub(_from);
    }

    function getPenalty(uint256 _pid, uint256 _duration) public view returns (uint256) {
        uint256 passedRate = _duration.mul(100).div(poolInfo[_pid].duration);
        if (passedRate <= 25) {
            return 10;
        } 
        if (passedRate <= 50) {
            return 5;
        }
        return 0;
    }

    function updatePool(uint256 _pid) public {
        PoolInfo storage pool = poolInfo[_pid];
        if (block.timestamp <= pool.lastRewardBlock) {
            return;
        }
        if (pool.totalStaked == 0) {
            pool.lastRewardBlock = block.timestamp;
            return;
        }
        uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.timestamp);
        uint256 tokenReward = multiplier.mul(pool.emission);
        pool.accPointPerShare = pool.accPointPerShare.add(tokenReward.mul(1e12).div(pool.totalStaked));
        pool.lastRewardBlock = block.timestamp;
    }

    /**
     * @notice Allows a user to deposit a specified amount of tokens for staking.
     * @dev This function is protected by the nonReentrant modifier to prevent reentrancy attacks.
     * @param _amount The amount of tokens to be deposited.
     * @param _pid The id of the staking pool.
     */
    function deposit(uint256 _amount, uint256 _pid) external nonReentrant {
        require(_pid < poolLength, "Invalid pool id");
        token.safeTransferFrom(msg.sender, address(this), _amount);

        PoolInfo storage pool = poolInfo[_pid];
        updatePool(_pid);
        pool.totalStaked = pool.totalStaked.add(_amount);

        UserInfo storage user = userInfo[msg.sender][_pid];

        if (!isInvestor[msg.sender] && _amount > 0) {
            investors[totalInvestors] = msg.sender;
            totalInvestors ++;
            isInvestor[msg.sender] = true;
        }

        uint256 pendingReward = user.staked.mul(pool.accPointPerShare).div(1e12).sub(user.rewardDebt);

        user.staked = user.staked.add(_amount);
        user.lastStakedTime = block.timestamp;

        token.safeTransfer(msg.sender, pendingReward);

        user.rewardDebt = user.staked.mul(pool.accPointPerShare).div(1e12);
        pool.totalRewarded = pool.totalRewarded.add(pendingReward);

        emit Deposit(msg.sender, _amount, _pid);
    }

    /**
     * @notice Allows a user to compound pending reward of tokens for staking.
     * @dev This function is protected by the nonReentrant modifier to prevent reentrancy attacks.
     * @param _pid The id of the staking pool.
     */
    function compound(uint256 _pid) external nonReentrant {
        require(_pid < poolLength, "Invalid pool id");
        
        PoolInfo storage pool = poolInfo[_pid];
        updatePool(_pid);

        UserInfo storage user = userInfo[msg.sender][_pid];
        require(block.timestamp - user.lastStakedTime > 1 days, "Insufficient compound duration");

        uint256 pendingReward = user.staked.mul(pool.accPointPerShare).div(1e12).sub(user.rewardDebt);

        pool.totalStaked = pool.totalStaked.add(pendingReward);

        user.staked = user.staked.add(pendingReward);
        user.lastStakedTime = block.timestamp;

        user.rewardDebt = user.staked.mul(pool.accPointPerShare).div(1e12);

        emit Compound(msg.sender, pendingReward, _pid);
    }

    /**
     * @notice Withdraws a specified amount of token from the contract.
     * @dev This function allows the caller to withdraw a certain amount of ether from the contract.
     *      It checks if the contract has enough balance to fulfill the withdrawal request.
     *      Emits a {Withdraw} event upon successful withdrawal.
     * @param _amount The amount of token to withdraw.
     * @param _pid The id of the staking pool.
     */
    function withdraw(uint256 _amount, uint256 _pid) external nonReentrant {
        require(_amount > 0, "Amount must be greater than 0");
        require(_pid < poolLength, "Invalid pool id");

        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[msg.sender][_pid];
        require(user.staked >= _amount, "Insufficient staked amount");

        updatePool(_pid);

        uint256 duration = block.timestamp - user.lastStakedTime;

        uint256 penaltyAmount = _amount.mul(getPenalty(_pid, duration)).div(100);

        uint256 pendingReward = user.staked.mul(pool.accPointPerShare).div(1e12).sub(user.rewardDebt);

        uint256 withdrawAmount = _amount.sub(penaltyAmount).add(pendingReward);

        user.lastStakedTime = block.timestamp;
        user.staked = user.staked.sub(_amount);

        pool.totalStaked = pool.totalStaked.sub(_amount);
        pool.totalRewarded = pool.totalRewarded.add(pendingReward);

        token.safeTransfer(msg.sender, withdrawAmount);

        user.rewardDebt = user.staked.mul(pool.accPointPerShare).div(1e12);

        emit Withdraw(msg.sender, _amount, _pid);
    }

    /**
     * @notice Calculates the pending reward for a given user and reward type.
     * @param _user The address of the user whose pending reward is to be calculated.
     * @param _pid The id of the staking pool.
     * @return pendingReward The amount of pending reward for the specified user and reward type.
     */
    function getPendingReward(address _user, uint256 _pid) external view returns (uint256) {
	    PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_user][_pid];
        uint256 accPointPerShare = pool.accPointPerShare;
        if (block.timestamp > pool.lastRewardBlock && pool.totalStaked != 0) {
            uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.timestamp);
            uint256 tokenReward = multiplier.mul(pool.emission);
            accPointPerShare = accPointPerShare.add(tokenReward.mul(1e12).div(pool.totalStaked));
        }
        return user.staked.mul(accPointPerShare).div(1e12).sub(user.rewardDebt);
    }
}

Read Contract

getMultiplier 0x8dbb1e3a → uint256
getPenalty 0x58225dc2 → uint256
getPendingReward 0x999ffd97 → uint256
investors 0x3feb5f2b → address
isInvestor 0xcee2a9cf → bool
owner 0x8da5cb5b → address
poolInfo 0x1526fe27 → uint256, uint256, uint256, uint256, uint256, uint256
poolLength 0x081e3eda → uint256
startTime 0x78e97925 → uint256
token 0xfc0c546a → address
totalInvestors 0x29b8caff → uint256
userInfo 0x21ce919d → uint256, uint256, uint256

Write Contract 8 functions

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

addPool 0x6d89dbc5
uint256 _duration
uint256 _emission
compound 0xaa5f7e26
uint256 _pid
deposit 0xe2bbb158
uint256 _amount
uint256 _pid
renounceOwnership 0x715018a6
No parameters
setPool 0xf1c8f964
uint256 _duration
uint256 _emission
uint256 _pid
transferOwnership 0xf2fde38b
address newOwner
updatePool 0x51eb05a6
uint256 _pid
withdraw 0x441a3e70
uint256 _amount
uint256 _pid

Recent Transactions

This address has 1 on-chain transactions, but only 1.2% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →