Omniscia 0xPhase Audit

IVault Code Style Findings

IVault Code Style Findings

IVT-01C: Multiple Top-Level Declarations

TypeSeverityLocation
Code StyleIVault.sol:L73, L141, L266, L279, L290

Description:

The referenced file contains multiple top-level declarations that decrease the legibility of the codebase.

Example:

vault/IVault.sol
73interface IVaultAccounting {
74 /// @notice Adds collateral for the user
75 /// @param amount The amount to add
76 /// @param extraData The extra adapter data
77 function addCollateral(
78 uint256 amount,
79 bytes memory extraData
80 ) external payable;
81
82 /// @notice Adds collateral for the user
83 /// @param user The user address
84 /// @param amount The amount to add
85 /// @param extraData The extra adapter data
86 function addCollateral(
87 address user,
88 uint256 amount,
89 bytes memory extraData
90 ) external payable;
91
92 /// @notice Gives collateral for the user
93 /// @param user The user id
94 /// @param amount The amount to add
95 /// @param extraData The extra adapter data
96 function addCollateral(
97 uint256 user,
98 uint256 amount,
99 bytes memory extraData
100 ) external payable;
101
102 /// @notice Removes collateral from the user
103 /// @param amount The amount to remove
104 /// @param extraData The extra adapter data
105 function removeCollateral(uint256 amount, bytes memory extraData) external;
106
107 /// @notice Removes all collateral from the user
108 /// @param extraData The extra adapter data
109 function removeAllCollateral(bytes memory extraData) external;
110
111 /// @notice Mints for the user
112 /// @param amount The amount to mint
113 function mintUSD(uint256 amount) external;
114
115 /// @notice Repays for the user
116 /// @param amount The amount to repay
117 function repayUSD(uint256 amount) external;
118
119 /// @notice Repays for the user
120 /// @param user The user address
121 /// @param amount The amount to repay
122 function repayUSD(address user, uint256 amount) external;
123
124 /// @notice Repays for the user
125 /// @param user The user id
126 /// @param amount The amount to repay
127 function repayUSD(uint256 user, uint256 amount) external;
128
129 /// @notice Repays all for the user
130 function repayAllUSD() external;
131
132 /// @notice Repays all for the user
133 /// @param user The user address
134 function repayAllUSD(address user) external;
135
136 /// @notice Repays all for the user
137 /// @param user The user id
138 function repayAllUSD(uint256 user) external;
139}
140
141interface IVaultGetters {
142 /// @notice Returns if the user is solvent
143 /// @param user The user id
144 /// @return If the user is solvent
145 function isSolvent(uint256 user) external view returns (bool);
146
147 /// @notice Returns the user's debt value in dollars
148 /// @param user The user id
149 /// @return The debt value
150 function debtValue(uint256 user) external view returns (uint256);
151
152 /// @notice Returns the user's debt shares
153 /// @param user The user id
154 /// @return The debt shares
155 function debtShares(uint256 user) external view returns (uint256);
156
157 /// @notice Returns the user's deposit value in dollars
158 /// @param user The user id
159 /// @return The deposit value
160 function depositValue(uint256 user) external view returns (uint256);
161
162 /// @notice Returns the user's total deposit in token amount
163 /// @param user The user id
164 /// @return The total deposit
165 function deposit(uint256 user) external view returns (uint256);
166
167 /// @notice Returns the user's yield deposit in token amount
168 /// @param user The user id
169 /// @return The yield deposit
170 function yieldDeposit(uint256 user) external view returns (uint256);
171
172 /// @notice Returns the user's vault deposit in token amount
173 /// @param user The user id
174 /// @return The vault deposit
175 function pureDeposit(uint256 user) external view returns (uint256);
176
177 /// @notice Returns the price of the underlying asset from the oracle
178 /// @return The underlying asset price
179 function price() external view returns (uint256);
180
181 /// @notice Returns the interest rate for the vault
182 /// @return The interest rate
183 function getInterest() external view returns (uint256);
184
185 /// @notice Returns the total amount of collateral in the vault and invested in yield
186 /// @return The amount of collateral
187 function collectiveCollateral() external view returns (uint256);
188
189 /// @notice Returns the system clock contract
190 /// @return The system clock contract
191 function systemClock() external view returns (ISystemClock);
192
193 /// @notice Returns the manager contract
194 /// @return The manager contract
195 function manager() external view returns (Manager);
196
197 /// @notice Returns the cash contract
198 /// @return The cash contract
199 function cash() external view returns (IPegToken);
200
201 /// @notice Returns the treasury contract
202 /// @return The treasury contract
203 function treasury() external view returns (ITreasury);
204
205 /// @notice Returns the storage contract
206 /// @return The storage contract
207 function varStorage() external view returns (Storage);
208
209 /// @notice Returns the asset token contract
210 /// @return The asset token contract
211 function asset() external view returns (IERC20);
212
213 /// @notice Returns the price oracle contract
214 /// @return The price oracle contract
215 function priceOracle() external view returns (IOracle);
216
217 /// @notice Returns the max mint
218 /// @return The max mint
219 function maxMint() external view returns (uint256);
220
221 /// @notice Returns the interest contract
222 /// @return The interest contract
223 function interest() external view returns (IInterest);
224
225 /// @notice Returns the max collateral ratio
226 /// @return The max collateral ratio
227 function maxCollateralRatio() external view returns (uint256);
228
229 /// @notice Returns the borrow fee
230 /// @return The borrow fee
231 function borrowFee() external view returns (uint256);
232
233 /// @notice Returns the liquidation fee
234 /// @return The liquidation fee
235 function liquidationFee() external view returns (uint256);
236
237 /// @notice Returns the health target minimum
238 /// @return The health target minimum
239 function healthTargetMinimum() external view returns (uint256);
240
241 /// @notice Returns the health target maximum
242 /// @return The health target minimum
243 function healthTargetMaximum() external view returns (uint256);
244
245 /// @notice Returns the collective debt
246 /// @return The collective debt
247 function collectiveDebt() external view returns (uint256);
248
249 /// @notice Returns the total debt shares
250 /// @return The total debt shares
251 function totalDebtShares() external view returns (uint256);
252
253 /// @notice Returns the last debt update timestamp
254 /// @return The last debt update timestamp
255 function lastDebtUpdate() external view returns (uint256);
256
257 /// @notice Returns if the context is currently locked due to a sensitive function being called
258 /// @return If the context is currently locked
259 function contextLocked() external view returns (bool);
260
261 /// @notice Returns if the market is current locked
262 /// @return If the matket is currently locked
263 function marketsLocked() external view returns (bool);
264}
265
266interface IVaultLiquidation {
267 /// @notice Liquidates a user based on liquidationInfo(user)
268 /// @param user The user id
269 function liquidateUser(uint256 user) external;
270
271 /// @notice Returns liquidation info about the user
272 /// @param user The user id
273 /// @return The liquidation info
274 function liquidationInfo(
275 uint256 user
276 ) external view returns (LiquidationInfo memory);
277}
278
279interface IVaultSetters {
280 /// @notice Sets the health target for a liquidation for the user
281 /// @param healthTarget The health target
282 function setHealthTarget(uint256 healthTarget) external;
283
284 /// @notice Sets the yield percent for the user
285 /// @param yieldPercent The yield percent
286 function setYieldPercent(uint256 yieldPercent) external;
287}
288
289// solhint-disable-next-line no-empty-blocks
290interface IVault is

Recommendation:

We advise all highlighted top-level declarations to be split into their respective code files, avoiding unnecessary imports as well as increasing the legibility of the codebase.

Alleviation (3dd3d7bf0c2693b2f9c23bacedfa420393f7ea84):

All highlighted interfaces except the main IVault one were split to their dedicated files, rendering this exhibit applied in full.