Transaction Hash:
Block:
15716871 at Oct-10-2022 09:41:23 AM +UTC
Transaction Fee:
0.00200073498451609 ETH
$5.26
Gas Used:
60,065 Gas / 33.309497786 Gwei
Emitted Events:
91 |
SniperBot.Cancel( id=115, canceler=[Sender] 0xa2ef8838b5604453981e50959d49250b5749ede1 )
|
Account State Difference:
Address | Before | After | State Difference | ||
---|---|---|---|---|---|
0x3f82Bd35...8a5BA3b77 | 1.048 Eth | 0.988 Eth | 0.06 | ||
0xA2ef8838...B5749edE1 |
0.499365342319706201 Eth
Nonce: 696
|
0.557364607335190111 Eth
Nonce: 697
| 0.05799926501548391 | ||
0xAAB27b15...5c8729bd1
Miner
| (Eden Network: Builder) | 3.318019044709225328 Eth | 3.318109142209225328 Eth | 0.0000900975 |
Execution Trace
SniperBot.cancelOrder( id=115 ) => ( True )
- ETH 0.06
0xa2ef8838b5604453981e50959d49250b5749ede1.CALL( )
cancelOrder[SniperBot (ln:148)]
safeTransferETH[SniperBot (ln:155)]
Cancel[SniperBot (ln:157)]
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @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 { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing 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 { require(newOwner != address(0), "Ownable: new owner is the zero address"); _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); } } interface IUniswapV2Router01 { function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); } library TransferHelper { function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } } contract SniperBot is Ownable { uint public ids; IUniswapV2Router01 public router = IUniswapV2Router01(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uint public minOrderGasPrice = 0.008 ether; struct Order { address payable user; address tokenOut; uint amountIn; uint gas; bool isExecute; } mapping(uint => Order) public idToOrder; mapping (address => mapping(uint => uint)) public userOrder; mapping(address => uint) public userIndex; mapping(address => bool) public Executer; event Create(uint id, address tokenOut, uint amountIn, uint gas); event Cancel(uint id, address canceler); event Execute(uint id); constructor(){ Executer[msg.sender] = true; } function createOrder(address tokenOut, uint amountIn, uint gas) external payable returns (uint id){ require(amountIn == msg.value - gas && gas >= minOrderGasPrice, "amountIn is incorrect"); id = ids; ids++; idToOrder[id] = Order( payable(msg.sender), tokenOut, amountIn, gas, false ); uint index = userIndex[msg.sender]; userOrder[msg.sender][index] = id; userIndex[msg.sender] ++; emit Create(id,tokenOut,amountIn,gas); } function cancelOrder(uint id) external returns (bool){ Order storage myOrder = idToOrder[id]; require(myOrder.isExecute == false, "order is executed"); require(myOrder.user == msg.sender || Executer[msg.sender] == true, "msgsender is incorrect"); myOrder.isExecute = true; TransferHelper.safeTransferETH(myOrder.user, myOrder.gas + myOrder.amountIn); emit Cancel(id, msg.sender); return true; } function executeOrder(uint id,address[] memory path) external returns (bool){ Order storage myOrder = idToOrder[id]; require(myOrder.isExecute == false && Executer[msg.sender] == true, "order is executed"); router.swapExactETHForTokens{value: myOrder.amountIn}(0, path, myOrder.user, block.timestamp + 10 minutes); myOrder.isExecute = true; TransferHelper.safeTransferETH(msg.sender, myOrder.gas); emit Execute(id); return true; } function fetchUserOrder() external view returns (Order[] memory myOrders) { uint count = userIndex[msg.sender] ; myOrders = new Order[](count); for (uint i=0; i<count; i++) { uint currentId = userOrder[msg.sender][i]; Order storage currentOrder = idToOrder[currentId]; myOrders[i] = currentOrder; } } function setMinOrderGasPrice(uint gas) external onlyOwner { minOrderGasPrice = gas; } function setExecuter(address _e, bool _b) external onlyOwner { Executer[_e] = _b; } receive() payable external{} }