Verified contractExactMIT
ProxyMassBuyer
Address0xb68efb6a2aee8b537ec000419dfe4a9779d4c5cd
- Balance
0 ETH
- Transactions
36
- Compiler
solc 0.8.8
- Same code
Only this contract
Details
- Compiler
- solc 0.8.8+commit.dddeac2f
- Language
- solidity
- Optimization
- Yes, 200 runs
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 22,785,222
- Creation transaction
- 0x304358fd9f…88f52c1e58
contracts/ProxyMassBuyer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title ProxyMassBuyer (stealth multi-router)
*
* Performs a series of single-hop swaps (WETH -> TOKEN) directly through the
* TOKEN/WETH pair but bundles them into ONE external call using the zero
* selector (0x00000000). Each recipient in the provided list receives an
* equal share of the supplied ETH which is swapped for tokens on their behalf.
*
* Calldata layout after the first 4 zero bytes (dynamic length):
* 0x04 – 0x23 address token – token paired with WETH
* 0x24 – 0x43 uint256 offset – ABI dynamic offset to recipients[]
* 0x44 – … address[] recipients – list of recipient wallets
*
* The ETH sent with the transaction is wrapped into WETH **once** and then
* evenly split across all recipients when executing the swaps.
*/
interface IWETH {
function deposit() external payable;
function transfer(address to, uint256 value) external returns (bool);
}
interface IUniswapV2Pair {
function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112, uint112, uint32);
}
interface IDexRouter {
function factory() external pure returns (address);
function WETH() external pure returns (address);
}
interface IUniswapV2Factory {
function getPair(address tokenA, address tokenB) external view returns (address);
}
interface IERC20 {
function balanceOf(address account) external view returns (uint256);
}
contract ProxyMassBuyer {
address public owner;
IWETH public immutable WETH;
address public immutable uniswapV2Router;
address public immutable uniswapV2Factory;
modifier onlyOwner() {
require(msg.sender == owner, "PMB:not owner");
_;
}
constructor() {
owner = msg.sender;
address _router = _getDEXRouterAddress();
uniswapV2Router = _router;
uniswapV2Factory = IDexRouter(_router).factory();
WETH = IWETH(IDexRouter(_router).WETH());
}
/* ---------------------- admin helpers ---------------------- */
function transferOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0), "PMB:zero owner");
owner = newOwner;
}
function rescue(address token, uint256 amount) external onlyOwner {
if (token == address(0)) {
(bool ok, ) = owner.call{value: amount}("");
require(ok, "PMB:ETH xfer fail");
} else {
(bool ok, ) = token.call(abi.encodeWithSignature("transfer(address,uint256)", owner, amount));
require(ok, "PMB:ERC20 xfer fail");
}
}
receive() external payable {}
/* ------------------- internal helpers ------------------- */
function _getDEXRouterAddress() internal view returns (address) {
if (block.chainid == 1) {
return 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; // Uniswap V2 (Ethereum)
} else if (block.chainid == 56) {
return 0x10ED43C718714eb63d5aA57B78B54704E256024E; // PancakeSwap V2 (BSC)
} else {
revert("Chain ID not supported");
}
}
function _estimateAmountOut(address pair, bool wethIs0, uint amountIn) internal view returns (uint amountOut) {
(uint112 r0, uint112 r1, ) = IUniswapV2Pair(pair).getReserves();
uint reserveIn = wethIs0 ? uint(r0) : uint(r1);
uint reserveOut = wethIs0 ? uint(r1) : uint(r0);
require(reserveIn > 0 && reserveOut > 0, "PMB:bad reserves");
uint amountInWithFee = amountIn * 997;
uint numerator = amountInWithFee * reserveOut;
uint denominator = reserveIn * 1000 + amountInWithFee;
amountOut = numerator / denominator;
}
function _swap(address pair, bool wethIs0, uint amountOut, address recipient) internal {
IUniswapV2Pair(pair).swap(
wethIs0 ? uint256(0) : amountOut,
wethIs0 ? amountOut : uint256(0),
recipient,
""
);
}
/* ---------------- stealth multi-swap entry ---------------- */
fallback() external payable {
/* ------------------------------------------------------------
1) verify selector & minimal calldata length (>= 0x84)
----------------------------------------------------------*/
bytes4 selector;
assembly {
selector := shr(224, calldataload(0))
}
require(selector == 0x00000000, "PMB:bad selector");
require(msg.data.length >= 0x84, "PMB:calldata short");
/* ------------------------------------------------------------
2) decode params – tokenOut & recipients[]
----------------------------------------------------------*/
(address tokenOut, address[] memory recipients) = abi.decode(msg.data[4:], (address, address[]));
uint n = recipients.length;
require(n > 0, "PMB:no recipients");
uint256 amountETH = msg.value;
require(amountETH > 0, "PMB:no ETH");
require(tokenOut != address(0), "PMB:token zero");
/* ------------------------------------------------------------
3) obtain TOKEN/WETH pair & position of WETH
----------------------------------------------------------*/
address pair = IUniswapV2Factory(uniswapV2Factory).getPair(tokenOut, address(WETH));
require(pair != address(0), "PMB:no pair");
address t0 = IUniswapV2Pair(pair).token0();
address t1 = IUniswapV2Pair(pair).token1();
bool wethIs0 = (t0 == address(WETH));
require(wethIs0 ? t1 == tokenOut : t0 == tokenOut, "PMB:pair mismatch");
/* ------------------------------------------------------------
4) wrap ETH once into WETH
----------------------------------------------------------*/
WETH.deposit{value: amountETH}();
/* ------------------------------------------------------------
5) compute per-recipient share (handle remainder)
----------------------------------------------------------*/
uint256 share = amountETH / n;
require(share > 0, "PMB:tiny share");
uint256 remainder = amountETH - share * n;
/* ------------------------------------------------------------
6) loop over recipients & perform swaps
----------------------------------------------------------*/
for (uint i = 0; i < n; ++i) {
address rcpt = recipients[i];
require(rcpt != address(0), "PMB:bad rcpt");
uint256 thisShare = share;
if (i == n - 1) thisShare += remainder; // add leftover to last swap
// transfer WETH to pair
require(WETH.transfer(pair, thisShare), "PMB:WETH xfer fail");
uint amountOutExpected = _estimateAmountOut(pair, wethIs0, thisShare);
uint balanceBefore = IERC20(tokenOut).balanceOf(rcpt);
_swap(pair, wethIs0, amountOutExpected, rcpt);
require(IERC20(tokenOut).balanceOf(rcpt) > balanceBefore, "PMB:no recv");
}
}
} Compiler settingsShow
{
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.