-
Notifications
You must be signed in to change notification settings - Fork 6
Renzo Integration #841
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
Merged
Merged
Renzo Integration #841
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
780d1ee
Updated `HyperdriveFactory` so that it can support initialization wit…
jalextowle bed3b07
Add initialize tests for the deployer coordinator
jalextowle eccb971
copy steth integration
sentilesdal 08c6bbb
rename files
sentilesdal c4b5269
stEth -> ezEth
sentilesdal ee2354a
add interfaces
sentilesdal d575c59
add IRestakeManager interface
sentilesdal 7c39431
lido -> restakeManager
sentilesdal 3e55629
remove lido, update deposit method
sentilesdal a22d33b
copy steth test file
sentilesdal d9436a8
capitalize name
sentilesdal 7e6ffc6
update deposit/withdraw functions
sentilesdal 668f61a
add deployers
sentilesdal 541a75e
fixup deployers
sentilesdal 16bcaad
add ezETH to deployers
sentilesdal 3b78692
add ezETH to instances
sentilesdal 449f6ab
add calculateTVLs to interface
sentilesdal 71424fb
add and cleanup tests
sentilesdal 709bbf3
remove ezETH from constructors
sentilesdal a728926
update tests
sentilesdal 86ea5da
fix remaining tests
sentilesdal 9f0b18e
small cleanups
sentilesdal 85a415b
wrap comment
sentilesdal 01e4ede
address nit fixes
sentilesdal 8500531
remove IEzETHHyperdriveCore.sol
sentilesdal ceb6b3c
remove unused import
sentilesdal 848e107
add IRenzoOracle, combine interface files
sentilesdal c3ea825
update imports
sentilesdal 943ae52
final nits addressed
sentilesdal c40feeb
fix capitalization
sentilesdal f7eda2b
capitalization
sentilesdal 0c75476
asdf.sol
sentilesdal 60ea094
rename
sentilesdal 60fda4b
don't allow ETH txns
sentilesdal 542849e
disable ETH for deployAndInitialize
sentilesdal 9b161f6
update tests
sentilesdal 2440c71
remove consoles
sentilesdal 2b2a340
small nits
sentilesdal 1452c58
fix revert tests
sentilesdal 133d830
all tess passing
sentilesdal bbda5d1
remove unused code
sentilesdal 6c8016b
cleanup
sentilesdal 4f23503
last fixups
sentilesdal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
contracts/src/deployers/ezeth/EzETHHyperdriveCoreDeployer.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| pragma solidity 0.8.20; | ||
|
|
||
| import { IERC20 } from "../../interfaces/IERC20.sol"; | ||
| import { IHyperdrive } from "../../interfaces/IHyperdrive.sol"; | ||
| import { IHyperdriveCoreDeployer } from "../../interfaces/IHyperdriveCoreDeployer.sol"; | ||
| import { IRestakeManager } from "../../interfaces/IRenzo.sol"; | ||
| import { EzETHHyperdrive } from "../../instances/ezeth/EzETHHyperdrive.sol"; | ||
|
|
||
| /// @author DELV | ||
| /// @title EzETHHyperdriveCoreDeployer | ||
| /// @notice The core deployer for the EzETHHyperdrive implementation. | ||
| /// @custom:disclaimer The language used in this code is for coding convenience | ||
| /// only, and is not intended to, and does not, have any | ||
| /// particular legal or regulatory significance. | ||
| contract EzETHHyperdriveCoreDeployer is IHyperdriveCoreDeployer { | ||
| /// @notice The Renzo contract. | ||
| IRestakeManager public immutable restakeManager; | ||
|
|
||
| /// @notice Instantiates the core deployer. | ||
| /// @param _restakeManager The Renzo contract. | ||
| constructor(IRestakeManager _restakeManager) { | ||
| restakeManager = _restakeManager; | ||
| } | ||
|
|
||
| /// @notice Deploys a Hyperdrive instance with the given parameters. | ||
| /// @param _config The configuration of the Hyperdrive pool. | ||
| /// @param target0 The target0 address. | ||
| /// @param target1 The target1 address. | ||
| /// @param target2 The target2 address. | ||
| /// @param target3 The target3 address. | ||
| /// @param target4 The target4 address. | ||
| /// @param _salt The create2 salt used in the deployment. | ||
| /// @return The address of the newly deployed EzETHHyperdrive instance. | ||
| function deploy( | ||
| IHyperdrive.PoolConfig memory _config, | ||
| bytes memory, // unused extra data | ||
| address target0, | ||
| address target1, | ||
| address target2, | ||
| address target3, | ||
| address target4, | ||
| bytes32 _salt | ||
| ) external returns (address) { | ||
| return ( | ||
| address( | ||
| // NOTE: We hash the sender with the salt to prevent the | ||
| // front-running of deployments. | ||
| new EzETHHyperdrive{ | ||
| salt: keccak256(abi.encode(msg.sender, _salt)) | ||
| }( | ||
| _config, | ||
| target0, | ||
| target1, | ||
| target2, | ||
| target3, | ||
| target4, | ||
| restakeManager | ||
| ) | ||
| ) | ||
| ); | ||
| } | ||
| } |
127 changes: 127 additions & 0 deletions
127
contracts/src/deployers/ezeth/EzETHHyperdriveDeployerCoordinator.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| pragma solidity 0.8.20; | ||
|
|
||
| import { IERC20 } from "../../interfaces/IERC20.sol"; | ||
| import { IHyperdrive } from "../../interfaces/IHyperdrive.sol"; | ||
| import { IHyperdriveDeployerCoordinator } from "../../interfaces/IHyperdriveDeployerCoordinator.sol"; | ||
| import { IRestakeManager } from "../../interfaces/IRenzo.sol"; | ||
| import { FixedPointMath, ONE } from "../../libraries/FixedPointMath.sol"; | ||
| import { HyperdriveDeployerCoordinator } from "../HyperdriveDeployerCoordinator.sol"; | ||
|
|
||
| /// @author DELV | ||
| /// @title EzETHHyperdriveDeployerCoordinator | ||
| /// @custom:disclaimer The language used in this code is for coding convenience | ||
| /// @notice The deployer coordinator for the EzETHHyperdrive implementation. | ||
| /// only, and is not intended to, and does not, have any | ||
| /// particular legal or regulatory significance. | ||
| contract EzETHHyperdriveDeployerCoordinator is HyperdriveDeployerCoordinator { | ||
| using FixedPointMath for uint256; | ||
|
|
||
| /// @notice The Renzo contract. | ||
| IRestakeManager public immutable restakeManager; | ||
|
|
||
| /// @notice The ezETH token contract. | ||
| IERC20 public immutable ezETH; | ||
|
|
||
| /// @notice Instantiates the deployer coordinator. | ||
| /// @param _coreDeployer The core deployer. | ||
| /// @param _target0Deployer The target0 deployer. | ||
| /// @param _target1Deployer The target1 deployer. | ||
| /// @param _target2Deployer The target2 deployer. | ||
| /// @param _target3Deployer The target3 deployer. | ||
| /// @param _target4Deployer The target4 deployer. | ||
| /// @param _restakeManager The Renzo contract. | ||
| constructor( | ||
| address _coreDeployer, | ||
| address _target0Deployer, | ||
| address _target1Deployer, | ||
| address _target2Deployer, | ||
| address _target3Deployer, | ||
| address _target4Deployer, | ||
| IRestakeManager _restakeManager | ||
| ) | ||
| HyperdriveDeployerCoordinator( | ||
| _coreDeployer, | ||
| _target0Deployer, | ||
| _target1Deployer, | ||
| _target2Deployer, | ||
| _target3Deployer, | ||
| _target4Deployer | ||
| ) | ||
| { | ||
| restakeManager = _restakeManager; | ||
| ezETH = IERC20(_restakeManager.ezETH()); | ||
| } | ||
|
|
||
| /// @dev Prepares the coordinator for initialization by drawing funds from | ||
| /// the LP, if necessary. | ||
| /// @param _hyperdrive The Hyperdrive instance that is being initialized. | ||
| /// @param _lp The LP that is initializing the pool. | ||
| /// @param _contribution The amount of capital to supply. The units of this | ||
| /// quantity are either base or vault shares, depending on the value | ||
| /// of `_options.asBase`. | ||
| /// @param _options The options that configure how the initialization is | ||
| /// settled. | ||
| /// @return value The value that should be sent in the initialize | ||
| /// transaction. | ||
| function _prepareInitialize( | ||
| IHyperdrive _hyperdrive, | ||
| address _lp, | ||
| uint256 _contribution, | ||
| IHyperdrive.Options memory _options | ||
| ) internal override returns (uint256 value) { | ||
| // Depositing as base is disallowed. | ||
| if (_options.asBase) { | ||
| revert IHyperdrive.UnsupportedToken(); | ||
| } | ||
| // Otherwise, transfer vault shares from the LP and approve the | ||
| // Hyperdrive pool. | ||
| ezETH.transferFrom(_lp, address(this), _contribution); | ||
| ezETH.approve(address(_hyperdrive), _contribution); | ||
| return value; | ||
sentilesdal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /// @dev Allows the contract to receive ether. | ||
| function _checkMessageValue() internal view override { | ||
| if (msg.value > 0) { | ||
| revert IHyperdrive.NotPayable(); | ||
| } | ||
| } | ||
|
|
||
| /// @notice Checks the pool configuration to ensure that it is valid. | ||
| /// @param _deployConfig The deploy configuration of the Hyperdrive pool. | ||
| function _checkPoolConfig( | ||
| IHyperdrive.PoolDeployConfig memory _deployConfig | ||
| ) internal view override { | ||
| // Perform the default checks. | ||
| super._checkPoolConfig(_deployConfig); | ||
|
|
||
| // Ensure that the minimum share reserves are equal to 1e15. This value | ||
| // has been tested to prevent arithmetic overflows in the | ||
| // `_updateLiquidity` function when the share reserves are as high as | ||
| // 200 million. | ||
| if (_deployConfig.minimumShareReserves != 1e15) { | ||
| revert IHyperdriveDeployerCoordinator.InvalidMinimumShareReserves(); | ||
| } | ||
|
|
||
| // Ensure that the minimum transaction amount are equal to 1e15. This | ||
| // value has been tested to prevent precision issues. | ||
| if (_deployConfig.minimumTransactionAmount != 1e15) { | ||
| revert IHyperdriveDeployerCoordinator | ||
| .InvalidMinimumTransactionAmount(); | ||
| } | ||
| } | ||
|
|
||
| /// @dev Gets the initial vault share price of the Hyperdrive pool. | ||
| /// @return The initial vault share price of the Hyperdrive pool. | ||
| function _getInitialVaultSharePrice( | ||
| bytes memory // unused extra data | ||
| ) internal view override returns (uint256) { | ||
| // Return ezETH's current vault share price. | ||
| (, , uint256 totalTVL) = restakeManager.calculateTVLs(); | ||
| uint256 ezETHSupply = ezETH.totalSupply(); | ||
|
|
||
| // Price in ETH / ezETH, does not include eigenlayer points. | ||
| return totalTVL.divDown(ezETHSupply); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| pragma solidity 0.8.20; | ||
|
|
||
| import { IERC20 } from "../../interfaces/IERC20.sol"; | ||
| import { EzETHTarget0 } from "../../instances/ezeth/EzETHTarget0.sol"; | ||
| import { IHyperdrive } from "../../interfaces/IHyperdrive.sol"; | ||
| import { IHyperdriveTargetDeployer } from "../../interfaces/IHyperdriveTargetDeployer.sol"; | ||
| import { IRestakeManager } from "../../interfaces/IRenzo.sol"; | ||
|
|
||
| /// @author DELV | ||
| /// @title EzETHTarget0Deployer | ||
| /// @notice The target0 deployer for the EzETHHyperdrive implementation. | ||
| /// @custom:disclaimer The language used in this code is for coding convenience | ||
| /// only, and is not intended to, and does not, have any | ||
| /// particular legal or regulatory significance. | ||
| contract EzETHTarget0Deployer is IHyperdriveTargetDeployer { | ||
| /// @notice The Renzo contract. | ||
| IRestakeManager public immutable restakeManager; | ||
|
|
||
| /// @notice Instantiates the core deployer. | ||
| /// @param _restakeManager The Renzo contract. | ||
| constructor(IRestakeManager _restakeManager) { | ||
| restakeManager = _restakeManager; | ||
| } | ||
|
|
||
| /// @notice Deploys a target0 instance with the given parameters. | ||
| /// @param _config The configuration of the Hyperdrive pool. | ||
| /// @param _salt The create2 salt used in the deployment. | ||
| /// @return The address of the newly deployed EzETHTarget0 instance. | ||
| function deploy( | ||
| IHyperdrive.PoolConfig memory _config, | ||
| bytes memory, // unused extra data | ||
| bytes32 _salt | ||
| ) external override returns (address) { | ||
| return | ||
| address( | ||
| // NOTE: We hash the sender with the salt to prevent the | ||
| // front-running of deployments. | ||
| new EzETHTarget0{ | ||
| salt: keccak256(abi.encode(msg.sender, _salt)) | ||
| }(_config, restakeManager) | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| pragma solidity 0.8.20; | ||
|
|
||
| import { IERC20 } from "../../interfaces/IERC20.sol"; | ||
| import { EzETHTarget1 } from "../../instances/ezeth/EzETHTarget1.sol"; | ||
| import { IHyperdrive } from "../../interfaces/IHyperdrive.sol"; | ||
| import { IHyperdriveTargetDeployer } from "../../interfaces/IHyperdriveTargetDeployer.sol"; | ||
| import { IRestakeManager } from "../../interfaces/IRenzo.sol"; | ||
|
|
||
| /// @author DELV | ||
| /// @title EzETHTarget1Deployer | ||
| /// @notice The target1 deployer for the EzETHHyperdrive implementation. | ||
| /// @custom:disclaimer The language used in this code is for coding convenience | ||
| /// only, and is not intended to, and does not, have any | ||
| /// particular legal or regulatory significance. | ||
| contract EzETHTarget1Deployer is IHyperdriveTargetDeployer { | ||
| /// @notice The Renzo contract. | ||
| IRestakeManager public immutable restakeManager; | ||
|
|
||
| /// @notice Instantiates the core deployer. | ||
| /// @param _restakeManager The Renzo contract. | ||
| constructor(IRestakeManager _restakeManager) { | ||
| restakeManager = _restakeManager; | ||
| } | ||
|
|
||
| /// @notice Deploys a target1 instance with the given parameters. | ||
| /// @param _config The configuration of the Hyperdrive pool. | ||
| /// @param _salt The create2 salt used in the deployment. | ||
| /// @return The address of the newly deployed EzETHTarget1 instance. | ||
| function deploy( | ||
| IHyperdrive.PoolConfig memory _config, | ||
| bytes memory, // unused extra data | ||
| bytes32 _salt | ||
| ) external returns (address) { | ||
| return | ||
| address( | ||
| // NOTE: We hash the sender with the salt to prevent the | ||
| // front-running of deployments. | ||
| new EzETHTarget1{ | ||
| salt: keccak256(abi.encode(msg.sender, _salt)) | ||
| }(_config, restakeManager) | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| pragma solidity 0.8.20; | ||
|
|
||
| import { IERC20 } from "../../interfaces/IERC20.sol"; | ||
| import { EzETHTarget2 } from "../../instances/ezeth/EzETHTarget2.sol"; | ||
| import { IHyperdrive } from "../../interfaces/IHyperdrive.sol"; | ||
| import { IHyperdriveTargetDeployer } from "../../interfaces/IHyperdriveTargetDeployer.sol"; | ||
| import { IRestakeManager } from "../../interfaces/IRenzo.sol"; | ||
|
|
||
| /// @author DELV | ||
| /// @title EzETHTarget2Deployer | ||
| /// @notice The target2 deployer for the EzETHHyperdrive implementation. | ||
| /// @custom:disclaimer The language used in this code is for coding convenience | ||
| /// only, and is not intended to, and does not, have any | ||
| /// particular legal or regulatory significance. | ||
| contract EzETHTarget2Deployer is IHyperdriveTargetDeployer { | ||
| /// @notice The Renzo contract. | ||
| IRestakeManager public immutable restakeManager; | ||
|
|
||
| /// @notice Instantiates the core deployer. | ||
| /// @param _restakeManager The Renzo contract. | ||
| constructor(IRestakeManager _restakeManager) { | ||
| restakeManager = _restakeManager; | ||
| } | ||
|
|
||
| /// @notice Deploys a target2 instance with the given parameters. | ||
| /// @param _config The configuration of the Hyperdrive pool. | ||
| /// @param _salt The create2 salt used in the deployment. | ||
| /// @return The address of the newly deployed EzETHTarget2 instance. | ||
| function deploy( | ||
| IHyperdrive.PoolConfig memory _config, | ||
| bytes memory, // unused extra data | ||
| bytes32 _salt | ||
| ) external returns (address) { | ||
| return | ||
| address( | ||
| // NOTE: We hash the sender with the salt to prevent the | ||
| // front-running of deployments. | ||
| new EzETHTarget2{ | ||
| salt: keccak256(abi.encode(msg.sender, _salt)) | ||
| }(_config, restakeManager) | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| pragma solidity 0.8.20; | ||
|
|
||
| import { IERC20 } from "../../interfaces/IERC20.sol"; | ||
| import { EzETHTarget3 } from "../../instances/ezeth/EzETHTarget3.sol"; | ||
| import { IHyperdrive } from "../../interfaces/IHyperdrive.sol"; | ||
| import { IHyperdriveTargetDeployer } from "../../interfaces/IHyperdriveTargetDeployer.sol"; | ||
| import { IRestakeManager } from "../../interfaces/IRenzo.sol"; | ||
|
|
||
| /// @author DELV | ||
| /// @title EzETHTarget3Deployer | ||
| /// @notice The target3 deployer for the EzETHHyperdrive implementation. | ||
| /// @custom:disclaimer The language used in this code is for coding convenience | ||
| /// only, and is not intended to, and does not, have any | ||
| /// particular legal or regulatory significance. | ||
| contract EzETHTarget3Deployer is IHyperdriveTargetDeployer { | ||
| /// @notice The Renzo contract. | ||
| IRestakeManager public immutable restakeManager; | ||
|
|
||
| /// @notice Instantiates the core deployer. | ||
| /// @param _restakeManager The Renzo contract. | ||
| constructor(IRestakeManager _restakeManager) { | ||
| restakeManager = _restakeManager; | ||
| } | ||
|
|
||
| /// @notice Deploys a target3 instance with the given parameters. | ||
| /// @param _config The configuration of the Hyperdrive pool. | ||
| /// @param _salt The create2 salt used in the deployment. | ||
| /// @return The address of the newly deployed EzETHTarget3 instance. | ||
| function deploy( | ||
| IHyperdrive.PoolConfig memory _config, | ||
| bytes memory, // unused extra data | ||
| bytes32 _salt | ||
| ) external returns (address) { | ||
| return | ||
| address( | ||
| // NOTE: We hash the sender with the salt to prevent the | ||
| // front-running of deployments. | ||
| new EzETHTarget3{ | ||
| salt: keccak256(abi.encode(msg.sender, _salt)) | ||
| }(_config, restakeManager) | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.