Skip to content

Commit

Permalink
revert ContractAddresses.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
dan13ram committed Aug 27, 2024
1 parent 498985f commit b287b5f
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 263 deletions.
File renamed without changes.
92 changes: 76 additions & 16 deletions script/ContractAddresses.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// SPDX-License-Identifier: BSD 3-Clause License
pragma solidity ^0.8.24;


contract ContractAddresses {

struct YnEigenAddresses {
address YNEIGEN_ADDRESS;
address TOKEN_STAKING_NODES_MANAGER_ADDRESS;
Expand All @@ -10,18 +12,14 @@ contract ContractAddresses {
address LSD_RATE_PROVIDER_ADDRESS;
address YNEIGEN_DEPOSIT_ADAPTER_ADDRESS;
address TIMELOCK_CONTROLLER_ADDRESS;
address STETH_ADDRESS;
address WSTETH_ADDRESS;
address OETH_ADDRESS;
address WOETH_ADDRESS;
}

struct YieldNestAddresses {
address YNETH_ADDRESS;
address STAKING_NODES_MANAGER_ADDRESS;
address REWARDS_DISTRIBUTOR_ADDRESS;
address EXECUTION_LAYER_RECEIVER_ADDRESS;
address CONSENSUS_LAYER_RECEIVER_ADDRESS;
address CONSENSUS_LAYER_RECEIVER_ADDRESS;
}

struct EigenlayerAddresses {
Expand All @@ -33,6 +31,29 @@ contract ContractAddresses {
address DELAYED_WITHDRAWAL_ROUTER_ADDRESS;
}

struct LSDAddresses {
address SFRXETH_ADDRESS;
address RETH_ADDRESS;
address STETH_ADDRESS;
address WSTETH_ADDRESS;
address OETH_ADDRESS;
address WOETH_ADDRESS;
address OETH_ZAPPER_ADDRESS;
address SWELL_ADDRESS;
address METH_ADDRESS;
address CBETH_ADDRESS;
}

struct LSDStrategies {
address RETH_STRATEGY_ADDRESS;
address STETH_STRATEGY_ADDRESS;
address OETH_STRATEGY_ADDRESS;
address SFRXETH_STRATEGY_ADDRESS;
address SWELL_STRATEGY_ADDRESS;
address METH_STRATEGY_ADDRESS;
address CBETH_STRATEGY_ADDRESS;
}

struct EthereumAddresses {
address WETH_ADDRESS;
address DEPOSIT_2_ADDRESS;
Expand All @@ -41,6 +62,8 @@ contract ContractAddresses {
struct ChainAddresses {
EthereumAddresses ethereum;
EigenlayerAddresses eigenlayer;
LSDAddresses lsd;
LSDStrategies lsdStrategies;
YieldNestAddresses yn;
YnEigenAddresses ynEigen;
}
Expand All @@ -51,7 +74,10 @@ contract ContractAddresses {
}

mapping(uint256 => ChainAddresses) public addresses;
ChainIds public chainIds = ChainIds({mainnet: 1, holeksy: 17000});
ChainIds public chainIds = ChainIds({
mainnet: 1,
holeksy: 17000
});

constructor() {
addresses[chainIds.mainnet] = ChainAddresses({
Expand All @@ -67,6 +93,27 @@ contract ContractAddresses {
STRATEGY_MANAGER_PAUSER_ADDRESS: 0xBE1685C81aA44FF9FB319dD389addd9374383e90,
DELAYED_WITHDRAWAL_ROUTER_ADDRESS: 0x7Fe7E9CC0F274d2435AD5d56D5fa73E47F6A23D8
}),
lsd: LSDAddresses({
SFRXETH_ADDRESS: 0xac3E018457B222d93114458476f3E3416Abbe38F,
RETH_ADDRESS: 0xae78736Cd615f374D3085123A210448E74Fc6393,
STETH_ADDRESS: 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84,
WSTETH_ADDRESS: 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0,
OETH_ADDRESS: 0x856c4Efb76C1D1AE02e20CEB03A2A6a08b0b8dC3,
WOETH_ADDRESS: 0xDcEe70654261AF21C44c093C300eD3Bb97b78192,
OETH_ZAPPER_ADDRESS: 0x9858e47BCbBe6fBAC040519B02d7cd4B2C470C66,
SWELL_ADDRESS: 0xf951E335afb289353dc249e82926178EaC7DEd78,
METH_ADDRESS: 0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa,
CBETH_ADDRESS: 0xBe9895146f7AF43049ca1c1AE358B0541Ea49704
}),
lsdStrategies: LSDStrategies({
RETH_STRATEGY_ADDRESS: 0x1BeE69b7dFFfA4E2d53C2a2Df135C388AD25dCD2,
STETH_STRATEGY_ADDRESS: 0x93c4b944D05dfe6df7645A86cd2206016c51564D,
OETH_STRATEGY_ADDRESS: 0xa4C637e0F704745D182e4D38cAb7E7485321d059,
SFRXETH_STRATEGY_ADDRESS: 0x8CA7A5d6f3acd3A7A8bC468a8CD0FB14B6BD28b6,
SWELL_STRATEGY_ADDRESS: 0x0Fe4F44beE93503346A3Ac9EE5A26b130a5796d6,
METH_STRATEGY_ADDRESS: 0x298aFB19A105D59E74658C4C334Ff360BadE6dd2,
CBETH_STRATEGY_ADDRESS: 0x54945180dB7943c0ed0FEE7EdaB2Bd24620256bc
}),
yn: YieldNestAddresses({
YNETH_ADDRESS: 0x09db87A538BD693E9d08544577d5cCfAA6373A48,
STAKING_NODES_MANAGER_ADDRESS: 0x8C33A1d6d062dB7b51f79702355771d44359cD7d,
Expand All @@ -81,11 +128,7 @@ contract ContractAddresses {
EIGEN_STRATEGY_MANAGER_ADDRESS: 0x92D904019A92B0Cafce3492Abb95577C285A68fC,
LSD_RATE_PROVIDER_ADDRESS: 0xb658Cf6F4C232Be5c6035f2b42b96393089F20D9,
YNEIGEN_DEPOSIT_ADAPTER_ADDRESS: 0x9e72155d301a6555dc565315be72D295c76753c0,
TIMELOCK_CONTROLLER_ADDRESS: 0xbB73f8a5B0074b27c6df026c77fA08B0111D017A,
STETH_ADDRESS: 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84,
WSTETH_ADDRESS: 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0,
OETH_ADDRESS: 0x856c4Efb76C1D1AE02e20CEB03A2A6a08b0b8dC3,
WOETH_ADDRESS: 0xDcEe70654261AF21C44c093C300eD3Bb97b78192
TIMELOCK_CONTROLLER_ADDRESS: 0xbB73f8a5B0074b27c6df026c77fA08B0111D017A
})
});

Expand All @@ -105,6 +148,27 @@ contract ContractAddresses {
STRATEGY_MANAGER_PAUSER_ADDRESS: 0x28Ade60640fdBDb2609D8d8734D1b5cBeFc0C348,
DELAYED_WITHDRAWAL_ROUTER_ADDRESS: 0x642c646053eaf2254f088e9019ACD73d9AE0FA32 // Placeholder address, replaced with address(1) for holesky
}),
lsd: LSDAddresses({
SFRXETH_ADDRESS: 0xa63f56985F9C7F3bc9fFc5685535649e0C1a55f3,
RETH_ADDRESS: 0x7322c24752f79c05FFD1E2a6FCB97020C1C264F1, // source: https://docs.rocketpool.net/guides/staking/via-rp
STETH_ADDRESS: 0x3F1c547b21f65e10480dE3ad8E19fAAC46C95034, // source: https://docs.lido.fi/deployed-contracts/holesky/
WSTETH_ADDRESS: 0x8d09a4502Cc8Cf1547aD300E066060D043f6982D, // source: https://docs.lido.fi/deployed-contracts/holesky/
OETH_ADDRESS: 0x10B83FBce870642ee33f0877ffB7EA43530E473D, // TODO: fix, currently a YieldNest Mock is used
WOETH_ADDRESS: 0xbaAcDcC565006b6429F57bC0f436dFAf14A526b1, // TODO: fix, currently a YieldNest Mock is used
OETH_ZAPPER_ADDRESS: 0x9858e47BCbBe6fBAC040519B02d7cd4B2C470C66, // TODO: fix, placeholder until available
SWELL_ADDRESS: 0xf951E335afb289353dc249e82926178EaC7DEd78, // TODO: fix, placeholder until available
METH_ADDRESS: 0xe3C063B1BEe9de02eb28352b55D49D85514C67FF,
CBETH_ADDRESS: 0x8720095Fa5739Ab051799211B146a2EEE4Dd8B37
}),
lsdStrategies: LSDStrategies({
RETH_STRATEGY_ADDRESS: 0x3A8fBdf9e77DFc25d09741f51d3E181b25d0c4E0,
STETH_STRATEGY_ADDRESS: 0x7D704507b76571a51d9caE8AdDAbBFd0ba0e63d3,
OETH_STRATEGY_ADDRESS: 0xa4C637e0F704745D182e4D38cAb7E7485321d059, // TODO: fix, placeholder until available
SFRXETH_STRATEGY_ADDRESS: 0x9281ff96637710Cd9A5CAcce9c6FAD8C9F54631c,
SWELL_STRATEGY_ADDRESS: 0x0Fe4F44beE93503346A3Ac9EE5A26b130a5796d6, // TODO: fix, placeholder until available
METH_STRATEGY_ADDRESS: 0xaccc5A86732BE85b5012e8614AF237801636F8e5,
CBETH_STRATEGY_ADDRESS: 0x70EB4D3c164a6B4A5f908D4FBb5a9cAfFb66bAB6
}),
yn: YieldNestAddresses({
YNETH_ADDRESS: 0xd9029669BC74878BCB5BE58c259ed0A277C5c16E,
STAKING_NODES_MANAGER_ADDRESS: 0xc2387EBb4Ea66627E3543a771e260Bd84218d6a1,
Expand All @@ -119,11 +183,7 @@ contract ContractAddresses {
EIGEN_STRATEGY_MANAGER_ADDRESS: 0xA0a11A9b84bf87c0323bc183715a22eC7881B7FC,
LSD_RATE_PROVIDER_ADDRESS: 0xd68C29263F6dC2Ff8D9307b3AfAcD6D6fDeFbB3A,
YNEIGEN_DEPOSIT_ADAPTER_ADDRESS: 0x7d0c1F604571a1c015684e6c15f2DdEc432C5e74,
TIMELOCK_CONTROLLER_ADDRESS: 0x62173555C27C67644C5634e114e42A63A59CD7A5,
STETH_ADDRESS: 0x3F1c547b21f65e10480dE3ad8E19fAAC46C95034, // source: https://docs.lido.fi/deployed-contracts/holesky/
WSTETH_ADDRESS: 0x8d09a4502Cc8Cf1547aD300E066060D043f6982D, // source: https://docs.lido.fi/deployed-contracts/holesky/
OETH_ADDRESS: 0x10B83FBce870642ee33f0877ffB7EA43530E473D, // TODO: fix, currently a YieldNest Mock is used
WOETH_ADDRESS: 0xbaAcDcC565006b6429F57bC0f436dFAf14A526b1 // TODO: fix, currently a YieldNest Mock is used
TIMELOCK_CONTROLLER_ADDRESS: 0x62173555C27C67644C5634e114e42A63A59CD7A5
})
});
}
Expand Down
33 changes: 16 additions & 17 deletions script/DeployYieldNest.s.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: BSD 3-Clause License
pragma solidity ^0.8.24;

import {TransparentUpgradeableProxy} from
"lib/openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

import {TransparentUpgradeableProxy} from "lib/openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {IEigenPodManager} from "lib/eigenlayer-contracts/src/contracts/interfaces/IEigenPodManager.sol";
import {IDelegationManager} from "lib/eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol";
import {IDelayedWithdrawalRouter} from "lib/eigenlayer-contracts/src/contracts/interfaces/IDelayedWithdrawalRouter.sol";
Expand All @@ -26,6 +26,7 @@ import {ActorAddresses} from "script/Actors.sol";
import {console} from "lib/forge-std/src/console.sol";

contract DeployYieldNest is BaseYnETHScript {

TransparentUpgradeableProxy public ynethProxy;
TransparentUpgradeableProxy public stakingNodesManagerProxy;
TransparentUpgradeableProxy public rewardsDistributorProxy;
Expand All @@ -49,6 +50,7 @@ contract DeployYieldNest is BaseYnETHScript {
ActorAddresses.Actors actors;

function run() external {

uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");

address publicKey = vm.addr(deployerPrivateKey);
Expand Down Expand Up @@ -81,32 +83,25 @@ contract DeployYieldNest is BaseYnETHScript {
RewardsReceiver executionLayerReceiverImplementation = new RewardsReceiver();
RewardsReceiver consensusLayerReceiverImplementation = new RewardsReceiver();

executionLayerReceiverProxy = new TransparentUpgradeableProxy(
address(executionLayerReceiverImplementation), actors.admin.PROXY_ADMIN_OWNER, ""
);
consensusLayerReceiverProxy = new TransparentUpgradeableProxy(
address(consensusLayerReceiverImplementation), actors.admin.PROXY_ADMIN_OWNER, ""
);
executionLayerReceiverProxy = new TransparentUpgradeableProxy(address(executionLayerReceiverImplementation), actors.admin.PROXY_ADMIN_OWNER, "");
consensusLayerReceiverProxy = new TransparentUpgradeableProxy(address(consensusLayerReceiverImplementation), actors.admin.PROXY_ADMIN_OWNER, "");

executionLayerReceiver = RewardsReceiver(payable(executionLayerReceiverProxy));
consensusLayerReceiver = RewardsReceiver(payable(consensusLayerReceiverProxy));

stakingNodeImplementation = new StakingNode();

RewardsDistributor rewardsDistributorImplementation = new RewardsDistributor();
rewardsDistributorProxy = new TransparentUpgradeableProxy(
address(rewardsDistributorImplementation), actors.admin.PROXY_ADMIN_OWNER, ""
);
rewardsDistributorProxy = new TransparentUpgradeableProxy(address(rewardsDistributorImplementation), actors.admin.PROXY_ADMIN_OWNER, "");
rewardsDistributor = RewardsDistributor(payable(rewardsDistributorProxy));

// Deploy proxies
ynethProxy = new TransparentUpgradeableProxy(address(yneth), actors.admin.PROXY_ADMIN_OWNER, "");
stakingNodesManagerProxy =
new TransparentUpgradeableProxy(address(stakingNodesManager), actors.admin.PROXY_ADMIN_OWNER, "");
stakingNodesManagerProxy = new TransparentUpgradeableProxy(address(stakingNodesManager), actors.admin.PROXY_ADMIN_OWNER, "");

yneth = ynETH(payable(ynethProxy));
stakingNodesManager = StakingNodesManager(payable(stakingNodesManagerProxy));

// Initialize ynETH with example parameters
address[] memory pauseWhitelist = new address[](1);
pauseWhitelist[0] = actors.ops.PAUSE_ADMIN;
Expand Down Expand Up @@ -154,8 +149,10 @@ contract DeployYieldNest is BaseYnETHScript {
rewardsDistributor.initialize(rewardsDistributorInit);

// Initialize RewardsReceiver with example parameters
RewardsReceiver.Init memory rewardsReceiverInit =
RewardsReceiver.Init({admin: actors.admin.ADMIN, withdrawer: address(rewardsDistributor)});
RewardsReceiver.Init memory rewardsReceiverInit = RewardsReceiver.Init({
admin: actors.admin.ADMIN,
withdrawer: address(rewardsDistributor)
});
executionLayerReceiver.initialize(rewardsReceiverInit);
consensusLayerReceiver.initialize(rewardsReceiverInit); // Initializing consensusLayerReceiver

Expand All @@ -173,7 +170,9 @@ contract DeployYieldNest is BaseYnETHScript {
rewardsDistributor: rewardsDistributor,
stakingNodeImplementation: stakingNodeImplementation
});

saveDeployment(deployment);

}
}

40 changes: 18 additions & 22 deletions script/commands/DepositToYnLSDe.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {IynEigen} from "../../src/interfaces/IynEigen.sol";
import {ImETHStaking} from "../../src/external/mantle/ImETHStaking.sol";
import {IfrxMinter} from "../../src/external/frax/IfrxMinter.sol";

import {ContractAddresses as ContractAddressesOld} from "../../test/utils/ContractAddresses.sol";

import "../ynEigen/BaseYnEigenScript.s.sol";

interface IRocketPoolDepositPool {
Expand All @@ -25,8 +23,6 @@ contract DepositToYnLSDe is BaseYnEigenScript {

uint256 public constant AMOUNT = 0.1 ether;

ContractAddressesOld.ChainAddresses chainAddressesOld = (new ContractAddressesOld()).getChainAddresses(block.chainid);

function run() public {
address token = _getTokenAddress(vm.prompt("Token (`sfrxETH`, `wstETH`, `mETH` and `rETH` (holesky only))"));
uint256 path = vm.parseUint(vm.prompt("Path (`0` for deposit or `1` for send"));
Expand Down Expand Up @@ -60,26 +56,26 @@ contract DepositToYnLSDe is BaseYnEigenScript {

function _getTokenAddress(string memory n) internal view returns (address) {
if (keccak256(abi.encodePacked(n)) == keccak256(abi.encodePacked("sfrxETH")) && block.chainid == 1) {
return chainAddressesOld.lsd.SFRXETH_ADDRESS;
return chainAddresses.lsd.SFRXETH_ADDRESS;
} else if (keccak256(abi.encodePacked(n)) == keccak256(abi.encodePacked("wstETH"))) {
return chainAddressesOld.lsd.WSTETH_ADDRESS;
return chainAddresses.lsd.WSTETH_ADDRESS;
} else if (keccak256(abi.encodePacked(n)) == keccak256(abi.encodePacked("mETH"))) {
return chainAddressesOld.lsd.METH_ADDRESS;
return chainAddresses.lsd.METH_ADDRESS;
} else if (keccak256(abi.encodePacked(n)) == keccak256(abi.encodePacked("rETH")) && block.chainid == 17000) {
return chainAddressesOld.lsd.RETH_ADDRESS;
return chainAddresses.lsd.RETH_ADDRESS;
} else {
revert("Invalid token name");
}
}

function _getToken(address token) internal returns (uint256 _amount) {
if (token == chainAddressesOld.lsd.SFRXETH_ADDRESS) {
if (token == chainAddresses.lsd.SFRXETH_ADDRESS) {
_amount = _getSFRXETH();
} else if (token == chainAddressesOld.lsd.WSTETH_ADDRESS) {
} else if (token == chainAddresses.lsd.WSTETH_ADDRESS) {
_amount = _getWSTETH();
} else if (token == chainAddressesOld.lsd.METH_ADDRESS) {
} else if (token == chainAddresses.lsd.METH_ADDRESS) {
_amount = _getMETH();
} else if (token == chainAddressesOld.lsd.RETH_ADDRESS) {
} else if (token == chainAddresses.lsd.RETH_ADDRESS) {
_amount = _getRETH();
} else {
revert("Invalid token address");
Expand All @@ -92,37 +88,37 @@ contract DepositToYnLSDe is BaseYnEigenScript {
}

function _getWSTETH() internal returns (uint256) {
uint256 balanceBefore = IERC20(chainAddressesOld.lsd.STETH_ADDRESS).balanceOf(broadcaster);
(bool sent, ) = chainAddressesOld.lsd.STETH_ADDRESS.call{value: AMOUNT}("");
uint256 balanceBefore = IERC20(chainAddresses.lsd.STETH_ADDRESS).balanceOf(broadcaster);
(bool sent, ) = chainAddresses.lsd.STETH_ADDRESS.call{value: AMOUNT}("");
require(sent, "Failed to send Ether");

uint256 amount = IERC20(chainAddressesOld.lsd.STETH_ADDRESS).balanceOf(broadcaster) - balanceBefore;
IERC20(chainAddressesOld.lsd.STETH_ADDRESS).approve(chainAddressesOld.lsd.WSTETH_ADDRESS, amount);
return IwstETH(chainAddressesOld.lsd.WSTETH_ADDRESS).wrap(amount);
uint256 amount = IERC20(chainAddresses.lsd.STETH_ADDRESS).balanceOf(broadcaster) - balanceBefore;
IERC20(chainAddresses.lsd.STETH_ADDRESS).approve(chainAddresses.lsd.WSTETH_ADDRESS, amount);
return IwstETH(chainAddresses.lsd.WSTETH_ADDRESS).wrap(amount);
}

// NOTE: fails if AMOUNT < 0.1 ether
function _getMETH() internal returns (uint256) {
ImETHStaking mETHStaking = block.chainid == 1
? ImETHStaking(0xe3cBd06D7dadB3F4e6557bAb7EdD924CD1489E8f)
: ImETHStaking(0xbe16244EAe9837219147384c8A7560BA14946262);
IERC20 mETH = IERC20(chainAddressesOld.lsd.METH_ADDRESS);
IERC20 mETH = IERC20(chainAddresses.lsd.METH_ADDRESS);
uint256 _balanceBefore = mETH.balanceOf(broadcaster);
mETHStaking.stake{value: AMOUNT}(mETHStaking.ethToMETH(AMOUNT));
return mETH.balanceOf(broadcaster) - _balanceBefore;
}

function _getRETH() internal returns (uint256) { // NOTE: only holesky
IRocketPoolDepositPool depositPool = IRocketPoolDepositPool(0x320f3aAB9405e38b955178BBe75c477dECBA0C27);
uint256 _balanceBefore = IERC20(chainAddressesOld.lsd.RETH_ADDRESS).balanceOf(broadcaster);
uint256 _balanceBefore = IERC20(chainAddresses.lsd.RETH_ADDRESS).balanceOf(broadcaster);
// NOTE: only works if pool is not at max capacity (it may be)
depositPool.deposit{value: AMOUNT}();
return IERC20(chainAddressesOld.lsd.RETH_ADDRESS).balanceOf(broadcaster) - _balanceBefore;
return IERC20(chainAddresses.lsd.RETH_ADDRESS).balanceOf(broadcaster) - _balanceBefore;
}

function _deposit(uint256 amount, address token) internal {
IERC20(token).approve(chainAddressesOld.ynEigen.YNEIGEN_ADDRESS, amount);
IynEigen(chainAddressesOld.ynEigen.YNEIGEN_ADDRESS).deposit(IERC20(token), amount, broadcaster);
IERC20(token).approve(chainAddresses.ynEigen.YNEIGEN_ADDRESS, amount);
IynEigen(chainAddresses.ynEigen.YNEIGEN_ADDRESS).deposit(IERC20(token), amount, broadcaster);
}

function _send(uint256 amount, address token) internal {
Expand Down
4 changes: 2 additions & 2 deletions script/ynEigen/YnEigenDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ contract YnEigenDeployer is BaseYnEigenScript {

{
ynEigenChainAddresses = YnEigenChainAddresses({
WSTETH_ADDRESS: chainAddresses.ynEigen.WSTETH_ADDRESS,
WOETH_ADDRESS: chainAddresses.ynEigen.WOETH_ADDRESS,
WSTETH_ADDRESS: chainAddresses.lsd.WSTETH_ADDRESS,
WOETH_ADDRESS: chainAddresses.lsd.WOETH_ADDRESS,
STRATEGY_MANAGER: chainAddresses.eigenlayer.STRATEGY_MANAGER_ADDRESS,
DELEGATION_MANAGER: chainAddresses.eigenlayer.DELEGATION_MANAGER_ADDRESS
});
Expand Down
Loading

0 comments on commit b287b5f

Please sign in to comment.