From d9e9fe09643b351c1a6fc9c65df928ea2c3eef63 Mon Sep 17 00:00:00 2001 From: Flocqst Date: Fri, 25 Oct 2024 20:16:29 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20bidBuffer=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AuctionFactory.sol | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/AuctionFactory.sol b/src/AuctionFactory.sol index b3e4296..9007896 100644 --- a/src/AuctionFactory.sol +++ b/src/AuctionFactory.sol @@ -7,12 +7,25 @@ import "@openzeppelin/contracts/proxy/Clones.sol"; /// @title Auction Factory Contract for USDC-KWENTA Auctions /// @author Flocqst (florian@kwenta.io) 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 @@ -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) { @@ -36,21 +59,19 @@ 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( @@ -58,6 +79,14 @@ contract AuctionFactory { ); } + /// @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;