• 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

66.67
/contracts/src/deployers/lseth/LsETHHyperdriveDeployerCoordinator.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 { IRiverV1 } from "../../interfaces/IRiverV1.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 LsETHHyperdriveDeployerCoordinator
15
/// @notice The deployer coordinator for the LsETHHyperdrive 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 LsETHHyperdriveDeployerCoordinator 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 = "LsETHHyperdriveDeployerCoordinator";
25

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

29
    /// @dev The LsETH contract.
30
    IRiverV1 internal immutable river;
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 _river The LsETH 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
        IRiverV1 _river
50
    )
51
        HyperdriveDeployerCoordinator(
52
            _factory,
53
            _coreDeployer,
54
            _target0Deployer,
55
            _target1Deployer,
56
            _target2Deployer,
57
            _target3Deployer,
58
            _target4Deployer
59
        )
60
    {
UNCOV
61
        river = _river;
×
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
        // Depositing as base is disallowed.
81
        if (_options.asBase) {
38✔
UNCOV
82
            revert IHyperdrive.UnsupportedToken();
×
83
        }
84

85
        // Transfer vault shares from the LP and approve the
86
        // Hyperdrive pool.
87
        ERC20(address(river)).safeTransferFrom(
76✔
88
            _lp,
89
            address(this),
90
            _contribution
91
        );
92
        ERC20(address(river)).forceApprove(address(_hyperdrive), _contribution);
76✔
93

94
        // NOTE: Return zero since this yield source isn't payable.
95
        return 0;
76✔
96
    }
97

98
    /// @dev We override the message value check since this integration is
99
    ///      not payable.
100
    function _checkMessageValue() internal view override {
101
        if (msg.value != 0) {
80✔
102
            revert IHyperdrive.NotPayable();
4✔
103
        }
104
    }
105

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

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

119
        // Ensure that the vault shares token address is properly configured.
120
        if (address(_deployConfig.vaultSharesToken) != address(river)) {
960✔
UNCOV
121
            revert IHyperdriveDeployerCoordinator.InvalidVaultSharesToken();
×
122
        }
123

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

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

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