Skip to content

Commit 01642c6

Browse files
author
Rohan Kulkarni
committed
chore: audit snapshot
1 parent a99f613 commit 01642c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+950
-919
lines changed

src/auction/Auction.sol

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import { IWETH } from "../lib/interfaces/IWETH.sol";
1515

1616
/// @title Auction
1717
/// @author Rohan Kulkarni
18-
/// @notice DAO Auction House
18+
/// @notice A DAO's auction house
19+
/// Modified from:
20+
/// - NounsAuctionHouse.sol commit 2cbe6c7 - licensed under the BSD-3-Clause license.
21+
/// - Zora V3 ReserveAuctionCoreEth module commit 795aeca - licensed under the GPL-3.0 license.
1922
contract Auction is IAuction, UUPS, Ownable, ReentrancyGuard, Pausable, AuctionStorageV1 {
2023
/// ///
2124
/// IMMUTABLES ///
@@ -31,7 +34,7 @@ contract Auction is IAuction, UUPS, Ownable, ReentrancyGuard, Pausable, AuctionS
3134
/// CONSTRUCTOR ///
3235
/// ///
3336

34-
/// @param _manager The address of the contract upgrade manager
37+
/// @param _manager The contract upgrade manager address
3538
/// @param _weth The address of WETH
3639
constructor(address _manager, address _weth) payable initializer {
3740
manager = IManager(_manager);
@@ -42,7 +45,7 @@ contract Auction is IAuction, UUPS, Ownable, ReentrancyGuard, Pausable, AuctionS
4245
/// INITIALIZER ///
4346
/// ///
4447

45-
/// @notice Initializes a DAO's auction house
48+
/// @notice Initializes a DAO's auction contract
4649
/// @param _token The ERC-721 token address
4750
/// @param _founder The founder responsible for starting the first auction
4851
/// @param _treasury The treasury address where ETH will be sent
@@ -61,13 +64,13 @@ contract Auction is IAuction, UUPS, Ownable, ReentrancyGuard, Pausable, AuctionS
6164
// Initialize the reentrancy guard
6265
__ReentrancyGuard_init();
6366

64-
// Grant initial ownership to a founder to unpause the auction house when ready
67+
// Grant initial ownership to a founder
6568
__Ownable_init(_founder);
6669

67-
// Pause the contract until the first auction is ready to begin
70+
// Pause the contract until the first auction
6871
__Pausable_init(true);
6972

70-
// Store the address of the ERC-721 token that will be bid on
73+
// Store DAO's ERC-721 token
7174
token = Token(_token);
7275

7376
// Store the auction house settings
@@ -94,7 +97,7 @@ contract Auction is IAuction, UUPS, Ownable, ReentrancyGuard, Pausable, AuctionS
9497
// Ensure the auction is still active
9598
if (block.timestamp >= _auction.endTime) revert AUCTION_OVER();
9699

97-
// Cache the address of the current highest bidder
100+
// Cache the address of the highest bidder
98101
address highestBidder = _auction.highestBidder;
99102

100103
// If this is the first bid:
@@ -104,10 +107,10 @@ contract Auction is IAuction, UUPS, Ownable, ReentrancyGuard, Pausable, AuctionS
104107

105108
// Else this is a subsequent bid:
106109
} else {
107-
// Cache the current highest bid
110+
// Cache the highest bid
108111
uint256 highestBid = _auction.highestBid;
109112

110-
// Used to store the minimum amount required to beat the current bid
113+
// Used to store the minimum bid required
111114
uint256 minBid;
112115

113116
// Cannot realistically overflow
@@ -123,10 +126,10 @@ contract Auction is IAuction, UUPS, Ownable, ReentrancyGuard, Pausable, AuctionS
123126
_handleOutgoingTransfer(highestBidder, highestBid);
124127
}
125128

126-
// Store the incoming bid as the new highest bid
129+
// Store the new highest bid
127130
auction.highestBid = msg.value;
128131

129-
// Store the caller as the new highest bidder
132+
// Store the new highest bidder
130133
auction.highestBidder = msg.sender;
131134

132135
// Used to store if the auction will be extended
@@ -151,7 +154,7 @@ contract Auction is IAuction, UUPS, Ownable, ReentrancyGuard, Pausable, AuctionS
151154
}
152155

