0x0::limited_fixed_price

Module of LimitedFixedPriceMarket

LimitedFixedPriceMarket functions as a FixedPriceMarket but allows limiting the amount of NFTs that an address is allowed to buy from it.

It implements a fixed price sale configuration, where all NFTs in the inventory get sold at a fixed price.

NFT creators can decide to use multiple markets to create a tiered market sale by segregating NFTs by different sale segments.

Structs

limited_fixed_price::LimitedFixedPriceMarket<FT> has store, key

Fields:

Name Type Description
id object::UID

LimitedFixedPriceMarket ID

limit u64

Limit of how many NFTs each account is allowed to buy from this market

price u64

Fixed price denominated in fungible-token, FT

inventory_id object::ID

Warehouse or Factory that the market will redeem from

addresses vec_map::VecMap<address, u64>

Stores the withdraw count for each address

TODO: Replace with data structure that compresses address count

Fixed price market object

limited_fixed_price::Witness has drop

Witness used to authenticate witness protected endpoints

Methods

public fun new<FT>(
    inventory_id: object::ID,
    limit: u64,
    price: u64,
    ctx: &mut tx_context::TxContext,
): limited_fixed_price::LimitedFixedPriceMarket<FT>

Create a new LimitedFixedPriceMarket<FT>

Price is denominated in fungible token, FT, such as SUI.

Requires that Inventory with given ID exists on the Listing that this market will be inserted into.

public entry fun init_market<FT>(
    inventory_id: object::ID,
    limit: u64,
    price: u64,
    ctx: &mut tx_context::TxContext,
)

Creates a LimitedFixedPriceMarket<FT> and transfers to transaction sender

Price is denominated in fungible token, FT, such as SUI.

Requires that Inventory with given ID exists on the Listing that this market will be inserted into.

This market can later be consumed by listing::init_venue or venue::init_venue for later use in a launchpad listing.

public entry fun init_venue<C, FT>(
    listing: &mut listing::Listing,
    inventory_id: object::ID,
    is_whitelisted: bool,
    limit: u64,
    price: u64,
    ctx: &mut tx_context::TxContext,
)

Initializes a Venue with LimitedFixedPriceMarket<FT>

Price is denominated in fungible token, FT, such as SUI.

Requires that Inventory with given ID exists on the Listing that this market will be inserted into.

Resultant Venue can later be consumed by listing::add_venue for later use in a launchpad listing.

Panics

Panics if Inventory with given ID does not exist on Listing or if transaction sender is not the Listing admin.

public fun create_venue<C, FT>(
    listing: &mut listing::Listing,
    inventory_id: object::ID,
    is_whitelisted: bool,
    limit: u64,
    price: u64,
    ctx: &mut tx_context::TxContext,
): object::ID

Creates a Venue with LimitedFixedPriceMarket<FT>

Price is denominated in fungible token, FT, such as SUI.

Requires that Inventory with given ID exists on the Listing that this market will be inserted into.

Resultant Venue can later be consumed by listing::add_venue for later use in a launchpad listing.

Panics

Panics if Inventory with given ID does not exist on Listing or if transaction sender is not the Listing admin.

public fun borrow_count<FT>(
    market: &limited_fixed_price::LimitedFixedPriceMarket<FT>,
    who: address,
): 
    u64

Returns how many NFTs the given address bought from the market

public fun increment_count<FT>(
    market: &mut limited_fixed_price::LimitedFixedPriceMarket<FT>,
    who: address,
)

Increments count while enforcing market limit

Panics

Panics if limit is violated

public entry fun buy_nft<C, FT>(
    listing: &mut listing::Listing,
    venue_id: object::ID,
    wallet: &mut coin::Coin<FT>,
    ctx: &mut tx_context::TxContext,
)

Buy NFT for non-whitelisted sale

Panics

Panics if Venue does not exist, is not live, or is whitelisted or wallet does not have the necessary funds.

public entry fun buy_nft_into_safe<C, FT>(
    listing: &mut listing::Listing,
    venue_id: object::ID,
    wallet: &mut coin::Coin<FT>,
    buyer_safe: &mut safe::Safe,
    ctx: &mut tx_context::TxContext,
)

Buy NFT for non-whitelisted sale

Panics

Panics if Venue does not exist, is not live, or is whitelisted or wallet does not have the necessary funds.

public entry fun create_safe_and_buy_nft<C, FT>(
    listing: &mut listing::Listing,
    venue_id: object::ID,
    wallet: &mut coin::Coin<FT>,
    ctx: &mut tx_context::TxContext,
)

Buy NFT for non-whitelisted sale. Deposits the NFT to a safe and transfers the ownership to the buyer.

Panics

Panics if Venue does not exist, is not live, or is whitelisted or wallet does not have the necessary funds.

public entry fun buy_whitelisted_nft<C, FT>(
    listing: &mut listing::Listing,
    venue_id: object::ID,
    wallet: &mut coin::Coin<FT>,
    whitelist_token: market_whitelist::Certificate,
    ctx: &mut tx_context::TxContext,
)

Buy NFT for whitelisted sale

Panics

  • If Venue does not exist, is not live, or is not whitelisted
  • If whitelist Certificate was not issued for given market

public entry fun buy_whitelisted_nft_into_safe<C, FT>(
    listing: &mut listing::Listing,
    venue_id: object::ID,
    wallet: &mut coin::Coin<FT>,
    safe: &mut safe::Safe,
    whitelist_token: market_whitelist::Certificate,
    ctx: &mut tx_context::TxContext,
)

Buy NFT for whitelisted sale Deposits the NFT to a safe and transfers the ownership to the buyer.

Panics

  • If Venue does not exist, is not live, or is not whitelisted
  • If whitelist Certificate was not issued for given market

public entry fun create_safe_and_buy_whitelisted_nft<C, FT>(
    listing: &mut listing::Listing,
    venue_id: object::ID,
    wallet: &mut coin::Coin<FT>,
    whitelist_token: market_whitelist::Certificate,
    ctx: &mut tx_context::TxContext,
)

Buy NFT for whitelisted sale Deposits the NFT to a safe and transfers the ownership to the buyer.

Panics

  • If Venue does not exist, is not live, or is not whitelisted
  • If whitelist Certificate was not issued for given market

public entry fun set_limit<FT>(
    listing: &mut listing::Listing,
    venue_id: object::ID,
    new_limit: u64,
    ctx: &mut tx_context::TxContext,
)

Change market limit

Limit can only be increased.

Panics

Panics if transaction sender is not Listing admin or if limit was decreased.

public entry fun set_price<FT>(
    listing: &mut listing::Listing,
    venue_id: object::ID,
    new_price: u64,
    ctx: &mut tx_context::TxContext,
)

Change market price

Panics

Panics if transaction sender is not Listing admin.

public fun limit<FT>(
    market: &limited_fixed_price::LimitedFixedPriceMarket<FT>,
): 
    u64

Return market limit

public fun price<FT>(
    market: &limited_fixed_price::LimitedFixedPriceMarket<FT>,
): 
    u64

Return market price

public fun assert_limit<FT>(
    market: &limited_fixed_price::LimitedFixedPriceMarket<FT>,
    limit: u64,
)

Asserts that limit does not violate market limit

Panics

Panics if limit is greater than market limit.