Implementation of auction module. More information in: ../../../docs
- Struct
App - Resource
AuctionHouse - Struct
Auction - Struct
AuctionStartedEvent - Struct
AuctionFinalizedEvent - Struct
BidEvent - Struct
AuctionExtendedEvent - Constants
- Function
init - Function
start_auction_and_place_bid - Function
place_bid - Function
claim - Function
get_auction_metadata - Function
collect_winning_auction_fund - Function
admin_withdraw_funds - Function
admin_finalize_auction - Function
admin_finalize_auction_internal - Function
admin_try_finalize_auctions
use 0x0::config;
use 0x0::domain;
use 0x0::registration_nft;
use 0x0::registry;
use 0x0::suins;
use 0x1::option;
use 0x1::string;
use 0x2::balance;
use 0x2::clock;
use 0x2::coin;
use 0x2::event;
use 0x2::linked_table;
use 0x2::object;
use 0x2::sui;
use 0x2::transfer;
use 0x2::tx_context;
Authorization witness to call protected functions of suins.
struct App has drop
Fields
-
dummy_field: bool
The AuctionHouse application.
struct AuctionHouse has store, key
Fields
The Auction application.
struct Auction has store
Fields
-
domain: domain::Domain -
start_timestamp_ms: u64 -
end_timestamp_ms: u64 -
winner: address -
current_bid: coin::Coin<sui::SUI> -
nft: registration_nft::RegistrationNFT
struct AuctionStartedEvent has copy, drop
Fields
-
domain: domain::Domain -
start_timestamp_ms: u64 -
end_timestamp_ms: u64 -
starting_bid: u64 -
bidder: address
struct AuctionFinalizedEvent has copy, drop
Fields
-
domain: domain::Domain -
start_timestamp_ms: u64 -
end_timestamp_ms: u64 -
winning_bid: u64 -
winner: address
struct BidEvent has copy, drop
Fields
-
domain: domain::Domain -
bid: u64 -
bidder: address
struct AuctionExtendedEvent has copy, drop
Fields
-
domain: domain::Domain -
end_timestamp_ms: u64
const ENoProfits: u64 = 13;
The auction bidding period is 2 days.
const AUCTION_BIDDING_PERIOD_MS: u64 = 172800000;
The auction quiet period is 10 minutes.
const AUCTION_MIN_QUIET_PERIOD_MS: u64 = 600000;
One year is the default duration for a domain.
const DEFAULT_DURATION: u8 = 1;
const EAuctionEnded: u64 = 9;
const EAuctionNotEndedYet: u64 = 8;
Placing a bid in a not started
const EAuctionNotStarted: u64 = 7;
Trying to start an action but it's already started.
const EAuctionStarted: u64 = 1;
const EBidAmountTooLow: u64 = 12;
The bid value is too low (compared to min_bid or previous bid).
const EInvalidBidValue: u64 = 0;
const ENotWinner: u64 = 10;
const EWinnerCannotPlaceBid: u64 = 11;
fun init(ctx: &mut tx_context::TxContext)
Start an auction if it's not started yet; and make the first bid.
public fun start_auction_and_place_bid(self: &mut auction::AuctionHouse, suins: &mut suins::SuiNS, domain_name: string::String, bid: coin::Coin<sui::SUI>, clock: &clock::Clock, ctx: &mut tx_context::TxContext)
Bidders use this function to place a new bid.
Panics
Panics if domain is invalid
or there isn't an auction for domain
or bid is too low,
public fun place_bid(self: &mut auction::AuctionHouse, domain_name: string::String, bid: coin::Coin<sui::SUI>, clock: &clock::Clock, ctx: &mut tx_context::TxContext)
Auction winner can come and claim the NFT
Panics sender is not the winner
public fun claim(self: &mut auction::AuctionHouse, domain_name: string::String, clock: &clock::Clock, ctx: &mut tx_context::TxContext): registration_nft::RegistrationNFT
Get metadata of an auction
The domain name being auctioned.
(start_timestamp_ms, end_timestamp_ms, winner, highest_amount)
public fun get_auction_metadata(self: &auction::AuctionHouse, domain_name: string::String): (option::Option<u64>, option::Option<u64>, option::Option<address>, option::Option<u64>)
public fun collect_winning_auction_fund(self: &mut auction::AuctionHouse, domain_name: string::String, clock: &clock::Clock, ctx: &mut tx_context::TxContext)
public fun admin_withdraw_funds(_: &suins::AdminCap, self: &mut auction::AuctionHouse, ctx: &mut tx_context::TxContext): coin::Coin<sui::SUI>
Admin functionality used to finalize a single auction.
An operation_limit limit must be provided which controls how many
individual operations to perform. This allows the admin to be able to
make forward progress in finalizing auctions even in the presence of
thousands of bids.
This will attempt to do as much as possible of the following
based on the provided operation_limit:
- claim the winning bid and place in
AuctionHouse.balance - push the
RegistrationNFTto the winner - push loosing bids back to their respective account owners
Once all of the above has been done the auction is destroyed, freeing on-chain storage.
public fun admin_finalize_auction(admin: &suins::AdminCap, self: &mut auction::AuctionHouse, domain: string::String, clock: &clock::Clock)
fun admin_finalize_auction_internal(_: &suins::AdminCap, self: &mut auction::AuctionHouse, domain: domain::Domain, clock: &clock::Clock)
Admin functionality used to finalize an arbitrary number of auctions.
An operation_limit limit must be provided which controls how many
individual operations to perform. This allows the admin to be able to
make forward progress in finalizing auctions even in the presence of
thousands of auctions/bids.
public fun admin_try_finalize_auctions(admin: &suins::AdminCap, self: &mut auction::AuctionHouse, operation_limit: u64, clock: &clock::Clock)