Skip to content

Commit

Permalink
👷 bidBuffer change
Browse files Browse the repository at this point in the history
  • Loading branch information
Flocqst committed Oct 25, 2024
1 parent 4a45478 commit d9e9fe0
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions src/AuctionFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,25 @@ import "@openzeppelin/contracts/proxy/Clones.sol";
/// @title Auction Factory Contract for USDC-KWENTA Auctions
/// @author Flocqst ([email protected])
contract AuctionFactory {
/// @notice Kwenta owned/operated multisig address that
/// can authorize upgrades
/// @dev making immutable because the pDAO address
/// will *never* change
address internal immutable pDAO;

/// @notice Address of the auction implementation contract
address public auctionImplementation;

/// @notice Array of all auctions created
address[] public auctions;

/// @notice Bid buffer amount used for all auctions
uint256 public bidBuffer;

/// @notice thrown when attempting to update
/// the bidBuffer when caller is not the Kwenta pDAO
error OnlyPDAO();

/// @notice Emitted when a new auction is created
/// @param auctionContract The address of the newly created auction contract
/// @param owner The address of the account that created the auction
Expand All @@ -25,6 +38,16 @@ contract AuctionFactory {
address[] allAuctions
);

/// @notice Emitted when the bid buffer is updated
/// @param _newBidBuffer The new bid buffer value
event BidBufferUpdated(uint256 _newBidBuffer);

/// @notice Modifier to restrict access to pDAO only
modifier onlyPDAO() {
if (msg.sender != pDAO) revert OnlyPDAO();
_;
}

/// @notice Constructs the AuctionFactory with the address of the auction implementation contract
/// @param _auctionImplementation The address of the auction implementation contract
constructor(address _auctionImplementation) {
Expand All @@ -36,28 +59,34 @@ contract AuctionFactory {
/// @param _usdc The address for the USDC ERC20 token
/// @param _kwenta The address for the KWENTA ERC20 token
/// @param _startingBid The starting bid amount
/// @param _bidBuffer The initial bid buffer amount
/// @dev The newly created auction contract is initialized and added to the auctions array
function createAuction(
address _owner,
address _usdc,
address _kwenta,
uint256 _startingBid,
uint256 _bidBuffer
uint256 _startingBid
) external {
address clone = Clones.clone(auctionImplementation);
Auction(clone).initialize(
_owner, _usdc, _kwenta, _startingBid, _bidBuffer
_owner, _usdc, _kwenta, _startingBid, bidBuffer
);
Auction newAuction =
new Auction(_owner, _usdc, _kwenta, _startingBid, _bidBuffer);
new Auction(_owner, _usdc, _kwenta, _startingBid, bidBuffer);
auctions.push(address(newAuction));

emit AuctionCreated(
address(newAuction), msg.sender, auctions.length, auctions
);
}

/// @notice Updates the bid buffer amount
/// @param _newBidBuffer The new bid buffer value to set
/// @dev Only callable by pDAO
function updateBidBuffer(uint256 _newBidBuffer) external onlyPDAO {
bidBuffer = _newBidBuffer;
emit BidBufferUpdated(_newBidBuffer);
}

/// @notice Returns the array of all auction contract addresses
function getAllAuctions() external view returns (address[] memory) {
return auctions;
Expand Down

0 comments on commit d9e9fe0

Please sign in to comment.