Skip to content

Commit

Permalink
✨ prettify
Browse files Browse the repository at this point in the history
  • Loading branch information
Flocqst committed Jul 31, 2024
1 parent debfcce commit bfedeb6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
27 changes: 18 additions & 9 deletions src/Auction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";


contract Auction is Ownable, Initializable {
event Start();
event Bid(address indexed sender, uint256 amount);
Expand All @@ -14,7 +13,9 @@ contract Auction is Ownable, Initializable {
event BidBufferUpdated(uint256 newBidIncrement);
event BiddingLocked();
event BiddingUnlocked();
event FundsWithdrawn(address indexed owner, uint256 usdcAmount, uint256 kwentaAmount);
event FundsWithdrawn(
address indexed owner, uint256 usdcAmount, uint256 kwentaAmount
);

error AuctionAlreadyStarted();
error AuctionNotStarted();
Expand All @@ -40,7 +41,13 @@ contract Auction is Ownable, Initializable {
uint256 public highestBid;
mapping(address => uint256) public bids;

constructor(address initialOwner, address _usdc, address _kwenta, uint256 _startingBid, uint256 _bidBuffer) Ownable(initialOwner) {
constructor(
address initialOwner,
address _usdc,
address _kwenta,
uint256 _startingBid,
uint256 _bidBuffer
) Ownable(initialOwner) {
usdc = IERC20(_usdc);
kwenta = IERC20(_kwenta);

Expand All @@ -49,10 +56,10 @@ contract Auction is Ownable, Initializable {
}

function initialize(
address initialOwner,
address _usdc,
address _kwenta,
uint256 _startingBid,
address initialOwner,
address _usdc,
address _kwenta,
uint256 _startingBid,
uint256 _bidBuffer
) public initializer {
_transferOwnership(initialOwner);
Expand All @@ -64,7 +71,7 @@ contract Auction is Ownable, Initializable {
bidBuffer = _bidBuffer;
}

function start(uint256 _auctionAmount) external onlyOwner{
function start(uint256 _auctionAmount) external onlyOwner {
if (started) revert AuctionAlreadyStarted();

usdc.transferFrom(msg.sender, address(this), _auctionAmount);
Expand All @@ -79,7 +86,9 @@ contract Auction is Ownable, Initializable {
function bid(uint256 amount) external Lock {
if (!started) revert AuctionNotStarted();
if (block.timestamp >= endAt) revert AuctionAlreadyEnded();
if (amount <= highestBid + bidBuffer) revert BidTooLow(highestBid + bidBuffer);
if (amount <= highestBid + bidBuffer) {
revert BidTooLow(highestBid + bidBuffer);
}

kwenta.transferFrom(msg.sender, address(this), amount);

Expand Down
21 changes: 15 additions & 6 deletions src/AuctionFactory.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;

import { Auction } from './Auction.sol';
import {Auction} from "./Auction.sol";
import "@openzeppelin/contracts/proxy/Clones.sol";


contract AuctionFactory {
address public auctionImplementation;
address[] public auctions;

event AuctionCreated(address auctionContract, address owner, uint numAuctions, address[] allAuctions);
event AuctionCreated(
address auctionContract,
address owner,
uint256 numAuctions,
address[] allAuctions
);

constructor(address _auctionImplementation) {
auctionImplementation = _auctionImplementation;
Expand All @@ -23,11 +27,16 @@ contract AuctionFactory {
uint256 _bidBuffer
) external {
address clone = Clones.clone(auctionImplementation);
Auction(clone).initialize(_pDAO, _usdc, _kwenta, _startingBid, _bidBuffer);
Auction newAuction = new Auction(_pDAO, _usdc, _kwenta, _startingBid, _bidBuffer);
Auction(clone).initialize(
_pDAO, _usdc, _kwenta, _startingBid, _bidBuffer
);
Auction newAuction =
new Auction(_pDAO, _usdc, _kwenta, _startingBid, _bidBuffer);
auctions.push(address(newAuction));

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

function getAllAuctions() external view returns (address[] memory) {
Expand Down

0 comments on commit bfedeb6

Please sign in to comment.