Skip to content

Commit

Permalink
Merge branch 'batch-auctions' of https://github.com/Bond-Protocol/moo…
Browse files Browse the repository at this point in the history
…nraker into batch-auctions
  • Loading branch information
Oighty committed Jan 31, 2024
2 parents be60e9d + af979c4 commit 9ea5dae
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/bases/Auctioneer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ abstract contract Auctioneer is WithModules {
}

// Perform pre-funding, if needed
if (requiresPrefunding) {
// It does not make sense to pre-fund the auction if the capacity is in quote tokens
if (requiresPrefunding == true && params_.capacityInQuote == false) {
// Store pre-funding information
routing.prefunded = true;

Expand Down Expand Up @@ -324,8 +325,11 @@ abstract contract Auctioneer is WithModules {
// Cancel the auction on the module
module.cancelAuction(lotId_);

// If the auction is prefunded, transfer the remaining capacity to the owner
if (lotRouting[lotId_].prefunded && lotRemainingCapacity > 0) {
// If the auction is prefunded and supported, transfer the remaining capacity to the owner
if (
lotRouting[lotId_].prefunded == true && module.capacityInQuote(lotId_) == false
&& lotRemainingCapacity > 0
) {
// Transfer payout tokens to the owner
Routing memory routing = lotRouting[lotId_];
routing.baseToken.safeTransfer(routing.owner, lotRemainingCapacity);
Expand Down
14 changes: 14 additions & 0 deletions src/modules/Auction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ abstract contract Auction {
/// @param lotId_ The lot id
/// @return uint256 The remaining capacity of the lot
function remainingCapacity(uint96 lotId_) external view virtual returns (uint256);

/// @notice Get whether or not the capacity is in quote tokens
/// @dev The implementing function should handle the following:
/// - Return true if the capacity is in quote tokens
/// - Return false if the capacity is in base tokens
///
/// @param lotId_ The lot id
/// @return bool Whether or not the capacity is in quote tokens
function capacityInQuote(uint96 lotId_) external view virtual returns (bool);
}

abstract contract AuctionModule is Auction, Module {
Expand Down Expand Up @@ -532,6 +541,11 @@ abstract contract AuctionModule is Auction, Module {
return lotData[lotId_].capacity;
}

/// @inheritdoc Auction
function capacityInQuote(uint96 lotId_) external view override returns (bool) {
return lotData[lotId_].capacityInQuote;
}

/// @notice Get the lot data for a given lot ID
///
/// @param lotId_ The lot ID
Expand Down
11 changes: 11 additions & 0 deletions src/modules/auctions/LSBBA/LSBBA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,17 @@ contract LocalSealedBidBatchAuction is AuctionModule {
return (marginalPrice, numWinningBids);
}

/// @inheritdoc AuctionModule
/// @dev This function performs the following:
/// - Validates inputs
/// - Iterates over the bid queue to calculate the marginal clearing price of the auction
/// - Creates an array of winning bids
/// - Sets the auction status to settled
/// - Returns the array of winning bids
///
/// This function reverts if:
/// - The auction is not in the Decrypted state
/// - The auction has already been settled
function _settle(uint96 lotId_)
internal
override
Expand Down

0 comments on commit 9ea5dae

Please sign in to comment.