Files
strategic/scripts/Deploy.s.sol

85 lines
3.7 KiB
Solidity
Raw Permalink Normal View History

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Script} from "forge-std/Script.sol";
import {AtomicExecutor} from "../contracts/AtomicExecutor.sol";
contract Deploy is Script {
function run() external {
uint256 chainId = block.chainid;
address owner = msg.sender; // Or set from env
vm.startBroadcast();
AtomicExecutor executor = new AtomicExecutor(owner);
// Get protocol addresses based on chain
address[] memory targets = getProtocolAddresses(chainId);
executor.setAllowedTargets(targets, true);
// Allow Aave Pool for flash loan callbacks (if exists on chain)
address aavePool = getAavePool(chainId);
if (aavePool != address(0)) {
executor.setAllowedPool(aavePool, true);
}
vm.stopBroadcast();
console.log("AtomicExecutor deployed at:", address(executor));
console.log("Chain ID:", chainId);
console.log("Allowed targets:", targets.length);
}
function getProtocolAddresses(uint256 chainId) internal pure returns (address[] memory) {
if (chainId == 1) {
// Mainnet
address[] memory targets = new address[](6);
targets[0] = 0x87870Bca3F3fD6335C3F4ce8392A6935B38d4Fb1; // Aave v3 Pool
targets[1] = 0xE592427A0AEce92De3Edee1F18E0157C05861564; // Uniswap V3 Router
targets[2] = 0xc3d688B66703497DAA19211EEdff47f25384cdc3; // Compound v3 Comet
targets[3] = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer Vault
targets[4] = 0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5; // Curve Registry
targets[5] = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0; // Lido wstETH
return targets;
} else if (chainId == 42161) {
// Arbitrum
address[] memory targets = new address[](4);
targets[0] = 0x794a61358D6845594F94dc1DB02A252b5b4814aD; // Aave v3 Pool
targets[1] = 0xE592427A0AEce92De3Edee1F18E0157C05861564; // Uniswap V3 Router
targets[2] = 0xA5EDBDD9646f8dFF606d7448e414884C7d905dCA; // Compound v3 Comet
targets[3] = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer Vault
return targets;
} else if (chainId == 10) {
// Optimism
address[] memory targets = new address[](4);
targets[0] = 0x794a61358D6845594F94dc1DB02A252b5b4814aD; // Aave v3 Pool
targets[1] = 0xE592427A0AEce92De3Edee1F18E0157C05861564; // Uniswap V3 Router
targets[2] = 0xb125E6687d4313864e53df431d5425969c15Eb2F; // Compound v3 Comet
targets[3] = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer Vault
return targets;
} else if (chainId == 8453) {
// Base
address[] memory targets = new address[](4);
targets[0] = 0xA238Dd80C259a72e81d7e4664a9801593F98d1c5; // Aave v3 Pool
targets[1] = 0x2626664c2603336E57B271c5C0b26F421741e481; // Uniswap V3 Router
targets[2] = 0xb125E6687d4313864e53df431d5425969c15Eb2F; // Compound v3 Comet
targets[3] = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer Vault
return targets;
}
// Default: empty array
address[] memory empty = new address[](0);
return empty;
}
function getAavePool(uint256 chainId) internal pure returns (address) {
if (chainId == 1) return 0x87870Bca3F3fD6335C3F4ce8392A6935B38d4Fb1;
if (chainId == 42161) return 0x794a61358D6845594F94dc1DB02A252b5b4814aD;
if (chainId == 10) return 0x794a61358D6845594F94dc1DB02A252b5b4814aD;
if (chainId == 8453) return 0xA238Dd80C259a72e81d7e4664a9801593F98d1c5;
return address(0);
}
}