Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0x35eC9E2fEFb60251Eb00B0e4f4fc1AcEda8166f0
Balance 0 ETH
Nonce 1
Code Size 4881 bytes
Indexed Transactions 0 (1 on-chain, 1.3% indexed)
External Etherscan · Sourcify

Contract Bytecode

4881 bytes
0x608060405234801561000f575f5ffd5b5060043610610147575f3560e01c806372f702f3116100bf578063b089b83711610079578063b089b837146102c0578063b40920f7146102c9578063bce8567e146102dc578063d0dbcd24146102ef578063d6e4572114610301578063f2fde38b1461030a575f5ffd5b806372f702f314610240578063842e29811461026b5780638da5cb5b1461028b578063951c69d21461029b578063a5048177146102a4578063a6513562146102ad575f5ffd5b806327c830a91161011057806327c830a9146101c95780632aedd432146101d65780632e1a7d4d146101df578063584b62a1146101f257806361efa9de1461022f578063715018a614610238575f5ffd5b8062cb7db31461014b5780630a179327146101605780630cd5f85b146101735780631852e8d9146101865780631cfff51b146101ac575b5f5ffd5b61015e6101593660046110c0565b61031d565b005b61015e61016e366004611104565b61033c565b61015e61018136600461111f565b610398565b61019961019436600461115a565b6105dd565b6040519081526020015b60405180910390f35b6007546101b99060ff1681565b60405190151581526020016101a3565b6009546101b99060ff1681565b61019960065481565b61015e6101ed366004611182565b610682565b61020561020036600461115a565b610877565b6040805195865260208601949094529284019190915260608301521515608082015260a0016101a3565b61019960035481565b61015e6108c4565b600154610253906001600160a01b031681565b6040516001600160a01b0390911681526020016101a3565b61027e610279366004611199565b6108d7565b6040516101a391906111b2565b5f546001600160a01b0316610253565b61019960045481565b61019960085481565b6101996102bb366004611182565b61097b565b61019960025481565b61015e6102d7366004611182565b610a21565b61015e6102ea366004611104565b610d20565b6007546101b990610100900460ff1681565b61019960055481565b61015e610318366004611199565b610d69565b610325610de2565b600294909455600392909255600455600555600655565b610344610de2565b600780548215156101000261ff00199091161790556040517fe143534ba1fbc8afb2e3ead7b4733722be84ef0a792220f89564b4b779ad4a379061038d90831515815260200190565b60405180910390a150565b60075460ff166103ef5760405162461bcd60e51b815260206004820152601b60248201527f43594e5141493a205374616b696e672069732064697361626c6564000000000060448201526064015b60405180910390fd5b5f821161043e5760405162461bcd60e51b815260206004820152601d60248201527f43594e5141493a2043616e6e6f74207374616b65203020746f6b656e7300000060448201526064016103e6565b806276a700148061045157508062ed4e00145b8061045f575080630163f500145b8061046d5750806301da9c00145b8061047b5750806303170400145b6104c75760405162461bcd60e51b815260206004820152601b60248201527f43594e5141493a20496e76616c6964206c6f636b20706572696f64000000000060448201526064016103e6565b5f6104d18261097b565b6001549091506104ec906001600160a01b0316333086610e3b565b600a5f336001600160a01b03166001600160a01b031681526020019081526020015f206040518060a001604052808581526020014281526020018442610532919061123a565b815260208082018590525f6040928301819052845460018082018755958252908290208451600590920201908155838201519481019490945582820151600285015560608084015160038601556080909301516004909401805460ff1916941515949094179093558051868152928301859052820183905233917fb4caaf29adda3eefee3ad552a8e85058589bf834c7466cae4ee58787f70589ed91015b60405180910390a2505050565b6001600160a01b0382165f908152600a602052604081208054829190849081106106095761060961124d565b5f9182526020918290206040805160a0810182526005909302909101805480845260018201549484019490945260028101549183019190915260038101546060830181905260049091015460ff161515608083015290925060649161066e9190611261565b6106789190611278565b9150505b92915050565b600754610100900460ff166106d95760405162461bcd60e51b815260206004820181905260248201527f43594e5141493a205769746864726177616c73206172652064697361626c656460448201526064016103e6565b335f908152600a602052604090205481106107365760405162461bcd60e51b815260206004820152601b60248201527f43594e5141493a20496e76616c6964207374616b6520696e646578000000000060448201526064016103e6565b335f908152600a602052604081208054839081106107565761075661124d565b5f9182526020909120600590910201600481015490915060ff16156107bd5760405162461bcd60e51b815260206004820152601f60248201527f43594e5141493a205374616b6520616c72656164792077697468647261776e0060448201526064016103e6565b80545f6107ca33856105dd565b90508260020154421015610806575f6064600854846107e99190611261565b6107f39190611278565b90506107ff8184611297565b92505f9150505b60048301805460ff1916600117905561083633610823838561123a565b6001546001600160a01b03169190610ea8565b604080518381526020810183905233917f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6910160405180910390a250505050565b600a602052815f5260405f208181548110610890575f80fd5b5f91825260209091206005909102018054600182015460028301546003840154600490940154929550909350919060ff1685565b6108cc610de2565b6108d55f610ede565b565b6001600160a01b0381165f908152600a60209081526040808320805482518185028101850190935280835260609492939192909184015b82821015610970575f8481526020908190206040805160a081018252600586029092018054835260018082015484860152600282015492840192909252600381015460608401526004015460ff1615156080830152908352909201910161090e565b505050509050919050565b5f816276a7000361098e57505060025490565b8162ed4e00036109a057505060035490565b81630163f500036109b357505060045490565b816301da9c00036109c657505060055490565b816303170400036109d957505060065490565b60405162461bcd60e51b815260206004820152601b60248201527f43594e5141493a20496e76616c6964206c6f636b20706572696f64000000000060448201526064016103e6565b60075460ff16610a735760405162461bcd60e51b815260206004820152601b60248201527f43594e5141493a205374616b696e672069732064697361626c6564000000000060448201526064016103e6565b335f908152600a60205260409020548110610ad05760405162461bcd60e51b815260206004820152601b60248201527f43594e5141493a20496e76616c6964207374616b6520696e646578000000000060448201526064016103e6565b335f908152600a60205260408120805483908110610af057610af061124d565b5f9182526020909120600590910201600481015490915060ff1615610b575760405162461bcd60e51b815260206004820152601f60248201527f43594e5141493a205374616b6520616c72656164792077697468647261776e0060448201526064016103e6565b8060020154421015610bab5760405162461bcd60e51b815260206004820152601d60248201527f43594e5141493a205374616b65206973207374696c6c206c6f636b656400000060448201526064016103e6565b5f610bb633846105dd565b90505f8111610c185760405162461bcd60e51b815260206004820152602860248201527f43594e5141493a204e6f207265776172647320617661696c61626c6520746f206044820152671c995a5b9d995cdd60c21b60648201526084016103e6565b60048201805460ff19166001179055335f908152600a602052604090819020815160a0810190925283549091908190610c5290859061123a565b815260200142815260200184600101548560020154610c719190611297565b610c7b904261123a565b81526003858101546020808401919091525f604093840181905285546001808201885596825290829020855160059092020190815584820151958101959095558383015160028601556060840151918501919091556080909201516004909301805460ff191693151593909317909255815185815290810183905233917f6b889a17798e6d6c713ce057546c5549393d5a61350097aa354585ee243feaff91016105d0565b610d28610de2565b6007805460ff19168215159081179091556040519081527f4f79b573b3d0c2b7908a15cc4a623210a68435e8ba010d62a0d02bf5e99f95529060200161038d565b610d71610de2565b6001600160a01b038116610dd65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103e6565b610ddf81610ede565b50565b5f546001600160a01b031633146108d55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103e6565b6040516001600160a01b038481166024830152838116604483015260648201839052610ea29186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050610f2d565b50505050565b6040516001600160a01b03838116602483015260448201839052610ed991859182169063a9059cbb90606401610e70565b505050565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f610f416001600160a01b03841683610f8e565b905080515f14158015610f65575080806020019051810190610f6391906112aa565b155b15610ed957604051635274afe760e01b81526001600160a01b03841660048201526024016103e6565b6060610f9b83835f610fa2565b9392505050565b606081471015610fc75760405163cd78605960e01b81523060048201526024016103e6565b5f5f856001600160a01b03168486604051610fe291906112c5565b5f6040518083038185875af1925050503d805f811461101c576040519150601f19603f3d011682016040523d82523d5f602084013e611021565b606091505b509150915061103186838361103b565b9695505050505050565b6060826110505761104b82611097565b610f9b565b815115801561106757506001600160a01b0384163b155b1561109057604051639996b31560e01b81526001600160a01b03851660048201526024016103e6565b5080610f9b565b8051156110a75780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5f5f5f5f5f60a086880312156110d4575f5ffd5b505083359560208501359550604085013594606081013594506080013592509050565b8015158114610ddf575f5ffd5b5f60208284031215611114575f5ffd5b8135610f9b816110f7565b5f5f60408385031215611130575f5ffd5b50508035926020909101359150565b80356001600160a01b0381168114611155575f5ffd5b919050565b5f5f6040838503121561116b575f5ffd5b6111748361113f565b946020939093013593505050565b5f60208284031215611192575f5ffd5b5035919050565b5f602082840312156111a9575f5ffd5b610f9b8261113f565b602080825282518282018190525f918401906040840190835b8181101561121b578351805184526020810151602085015260408101516040850152606081015160608501526080810151151560808501525060a0830192506020840193506001810190506111cb565b509095945050505050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561067c5761067c611226565b634e487b7160e01b5f52603260045260245ffd5b808202811582820484141761067c5761067c611226565b5f8261129257634e487b7160e01b5f52601260045260245ffd5b500490565b8181038181111561067c5761067c611226565b5f602082840312156112ba575f5ffd5b8151610f9b816110f7565b5f82518060208501845e5f92019182525091905056fea2646970667358221220f8bad496586b2eddb09941a2d6b703c2bb635bbd9e2a38b56ca25c69b9c3ed0064736f6c634300081c0033

