Omniscia 0xPhase Audit

ITreasury Code Style Findings

ITreasury Code Style Findings

ITY-01C: Multiple Top-Level Declarations

TypeSeverityLocation
Code StyleITreasury.sol:L10, L136

Description:

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

Example:

treasury/ITreasury.sol
10interface ITreasury {
11 struct TokenInfo {
12 uint256 balance;
13 bool set;
14 }
15
16 struct Cause {
17 mapping(address => TokenInfo) token;
18 address[] tokens;
19 }
20
21 /// @notice Event emitted when a token or ETH is donated to a cause
22 /// @param cause The cause that was donated to
23 /// @param token The donated token address (ETH_ADDRESS for ETH)
24 /// @param amount The donation amount
25 event Donated(bytes32 indexed cause, address indexed token, uint256 amount);
26
27 /// @notice Event emitted when a token or ETH is spent by a cause
28 /// @param cause The cause that spent
29 /// @param token The spent token address (ETH_ADDRESS for ETH)
30 /// @param to The spend target address
31 /// @param amount The spent amount
32 event Spent(
33 bytes32 indexed cause,
34 address indexed token,
35 address indexed to,
36 uint256 amount
37 );
38
39 /// @notice Donates a token or ETH to a cause
40 /// @param cause The cause to donate to
41 /// @param token The donated token address (ETH_ADDRESS for ETH)
42 /// @param amount The donation amount
43 function donate(
44 bytes32 cause,
45 address token,
46 uint256 amount
47 ) external payable;
48
49 /// @notice Donates a token or ETH to a cause
50 /// @param cause The cause to donate to
51 /// @param token The donated token address (ETH_ADDRESS for ETH)
52 /// @param amount The donation amount
53 function donate(
54 string memory cause,
55 address token,
56 uint256 amount
57 ) external payable;
58
59 /// @notice Spends a token or ETH from a cause
60 /// @param cause The cause that's spending
61 /// @param token The spent token address (ETH_ADDRESS for ETH)
62 /// @param amount The spent amount
63 /// @param to The spend target address
64 function spend(
65 bytes32 cause,
66 address token,
67 uint256 amount,
68 address to
69 ) external;
70
71 /// @notice Spends a token or ETH from a cause
72 /// @param cause The cause that's spending
73 /// @param token The spent token address (ETH_ADDRESS for ETH)
74 /// @param amount The spent amount
75 /// @param to The spend target address
76 function spend(
77 string memory cause,
78 address token,
79 uint256 amount,
80 address to
81 ) external;
82
83 /// @notice Increases the balance for a token or ETH for a cause without transferring it in
84 /// @param cause The cause to increase for
85 /// @param token The token address to increase (ETH_ADDRESS for ETH)
86 /// @param amount The amount to increase
87 function increaseUnsafe(
88 bytes32 cause,
89 address token,
90 uint256 amount
91 ) external;
92
93 /// @notice Returns the total token or ETH balance in the treasury
94 /// @param token The token address (ETH_ADDRESS for ETH)
95 /// @return The balance for the token or ETH
96 function tokenBalance(address token) external view returns (uint256);
97
98 /// @notice Returns the total token or ETH balance in the treasury for the cause
99 /// @param cause The cause to check for
100 /// @param token The token address (ETH_ADDRESS for ETH)
101 /// @return The balance for the token or ETH
102 function tokenBalance(
103 bytes32 cause,
104 address token
105 ) external view returns (uint256);
106
107 /// @notice Returns the total token or ETH balance in the treasury for the cause
108 /// @param cause The cause to check for
109 /// @param token The token address (ETH_ADDRESS for ETH)
110 /// @return The balance for the token or ETH
111 function tokenBalance(
112 string memory cause,
113 address token
114 ) external view returns (uint256);
115
116 /// @notice Returns all tokens in the treasury
117 /// @return The list of token addresses
118 function tokens() external view returns (address[] memory);
119
120 /// @notice Returns all tokens in the treasury for the cause
121 /// @param cause The cause to check for
122 /// @return The list of token addresses
123 function tokens(bytes32 cause) external view returns (address[] memory);
124
125 /// @notice Returns all tokens in the treasury for the cause
126 /// @param cause The cause to check for
127 /// @return The list of token addresses
128 function tokens(string memory cause) external view returns (address[] memory);
129
130 /// @notice Returns the reserved address to represent native ETH
131 /// @return The reserved ETH address
132 // solhint-disable-next-line func-name-mixedcase
133 function ETH_ADDRESS() external view returns (address);
134}
135
136abstract contract TreasuryStorageV1 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):

The TreasuryStorageV1 implementation was split to its dedicated file, rendering this exhibit applied in full.