Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bEIGEN/EIGEN changes #717

Merged
merged 7 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions script/deploy/holesky/Preprod_Upgrade_bEIGEN_and_EIGEN.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts/governance/TimelockController.sol";

import "forge-std/Script.sol";
import "forge-std/Test.sol";

import "../../../src/contracts/token/BackingEigen.sol";
import "../../../src/contracts/token/Eigen.sol";

// forge script script/deploy/holesky/Preprod_Upgrade_bEIGEN_and_EIGEN.s.sol --rpc-url $RPC_HOLESKY --private-key $PRIVATE_KEY --broadcast -vvvv --verify --etherscan-api-key $ETHERSCAN_API_KEY
contract Preprod_Upgrade_bEIGEN_and_EIGEN is Script, Test {
Vm cheats = Vm(HEVM_ADDRESS);

BackingEigen public bEIGEN_proxy = BackingEigen(0xA72942289a043874249E60469F68f08B8c6ECCe8);
BackingEigen public bEIGEN_implementation;
Eigen public EIGEN_proxy = Eigen(0xD58f6844f79eB1fbd9f7091d05f7cb30d3363926);
Eigen public EIGEN_implementation;
ProxyAdmin public EIGEN_ProxyAdmin = ProxyAdmin(0x1BEF05C7303d44e0E2FCD2A19d993eDEd4c51b5B);
address public proxyAdminOwner = 0xDA29BB71669f46F2a779b4b62f03644A84eE3479;

IERC20 public bEIGEN_addressBefore;
IERC20 public EIGEN_addressBefore;

function run() external {
// Read and log the chain ID
uint256 chainId = block.chainid;
emit log_named_uint("You are deploying on ChainID", chainId);

if (chainId != 17000) {
revert("Chain not supported");
}

bEIGEN_addressBefore = EIGEN_proxy.bEIGEN();
require(bEIGEN_addressBefore == IERC20(0xA72942289a043874249E60469F68f08B8c6ECCe8),
"something horribly wrong");

EIGEN_addressBefore = bEIGEN_proxy.EIGEN();
require(EIGEN_addressBefore == IERC20(0xD58f6844f79eB1fbd9f7091d05f7cb30d3363926),
"something horribly wrong");

// Begin deployment
vm.startBroadcast();

// Deploy new implmementation contracts
EIGEN_implementation = new Eigen({
_bEIGEN: bEIGEN_addressBefore
});
bEIGEN_implementation = new BackingEigen({
_EIGEN: EIGEN_addressBefore
});

vm.stopBroadcast();

emit log_named_address("EIGEN_implementation", address(EIGEN_implementation));
emit log_named_address("bEIGEN_implementation", address(bEIGEN_implementation));

// Perform upgrade
vm.startBroadcast();
EIGEN_ProxyAdmin.upgrade(
TransparentUpgradeableProxy(payable(address(bEIGEN_proxy))),
address(bEIGEN_implementation)
);
EIGEN_ProxyAdmin.upgrade(
TransparentUpgradeableProxy(payable(address(EIGEN_proxy))),
address(EIGEN_implementation)
);
vm.stopBroadcast();

// Perform post-upgrade tests
checkUpgradeCorrectness();
simulateWrapAndUnwrap();
}

function checkUpgradeCorrectness() public {
cheats.startPrank(address(proxyAdminOwner));
require(EIGEN_ProxyAdmin.getProxyImplementation(TransparentUpgradeableProxy(payable(address(EIGEN_proxy)))) == address(EIGEN_implementation),
"implementation set incorrectly");
require(EIGEN_proxy.bEIGEN() == bEIGEN_addressBefore,
"bEIGEN address changed unexpectedly");
require(EIGEN_ProxyAdmin.getProxyImplementation(TransparentUpgradeableProxy(payable(address(bEIGEN_proxy)))) == address(bEIGEN_implementation),
"implementation set incorrectly");
require(bEIGEN_proxy.EIGEN() == EIGEN_addressBefore,
"EIGEN address changed unexpectedly");
cheats.stopPrank();
}

function simulateWrapAndUnwrap() public {
uint256 amount = 1e18;
cheats.prank(address(EIGEN_proxy));
bEIGEN_proxy.transfer(address(this), amount);

bEIGEN_proxy.approve(address(EIGEN_proxy), amount);
uint256 bEIGEN_balanceStart = bEIGEN_proxy.balanceOf(address(this));
uint256 EIGEN_balanceStart = EIGEN_proxy.balanceOf(address(this));
EIGEN_proxy.wrap(amount);
uint256 bEIGEN_balanceMiddle = bEIGEN_proxy.balanceOf(address(this));
uint256 EIGEN_balanceMiddle = EIGEN_proxy.balanceOf(address(this));
EIGEN_proxy.unwrap(amount);
uint256 bEIGEN_balanceAfter = bEIGEN_proxy.balanceOf(address(this));
uint256 EIGEN_balanceAfter = EIGEN_proxy.balanceOf(address(this));

require(bEIGEN_balanceMiddle + amount == bEIGEN_balanceStart, "wrapping did not transfer out bEIGEN");
require(EIGEN_balanceMiddle == EIGEN_balanceStart + amount, "wrapping did not transfer in EIGEN");

require(bEIGEN_balanceAfter == bEIGEN_balanceStart, "unwrapping did not transfer in bEIGEN");
require(EIGEN_balanceAfter == EIGEN_balanceStart, "unwrapping did not transfer out EIGEN");
}
}
112 changes: 112 additions & 0 deletions script/deploy/holesky/bEIGEN_and_EIGEN_upgrade.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts/governance/TimelockController.sol";

