diff --git a/deployment/deploy.s.sol b/deployment/deploy.s.sol new file mode 100644 index 000000000..4195c8a8c --- /dev/null +++ b/deployment/deploy.s.sol @@ -0,0 +1,362 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.13; + +import "forge-std/Script.sol"; +import "forge-std/console.sol"; +import "forge-std/StdJson.sol"; + +import "../script/Create2Factory.sol"; + +import "../src/EtherFiRedemptionManager.sol"; +import "../src/helpers/EtherFiViewer.sol"; + +interface ICreate2Factory { + function deploy(bytes memory code, bytes32 salt) external payable returns (address); + function verify(address addr, bytes32 salt, bytes memory code) external view returns (bool); + function computeAddress(bytes32 salt, bytes memory code) external view returns (address); +} + +contract DeployScript is Script { + using stdJson for string; + + ICreate2Factory constant factory = ICreate2Factory(0x356d1B83970CeF2018F2c9337cDdb67dff5AEF99); + + function run() external { + // ------------------------------------------------------------------------- + // INPUT + // ------------------------------------------------------------------------- + // 1. contract name + // 2. constructor args + // 3. bytecode + // 4. commithash_salt + // 5. (if verification is desired) deployed address + // ------------------------------------------------------------------------- + + // #1. contract name + string memory contractName = "EtherFiRedemptionManager"; + + // #2. constructor args + // Prepare bytecode with constructor params + bytes memory constructorArgs = abi.encode( + address(0), // liquidityPool + address(0), // eEth + address(0), // weEth + address(0), // treasury + address(0) // roleRegistry + ); + + // #3. bytecode + bytes memory bytecode = abi.encodePacked( + type(EtherFiRedemptionManager).creationCode, + constructorArgs + ); + + // #4. commithash_salt + // put the commit hash used for the deployment here + // since the git commit hash is 20 bytes, we add right padding to make it 32 bytes + bytes32 commithash_salt = bytes32(bytes20(hex"46a81769b944c166e46b4e02c4e78fade102d288")); + + + // Deploy using Create2Factory + bool to_deploy = true; + if (to_deploy) { + deploy(contractName, constructorArgs, bytecode, commithash_salt, true); + } else { + // #5. deployed address + // For verification, put the address here + address deployedAddress = address(0); + require(verify(deployedAddress, bytecode, commithash_salt), "Deployment verification failed"); + } + } + + function deploy(string memory contractName, bytes memory constructorArgs, bytes memory bytecode, bytes32 salt, bool logging) internal returns (address) { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + address predictedAddress = factory.computeAddress(salt, bytecode); + vm.startBroadcast(deployerPrivateKey); + address deployedAddress = factory.deploy(bytecode, salt); + require(deployedAddress == predictedAddress, "Deployment address mismatch"); + vm.stopBroadcast(); + + if (logging) { + + // 5. Create JSON deployment log (exact same format) + string memory deployLog = string.concat( + "{\n", + ' "contractName": "', contractName, '",\n', + ' "deploymentParameters": {\n', + ' "factory": "', vm.toString(address(factory)), '",\n', + ' "salt": "', vm.toString(salt), '",\n', + formatConstructorArgs(constructorArgs, contractName), '\n', + ' },\n', + ' "deployedAddress": "', vm.toString(deployedAddress), '"\n', + "}" + ); + + // 6. Save deployment log + string memory root = vm.projectRoot(); + string memory logFileDir = string.concat(root, "/deployment/", contractName); + vm.createDir(logFileDir, true); + + string memory logFileName = string.concat( + logFileDir, + "/", + getTimestampString(), + ".json" + ); + vm.writeFile(logFileName, deployLog); + + // 7. Console output + console.log("\n=== Deployment Successful ==="); + console.log("Contract:", contractName); + console.log("Deployed to:", deployedAddress); + console.log("Deployment log saved to:", logFileName); + console.log(deployLog); + } + } + + function verify(address addr, bytes memory bytecode, bytes32 salt) internal view returns (bool) { + return factory.verify(addr, salt, bytecode); + } + + //------------------------------------------------------------------------- + // Parse and format constructor arguments into JSON + //------------------------------------------------------------------------- + + function formatConstructorArgs(bytes memory constructorArgs, string memory contractName) + internal + view + returns (string memory) + { + // 1. Load artifact JSON + string memory artifactJson = readArtifact(contractName); + + // 2. Parse ABI inputs for the constructor + bytes memory inputsArray = vm.parseJson(artifactJson, "$.abi[?(@.type == 'constructor')].inputs"); + if (inputsArray.length == 0) { + // No constructor, return empty object + return ' "constructorArgs": {}'; + } + + // 3. Decode to get the number of inputs + bytes[] memory decodedInputs = abi.decode(inputsArray, (bytes[])); + uint256 inputCount = decodedInputs.length; + + // 4. Collect param names and types in arrays + (string[] memory names, string[] memory typesArr) = getConstructorMetadata(artifactJson, inputCount); + + // 5. Build the final JSON + return decodeParamsJson(constructorArgs, names, typesArr); + } + + /** + * @dev Helper to read the contract's compiled artifact + */ + function readArtifact(string memory contractName) internal view returns (string memory) { + string memory root = vm.projectRoot(); + string memory path = string.concat(root, "/out/", contractName, ".sol/", contractName, ".json"); + return vm.readFile(path); + } + + /** + * @dev Extracts all `name` and `type` fields from the constructor inputs + */ + function getConstructorMetadata(string memory artifactJson, uint256 inputCount) + internal + pure + returns (string[] memory, string[] memory) + { + string[] memory names = new string[](inputCount); + string[] memory typesArr = new string[](inputCount); + + for (uint256 i = 0; i < inputCount; i++) { + // We'll build the JSON path e.g. "$.abi[?(@.type == 'constructor')].inputs[0].name" + string memory baseQuery = string.concat("$.abi[?(@.type == 'constructor')].inputs[", vm.toString(i), "]"); + + names[i] = trim(string(vm.parseJson(artifactJson, string.concat(baseQuery, ".name")))); + typesArr[i] = trim(string(vm.parseJson(artifactJson, string.concat(baseQuery, ".type")))); + } + return (names, typesArr); + } + + /** + * @dev Decodes each provided constructorArg and builds the JSON lines + */ + function decodeParamsJson( + bytes memory constructorArgs, + string[] memory names, + string[] memory typesArr + ) + internal + pure + returns (string memory) + { + uint256 offset; + string memory json = ' "constructorArgs": {\n'; + + for (uint256 i = 0; i < names.length; i++) { + (string memory val, uint256 newOffset) = decodeParam(constructorArgs, offset, typesArr[i]); + offset = newOffset; + + json = string.concat( + json, + ' "', names[i], '": "', val, '"', + (i < names.length - 1) ? ",\n" : "\n" + ); + } + return string.concat(json, " }"); + } + + //------------------------------------------------------------------------- + // Decoder logic (same as before) + //------------------------------------------------------------------------- + + function decodeParam(bytes memory data, uint256 offset, string memory t) + internal + pure + returns (string memory, uint256) + { + if (!isDynamicType(t)) { + // For static params, read 32 bytes directly + bytes memory chunk = slice(data, offset, 32); + return (formatStaticParam(t, bytes32(chunk)), offset + 32); + } else { + // Dynamic param: first 32 bytes is a pointer to the data location + uint256 dataLoc = uint256(bytes32(slice(data, offset, 32))); + offset += 32; + + // Next 32 bytes at that location is the length + uint256 len = uint256(bytes32(slice(data, dataLoc, 32))); + bytes memory dynData = slice(data, dataLoc + 32, len); + + return (formatDynamicParam(t, dynData), offset); + } + } + + function formatStaticParam(string memory t, bytes32 chunk) internal pure returns (string memory) { + if (compare(t, "address")) { + return vm.toString(address(uint160(uint256(chunk)))); + } else if (compare(t, "uint256")) { + return vm.toString(uint256(chunk)); + } else if (compare(t, "bool")) { + return uint256(chunk) != 0 ? "true" : "false"; + } else if (compare(t, "bytes32")) { + return vm.toString(chunk); + } + revert("Unsupported static type"); + } + + function formatDynamicParam(string memory t, bytes memory dynData) internal pure returns (string memory) { + if (compare(t, "string")) { + return string(dynData); + } else if (compare(t, "bytes")) { + return vm.toString(dynData); + } else if (endsWithArray(t)) { + // e.g. "uint256[]" or "address[]" + if (startsWith(t, "uint256")) { + uint256[] memory arr = abi.decode(dynData, (uint256[])); + return formatUint256Array(arr); + } else if (startsWith(t, "address")) { + address[] memory arr = abi.decode(dynData, (address[])); + return formatAddressArray(arr); + } + } + revert("Unsupported dynamic type"); + } + + //------------------------------------------------------------------------- + // Array format helpers + //------------------------------------------------------------------------- + + function formatUint256Array(uint256[] memory arr) internal pure returns (string memory) { + string memory out = "["; + for (uint256 i = 0; i < arr.length; i++) { + out = string.concat(out, (i == 0 ? "" : ","), vm.toString(arr[i])); + } + return string.concat(out, "]"); + } + + function formatAddressArray(address[] memory arr) internal pure returns (string memory) { + string memory out = "["; + for (uint256 i = 0; i < arr.length; i++) { + out = string.concat(out, (i == 0 ? "" : ","), vm.toString(arr[i])); + } + return string.concat(out, "]"); + } + + //------------------------------------------------------------------------- + // Type checks + //------------------------------------------------------------------------- + + function isDynamicType(string memory t) internal pure returns (bool) { + return startsWith(t, "string") || startsWith(t, "bytes") || endsWithArray(t); + } + + function endsWithArray(string memory t) internal pure returns (bool) { + bytes memory b = bytes(t); + return b.length >= 2 && (b[b.length - 2] == '[' && b[b.length - 1] == ']'); + } + + //------------------------------------------------------------------------- + // Low-level bytes slicing + //------------------------------------------------------------------------- + + function slice(bytes memory data, uint256 start, uint256 length) internal pure returns (bytes memory) { + require(data.length >= start + length, "slice_outOfBounds"); + bytes memory out = new bytes(length); + for (uint256 i = 0; i < length; i++) { + out[i] = data[start + i]; + } + return out; + } + + //------------------------------------------------------------------------- + // String helpers + //------------------------------------------------------------------------- + + function trim(string memory str) internal pure returns (string memory) { + bytes memory b = bytes(str); + uint256 start; + uint256 end = b.length; + while (start < b.length && uint8(b[start]) <= 0x20) start++; + while (end > start && uint8(b[end - 1]) <= 0x20) end--; + bytes memory out = new bytes(end - start); + for (uint256 i = 0; i < out.length; i++) { + out[i] = b[start + i]; + } + return string(out); + } + + function compare(string memory a, string memory b) internal pure returns (bool) { + return keccak256(bytes(a)) == keccak256(bytes(b)); + } + + function startsWith(string memory str, string memory prefix) internal pure returns (bool) { + bytes memory s = bytes(str); + bytes memory p = bytes(prefix); + if (s.length < p.length) return false; + for (uint256 i = 0; i < p.length; i++) { + if (s[i] != p[i]) return false; + } + return true; + } + + //------------------------------------------------------------------------- + // Timestamp-based filename + //------------------------------------------------------------------------- + + // The timestamp is in UTC (Coordinated Universal Time). This is because block.timestamp returns a Unix timestamp, which is always in UTC. + function getTimestampString() internal view returns (string memory) { + uint256 ts = block.timestamp; + string memory year = vm.toString((ts / 31536000) + 1970); + string memory month = pad(vm.toString(((ts % 31536000) / 2592000) + 1)); + string memory day = pad(vm.toString(((ts % 2592000) / 86400) + 1)); + string memory hour = pad(vm.toString((ts % 86400) / 3600)); + string memory minute = pad(vm.toString((ts % 3600) / 60)); + string memory second = pad(vm.toString(ts % 60)); + return string.concat(year,"-",month,"-",day,"-",hour,"-",minute,"-",second); + } + + function pad(string memory n) internal pure returns (string memory) { + return bytes(n).length == 1 ? string.concat("0", n) : n; + } +} diff --git a/deployment/deployed-contracts.json b/deployment/deployed-contracts.json deleted file mode 100644 index 0da059318..000000000 --- a/deployment/deployed-contracts.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "EtherFiRedemptionManagerImplementation": "0xe6f40295A7500509faD08E924c91b0F050a7b84b", - "EtherFiRedemptionManagerInstance": "0xDadEf1fFBFeaAB4f68A9fD181395F68b4e4E7Ae0", - "EtherFiAdminImplementation": "0x683583979C8be7Bcfa41E788Ab38857dfF792f49", - "EtherFiRewardsRouterImplementation": "0xe94bF0DF71002ff0165CF4daB461dEBC3978B0fa", - "LiquidityPoolImplementation": "0xA6099d83A67a2c653feB5e4e48ec24C5aeE1C515", - "WeETHImplementation": "0x353E98F34b6E5a8D9d1876Bf6dF01284d05837cB", - "WithdrawRequestNFTImplementation": "0x685870a508b56c7f1002EEF5eFCFa01304474F61", - "EtherFiNodesManagerImplementation": "0x572E25fD70b6eB9a3CaD1CE1D48E3CfB938767F1" -} \ No newline at end of file diff --git a/foundry.toml b/foundry.toml index 93d6cd43a..069a383a3 100644 --- a/foundry.toml +++ b/foundry.toml @@ -2,7 +2,7 @@ src = 'src' out = 'out' libs = ['lib'] -fs_permissions = [{ access = "read-write", path = "./release"}, { access = "read", path = "./test" }, { access = "read-write", path = "./operations" }, { access = "read-write", path = "./deployment" }] +fs_permissions = [{ access = "read-write", path = "./release"}, { access = "read", path = "./test" }, { access = "read-write", path = "./operations" }, { access = "read-write", path = "./deployment" }, { access = "read", path = "./out" }] gas_reports = ["*"] optimizer_runs = 1500 extra_output = ["storageLayout"] diff --git a/script/Create2Factory.sol b/script/Create2Factory.sol index ba8b2a470..0cf5d152f 100644 --- a/script/Create2Factory.sol +++ b/script/Create2Factory.sol @@ -4,12 +4,32 @@ pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Create2.sol"; contract Create2Factory { - event Deployed(address addr, address deployer, bytes32 bytecode_hash, bytes32 salt); + event Deployed(address addr, address deployer, bytes32 bytecodeHash, bytes32 salt); + /// @notice Deploys a contract using CREATE2 + /// @param code The contract bytecode including constructor arguments + /// @param salt A unique value to influence contract address function deploy(bytes memory code, bytes32 salt) external payable returns (address) { address addr = Create2.deploy(msg.value, salt, code); - emit Deployed(addr, address(this), keccak256(code), salt); + emit Deployed(addr, msg.sender, keccak256(code), salt); return addr; } + + /// @notice Computes the deterministic address of a contract + /// @param salt The salt used for deployment + /// @param code The bytecode including constructor arguments + /// @return predicted The predicted deterministic contract address + function computeAddress(bytes32 salt, bytes memory code) public view returns (address predicted) { + predicted = Create2.computeAddress(salt, keccak256(code), address(this)); + } + + /// @notice Verifies whether a given deployed address matches provided code and salt + /// @param addr The address to verify + /// @param salt The salt used for the deployment + /// @param code The contract bytecode including constructor arguments + /// @return True if the address matches the computed address, false otherwise + function verify(address addr, bytes32 salt, bytes memory code) external view returns (bool) { + return (addr == computeAddress(salt, code)); + } } \ No newline at end of file diff --git a/script/deploys/BucketRateLimiter.s.sol b/script/deploys/BucketRateLimiter.s.sol deleted file mode 100644 index 60a2046d3..000000000 --- a/script/deploys/BucketRateLimiter.s.sol +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; - -import "../../src/BucketRateLimiter.sol"; -import "../../src/UUPSProxy.sol"; - -interface IL2SyncPool { - function setRateLimiter(address rateLimiter) external; -} - -contract Deploy is Script { - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - address deployer = vm.addr(deployerPrivateKey); - address l2syncpool; - - if (block.chainid == 59144) l2syncpool = 0x823106E745A62D0C2FC4d27644c62aDE946D9CCa; // LINEA - else if (block.chainid == 81457) l2syncpool = 0x52c4221Cb805479954CDE5accfF8C4DcaF96623B; // BLAST - else if (block.chainid == 34443) l2syncpool = 0x52c4221Cb805479954CDE5accfF8C4DcaF96623B; // MODE - else if (block.chainid == 8453) l2syncpool = 0xc38e046dFDAdf15f7F56853674242888301208a5; // BASE - else revert("Unsupported chain id"); - - vm.startBroadcast(deployerPrivateKey); - - BucketRateLimiter impl = new BucketRateLimiter(); - UUPSProxy proxy = new UUPSProxy(address(impl), ""); - BucketRateLimiter limiter = BucketRateLimiter(address(proxy)); - limiter.initialize(); - - limiter.updateConsumer(l2syncpool); - IL2SyncPool(l2syncpool).setRateLimiter(address(limiter)); - - vm.stopBroadcast(); - - // TEST - - vm.startPrank(deployer); - limiter.setCapacity(0.0002 ether); - limiter.setRefillRatePerSecond(0.0002 ether); - vm.stopPrank(); - - vm.prank(l2syncpool); - vm.expectRevert("BucketRateLimiter: rate limit exceeded"); - limiter.updateRateLimit(address(0), address(0), 0.0001 ether, 0.0001 ether); - - vm.prank(l2syncpool); - vm.warp(block.timestamp + 1); - limiter.updateRateLimit(address(0), address(0), 0.0001 ether, 0.0001 ether); - } - -} \ No newline at end of file diff --git a/script/deploys/DeployAndPopulateAddressProviderScript.s.sol b/script/deploys/DeployAndPopulateAddressProviderScript.s.sol deleted file mode 100644 index efa0c42e4..000000000 --- a/script/deploys/DeployAndPopulateAddressProviderScript.s.sol +++ /dev/null @@ -1,86 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; -import "../../src/helpers/AddressProvider.sol"; - -contract DeployAndPopulateAddressProvider is Script { - - /*---- Storage variables ----*/ - - struct PhaseOneAddresses { - address auctionManagerAddress; - address stakingManagerAddress; - address etherFiNodesManagerAddress; - address protocolRevenueManager; - address tnft; - address bnft; - address treasury; - address nodeOperatorManager; - address etherFiNode; - address earlyAdopterPool; - } - - struct PhaseOnePointFiveAddress { - address eETH; - address liquidityPool; - address membershipManager; - address membershipNFT; - address nftExchange; - address regulationsManager; - address weETH; - } - - AddressProvider public addressProvider; - PhaseOneAddresses public phaseOneAddresses; - PhaseOnePointFiveAddress public phaseOnePointFiveAddress; - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - address owner = vm.envAddress("DEPLOYER"); - vm.startBroadcast(deployerPrivateKey); - - addressProvider = new AddressProvider(owner); - console.log(address(addressProvider)); - - /*---- Populate Registry ----*/ - - phaseOneAddresses.auctionManagerAddress = vm.envAddress("AUCTION_MANAGER_PROXY_ADDRESS"); - phaseOneAddresses.stakingManagerAddress = vm.envAddress("STAKING_MANAGER_PROXY_ADDRESS"); - phaseOneAddresses.etherFiNodesManagerAddress = vm.envAddress("ETHERFI_NODES_MANAGER_PROXY_ADDRESS"); - phaseOneAddresses.protocolRevenueManager = vm.envAddress("PROTOCOL_REVENUE_MANAGER_PROXY_ADDRESS"); - phaseOneAddresses.tnft = vm.envAddress("TNFT_PROXY_ADDRESS"); - phaseOneAddresses.bnft = vm.envAddress("BNFT_PROXY_ADDRESS"); - phaseOneAddresses.treasury = vm.envAddress("TREASURY_ADDRESS"); - phaseOneAddresses.nodeOperatorManager = vm.envAddress("NODE_OPERATOR_MANAGER_ADDRESS"); - phaseOneAddresses.etherFiNode = vm.envAddress("ETHERFI_NODE"); - phaseOneAddresses.earlyAdopterPool = vm.envAddress("EARLY_ADOPTER_POOL"); - phaseOnePointFiveAddress.eETH = vm.envAddress("EETH_PROXY_ADDRESS"); - phaseOnePointFiveAddress.liquidityPool = vm.envAddress("LIQUIDITY_POOL_PROXY_ADDRESS"); - phaseOnePointFiveAddress.membershipManager = vm.envAddress("MEMBERSHIP_MANAGER_PROXY_ADDRESS"); - phaseOnePointFiveAddress.membershipNFT = vm.envAddress("MEMBERSHIP_NFT_PROXY_ADDRESS"); - phaseOnePointFiveAddress.nftExchange = vm.envAddress("NFT_EXCHANGE"); - phaseOnePointFiveAddress.regulationsManager = vm.envAddress("REGULATIONS_MANAGER_PROXY_ADDRESS"); - phaseOnePointFiveAddress.weETH = vm.envAddress("WEETH_PROXY_ADDRESS"); - - addressProvider.addContract(phaseOneAddresses.auctionManagerAddress, "AuctionManager"); - addressProvider.addContract(phaseOneAddresses.stakingManagerAddress, "StakingManager"); - addressProvider.addContract(phaseOneAddresses.etherFiNodesManagerAddress, "EtherFiNodesManager"); - addressProvider.addContract(phaseOneAddresses.protocolRevenueManager, "ProtocolRevenueManager"); - addressProvider.addContract(phaseOneAddresses.tnft, "TNFT"); - addressProvider.addContract(phaseOneAddresses.bnft, "BNFT"); - addressProvider.addContract(phaseOneAddresses.treasury, "Treasury"); - addressProvider.addContract(phaseOneAddresses.nodeOperatorManager, "NodeOperatorManager"); - addressProvider.addContract(phaseOneAddresses.etherFiNode, "EtherFiNode"); - addressProvider.addContract(phaseOneAddresses.earlyAdopterPool, "EarlyAdopterPool"); - addressProvider.addContract(phaseOnePointFiveAddress.eETH, "EETH"); - addressProvider.addContract(phaseOnePointFiveAddress.liquidityPool, "LiquidityPool"); - addressProvider.addContract(phaseOnePointFiveAddress.membershipManager, "MembershipManager"); - addressProvider.addContract(phaseOnePointFiveAddress.membershipNFT, "MembershipNFT"); - addressProvider.addContract(phaseOnePointFiveAddress.nftExchange, "NFTExchange"); - addressProvider.addContract(phaseOnePointFiveAddress.regulationsManager, "RegulationsManager"); - addressProvider.addContract(phaseOnePointFiveAddress.weETH, "WeETH"); - - vm.stopBroadcast(); - } -} \ No newline at end of file diff --git a/script/deploys/DeployBucketLimiter.s.sol b/script/deploys/DeployBucketLimiter.s.sol deleted file mode 100644 index 54d1b7490..000000000 --- a/script/deploys/DeployBucketLimiter.s.sol +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; - -import "src/BucketRateLimiter.sol"; - -contract Deploy is Script { - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - - vm.startBroadcast(deployerPrivateKey); - - BucketRateLimiter limiter = new BucketRateLimiter(); - - vm.stopBroadcast(); - } -} diff --git a/script/deploys/DeployCumulativeMerkleRewardsDistributor.sol b/script/deploys/DeployCumulativeMerkleRewardsDistributor.sol deleted file mode 100644 index 696909109..000000000 --- a/script/deploys/DeployCumulativeMerkleRewardsDistributor.sol +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; - -import "src/CumulativeMerkleRewardsDistributor.sol"; -import "src/UUPSProxy.sol"; -import "../../src/helpers/AddressProvider.sol"; -import "forge-std/console.sol"; - -/* Deploy Command - * source .env && forge script ./script/deploys/DeployCumulativeMerkleRewardsDistributor.sol:DeployCumulativeMerkleRewardsDistributor --rpc-url MAINNET_RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --verify --slow -vvvv -*/ - -contract DeployCumulativeMerkleRewardsDistributor is Script { - - AddressProvider public addressProvider; - /////////////////////////////////////// - address roleRegistryProxyAddress; - ////////////////////////////////////// - - function run() external { - - address addressProviderAddress = vm.envAddress("CONTRACT_REGISTRY"); - - vm.startBroadcast(); - - - addressProvider = AddressProvider(addressProviderAddress); - roleRegistryProxyAddress = addressProvider.getContractAddress("RoleRegistry"); - address timelockAddress = addressProvider.getContractAddress("EtherFiTimelock"); - console2.log("RoleRegistry address:", roleRegistryProxyAddress); - - bytes memory initializerData = abi.encodeWithSelector(CumulativeMerkleRewardsDistributor.initialize.selector); - CumulativeMerkleRewardsDistributor cumulativeMerkleRewardsDistributorImplementation = new CumulativeMerkleRewardsDistributor(roleRegistryProxyAddress); - UUPSProxy cumulativeMerkleRewardsDistributorProxy = new UUPSProxy(address(cumulativeMerkleRewardsDistributorImplementation), initializerData); - CumulativeMerkleRewardsDistributor cumulativeMerkleInstance = CumulativeMerkleRewardsDistributor(address(cumulativeMerkleRewardsDistributorProxy)); - //cumulativeMerkleInstance.grantRole(keccak256("CUMULATIVE_MERKLE_REWARDS_DISTRIBUTOR_ADMIN_ROLE"), msg.sender); - cumulativeMerkleInstance.transferOwnership(address(timelockAddress)); - - vm.stopBroadcast(); - } -} diff --git a/script/deploys/DeployEarlyAdopterPool.s.sol b/script/deploys/DeployEarlyAdopterPool.s.sol deleted file mode 100644 index 735af5d87..000000000 --- a/script/deploys/DeployEarlyAdopterPool.s.sol +++ /dev/null @@ -1,95 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; -import "forge-std/console.sol"; -import "../../src/EarlyAdopterPool.sol"; -import "../../test/TestERC20.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; - -contract DeployEarlyAdopterPoolScript is Script { - using Strings for string; - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - - EarlyAdopterPool earlyAdopterPool = new EarlyAdopterPool( - 0xae78736Cd615f374D3085123A210448E74Fc6393, - 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0, - 0xac3E018457B222d93114458476f3E3416Abbe38F, - 0xBe9895146f7AF43049ca1c1AE358B0541Ea49704 - ); - - vm.stopBroadcast(); - - // Sets the variables to be written to contract addresses.txt - string memory earlyAdopterPoolAddress = Strings.toHexString( - address(earlyAdopterPool) - ); - - // Declare version Var - uint256 version; - - // Set path to version file where current version is recorded - /// @dev Initial version.txt and X.release files should be created manually - string memory versionPath = "release/logs/earlyAdopterPool/version.txt"; - - // Read Current version - string memory versionString = vm.readLine(versionPath); - - // Cast string to uint256 - version = _stringToUint(versionString); - - version++; - - // Declares the incremented version to be written to version.txt file - string memory versionData = string( - abi.encodePacked(Strings.toString(version)) - ); - - // Overwrites the version.txt file with incremented version - vm.writeFile(versionPath, versionData); - - // Sets the path for the release file using the incremented version var - string memory releasePath = string( - abi.encodePacked( - "release/logs/earlyAdopterPool/", - Strings.toString(version), - ".release" - ) - ); - - // Concatenates data to be written to X.release file - string memory writeData = string( - abi.encodePacked( - "Version: ", - Strings.toString(version), - "\n", - "Early Adopter Pool Contract Address: ", - earlyAdopterPoolAddress - ) - ); - - // Writes the data to .release file - vm.writeFile(releasePath, writeData); - } - - function _stringToUint(string memory numString) - internal - pure - returns (uint256) - { - uint256 val = 0; - bytes memory stringBytes = bytes(numString); - for (uint256 i = 0; i < stringBytes.length; i++) { - uint256 exp = stringBytes.length - i; - bytes1 ival = stringBytes[i]; - uint8 uval = uint8(ival); - uint256 jval = uval - uint256(0x30); - - val += (uint256(jval) * (10**(exp - 1))); - } - return val; - } -} diff --git a/script/deploys/DeployEtherFISuite.s.sol b/script/deploys/DeployEtherFISuite.s.sol deleted file mode 100644 index aa98e7af8..000000000 --- a/script/deploys/DeployEtherFISuite.s.sol +++ /dev/null @@ -1,330 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; -import "../../src/Treasury.sol"; -import "../../src/NodeOperatorManager.sol"; -import "../../src/EtherFiNodesManager.sol"; -import "../../src/EtherFiNode.sol"; -import "../../src/archive/ProtocolRevenueManager.sol"; -import "../../src/StakingManager.sol"; -import "../../src/AuctionManager.sol"; -import "../../src/LiquidityPool.sol"; -import "../../src/EETH.sol"; -import "../../src/WeETH.sol"; -import "../../src/archive/RegulationsManager.sol"; -import "../../src/UUPSProxy.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; - -import "../../test/TestERC20.sol"; - -contract DeployEtherFiSuiteScript is Script { - using Strings for string; - - bytes32 initialHash = vm.envBytes32("INITIAL_HASH"); - - - /*---- Storage variables ----*/ - - TestERC20 public rETH; - TestERC20 public wstETH; - TestERC20 public sfrxEth; - TestERC20 public cbEth; - - UUPSProxy public auctionManagerProxy; - UUPSProxy public stakingManagerProxy; - UUPSProxy public etherFiNodeManagerProxy; - UUPSProxy public protocolRevenueManagerProxy; - UUPSProxy public TNFTProxy; - UUPSProxy public BNFTProxy; - UUPSProxy public liquidityPoolProxy; - UUPSProxy public eETHProxy; - UUPSProxy public claimReceiverPoolProxy; - UUPSProxy public regulationsManagerProxy; - UUPSProxy public weETHProxy; - - BNFT public BNFTImplementation; - BNFT public BNFTInstance; - - TNFT public TNFTImplementation; - TNFT public TNFTInstance; - - WeETH public weEthImplementation; - WeETH public weEthInstance; - - AuctionManager public auctionManagerImplementation; - AuctionManager public auctionManager; - - StakingManager public stakingManagerImplementation; - StakingManager public stakingManager; - - ProtocolRevenueManager public protocolRevenueManagerImplementation; - ProtocolRevenueManager public protocolRevenueManager; - - EtherFiNodesManager public etherFiNodesManagerImplementation; - EtherFiNodesManager public etherFiNodesManager; - - LiquidityPool public liquidityPoolImplementation; - LiquidityPool public liquidityPool; - - EETH public eETHImplementation; - EETH public eETHInstance; - - RegulationsManager public regulationsManagerInstance; - RegulationsManager public regulationsManagerImplementation; - - struct suiteAddresses { - address treasury; - address nodeOperatorManager; - address auctionManager; - address stakingManager; - address TNFT; - address BNFT; - address etherFiNodesManager; - address protocolRevenueManager; - address etherFiNode; - address regulationsManager; - address liquidityPool; - address eETH; - address weEth; - } - - suiteAddresses suiteAddressesStruct; - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - address ethDepositContractAddress; - if (block.chainid == 5) { - // goerli - ethDepositContractAddress = 0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b; - } else if (block.chainid == 1) { - ethDepositContractAddress = 0x00000000219ab540356cBB839Cbe05303d7705Fa; - } else { - assert(false); - } - - vm.startBroadcast(deployerPrivateKey); - - // Deploy contracts - Treasury treasury = new Treasury(); - NodeOperatorManager nodeOperatorManager = new NodeOperatorManager(); - - auctionManagerImplementation = new AuctionManager(); - auctionManagerProxy = new UUPSProxy(address(auctionManagerImplementation),""); - auctionManager = AuctionManager(address(auctionManagerProxy)); - auctionManager.initialize(address(nodeOperatorManager)); - - stakingManagerImplementation = new StakingManager(); - stakingManagerProxy = new UUPSProxy(address(stakingManagerImplementation),""); - stakingManager = StakingManager(address(stakingManagerProxy)); - stakingManager.initialize(address(auctionManager), ethDepositContractAddress); - - BNFTImplementation = new BNFT(); - BNFTProxy = new UUPSProxy(address(BNFTImplementation),""); - BNFTInstance = BNFT(address(BNFTProxy)); - BNFTInstance.initialize(address(stakingManager)); - - TNFTImplementation = new TNFT(); - TNFTProxy = new UUPSProxy(address(TNFTImplementation),""); - TNFTInstance = TNFT(address(TNFTProxy)); - TNFTInstance.initialize(address(stakingManager)); - - protocolRevenueManagerImplementation = new ProtocolRevenueManager(); - protocolRevenueManagerProxy = new UUPSProxy(address(protocolRevenueManagerImplementation),""); - protocolRevenueManager = ProtocolRevenueManager(payable(address(protocolRevenueManagerProxy))); - protocolRevenueManager.initialize(); - - etherFiNodesManagerImplementation = new EtherFiNodesManager(); - etherFiNodeManagerProxy = new UUPSProxy(address(etherFiNodesManagerImplementation),""); - etherFiNodesManager = EtherFiNodesManager(payable(address(etherFiNodeManagerProxy))); - etherFiNodesManager.initialize( - address(treasury), - address(auctionManager), - address(stakingManager), - address(TNFTInstance), - address(BNFTInstance), - address(0), // TODO - address(0), - address(0) - ); - - regulationsManagerImplementation = new RegulationsManager(); - regulationsManagerProxy = new UUPSProxy(address(regulationsManagerImplementation), ""); - regulationsManagerInstance = RegulationsManager(address(regulationsManagerProxy)); - regulationsManagerInstance.initialize(); - - EtherFiNode etherFiNode = new EtherFiNode(); - - // Mainnet Addresses - // address private immutable rETH = 0xae78736Cd615f374D3085123A210448E74Fc6393; - // address private immutable wstETH = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0; - // address private immutable sfrxETH = 0xac3E018457B222d93114458476f3E3416Abbe38F; - // address private immutable cbETH = 0xBe9895146f7AF43049ca1c1AE358B0541Ea49704; - rETH = new TestERC20("Rocket Pool ETH", "rETH"); - cbEth = new TestERC20("Staked ETH", "wstETH"); - wstETH = new TestERC20("Coinbase ETH", "cbEth"); - sfrxEth = new TestERC20("Frax ETH", "sfrxEth"); - - liquidityPoolImplementation = new LiquidityPool(); - liquidityPoolProxy = new UUPSProxy( - address(liquidityPoolImplementation), - "" - ); - liquidityPool = LiquidityPool( - payable(address(liquidityPoolProxy)) - ); - - eETHImplementation = new EETH(); - eETHProxy = new UUPSProxy(address(eETHImplementation), ""); - eETHInstance = EETH(address(eETHProxy)); - eETHInstance.initialize(payable(address(liquidityPool))); - - // Setup dependencies - nodeOperatorManager.setAuctionContractAddress(address(auctionManager)); - - auctionManager.setStakingManagerContractAddress(address(stakingManager)); - - protocolRevenueManager.setAuctionManagerAddress(address(auctionManager)); - protocolRevenueManager.setEtherFiNodesManagerAddress(address(etherFiNodesManager)); - - stakingManager.setEtherFiNodesManagerAddress(address(etherFiNodesManager)); - stakingManager.setLiquidityPoolAddress(address(liquidityPool)); - stakingManager.registerEtherFiNodeImplementationContract(address(etherFiNode)); - stakingManager.registerTNFTContract(address(TNFTInstance)); - stakingManager.registerBNFTContract(address(BNFTInstance)); - - liquidityPool.initialize(address(eETHInstance), address(stakingManager), address(etherFiNodesManager), address(0), address(0), address(0), address(0)); - - weEthImplementation = new WeETH(); - weETHProxy = new UUPSProxy(address(weEthImplementation), ""); - weEthInstance = WeETH(address(weETHProxy)); - weEthInstance.initialize(payable(address(liquidityPool)), address(eETHInstance)); - - regulationsManagerInstance.initializeNewWhitelist(initialHash); - - vm.stopBroadcast(); - - suiteAddressesStruct = suiteAddresses({ - treasury: address(treasury), - nodeOperatorManager: address(nodeOperatorManager), - auctionManager: address(auctionManager), - stakingManager: address(stakingManager), - TNFT: address(TNFTInstance), - BNFT: address(BNFTInstance), - etherFiNodesManager: address(etherFiNodesManager), - protocolRevenueManager: address(protocolRevenueManager), - etherFiNode: address(etherFiNode), - regulationsManager: address(regulationsManagerInstance), - liquidityPool: address(liquidityPool), - eETH: address(eETHInstance), - weEth: address(weEthInstance) - }); - - writeSuiteVersionFile(); - writeLpVersionFile(); - } - - function _stringToUint( - string memory numString - ) internal pure returns (uint256) { - uint256 val = 0; - bytes memory stringBytes = bytes(numString); - for (uint256 i = 0; i < stringBytes.length; i++) { - uint256 exp = stringBytes.length - i; - bytes1 ival = stringBytes[i]; - uint8 uval = uint8(ival); - uint256 jval = uval - uint256(0x30); - - val += (uint256(jval) * (10 ** (exp - 1))); - } - return val; - } - - function writeSuiteVersionFile() internal { - // Read Current version - string memory versionString = vm.readLine("release/logs/EtherFiSuite/version.txt"); - - // Cast string to uint256 - uint256 version = _stringToUint(versionString); - - version++; - - // Overwrites the version.txt file with incremented version - vm.writeFile( - "release/logs/EtherFiSuite/version.txt", - string(abi.encodePacked(Strings.toString(version))) - ); - - // Writes the data to .release file - vm.writeFile( - string( - abi.encodePacked( - "release/logs/EtherFiSuite/", - Strings.toString(version), - ".release" - ) - ), - string( - abi.encodePacked( - Strings.toString(version), - "\nTreasury: ", - Strings.toHexString(suiteAddressesStruct.treasury), - "\nNode Operator Key Manager: ", - Strings.toHexString(suiteAddressesStruct.nodeOperatorManager), - "\nAuctionManager: ", - Strings.toHexString(suiteAddressesStruct.auctionManager), - "\nStakingManager: ", - Strings.toHexString(suiteAddressesStruct.stakingManager), - "\nEtherFi Node Manager: ", - Strings.toHexString(suiteAddressesStruct.etherFiNodesManager), - "\nProtocol Revenue Manager: ", - Strings.toHexString(suiteAddressesStruct.protocolRevenueManager), - "\nTNFT: ", - Strings.toHexString(suiteAddressesStruct.TNFT), - "\nBNFT: ", - Strings.toHexString(suiteAddressesStruct.BNFT) - ) - ) - ); - } - - function writeLpVersionFile() internal { - // Read Current version - string memory versionString = vm.readLine("release/logs/LiquidityPool/version.txt"); - - // Cast string to uint256 - uint256 version = _stringToUint(versionString); - - version++; - - // Overwrites the version.txt file with incremented version - vm.writeFile( - "release/logs/LiquidityPool/version.txt", - string(abi.encodePacked(Strings.toString(version))) - ); - - // Writes the data to .release file - vm.writeFile( - string( - abi.encodePacked( - "release/logs/LiquidityPool/", - Strings.toString(version), - ".release" - ) - ), - string( - abi.encodePacked( - Strings.toString(version), - "\nRegulations Manager: ", - Strings.toHexString(suiteAddressesStruct.regulationsManager), - "\nLiquidity Pool: ", - Strings.toHexString(suiteAddressesStruct.liquidityPool), - "\neETH: ", - Strings.toHexString(suiteAddressesStruct.eETH), - "\nweETH: ", - Strings.toHexString(suiteAddressesStruct.weEth) - ) - ) - ); - } -} diff --git a/script/deploys/DeployEtherFiOperationParameters.s.sol b/script/deploys/DeployEtherFiOperationParameters.s.sol deleted file mode 100644 index 15080939a..000000000 --- a/script/deploys/DeployEtherFiOperationParameters.s.sol +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; - -import "@openzeppelin/contracts/utils/Strings.sol"; - -import "../../src/Liquifier.sol"; -import "../../src/EtherFiRestaker.sol"; -import "../../src/helpers/AddressProvider.sol"; -import "../../src/UUPSProxy.sol"; -import "../../src/helpers/EtherFiOperationParameters.sol"; - - -contract Deploy is Script { - using Strings for string; - AddressProvider public addressProvider; - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - address addressProviderAddress = vm.envAddress("CONTRACT_REGISTRY"); - addressProvider = AddressProvider(addressProviderAddress); - - vm.startBroadcast(deployerPrivateKey); - - bool to_upgrade = true; - - if (to_upgrade) { - EtherFiOperationParameters instance = EtherFiOperationParameters(0xD0Ff8996DB4bDB46870b7E833b7532f484fEad1A); - EtherFiOperationParameters impl = new EtherFiOperationParameters(); - instance.upgradeTo(address(impl)); - } else { - EtherFiOperationParameters impl = new EtherFiOperationParameters(); - UUPSProxy proxy = new UUPSProxy(address(impl), ""); - - EtherFiOperationParameters instance = EtherFiOperationParameters(payable(proxy)); - - instance.updateTagAdmin("ORACLE", 0x566E58ac0F2c4BCaF6De63760C56cC3f825C48f5, true); - instance.updateTagAdmin("EIGENPOD", 0x566E58ac0F2c4BCaF6De63760C56cC3f825C48f5, true); - // instance.updateTagKeyValue("ORACLE", "WITHDRAWAL_TARGET_GAS_PRICE", "12.5"); // 12.5 gwei - // instance.updateTagKeyValue("ORACLE", "TARGET_LIQUIDITY_IN_PERCENT_OF_TVL", "2.0"); // 2.0 % of TVL - // instance.updateTagKeyValue("EIGENPOD", "PROOF_SUBMIT_TARGET_GAS_PRICE", "12.5"); // 12.5 gwei - } - - vm.stopBroadcast(); - } -} \ No newline at end of file diff --git a/script/deploys/DeployEtherFiRestaker.s.sol b/script/deploys/DeployEtherFiRestaker.s.sol deleted file mode 100644 index eda1ba4fb..000000000 --- a/script/deploys/DeployEtherFiRestaker.s.sol +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; - -import "../../src/Liquifier.sol"; -import "../../src/EtherFiRestaker.sol"; -import "../../src/helpers/AddressProvider.sol"; -import "../../src/UUPSProxy.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; - -contract Deploy is Script { - using Strings for string; - - UUPSProxy public liquifierProxy; - - Liquifier public liquifierInstance; - - AddressProvider public addressProvider; - address eigenlayerRewardsCoordinator; - - address admin; - - function run() external { - require(eigenlayerRewardsCoordinator != address(0), "must set rewardsCoordinator"); - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - address addressProviderAddress = vm.envAddress("CONTRACT_REGISTRY"); - addressProvider = AddressProvider(addressProviderAddress); - - vm.startBroadcast(deployerPrivateKey); - - EtherFiRestaker restaker = EtherFiRestaker(payable(new UUPSProxy(payable(new EtherFiRestaker(eigenlayerRewardsCoordinator)), ""))); - restaker.initialize( - addressProvider.getContractAddress("LiquidityPool"), - addressProvider.getContractAddress("Liquifier") - ); - - new Liquifier(); - - // addressProvider.addContract(address(liquifierInstance), "Liquifier"); - - vm.stopBroadcast(); - } -} diff --git a/script/deploys/DeployEtherFiRewardsRouter.s.sol b/script/deploys/DeployEtherFiRewardsRouter.s.sol deleted file mode 100644 index ac7cd18ea..000000000 --- a/script/deploys/DeployEtherFiRewardsRouter.s.sol +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; - -import "src/EtherFiRewardsRouter.sol"; -import "src/UUPSProxy.sol"; -import "../../src/helpers/AddressProvider.sol"; -import "forge-std/console.sol"; - -/* Deploy Command - * source .env && forge script ./script/deploys/DeployEtherFiRewardsRouter.s.sol:DeployEtherFiRewardsRouter --rpc-url MAINNET_RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --verify --slow -vvvv -*/ - -contract DeployEtherFiRewardsRouter is Script { - - AddressProvider public addressProvider; - /////////////////////////////////////// - address roleRegistryProxyAddress = address(0x1d3Af47C1607A2EF33033693A9989D1d1013BB50); //replace with deployed RoleRegistryProxy address - address treasuryGnosisSafeAddress = address(0x0c83EAe1FE72c390A02E426572854931EefF93BA); - address etherfiRouterAdmin = address(0xc13C06899a9BbEbB3E2b38dBe86e4Ea8852AFC9b); - ////////////////////////////////////// - - function run() external { - - address addressProviderAddress = vm.envAddress("CONTRACT_REGISTRY"); - - vm.startBroadcast(); - - RoleRegistry roleRegistryInstance = RoleRegistry(roleRegistryProxyAddress); - roleRegistryInstance.grantRole(keccak256("ETHERFI_REWARDS_ROUTER_ADMIN_ROLE"), etherfiRouterAdmin); - - addressProvider = AddressProvider(addressProviderAddress); - - address liquidityPoolProxyAddress = addressProvider.getContractAddress("LiquidityPool"); - bytes memory initializerData = abi.encodeWithSelector(EtherFiRewardsRouter.initialize.selector); - EtherFiRewardsRouter etherFiRewardsRouterImplementation = new EtherFiRewardsRouter(liquidityPoolProxyAddress, treasuryGnosisSafeAddress, roleRegistryProxyAddress); - UUPSProxy etherFiRewardsRouterProxy = new UUPSProxy(address(etherFiRewardsRouterImplementation), initializerData); - } -} diff --git a/script/deploys/DeployEtherFiViewer.s.sol b/script/deploys/DeployEtherFiViewer.s.sol deleted file mode 100644 index b24e6fa3e..000000000 --- a/script/deploys/DeployEtherFiViewer.s.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; - -import "src/helpers/EtherFiViewer.sol"; -import "src/UUPSProxy.sol"; - -contract DeployEtherFiViewer is Script { - - function run() external { - address addressProviderAddress = vm.envAddress("CONTRACT_REGISTRY"); - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - - vm.startBroadcast(deployerPrivateKey); - - EtherFiViewer impl = new EtherFiViewer(); - - // UUPSProxy proxy = new UUPSProxy(address(impl), ""); - // EtherFiViewer viewer = EtherFiViewer(address(proxy)); - // viewer.initialize(addressProviderAddress); - - EtherFiViewer viewer = EtherFiViewer(address(0x2ecd155405cA52a5ca0e552981fF44A8252FAb81)); - viewer.upgradeTo(address(impl)); - vm.stopBroadcast(); - - } -} diff --git a/script/deploys/DeployEtherFiWithdrawalBuffer.s.sol b/script/deploys/DeployEtherFiWithdrawalBuffer.s.sol deleted file mode 100644 index ebc4050cf..000000000 --- a/script/deploys/DeployEtherFiWithdrawalBuffer.s.sol +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; - -import "@openzeppelin/contracts/utils/Strings.sol"; - -import "../../src/Liquifier.sol"; -import "../../src/EtherFiRestaker.sol"; -import "../../src/helpers/AddressProvider.sol"; -import "../../src/UUPSProxy.sol"; -import "../../src/EtherFiRedemptionManager.sol"; - - -contract Deploy is Script { - using Strings for string; - AddressProvider public addressProvider; - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - address addressProviderAddress = vm.envAddress("CONTRACT_REGISTRY"); - addressProvider = AddressProvider(addressProviderAddress); - - vm.startBroadcast(deployerPrivateKey); - - EtherFiRedemptionManager impl = new EtherFiRedemptionManager( - addressProvider.getContractAddress("LiquidityPool"), - addressProvider.getContractAddress("EETH"), - addressProvider.getContractAddress("WeETH"), - 0x0c83EAe1FE72c390A02E426572854931EefF93BA, // protocol safe - 0x1d3Af47C1607A2EF33033693A9989D1d1013BB50 // role registry - ); - UUPSProxy proxy = new UUPSProxy(payable(impl), ""); - - EtherFiRedemptionManager instance = EtherFiRedemptionManager(payable(proxy)); - instance.initialize(10_00, 1_00, 1_00, 5 ether, 0.001 ether); - - vm.stopBroadcast(); - } -} diff --git a/script/deploys/DeployImplementationContract.s.sol b/script/deploys/DeployImplementationContract.s.sol deleted file mode 100644 index d1698a17e..000000000 --- a/script/deploys/DeployImplementationContract.s.sol +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.24; - -import "forge-std/Script.sol"; -// import "../../src/eBtcRateProvider.sol"; -// import "../../src/helpers/EtherFiViewer.sol"; -import "../../src/EtherFiNodesManager.sol"; -import "../../src/EtherFiNode.sol"; -import "../../src/EtherFiAdmin.sol"; -import "../../src/EtherFiOracle.sol"; -import "../../src/LiquidityPool.sol"; -import "../../src/Liquifier.sol"; - -import "../Create2Factory.sol"; - - -contract Deploy is Script { - bytes32 immutable salt = keccak256("ETHER_FI"); - Create2Factory immutable factory = Create2Factory(0x6521991A0BC180a5df7F42b27F4eE8f3B192BA62); - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.selectFork(vm.createFork(vm.envString("MAINNET_RPC_URL"))); - - vm.startBroadcast(deployerPrivateKey); - bytes memory code = abi.encodePacked(type(Liquifier).creationCode); - factory.deploy(code, salt); - } -} \ No newline at end of file diff --git a/script/deploys/DeployLiquifier.s.sol b/script/deploys/DeployLiquifier.s.sol deleted file mode 100644 index 23f6012df..000000000 --- a/script/deploys/DeployLiquifier.s.sol +++ /dev/null @@ -1,97 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; - -import "../../src/Liquifier.sol"; -import "../../src/helpers/AddressProvider.sol"; -import "../../src/UUPSProxy.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; - -contract DeployLiquifierScript is Script { - using Strings for string; - - UUPSProxy public liquifierProxy; - - Liquifier public liquifierImplementation; - Liquifier public liquifierInstance; - - AddressProvider public addressProvider; - - address cbEth_Eth_Pool; - address wbEth_Eth_Pool; - address stEth_Eth_Pool; - address cbEth; - address wbEth; - address stEth; - address cbEthStrategy; - address wbEthStrategy; - address stEthStrategy; - address eigenLayerStrategyManager; - address lidoWithdrawalQueue; - uint32 depositCapRefreshInterval; - - address admin; - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - address addressProviderAddress = vm.envAddress("CONTRACT_REGISTRY"); - addressProvider = AddressProvider(addressProviderAddress); - - vm.startBroadcast(deployerPrivateKey); - - liquifierImplementation = new Liquifier(); - liquifierProxy = new UUPSProxy(payable(liquifierImplementation), ""); - liquifierInstance = Liquifier(payable(liquifierProxy)); - if(block.chainid == 1) { - cbEth_Eth_Pool = 0x5FAE7E604FC3e24fd43A72867ceBaC94c65b404A; - wbEth_Eth_Pool = 0xBfAb6FA95E0091ed66058ad493189D2cB29385E6; - stEth_Eth_Pool = 0xDC24316b9AE028F1497c275EB9192a3Ea0f67022; - cbEth = 0xBe9895146f7AF43049ca1c1AE358B0541Ea49704; - wbEth = 0xa2E3356610840701BDf5611a53974510Ae27E2e1; - stEth = 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84; - cbEthStrategy = 0x54945180dB7943c0ed0FEE7EdaB2Bd24620256bc; - wbEthStrategy = 0x7CA911E83dabf90C90dD3De5411a10F1A6112184; - stEthStrategy = 0x93c4b944D05dfe6df7645A86cd2206016c51564D; - eigenLayerStrategyManager = 0x858646372CC42E1A627fcE94aa7A7033e7CF075A; - lidoWithdrawalQueue = 0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1; - - depositCapRefreshInterval = 3600; // 3600 seconds = 1 hour - - admin = 0x2aCA71020De61bb532008049e1Bd41E451aE8AdC; - } else if(block.chainid == 5) { - // liquifierInstance.initialize(); - } - - - // function initialize(address _treasury, address _liquidityPool, address _eigenLayerStrategyManager, address _lidoWithdrawalQueue, - // address _stEth, address _cbEth, address _wbEth, address _cbEth_Eth_Pool, address _wbEth_Eth_Pool, address _stEth_Eth_Pool, - // uint32 _depositCapRefreshInterval) - // liquifierInstance.initialize( - // addressProvider.getContractAddress("Treasury"), - // addressProvider.getContractAddress("LiquidityPool"), - // eigenLayerStrategyManager, - // lidoWithdrawalQueue, - // stEth, - // cbEth, - // wbEth, - // cbEth_Eth_Pool, - // wbEth_Eth_Pool, - // stEth_Eth_Pool, - // depositCapRefreshInterval // deposit cap refresh interval in seconds - // ); - - liquifierInstance.updateAdmin(admin, true); - - address oracleWallet = 0x12582A27E5e19492b4FcD194a60F8f5e1aa31B0F; - liquifierInstance.updateAdmin(oracleWallet, true); - - liquifierInstance.registerToken(stEth, stEthStrategy, true, 0, 1, 10, false); // 1 ether timebound cap, 10 ether max cap - liquifierInstance.registerToken(cbEth, cbEthStrategy, true, 0, 1, 10, false); - liquifierInstance.registerToken(wbEth, wbEthStrategy, true, 0, 1, 10, false); - - addressProvider.addContract(address(liquifierInstance), "Liquifier"); - - vm.stopBroadcast(); - } -} diff --git a/script/deploys/DeployLoyaltyPointsMarketSafe.sol b/script/deploys/DeployLoyaltyPointsMarketSafe.sol deleted file mode 100644 index 6441a6ab3..000000000 --- a/script/deploys/DeployLoyaltyPointsMarketSafe.sol +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; -import "../../src/UUPSProxy.sol"; -import "../../src/LoyaltyPointsMarketSafe.sol"; -import "../../src/helpers/AddressProvider.sol"; - -contract DeployLoyaltyPointsMarketSafeScript is Script { - - LoyaltyPointsMarketSafe public lpaMarketSafe; - AddressProvider public addressProvider; - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - - address addressProviderAddress = vm.envAddress("CONTRACT_REGISTRY"); - - addressProvider = AddressProvider(addressProviderAddress); - - vm.startBroadcast(deployerPrivateKey); - - lpaMarketSafe = new LoyaltyPointsMarketSafe(1500000000000); - - addressProvider.addContract(address(lpaMarketSafe), "LoyaltyPointsMarketSafeV2"); - - vm.stopBroadcast(); - } -} diff --git a/script/deploys/DeployMultiCall.s.sol b/script/deploys/DeployMultiCall.s.sol deleted file mode 100644 index a3d0499ef..000000000 --- a/script/deploys/DeployMultiCall.s.sol +++ /dev/null @@ -1,62 +0,0 @@ -/** - *Submitted for verification at Etherscan.io on 2019-06-10 -*/ -import "forge-std/Script.sol"; - -pragma solidity >=0.5.0; -pragma experimental ABIEncoderV2; - -/// @title Multicall - Aggregate results from multiple read-only function calls -/// @author Michael Elliot -/// @author Joshua Levine -/// @author Nick Johnson - -contract Multicall { - struct Call { - address target; - bytes callData; - } - function aggregate(Call[] memory calls) public returns (uint256 blockNumber, bytes[] memory returnData) { - blockNumber = block.number; - returnData = new bytes[](calls.length); - for(uint256 i = 0; i < calls.length; i++) { - (bool success, bytes memory ret) = calls[i].target.call(calls[i].callData); - require(success); - returnData[i] = ret; - } - } - // Helper functions - function getEthBalance(address addr) public view returns (uint256 balance) { - balance = addr.balance; - } - function getBlockHash(uint256 blockNumber) public view returns (bytes32 blockHash) { - blockHash = blockhash(blockNumber); - } - function getLastBlockHash() public view returns (bytes32 blockHash) { - blockHash = blockhash(block.number - 1); - } - function getCurrentBlockTimestamp() public view returns (uint256 timestamp) { - timestamp = block.timestamp; - } - function getCurrentBlockDifficulty() public view returns (uint256 difficulty) { - difficulty = block.difficulty; - } - function getCurrentBlockGasLimit() public view returns (uint256 gaslimit) { - gaslimit = block.gaslimit; - } - function getCurrentBlockCoinbase() public view returns (address coinbase) { - coinbase = block.coinbase; - } -} - -contract DeployMultiCall is Script { - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - - Multicall multicall = new Multicall(); - - vm.stopBroadcast(); - } -} \ No newline at end of file diff --git a/script/deploys/DeployPhaseOne.s.sol b/script/deploys/DeployPhaseOne.s.sol deleted file mode 100644 index 8730c91df..000000000 --- a/script/deploys/DeployPhaseOne.s.sol +++ /dev/null @@ -1,246 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; -import "../../src/Treasury.sol"; -import "../../src/NodeOperatorManager.sol"; -import "../../src/EtherFiNodesManager.sol"; -import "../../src/EtherFiNode.sol"; -import "../../src/BNFT.sol"; -import "../../src/TNFT.sol"; -import "../../src/archive/ProtocolRevenueManager.sol"; -import "../../src/StakingManager.sol"; -import "../../src/AuctionManager.sol"; -import "../../src/UUPSProxy.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; - -contract DeployPhaseOne is Script { - using Strings for string; - - /*---- Storage variables ----*/ - - UUPSProxy public auctionManagerProxy; - UUPSProxy public stakingManagerProxy; - UUPSProxy public etherFiNodeManagerProxy; - UUPSProxy public protocolRevenueManagerProxy; - UUPSProxy public TNFTProxy; - UUPSProxy public BNFTProxy; - - BNFT public BNFTImplementation; - BNFT public BNFTInstance; - - TNFT public TNFTImplementation; - TNFT public TNFTInstance; - - AuctionManager public auctionManagerImplementation; - AuctionManager public auctionManager; - - StakingManager public stakingManagerImplementation; - StakingManager public stakingManager; - - ProtocolRevenueManager public protocolRevenueManagerImplementation; - ProtocolRevenueManager public protocolRevenueManager; - - EtherFiNodesManager public etherFiNodesManagerImplementation; - EtherFiNodesManager public etherFiNodesManager; - - struct suiteAddresses { - address treasury; - address nodeOperatorManager; - address auctionManager; - address stakingManager; - address TNFT; - address BNFT; - address etherFiNodesManager; - address protocolRevenueManager; - address etherFiNode; - } - - suiteAddresses suiteAddressesStruct; - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - address ethDepositContractAddress; - if (block.chainid == 5) { - // goerli - ethDepositContractAddress = 0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b; - } else if (block.chainid == 1) { - ethDepositContractAddress = 0x00000000219ab540356cBB839Cbe05303d7705Fa; - } else { - assert(false); - } - - vm.startBroadcast(deployerPrivateKey); - - // Deploy contracts - Treasury treasury = new Treasury(); - NodeOperatorManager nodeOperatorManager = new NodeOperatorManager(); - - auctionManagerImplementation = new AuctionManager(); - auctionManagerProxy = new UUPSProxy(address(auctionManagerImplementation),""); - auctionManager = AuctionManager(address(auctionManagerProxy)); - auctionManager.initialize(address(nodeOperatorManager)); - - stakingManagerImplementation = new StakingManager(); - stakingManagerProxy = new UUPSProxy(address(stakingManagerImplementation),""); - stakingManager = StakingManager(address(stakingManagerProxy)); - stakingManager.initialize(address(auctionManager), ethDepositContractAddress); - - BNFTImplementation = new BNFT(); - BNFTProxy = new UUPSProxy(address(BNFTImplementation),""); - BNFTInstance = BNFT(address(BNFTProxy)); - BNFTInstance.initialize(address(stakingManager)); - - TNFTImplementation = new TNFT(); - TNFTProxy = new UUPSProxy(address(TNFTImplementation),""); - TNFTInstance = TNFT(address(TNFTProxy)); - TNFTInstance.initialize(address(stakingManager)); - - protocolRevenueManagerImplementation = new ProtocolRevenueManager(); - protocolRevenueManagerProxy = new UUPSProxy(address(protocolRevenueManagerImplementation),""); - protocolRevenueManager = ProtocolRevenueManager(payable(address(protocolRevenueManagerProxy))); - protocolRevenueManager.initialize(); - - etherFiNodesManagerImplementation = new EtherFiNodesManager(); - etherFiNodeManagerProxy = new UUPSProxy(address(etherFiNodesManagerImplementation),""); - etherFiNodesManager = EtherFiNodesManager(payable(address(etherFiNodeManagerProxy))); - etherFiNodesManager.initialize( - address(treasury), - address(auctionManager), - address(stakingManager), - address(TNFTInstance), - address(BNFTInstance), - address(0), // TODO - address(0), - address(0) - ); - - EtherFiNode etherFiNode = new EtherFiNode(); - - // Setup dependencies - nodeOperatorManager.setAuctionContractAddress(address(auctionManager)); - - auctionManager.setStakingManagerContractAddress(address(stakingManager)); - - protocolRevenueManager.setAuctionManagerAddress(address(auctionManager)); - protocolRevenueManager.setEtherFiNodesManagerAddress(address(etherFiNodesManager)); - - stakingManager.setEtherFiNodesManagerAddress(address(etherFiNodesManager)); - stakingManager.registerEtherFiNodeImplementationContract(address(etherFiNode)); - stakingManager.registerTNFTContract(address(TNFTInstance)); - stakingManager.registerBNFTContract(address(BNFTInstance)); - - vm.stopBroadcast(); - - suiteAddressesStruct = suiteAddresses({ - treasury: address(treasury), - nodeOperatorManager: address(nodeOperatorManager), - auctionManager: address(auctionManager), - stakingManager: address(stakingManager), - TNFT: address(TNFTInstance), - BNFT: address(BNFTInstance), - etherFiNodesManager: address(etherFiNodesManager), - protocolRevenueManager: address(protocolRevenueManager), - etherFiNode: address(etherFiNode) - }); - - writeSuiteVersionFile(); - writeNFTVersionFile(); - } - - function _stringToUint( - string memory numString - ) internal pure returns (uint256) { - uint256 val = 0; - bytes memory stringBytes = bytes(numString); - for (uint256 i = 0; i < stringBytes.length; i++) { - uint256 exp = stringBytes.length - i; - bytes1 ival = stringBytes[i]; - uint8 uval = uint8(ival); - uint256 jval = uval - uint256(0x30); - - val += (uint256(jval) * (10 ** (exp - 1))); - } - return val; - } - - function writeSuiteVersionFile() internal { - // Read Current version - string memory versionString = vm.readLine("release/logs/PhaseOne/version.txt"); - - // Cast string to uint256 - uint256 version = _stringToUint(versionString); - - version++; - - // Overwrites the version.txt file with incremented version - vm.writeFile( - "release/logs/PhaseOne/version.txt", - string(abi.encodePacked(Strings.toString(version))) - ); - - // Writes the data to .release file - vm.writeFile( - string( - abi.encodePacked( - "release/logs/PhaseOne/", - Strings.toString(version), - ".release" - ) - ), - string( - abi.encodePacked( - Strings.toString(version), - "\nTreasury: ", - Strings.toHexString(suiteAddressesStruct.treasury), - "\nNode Operator Key Manager: ", - Strings.toHexString(suiteAddressesStruct.nodeOperatorManager), - "\nAuctionManager: ", - Strings.toHexString(suiteAddressesStruct.auctionManager), - "\nStakingManager: ", - Strings.toHexString(suiteAddressesStruct.stakingManager), - "\nEtherFi Node Manager: ", - Strings.toHexString(suiteAddressesStruct.etherFiNodesManager), - "\nProtocol Revenue Manager: ", - Strings.toHexString(suiteAddressesStruct.protocolRevenueManager) - ) - ) - ); - } - - function writeNFTVersionFile() internal { - // Read Current version - string memory versionString = vm.readLine("release/logs/PhaseOneNFTs/version.txt"); - - // Cast string to uint256 - uint256 version = _stringToUint(versionString); - - version++; - - // Overwrites the version.txt file with incremented version - vm.writeFile( - "release/logs/PhaseOneNFTs/version.txt", - string(abi.encodePacked(Strings.toString(version))) - ); - - // Writes the data to .release file - vm.writeFile( - string( - abi.encodePacked( - "release/logs/PhaseOneNFTs/", - Strings.toString(version), - ".release" - ) - ), - string( - abi.encodePacked( - Strings.toString(version), - "\nTNFT: ", - Strings.toHexString(suiteAddressesStruct.TNFT), - "\nBNFT: ", - Strings.toHexString(suiteAddressesStruct.BNFT) - ) - ) - ); - } -} diff --git a/script/deploys/DeployPhaseOnePointFive.s.sol b/script/deploys/DeployPhaseOnePointFive.s.sol deleted file mode 100644 index db69f9fe9..000000000 --- a/script/deploys/DeployPhaseOnePointFive.s.sol +++ /dev/null @@ -1,149 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; -import "../../src/MembershipManager.sol"; -import "../../src/MembershipNFT.sol"; -import "../../src/WeETH.sol"; -import "../../src/EETH.sol"; -import "../../src/NFTExchange.sol"; -import "../../src/LiquidityPool.sol"; -import "../../src/helpers/AddressProvider.sol"; -import "../../src/archive/RegulationsManager.sol"; -import "../../src/UUPSProxy.sol"; - -contract DeployPhaseOnePointFiveScript is Script { - - /*---- Storage variables ----*/ - - UUPSProxy public membershipManagerProxy; - UUPSProxy public membershipNFTProxy; - UUPSProxy public eETHProxy; - UUPSProxy public weETHProxy; - UUPSProxy public liquidityPoolProxy; - UUPSProxy public regulationsManagerProxy; - UUPSProxy public nftExchangeProxy; - - MembershipManager public membershipManagerImplementation; - MembershipManager public membershipManager; - - MembershipNFT public membershipNFTImplementation; - MembershipNFT public membershipNFT; - - WeETH public weETHImplementation; - WeETH public weETH; - - EETH public eETHImplementation; - EETH public eETH; - - LiquidityPool public liquidityPoolImplementation; - LiquidityPool public liquidityPool; - - RegulationsManager public regulationsManagerImplementation; - RegulationsManager public regulationsManager; - - NFTExchange public nftExchangeImplementation; - NFTExchange public nftExchange; - - AddressProvider public addressProvider; - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - - bytes32[] memory emptyProof; - - address addressProviderAddress = vm.envAddress("CONTRACT_REGISTRY"); - addressProvider = AddressProvider(addressProviderAddress); - - address stakingManagerProxyAddress = addressProvider.getContractAddress("StakingManager"); - address etherFiNodesManagerProxyAddress = addressProvider.getContractAddress("EtherFiNodesManager"); - address treasury = addressProvider.getImplementationAddress("Treasury"); - address protocolRevenueManagerProxy = addressProvider.getContractAddress("ProtocolRevenueManager"); - address tnft = addressProvider.getContractAddress("TNFT"); - address admin = vm.envAddress("DEPLOYER"); - - bytes32 initialHash = vm.envBytes32("INITIAL_HASH"); - - string memory baseURI = vm.envString("BASE_URI"); - - // Deploy contracts - regulationsManagerImplementation = new RegulationsManager(); - regulationsManagerProxy = new UUPSProxy(address(regulationsManagerImplementation),""); - regulationsManager = RegulationsManager(address(regulationsManagerProxy)); - regulationsManager.initialize(); - addressProvider.addContract(address(regulationsManagerProxy), "RegulationsManager"); - - liquidityPoolImplementation = new LiquidityPool(); - liquidityPoolProxy = new UUPSProxy(address(liquidityPoolImplementation),""); - liquidityPool = LiquidityPool(payable(address(liquidityPoolProxy))); - addressProvider.addContract(address(liquidityPoolProxy), "LiquidityPool"); - - eETHImplementation = new EETH(); - eETHProxy = new UUPSProxy(address(eETHImplementation),""); - eETH = EETH(address(eETHProxy)); - eETH.initialize(address(liquidityPool)); - addressProvider.addContract(address(eETHProxy), "EETH"); - - membershipNFTImplementation = new MembershipNFT(); - membershipNFTProxy = new UUPSProxy(address(membershipNFTImplementation),""); - membershipNFT = MembershipNFT(payable(address(membershipNFTProxy))); - addressProvider.addContract(address(membershipNFTProxy), "MembershipNFT"); - - membershipManagerImplementation = new MembershipManager(); - membershipManagerProxy = new UUPSProxy(address(membershipManagerImplementation),""); - membershipManager = MembershipManager(payable(address(membershipManagerProxy))); - addressProvider.addContract(address(membershipManagerProxy), "MembershipManager"); - - liquidityPool.initialize(address(eETH), address(stakingManagerProxyAddress), address(etherFiNodesManagerProxyAddress), address(membershipManager), address(tnft), address(0), address(0)); - // membershipManager.initialize(address(eETH), address(liquidityPool), address(membershipNFT), treasury, protocolRevenueManagerProxy); - membershipNFT.initialize(baseURI, address(membershipManager)); - - weETHImplementation = new WeETH(); - weETHProxy = new UUPSProxy(address(weETHImplementation),""); - weETH = WeETH(address(weETHProxy)); - weETH.initialize(address(liquidityPool), address(eETH)); - addressProvider.addContract(address(weETHProxy), "WeETH"); - - nftExchangeImplementation = new NFTExchange(); - nftExchangeProxy = new UUPSProxy(address(nftExchangeImplementation),""); - nftExchange = NFTExchange(address(nftExchangeProxy)); - nftExchange.initialize(tnft, address(membershipNFT), address(etherFiNodesManagerProxyAddress)); - addressProvider.addContract(address(nftExchangeProxy), "NFTExchange"); - - setUpAdmins(admin); - - regulationsManager.initializeNewWhitelist(initialHash); - regulationsManager.confirmEligibility(initialHash); - membershipManager.setTopUpCooltimePeriod(28 days); - - initializeTiers(); - preMint(); - membershipManager.setFeeAmounts(0.05 ether, 0.05 ether, 0, 0); - membershipManager.pauseContract(); - - vm.stopBroadcast(); - } - - function setUpAdmins(address _admin) internal { - // liquidityPool.updateAdmin(_admin, true); - regulationsManager.updateAdmin(_admin, true); - membershipManager.updateAdmin(_admin, true); - membershipNFT.updateAdmin(_admin, true); - nftExchange.updateAdmin(_admin); - } - - function initializeTiers() internal { - membershipManager.addNewTier(0, 1); - membershipManager.addNewTier(672, 2); - membershipManager.addNewTier(2016, 3); - membershipManager.addNewTier(4704, 4); - } - - function preMint() internal { - bytes32[] memory emptyProof; - uint256 minAmount = membershipManager.minimumAmountForMint(); - // MembershipManager V1 does not have `wrapEthBatch` - // membershipManager.wrapEthBatch{value: 100 * minAmount}(100, minAmount, 0, emptyProof); - } -} diff --git a/script/deploys/DeployPhaseTwo.s.sol b/script/deploys/DeployPhaseTwo.s.sol deleted file mode 100644 index 3ea414e85..000000000 --- a/script/deploys/DeployPhaseTwo.s.sol +++ /dev/null @@ -1,175 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; -import "../../src/UUPSProxy.sol"; -import "../../src/EtherFiOracle.sol"; -import "../../src/EtherFiAdmin.sol"; -import "../../src/WithdrawRequestNFT.sol"; -import "../../src/helpers/AddressProvider.sol"; - -import "../../src/interfaces/IAuctionManager.sol"; -import "../../src/interfaces/IStakingManager.sol"; -import "../../src/interfaces/ILiquidityPool.sol"; -import "../../src/interfaces/IMembershipManager.sol"; -import "../../src/interfaces/IMembershipNFT.sol"; -import "../../src/interfaces/IEtherFiNodesManager.sol"; -import "../../src/interfaces/IEtherFiOracle.sol"; -import "../../src/interfaces/IWithdrawRequestNFT.sol"; - -import "../../src/UUPSProxy.sol"; - -contract DeployPhaseTwoScript is Script { - UUPSProxy public etherFiOracleProxy; - EtherFiOracle public etherFiOracleInstance; - EtherFiOracle public etherFiOracleImplementation; - - UUPSProxy public etherFiAdminProxy; - EtherFiAdmin public etherFiAdminInstance; - EtherFiAdmin public etherFiAdminImplementation; - - UUPSProxy public withdrawRequestNftProxy; - WithdrawRequestNFT public withdrawRequestNftInstance; - WithdrawRequestNFT public withdrawRequestNftImplementation; - - AddressProvider public addressProvider; - - address addressProviderAddress; - address etherFiOracleAddress; - address stakingManagerAddress; - address auctionAddress; - address managerAddress; - address liquidityPoolAddress; - address eEthAddress; - address membershipManagerAddress; - address withdrawRequestNFTAddress; - - address oracleAdminAddress; - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - addressProviderAddress = vm.envAddress("CONTRACT_REGISTRY"); - oracleAdminAddress = vm.envAddress("ORACLE_ADMIN_ADDRESS"); - addressProvider = AddressProvider(addressProviderAddress); - - vm.startBroadcast(deployerPrivateKey); - - deploy_WithdrawRequestNFT(); - - deploy_EtherFiOracle(); - - deploy_EtherFiAdmin(); - - vm.stopBroadcast(); - } - - function retrieve_contract_addresses() internal { - // Retrieve the addresses of the contracts that have already deployed - etherFiOracleAddress = addressProvider.getContractAddress("EtherFiOracle"); - stakingManagerAddress = addressProvider.getContractAddress("StakingManager"); - auctionAddress = addressProvider.getContractAddress("AuctionManager"); - managerAddress = addressProvider.getContractAddress("EtherFiNodesManager"); - liquidityPoolAddress = addressProvider.getContractAddress("LiquidityPool"); - eEthAddress = addressProvider.getContractAddress("EETH"); - membershipManagerAddress = addressProvider.getContractAddress("MembershipManager"); - withdrawRequestNFTAddress = addressProvider.getContractAddress("WithdrawRequestNFT"); - } - - function deploy_WithdrawRequestNFT() internal { - if (addressProvider.getContractAddress("WithdrawRequestNFT") != address(0)) { - addressProvider.removeContract("WithdrawRequestNFT"); - } - retrieve_contract_addresses(); - - withdrawRequestNftImplementation = new WithdrawRequestNFT(address(0)); - withdrawRequestNftProxy = new UUPSProxy(address(withdrawRequestNftImplementation), ""); - withdrawRequestNftInstance = WithdrawRequestNFT(payable(withdrawRequestNftProxy)); - - withdrawRequestNftInstance.initialize(liquidityPoolAddress, eEthAddress, membershipManagerAddress); - - addressProvider.addContract(address(withdrawRequestNftProxy), "WithdrawRequestNFT"); - } - - function deploy_EtherFiOracle() internal { - if (addressProvider.getContractAddress("EtherFiOracle") != address(0)) { - addressProvider.removeContract("EtherFiOracle"); - } - retrieve_contract_addresses(); - - etherFiOracleImplementation = new EtherFiOracle(); - etherFiOracleProxy = new UUPSProxy(address(etherFiOracleImplementation), ""); - etherFiOracleInstance = EtherFiOracle(payable(etherFiOracleProxy)); - - if (block.chainid == 1) { - // Mainnet's slot 0 happened at 1606824023; https://beaconcha.in/slot/0 - etherFiOracleInstance.initialize(1, 7200, 0, 32, 12, 1606824023); - - // TODO - // address oracleNodeAddress = 0xD0d7F8a5a86d8271ff87ff24145Cf40CEa9F7A39 - // etherFiOracleInstance.addCommitteeMember(oracleNodeAddress); - - } else if (block.chainid == 5) { - // Goerli's slot 0 happened at 1616508000; https://goerli.beaconcha.in/slot/0 - etherFiOracleInstance.initialize(1, 96, 0, 32, 12, 1616508000); - // 96 slots = 19.2 mins, 7200 slots = 225 epochs = 1day - - etherFiOracleInstance.addCommitteeMember(address(0xD0d7F8a5a86d8271ff87ff24145Cf40CEa9F7A39)); - etherFiOracleInstance.addCommitteeMember(address(0x601B37004f2A6B535a6cfBace0f88D2d534aCcD8)); - } else { - require(false, "chain is wrong"); - } - - addressProvider.addContract(address(etherFiOracleProxy), "EtherFiOracle"); - } - - function deploy_EtherFiAdmin() internal { - if (addressProvider.getContractAddress("EtherFiAdmin") != address(0)) { - addressProvider.removeContract("EtherFiAdmin"); - } - retrieve_contract_addresses(); - - etherFiAdminImplementation = new EtherFiAdmin(); - etherFiAdminProxy = new UUPSProxy(address(etherFiAdminImplementation), ""); - etherFiAdminInstance = EtherFiAdmin(payable(etherFiAdminProxy)); - - int32 acceptableRebaseAprInBps; - uint16 postReportWaitTimeInSlots; - - if (block.chainid == 1) { - acceptableRebaseAprInBps = 500; // 5% - postReportWaitTimeInSlots = 7200 / 2; // 7200 slots = 225 epochs = 1 day - } else if (block.chainid == 5) { - acceptableRebaseAprInBps = 600; // 6% - postReportWaitTimeInSlots = 15 minutes / 12 seconds; // 15 minutes - } else { - require(false, "chain is wrong"); - } - - etherFiAdminInstance.initialize( - etherFiOracleAddress, - stakingManagerAddress, - auctionAddress, - managerAddress, - liquidityPoolAddress, - membershipManagerAddress, - withdrawRequestNFTAddress, - acceptableRebaseAprInBps, - postReportWaitTimeInSlots - ); - // etherFiAdminInstance.updateAdmin(oracleAdminAddress, true); - IEtherFiOracle(address(etherFiOracleAddress)).setEtherFiAdmin(address(etherFiAdminInstance)); - //IWithdrawRequestNFT(address(withdrawRequestNFTAddress)).updateAdmin(address(etherFiAdminInstance), true); - - // Used only for development - if (false) { - address admin = address(etherFiAdminInstance); - IAuctionManager(address(auctionAddress)).updateAdmin(admin, true); - IStakingManager(address(stakingManagerAddress)).updateAdmin(admin, true); - // ILiquidityPool(address(liquidityPoolAddress)).updateAdmin(admin, true); - IMembershipManager(address(membershipManagerAddress)).updateAdmin(admin, true); - IEtherFiNodesManager(address(managerAddress)).updateAdmin(admin, true); - } - - addressProvider.addContract(address(etherFiAdminProxy), "EtherFiAdmin"); - } -} \ No newline at end of file diff --git a/script/deploys/DeployRoleRegistry.s.sol b/script/deploys/DeployRoleRegistry.s.sol deleted file mode 100644 index 20acf96ae..000000000 --- a/script/deploys/DeployRoleRegistry.s.sol +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.24; - -import "forge-std/Script.sol"; - -import "src/RoleRegistry.sol"; -import "src/UUPSProxy.sol"; -import "../../src/helpers/AddressProvider.sol"; - - -/* deploy command - * source .env && forge script ./script/deploys/DeployRoleRegistry.s.sol:DeployRoleRegistry --rpc-url MAINNET_RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --verify --slow -vvvv -*/ - -contract DeployRoleRegistry is Script { - - AddressProvider public addressProvider; - /////////////////////////////////////// - address superAdmin = address(0x8D5AAc5d3d5cda4c404fA7ee31B0822B648Bb150); //replace with actual super admin address - ////////////////////////////////////// - - function run() external { - vm.startBroadcast(); - - RoleRegistry roleRegistryImplementation = new RoleRegistry(); - bytes memory initializerData = abi.encodeWithSelector(RoleRegistry.initialize.selector, superAdmin); - UUPSProxy roleRegistryProxy = new UUPSProxy(address(roleRegistryImplementation), initializerData); - - vm.stopBroadcast(); - } -} diff --git a/script/deploys/DeployTVLOracle.s.sol b/script/deploys/DeployTVLOracle.s.sol deleted file mode 100644 index ad6a0ebac..000000000 --- a/script/deploys/DeployTVLOracle.s.sol +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; -import "../../src/UUPSProxy.sol"; -import "../../src/TVLOracle.sol"; -import "../../src/helpers/AddressProvider.sol"; - -contract DeployTVLOracleScript is Script { - - /*---- Storage variables ----*/ - - TVLOracle public tvlOracle; - AddressProvider public addressProvider; - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - - address addressProviderAddress = vm.envAddress("CONTRACT_REGISTRY"); - address tvlAggregatorAddress = vm.envAddress("TVL_AGGREGATOR_ADDRESS"); - - addressProvider = AddressProvider(addressProviderAddress); - - vm.startBroadcast(deployerPrivateKey); - - // Deploy contract - tvlOracle = new TVLOracle(tvlAggregatorAddress); - addressProvider.addContract(address(tvlOracle), "TVLOracle"); - - vm.stopBroadcast(); - } -} diff --git a/script/deploys/DeployV2Dot49.s.sol b/script/deploys/DeployV2Dot49.s.sol deleted file mode 100644 index 3f939c867..000000000 --- a/script/deploys/DeployV2Dot49.s.sol +++ /dev/null @@ -1,289 +0,0 @@ - -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; -import "../../src/LiquidityPool.sol"; -import "../../src/EtherFiAdmin.sol"; -import "../../src/WeETH.sol"; -import "../../src/UUPSProxy.sol"; -import "../../src/EtherFiTimelock.sol"; -import "../../src/helpers/AddressProvider.sol"; -import "../../src/EtherFiRewardsRouter.sol"; -import "../../src/EtherFiRedemptionManager.sol"; -import "../../src/EtherFiNodesManager.sol"; -import "../../src/WithdrawRequestNFT.sol"; -import "forge-std/console.sol"; -import "forge-std/console2.sol"; - -import "../../src/EETH.sol"; - -contract DeployV2Dot49Script is Script { - - LiquidityPool liquidityPoolImplementation; - RoleRegistry roleRegistryImplementation; - EtherFiAdmin etherFiAdminImplementation; - EtherFiRewardsRouter etherFiRewardsRouterImplementation; - WeETH weEthImplementation; - EtherFiNodesManager managerImplementation; - WithdrawRequestNFT withdrawRequestNFTImplementation; - EtherFiRedemptionManager etherFiRedemptionManagerImplementation; - EtherFiTimelock operatingTimelockImplementation; - - LiquidityPool public liquidityPoolInstance; - RoleRegistry public roleRegistryInstance; - EtherFiAdmin public etherFiAdminInstance; - EtherFiRewardsRouter public etherFiRewardsRouterInstance; - WeETH public weETHInstance; - EtherFiNodesManager public managerInstance; - WithdrawRequestNFT public withdrawRequestNFTInstance; - EtherFiRedemptionManager public etherFiRedemptionManagerInstance; - EtherFiTimelock public operatingTimelockInstance; - EtherFiTimelock public oldOperatingTimelockInstance; - EtherFiTimelock public timelockInstance; - EETH public eETHInstance; - - bool public isProd = true; - - AddressProvider public addressProvider; - EtherFiTimelock public etherFiTimelock; - address public deployerKey = address(0x123); //get correct deployer key - address public treasuryGnosisSafeAddress = address(0x0c83EAe1FE72c390A02E426572854931EefF93BA); - - address public treasuryAddress = address(0x0c83EAe1FE72c390A02E426572854931EefF93BA); - - address public etherfiMultisig = address(0x2aCA71020De61bb532008049e1Bd41E451aE8AdC); - address public etherfiOracleAdmin = address(0x12582A27E5e19492b4FcD194a60F8f5e1aa31B0F); - address public liquidityPoolAdmin = address(0xFa238cB37E58556b23ea45643FFe4Da382162a53); - address public hypernativeEoa = address(0x9AF1298993DC1f397973C62A5D47a284CF76844D); - address public timelockAddress = address(0x9f26d4C958fD811A1F59B01B86Be7dFFc9d20761); - address public oldTreasury = address(0x6329004E903B7F420245E7aF3f355186f2432466); - address public etherOracleMember1 = address(0xDd777e5158Cb11DB71B4AF93C75A96eA11A2A615); - address public etherOracleMember2 = address(0x2c7cB7d5dC4aF9caEE654553a144C76F10D4b320); - - function init() internal { - addressProvider = AddressProvider(vm.envAddress("CONTRACT_REGISTRY")); - roleRegistryInstance = RoleRegistry(address(0x62247D29B4B9BECf4BB73E0c722cf6445cfC7cE9)); - operatingTimelockInstance = EtherFiTimelock(payable(address(0xcD425f44758a08BaAB3C4908f3e3dE5776e45d7a))); - timelockInstance = EtherFiTimelock(payable(address(0x9f26d4C958fD811A1F59B01B86Be7dFFc9d20761))); - - etherFiAdminInstance = EtherFiAdmin(addressProvider.getContractAddress("EtherFiAdmin")); - managerInstance = EtherFiNodesManager(payable(addressProvider.getContractAddress("EtherFiNodesManager"))); - etherFiRewardsRouterInstance = EtherFiRewardsRouter(payable(address(0x73f7b1184B5cD361cC0f7654998953E2a251dd58))); - liquidityPoolInstance = LiquidityPool(payable(addressProvider.getContractAddress("LiquidityPool"))); - weETHInstance = WeETH(addressProvider.getContractAddress("WeETH")); - withdrawRequestNFTInstance = WithdrawRequestNFT(addressProvider.getContractAddress("WithdrawRequestNFT")); - etherFiRedemptionManagerInstance = EtherFiRedemptionManager(payable(address(0xDadEf1fFBFeaAB4f68A9fD181395F68b4e4E7Ae0))); - eETHInstance = EETH(addressProvider.getContractAddress("EETH")); - - - //print all addresses of contracts in same order - console2.log('AddressProvider: ', address(addressProvider)); - console2.log('RoleRegistry: ', address(roleRegistryInstance)); - console2.log('OperatingTimelock: ', address(operatingTimelockInstance)); - console2.log('Timelock: ', address(timelockInstance)); - - console2.log('EtherFiAdmin: ', address(etherFiAdminInstance)); - console2.log('EtherFiNodesManager: ', address(managerInstance)); - console2.log('EtherFiRewardsRouter: ', address(etherFiRewardsRouterInstance)); - console2.log('LiquidityPool: ', address(liquidityPoolInstance)); - console2.log('WeETH: ', address(weETHInstance)); - console2.log('WithdrawRequestNFT: ', address(withdrawRequestNFTInstance)); - console2.log('EtherFiRedemptionManager: ', address(etherFiRedemptionManagerInstance)); - console2.log('EETH: ', address(eETHInstance)); - console2.log('Treasury: ', address(treasuryAddress)); - - } - -function writeDeployedContractsToFile() internal { - // Split the JSON generation to reduce stack variables - string memory jsonPart1 = string(abi.encodePacked( - "{\n", - ' "EtherFiRedemptionManagerImplementation": "', vm.toString(address(etherFiRedemptionManagerImplementation)), '",\n', - ' "EtherFiRedemptionManagerInstance": "', vm.toString(address(etherFiRedemptionManagerInstance)), '",\n', - ' "EtherFiAdminImplementation": "', vm.toString(address(etherFiAdminImplementation)), '",\n' - //' "EtherFiNodesManagerImplementation": "', vm.toString(address(managerImplementation)), '",\n' - )); - - string memory jsonPart2 = string(abi.encodePacked( - ' "EtherFiRewardsRouterImplementation": "', vm.toString(address(etherFiRewardsRouterImplementation)), '",\n', - ' "LiquidityPoolImplementation": "', vm.toString(address(liquidityPoolImplementation)), '",\n', - ' "WeETHImplementation": "', vm.toString(address(weEthImplementation)), '",\n', - ' "WithdrawRequestNFTImplementation": "', vm.toString(address(withdrawRequestNFTImplementation)), '",\n', - "}" - )); - - string memory jsonContent = string(abi.encodePacked(jsonPart1, jsonPart2)); - vm.writeFile("deployment/deployed-contracts.json", jsonContent); -} - - /////////////////////////// DEPLOYMENT //////////////////////////// - function deployImplementationContracts() internal { - // deploy key - vm.startBroadcast(); - etherFiRedemptionManagerImplementation = new EtherFiRedemptionManager(address(liquidityPoolInstance), address(eETHInstance), address(weETHInstance), address(treasuryAddress), address(roleRegistryInstance)); - UUPSProxy etherFiRedemptionManagerProxy = new UUPSProxy(address(etherFiRedemptionManagerImplementation), ""); - etherFiRedemptionManagerInstance = EtherFiRedemptionManager(payable(etherFiRedemptionManagerProxy)); - - etherFiAdminImplementation = new EtherFiAdmin(); - //managerImplementation = new EtherFiNodesManager(); - etherFiRewardsRouterImplementation = new EtherFiRewardsRouter(address(liquidityPoolInstance), treasuryAddress, address(roleRegistryInstance)); - liquidityPoolImplementation = new LiquidityPool(); - weEthImplementation = new WeETH(); - withdrawRequestNFTImplementation = new WithdrawRequestNFT(treasuryAddress); - vm.stopBroadcast(); - } - - function deployNodesManager() internal { - vm.startBroadcast(); - managerImplementation = new EtherFiNodesManager(); - console2.log('EtherFiNodesManager: ', address(managerImplementation)); - vm.stopBroadcast(); - } - - - - //////////////////////////// ROLE REGISTRY SETUP //////////////////////////// - - function grantRoles() internal { - // tenderly address - address etherfiMultisig = address(0xD0d7F8a5a86d8271ff87ff24145Cf40CEa9F7A39); - address etherfiOracleAdmin = address(0xD0d7F8a5a86d8271ff87ff24145Cf40CEa9F7A39); - address liquidityPoolAdmin = address(0xD0d7F8a5a86d8271ff87ff24145Cf40CEa9F7A39); - address hypernativeEoa = address(0xD0d7F8a5a86d8271ff87ff24145Cf40CEa9F7A39); - if(isProd) { - // prod address - etherfiMultisig = address(0x2aCA71020De61bb532008049e1Bd41E451aE8AdC); - etherfiOracleAdmin = address(0x12582A27E5e19492b4FcD194a60F8f5e1aa31B0F); - liquidityPoolAdmin = address(0xFa238cB37E58556b23ea45643FFe4Da382162a53); - hypernativeEoa = address(0x9AF1298993DC1f397973C62A5D47a284CF76844D); - } - - vm.startBroadcast(vm.envUint("PRIVATE_KEY")); - roleRegistryInstance.grantRole(liquidityPoolInstance.LIQUIDITY_POOL_ADMIN_ROLE(), liquidityPoolAdmin); - roleRegistryInstance.grantRole(etherFiAdminInstance.ETHERFI_ORACLE_EXECUTOR_ADMIN_ROLE(), etherfiOracleAdmin); - roleRegistryInstance.grantRole(etherFiAdminInstance.ETHERFI_ORACLE_EXECUTOR_TASK_MANAGER_ROLE(), etherfiOracleAdmin); - roleRegistryInstance.grantRole(roleRegistryInstance.PROTOCOL_UNPAUSER(), etherfiMultisig); - roleRegistryInstance.grantRole(roleRegistryInstance.PROTOCOL_PAUSER(), address(etherFiAdminInstance)); - roleRegistryInstance.grantRole(roleRegistryInstance.PROTOCOL_PAUSER(), address(hypernativeEoa)); - roleRegistryInstance.grantRole(roleRegistryInstance.PROTOCOL_PAUSER(), address(etherfiMultisig)); - roleRegistryInstance.grantRole(roleRegistryInstance.PROTOCOL_UNPAUSER(), address(etherFiAdminInstance)); - roleRegistryInstance.grantRole(etherFiRewardsRouterInstance.ETHERFI_REWARDS_ROUTER_ADMIN_ROLE(), address(etherfiMultisig)); - roleRegistryInstance.transferOwnership(address(timelockInstance)); - vm.stopBroadcast(); - } - //transfer ownership and initalize role registry - function completeRoleRegistrySetup() internal { - vm.startBroadcast(address(timelockInstance)); - roleRegistryInstance.acceptOwnership(); - //liquidityPoolInstance.initializeRoleRegistry(address(roleRegistryInstance)); - etherFiAdminInstance.initializeRoleRegistry(address(roleRegistryInstance)); - vm.stopBroadcast(); - - } - - function renamingEtherAdminRoles() internal { - vm.startBroadcast(); - address etherfiMultisig = address(0x2aCA71020De61bb532008049e1Bd41E451aE8AdC); - address oracleEOA = address(0x12582A27E5e19492b4FcD194a60F8f5e1aa31B0F); - bytes32 taskManagerRole = keccak256("ETHERFI_ORACLE_EXECUTOR_TASK_MANAGER_ROLE"); - bytes32 adminRole = keccak256("ETHERFI_ORACLE_EXECUTOR_ADMIN_ROLE"); - bytes32 validatorManagerRole = keccak256("ETHERFI_ORACLE_EXECUTOR_VALIDATOR_MANAGER_ROLE"); - RoleRegistry roleRegistry = RoleRegistry(0x62247D29B4B9BECf4BB73E0c722cf6445cfC7cE9); - - roleRegistry.revokeRole(adminRole, oracleEOA); - roleRegistry.revokeRole(validatorManagerRole, oracleEOA); - - roleRegistry.grantRole(taskManagerRole, oracleEOA); - roleRegistry.grantRole(taskManagerRole, etherfiMultisig); - roleRegistry.grantRole(adminRole, etherfiMultisig); - vm.stopBroadcast(); - } - - function updateRoleRegistry() internal { - vm.startBroadcast(); - bytes32 taskManagerRole = keccak256("ETHERFI_ORACLE_EXECUTOR_TASK_MANAGER_ROLE"); - - bytes32 adminRole = keccak256("ETHERFI_ORACLE_EXECUTOR_ADMIN_ROLE"); - bytes32 liquidityPoolAdminRole = keccak256("LIQUIDITY_POOL_ADMIN_ROLE"); - bytes32 redemptionManagerAdminRole = keccak256("ETHERFI_REDEMPTION_MANAGER_ADMIN_ROLE"); - bytes32 withdrawRequestNFTAdminRole = keccak256("WITHDRAW_REQUEST_NFT_ADMIN_ROLE"); - - - roleRegistryInstance.revokeRole(liquidityPoolAdminRole, address(oldOperatingTimelockInstance)); - roleRegistryInstance.revokeRole(redemptionManagerAdminRole, address(oldOperatingTimelockInstance)); - roleRegistryInstance.revokeRole(withdrawRequestNFTAdminRole, address(oldOperatingTimelockInstance)); - roleRegistryInstance.revokeRole(adminRole, address(oldOperatingTimelockInstance)); - - roleRegistryInstance.grantRole(liquidityPoolAdminRole, address(operatingTimelockInstance)); - roleRegistryInstance.grantRole(redemptionManagerAdminRole, address(operatingTimelockInstance)); - roleRegistryInstance.grantRole(withdrawRequestNFTAdminRole, address(operatingTimelockInstance)); - roleRegistryInstance.grantRole(adminRole, address(operatingTimelockInstance)); - vm.stopBroadcast(); - } - - //////////////////////////// ADDRESS PROVIDER SETUP //////////////////////////// - - function updateAddressProvider() internal { - address etherfiMultisig = address(0x2aCA71020De61bb532008049e1Bd41E451aE8AdC); - vm.startBroadcast(address(timelockInstance)); - addressProvider.addContract(address(roleRegistryInstance), "RoleRegistry"); - addressProvider.addContract(address(etherFiRewardsRouterInstance), "EtherFiRewardsRouter"); - addressProvider.setOwner(etherfiMultisig); - vm.stopBroadcast(); - } - - //////////////////////////// CONTRACT UPGRADES //////////////////////////// - - function upgradeContracts() internal { - //behind timelock - vm.startBroadcast(address(timelockInstance)); - liquidityPoolInstance.upgradeTo(address(liquidityPoolImplementation)); - etherFiAdminInstance.upgradeTo(address(etherFiAdminImplementation)); - weETHInstance.upgradeTo(address(weEthImplementation)); - etherFiRewardsRouterInstance.upgradeTo(address(etherFiRewardsRouterImplementation)); - vm.stopBroadcast(); - } - - function initContracts() internal { - vm.startBroadcast(); - etherFiRedemptionManagerInstance.initialize(10_00, 30, 1_00, 1000 ether, 0.01157407407 ether); - vm.stopBroadcast(); - } - - //////////////////////////// OPERATING TIMELOCK SETUP //////////////////////////// - - function deployOperatingTimelock() internal { - vm.startBroadcast(); - uint256 minDelay = 60 * 60 * 8; // 8 hours - address[] memory proposers = new address[](1); - proposers[0] = address(0x2aCA71020De61bb532008049e1Bd41E451aE8AdC); - address admin = address(0); - EtherFiTimelock operatingTimelock = new EtherFiTimelock(minDelay, proposers, proposers, admin); - vm.stopBroadcast(); - } - - - function run() public { - init(); - //completeRoleRegistrySetup(); - //grantRoles(); - //renamingEtherAdminRoles(); - - - //deployOperatingTimelock(); - //uncomment after operating timelock is deployed - //oldOperatingTimelockInstance = EtherFiTimelock(payable(address(0x82215f1274356E94543a4D6baC6F7170D8A59F2A))); - //updateRoleRegistry(); - - //uncomment after deploy is done - //EtherFiRedemptionManager etherFiRedemptionManagerInstance = EtherFiRedemptionManager(address(0x9f26d4C958fD811A1F59B01B86Be7dFFc9d20761)); - //Timelock operatingTimelock = EtherFiTimelock(); - - //deployImplementationContracts(); - //writeDeployedContractsToFile(); - initContracts(); - //deployNodesManager(); - } - -} diff --git a/script/deploys/EtherFiTimelock.sol b/script/deploys/EtherFiTimelock.sol deleted file mode 100644 index 1500434a0..000000000 --- a/script/deploys/EtherFiTimelock.sol +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; -import "../../src/helpers/AddressProvider.sol"; -import "../../src/EtherFiTimelock.sol"; - -contract DeployLoyaltyPointsMarketSafeScript is Script { - - AddressProvider public addressProvider; - - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - - address addressProviderAddress = vm.envAddress("CONTRACT_REGISTRY"); - addressProvider = AddressProvider(addressProviderAddress); - - /* - // minimum wait time for a timelock tx - uint256 minWaitTime = 2 days; - - // who can propose transactions for the timelock - // TODO: Fill out the addresses we want - address[] memory proposers = new address[](2); - proposers[0] = ; - proposers[1] = admin; - - // who can execute transactions for the timelock - // TODO: Fill out the addresses we want - address[] memory executors = new address[](1); - executors[0] = owner; - - vm.startBroadcast(deployerPrivateKey); - - // Last param is left blank as recommended by OZ documentation - Timelock tl = new EtherFiTimelock(minWaitTime, proposers, executors, address(0x0)); - - addressProvider.addContract(address(tl), "Timelock"); - */ - - vm.stopBroadcast(); - } -} diff --git a/src/CumulativeMerkleRewardsDistributor.sol b/src/CumulativeMerkleRewardsDistributor.sol index 9b9f8d49f..3e33437c1 100644 --- a/src/CumulativeMerkleRewardsDistributor.sol +++ b/src/CumulativeMerkleRewardsDistributor.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.24; +pragma solidity ^0.8.24; import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {OwnableUpgradeable} from "@openzeppelin-upgradeable/contracts/access/OwnableUpgradeable.sol"; diff --git a/test/TestSetup.sol b/test/TestSetup.sol index 41e331fb4..b713ad8cd 100644 --- a/test/TestSetup.sol +++ b/test/TestSetup.sol @@ -59,7 +59,7 @@ import "../src/EtherFiRewardsRouter.sol"; import "../src/CumulativeMerkleRewardsDistributor.sol"; -contract TestSetup is Test, ContractCodeChecker { +contract TestSetup is Test, ContractCodeChecker, DepositDataGeneration, ArrayTestHelper { event Schedule(address target, uint256 value, bytes data, bytes32 predecessor, bytes32 salt, uint256 delay); event Execute(address target, uint256 value, bytes data, bytes32 predecessor, bytes32 salt);