• 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

33.33
/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
    /// @dev The LsETH contract.
27
    IRiverV1 internal immutable river;
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 _river The LsETH 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
        IRiverV1 _river
47
    )
48
        HyperdriveDeployerCoordinator(
49
            _factory,
50
            _coreDeployer,
51
            _target0Deployer,
52
            _target1Deployer,
53
            _target2Deployer,
54
            _target3Deployer,
55
            _target4Deployer
56
        )
57
    {
58
        river = _river;
×
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 The value that should be sent in the initialize transaction.
71
    function _prepareInitialize(
72
        IHyperdrive _hyperdrive,
73
        address _lp,
74
        uint256 _contribution,
75
        IHyperdrive.Options memory _options
76
    ) internal override returns (uint256) {
77
        // Depositing as base is disallowed.
UNCOV
78
        if (_options.asBase) {
×
79
            revert IHyperdrive.UnsupportedToken();
×
80
        }
81

82
        // Transfer vault shares from the LP and approve the
83
        // Hyperdrive pool.
UNCOV
84
        ERC20(address(river)).safeTransferFrom(
×
85
            _lp,
86
            address(this),
87
            _contribution
88
        );
UNCOV
89
        ERC20(address(river)).forceApprove(address(_hyperdrive), _contribution);
×
90

91
        // NOTE: Return zero since this yield source isn't payable.
UNCOV
92
        return 0;
×
93
    }
94

95
    /// @dev We override the message value check since this integration is
96
    ///      not payable.
97
    function _checkMessageValue() internal view override {
UNCOV
98
        if (msg.value != 0) {
×
UNCOV
99
            revert IHyperdrive.NotPayable();
×
100
        }
101
    }
102

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

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

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

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

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

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