Omniscia Myso Finance Audit

BalancerV2Looping Code Style Findings

BalancerV2Looping Code Style Findings

BVL-01C: Multiple Top-Level Declarations

TypeSeverityLocation
Code StyleBalancerV2Looping.sol:L10, L14, L23, L46

Description:

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

Example:

contracts/peer-to-peer/callbacks/BalancerV2Looping.sol
10interface IBalancerAsset {
11 // solhint-disable-previous-line no-empty-blocks
12}
13
14interface IBalancerVault {
15 function swap(
16 BalancerDataTypes.SingleSwap memory singleSwap,
17 BalancerDataTypes.FundManagement memory funds,
18 uint256 limit,
19 uint256 deadline
20 ) external payable returns (uint256);
21}
22
23library BalancerDataTypes {
24 enum SwapKind {
25 GIVEN_IN,
26 GIVEN_OUT
27 }
28
29 struct FundManagement {
30 address sender;
31 bool fromInternalBalance;
32 address payable recipient;
33 bool toInternalBalance;
34 }
35
36 struct SingleSwap {
37 bytes32 poolId;
38 SwapKind kind;
39 IBalancerAsset assetIn;
40 IBalancerAsset assetOut;
41 uint256 amount;
42 bytes userData;
43 }
44}
45
46contract BalancerV2Looping is IVaultCallback {

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 (c740f7c6b5ebd365618fd2d7ea77370599e1ca11):

All three referenced declarations that differ from the file's name have been relocated to their dedicated files and are imported by the BalancerV2Looping contract as advised.

BVL-02C: Suboptimal Struct Declaration Styles

TypeSeverityLocation
Code StyleBalancerV2Looping.sol:L57-L62, L70-L77, L97-L102, L110-L117

Description:

The linked declaration styles of the referenced structs are using index-based argument initialization.

Example:

contracts/peer-to-peer/callbacks/BalancerV2Looping.sol
57memory fundManagement = BalancerDataTypes.FundManagement(
58 address(this), // swap payer
59 false, // use payer's internal balance
60 payable(loan.borrower), // swap receiver
61 false // user receiver's internal balance
62);

Recommendation:

We advise the key-value declaration format to be utilized instead in each instance, greatly increasing the legibility of the codebase.

Alleviation (c740f7c6b5ebd365618fd2d7ea77370599e1ca11):

All referenced struct declarations have been replaced by their key-value declaration format, significantly increasing the legibility of their instantiation.