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

delvtech / hyperdrive / 8562121120

04 Apr 2024 10:27PM UTC coverage: 91.616%. First build
8562121120

push

github

web-flow
Fixed documentation nits (#935)

* Updated documentation

* Fixed the `RETHHyperdrive` test

0 of 1 new or added line in 1 file covered. (0.0%)

1650 of 1801 relevant lines covered (91.62%)

418126.39 hits per line

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

0.0
/contracts/src/deployers/reth/RETHHyperdriveDeployerCoordinator.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 { IHyperdrive } from "../../interfaces/IHyperdrive.sol";
7
import { IHyperdriveDeployerCoordinator } from "../../interfaces/IHyperdriveDeployerCoordinator.sol";
8
import { IRocketTokenRETH } from "../../interfaces/IRocketTokenRETH.sol";
9
import { ETH } from "../../libraries/Constants.sol";
10
import { FixedPointMath, ONE } from "../../libraries/FixedPointMath.sol";
11
import { HyperdriveDeployerCoordinator } from "../HyperdriveDeployerCoordinator.sol";
12

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

23
    /// @dev The Rocket Token RETH contract.
24
    IRocketTokenRETH internal immutable rocketTokenReth;
25

26
    /// @notice Instantiates the deployer coordinator.
27
    /// @param _coreDeployer The core deployer.
28
    /// @param _target0Deployer The target0 deployer.
29
    /// @param _target1Deployer The target1 deployer.
30
    /// @param _target2Deployer The target2 deployer.
31
    /// @param _target3Deployer The target3 deployer.
32
    /// @param _target4Deployer The target4 deployer.
33
    /// @param _rocketTokenReth The rETH token contract.
34
    constructor(
35
        address _coreDeployer,
36
        address _target0Deployer,
37
        address _target1Deployer,
38
        address _target2Deployer,
39
        address _target3Deployer,
40
        address _target4Deployer,
41
        IRocketTokenRETH _rocketTokenReth
42
    )
43
        HyperdriveDeployerCoordinator(
44
            _coreDeployer,
45
            _target0Deployer,
46
            _target1Deployer,
47
            _target2Deployer,
48
            _target3Deployer,
49
            _target4Deployer
50
        )
51
    {
52
        rocketTokenReth = _rocketTokenReth;
53
    }
54

55
    /// @dev Prepares the coordinator for initialization by drawing funds from
56
    ///      the LP, if necessary.
57
    /// @param _hyperdrive The Hyperdrive instance that is being initialized.
58
    /// @param _lp The LP that is initializing the pool.
59
    /// @param _contribution The amount of capital to supply. The units of this
60
    ///        quantity are either base or vault shares, depending on the value
61
    ///        of `_options.asBase`.
62
    /// @param _options The options that configure how the initialization is
63
    ///        settled.
64
    /// @return The value that should be sent in the initialize transaction.
65
    function _prepareInitialize(
66
        IHyperdrive _hyperdrive,
67
        address _lp,
68
        uint256 _contribution,
69
        IHyperdrive.Options memory _options
70
    ) internal override returns (uint256) {
71
        // If base is the deposit asset, revert because depositing as base
72
        // is not supported for the rETH integration.
73
        if (_options.asBase) {
×
74
            revert IHyperdrive.UnsupportedToken();
×
75
        }
76

77
        // Otherwise, transfer vault shares from the LP and approve the
78
        // Hyperdrive pool.
79
        ERC20(address(rocketTokenReth)).safeTransferFrom(
×
80
            _lp,
81
            address(this),
82
            _contribution
83
        );
84
        ERC20(address(rocketTokenReth)).forceApprove(
×
85
            address(_hyperdrive),
86
            _contribution
87
        );
88

89
        // NOTE: Return zero since this yield source isn't payable.
90
        return 0;
×
91
    }
92

93
    /// @dev Disallows the contract to receive ether, when opening positions.
94
    function _checkMessageValue() internal view override {
95
        if (msg.value > 0) {
×
96
            revert IHyperdrive.NotPayable();
×
97
        }
98
    }
99

100
    /// @notice Checks the pool configuration to ensure that it is valid.
101
    /// @param _deployConfig The deploy configuration of the Hyperdrive pool.
102
    function _checkPoolConfig(
103
        IHyperdrive.PoolDeployConfig memory _deployConfig
104
    ) internal view override {
105
        // Perform the default checks.
106
        super._checkPoolConfig(_deployConfig);
×
107

108
        // Ensure that the base token address is properly configured.
109
        if (address(_deployConfig.baseToken) != ETH) {
×
110
            revert IHyperdriveDeployerCoordinator.InvalidBaseToken();
×
111
        }
112

113
        // Ensure that the vault shares token address is properly configured.
114
        if (
115
            address(_deployConfig.vaultSharesToken) != address(rocketTokenReth)
×
116
        ) {
117
            revert IHyperdriveDeployerCoordinator.InvalidVaultSharesToken();
×
118
        }
119

120
        // Ensure that the minimum share reserves are equal to 1e15. This value
121
        // has been tested to prevent arithmetic overflows in the
122
        // `_updateLiquidity` function when the share reserves are as high as
123
        // 200 million.
124
        if (_deployConfig.minimumShareReserves != 1e15) {
×
125
            revert IHyperdriveDeployerCoordinator.InvalidMinimumShareReserves();
×
126
        }
127

128
        // Ensure that the minimum transaction amount are equal to 1e15. This
129
        // value has been tested to prevent precision issues.
NEW
130
        if (_deployConfig.minimumTransactionAmount != 1e15) {
×
131
            revert IHyperdriveDeployerCoordinator
×
132
                .InvalidMinimumTransactionAmount();
133
        }
134
    }
135

136
    /// @dev Gets the initial vault share price of the Hyperdrive pool.
137
    /// @return The initial vault share price of the Hyperdrive pool.
138
    function _getInitialVaultSharePrice(
139
        IHyperdrive.PoolDeployConfig memory, // unused pool deploy config
140
        bytes memory // unused extra data
141
    ) internal view override returns (uint256) {
142
        // Returns the value of one RETH token in ETH.
143
        return rocketTokenReth.getEthValue(ONE);
×
144
    }
145
}
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