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

delvtech / hyperdrive / 9927927593

14 Jul 2024 12:26PM UTC coverage: 92.277%. First build
9927927593

Pull #1081

github

web-flow
Merge e5af82277 into 683f2f7cd
Pull Request #1081: Added an Aave integration

120 of 142 new or added lines in 33 files covered. (84.51%)

2115 of 2292 relevant lines covered (92.28%)

376654.76 hits per line

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

60.0
/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 { EzETHConversions } from "../../instances/ezeth/EzETHConversions.sol";
7
import { IERC20 } from "../../interfaces/IERC20.sol";
8
import { IEzETHHyperdriveDeployerCoordinator } from "../../interfaces/IEzETHHyperdriveDeployerCoordinator.sol";
9
import { IHyperdrive } from "../../interfaces/IHyperdrive.sol";
10
import { IHyperdriveDeployerCoordinator } from "../../interfaces/IHyperdriveDeployerCoordinator.sol";
11
import { IRestakeManager, IRenzoOracle } from "../../interfaces/IRenzo.sol";
12
import { ETH, EZETH_HYPERDRIVE_DEPLOYER_COORDINATOR_KIND } from "../../libraries/Constants.sol";
13
import { FixedPointMath, ONE } from "../../libraries/FixedPointMath.sol";
14
import { HyperdriveDeployerCoordinator } from "../HyperdriveDeployerCoordinator.sol";
15

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

29
    /// @notice The deployer coordinator's kind.
30
    string
31
        public constant
32
        override(
33
            HyperdriveDeployerCoordinator,
34
            IHyperdriveDeployerCoordinator
35
        ) kind = EZETH_HYPERDRIVE_DEPLOYER_COORDINATOR_KIND;
36

37
    /// @notice The Renzo contract.
38
    IRestakeManager public immutable restakeManager;
39

40
    /// @notice The RenzoOracle contract.
41
    IRenzoOracle public immutable renzoOracle;
42

43
    /// @notice The ezETH token contract.
44
    IERC20 public immutable ezETH;
45

46
    /// @notice Instantiates the deployer coordinator.
47
    /// @param _name The deployer coordinator's name.
48
    /// @param _factory The factory that this deployer will be registered with.
49
    /// @param _coreDeployer The core deployer.
50
    /// @param _target0Deployer The target0 deployer.
51
    /// @param _target1Deployer The target1 deployer.
52
    /// @param _target2Deployer The target2 deployer.
53
    /// @param _target3Deployer The target3 deployer.
54
    /// @param _target4Deployer The target4 deployer.
55
    /// @param _restakeManager The Renzo contract.
56
    constructor(
57
        string memory _name,
58
        address _factory,
59
        address _coreDeployer,
60
        address _target0Deployer,
61
        address _target1Deployer,
62
        address _target2Deployer,
63
        address _target3Deployer,
64
        address _target4Deployer,
65
        IRestakeManager _restakeManager
66
    )
67
        HyperdriveDeployerCoordinator(
68
            _name,
69
            _factory,
70
            _coreDeployer,
71
            _target0Deployer,
72
            _target1Deployer,
73
            _target2Deployer,
74
            _target3Deployer,
75
            _target4Deployer
76
        )
77
    {
78
        restakeManager = _restakeManager;
×
79
        ezETH = IERC20(_restakeManager.ezETH());
×
80
        renzoOracle = IRenzoOracle(restakeManager.renzoOracle());
×
81
    }
82

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

104
        // Otherwise, transfer vault shares from the LP and approve the
105
        // Hyperdrive pool.
106
        ERC20(address(ezETH)).safeTransferFrom(
21✔
107
            _lp,
108
            address(this),
109
            _contribution
110
        );
111
        ERC20(address(ezETH)).forceApprove(address(_hyperdrive), _contribution);
21✔
112

113
        // NOTE: Return zero since this yield source isn't payable.
114
        return 0;
21✔
115
    }
116

117
    /// @notice Convert an amount of vault shares to an amount of base.
118
    /// @param _renzoOracle The RenzoOracle contract.
