Address Contract Verified
Address
0xb12FC17Ef29B6B67958709E8DDFDFEc445063711
Balance
0 ETH
Nonce
1
Code Size
6021 bytes
Creator
0x8D5c74bd...1818 at tx 0x614896be...50009a
Indexed Transactions
0
Contract Bytecode
6021 bytes
0x60806040526004361015610018575b361561001657005b005b5f803560e01c80630777bfe814610dae5780631694505e14610d69578063230ed44a14610d2757806328f235ba14610d0457806329e3ba2c146109a35780632c76d7a61461095e57806349df728c14610822578063534a264c146107ff578063715018a6146107a5578063765eebf8146102345780638da5cb5b1461020d57806390d49b9d146101c8578063e086e5ec146101455763f2fde38b146100bd575061000e565b34610142576020366003190112610142576100d66111c3565b6100de611729565b6001600160a01b0316801561012e5781546001600160a01b03198116821783556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b631e4fbdf760e01b82526004829052602482fd5b80fd5b503461014257806003193601126101425761015e611729565b47801561018e57815482918291829182916001600160a01b031682f1156101825780f35b604051903d90823e3d90fd5b60405162461bcd60e51b81526020600482015260126024820152714e6f2045544820746f20776974686472617760701b6044820152606490fd5b5034610142576020366003190112610142576101e26111c3565b6101ea611729565b60018060a01b03166bffffffffffffffffffffffff60a01b600554161760055580f35b5034610142578060031936011261014257546040516001600160a01b039091168152602090f35b50346101425761028d90610247366111d9565b969592949161025b879a92959a151561125d565b61026860028710156112a1565b6001600160a01b03169361027d8515156112dc565b6001600160a01b03161515611321565b6104b042019283421161079157737a250d5630b4cf539739df2c5dacb4c659f2488d810361062e575050821561061a576001600160a01b036102ce88611361565b60405163095ea7b360e01b81523060048201526024810184905291602091839160449183918c91165af180156105f2576105fd575b506001600160a01b0361031588611361565b6040516323b872dd60e01b81523360048201523060248201526044810184905291602091839160649183918c91165af180156105f2576105d5575b506001600160a01b0361036288611361565b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d16600482018190526024820185905294929091602091839160449183918d91165af180156105ca578880946103f288958a98958e9561059d575b50604051632512eca560e11b815298899788968795309360048801611519565b03925af1801561059257610570575b505b6001101561055c578293610420602060018060a01b039201611361565b16803b1561055757838091602460405180948193632e1a7d4d60e01b83528760048401525af190811561054c578491610533575b50906103e861046560025483611553565b04906104718282611566565b936001600160a01b031690816104db575b5050600554829182918291906001600160a01b03168282156104d2575bf1156104c557818080928181156104bc575b3390f1156101825780f35b506108fc6104b1565b50604051903d90823e3d90fd5b506108fc61049f565b838093949295508091610507866105026103e86104fa60035486611553565b048094611566565b611566565b9682821561052a575bf11561051f5782905f80610482565b6040513d84823e3d90fd5b506108fc610510565b8161053d916113a5565b61054857825f610454565b5050fd5b6040513d86823e3d90fd5b505050fd5b634e487b7160e01b83526032600452602483fd5b61058b903d8087833e61058381836113a5565b810190611444565b505f610401565b6040513d87823e3d90fd5b6105be9060203d6020116105c3575b6105b681836113a5565b81019061142c565b6103d2565b503d6105ac565b6040513d8a823e3d90fd5b6105ed9060203d6020116105c3576105b681836113a5565b610350565b6040513d89823e3d90fd5b6106159060203d6020116105c3576105b681836113a5565b610303565b634e487b7160e01b86526032600452602486fd5b7368b3465833fb72a70ecdf485e0e4c7bd8665fc459192935014610654575b5050610403565b821561061a576106708261066789611361565b309033906115b2565b61067987611361565b7f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc456001600160a01b031692906106b29082908590611678565b6106bb88611361565b91846001101561077d5760209261073b9262ffffff60e4936106de878e01611361565b604051946106eb86611375565b60018060a01b0316855260018060a01b03168785015216604083015230606083015287608083015260a08201528860c0820152886040519586948593635023b4df60e01b855260048501906113d6565b5af180156105925761074e575b8061064d565b61076f9060203d602011610776575b61076781836113a5565b8101906113c7565b505f610748565b503d61075d565b634e487b7160e01b88526032600452602488fd5b634e487b7160e01b88526011600452602488fd5b50346101425780600319360112610142576107be611729565b80546001600160a01b03198116825581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b503461014257602036600319011261014257610819611729565b60043560025580f35b50346101425760203660031901126101425761083c6111c3565b610844611729565b6040516370a0823160e01b8152306004820152906001600160a01b0316602082602481845afa91821561095357839261091b575b5081156108de57825460405163a9059cbb60e01b81526001600160a01b03909116600482015260248101929092526020908290604490829086905af1801561051f576108c2575080f35b6108da9060203d6020116105c3576105b681836113a5565b5080f35b60405162461bcd60e51b81526020600482015260156024820152744e6f20746f6b656e7320746f20776974686472617760581b6044820152606490fd5b9091506020813d60201161094b575b81610937602093836113a5565b810103126109475751905f610878565b5f80fd5b3d915061092a565b6040513d85823e3d90fd5b50346101425780600319360112610142576040517f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc456001600160a01b03168152602090f35b5060c0366003190112610142576004359060243562ffffff8116809103610d005760443567ffffffffffffffff8111610cfc576109e4903690600401611192565b90936064356001600160a01b038116929190839003610cf8576084356001600160a01b03811690819003610cf45760a4356001600160a01b03811690819003610cf057610a3234151561125d565b610a3f60028510156112a1565b610a4a8515156112dc565b610a55821515611321565b6103e8610a6460025434611553565b0495610a708734611566565b956104b0420192834211610cdc5780610c98575b50737a250d5630b4cf539739df2c5dacb4c659f2488d8103610b6557505092869792610ad79592889560405197889687958695637ff36ab560e01b875260048701526080602487015260848601916114c9565b6044840192909252606483015203917f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03165af1801561095357839283928392610b4b575b505b6005546001600160a01b0316828215610b42575bf1156101825780f35b506108fc610b39565b610b5e903d8085833e61058381836113a5565b505f610b23565b7368b3465833fb72a70ecdf485e0e4c7bd8665fc459193949599925014610b98575b505050505081808094508092610b25565b8715610c8457610ba781611361565b9760011015610c845796602093610c219360e493610bc7878b9c01611361565b60405194610bd486611375565b60018060a01b0316855260018060a01b0316878501526040840152606083015285608083015260a08201528660c082015260405194859384926304e45aaf60e01b845260048401906113d6565b7f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc456001600160a01b03165af1801561095357839283928392610c65575b8194610b87565b610c7d9060203d6020116107765761076781836113a5565b505f610c5e565b634e487b7160e01b87526032600452602487fd5b965088808080610502610cbe8d6103e8610cb460035434611553565b0492839134611566565b9b828215610cd3575bf1156105ca575f610a84565b506108fc610cc7565b634e487b7160e01b8a52601160045260248afd5b8680fd5b8580fd5b8480fd5b8280fd5b5080fd5b503461014257602036600319011261014257610d1e611729565b60043560035580f35b5034610142576020366003190112610142576004356004811015610d005762ffffff90602092506003600a8083046004015492060260031b1c16604051908152f35b50346101425780600319360112610142576040517f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03168152602090f35b503461094757610df790610dc1366111d9565b989091610dd588969498979597151561125d565b610de260028910156112a1565b6001600160a01b03169161027d8315156112dc565b6104b042019182421161117e575f91737a250d5630b4cf539739df2c5dacb4c659f2488d8103611026575050508415610fbe576001600160a01b03610e3b85611361565b6040516323b872dd60e01b81523360048201523060248201526044810186905291602091839160649183915f91165af18015610fb357611009575b506001600160a01b03610e8885611361565b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d166004820181905260248201879052909390929091602091859160449183915f91165af1928315610fb3575f94610f19889387938b97610fec575b506040516318cbafe560e01b815298899788968795309360048801611519565b03925af1908115610fb3575f91610fd2575b50805160011015610fbe5760400151915b60011015610fbe576001600160a01b0390610f5990602001611361565b16803b15610947575f8091602460405180948193632e1a7d4d60e01b83528760048401525af18015610fb357610f9e575b50918180936103e861046560025483611553565b610fab9192505f906113a5565b5f905f610f8a565b6040513d5f823e3d90fd5b634e487b7160e01b5f52603260045260245ffd5b610fe691503d805f833e61058381836113a5565b5f610f2b565b6110049060203d6020116105c3576105b681836113a5565b610ef9565b6110219060203d6020116105c3576105b681836113a5565b610e76565b7368b3465833fb72a70ecdf485e0e4c7bd8665fc45919493509694919614611051575b505050610f3c565b90919280955015610fbe576110698161066786611361565b61107284611361565b7f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc456001600160a01b031693906110ab9083908690611678565b6110b485611361565b8660011015610fbe576020936111329362ffffff60e4946110d6888b01611361565b604051956110e387611375565b60018060a01b0316865260018060a01b031688860152166040840152306060840152608083015260a08201525f60c08201525f60405195869485936304e45aaf60e01b855260048501906113d6565b5af1908115610fb3575f9161114c575b50915f8080611049565b90506020813d602011611176575b81611167602093836113a5565b8101031261094757515f611142565b3d915061115a565b634e487b7160e01b5f52601160045260245ffd5b9181601f840112156109475782359167ffffffffffffffff8311610947576020808501948460051b01011161094757565b600435906001600160a01b038216820361094757565b9060e060031983011261094757600435916024359160443562ffffff8116810361094757916064359067ffffffffffffffff82116109475761121d91600401611192565b90916084356001600160a01b0381168103610947579060a4356001600160a01b0381168103610947579060c4356001600160a01b03811681036109475790565b1561126457565b60405162461bcd60e51b815260206004820152601560248201527404d7573742073656e642045544820746f207377617605c1b6044820152606490fd5b156112a857565b60405162461bcd60e51b815260206004820152600c60248201526b092dcecc2d8d2c840e0c2e8d60a31b6044820152606490fd5b156112e357565b60405162461bcd60e51b8152602060048201526016602482015275496e76616c696420726f75746572206164647265737360501b6044820152606490fd5b1561132857565b60405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c9958da5c1a595b9d607a1b6044820152606490fd5b356001600160a01b03811681036109475790565b60e0810190811067ffffffffffffffff82111761139157604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff82111761139157604052565b90816020910312610947575190565b80516001600160a01b03908116835260208083015182169084015260408083015162ffffff16908401526060808301518216908401526080808301519084015260a0808301519084015260c09182015116910152565b90816020910312610947575180151581036109475790565b6020818303126109475780519067ffffffffffffffff821161094757019080601f830112156109475781519167ffffffffffffffff8311611391578260051b906040519361149560208401866113a5565b845260208085019282010192831161094757602001905b8282106114b95750505090565b81518152602091820191016114ac565b916020908281520191905f905b8082106114e35750505090565b91929091908335906001600160a01b0382168203610947576001600160a01b0390911681526020908101930191600101906114d6565b92909361153f92608095989796988552602085015260a0604085015260a08401916114c9565b6001600160a01b0390951660608201520152565b8181029291811591840414171561117e57565b9190820391821161117e57565b3d156115ad573d9067ffffffffffffffff821161139157604051916115a2601f8201601f1916602001846113a5565b82523d5f602084013e565b606090565b6040516323b872dd60e01b602082019081526001600160a01b03938416602483015293909216604483015260648201939093525f9283929091839061160481608481015b03601f1981018352826113a5565b51925af1611610611573565b81611649575b501561161e57565b60405162461bcd60e51b815260206004820152600360248201526229aa2360e91b6044820152606490fd5b805180159250821561165e575b50505f611616565b611671925060208091830101910161142c565b5f80611656565b60405163095ea7b360e01b602082019081526001600160a01b03909316602482015260448101939093525f9283929083906116b681606481016115f6565b51925af16116c2611573565b816116fa575b50156116d057565b60405162461bcd60e51b8152602060048201526002602482015261534160f01b6044820152606490fd5b805180159250821561170f575b50505f6116c8565b611722925060208091830101910161142c565b5f80611707565b5f546001600160a01b0316330361173c57565b63118cdaa760e01b5f523360045260245ffdfea2646970667358221220487fa615781e1de6ad3958b9fb198a0f570945d835f7b6ea596d9f36d000918564736f6c634300081a0033
Verified Source Code Full Match
Compiler: v0.8.26+commit.8a97fa7a
EVM: cancun
Optimization: Yes (200 runs)
main_eth_update.sol 416 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.8.26;
pragma abicoder v2;
import "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
// import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "@uniswap/v3-periphery/contracts/interfaces/IQuoterV2.sol";
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
interface ISwapRouter {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}
function exactInputSingle(ExactInputSingleParams calldata params)
external
payable
returns (uint256 amountOut);
struct ExactOutputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 amountOut;
uint256 amountInMaximum;
uint160 sqrtPriceLimitX96;
}
function exactOutputSingle(ExactOutputSingleParams calldata params)
external
payable
returns (uint256 amountIn);
}
/// @title Interface for WETH9
interface IWETH is IERC20 {
/// @notice Deposit ether to get wrapped ether
function deposit() external payable;
/// @notice Withdraw wrapped ether to get ether
function withdraw(uint256) external;
}
interface IUniswapV3Factory {
function getPool(address tokenA, address tokenB, uint24 fee) external view returns (address);
}
interface IUniswapV3Pool {
function fee() external view returns (uint24);
}
contract Baseswap is Ownable {
// Uniswap Router Address
address private constant UNISWAP_V2_ROUTER_ADDRESS =
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address private constant UNISWAP_V3_ROUTER_ADDRESS =
0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45;
// address private constant UNISWAP_V3_QUOTER_ADDRESS = 0x61fFE014bA17989E743c5F6cB21bF9697530B21e;
// address private constant UNISWAP_V3_FACTORY = 0x1F98431c8aD98523631AE4a59f267346ea31F984;
address private WETH = 0x4200000000000000000000000000000000000006;
uint256 BOT_FEE = 100;
uint256 REF_FEE = 5;
uint24[4] public feeTiers = [100, 500, 3000, 10000]; // Possible Uniswap V3 fee tiers
// Uniswap Router
ISwapRouter public immutable uniswapV3Router; // V3
IUniswapV2Router02 public immutable uniswapV2Router; // V2
// IQuoterV2 public immutable uniswapV3Quoter;
address BOT_FEE_WALLET;
// function getExistingPoolFeeTier(address tokenA, address tokenB) internal returns (uint24) {
// IUniswapV3Factory factory = IUniswapV3Factory(UNISWAP_V3_FACTORY);
// for (uint256 i = 0; i < feeTiers.length; i++) {
// address pool = factory.getPool(tokenA, tokenB, feeTiers[i]);
// if (pool != address(0)) {
// return feeTiers[i]; // Return the first matching fee tier
// }
// }
// revert("No pool found for this pair");
// }
constructor(address BOT_FEE_WALLET_) Ownable(msg.sender) {
BOT_FEE_WALLET = BOT_FEE_WALLET_;
// uniswapV3Quoter = IQuoterV2(UNISWAP_V3_QUOTER_ADDRESS);
uniswapV2Router = IUniswapV2Router02(UNISWAP_V2_ROUTER_ADDRESS);
uniswapV3Router = ISwapRouter(UNISWAP_V3_ROUTER_ADDRESS);
}
function BaseBuy(
uint256 amountOutMin,
uint24 feeTier,
address[] calldata path,
address router,
address to,
address referral
) external payable {
require(msg.value > 0, "Must send ETH to swap");
require(path.length >= 2, "Invalid path");
require(router != address(0), "Invalid router address");
require(to != address(0), "Invalid recipient");
uint256 bot_fee = (msg.value * BOT_FEE) / 1000;
uint256 ref_fee = 0;
uint256 amountIn = msg.value - bot_fee;
uint256 deadline = block.timestamp + 1200;
if (referral != address(0)) {
ref_fee = (msg.value * REF_FEE) / 1000;
amountIn = msg.value - bot_fee - ref_fee;
// IERC20(path[0]).transferFrom(msg.sender, referral, ref_fee);
payable(referral).transfer(ref_fee);
}
if (router == UNISWAP_V2_ROUTER_ADDRESS) {
// uint256[] memory amountOuts = uniswapV2Router.getAmountsOut(
// amountIn,
// path
// );
// uint256 expectedAmountOut = amountOuts[1];
// uint256 amountOutMin = expectedAmountOut - expectedAmountOut * slippage / 1e7;
// Uniswap V2
uniswapV2Router.swapExactETHForTokens{value: amountIn}(
amountOutMin,
path,
to,
deadline
);
} else if (router == UNISWAP_V3_ROUTER_ADDRESS) {
// uint24 feeTier = getExistingPoolFeeTier(path[0], path[1]);
// IQuoterV2.QuoteExactInputSingleParams memory params_ = IQuoterV2.QuoteExactInputSingleParams({
// tokenIn: path[0],
// tokenOut: path[1],
// amountIn: amountIn,
// fee: feeTier,
// sqrtPriceLimitX96: 0
// });
// (uint256 amountOut,,,) = uniswapV3Quoter.quoteExactInputSingle(params_);
// uint256 amountOutMin = amountOut - amountOut * slippage / 1e7;
// Note: To use this example, you should explicitly set slippage limits, omitting for simplicity
// uint256 minOut = /* Calculate min output */ 0;
// uint160 priceLimit = /* Calculate price limit */ 0;
// Create the params that will be used to execute the swap
ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({
tokenIn: path[0],
tokenOut: path[1],
fee: feeTier,
recipient: to,
amountIn: amountIn,
amountOutMinimum: amountOutMin,
sqrtPriceLimitX96: 0
});
// The call to `exactInputSingle` executes the swap.
uniswapV3Router.exactInputSingle{value: amountIn}(params);
}
payable(BOT_FEE_WALLET).transfer(bot_fee);
}
function BaseSell_1(
uint256 amountIn,
uint256 amountOutMin,
uint24 feeTier,
address[] calldata path,
address router,
address to,
address referral
) external {
require(amountIn > 0, "Must send ETH to swap");
require(path.length >= 2, "Invalid path");
require(router != address(0), "Invalid router address");
require(to != address(0), "Invalid recipient");
uint256 deadline = block.timestamp + 1200;
uint256 amountOut_ = 0;
if (router == UNISWAP_V2_ROUTER_ADDRESS) {
// uint256[] memory amountOuts = uniswapV2Router.getAmountsOut(
// amountIn,
// path
// );
// uint256 expectedAmountOut = amountOuts[1];
// uint256 amountOutMin = expectedAmountOut - expectedAmountOut * slippage / 1e7;
// Transfer the specified amount of tokens from the sender to this contract
IERC20(path[0]).transferFrom(msg.sender, address(this), amountIn);
// Approve the Uniswap router to spend the tokens
IERC20(path[0]).approve(address(uniswapV2Router), amountIn);
// Uniswap V2
uint256[] memory amounts = uniswapV2Router.swapExactTokensForETH(
amountIn,
amountOutMin,
path,
address(this),
deadline
);
amountOut_ = amounts[1];
} else if (router == UNISWAP_V3_ROUTER_ADDRESS) {
// uint24 feeTier = getExistingPoolFeeTier(path[0], path[1]);
// IQuoterV2.QuoteExactInputSingleParams memory params_ = IQuoterV2.QuoteExactInputSingleParams({
// tokenIn: path[0],
// tokenOut: path[1],
// amountIn: amountIn,
// fee: feeTier,
// sqrtPriceLimitX96: 0
// });
// (uint256 amountOut,,,) = uniswapV3Quoter.quoteExactInputSingle(params_);
// uint256 amountOutMin = amountOut - amountOut * slippage / 1e7;
// Transfer the specified amount of WETH9 to this contract.
TransferHelper.safeTransferFrom(
path[0],
msg.sender,
address(this),
amountIn
);
// Approve the router to spend WETH9.
TransferHelper.safeApprove(
path[0],
address(uniswapV3Router),
amountIn
);
// Note: To use this example, you should explicitly set slippage limits, omitting for simplicity
// uint256 minOut = /* Calculate min output */ 0;
// uint160 priceLimit = /* Calculate price limit */ 0;
// Create the params that will be used to execute the swap
ISwapRouter.ExactInputSingleParams memory params = ISwapRouter
.ExactInputSingleParams({
tokenIn: path[0],
tokenOut: path[1],
fee: feeTier,
recipient: address(this),
amountIn: amountIn,
amountOutMinimum: amountOutMin,
sqrtPriceLimitX96: 0
});
// The call to `exactInputSingle` executes the swap.
amountOut_ = uniswapV3Router.exactInputSingle(params);
}
IWETH(path[1]).withdraw(amountOut_);
uint256 bot_fee = amountOut_ * BOT_FEE / 1000;
uint256 ref_fee = 0;
uint256 amountOut__ = amountOut_ - bot_fee;
if (referral != address(0)) {
ref_fee = (amountOut_ * REF_FEE) / 1000;
amountOut__ = amountOut_ - ref_fee - bot_fee;
payable(referral).transfer(ref_fee);
// IERC20(path[0]).transfer(referral, ref_fee);
}
payable(BOT_FEE_WALLET).transfer(bot_fee);
// payable(msg.sender).transfer(bot_fee);
payable(msg.sender).transfer(amountOut__);
}
function BaseSell_2(
uint256 amountOut,
uint256 amountInMax,
uint24 feeTier,
address[] calldata path,
address router,
address to,
address referral
) external {
require(amountOut > 0, "Must send ETH to swap");
require(path.length >= 2, "Invalid path");
require(router != address(0), "Invalid router address");
require(to != address(0), "Invalid recipient");
uint256 deadline = block.timestamp + 1200;
// IERC20(path[0]).approve(address(this), amountInMax);
if (router == UNISWAP_V2_ROUTER_ADDRESS) {
// uint256[] memory amountIns = uniswapV2Router.getAmountsIn(
// amountOut,
// path
// );
// uint256 expectedAmountIn = amountIns[0];
// uint256 amountInMax = expectedAmountIn * (1e7 + slippage) / 1e7;
// uint256 expectedamountOut = amountOuts[1];
// uint256 amountOutMin = expectedamountOut - expectedamountOut * slippage / 100;
// Transfer the maximum tokens from the sender to this contract
IERC20(path[0]).approve(address(this), amountInMax);
IERC20(path[0]).transferFrom(msg.sender, address(this), amountInMax);
// Approve the Uniswap router to spend the tokens
IERC20(path[0]).approve(address(uniswapV2Router), amountInMax);
// Uniswap V2
uniswapV2Router.swapTokensForExactETH(
amountOut,
amountInMax,
path,
address(this),
deadline
);
} else if (router == UNISWAP_V3_ROUTER_ADDRESS) {
// uint24 feeTier = getExistingPoolFeeTier(path[0], path[1]);
// IQuoterV2.QuoteExactOutputSingleParams memory params_ = IQuoterV2.QuoteExactOutputSingleParams({
// tokenIn: path[0],
// tokenOut: path[1],
// amount: amountOut,
// fee: feeTier,
// sqrtPriceLimitX96: 0
// });
// (uint256 amountIn,,,) = uniswapV3Quoter.quoteExactOutputSingle(params_);
// uint256 amountInMax = amountIn * (1e7 + slippage) / 1e7;
// Transfer the specified amount of WETH9 to this contract.
TransferHelper.safeTransferFrom(
path[0],
msg.sender,
address(this),
amountInMax
);
// Approve the router to spend WETH9.
TransferHelper.safeApprove(
path[0],
address(uniswapV3Router),
amountInMax
);
// Note: To use this example, you should explicitly set slippage limits, omitting for simplicity
// uint256 minOut = /* Calculate min output */ 0;
// uint160 priceLimit = /* Calculate price limit */ 0;
// Create the params that will be used to execute the swap
ISwapRouter.ExactOutputSingleParams memory params = ISwapRouter
.ExactOutputSingleParams({
tokenIn: path[0],
tokenOut: path[1],
fee: feeTier,
recipient: address(this),
amountOut: amountOut,
amountInMaximum: amountInMax,
sqrtPriceLimitX96: 0
});
// The call to `exactInputSingle` executes the swap.
uniswapV3Router.exactOutputSingle(params);
}
IWETH(path[1]).withdraw(amountOut);
uint256 bot_fee = amountOut * BOT_FEE / 1000;
uint256 ref_fee = 0;
uint256 amountOut_ = amountOut - bot_fee;
if (referral != address(0)) {
ref_fee = (amountOut * REF_FEE) / 1000;
amountOut_ = amountOut - ref_fee - bot_fee;
payable(referral).transfer(ref_fee);
}
payable(BOT_FEE_WALLET).transfer(bot_fee);
payable(msg.sender).transfer(amountOut_);
}
/// @notice Withdraw all ETH from the contract
function withdrawETH() external onlyOwner {
uint256 balance = address(this).balance;
require(balance > 0, "No ETH to withdraw");
// Transfer ETH to the owner
payable(owner()).transfer(balance);
}
/// @notice Withdraw all tokens of a specific ERC20 from the contract
/// @param tokenAddress The address of the ERC20 token
function withdrawTokens(address tokenAddress) external onlyOwner {
IERC20 token = IERC20(tokenAddress);
uint256 balance = token.balanceOf(address(this));
require(balance > 0, "No tokens to withdraw");
// Transfer tokens to the owner
token.transfer(owner(), balance);
}
function setFeeWallet(address feeWallet) external onlyOwner {
BOT_FEE_WALLET = feeWallet;
}
function setBotFeePercent(uint256 percent) external onlyOwner {
BOT_FEE = percent;
}
function setRefFeePercent(uint256 percent) external onlyOwner {
REF_FEE = percent;
}
// Allow the contract to receive ETH
receive() external payable {}
// Fallback function
fallback() external payable {}
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
ERC20.sol 312 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance < type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
IUniswapV2Router02.sol 44 lines
pragma solidity >=0.6.2;
import './IUniswapV2Router01.sol';
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
IQuoterV2.sol 98 lines
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
/// @title QuoterV2 Interface
/// @notice Supports quoting the calculated amounts from exact input or exact output swaps.
/// @notice For each pool also tells you the number of initialized ticks crossed and the sqrt price of the pool after the swap.
/// @dev These functions are not marked view because they rely on calling non-view functions and reverting
/// to compute the result. They are also not gas efficient and should not be called on-chain.
interface IQuoterV2 {
/// @notice Returns the amount out received for a given exact input swap without executing the swap
/// @param path The path of the swap, i.e. each token pair and the pool fee
/// @param amountIn The amount of the first token to swap
/// @return amountOut The amount of the last token that would be received
/// @return sqrtPriceX96AfterList List of the sqrt price after the swap for each pool in the path
/// @return initializedTicksCrossedList List of the initialized ticks that the swap crossed for each pool in the path
/// @return gasEstimate The estimate of the gas that the swap consumes
function quoteExactInput(bytes memory path, uint256 amountIn)
external
returns (
uint256 amountOut,
uint160[] memory sqrtPriceX96AfterList,
uint32[] memory initializedTicksCrossedList,
uint256 gasEstimate
);
struct QuoteExactInputSingleParams {
address tokenIn;
address tokenOut;
uint256 amountIn;
uint24 fee;
uint160 sqrtPriceLimitX96;
}
/// @notice Returns the amount out received for a given exact input but for a swap of a single pool
/// @param params The params for the quote, encoded as `QuoteExactInputSingleParams`
/// tokenIn The token being swapped in
/// tokenOut The token being swapped out
/// fee The fee of the token pool to consider for the pair
/// amountIn The desired input amount
/// sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap
/// @return amountOut The amount of `tokenOut` that would be received
/// @return sqrtPriceX96After The sqrt price of the pool after the swap
/// @return initializedTicksCrossed The number of initialized ticks that the swap crossed
/// @return gasEstimate The estimate of the gas that the swap consumes
function quoteExactInputSingle(QuoteExactInputSingleParams memory params)
external
returns (
uint256 amountOut,
uint160 sqrtPriceX96After,
uint32 initializedTicksCrossed,
uint256 gasEstimate
);
/// @notice Returns the amount in required for a given exact output swap without executing the swap
/// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order
/// @param amountOut The amount of the last token to receive
/// @return amountIn The amount of first token required to be paid
/// @return sqrtPriceX96AfterList List of the sqrt price after the swap for each pool in the path
/// @return initializedTicksCrossedList List of the initialized ticks that the swap crossed for each pool in the path
/// @return gasEstimate The estimate of the gas that the swap consumes
function quoteExactOutput(bytes memory path, uint256 amountOut)
external
returns (
uint256 amountIn,
uint160[] memory sqrtPriceX96AfterList,
uint32[] memory initializedTicksCrossedList,
uint256 gasEstimate
);
struct QuoteExactOutputSingleParams {
address tokenIn;
address tokenOut;
uint256 amount;
uint24 fee;
uint160 sqrtPriceLimitX96;
}
/// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool
/// @param params The params for the quote, encoded as `QuoteExactOutputSingleParams`
/// tokenIn The token being swapped in
/// tokenOut The token being swapped out
/// fee The fee of the token pool to consider for the pair
/// amountOut The desired output amount
/// sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap
/// @return amountIn The amount required as the input for the swap in order to receive `amountOut`
/// @return sqrtPriceX96After The sqrt price of the pool after the swap
/// @return initializedTicksCrossed The number of initialized ticks that the swap crossed
/// @return gasEstimate The estimate of the gas that the swap consumes
function quoteExactOutputSingle(QuoteExactOutputSingleParams memory params)
external
returns (
uint256 amountIn,
uint160 sqrtPriceX96After,
uint32 initializedTicksCrossed,
uint256 gasEstimate
);
}
TransferHelper.sol 60 lines
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
library TransferHelper {
/// @notice Transfers tokens from the targeted address to the given destination
/// @notice Errors with 'STF' if transfer fails
/// @param token The contract address of the token to be transferred
/// @param from The originating address from which the tokens will be transferred
/// @param to The destination address of the transfer
/// @param value The amount to be transferred
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
(bool success, bytes memory data) =
token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
}
/// @notice Transfers tokens from msg.sender to a recipient
/// @dev Errors with ST if transfer fails
/// @param token The contract address of the token which will be transferred
/// @param to The recipient of the transfer
/// @param value The value of the transfer
function safeTransfer(
address token,
address to,
uint256 value
) internal {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
}
/// @notice Approves the stipulated contract to spend the given allowance in the given token
/// @dev Errors with 'SA' if transfer fails
/// @param token The contract address of the token to be approved
/// @param to The target of the approval
/// @param value The amount of the given token the target will be allowed to spend
function safeApprove(
address token,
address to,
uint256 value
) internal {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');
}
/// @notice Transfers ETH to the recipient address
/// @dev Fails with `STE`
/// @param to The destination of the transfer
/// @param value The value to be transferred
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'STE');
}
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
IUniswapV2Router01.sol 95 lines
pragma solidity >=0.6.2;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
draft-IERC6093.sol 161 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
IERC20Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
Read Contract
feeTiers 0x230ed44a → uint24
owner 0x8da5cb5b → address
uniswapV2Router 0x1694505e → address
uniswapV3Router 0x2c76d7a6 → address
Write Contract 10 functions
These functions modify contract state and require a wallet transaction to execute.
BaseBuy 0x29e3ba2c
uint256 amountOutMin
uint24 feeTier
address[] path
address router
address to
address referral
BaseSell_1 0x0777bfe8
uint256 amountIn
uint256 amountOutMin
uint24 feeTier
address[] path
address router
address to
address referral
BaseSell_2 0x765eebf8
uint256 amountOut
uint256 amountInMax
uint24 feeTier
address[] path
address router
address to
address referral
renounceOwnership 0x715018a6
No parameters
setBotFeePercent 0x534a264c
uint256 percent
setFeeWallet 0x90d49b9d
address feeWallet
setRefFeePercent 0x28f235ba
uint256 percent
transferOwnership 0xf2fde38b
address newOwner
withdrawETH 0xe086e5ec
No parameters
withdrawTokens 0x49df728c
address tokenAddress
Recent Transactions
No transactions found for this address