153156
/// ///
154-
/// SETTLE & CREATE AUCTION ///
157+
/// SETTLE & CREATE AUCTION ///
155158
/// ///
156159

157160
/// @notice Settles the current auction and creates the next one
@@ -290,7 +293,7 @@ contract Auction is IAuction, UUPS, Ownable, ReentrancyGuard, Pausable, AuctionS
290293
return settings.timeBuffer;
291294
}
292295

293-
/// @notice The minimum percentage of the highest bid that a subsequent bid must beat
296+
/// @notice The minimum percentage an incoming bid must raise the highest bid
294297
function minBidIncrement() external view returns (uint256) {
295298
return settings.minBidIncrement;
296299
}

src/auction/IAuction.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ interface IAuction is IUUPS, IOwnable, IPausable {
123123
/// @notice The minimum amount of time to place a bid during an active auction
124124
function timeBuffer() external view returns (uint256);
125125

126-
/// @notice The minimum percentage of the highest bid that a subsequent bid must beat
126+
/// @notice The minimum percentage an incoming bid must raise the highest bid
127127
function minBidIncrement() external view returns (uint256);
128128

129129
/// @notice Updates the time duration of each auction

src/auction/types/AuctionTypesV1.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ contract AuctionTypesV1 {
99
/// @param treasury The DAO treasury
1010
/// @param duration The time duration of each auction
1111
/// @param timeBuffer The minimum time to place a bid
12-
/// @param minBidIncrement The minimum percentage an incoming bid must beat the highest bid by
12+
/// @param minBidIncrement The minimum percentage an incoming bid must raise the highest bid
1313
/// @param reservePrice The reserve price of each auction
1414
struct Settings {
1515
address treasury;

src/governance/governor/Governor.sol

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import { IGovernor } from "./IGovernor.sol";
1414

1515
/// @title Governor
1616
/// @author Rohan Kulkarni
17-
/// @notice DAO proposal manager and transaction scheduler
17+
/// @notice A DAO's proposal manager and transaction scheduler
18+
/// Modified from:
19+
/// - OpenZeppelin Contracts v4.7.3 (governance/extensions/GovernorTimelockControl.sol)
20+
/// - NounsDAOLogicV1.sol commit 2cbe6c7 - licensed under the BSD-3-Clause license.
1821
contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
1922
/// ///
2023
/// CONSTANTS ///
@@ -34,7 +37,7 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
3437
/// CONSTRUCTOR ///
3538
/// ///
3639

37-
/// @param _manager The address of the contract upgrade manager
40+
/// @param _manager The contract upgrade manager address
3841
constructor(address _manager) payable initializer {
3942
manager = IManager(_manager);
4043
}
@@ -76,10 +79,10 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
7679
settings.proposalThresholdBps = SafeCast.toUint16(_proposalThresholdBps);
7780
settings.quorumThresholdBps = SafeCast.toUint16(_quorumThresholdBps);
7881

79-
// Initialize support for off-chain voting
82+
// Initialize EIP-712 support
8083
__EIP712_init(string.concat(settings.token.symbol(), " GOV"), "1");
8184

82-
// Grant ownership of the contract to the treasury
85+
// Grant ownership to the treasury
8386
__Ownable_init(_treasury);
8487
}
8588

@@ -135,7 +138,7 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
135138
if (numTargets != _values.length) revert PROPOSAL_LENGTH_MISMATCH();
136139
if (numTargets != _calldatas.length) revert PROPOSAL_LENGTH_MISMATCH();
137140

138-
// Compute the hash of the description
141+
// Compute the description hash
139142
bytes32 descriptionHash = keccak256(bytes(_description));
140143

141144
// Compute the proposal id
@@ -144,7 +147,7 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
144147
// Get the pointer to store the proposal
145148
Proposal storage proposal = proposals[proposalId];
146149

147-
// Ensure a proposal with the same id doesn't already exist
150+
// Ensure the proposal doesn't already exist
148151
if (proposal.voteStart != 0) revert PROPOSAL_EXISTS(proposalId);
149152

150153
// Used to store the snapshot and deadline
@@ -161,7 +164,6 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
161164
// Store the proposal data
162165
proposal.voteStart = uint32(snapshot);
163166
proposal.voteEnd = uint32(deadline);
164-
165167
proposal.proposalThreshold = uint32(currentProposalThreshold);
166168
proposal.quorumVotes = uint32(quorum());
167169
proposal.proposer = msg.sender;
@@ -218,9 +220,9 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
218220
// Used to store the signed digest
219221
bytes32 digest;
220222

221-
// Cannot realistically overflow voter nonces
223+
// Cannot realistically overflow
222224
unchecked {
223-
// Compute the encoded message
225+
// Compute the message
224226
digest = keccak256(
225227
abi.encodePacked(
226228
"\x19\x01",
@@ -230,11 +232,11 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
230232
);
231233
}
232234

233-
// Recover the signer of the message
235+
// Recover the message signer
234236
address recoveredAddress = ecrecover(digest, _v, _r, _s);
235237

236238
// Ensure the recovered signer is the given voter
237-
if (recoveredAddress == address(0) || recoveredAddress != _voter) revert INVALID_SIGNER();
239+
if (recoveredAddress == address(0) || recoveredAddress != _voter) revert INVALID_SIGNATURE();
238240

239241
return _castVote(_proposalId, _voter, _support, "");
240242
}
@@ -249,7 +251,7 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
249251
uint256 _support,
250252
string memory _reason
251253
) internal returns (uint256) {
252-
// Ensure voting for the proposal is active
254+
// Ensure voting is active
253255
if (state(_proposalId) != ProposalState.Active) revert VOTING_NOT_STARTED();
254256

255257
// Ensure the voter hasn't already voted
@@ -304,8 +306,8 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
304306
// Ensure the proposal has succeeded
305307
if (state(_proposalId) != ProposalState.Succeeded) revert PROPOSAL_UNSUCCESSFUL();
306308

307-
// Schedule the proposal for execution and get the timestamp that it'll be valid to execute
308-
eta = settings.treasury.schedule(_proposalId);
309+
// Schedule the proposal for execution
310+
eta = settings.treasury.queue(_proposalId);
309311

310312
emit ProposalQueued(_proposalId, eta);
311313
}
@@ -320,9 +322,9 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
320322
/// @param _calldatas The calldata of each call
321323
/// @param _descriptionHash The hash of the description
322324
function execute(
323-
address[] memory _targets,
324-
uint256[] memory _values,
325-
bytes[] memory _calldatas,
325+
address[] calldata _targets,
326+
uint256[] calldata _values,
327+
bytes[] calldata _calldatas,
326328
bytes32 _descriptionHash
327329
) external payable returns (bytes32) {
328330
// Get the proposal id
@@ -334,7 +336,7 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
334336
// Mark the proposal as executed
335337
proposals[proposalId].executed = true;
336338

337-
// Call the treasury to execute the proposal
339+
// Execute the proposal
338340
settings.treasury.execute{ value: msg.value }(_targets, _values, _calldatas, _descriptionHash);
339341

340342
emit ProposalExecuted(proposalId);
@@ -518,12 +520,12 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
518520
/// GOVERNOR SETTINGS ///
519521
/// ///
520522

521-
/// @notice The minimum basis points of the total token supply required to submit a proposal
523+
/// @notice The basis points of the token supply required to create a proposal
522524
function proposalThresholdBps() external view returns (uint256) {
523525
return settings.proposalThresholdBps;
524526
}
525527

526-
/// @notice The minimum basis points of the total token supply required to reach quorum
528+
/// @notice The basis points of the token supply required to reach quorum
527529
function quorumThresholdBps() external view returns (uint256) {
528530
return settings.quorumThresholdBps;
529531
}
@@ -548,7 +550,7 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
548550
return address(settings.token);
549551
}
550552

551-
/// @notice The address of the transaction executor and treasury
553+
/// @notice The address of the treasury
552554
function treasury() external view returns (address) {
553555
return address(settings.treasury);
554556
}

src/governance/governor/types/GovernorTypesV1.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { Treasury } from "../../treasury/Treasury.sol";
99
/// @notice The Governor custom data types
1010
interface GovernorTypesV1 {
1111
/// @notice The governor settings
12-
/// @param token The governance token
13-
/// @param proposalThresholdBps The minimum votes (in basis points of the total supply) required to submit a proposal
14-
/// @param quorumThresholdBps The minimum votes (in basis points of total supply) required to reach quorum
15-
/// @param treasury The treasury controller
16-
/// @param votingDelay The amount of time after a proposal until voting begins
17-
/// @param votingPeriod The amount of time voting takes place for an active proposal
12+
/// @param token The DAO governance token
13+
/// @param proposalThresholdBps The basis points of the token supply required to create a proposal
14+
/// @param quorumThresholdBps The basis points of the token supply required to reach quorum
15+
/// @param treasury The DAO treasury
16+
/// @param votingDelay The time delay to vote on a created proposal
17+
/// @param votingPeriod The time period to vote on a proposal
1818
/// @param vetoer The address with the ability to veto proposals
1919
struct Settings {
2020
Token token;

src/governance/treasury/ITreasury.sol

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,39 +58,70 @@ interface ITreasury is IUUPS, IOwnable {
5858
/// FUNCTIONS ///
5959
/// ///
6060

61+
/// @notice Initializes a DAO's treasury
62+
/// @param governor The governor address
63+
/// @param delay The time delay to execute a queued transaction
6164
function initialize(address governor, uint256 delay) external;
6265

66+
/// @notice The timestamp that a proposal is valid to execute
67+
/// @param proposalId The proposal id
6368
function timestamp(bytes32 proposalId) external view returns (uint256);
6469

70+
/// @notice If a proposal has been queued
71+
/// @param proposalId The proposal ids
6572
function isQueued(bytes32 proposalId) external view returns (bool);
6673

74+
/// @notice If a proposal is ready to execute (does not consider if a proposal has expired)
75+
/// @param proposalId The proposal id
6776
function isReady(bytes32 proposalId) external view returns (bool);
6877

78+
/// @notice If a proposal has expired to execute
79+
/// @param proposalId The proposal id
6980
function isExpired(bytes32 proposalId) external view returns (bool);
7081

82+
/// @notice Hashes a proposal's details into its proposal id
83+
/// @param targets The target addresses to call
84+
/// @param values The ETH values of each call
85+
/// @param calldatas The calldata of each call
86+
/// @param descriptionHash The hash of the description
7187
function hashProposal(
7288
address[] calldata targets,
7389
uint256[] calldata values,
7490
bytes[] calldata calldatas,
7591
bytes32 descriptionHash
7692
) external pure returns (bytes32);
7793

78-
function schedule(bytes32 proposalId) external returns (uint256 eta);
94+
/// @notice Schedules a proposal for execution
95+
/// @param proposalId The proposal id
96+
function queue(bytes32 proposalId) external returns (uint256 eta);
7997

98+
/// @notice Removes a queued proposal
99+
/// @param proposalId The proposal id
80100
function cancel(bytes32 proposalId) external;
81101

102+
/// @notice Executes a queued proposal
103+
/// @param targets The target addresses to call
104+
/// @param values The ETH values of each call
105+
/// @param calldatas The calldata of each call
106+
/// @param descriptionHash The hash of the description
82107
function execute(
83108
address[] calldata targets,
84109
uint256[] calldata values,
85110
bytes[] calldata calldatas,
86-
bytes32 _descriptionHash
111+
bytes32 descriptionHash
87112
) external payable;
88113

114+
/// @notice The time delay to execute a queued transaction
89115
function delay() external view returns (uint256);
90116

117+
/// @notice The time period to execute a transaction
91118
function gracePeriod() external view returns (uint256);
92119

120+
/// @notice Updates the time delay
121+
/// @param newDelay The new time delay
93122
function updateDelay(uint256 newDelay) external;
94123

124+
/// @notice Updates the grace period
125+
/// @param newGracePeriod The grace period
95126
function updateGracePeriod(uint256 newGracePeriod) external;
96127
}

0 commit comments

Comments
 (0)