• 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

46.15
/contracts/src/instances/steth/StETHBase.sol
1
// SPDX-License-Identifier: Apache-2.0
2
pragma solidity 0.8.20;
3

4
import { IHyperdrive } from "../../interfaces/IHyperdrive.sol";
5
import { ILido } from "../../interfaces/ILido.sol";
6
import { HyperdriveBase } from "../../internal/HyperdriveBase.sol";
7
import { FixedPointMath } from "../../libraries/FixedPointMath.sol";
8

9
/// @author DELV
10
/// @title StethHyperdrive
11
/// @notice The base contract for the stETH Hyperdrive implementation.
12
/// @dev Lido has it's own notion of shares to account for the accrual of
13
///      interest on the ether pooled in the Lido protocol. Instead of
14
///      maintaining a balance of shares, this integration can simply use Lido
15
///      shares directly.
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
abstract contract StETHBase is HyperdriveBase {
20
    using FixedPointMath for uint256;
21

22
    /// Yield Source ///
23

24
    /// @dev Accepts a deposit from the user in base.
25
    /// @param _baseAmount The base amount to deposit.
26
    /// @return sharesMinted The shares that were minted in the deposit.
27
    /// @return refund The amount of ETH to refund. This should be zero for
28
    ///         yield sources that don't accept ETH.
29
    function _depositWithBase(
30
        uint256 _baseAmount,
31
        bytes calldata // unused
32
    ) internal override returns (uint256 sharesMinted, uint256 refund) {
33
        // Ensure that sufficient ether was provided.
34
        if (msg.value < _baseAmount) {
14✔
35
            revert IHyperdrive.TransferFailed();
×
36
        }
37

38
        // If the user sent more ether than the amount specified, refund the
39
        // excess ether.
40
        unchecked {
41
            refund = msg.value - _baseAmount;
14✔
42
        }
43

44
        // Submit the provided ether to Lido to be deposited. The fee
45
        // collector address is passed as the referral address; however,
46
        // users can specify whatever referrer they'd like by depositing
47
        // stETH instead of ETH.
48
        sharesMinted = ILido(address(_vaultSharesToken)).submit{
14✔
49
            value: _baseAmount
50
        }(_feeCollector);
51

52
        return (sharesMinted, refund);
×
53
    }
54

55
    /// @dev Process a deposit in vault shares.
56
    /// @param _shareAmount The vault shares amount to deposit.
57
    function _depositWithShares(
58
        uint256 _shareAmount,
59
        bytes calldata // unused
60
    ) internal override {
61
        // Transfer stETH shares into the contract.
UNCOV
62
        ILido(address(_vaultSharesToken)).transferSharesFrom(
×
63
            msg.sender,
64
            address(this),
65
            _shareAmount
66
        );
67
    }
68

69
    /// @dev Process a withdrawal in base and send the proceeds to the
70
    ///      destination.
71
    function _withdrawWithBase(
72
        uint256, // unused
73
        address, // unused
74
        bytes calldata // unused
75
    ) internal pure override returns (uint256) {
76
        // stETH withdrawals aren't necessarily instantaneous. Users that want
77
        // to withdraw can manage their withdrawal separately.
UNCOV
78
        revert IHyperdrive.UnsupportedToken();
×
79
    }
80

81
    /// @dev Process a withdrawal in vault shares and send the proceeds to the
82
    ///      destination.
83
    /// @param _shareAmount The amount of vault shares to withdraw.
84
    /// @param _destination The destination of the withdrawal.
85
    function _withdrawWithShares(
86
        uint256 _shareAmount,
87
        address _destination,
88
        bytes calldata // unused
89
    ) internal override {
90
        // Transfer the stETH shares to the destination.
UNCOV
91
        ILido(address(_vaultSharesToken)).transferShares(
×
92
            _destination,
93
            _shareAmount
94
        );
95
    }
96

97
    /// @dev We override the message value check since this integration is
98
    ///      payable.
99
    function _checkMessageValue() internal pure override {}
100

101
    /// @dev Convert an amount of vault shares to an amount of base.
102
    /// @param _shareAmount The vault shares amount.
103
    /// @return baseAmount The base amount.
104
    function _convertToBase(
105
        uint256 _shareAmount
106
    ) internal view override returns (uint256) {
107
        return
14✔
108
            ILido(address(_vaultSharesToken)).getPooledEthByShares(
14✔
109
                _shareAmount
110
            );
111
    }
112

113
    /// @dev Convert an amount of base to an amount of vault shares.
114
    /// @param _baseAmount The base amount.
115
    /// @return shareAmount The vault shares amount.
116
    function _convertToShares(
117
        uint256 _baseAmount
118
    ) internal view override returns (uint256) {
UNCOV
119
        return
×
UNCOV
120
            ILido(address(_vaultSharesToken)).getSharesByPooledEth(_baseAmount);
×
121
    }
122

123
    /// @dev Gets the total amount of shares held by the pool in the yield
124
    ///      source.
125
    /// @return shareAmount The total amount of shares.
126
    function _totalShares()
127
        internal
128
        view
129
        override
130
        returns (uint256 shareAmount)
131
    {
132
        return ILido(address(_vaultSharesToken)).sharesOf(address(this));
30✔
133
    }
134
}
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