0x0::bidding

Bidding module that allows users to bid for any given NFT in a safe, giving NFT owners a platform to sell their NFTs to any available bid.

Structs

bidding::Witness has drop

=== Structs === Witness used to authenticate witness protected endpoints

bidding::Bid<FT> has key

Fields:

Name Type Description
id object::UID
nft object::ID
buyer address
safe object::ID
offer balance::Balance<FT>
commission option::Option<trading::BidCommission<FT>>

bidding::BidCreatedEvent has copy, drop

Fields:

Name Type Description
bid object::ID
nft object::ID
price u64
commission u64
buyer address
buyer_safe object::ID
ft_type ascii::String

bidding::BidClosedEvent has copy, drop

Fields:

Name Type Description
bid object::ID
nft object::ID
buyer address
price u64
ft_type ascii::String

Bid was closed by the user, no sell happened

bidding::BidMatchedEvent has copy, drop

Fields:

Name Type Description
bid object::ID
nft object::ID
price u64
seller address
buyer address
ft_type ascii::String
nft_type ascii::String

NFT was sold

Methods

public entry fun create_bid<FT>(
    nft: object::ID,
    buyers_safe: object::ID,
    price: u64,
    wallet: &mut coin::Coin<FT>,
    ctx: &mut tx_context::TxContext,
)

=== Entry points === Payable entry function to create a bid for an NFT.

It performs the following:

  • Sends funds Balance from wallet to the bid
  • Creates object bid and shares it.

public entry fun create_bid_with_commission<FT>(
    nft: object::ID,
    buyers_safe: object::ID,
    price: u64,
    beneficiary: address,
    commission_ft: u64,
    wallet: &mut coin::Coin<FT>,
    ctx: &mut tx_context::TxContext,
)

Payable entry function to create a bid for an NFT.

It performs the following:

  • Sends funds Balance from wallet to the bid
  • Creates object bid with commission and shares it.

To be called by a intermediate application, for the purpose of securing a commission for intermediating the process.

public entry fun sell_nft<C, FT>(
    bid: &mut bidding::Bid<FT>,
    transfer_cap: safe::TransferCap,
    sellers_safe: &mut safe::Safe,
    buyers_safe: &mut safe::Safe,
    allowlist: &transfer_allowlist::Allowlist,
    ctx: &mut tx_context::TxContext,
)

Entry function to sell an NFT with an open bid.

It performs the following:

  • Splits funds from Bid<FT> by:
    • (1) Creating TradePayment<C, FT> for the trade amount
  • Transfers NFT from sellers_safe to buyers_safe and burns TransferCap
  • Transfers bid commission funds to the address bid.commission.beneficiary

public entry fun sell_generic_nft<C: store + key, FT>(
    bid: &mut bidding::Bid<FT>,
    transfer_cap: safe::TransferCap,
    sellers_safe: &mut safe::Safe,
    buyers_safe: &mut safe::Safe,
    ctx: &mut tx_context::TxContext,
)

Similar to [sell_nft] except that this is meant for generic collections, ie. those which aren't native to our protocol.

public entry fun sell_nft_with_commission<C, FT>(
    bid: &mut bidding::Bid<FT>,
    transfer_cap: safe::TransferCap,
    beneficiary: address,
    commission_ft: u64,
    sellers_safe: &mut safe::Safe,
    buyers_safe: &mut safe::Safe,
    allowlist: &transfer_allowlist::Allowlist,
    ctx: &mut tx_context::TxContext,
)

Entry function to sell an NFT with an open bid.

It performs the following:

  • Splits funds from Bid<FT> by:
    • (1) Creating TradePayment<C, FT> for the Ask commission
    • (2) Creating TradePayment<C, FT> for the net trade amount
  • Transfers NFT from sellers_safe to buyers_safe and burns TransferCap
  • Transfers bid commission funds to the address bid.commission.beneficiary

To be called by a intermediate application, for the purpose of securing a commission for intermediating the process.

public entry fun sell_generic_nft_with_commission<C: store + key, FT>(
    bid: &mut bidding::Bid<FT>,
    transfer_cap: safe::TransferCap,
    beneficiary: address,
    commission_ft: u64,
    sellers_safe: &mut safe::Safe,
    buyers_safe: &mut safe::Safe,
    ctx: &mut tx_context::TxContext,
)

Similar to [sell_nft_with_commission] except that this is meant for generic collections, ie. those which aren't native to our protocol.

public entry fun close_bid<FT>(
    bid: &mut bidding::Bid<FT>,
    ctx: &mut tx_context::TxContext,
)

If a user wants to cancel their position, they get their coins back.

public fun share<FT>(bid: bidding::Bid<FT>)

=== Helpers ===

public fun new_bid<FT>(
    nft: object::ID,
    buyers_safe: object::ID,
    price: u64,
    commission: option::Option<trading::BidCommission<FT>>,
    wallet: &mut coin::Coin<FT>,
    ctx: &mut tx_context::TxContext,
): 
    bidding::Bid<FT>

Sends funds Balance from wallet to the bid and shares object bid.