StoxesFunV3Zap

0xe9cb2486e26a502febca85113030d643bc38f147

Verification
Verified
v0.8.26+commit.8a97fa7a
Type
Contract
1,330 bytes
ABI entries
7
3 read · 1 write
License
none

Contract information

Address
0xe9cb2486e26a502febca85113030d643bc38f147
Chain
Robinhood Chain (4663)
Compiler
v0.8.26+commit.8a97fa7a
Optimization
Enabled
Creation tx
0x307a0a5dfa…5888bab27a

Token

Not a token

This contract does not expose ERC-20 metadata.

Read contract (3)

POOL_FEE()uint24
WETH()address
swapRouter()address

ABI

[
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "swapRouter_",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "weth_",
        "type": "address"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "constructor"
  },
  {
    "inputs": [],
    "name": "InvalidParams",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "NoValue",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "POOL_FEE",
    "outputs": [
      {
        "internalType": "uint24",
        "name": "",
        "type": "uint24"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "WETH",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "token",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "minOut",
        "type": "uint256"
      },
      {
        "internalType": "address",
        "name": "recipient",
        "type": "address"
      }
    ],
    "name": "buy",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "amountOut",
        "type": "uint256"
      }
    ],
    "stateMutability": "payable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "swapRouter",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  }
]

Source code

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {ISwapRouter02} from "./interfaces/IUniswapV3.sol";
import {IWETH} from "./interfaces/IWETH.sol";

interface IERC20Approve {
    function approve(address spender, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
}

/// @title  StoxesFunV3Zap — native-ETH buy zap for stoxes.fun non-taxed tokens
/// @author stoxes.fun
/// @notice One-transaction ETH -> token buy through the existing verified
///         SwapRouter02 (bow.fun model): wraps the sent ETH to WETH, swaps
///         exact-in through the token's 1% V3 pool, and delivers the tokens
///         straight to the recipient (the router pays the pool, the pool pays
///         the recipient — the zap never holds tokens).
///
///         Quoting: `buy` returns `amountOut`, so front-ends quote with a
///         staticCall of `buy` (no separate Quoter needed). Sells do NOT go
///         through the zap — the front-end calls SwapRouter02 directly with
///         multicall [exactInputSingle -> unwrapWETH9] to receive native ETH.
///
///         Stateless and permissionless: no owner, no funds at rest.
contract StoxesFunV3Zap {
    /// @notice The 1% Uniswap V3 fee tier every stoxes.fun non-taxed pool uses.
    uint24 public constant POOL_FEE = 10_000;

    address public immutable swapRouter;
    address public immutable WETH;

    error InvalidParams();
    error NoValue();

    constructor(address swapRouter_, address weth_) {
        if (swapRouter_ == address(0) || weth_ == address(0)) revert InvalidParams();
        swapRouter = swapRouter_;
        WETH = weth_;
    }

    /// @notice Buys `token` with the ETH sent, delivering to `recipient`.
    /// @param  token        The stoxes.fun non-taxed launch token.
    /// @param  minOut       Slippage floor on tokens received (0 for quotes).
    /// @param  recipient    Who receives the tokens (usually the buyer).
    /// @return amountOut    Tokens delivered — staticCall this for a quote.
    function buy(address token, uint256 minOut, address recipient)
        external
        payable
        returns (uint256 amountOut)
    {
        if (msg.value == 0) revert NoValue();
        if (token == address(0) || recipient == address(0)) revert InvalidParams();

        IWETH(WETH).deposit{value: msg.value}();
        if (IERC20Approve(WETH).allowance(address(this), swapRouter) < msg.value) {
            IERC20Approve(WETH).approve(swapRouter, type(uint256).max);
        }

        amountOut = ISwapRouter02(swapRouter).exactInputSingle(
            ISwapRouter02.ExactInputSingleParams({
                tokenIn: WETH,
                tokenOut: token,
                fee: POOL_FEE,
                recipient: recipient,
                amountIn: msg.value,
                amountOutMinimum: minOut,
                sqrtPriceLimitX96: 0
            })
        );
    }
}
Chain explorer1964msChain node91ms