Verified contractExactMIT
BaseTwoPoolArbitrage
Address0xcf983036bfaa0f64b3c02d4f62f71c842c095ec4
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.34
- Same code
Only this contract
Details
- Compiler
- solc 0.8.34+commit.80d5c536
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,365,683
- Creation transaction
- 0x6c2a019157…ff6964e292
tests/TestArbitrage_SimpleNoflashloan_UniswapV3Base_ToshiWeth_sol.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IUniswapV3Pool {
function swap(
address recipient,
bool zeroForOne,
int256 amountSpecified,
uint160 sqrtPriceLimitX96,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
function token0() external view returns (address);
function token1() external view returns (address);
}
interface IERC20 {
function transfer(address to, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function balanceOf(address account) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
}
contract BaseTwoPoolArbitrage {
address public owner;
address public constant WETH = 0x4200000000000000000000000000000000000006;
address public constant TOSHI = 0xAC1Bd2486aAf3B5C0fc3Fd868558b082a531B2B4; // Replace with official TOSHI Base address if different
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;}
constructor() {
owner = msg.sender;
}
// Call this function from your JS script
function executeArb(
address poolBuy,
address poolSell,
uint256 amountInWETH
) external onlyOwner {
uint256 initialWETHBalance = IERC20(WETH).balanceOf(address(this));
require(initialWETHBalance >= amountInWETH, "Insufficient WETH balance in contract");
// --- STEP 1: Buy TOSHI on poolBuy ---
bool zeroForOneBuy = IUniswapV3Pool(poolBuy).token0() == WETH;
// Transfer WETH to the first pool ahead of execution if required by direct swap mechanics
IERC20(WETH).transfer(poolBuy, amountInWETH);
// Execute Swap on Buy Pool
(int256 amount0, int256 amount1) = IUniswapV3Pool(poolBuy).swap(
address(this),
zeroForOneBuy,
int256(amountInWETH),
zeroForOneBuy ? 4295128739 + 1 : 1461446703485210103287273052203988822378723970342 - 1, // Sqrt price limits
""
);
uint256 toshiReceived = uint256(zeroForOneBuy ? -amount1 : -amount0);
// --- STEP 2: Sell TOSHI on poolSell ---
bool zeroForOneSell = IUniswapV3Pool(poolSell).token0() == TOSHI;
IERC20(TOSHI).transfer(poolSell, toshiReceived);
IUniswapV3Pool(poolSell).swap(
address(this),
zeroForOneSell,
int256(toshiReceived),
zeroForOneSell ? 4295128739 + 1 : 1461446703485210103287273052203988822378723970342 - 1,
""
);
// --- STEP 3: Profit Verification ---
uint256 finalWETHBalance = IERC20(WETH).balanceOf(address(this));
require(finalWETHBalance > initialWETHBalance, "Arbitrage was unprofitable!");
}
function withdrawToken(address token) external onlyOwner {
uint256 balance = IERC20(token).balanceOf(address(this));
IERC20(token).transfer(owner, balance);
}
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.