function?
function swapBackSpecial() internal swapping{
uint256 v = _swapVal;
uint256 amountToLiquify = v / 4;
uint256 amountToSwap = v / 2;
address _weth = router.WETH();
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _weth;
if(_allowances[address(this)][address(router)] <= amountToSwap){ approve(address(router), amountToSwap); }
uint256 balanceBefore = address(this).balance;
router.swapExactTokensForETHSupportingFeeOnTransferTokens(
amountToSwap, 0, path, address(this), block.timestamp
);
uint256 amountETH = address(this).balance - balanceBefore;
uint256 amountETHLiquidity = amountETH / 2;
if(_allowances[address(this)][address(router)] <= amountToLiquify){ approve(address(router), amountToLiquify); }
if(IERC20(router.WETH()).allowance(address(this), address(router)) <= amountETHLiquidity){
IERC20(router.WETH()).approve(address(router), amountETHLiquidity);
}
router.addLiquidityETH{value: amountETHLiquidity}(
address(this), amountToLiquify, 0, 0, address(this), block.timestamp
);
}
have tried a dozen different variations on this and nothing seems to work. am i missing something dumb?
anyone have any input on this? router giving "insufficient_output_amount" which i read means slippage is not high enough but i thought using 0 for min expected would be the same as 100% slippage
Just remember that 100% slippage is not necessarily bad. It just means that you have a 100% tolerance for the reduction of the expected output. For instance, if noone else is using the liquidity pool and you use 1%, 10% or 100% for slippage, the output amount will be the same.
Обсуждают сегодня