• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

delvtech / hyperdrive / 8732730472

18 Apr 2024 05:12AM UTC coverage: 93.378% (+0.04%) from 93.337%
8732730472

Pull #989

github

web-flow
Merge e5c94423d into 78a1b5959
Pull Request #989: Metadata Functions

2 of 2 new or added lines in 2 files covered. (100.0%)

52 existing lines in 7 files now uncovered.

1805 of 1933 relevant lines covered (93.38%)

383731.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.64
/contracts/src/deployers/ezeth/EzETHHyperdriveDeployerCoordinator.sol
1
// SPDX-License-Identifier: Apache-2.0
2
pragma solidity 0.8.20;
3

4
import { ERC20 } from "openzeppelin/token/ERC20/ERC20.sol";
5
import { SafeERC20 } from "openzeppelin/token/ERC20/utils/SafeERC20.sol";
6
import { IERC20 } from "../../interfaces/IERC20.sol";
7
import { IHyperdrive } from "../../interfaces/IHyperdrive.sol";
8
import { IHyperdriveDeployerCoordinator } from "../../interfaces/IHyperdriveDeployerCoordinator.sol";
9
import { IRestakeManager, IRenzoOracle } from "../../interfaces/IRenzo.sol";
10
import { ETH } from "../../libraries/Constants.sol";
11
import { FixedPointMath, ONE } from "../../libraries/FixedPointMath.sol";
12
import { HyperdriveDeployerCoordinator } from "../HyperdriveDeployerCoordinator.sol";
13

