-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'auction-usdc' into weekly-auction-call
- Loading branch information
Showing
1 changed file
with
42 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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; | ||
} | ||
|
||
|
@@ -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; | ||
|