• 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

61.11
/contracts/src/deployers/steth/StETHHyperdriveDeployerCoordinator.sol
1
// SPDX-License-Identifier: Apache-2.0
2
pragma solidity 0.8.20;
3

4
import { IHyperdrive } from "../../interfaces/IHyperdrive.sol";
5
import { IHyperdriveDeployerCoordinator } from "../../interfaces/IHyperdriveDeployerCoordinator.sol";
6
import { ILido } from "../../interfaces/ILido.sol";
7
import { ETH } from "../../libraries/Constants.sol";
8
import { FixedPointMath, ONE } from "../../libraries/FixedPointMath.sol";
9
import { HyperdriveDeployerCoordinator } from "../HyperdriveDeployerCoordinator.sol";
10

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

20
    /// @notice The deployer coordinator's name.
21
    string public constant override name = "StETHHyperdriveDeployerCoordinator";
22

23
    /// @notice The deployer coordinator's version.
24
    string public constant override version = "v1.0.0";
25

26
    /// @notice The Lido contract.
27
    ILido public immutable lido;
28

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

61
    /// @dev Prepares the coordinator for initialization by drawing funds from
62
    ///      the LP, if necessary.
63
    /// @param _hyperdrive The Hyperdrive instance that is being initialized.
64
    /// @param _lp The LP that is initializing the pool.
65
    /// @param _contribution The amount of capital to supply. The units of this
66
    ///        quantity are either base or vault shares, depending on the value
67
    ///        of `_options.asBase`.
68
    /// @param _options The options that configure how the initialization is
69
    ///        settled.
70
    /// @return value The value that should be sent in the initialize
71
    ///         transaction.
72
    function _prepareInitialize(
73
        IHyperdrive _hyperdrive,
74
        address _lp,
75
        uint256 _contribution,
76
        IHyperdrive.Options memory _options
77
    ) internal override returns (uint256 value) {
78
        // If base is the deposit asset, ensure that enough ether was sent to
79
        // the contract and return the amount of ether that should be sent for
80
        // the contribution.
81
        if (_options.asBase) {
22✔
82
            if (msg.value < _contribution) {
4✔
UNCOV
83
                revert IHyperdriveDeployerCoordinator.InsufficientValue();
×
84
            }
85
            value = _contribution;
4✔
86
        }
87
        // Otherwise, transfer vault shares from the LP and approve the
88
        // Hyperdrive pool.
89
        else {
90
            uint256 approvalAmount = lido.transferSharesFrom(
60✔
91
                _lp,
92
                address(this),
93
                _contribution
94
            );
95
            lido.approve(address(_hyperdrive), approvalAmount);
40✔
96
        }
97

UNCOV
98
        return value;
×
99
    }
100

101
    /// @dev Allows the contract to receive ether.
102
    function _checkMessageValue() internal view override {}
103

104
    /// @notice Checks the pool configuration to ensure that it is valid.
105
    /// @param _deployConfig The deploy configuration of the Hyperdrive pool.
106
    function _checkPoolConfig(
107
        IHyperdrive.PoolDeployConfig memory _deployConfig
108
    ) internal view override {
109
        // Perform the default checks.
110
        super._checkPoolConfig(_deployConfig);
264✔
111

112
        // Ensure that the base token address is properly configured.
113
        if (address(_deployConfig.baseToken) != ETH) {
396✔
UNCOV
114
            revert IHyperdriveDeployerCoordinator.InvalidBaseToken();
×
115
        }
116

117
        // Ensure that the vault shares token address is properly configured.
118
        if (address(_deployConfig.vaultSharesToken) != address(lido)) {
528✔
UNCOV
119
            revert IHyperdriveDeployerCoordinator.InvalidVaultSharesToken();
×
120
        }
121

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

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

138
    /// @dev Gets the initial vault share price of the Hyperdrive pool.
139
    /// @return The initial vault share price of the Hyperdrive pool.
140
    function _getInitialVaultSharePrice(
141
        IHyperdrive.PoolDeployConfig memory, // unused pool deploy config
142
        bytes memory // unused extra data
143
    ) internal view override returns (uint256) {
144
        // Return stETH's current vault share price.
145
        return lido.getPooledEthByShares(ONE);
66✔
146
    }
147
}
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