14
/// @author DELV
15
/// @title EzETHHyperdriveDeployerCoordinator
16
/// @custom:disclaimer The language used in this code is for coding convenience
17
/// @notice The deployer coordinator for the EzETHHyperdrive implementation.
18
///                    only, and is not intended to, and does not, have any
19
///                    particular legal or regulatory significance.
20
contract EzETHHyperdriveDeployerCoordinator is HyperdriveDeployerCoordinator {
21
    using SafeERC20 for ERC20;
22
    using FixedPointMath for uint256;
23

24
    /// @notice The deployer coordinator's name.
25
    string public constant override name = "EzETHHyperdriveDeployerCoordinator";
26

27
    /// @notice The deployer coordinator's version.
28
    string public constant override version = "v1.0.0";
29

30
    /// @notice The Renzo contract.
31
    IRestakeManager public immutable restakeManager;
32

33
    /// @notice The RenzoOracle contract.
34
    IRenzoOracle public immutable renzoOracle;
35

36
    /// @notice The ezETH token contract.
37
    IERC20 public immutable ezETH;
38

39
    /// @notice Instantiates the deployer coordinator.
40
    /// @param _factory The factory that this deployer will be registered with.
41
    /// @param _coreDeployer The core deployer.
42
    /// @param _target0Deployer The target0 deployer.
43
    /// @param _target1Deployer The target1 deployer.
44
    /// @param _target2Deployer The target2 deployer.
45
    /// @param _target3Deployer The target3 deployer.
46
    /// @param _target4Deployer The target4 deployer.
47
    /// @param _restakeManager The Renzo contract.
48
    constructor(
49
        address _factory,
50
        address _coreDeployer,
51
        address _target0Deployer,
52
        address _target1Deployer,
53
        address _target2Deployer,
54
        address _target3Deployer,
55
        address _target4Deployer,
56
        IRestakeManager _restakeManager
57
    )
58
        HyperdriveDeployerCoordinator(
59
            _factory,
60
            _coreDeployer,
61
            _target0Deployer,
62
            _target1Deployer,
63
            _target2Deployer,
64
            _target3Deployer,
65
            _target4Deployer
66
        )
67
    {
UNCOV
68
        restakeManager = _restakeManager;
×
UNCOV
69
        ezETH = IERC20(_restakeManager.ezETH());
×
UNCOV
70
        renzoOracle = IRenzoOracle(restakeManager.renzoOracle());
×
71
    }
72

73
    /// @dev Prepares the coordinator for initialization by drawing funds from
74
    ///      the LP, if necessary.
75
    /// @param _hyperdrive The Hyperdrive instance that is being initialized.
76
    /// @param _lp The LP that is initializing the pool.
77
    /// @param _contribution The amount of capital to supply. The units of this
78
    ///        quantity are either base or vault shares, depending on the value
79
    ///        of `_options.asBase`.
80
    /// @param _options The options that configure how the initialization is
81
    ///        settled.
82
    /// @return The value that should be sent in the initialize transaction.
83
    function _prepareInitialize(
84
        IHyperdrive _hyperdrive,
85
        address _lp,
86
        uint256 _contribution,
87
        IHyperdrive.Options memory _options
88
    ) internal override returns (uint256) {
89
        // Depositing as base is disallowed.
90
        if (_options.asBase) {
20✔
UNCOV
91
            revert IHyperdrive.UnsupportedToken();
×
92
        }
93

94
        // Otherwise, transfer vault shares from the LP and approve the
95
        // Hyperdrive pool.
96
        ERC20(address(ezETH)).safeTransferFrom(
40✔
97
            _lp,
98
            address(this),
99
            _contribution
100
        );
101
        ERC20(address(ezETH)).forceApprove(address(_hyperdrive), _contribution);
40✔
102

103
        // NOTE: Return zero since this yield source isn't payable.
104
        return 0;
40✔
105
    }
106

107
    /// @dev We override the message value check since this integration is not
108
    ///      payable.
109
    function _checkMessageValue() internal view override {
110
        if (msg.value != 0) {
42✔
111
            revert IHyperdrive.NotPayable();
2✔
112
        }
113
    }
114

115
    /// @notice Checks the pool configuration to ensure that it is valid.
116
    /// @param _deployConfig The deploy configuration of the Hyperdrive pool.
117
    function _checkPoolConfig(
118
        IHyperdrive.PoolDeployConfig memory _deployConfig
119
    ) internal view override {
120
        // Perform the default checks.
121
        super._checkPoolConfig(_deployConfig);
252✔
122

123
        // Ensure that the base token address is properly configured.
124
        if (address(_deployConfig.baseToken) != ETH) {
378✔
UNCOV
125
            revert IHyperdriveDeployerCoordinator.InvalidBaseToken();
×
126
        }
127

128
        // Ensure that the vault shares token address is properly configured.
129
        if (address(_deployConfig.vaultSharesToken) != address(ezETH)) {
504✔
UNCOV
130
            revert IHyperdriveDeployerCoordinator.InvalidVaultSharesToken();
×
131
        }
132

133
        // Ensure that the minimum share reserves are equal to 1e15. This value
134
        // has been tested to prevent arithmetic overflows in the
135
        // `_updateLiquidity` function when the share reserves are as high as
136
        // 200 million.
137
        if (_deployConfig.minimumShareReserves != 1e15) {
252✔
UNCOV
138
            revert IHyperdriveDeployerCoordinator.InvalidMinimumShareReserves();
×
139
        }
140

141
        // Ensure that the minimum transaction amount are equal to 1e15. This
142
        // value has been tested to prevent precision issues.
143
        if (_deployConfig.minimumTransactionAmount != 1e15) {
252✔
UNCOV
144
            revert IHyperdriveDeployerCoordinator
×
145
                .InvalidMinimumTransactionAmount();
146
        }
147
    }
148

149
    /// @dev Gets the initial vault share price of the Hyperdrive pool.
150
    /// @return The initial vault share price of the Hyperdrive pool.
151
    function _getInitialVaultSharePrice(
152
        IHyperdrive.PoolDeployConfig memory, // unused pool deploy config
153
        bytes memory // unused extra data
154
    ) internal view override returns (uint256) {
155
        // Get the total TVL priced in ETH from restakeManager
156
        (, , uint256 totalTVL) = restakeManager.calculateTVLs();
63✔
157

158
        // Get the total supply of the ezETH token
159
        uint256 totalSupply = ezETH.totalSupply();
63✔
160

161
        return renzoOracle.calculateRedeemAmount(ONE, totalSupply, totalTVL);
63✔
162
    }
163
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc