Skip to content

Commit

Permalink
Merge branch 'auction-usdc' into weekly-auction-call
Browse files Browse the repository at this point in the history
  • Loading branch information
cmontecoding committed Oct 25, 2024
2 parents 9774bf9 + b25bcc5 commit c6cca60
Showing 1 changed file with 42 additions and 16 deletions.
58 changes: 42 additions & 16 deletions src/AuctionFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +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 @@ -26,11 +38,21 @@ contract AuctionFactory {
address[] allAuctions
);

/// @notice Constructs the AuctionFactory with the address of the auction
/// implementation contract
/// @param _auctionImplementation The address of the auction implementation
/// contract
constructor(address _auctionImplementation) {
/// @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 _pDAO Kwenta owned/operated multisig address
/// @param _auctionImplementation The address of the auction implementation contract
constructor(address _pDAO, address _auctionImplementation) {
pDAO = _pDAO;
auctionImplementation = _auctionImplementation;
}

Expand All @@ -40,31 +62,35 @@ 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
/// @return newAuction The newly created auction contract
/// @dev The newly created auction contract is initialized and added to the auctions array and returned
function createAuction(
address _owner,
address _usdc,
address _kwenta,
uint256 _startingBid,
uint256 _bidBuffer
)
external
{
uint256 _startingBid
) external returns (Auction newAuction) {
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);
newAuction =
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 c6cca60

Please sign in to comment.