import "../../../src/contracts/token/BackingEigen.sol";
import "../../../src/contracts/token/Eigen.sol";

import "forge-std/Script.sol";
import "forge-std/Test.sol";

// # To load the variables in the .env file
// source .env

// # To deploy and verify our contract
// 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
contract bEIGEN_and_EIGEN_upgrade is Script, Test {
Vm cheats = Vm(HEVM_ADDRESS);

BackingEigen public bEIGEN_proxy = BackingEigen(0x275cCf9Be51f4a6C94aBa6114cdf2a4c45B9cb27);
BackingEigen public bEIGEN_implementation;
Eigen public EIGEN_proxy = Eigen(0x3B78576F7D6837500bA3De27A60c7f594934027E);
Eigen public EIGEN_implementation;
ProxyAdmin public token_ProxyAdmin = ProxyAdmin(0x67482666771e82C9a73BB9e9A22B2B597f448BBf);
address public opsMultisig = 0xfaEF7338b7490b9E272d80A1a39f4657cAf2b97d;

IERC20 public bEIGEN_addressBefore;
IERC20 public EIGEN_addressBefore;

function run() external {
// Read and log the chain ID
uint256 chainId = block.chainid;
emit log_named_uint("You are deploying on ChainID", chainId);

if (chainId != 17000) {
revert("Chain not supported");
}

bEIGEN_addressBefore = EIGEN_proxy.bEIGEN();
EIGEN_addressBefore = bEIGEN_proxy.EIGEN();

require(bEIGEN_addressBefore == IERC20(0x275cCf9Be51f4a6C94aBa6114cdf2a4c45B9cb27),
"something horribly wrong");
require(EIGEN_addressBefore == IERC20(0x3B78576F7D6837500bA3De27A60c7f594934027E),
"something horribly wrong");

// Begin deployment
vm.startBroadcast();

// Deploy new implementation contracts
EIGEN_implementation = new Eigen({
_bEIGEN: bEIGEN_addressBefore
});
bEIGEN_implementation = new BackingEigen({
_EIGEN: EIGEN_addressBefore
});
vm.stopBroadcast();

emit log_named_address("EIGEN_implementation", address(EIGEN_implementation));
emit log_named_address("bEIGEN_implementation", address(bEIGEN_implementation));

// Perform post-upgrade tests
simulatePerformingUpgrade();
checkUpgradeCorrectness();
simulateWrapAndUnwrap();
}

function simulatePerformingUpgrade() public {
cheats.startPrank(opsMultisig);
// Upgrade contracts
token_ProxyAdmin.upgrade(TransparentUpgradeableProxy(payable(address(EIGEN_proxy))), address(EIGEN_implementation));
token_ProxyAdmin.upgrade(TransparentUpgradeableProxy(payable(address(bEIGEN_proxy))), address(bEIGEN_implementation));
cheats.stopPrank();
}

function checkUpgradeCorrectness() public {
vm.startPrank(opsMultisig);
require(token_ProxyAdmin.getProxyImplementation(TransparentUpgradeableProxy(payable(address(EIGEN_proxy)))) == address(EIGEN_implementation),
"implementation set incorrectly");
require(EIGEN_proxy.bEIGEN() == bEIGEN_addressBefore,
"bEIGEN address changed unexpectedly");
require(token_ProxyAdmin.getProxyImplementation(TransparentUpgradeableProxy(payable(address(bEIGEN_proxy)))) == address(bEIGEN_implementation),
"implementation set incorrectly");
require(bEIGEN_proxy.EIGEN() == EIGEN_addressBefore,
"EIGEN address changed unexpectedly");
cheats.stopPrank();
}

function simulateWrapAndUnwrap() public {
uint256 amount = 1e18;
cheats.prank(address(EIGEN_proxy));
bEIGEN_proxy.transfer(address(this), amount);

bEIGEN_proxy.approve(address(EIGEN_proxy), amount);
uint256 bEIGEN_balanceStart = bEIGEN_proxy.balanceOf(address(this));
uint256 EIGEN_balanceStart = EIGEN_proxy.balanceOf(address(this));
EIGEN_proxy.wrap(amount);
uint256 bEIGEN_balanceMiddle = bEIGEN_proxy.balanceOf(address(this));
uint256 EIGEN_balanceMiddle = EIGEN_proxy.balanceOf(address(this));
EIGEN_proxy.unwrap(amount);
uint256 bEIGEN_balanceAfter = bEIGEN_proxy.balanceOf(address(this));
uint256 EIGEN_balanceAfter = EIGEN_proxy.balanceOf(address(this));

require(bEIGEN_balanceMiddle + amount == bEIGEN_balanceStart, "wrapping did not transfer out bEIGEN");
require(EIGEN_balanceMiddle == EIGEN_balanceStart + amount, "wrapping did not transfer in EIGEN");

require(bEIGEN_balanceAfter == bEIGEN_balanceStart, "unwrapping did not transfer in bEIGEN");
require(EIGEN_balanceAfter == EIGEN_balanceStart, "unwrapping did not transfer out EIGEN");
}
}
72 changes: 72 additions & 0 deletions script/deploy/mainnet/EIGEN_timelock_reduction.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import "@openzeppelin/contracts/governance/TimelockController.sol";

