Skip to content

Latest commit

 

History

History
628 lines (353 loc) · 15.3 KB

File metadata and controls

628 lines (353 loc) · 15.3 KB

Module 0x0::auction

Implementation of auction module. More information in: ../../../docs

Struct App

Authorization witness to call protected functions of suins.

struct App has drop
Fields
dummy_field: bool

Resource AuctionHouse

The AuctionHouse application.

struct AuctionHouse has store, key
Fields
id: object::UID
balance: balance::Balance<sui::SUI>
auctions: linked_table::LinkedTable<domain::Domain, auction::Auction>

Struct Auction

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

struct AuctionStartedEvent has copy, drop
Fields
domain: domain::Domain
start_timestamp_ms: u64
end_timestamp_ms: u64
starting_bid: u64
bidder: address

Struct AuctionFinalizedEvent

struct AuctionFinalizedEvent has copy, drop
Fields
domain: domain::Domain
start_timestamp_ms: u64
end_timestamp_ms: u64
winning_bid: u64
winner: address

Struct BidEvent

struct BidEvent has copy, drop
Fields
domain: domain::Domain
bid: u64
bidder: address

Struct AuctionExtendedEvent

struct AuctionExtendedEvent has copy, drop
Fields
domain: domain::Domain
end_timestamp_ms: u64

Constants

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;

Function init

fun init(ctx: &mut tx_context::TxContext)

Function start_auction_and_place_bid

Start an auction if it's not started yet; and make the first bid.

Function place_bid

Notice

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,

Function claim

Notice

Auction winner can come and claim the NFT

Panics sender is not the winner

Function get_auction_metadata

Notice

Get metadata of an auction

Params

The domain name being auctioned.

Return

(start_timestamp_ms, end_timestamp_ms, winner, highest_amount)

Function collect_winning_auction_fund

Function admin_withdraw_funds

Function admin_finalize_auction

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 RegistrationNFT to 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.

Function admin_finalize_auction_internal

Function admin_try_finalize_auctions

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)