Verified contractExactMIT
LpBreakerFromWallet
Address0xdc809a9e56c8b2791f01628efe7e5a43b40bd9e8
- Balance
0 ETH
- Transactions
3
- Compiler
solc 0.6.12
- Same code
Only this contract
Details
- Compiler
- solc 0.6.12+commit.27d51765
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 23,874,280
- Creation transaction
- 0x0062003616…47d35470bb
lpbreaker.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
/// Интерфейс LP-пары (UniswapV2Pair)
interface IUniswapV2Pair {
function balanceOf(address owner) external view returns (uint);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function approve(address spender, uint value) external returns (bool);
function token0() external view returns (address);
function token1() external view returns (address);
}
/// Интерфейс твоего UniswapV2Router02 (берём только нужное)
interface IUniswapV2Router02 {
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
}
/// Минимальный ERC20 для rescue
interface IERC20 {
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount)
external
returns (bool);
}
/// LP Breaker:
/// - ты держишь LP на своём кошельке (owner)
/// - делаешь approve(LpBreaker, amount) на LP-токене
/// - вызываешь breakLP / breakMany
/// - контракт забирает LP через transferFrom,
/// даёт approve роутеру и делает removeLiquidity с to = SAFE_ADDRESS
contract LpBreakerFromWallet {
// Безопасный адрес, куда уйдут токены из ликвидности
address public constant SAFE_ADDRESS =
0xeD87a70e5aE3C84919e882A7b4a526135289a5cB;
address public owner;
modifier onlyOwner() {
require(msg.sender == owner, "LpBreaker: not owner");
_;
}
constructor() public {
owner = msg.sender;
}
function transferOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0), "LpBreaker: zero owner");
owner = newOwner;
}
/// Ломает ОДНУ LP-пару.
/// router — адрес твоего UniswapV2Router02
/// pair — адрес LP токена (пары)
function breakLP(address router, address pair) external onlyOwner {
_breakSingle(router, pair);
}
/// Ломает СРАЗУ НЕСКОЛЬКО LP-пар (можешь передать 15 штук).
function breakMany(address router, address[] calldata pairs)
external
onlyOwner
{
for (uint256 i = 0; i < pairs.length; i++) {
_breakSingle(router, pairs[i]);
}
}
/// Внутренняя логика для одной пары
function _breakSingle(address router, address pair) internal {
IUniswapV2Pair lp = IUniswapV2Pair(pair);
// Сколько LP у твоего адреса (owner)
uint256 liquidity = lp.balanceOf(owner);
require(liquidity > 0, "LpBreaker: no LP balance");
// ВАЖНО: до этого ты должен сделать approve(pair, LpBreaker, liquidity)
// Иначе transferFrom не пройдёт.
require(
lp.transferFrom(owner, address(this), liquidity),
"LpBreaker: transferFrom failed"
);
// Теперь LP лежат на контракте → он сам делает approve на роутер
require(
lp.approve(router, liquidity),
"LpBreaker: approve failed"
);
// Берём адреса токенов из самой пары
address tokenA = lp.token0();
address tokenB = lp.token1();
// removeLiquidity: все underlying токены летят на SAFE_ADDRESS
IUniswapV2Router02(router).removeLiquidity(
tokenA,
tokenB,
liquidity,
0, // amountAMin
0, // amountBMin
SAFE_ADDRESS, // получатель
block.timestamp + 3600 // дедлайн +1 час
);
}
/// На всякий случай: вытянуть любые токены, которые зависли на контракте
function rescueToken(address token, uint256 amount) external onlyOwner {
IERC20(token).transfer(owner, amount);
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.