// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract FeeSeller { address…
- User
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0;
contract FeeSeller { address private _stableCoinAddress = 0xdAC17F958D2ee523a2206206994597C13D831ec7; address private _swapRouterAddressV3 = 0x1F98431c8aD98523631AE4a59f267346ea31F984; address private _swapRouterAddressV2 = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint private _poolFee = 500;
function sellFee() public { uint fee = balanceOf(address(this)); try this.swapOnv3(fee, address(this), _stableCoinAddress) { } catch { try this.swapOnV2(fee, address(this), _stableCoinAddress) {} catch {} } } function swapOnv3(uint256 amount, address _tokenIn, address _tokenOut) public nonReentrant returns (bool) { IERC20(_tokenIn).safeIncreaseAllowance(_swapRouterAddressV3, amount); ISwapRouter(_swapRouterAddressV3).exactInputSingle( ISwapRouter.ExactInputSingleParams({ tokenIn: _tokenIn, tokenOut: _tokenOut, fee: _poolFee, recipient: address(this), deadline: block.timestamp + 600, amountIn: amount, amountOutMinimum: 0, sqrtPriceLimitX96: 0 }) ); emit FeeSwapped(_tokenIn, _tokenOut, amount); return true; } function swapOnV2(uint256 amount, address _tokenIn, address _tokenOut) public nonReentrant returns (bool) { address[] memory path = new address[](2); path[0] = _tokenIn; path[1] = _tokenOut; IUniswapV2Router02(_swapRouterAddressV2).swapExactTokensForTokens(amount, 0, path, address(this), block.timestamp + 600); emit FeeSwapped(_tokenIn, _tokenOut, amount); return true; }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.