通过这段神奇的代码 ,就可以判断出来加池子和撤池子了
event test(bool a,bool b ,address c,uint d,uint e);
function _isLiquidity(address from,address to)internal returns(bool isAdd,bool isDel,address,uint,uint){
address token0 = IUniswapV2Pair(address(uniswapV2Pair)).token0();
(uint r0,) = IUniswapV2Pair(address(uniswapV2Pair)).getReserves();
uint bal0 = IERC20(token0).balanceOf(address(uniswapV2Pair));
if( ammPairs[to] ){
if( token0 != address(this) && bal0 > r0 ){
isAdd = bal0 – r0 > addPriceTokenAmount;
}
}
if( ammPairs[from] ){
if( token0 != address(this) && bal0 < r0 ){
isDel = r0 – bal0 > 0;
}
}
emit test(isAdd,isDel,token,r0,bal0);

return (isAdd,isDel,token,r0,bal0);}

然后再通过from和to的地址,判断一下是否是lp地址,就可以区分卖或者卖了。太神奇了