import "forge-std/Script.sol";
import "forge-std/Test.sol";

// # To load the variables in the .env file
// source .env

// # To deploy and verify our contract
// forge script script/deploy/mainnet/EIGEN_timelock_reduction.s.sol:EIGEN_timelock_reduction -vvvv --rpc-url $RPC_URL
contract EIGEN_timelock_reduction is Script, Test {
Vm cheats = Vm(HEVM_ADDRESS);

TimelockController public EIGEN_TimelockController = TimelockController(payable(0x2520C6b2C1FBE1813AB5c7c1018CDa39529e9FF2));
address public EIGEN_TimelockAdmin = 0xbb00DDa2832850a43840A3A86515E3Fe226865F2;

uint256 public newDelay = 0;

function run() external {
// Read and log the chain ID
uint256 chainId = block.chainid;
emit log_named_uint("You are deploying on ChainID", chainId);

if (chainId == 1) {
// rpcUrl = "RPC_MAINNET";
} else {
revert("Chain not supported");
}

uint256 minDelayBefore = EIGEN_TimelockController.getMinDelay();

require(minDelayBefore == 10 days,
"something horribly wrong");

bytes memory proposalData = abi.encodeWithSelector(
TimelockController.updateDelay.selector,
newDelay
);
emit log_named_bytes("proposalData", proposalData);

// propose change to zero delay
vm.startPrank(EIGEN_TimelockAdmin);
EIGEN_TimelockController.schedule({
target: address(EIGEN_TimelockController),
value: 0,
data: proposalData,
predecessor: bytes32(0),
salt: bytes32(0),
delay: minDelayBefore
});

// fast-forward to after current delay and execute
vm.warp(block.timestamp + minDelayBefore);
EIGEN_TimelockController.execute({
target: address(EIGEN_TimelockController),
value: 0,
payload: proposalData,
predecessor: bytes32(0),
salt: bytes32(0)
});

cheats.stopPrank();

uint256 minDelayAfter = EIGEN_TimelockController.getMinDelay();

require(minDelayAfter == 0,
"min delay not set to zero");
}
}
Loading
Loading