FomoManager

Description:

Multi-signature wallet contract requiring multiple confirmations for transaction execution.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @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.
 *
 * The initial owner is set to the address provided by the deployer. 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;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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 {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _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/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @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;
    }
}
"
    },
    "contracts/FomoManager.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/access/Ownable.sol";

interface IUniswapV2Router02 {
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external payable;
    function WETH() external pure returns (address);
}

contract BuyWallet {
    address public immutable manager;
    address public immutable token;
    address public immutable router;
    
    constructor(address _token, address _router) {
        manager = msg.sender;
        token = _token;
        router = _router;
    }
    
    function executeBuy() external {
        require(msg.sender == manager, "Only manager");
        
        uint256 balance = address(this).balance;
        if (balance > 0) {
            address weth = IUniswapV2Router02(router).WETH();
            
            address[] memory path = new address[](2);
            path[0] = weth;
            path[1] = token;
            
            IUniswapV2Router02(router).swapExactETHForTokensSupportingFeeOnTransferTokens{
                value: balance
            }(
                0,
                path,
                address(this),
                block.timestamp
            );
        }
    }
    
    receive() external payable {}
}

contract FomoManager is Ownable {
    address public token;
    address public router;
    
    address[] public buyWallets;
    uint256 public currentWalletIndex;
    uint256 public walletsPerBatch = 10;
    
    mapping(address => bool) public isAuthorized;
    
    event WalletCreated(address indexed wallet, uint256 index);
    event BuyExecuted(address indexed wallet, uint256 amount);
    event TokenAddressUpdated(address indexed oldToken, address indexed newToken);
    
    modifier onlyAuthorized() {
        require(isAuthorized[msg.sender] || msg.sender == owner(), "Not authorized");
        _;
    }
    
    constructor(address _token, address _router) Ownable(msg.sender) {
        token = _token;
        router = _router;
        if (_token != address(0)) {
            isAuthorized[_token] = true;
        }
        
        if (_token != address(0)) {
            _createWalletBatch();
        }
    }
    
    function updateTokenAddress(address _newToken) external onlyOwner {
        require(_newToken != address(0), "Invalid token address");
        require(token == address(0), "Token already set");
        
        address oldToken = token;
        token = _newToken;
        isAuthorized[_newToken] = true;
        
        _createWalletBatch();
        
        emit TokenAddressUpdated(oldToken, _newToken);
    }
    
    function setAuthorized(address account, bool authorized) external onlyOwner {
        isAuthorized[account] = authorized;
    }
    
    function setWalletsPerBatch(uint256 _amount) external onlyOwner {
        require(_amount > 0 && _amount <= 50, "Invalid batch size");
        walletsPerBatch = _amount;
    }
    
    function _createWalletBatch() private {
        for (uint256 i = 0; i < walletsPerBatch; i++) {
            BuyWallet newWallet = new BuyWallet(token, router);
            buyWallets.push(address(newWallet));
            emit WalletCreated(address(newWallet), buyWallets.length - 1);
        }
    }
    
    function getNextBuyWallet() external onlyAuthorized returns (address) {
        if (currentWalletIndex >= buyWallets.length - 5) {
            _createWalletBatch();
        }
        
        address wallet = buyWallets[currentWalletIndex];
        currentWalletIndex++;
        
        return wallet;
    }
    
    function manuallyCreateWallets(uint256 amount) external onlyOwner {
        for (uint256 i = 0; i < amount; i++) {
            BuyWallet newWallet = new BuyWallet(token, router);
            buyWallets.push(address(newWallet));
            emit WalletCreated(address(newWallet), buyWallets.length - 1);
        }
    }
    
    function getTotalWallets() external view returns (uint256) {
        return buyWallets.length;
    }
    
    function getUnusedWallets() external view returns (uint256) {
        if (currentWalletIndex >= buyWallets.length) return 0;
        return buyWallets.length - currentWalletIndex;
    }
    
    function batchExecuteBuys(uint256 count) external onlyAuthorized returns (uint256 successfulBuys) {
        require(count <= 20, "Too many buys");
        
        uint256 startIndex = currentWalletIndex > count ? currentWalletIndex - count : 0;
        
        for (uint256 i = startIndex; i < currentWalletIndex && successfulBuys < count; i++) {
            address wallet = buyWallets[i];
            if (address(wallet).balance > 0) {
                try BuyWallet(payable(wallet)).executeBuy() {
                    successfulBuys++;
                } catch {
                    // Continue on failure
                }
            }
        }
        
        return successfulBuys;
    }
    
    function batchExecuteBuysByRange(uint256 startIndex, uint256 endIndex) external onlyOwner {
        require(endIndex <= buyWallets.length, "Index out of bounds");
        require(endIndex - startIndex <= 20, "Range too large");
        
        for (uint256 i = startIndex; i < endIndex; i++) {
            address wallet = buyWallets[i];
            if (address(wallet).balance > 0) {
                try BuyWallet(payable(wallet)).executeBuy() {
                    emit BuyExecuted(wallet, address(wallet).balance);
                } catch {
                    // Continue on failure
                }
            }
        }
    }
    
    receive() external payable {}
}
"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "evmVersion": "paris",
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    }
  }
}}

Tags:
Multisig, Swap, Multi-Signature, Factory|addr:0x8417349f1c8ba69e9e7fc0ec2f7d50ce078514b9|verified:true|block:23584889|tx:0x9c5623158544fff9b217a7e3a26638fdc24dca4735411f8022605e62c2f2dae6|first_check:1760598687

Submitted on: 2025-10-16 09:11:30

Comments

Log in to comment.

No comments yet.