119
    /// @param _restakeManager The Renzo entrypoint contract.
120
    /// @param _vaultSharesToken The vault shares asset.
121
    /// @param _shareAmount The vault shares amount.
122
    /// @return The base amount.
123
    function convertToBase(
124
        IRenzoOracle _renzoOracle,
125
        IRestakeManager _restakeManager,
126
        IERC20 _vaultSharesToken,
127
        uint256 _shareAmount
128
    ) public view returns (uint256) {
129
        return
22✔
130
            EzETHConversions.convertToBase(
22✔
131
                _renzoOracle,
132
                _restakeManager,
133
                _vaultSharesToken,
134
                _shareAmount
135
            );
136
    }
137

138
    /// @notice Convert an amount of base to an amount of vault shares.
139
    /// @param _renzoOracle The RenzoOracle contract.
140
    /// @param _restakeManager The Renzo entrypoint contract.
141
    /// @param _vaultSharesToken The vault shares asset.
142
    /// @param _baseAmount The base amount.
143
    /// @return The vault shares amount.
144
    function convertToShares(
145
        IRenzoOracle _renzoOracle,
146
        IRestakeManager _restakeManager,
147
        IERC20 _vaultSharesToken,
148
        uint256 _baseAmount
149
    ) public view returns (uint256) {
NEW
150
        return
×
NEW
151
            EzETHConversions.convertToShares(
×
152
                _renzoOracle,
153
                _restakeManager,
154
                _vaultSharesToken,
155
                _baseAmount
156
            );
157
    }
158

159
    /// @dev We override the message value check since this integration is
160
    ///      not payable.
161
    function _checkMessageValue() internal view override {
162
        if (msg.value != 0) {
22✔
163
            revert IHyperdrive.NotPayable();
1✔
164
        }
165
    }
166

167
    /// @notice Checks the pool configuration to ensure that it is valid.
168
    /// @param _deployConfig The deploy configuration of the Hyperdrive pool.
169
    function _checkPoolConfig(
170
        IHyperdrive.PoolDeployConfig memory _deployConfig
171
    ) internal view override {
172
        // Perform the default checks.
173
        super._checkPoolConfig(_deployConfig);
132✔
174

175
        // Ensure that the base token address is properly configured.
176
        if (address(_deployConfig.baseToken) != ETH) {
132✔
177
            revert IHyperdriveDeployerCoordinator.InvalidBaseToken();
×
178
        }
179

180
        // Ensure that the vault shares token address is properly configured.
181
        if (address(_deployConfig.vaultSharesToken) != address(ezETH)) {
132✔
182
            revert IHyperdriveDeployerCoordinator.InvalidVaultSharesToken();
×
183
        }
184

185
        // Ensure that the minimum share reserves are equal to 1e15. This value
186
        // has been tested to prevent arithmetic overflows in the
187
        // `_updateLiquidity` function when the share reserves are as high as
188
        // 200 million.
189
        if (_deployConfig.minimumShareReserves != 1e15) {
132✔
190
            revert IHyperdriveDeployerCoordinator.InvalidMinimumShareReserves();
×
191
        }
192

193
        // Ensure that the minimum transaction amount are equal to 1e15. This
194
        // value has been tested to prevent precision issues.
195
        if (_deployConfig.minimumTransactionAmount != 1e15) {
132✔
196
            revert IHyperdriveDeployerCoordinator
×
197
                .InvalidMinimumTransactionAmount();
198
        }
199
    }
200

201
    /// @dev Gets the initial vault share price of the Hyperdrive pool.
202
    /// @param _deployConfig The deploy configuration of the Hyperdrive pool.
203
    /// @return The initial vault share price of the Hyperdrive pool.
204
    function _getInitialVaultSharePrice(
205
        IHyperdrive.PoolDeployConfig memory _deployConfig,
206
        bytes memory // unused extra data
207
    ) internal view override returns (uint256) {
208
        return
22✔
209
            convertToBase(
22✔
210
                renzoOracle,
211
                restakeManager,
212
                _deployConfig.vaultSharesToken,
213
                ONE
214
            );
215
    }
216
}
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