2026-02-13 18:21:49 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
pragma solidity ^0.8.19;
|
|
|
|
|
|
2026-02-26 14:20:11 +00:00
|
|
|
import "../src/OptimizerV3Push3.sol";
|
2026-02-13 18:21:49 +00:00
|
|
|
import { UUPSUpgradeable } from "@openzeppelin/proxy/utils/UUPSUpgradeable.sol";
|
|
|
|
|
import "forge-std/Script.sol";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @title UpgradeOptimizer
|
|
|
|
|
* @notice Upgrades an existing Optimizer UUPS proxy to OptimizerV3 implementation.
|
|
|
|
|
* @dev Usage:
|
|
|
|
|
* OPTIMIZER_PROXY=0x... forge script script/UpgradeOptimizer.sol \
|
|
|
|
|
* --rpc-url <RPC_URL> --broadcast
|
|
|
|
|
*
|
|
|
|
|
* The caller must be the proxy admin (the address that called initialize()).
|
|
|
|
|
*/
|
|
|
|
|
contract UpgradeOptimizer is Script {
|
|
|
|
|
function run() public {
|
|
|
|
|
address proxyAddress = vm.envAddress("OPTIMIZER_PROXY");
|
|
|
|
|
require(proxyAddress != address(0), "OPTIMIZER_PROXY env var required");
|
|
|
|
|
|
|
|
|
|
string memory seedPhrase = vm.readFile(".secret");
|
|
|
|
|
uint256 privateKey = vm.deriveKey(seedPhrase, 0);
|
|
|
|
|
vm.startBroadcast(privateKey);
|
|
|
|
|
address sender = vm.addr(privateKey);
|
|
|
|
|
|
|
|
|
|
console.log("\n=== Optimizer UUPS Upgrade ===");
|
|
|
|
|
console.log("Proxy address:", proxyAddress);
|
|
|
|
|
console.log("Admin (sender):", sender);
|
|
|
|
|
|
2026-02-26 14:20:11 +00:00
|
|
|
// Deploy new OptimizerV3Push3 implementation
|
|
|
|
|
OptimizerV3Push3 newImpl = new OptimizerV3Push3();
|
|
|
|
|
console.log("New OptimizerV3Push3 implementation:", address(newImpl));
|
2026-02-13 18:21:49 +00:00
|
|
|
|
|
|
|
|
// Upgrade proxy to new implementation (no reinitialize needed — storage layout compatible)
|
|
|
|
|
UUPSUpgradeable(proxyAddress).upgradeTo(address(newImpl));
|
2026-02-26 14:20:11 +00:00
|
|
|
console.log("Proxy upgraded to OptimizerV3Push3");
|
2026-02-13 18:21:49 +00:00
|
|
|
|
2026-02-26 14:20:11 +00:00
|
|
|
// Verify upgrade by calling isBullMarket through the proxy
|
|
|
|
|
OptimizerV3Push3 upgraded = OptimizerV3Push3(proxyAddress);
|
|
|
|
|
bool bull = upgraded.isBullMarket(0, 0);
|
2026-02-13 18:21:49 +00:00
|
|
|
console.log("\n=== Post-Upgrade Verification ===");
|
2026-02-26 14:20:11 +00:00
|
|
|
console.log("isBullMarket(0,0):", bull);
|
2026-02-13 18:21:49 +00:00
|
|
|
|
|
|
|
|
vm.stopBroadcast();
|
|
|
|
|
}
|
|
|
|
|
}
|