|
1 | 1 | // SPDX-License-Identifier: Apache-2.0
|
2 | 2 | pragma solidity 0.8.20;
|
3 | 3 |
|
4 |
| -import { Admin } from "./Admin.sol"; |
5 |
| -import { ERC4626 } from "solady/tokens/ERC4626.sol"; |
6 |
| -import { Positions } from "./Positions.sol"; |
7 |
| - |
8 |
| -import { IHyperdrive } from "hyperdrive/contracts/src/interfaces/IHyperdrive.sol"; |
| 4 | +import { EverlongAdmin } from "./internal/EverlongAdmin.sol"; |
| 5 | +import { EverlongBase } from "./internal/EverlongBase.sol"; |
| 6 | +import { EverlongPositions } from "./internal/EverlongPositions.sol"; |
9 | 7 |
|
10 | 8 | /// ,---..-. .-.,---. ,---. ,-. .---. .-. .-. ,--,
|
11 | 9 | /// | .-' \ \ / / | .-' | .-.\ | | / .-. ) | \| |.' .'
|
@@ -57,120 +55,23 @@ import { IHyperdrive } from "hyperdrive/contracts/src/interfaces/IHyperdrive.sol
|
57 | 55 | // +++#####+++++++++--------------++++++++++++
|
58 | 56 | // #+ +++#######+++++++++++---------------+++++++++#+
|
59 | 57 | // ###########++++++++++++++-------------++++++++++###
|
60 |
| -/// |
| 58 | +// |
61 | 59 | /// @author DELV
|
62 | 60 | /// @title Everlong
|
63 | 61 | /// @notice A money market powered by Hyperdrive.
|
64 | 62 | /// @custom:disclaimer The language used in this code is for coding convenience
|
65 | 63 | /// only, and is not intended to, and does not, have any
|
66 | 64 | /// particular legal or regulatory significance.
|
67 |
| -contract Everlong is Admin, ERC4626, Positions { |
68 |
| - /// @notice Virtual shares are used to mitigate inflation attacks. |
69 |
| - bool public constant useVirtualShares = true; |
70 |
| - |
71 |
| - /// @notice Used to reduce the feasibility of an inflation attack. |
72 |
| - /// TODO: Determine the appropriate value for our case. Current value |
73 |
| - /// was picked arbitrarily. |
74 |
| - uint8 public constant decimalsOffset = 3; |
75 |
| - |
76 |
| - /// @notice Address of the Hyperdrive instance wrapped by Everlong. |
77 |
| - address public immutable hyperdrive; |
78 |
| - |
79 |
| - /// @notice ERC20 token used for deposits, idle liquidity, and |
80 |
| - /// the purchase of bonds from the Hyperdrive instance. |
81 |
| - address internal immutable _asset; |
82 |
| - |
83 |
| - /// @notice Decimals used by the `_asset`. |
84 |
| - uint8 internal immutable _decimals; |
85 |
| - |
86 |
| - /// @notice Name of the Everlong token. |
87 |
| - string internal _name; |
88 |
| - |
89 |
| - /// @notice Symbol of the Everlong token. |
90 |
| - string internal _symbol; |
91 |
| - |
| 65 | +contract Everlong is EverlongAdmin, EverlongPositions { |
92 | 66 | /// @notice Initial configuration paramters for Everlong.
|
93 |
| - /// @param hyperdrive_ Address of the Hyperdrive instance wrapped by Everlong. |
94 |
| - /// @param name_ Name of the ERC20 token managed by Everlong. |
95 |
| - /// @param symbol_ Symbol of the ERC20 token managed by Everlong. |
96 |
| - /// @param asset_ ERC20 token used to purchase bonds from the Hyperdrive instance. |
| 67 | + /// @param _name Name of the ERC20 token managed by Everlong. |
| 68 | + /// @param _symbol Symbol of the ERC20 token managed by Everlong. |
| 69 | + /// @param __hyperdrive Address of the Hyperdrive instance wrapped by Everlong. |
| 70 | + /// @param __asBase Whether to use Hyperdrive's base token for bond purchases. |
97 | 71 | constructor(
|
98 |
| - string memory name_, |
99 |
| - string memory symbol_, |
100 |
| - address hyperdrive_, |
101 |
| - address asset_ |
102 |
| - ) Admin() { |
103 |
| - // Store constructor parameters. |
104 |
| - _name = name_; |
105 |
| - _symbol = symbol_; |
106 |
| - hyperdrive = hyperdrive_; |
107 |
| - _asset = asset_; |
108 |
| - |
109 |
| - // Attempt to retrieve the decimals from the {_asset} contract. |
110 |
| - // If it does not implement `decimals() (uint256)`, use the default. |
111 |
| - (bool success, uint8 result) = _tryGetAssetDecimals(_asset); |
112 |
| - _decimals = success ? result : _DEFAULT_UNDERLYING_DECIMALS; |
113 |
| - } |
114 |
| - |
115 |
| - /// @dev Address of the underlying Hyperdrive instance. |
116 |
| - /// @dev MUST be an ERC20 token contract. |
117 |
| - /// @dev MUST NOT revert. |
118 |
| - function asset() public view virtual override returns (address) { |
119 |
| - return _asset; |
120 |
| - } |
121 |
| - |
122 |
| - /// @dev Returns the name of the Everlong token. |
123 |
| - function name() public view virtual override returns (string memory) { |
124 |
| - return _name; |
125 |
| - } |
126 |
| - |
127 |
| - /// @dev Returns the symbol of the Everlong token. |
128 |
| - function symbol() public view virtual override returns (string memory) { |
129 |
| - return _symbol; |
130 |
| - } |
131 |
| - |
132 |
| - /// @dev Returns the kind of the Everlong instance. |
133 |
| - function kind() public view virtual returns (string memory) { |
134 |
| - return "Everlong"; |
135 |
| - } |
136 |
| - |
137 |
| - /// @dev Returns the version of the Everlong instance. |
138 |
| - function version() public view virtual returns (string memory) { |
139 |
| - return "v0.0.1"; |
140 |
| - } |
141 |
| - |
142 |
| - /// @dev Returns whether virtual shares will be used to mitigate the inflation attack. |
143 |
| - /// @dev See: https://github.com/OpenZeppelin/openzeppelin-contracts/issues/3706 |
144 |
| - /// @dev MUST NOT revert. |
145 |
| - function _useVirtualShares() internal view virtual override returns (bool) { |
146 |
| - return useVirtualShares; |
147 |
| - } |
148 |
| - |
149 |
| - /// @dev Returns the number of decimals of the underlying asset. |
150 |
| - /// @dev MUST NOT revert. |
151 |
| - function _underlyingDecimals() |
152 |
| - internal |
153 |
| - view |
154 |
| - virtual |
155 |
| - override |
156 |
| - returns (uint8) |
157 |
| - { |
158 |
| - return _decimals; |
159 |
| - } |
160 |
| - |
161 |
| - /// @dev A non-zero value used to make the inflation attack even more unfeasible. |
162 |
| - /// @dev MUST NOT revert. |
163 |
| - function _decimalsOffset() internal view virtual override returns (uint8) { |
164 |
| - return decimalsOffset; |
165 |
| - } |
166 |
| - |
167 |
| - // TODO: Might not need this but including for convenience. |
168 |
| - function _beforeWithdraw(uint256, uint256) internal override { |
169 |
| - // revert("TODO"); |
170 |
| - } |
171 |
| - |
172 |
| - // TODO: Might not need this but including for convenience. |
173 |
| - function _afterDeposit(uint256, uint256) internal override { |
174 |
| - // revert("TODO"); |
175 |
| - } |
| 72 | + string memory _name, |
| 73 | + string memory _symbol, |
| 74 | + address __hyperdrive, |
| 75 | + bool __asBase |
| 76 | + ) EverlongBase(_name, _symbol, __hyperdrive, __asBase) {} |
176 | 77 | }
|
0 commit comments