1
1
// SPDX-License-Identifier: Apache-2.0
2
- pragma solidity 0.8.20 ;
2
+ pragma solidity 0.8.22 ;
3
3
4
- import { IHyperdrive } from "hyperdrive/contracts/src/interfaces/IHyperdrive.sol " ;
5
4
import { DoubleEndedQueue } from "openzeppelin/utils/structs/DoubleEndedQueue.sol " ;
6
- import { IERC20 } from "openzeppelin/interfaces/IERC20.sol " ;
7
5
import { IEverlongEvents } from "../interfaces/IEverlongEvents.sol " ;
8
- import { EVERLONG_KIND, EVERLONG_VERSION } from "../libraries/Constants.sol " ;
9
- import { EverlongERC4626 } from "./EverlongERC4626.sol " ;
6
+ import { EverlongStorage } from "./EverlongStorage.sol " ;
10
7
11
8
// TODO: Reassess whether centralized configuration management makes sense.
12
9
// https://github.com/delvtech/everlong/pull/2#discussion_r1703799747
@@ -16,79 +13,21 @@ import { EverlongERC4626 } from "./EverlongERC4626.sol";
16
13
/// @custom:disclaimer The language used in this code is for coding convenience
17
14
/// only, and is not intended to, and does not, have any
18
15
/// particular legal or regulatory significance.
19
- abstract contract EverlongBase is EverlongERC4626 , IEverlongEvents {
16
+ abstract contract EverlongBase is EverlongStorage , IEverlongEvents {
20
17
using DoubleEndedQueue for DoubleEndedQueue.Bytes32Deque;
21
18
22
19
// โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
23
- // โ Storage โ
20
+ // โ Stateful โ
24
21
// โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
25
22
26
- // Admin //
23
+ /// @dev Rebalances the Everlong bond portfolio if needed.
24
+ function _rebalance () internal virtual ;
27
25
28
- /// @dev Address of the contract admin.
29
- address internal _admin;
30
-
31
- // Hyperdrive //
32
-
33
- /// @dev Address of the Hyperdrive instance wrapped by Everlong.
34
- address public immutable hyperdrive;
35
-
36
- /// @dev Whether to use Hyperdrive's base token to purchase bonds.
37
- // If false, use the Hyperdrive's `vaultSharesToken`.
38
- bool internal immutable _asBase;
39
-
40
- // Positions //
41
-
42
- // TODO: Reassess using a more tailored data structure.
43
- /// @dev Utility data structure to manage the position queue.
44
- /// Supports pushing and popping from both the front and back.
45
- DoubleEndedQueue.Bytes32Deque internal _positions;
46
-
47
- // โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
48
- // โ Constructor โ
49
- // โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
50
-
51
- /// @notice Initial configuration paramters for Everlong.
52
- /// @param _name Name of the ERC20 token managed by Everlong.
53
- /// @param _symbol Symbol of the ERC20 token managed by Everlong.
54
- /// @param _hyperdrive Address of the Hyperdrive instance wrapped by Everlong.
55
- /// @param __asBase Whether to use Hyperdrive's base token for bond purchases.
56
- constructor (
57
- string memory _name ,
58
- string memory _symbol ,
59
- address _hyperdrive ,
60
- bool __asBase
61
- )
62
- EverlongERC4626 (
63
- _name,
64
- _symbol,
65
- __asBase
66
- ? IHyperdrive (_hyperdrive).baseToken ()
67
- : IHyperdrive (_hyperdrive).vaultSharesToken ()
68
- )
69
- {
70
- // Store constructor parameters.
71
- hyperdrive = _hyperdrive;
72
- _asBase = __asBase;
73
- _admin = msg .sender ;
74
-
75
- // Give 1 wei approval to make the slot "dirty".
76
- IERC20 (_asset).approve (_hyperdrive, 1 );
77
- }
78
-
79
- // โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
80
- // โ Getters โ
81
- // โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
82
-
83
- /// @notice Returns the kind of the Everlong instance.
84
- /// @return Everlong contract kind.
85
- function kind () public view virtual returns (string memory ) {
86
- return EVERLONG_KIND;
87
- }
88
-
89
- /// @notice Returns the version of the Everlong instance.
90
- /// @return Everlong contract version.
91
- function version () public view virtual returns (string memory ) {
92
- return EVERLONG_VERSION;
93
- }
26
+ /// @dev Close positions until sufficient idle liquidity is held.
27
+ /// @dev Reverts if the target is unreachable.
28
+ /// @param _target Target amount of idle liquidity to reach.
29
+ /// @return idle Amount of idle after the increase.
30
+ function _increaseIdle (
31
+ uint256 _target
32
+ ) internal virtual returns (uint256 idle );
94
33
}
0 commit comments