Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR is part of #9765. This PR introduces
pallet-auction, a new FRAME pallet that provides a generic framework for on-chain auctions. The pallet allows for the creation and management of auctions for any type of asset, with customizable logic through theAuctionHandlertrait.The auction pallet implements a flexible auction mechanism that can be used to implement various auction types, such as English auctions, Dutch auctions, or other custom formats. It provides a standard interface through the
Auctiontrait so other pallets can query and update auctions via a shared API.Integration
This PR introduces a new pallet (
pallet-auction) that downstream projects can integrate into their runtime. The integration requires:construct_runtime!macroAuctionHandlertrait to define custom auction logicBalance,AuctionId) in your runtime's configExample integration:
The pallet is designed to be generic and can work with any asset type through the handler implementation.
Review Notes
Implementation Details
The auction pallet uses a simple but effective storage design:
Auctions<T>: Maps auction IDs to auction information including current bid and timingAuctionEndTime<T>: Double map from end block to auction ID for efficient batch processing of ending auctionsAuctionsIndex<T>: Tracks the next available auction ID for new auction creationKey Features
AuctionHandlertrait allows for custom implementation of auction logicon_finalizehookAuctiontrait for interoperabilityAuction Lifecycle
new_auction()bid()Storage Efficiency
The pallet uses efficient storage patterns:
AuctionEndTimeallows batch processing of ending auctionsError Handling
The pallet includes comprehensive error handling:
AuctionNotExist: For invalid auction IDsAuctionNotStarted: For bids placed before auction startBidNotAccepted: For bids rejected by the handlerInvalidBidPrice: For invalid bid amountsNoAvailableAuctionId: For auction ID overflowSecurity Considerations
Checklist
Trequired)