Verified contractExactMIT
CrossDEXArbitrage
Address0x7668d7f1088ee07820a8aee73c9cdb70779ce9c2
- 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,369,800
- Creation transaction
- 0xe8c07342a9…e6b5895d7c
contracts/Arbitrage.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IERC20 {
function approve(address spender, uint256 amount) external returns (bool);
function transfer(address recipient, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
}
interface IPool {
function flashLoanSimple(
address receiverAddress,
address asset,
uint256 amount,
bytes calldata params,
uint16 referralCode
) external;
}
interface IAerodromeRouter {
struct Route {
address from;
address to;
bool stable;
address factory;
}
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
Route[] memory routes,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
}
interface ISwapRouter {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}
function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
}
contract CrossDEXArbitrage {
address public immutable owner;
address public constant AAVE_POOL = 0xA238Dd80C259a72e81d7e4664a9801593F98d1c5;
address public constant UNISWAP_ROUTER = 0x2626664c2603336E57B271c5C0b26F421741e481; // Compiler checksum corrected
address public constant AERODROME_ROUTER = 0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43;
address public constant AERODROME_FACTORY = 0x420DD381b31aEf6683db6B902084cB0FFECe40Da;
address public constant OKX_WALLET = 0x3bb6963B5BC7626b930dcE5c9612d5A1FdC2cf84; // Compiler checksum corrected
address public constant WETH = 0x4200000000000000000000000000000000000006;
event ArbitrageExecuted(address indexed asset, uint256 amountBorrowed, uint256 profit);
constructor() {
owner = msg.sender;
}
function startArbitrage(address asset, uint256 amount) external {
require(msg.sender == owner, "Unauthorized caller");
IPool(AAVE_POOL).flashLoanSimple(address(this), asset, amount, "", 0);
}
function executeOperation(
address asset,
uint256 amount,
uint256 premium,
address initiator,
bytes calldata params
) external returns (bool) {
require(msg.sender == AAVE_POOL, "Caller must be Aave Pool");
require(initiator == address(this), "Invalid loan initiator");
uint256 amountOwed = amount + premium;
IERC20(asset).approve(AERODROME_ROUTER, 0);
IERC20(asset).approve(AERODROME_ROUTER, amount);
IAerodromeRouter.Route[] memory routes = new IAerodromeRouter.Route[](1);
routes[0] = IAerodromeRouter.Route({
from: asset,
to: WETH,
stable: false,
factory: AERODROME_FACTORY
});
uint256[] memory amountsOut = IAerodromeRouter(AERODROME_ROUTER).swapExactTokensForTokens(
amount,
0,
routes,
address(this),
block.timestamp
);
uint256 wethOut = amountsOut[1];
require(wethOut > 0, "Aerodrome swap returned zero WETH");
IERC20(WETH).approve(UNISWAP_ROUTER, 0);
IERC20(WETH).approve(UNISWAP_ROUTER, wethOut);
uint256 usdcReturned = ISwapRouter(UNISWAP_ROUTER).exactInputSingle(
ISwapRouter.ExactInputSingleParams({
tokenIn: WETH,
tokenOut: asset,
fee: 500,
recipient: address(this),
deadline: block.timestamp,
amountIn: wethOut,
amountOutMinimum: amountOwed,
sqrtPriceLimitX96: 0
})
);
require(usdcReturned > amountOwed, "Spread below profitability threshold");
uint256 profit = usdcReturned - amountOwed;
IERC20(asset).approve(AAVE_POOL, 0);
IERC20(asset).approve(AAVE_POOL, amountOwed);
if (profit > 0) {
IERC20(asset).transfer(OKX_WALLET, profit);
}
emit ArbitrageExecuted(asset, amount, profit);
return true;
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.