Skip to content
Merged
Show file tree
Hide file tree
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 Mar 13, 2024
bed3b07
Add initialize tests for the deployer coordinator
jalextowle Mar 13, 2024
eccb971
copy steth integration
sentilesdal Feb 29, 2024
08c6bbb
rename files
sentilesdal Feb 29, 2024
c4b5269
stEth -> ezEth
sentilesdal Feb 29, 2024
ee2354a
add interfaces
sentilesdal Feb 29, 2024
d575c59
add IRestakeManager interface
sentilesdal Feb 29, 2024
7c39431
lido -> restakeManager
sentilesdal Mar 11, 2024
3e55629
remove lido, update deposit method
sentilesdal Mar 12, 2024
a22d33b
copy steth test file
sentilesdal Mar 12, 2024
d9436a8
capitalize name
sentilesdal Mar 12, 2024
7e6ffc6
update deposit/withdraw functions
sentilesdal Mar 12, 2024
668f61a
add deployers
sentilesdal Mar 12, 2024
541a75e
fixup deployers
sentilesdal Mar 12, 2024
16bcaad
add ezETH to deployers
sentilesdal Mar 13, 2024
3b78692
add ezETH to instances
sentilesdal Mar 13, 2024
449f6ab
add calculateTVLs to interface
sentilesdal Mar 13, 2024
71424fb
add and cleanup tests
sentilesdal Mar 14, 2024
709bbf3
remove ezETH from constructors
sentilesdal Mar 14, 2024
a728926
update tests
sentilesdal Mar 14, 2024
86ea5da
fix remaining tests
sentilesdal Mar 15, 2024
9f0b18e
small cleanups
sentilesdal Mar 15, 2024
85a415b
wrap comment
sentilesdal Mar 15, 2024
01e4ede
address nit fixes
sentilesdal Mar 15, 2024
8500531
remove IEzETHHyperdriveCore.sol
sentilesdal Mar 15, 2024
ceb6b3c
remove unused import
sentilesdal Mar 15, 2024
848e107
add IRenzoOracle, combine interface files
sentilesdal Mar 15, 2024
c3ea825
update imports
sentilesdal Mar 15, 2024
943ae52
final nits addressed
sentilesdal Mar 16, 2024
c40feeb
fix capitalization
sentilesdal Mar 16, 2024
f7eda2b
capitalization
sentilesdal Mar 16, 2024
0c75476
asdf.sol
sentilesdal Mar 16, 2024
60ea094
rename
sentilesdal Mar 16, 2024
60fda4b
don't allow ETH txns
sentilesdal Mar 16, 2024
542849e
disable ETH for deployAndInitialize
sentilesdal Mar 16, 2024
9b161f6
update tests
sentilesdal Mar 17, 2024
2440c71
remove consoles
sentilesdal Mar 17, 2024
2b2a340
small nits
sentilesdal Mar 17, 2024
1452c58
fix revert tests
sentilesdal Mar 17, 2024
133d830
all tess passing
sentilesdal Mar 17, 2024
bbda5d1
remove unused code
sentilesdal Mar 18, 2024
6c8016b
cleanup
sentilesdal Mar 18, 2024
4f23503
last fixups
sentilesdal Mar 18, 2024
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
63 changes: 63 additions & 0 deletions contracts/src/deployers/ezeth/EzETHHyperdriveCoreDeployer.sol
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 contracts/src/deployers/ezeth/EzETHHyperdriveDeployerCoordinator.sol
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;
}

/// @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);
}
}
44 changes: 44 additions & 0 deletions contracts/src/deployers/ezeth/EzETHTarget0Deployer.sol
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)
);
}
}
44 changes: 44 additions & 0 deletions contracts/src/deployers/ezeth/EzETHTarget1Deployer.sol
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)
);
}
}
44 changes: 44 additions & 0 deletions contracts/src/deployers/ezeth/EzETHTarget2Deployer.sol
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)
);
}
}
44 changes: 44 additions & 0 deletions contracts/src/deployers/ezeth/EzETHTarget3Deployer.sol
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)
);
}
}
Loading