• 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

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
    /// @notice The deployer coordinator's name.
24
    string public constant override name = "RETHHyperdriveDeployerCoordinator";
25

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

29
    /// @dev The Rocket Token RETH contract.
30
    IRocketTokenRETH internal immutable rocketTokenReth;
31

32
    /// @notice Instantiates the deployer coordinator.
33
    /// @param _factory The factory that this deployer will be registered with.
34
    /// @param _coreDeployer The core deployer.
35
    /// @param _target0Deployer The target0 deployer.
36
    /// @param _target1Deployer The target1 deployer.
37
    /// @param _target2Deployer The target2 deployer.
38
    /// @param _target3Deployer The target3 deployer.
39
    /// @param _target4Deployer The target4 deployer.
40
    /// @param _rocketTokenReth The rETH token contract.
41
    constructor(
42
        address _factory,
43
        address _coreDeployer,
44
        address _target0Deployer,
45
        address _target1Deployer,
46
        address _target2Deployer,
47
        address _target3Deployer,
48
        address _target4Deployer,
49
        IRocketTokenRETH _rocketTokenReth
50
    )
51
        HyperdriveDeployerCoordinator(
52
            _factory,
53
            _coreDeployer,
54
            _target0Deployer,
55
            _target1Deployer,
56
            _target2Deployer,
57
            _target3Deployer,
58
            _target4Deployer
59
        )
60
    {
UNCOV
61
        rocketTokenReth = _rocketTokenReth;
×
62
    }
63

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

86
        // Otherwise, transfer vault shares from the LP and approve the
87
        // Hyperdrive pool.
UNCOV
88
        ERC20(address(rocketTokenReth)).safeTransferFrom(
×
89
            _lp,
90
            address(this),
91
            _contribution
92
        );
UNCOV
93
        ERC20(address(rocketTokenReth)).forceApprove(
×
94
            address(_hyperdrive),
95
            _contribution
96
        );
97

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

102
    /// @dev Disallows the contract to receive ether, when opening positions.
103
    function _checkMessageValue() internal view override {
UNCOV
104
        if (msg.value != 0) {
×
UNCOV
105
            revert IHyperdrive.NotPayable();
×
106
        }
107
    }
108

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

117
        // Ensure that the base token address is properly configured.
UNCOV
118
        if (address(_deployConfig.baseToken) != ETH) {
×
UNCOV
119
            revert IHyperdriveDeployerCoordinator.InvalidBaseToken();
×
120
        }
121

122
        // Ensure that the vault shares token address is properly configured.
123
        if (
UNCOV
124
            address(_deployConfig.vaultSharesToken) != address(rocketTokenReth)
×
125
        ) {
UNCOV
126
            revert IHyperdriveDeployerCoordinator.InvalidVaultSharesToken();
×
127
        }
128

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

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

145
    /// @dev Gets the initial vault share price of the Hyperdrive pool.
146
    /// @return The initial vault share price of the Hyperdrive pool.
147
    function _getInitialVaultSharePrice(
148
        IHyperdrive.PoolDeployConfig memory, // unused pool deploy config
149
        bytes memory // unused extra data
150
    ) internal view override returns (uint256) {
151
        // Returns the value of one RETH token in ETH.
UNCOV
152
        return rocketTokenReth.getEthValue(ONE);
×
153
    }
154
}
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