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

delvtech / hyperdrive / 10637797741

30 Aug 2024 06:57PM UTC coverage: 89.37%. First build
10637797741

Pull #1152

github

web-flow
Merge 1e72dcbdc into 9857eb6ef
Pull Request #1152: RsETH on Linea

43 of 64 new or added lines in 10 files covered. (67.19%)

2354 of 2634 relevant lines covered (89.37%)

347620.55 hits per line

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

76.47
/contracts/src/instances/rseth-linea/RsETHLineaBase.sol
1
// SPDX-License-Identifier: Apache-2.0
2
pragma solidity 0.8.22;
3

4
import { IHyperdrive } from "../../interfaces/IHyperdrive.sol";
5
import { IRSETHPoolV2 } from "../../interfaces/IRSETHPoolV2.sol";
6
import { HyperdriveBase } from "../../internal/HyperdriveBase.sol";
7
import { RsETHLineaConversions } from "./RsETHLineaConversions.sol";
8

9
/// @author DELV
10
/// @title RsETHLineaBase
11
/// @notice The base contract for the RsETHLinea Hyperdrive implementation.
12
/// @custom:disclaimer The language used in this code is for coding convenience
13
///                    only, and is not intended to, and does not, have any
14
///                    particular legal or regulatory significance.
15
abstract contract RsETHLineaBase is HyperdriveBase {
16
    /// @dev The Kelp DAO deposit contract on Linea. The rsETH/ETH price is used
17
    ///      as the vault share price.
18
    IRSETHPoolV2 internal immutable _rsETHPool;
19

20
    /// @notice Instantiates the rsETH Linea Hyperdrive base contract.
21
    /// @param __rsETHPool The Kelp DAO deposit contract that provides the
22
    ///        vault share price.
23
    constructor(IRSETHPoolV2 __rsETHPool) {
24
        _rsETHPool = __rsETHPool;
192✔
25
    }
26

27
    /// Yield Source ///
28

29
    /// @dev Accepts a deposit from the user in base. This is only allowed when
30
    ///      Kelp DAO fees are turned off.
31
    /// @param _baseAmount The base amount to deposit.
32
    /// @return sharesMinted The shares that were minted in the deposit.
33
    /// @return refund The amount of ETH to refund. This should be zero for
34
    ///         yield sources that don't accept ETH.
35
    function _depositWithBase(
36
        uint256 _baseAmount,
37
        bytes calldata // unused
38
    ) internal override returns (uint256 sharesMinted, uint256 refund) {
39
        // If Kelp DAO is taking a bridge fee, we disallow depositing with base.
40
        // This avoids problems with the `openShort` accounting.
41
        if (_rsETHPool.feeBps() > 0) {
1,103✔
NEW
42
            revert IHyperdrive.UnsupportedToken();
×
43
        }
44

45
        // If the user sent more ether than the amount specified, refund the
46
        // excess ether.
47
        unchecked {
48
            refund = msg.value - _baseAmount;
1,103✔
49
        }
50

51
        // TODO: Get a referral ID.
52
        //
53
        // Submit the provided ether to the Kelp DAO deposit pool. We specify
54
        // the empty referral address; however, users can specify whatever
55
        // referrer they'd like by depositing wrsETH instead of ETH.
56
        _rsETHPool.deposit{ value: _baseAmount }("");
1,103✔
57
        sharesMinted = _convertToShares(_baseAmount);
1,103✔
58

NEW
59
        return (sharesMinted, refund);
×
60
    }
61

62
    /// @dev Process a deposit in vault shares.
63
    /// @param _shareAmount The vault shares amount to deposit.
64
    function _depositWithShares(
65
        uint256 _shareAmount,
66
        bytes calldata // unused _extraData
67
    ) internal override {
68
        // NOTE: Since Linea wrsETH is an OpenZeppelin ERC20 token, we don't
69
        // need to use `safeTransferFrom`.
70
        //
71
        // Take custody of the deposit in vault shares.
72
        bool success = _vaultSharesToken.transferFrom(
1,133✔
73
            msg.sender,
74
            address(this),
75
            _shareAmount
76
        );
77
        if (!success) {
1,133✔
NEW
78
            revert IHyperdrive.TransferFailed();
×
79
        }
80
    }
81

82
    /// @dev Withdrawals with base are not supported for this integration.
83
    function _withdrawWithBase(
84
        uint256, // unused
85
        address, // unused
86
        bytes calldata // unused
87
    ) internal pure override returns (uint256) {
88
        revert IHyperdrive.UnsupportedToken();
200✔
89
    }
90

91
    /// @dev Process a withdrawal in vault shares and send the proceeds to the
92
    ///      destination.
93
    /// @param _shareAmount The amount of vault shares to withdraw.
94
    /// @param _destination The destination of the withdrawal.
95
    function _withdrawWithShares(
96
        uint256 _shareAmount,
97
        address _destination,
98
        bytes calldata // unused
99
    ) internal override {
100
        // NOTE: Since Linea wrsETH is an OpenZeppelin ERC20 token, we don't
101
        // need to use `safeTransfer`.
102
        //
103
        // Transfer vault shares to the destination.
104
        bool success = _vaultSharesToken.transfer(_destination, _shareAmount);
1,459✔
105
        if (!success) {
1,459✔
NEW
106
            revert IHyperdrive.TransferFailed();
×
107
        }
108
    }
109

110
    /// @dev Convert an amount of vault shares to an amount of base.
111
    /// @param _shareAmount The vault shares amount.
112
    /// @return The base amount.
113
    function _convertToBase(
114
        uint256 _shareAmount
115
    ) internal view override returns (uint256) {
116
        return RsETHLineaConversions.convertToBase(_rsETHPool, _shareAmount);
8,844✔
117
    }
118

119
    /// @dev Convert an amount of base to an amount of vault shares.
120
    /// @param _baseAmount The base amount.
121
    /// @return The vault shares amount.
122
    function _convertToShares(
123
        uint256 _baseAmount
124
    ) internal view override returns (uint256) {
125
        return RsETHLineaConversions.convertToShares(_rsETHPool, _baseAmount);
6,675✔
126
    }
127

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

140
    /// @dev We override the message value check since this integration is
141
    ///      payable.
142
    function _checkMessageValue() internal view override {}
143
}
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