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

delvtech / hyperdrive / 9928368899

14 Jul 2024 01:43PM UTC coverage: 92.237%. First build
9928368899

Pull #1081

github

jalextowle
Added a getter for Aave's vault
Pull Request #1081: Added an Aave integration

120 of 143 new or added lines in 33 files covered. (83.92%)

2115 of 2293 relevant lines covered (92.24%)

376490.5 hits per line

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

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

4
import { StETHConversions } from "../../instances/steth/StETHConversions.sol";
5
import { IERC20 } from "../../interfaces/IERC20.sol";
6
import { IHyperdrive } from "../../interfaces/IHyperdrive.sol";
7
import { IHyperdriveDeployerCoordinator } from "../../interfaces/IHyperdriveDeployerCoordinator.sol";
8
import { ILido } from "../../interfaces/ILido.sol";
9
import { IStETHHyperdriveDeployerCoordinator } from "../../interfaces/IStETHHyperdriveDeployerCoordinator.sol";
10
import { ETH, STETH_HYPERDRIVE_DEPLOYER_COORDINATOR_KIND } from "../../libraries/Constants.sol";
11
import { FixedPointMath, ONE } from "../../libraries/FixedPointMath.sol";
12
import { HyperdriveDeployerCoordinator } from "../HyperdriveDeployerCoordinator.sol";
13

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

26
    /// @notice The deployer coordinator's kind.
27
    string
28
        public constant
29
        override(
30
            HyperdriveDeployerCoordinator,
31
            IHyperdriveDeployerCoordinator
32
        ) kind = STETH_HYPERDRIVE_DEPLOYER_COORDINATOR_KIND;
33

34
    /// @notice The Lido contract.
35
    ILido public immutable lido;
36

37
    /// @notice Instantiates the deployer coordinator.
38
    /// @param _name The deployer coordinator's name.
39
    /// @param _factory The factory that this deployer will be registered with.
40
    /// @param _coreDeployer The core deployer.
41
    /// @param _target0Deployer The target0 deployer.
42
    /// @param _target1Deployer The target1 deployer.
43
    /// @param _target2Deployer The target2 deployer.
44
    /// @param _target3Deployer The target3 deployer.
45
    /// @param _target4Deployer The target4 deployer.
46
    /// @param _lido The Lido contract.
47
    constructor(
48
        string memory _name,
49
        address _factory,
50
        address _coreDeployer,
51
        address _target0Deployer,
52
        address _target1Deployer,
53
        address _target2Deployer,
54
        address _target3Deployer,
55
        address _target4Deployer,
56
        ILido _lido
57
    )
58
        HyperdriveDeployerCoordinator(
59
            _name,
60
            _factory,
61
            _coreDeployer,
62
            _target0Deployer,
63
            _target1Deployer,
64
            _target2Deployer,
65
            _target3Deployer,
66
            _target4Deployer
67
        )
68
    {
69
        lido = _lido;
×
70
    }
71

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

109
        return value;
×
110
    }
111

112
    /// @notice Convert an amount of vault shares to an amount of base.
113
    /// @param _vaultSharesToken The vault shares asset.
114
    /// @param _shareAmount The vault shares amount.
115
    /// @return The base amount.
116
    function convertToBase(
117
        IERC20 _vaultSharesToken,
118
        uint256 _shareAmount
119
    ) public view returns (uint256) {
120
        return StETHConversions.convertToBase(_vaultSharesToken, _shareAmount);
23✔
121
    }
122

123
    /// @notice Convert an amount of base to an amount of vault shares.
124
    /// @param _vaultSharesToken The vault shares asset.
125
    /// @param _baseAmount The base amount.
126
    /// @return The vault shares amount.
127
    function convertToShares(
128
        IERC20 _vaultSharesToken,
129
        uint256 _baseAmount
130
    ) public view returns (uint256) {
NEW
131
        return StETHConversions.convertToShares(_vaultSharesToken, _baseAmount);
×
132
    }
133

134
    /// @dev We override the message value check since this integration is
135
    ///      payable.
136
    function _checkMessageValue() internal view override {}
137

138
    /// @notice Checks the pool configuration to ensure that it is valid.
139
    /// @param _deployConfig The deploy configuration of the Hyperdrive pool.
140
    function _checkPoolConfig(
141
        IHyperdrive.PoolDeployConfig memory _deployConfig
142
    ) internal view override {
143
        // Perform the default checks.
144
        super._checkPoolConfig(_deployConfig);
138✔
145

146
        // Ensure that the base token address is properly configured.
147
        if (address(_deployConfig.baseToken) != ETH) {
138✔
148
            revert IHyperdriveDeployerCoordinator.InvalidBaseToken();
×
149
        }
150

151
        // Ensure that the vault shares token address is properly configured.
152
        if (address(_deployConfig.vaultSharesToken) != address(lido)) {
138✔
153
            revert IHyperdriveDeployerCoordinator.InvalidVaultSharesToken();
×
154
        }
155

156
        // Ensure that the minimum share reserves are equal to 1e15. This value
157
        // has been tested to prevent arithmetic overflows in the
158
        // `_updateLiquidity` function when the share reserves are as high as
159
        // 200 million.
160
        if (_deployConfig.minimumShareReserves != 1e15) {
138✔
161
            revert IHyperdriveDeployerCoordinator.InvalidMinimumShareReserves();
×
162
        }
163

164
        // Ensure that the minimum transaction amount are equal to 1e15. This
165
        // value has been tested to prevent precision issues.
166
        if (_deployConfig.minimumTransactionAmount != 1e15) {
138✔
167
            revert IHyperdriveDeployerCoordinator
×
168
                .InvalidMinimumTransactionAmount();
169
        }
170
    }
171

172
    /// @dev Gets the initial vault share price of the Hyperdrive pool.
173
    /// @param _deployConfig The deploy configuration of the Hyperdrive pool.
174
    /// @return The initial vault share price of the Hyperdrive pool.
175
    function _getInitialVaultSharePrice(
176
        IHyperdrive.PoolDeployConfig memory _deployConfig,
177
        bytes memory // unused extra data
178
    ) internal view override returns (uint256) {
179
        return convertToBase(_deployConfig.vaultSharesToken, ONE);
23✔
180
    }
181
}
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