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

delvtech / hyperdrive / 9179140169

21 May 2024 05:53PM UTC coverage: 88.259% (-2.8%) from 91.088%
9179140169

push

github

cashd
wip

16 of 32 new or added lines in 4 files covered. (50.0%)

77 existing lines in 15 files now uncovered.

1774 of 2010 relevant lines covered (88.26%)

371757.72 hits per line

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

36.36
/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 Renzo contract.
28
    IRestakeManager public immutable restakeManager;
29

30
    /// @notice The RenzoOracle contract.
31
    IRenzoOracle public immutable renzoOracle;
32

33
    /// @notice The ezETH token contract.
34
    IERC20 public immutable ezETH;
35

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

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

91
        // Otherwise, transfer vault shares from the LP and approve the
92
        // Hyperdrive pool.
UNCOV
93
        ERC20(address(ezETH)).safeTransferFrom(
×
94
            _lp,
95
            address(this),
96
            _contribution
97
        );
UNCOV
98
        ERC20(address(ezETH)).forceApprove(address(_hyperdrive), _contribution);
×
99

100
        // NOTE: Return zero since this yield source isn't payable.
UNCOV
101
        return 0;
×
102
    }
103

104
    /// @dev We override the message value check since this integration is not
105
    ///      payable.
106
    function _checkMessageValue() internal view override {
UNCOV
107
        if (msg.value != 0) {
×
UNCOV
108
            revert IHyperdrive.NotPayable();
×
109
        }
110
    }
111

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

120
        // Ensure that the base token address is properly configured.
121
        if (address(_deployConfig.baseToken) != ETH) {
15✔
122
            revert IHyperdriveDeployerCoordinator.InvalidBaseToken();
×
123
        }
124

125
        // Ensure that the vault shares token address is properly configured.
126
        if (address(_deployConfig.vaultSharesToken) != address(ezETH)) {
20✔
127
            revert IHyperdriveDeployerCoordinator.InvalidVaultSharesToken();
×
128
        }
129

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

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

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

155
        // Get the total supply of the ezETH token
156
        uint256 totalSupply = ezETH.totalSupply();
3✔
157

158
        return renzoOracle.calculateRedeemAmount(ONE, totalSupply, totalTVL);
3✔
159
    }
160
}
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