• 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

50.0
/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 Lido contract.
24
    ILido public immutable lido;
25

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

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

95
        return value;
×
96
    }
97

98
    /// @dev Allows the contract to receive ether.
99
    function _checkMessageValue() internal view override {}
100

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

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

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

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

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

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