Verified Source Code Partial Match

Compiler: v0.8.28+commit.7893614a EVM: cancun Optimization: Yes (200 runs)
CYNQAISTAKING.sol 667 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

/**
 * @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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 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 Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling 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);
    }
}

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

    /**
     * @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 Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * 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.
     */
    function functionCall(
        address target,
        bytes memory data
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(
            data
        );
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(
        address target,
        bytes memory data
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(
        address target,
        bytes memory data
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata
    ) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}

/**
 * @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;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(
        address spender,
        uint256 currentAllowance,
        uint256 requestedDecrease
    );

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(
            token,
            abi.encodeCall(token.transferFrom, (from, to, value))
        );
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 requestedDecrease
    ) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(
                    spender,
                    currentAllowance,
                    requestedDecrease
                );
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        bytes memory approvalCall = abi.encodeCall(
            token.approve,
            (spender, value)
        );

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(
                token,
                abi.encodeCall(token.approve, (spender, 0))
            );
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @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);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(
        IERC20 token,
        bytes memory data
    ) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success &&
            (returndata.length == 0 || abi.decode(returndata, (bool))) &&
            address(token).code.length > 0;
    }
}

contract CYNQAISTAKING is Ownable {
    IERC20 public stakingToken;
    using SafeERC20 for IERC20;

    uint256 public rewardRate3Months = 400;  //   400% APR Reward
    uint256 public rewardRate6Months = 600;  //   600% APR Reward
    uint256 public rewardRate9Months = 1400; //  1400% APR Reward
    uint256 public rewardRate12Months = 1900; // 1900% APR Reward
    uint256 public rewardRate20Months = 4200; // 4200% APR Reward

    bool public stakingEnabled = true;
    bool public withdrawalsEnabled = true;

    uint256 public earlyWithdrawalPenaltyRate = 20;
    bool public emergencyPaused = false;

    struct Stake {
        uint256 amount;
        uint256 startTime;
        uint256 endTime;
        uint256 rewardRate;
        bool withdrawn;
    }

    mapping(address => Stake[]) public stakes;

    event Staked(address indexed user, uint256 amount, uint256 lockPeriod, uint256 rewardRate);
    event Withdrawn(address indexed user, uint256 amount, uint256 reward);
    event RewardReinvested(address indexed user, uint256 stakeIndex, uint256 amount);
    event TokensDeposited(address indexed owner, uint256 amount);
    event TokensWithdrawn(address indexed owner, uint256 amount);
    event EmergencyPaused(address indexed owner);
    event EmergencyUnpaused(address indexed owner);
    event MaxStakeUpdated(uint256 oldMaxStake, uint256 newMaxStake);
    event StakingStatusUpdated(bool enabled);
    event WithdrawalStatusUpdated(bool enabled);

    constructor(IERC20 _stakingToken) {
        stakingToken = _stakingToken;
    }

    modifier stakingAllowed() {
        require(stakingEnabled, "CYNQAI: Staking is disabled");
        _;
    }

    modifier withdrawalsAllowed() {
        require(withdrawalsEnabled, "CYNQAI: Withdrawals are disabled");
        _;
    }

    function stakeCYNQ(uint256 _amount, uint256 _lockPeriod) external stakingAllowed {
        require(_amount > 0, "CYNQAI: Cannot stake 0 tokens");
        require(
            _lockPeriod == 90 days ||
            _lockPeriod == 180 days ||
            _lockPeriod == 270 days ||
            _lockPeriod == 360 days ||
            _lockPeriod == 600 days ,
            "CYNQAI: Invalid lock period"
        );

        uint256 rewardRate = getRewardRate(_lockPeriod);

        stakingToken.safeTransferFrom(msg.sender, address(this), _amount);

        stakes[msg.sender].push(
            Stake({
                amount: _amount,
                startTime: block.timestamp,
                endTime: block.timestamp + _lockPeriod,
                rewardRate: rewardRate,
                withdrawn: false
            })
        );

        emit Staked(msg.sender, _amount, _lockPeriod, rewardRate);
    }

    function withdraw(uint256 _stakeIndex) external withdrawalsAllowed {
        require(_stakeIndex < stakes[msg.sender].length, "CYNQAI: Invalid stake index");
        Stake storage userStake = stakes[msg.sender][_stakeIndex];
        require(!userStake.withdrawn, "CYNQAI: Stake already withdrawn");

        uint256 amountToWithdraw = userStake.amount;
        uint256 reward = calculateReward(msg.sender, _stakeIndex);

        if (block.timestamp < userStake.endTime) {
            uint256 penalty = (amountToWithdraw * earlyWithdrawalPenaltyRate) /  100;
            amountToWithdraw -= penalty;
            reward = 0;
        }

        userStake.withdrawn = true;
        stakingToken.safeTransfer(msg.sender, amountToWithdraw + reward);

        emit Withdrawn(msg.sender, amountToWithdraw, reward);
    }

    function getUserStakes(address _user) external view returns (Stake[] memory) {
        return stakes[_user];
    }

    function setRewardRate(
        uint256 _rewardRate3Months,
        uint256 _rewardRate6Months,
        uint256 _rewardRate9Months,
        uint256 _rewardRate12Months,
        uint256 _rewardRate20Months) external  onlyOwner {
            
            rewardRate3Months = _rewardRate3Months;
            rewardRate6Months = _rewardRate6Months;
            rewardRate9Months = _rewardRate9Months;
            rewardRate12Months = _rewardRate12Months;
            rewardRate20Months = _rewardRate20Months;

    }

    function setStakingEnabled(bool _enabled) external onlyOwner {
        stakingEnabled = _enabled;
        emit StakingStatusUpdated(_enabled);
    }

    function setWithdrawalsEnabled(bool _enabled) external onlyOwner {
        withdrawalsEnabled = _enabled;
        emit WithdrawalStatusUpdated(_enabled);
    }

    function reinvestReward(uint256 _stakeIndex) external stakingAllowed {
        require(_stakeIndex < stakes[msg.sender].length, "CYNQAI: Invalid stake index");
        Stake storage userStake = stakes[msg.sender][_stakeIndex];
        require(!userStake.withdrawn, "CYNQAI: Stake already withdrawn");
        require(block.timestamp >= userStake.endTime, "CYNQAI: Stake is still locked");

        uint256 reward = calculateReward(msg.sender, _stakeIndex);
        require(reward > 0, "CYNQAI: No rewards available to reinvest");

        userStake.withdrawn = true;

        stakes[msg.sender].push(
            Stake({
                amount: userStake.amount + reward,
                startTime: block.timestamp,
                endTime: block.timestamp + (userStake.endTime - userStake.startTime),
                rewardRate: userStake.rewardRate,
                withdrawn: false
            })
        );

        emit RewardReinvested(msg.sender, _stakeIndex, reward);
    }

    function getRewardRate(uint256 _lockPeriod) public view returns (uint256) {
        if (_lockPeriod == 90 days) return rewardRate3Months;
        if (_lockPeriod == 180 days) return rewardRate6Months;
        if (_lockPeriod == 270 days) return rewardRate9Months;
        if (_lockPeriod == 360 days) return rewardRate12Months;
        if (_lockPeriod == 600 days) return rewardRate20Months;
        revert("CYNQAI: Invalid lock period");
    }

    function calculateReward(address _user, uint256 _stakeIndex) public view returns (uint256) {
        Stake memory userStake = stakes[_user][_stakeIndex];
        return (userStake.amount * userStake.rewardRate) / 100;
    }
}

Read Contract

calculateReward 0x1852e8d9 → uint256
earlyWithdrawalPenaltyRate 0xa5048177 → uint256
emergencyPaused 0x27c830a9 → bool
getRewardRate 0xa6513562 → uint256
getUserStakes 0x842e2981 → tuple[]
owner 0x8da5cb5b → address
rewardRate12Months 0xd6e45721 → uint256
rewardRate20Months 0x2aedd432 → uint256
rewardRate3Months 0xb089b837 → uint256
rewardRate6Months 0x61efa9de → uint256
rewardRate9Months 0x951c69d2 → uint256
stakes 0x584b62a1 → uint256, uint256, uint256, uint256, bool
stakingEnabled 0x1cfff51b → bool
stakingToken 0x72f702f3 → address
withdrawalsEnabled 0xd0dbcd24 → bool

Write Contract 8 functions

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

reinvestReward 0xb40920f7
uint256 _stakeIndex
renounceOwnership 0x715018a6
No parameters
setRewardRate 0x00cb7db3
uint256 _rewardRate3Months
uint256 _rewardRate6Months
uint256 _rewardRate9Months
uint256 _rewardRate12Months
uint256 _rewardRate20Months
setStakingEnabled 0xbce8567e
bool _enabled
setWithdrawalsEnabled 0x0a179327
bool _enabled
stakeCYNQ 0x0cd5f85b
uint256 _amount
uint256 _lockPeriod
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x2e1a7d4d
uint256 _stakeIndex

Recent Transactions

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