• 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

11.76
/contracts/src/instances/ezeth/EzETHBase.sol
1
// SPDX-License-Identifier: Apache-2.0
2
pragma solidity 0.8.20;
3

4
import { IHyperdrive } from "../../interfaces/IHyperdrive.sol";
5
import { IRestakeManager, IRenzoOracle } from "../../interfaces/IRenzo.sol";
6
import { HyperdriveBase } from "../../internal/HyperdriveBase.sol";
7

8
/// @author DELV
9
/// @title ezETH Base Contract
10
/// @notice The base contract for the ezETH Hyperdrive implementation.
11
/// @dev ezETH shares are held separately in the ezETH token contract.  The
12
///      value of those tokens w.r.t. ETH are found by calling the
13
///      RestakeManager's calculateTVL for the total pooled ETH value and
14
///      dividing by the totalSupply of ezETH.
15
/// @custom:disclaimer The language used in this code is for coding convenience
16
///                    only, and is not intended to, and does not, have any
17
///                    particular legal or regulatory significance.
18
abstract contract EzETHBase is HyperdriveBase {
19
    /// @dev The Renzo entrypoint contract.
20
    IRestakeManager internal immutable _restakeManager;
21

22
    /// @dev The RenzoOracle contract.
23
    IRenzoOracle internal immutable _renzoOracle;
24

25
    /// @notice Instantiates the ezETH Hyperdrive base contract.
26
    /// @param __restakeManager The Renzo Restakemanager contract.
27
    constructor(IRestakeManager __restakeManager) {
28
        _restakeManager = __restakeManager;
10✔
29
        _renzoOracle = IRenzoOracle(__restakeManager.renzoOracle());
10✔
30
    }
31

32
    /// Yield Source ///
33

34
    //// @dev This option isn't supported because the minting calculation is too
35
    ///       imprecise.
36
    function _depositWithBase(
37
        uint256, // unused
38
        bytes calldata // unused
39
    ) internal pure override returns (uint256, uint256) {
UNCOV
40
        revert IHyperdrive.UnsupportedToken();
×
41
    }
42

43
    /// @dev Process a deposit in vault shares.
44
    /// @param _shareAmount The vault shares amount to deposit.
45
    function _depositWithShares(
46
        uint256 _shareAmount,
47
        bytes calldata // unused
48
    ) internal override {
49
        // NOTE: We don't need to use `safeTransfer` since ezETH uses
50
        // OpenZeppelin's ERC20Upgradeable implementation and is
51
        // standard-compliant.
52
        //
53
        // Transfer ezETH shares into the contract.
UNCOV
54
        _vaultSharesToken.transferFrom(msg.sender, address(this), _shareAmount);
×
55
    }
56

57
    /// @dev Process a withdrawal in base and send the proceeds to the
58
    ///      destination.
59
    function _withdrawWithBase(
60
        uint256, // unused
61
        address, // unused
62
        bytes calldata // unused
63
    ) internal pure override returns (uint256) {
64
        // ezETH withdrawals aren't necessarily instantaneous. Users that want
65
        // to withdraw can manage their withdrawal separately.
UNCOV
66
        revert IHyperdrive.UnsupportedToken();
×
67
    }
68

69
    /// @dev Process a withdrawal in vault shares and send the proceeds to the
70
    ///      destination.
71
    /// @param _shareAmount The amount of vault shares to withdraw.
72
    /// @param _destination The destination of the withdrawal.
73
    function _withdrawWithShares(
74
        uint256 _shareAmount,
75
        address _destination,
76
        bytes calldata // unused
77
    ) internal override {
78
        // NOTE: We don't need to use `safeTransfer` since ezETH uses
79
        // OpenZeppelin's ERC20Upgradeable implementation and is
80
        // standard-compliant.
81
        //
82
        // Transfer the ezETH shares to the destination.
UNCOV
83
        _vaultSharesToken.transfer(_destination, _shareAmount);
×
84
    }
85

86
    /// @dev Convert an amount of vault shares to an amount of base.
87
    /// @param _shareAmount The vault shares amount.
88
    /// @return baseAmount The base amount.
89
    function _convertToBase(
90
        uint256 _shareAmount
91
    ) internal view override returns (uint256) {
92
        // Get the total TVL priced in ETH from restakeManager
UNCOV
93
        (, , uint256 totalTVL) = _restakeManager.calculateTVLs();
×
94

95
        // Get the total supply of the ezETH token
UNCOV
96
        uint256 totalSupply = _vaultSharesToken.totalSupply();
×
97

UNCOV
98
        return
×
UNCOV
99
            _renzoOracle.calculateRedeemAmount(
×
100
                _shareAmount,
101
                totalSupply,
102
                totalTVL
103
            );
104
    }
105

106
    /// @dev Convert an amount of base to an amount of vault shares.
107
    /// @param _baseAmount The base amount.
108
    /// @return shareAmount The vault shares amount.
109
    function _convertToShares(
110
        uint256 _baseAmount
111
    ) internal view override returns (uint256) {
112
        // Get the total TVL priced in ETH from restakeManager
UNCOV
113
        (, , uint256 totalTVL) = _restakeManager.calculateTVLs();
×
114

115
        // Get the total supply of the ezETH token
UNCOV
116
        uint256 totalSupply = _vaultSharesToken.totalSupply();
×
117

UNCOV
118
        return
×
UNCOV
119
            _renzoOracle.calculateMintAmount(
×
120
                totalTVL,
121
                _baseAmount,
122
                totalSupply
123
            );
124
    }
125

126
    /// @dev Gets the total amount of shares held by the pool in the yield
127
    ///      source.
128
    /// @return shareAmount The total amount of shares.
129
    function _totalShares()
130
        internal
131
        view
132
        override
133
        returns (uint256 shareAmount)
134
    {
UNCOV
135
        return _vaultSharesToken.balanceOf(address(this));
×
136
    }
137

138
    /// @dev We override the message value check since this integration is
139
    ///      payable.
140
    function _checkMessageValue() internal view override {
UNCOV
141
        if (msg.value != 0) {
×
UNCOV
142
            revert IHyperdrive.NotPayable();
×
143
        }
144
    }
145
}
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