1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ pragma solidity ^ 0.8.12 ;
3
+
4
+ import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol " ;
5
+ import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol " ;
6
+ import "@openzeppelin/contracts/governance/TimelockController.sol " ;
7
+
8
+ import "../../../src/contracts/token/BackingEigen.sol " ;
9
+ import "../../../src/contracts/token/Eigen.sol " ;
10
+
11
+ import "forge-std/Script.sol " ;
12
+ import "forge-std/Test.sol " ;
13
+
14
+ // # To load the variables in the .env file
15
+ // source .env
16
+
17
+ // # To deploy and verify our contract
18
+ // forge script script/deploy/holesky/bEIGEN_and_EIGEN_upgrade.s.sol:bEIGEN_and_EIGEN_upgrade -vvv --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
19
+ contract bEIGEN_and_EIGEN_upgrade is Script , Test {
20
+ Vm cheats = Vm (HEVM_ADDRESS);
21
+
22
+ BackingEigen public bEIGEN_proxy = BackingEigen (0x275cCf9Be51f4a6C94aBa6114cdf2a4c45B9cb27 );
23
+ BackingEigen public bEIGEN_implementation;
24
+ Eigen public EIGEN_proxy = Eigen (0x3B78576F7D6837500bA3De27A60c7f594934027E );
25
+ Eigen public EIGEN_implementation;
26
+ ProxyAdmin public token_ProxyAdmin = ProxyAdmin (0x67482666771e82C9a73BB9e9A22B2B597f448BBf );
27
+ address public opsMultisig = 0xfaEF7338b7490b9E272d80A1a39f4657cAf2b97d ;
28
+
29
+ IERC20 public bEIGEN_addressBefore;
30
+ IERC20 public EIGEN_addressBefore;
31
+
32
+ function run () external {
33
+ // Read and log the chain ID
34
+ uint256 chainId = block .chainid ;
35
+ emit log_named_uint ("You are deploying on ChainID " , chainId);
36
+
37
+ if (chainId != 17000 ) {
38
+ revert ("Chain not supported " );
39
+ }
40
+
41
+ bEIGEN_addressBefore = EIGEN_proxy.bEIGEN ();
42
+ EIGEN_addressBefore = bEIGEN_proxy.EIGEN ();
43
+
44
+ require (bEIGEN_addressBefore == IERC20 (0x275cCf9Be51f4a6C94aBa6114cdf2a4c45B9cb27 ),
45
+ "something horribly wrong " );
46
+ require (EIGEN_addressBefore == IERC20 (0x3B78576F7D6837500bA3De27A60c7f594934027E ),
47
+ "something horribly wrong " );
48
+
49
+ // Begin deployment
50
+ vm.startBroadcast ();
51
+
52
+ // Deploy new implementation contracts
53
+ EIGEN_implementation = new Eigen ({
54
+ _bEIGEN: bEIGEN_addressBefore
55
+ });
56
+ bEIGEN_implementation = new BackingEigen ({
57
+ _EIGEN: EIGEN_addressBefore
58
+ });
59
+ vm.stopBroadcast ();
60
+
61
+ emit log_named_address ("EIGEN_implementation " , address (EIGEN_implementation));
62
+ emit log_named_address ("bEIGEN_implementation " , address (bEIGEN_implementation));
63
+
64
+ // Perform post-upgrade tests
65
+ simulatePerformingUpgrade ();
66
+ checkUpgradeCorrectness ();
67
+ simulateWrapAndUnwrap ();
68
+ }
69
+
70
+ function simulatePerformingUpgrade () public {
71
+ cheats.startPrank (opsMultisig);
72
+ // Upgrade contracts
73
+ token_ProxyAdmin.upgrade (TransparentUpgradeableProxy (payable (address (EIGEN_proxy))), address (EIGEN_implementation));
74
+ token_ProxyAdmin.upgrade (TransparentUpgradeableProxy (payable (address (bEIGEN_proxy))), address (bEIGEN_implementation));
75
+ cheats.stopPrank ();
76
+ }
77
+
78
+ function checkUpgradeCorrectness () public {
79
+ vm.startPrank (opsMultisig);
80
+ require (token_ProxyAdmin.getProxyImplementation (TransparentUpgradeableProxy (payable (address (EIGEN_proxy)))) == address (EIGEN_implementation),
81
+ "implementation set incorrectly " );
82
+ require (EIGEN_proxy.bEIGEN () == bEIGEN_addressBefore,
83
+ "bEIGEN address changed unexpectedly " );
84
+ require (token_ProxyAdmin.getProxyImplementation (TransparentUpgradeableProxy (payable (address (bEIGEN_proxy)))) == address (bEIGEN_implementation),
85
+ "implementation set incorrectly " );
86
+ require (bEIGEN_proxy.EIGEN () == EIGEN_addressBefore,
87
+ "EIGEN address changed unexpectedly " );
88
+ cheats.stopPrank ();
89
+ }
90
+
91
+ function simulateWrapAndUnwrap () public {
92
+ uint256 amount = 1e18 ;
93
+ cheats.prank (address (EIGEN_proxy));
94
+ bEIGEN_proxy.transfer (address (this ), amount);
95
+
96
+ bEIGEN_proxy.approve (address (EIGEN_proxy), amount);
97
+ uint256 bEIGEN_balanceStart = bEIGEN_proxy.balanceOf (address (this ));
98
+ uint256 EIGEN_balanceStart = EIGEN_proxy.balanceOf (address (this ));
99
+ EIGEN_proxy.wrap (amount);
100
+ uint256 bEIGEN_balanceMiddle = bEIGEN_proxy.balanceOf (address (this ));
101
+ uint256 EIGEN_balanceMiddle = EIGEN_proxy.balanceOf (address (this ));
102
+ EIGEN_proxy.unwrap (amount);
103
+ uint256 bEIGEN_balanceAfter = bEIGEN_proxy.balanceOf (address (this ));
104
+ uint256 EIGEN_balanceAfter = EIGEN_proxy.balanceOf (address (this ));
105
+
106
+ require (bEIGEN_balanceMiddle + amount == bEIGEN_balanceStart, "wrapping did not transfer out bEIGEN " );
107
+ require (EIGEN_balanceMiddle == EIGEN_balanceStart + amount, "wrapping did not transfer in EIGEN " );
108
+
109
+ require (bEIGEN_balanceAfter == bEIGEN_balanceStart, "unwrapping did not transfer in bEIGEN " );
110
+ require (EIGEN_balanceAfter == EIGEN_balanceStart, "unwrapping did not transfer out EIGEN " );
111
+ }
112
+ }
0 commit comments