Purpose and Functionality
The SALE module extends the ART20 module by providing integrated marketplace functionality. It enables creators and collectors to list their ART20 NFTs for sale at fixed prices, facilitating direct purchases and inventory management.
Key Features:
NFT Listing with Rich Metadata: Sellers can create sales with detailed information about their NFTs, including optional metadata like dimensions, creation year, medium, provenance, authenticity, and signature.
Dynamic Inventory Control: Add or remove NFTs from an active sale to respond to market demand or adjust offerings.
Flexible Withdrawal with Splitting: Withdraw accumulated funds from sales and optionally split the proceeds among multiple recipients based on predefined percentages.
Comprehensive Event Tracking: Monitor sale activities through events emitted for sale creation, NFT purchases, price updates, and withdrawals. These events enable off-chain tracking, analytics, and transparent transaction history.
Enhanced Safety and Security: The module incorporates safety checks to prevent arithmetic overflows and ensure secure fund transfers. It also integrates with the ART20 deny list to enforce restrictions and prevent unauthorized transactions.
Informative View Functions: Access essential sale and NFT data through a variety of view functions, facilitating integration with external applications and user interfaces.
Functions:
create_nft_sale
: Creates a new NFT sale with specified parameters, including the NFTs to be listed, price per NFT, and optional metadata.purchase_nfts
: Allows buyers to purchase NFTs from an active sale.add_nfts_to_sale
: Adds more NFTs to an existing sale.withdraw_currency
: Withdraws funds from a sale, with the option to split the proceeds among multiple recipients.remove_nfts_from_sale
: Removes NFTs from an active sale.close_sale
: Deactivates a sale, preventing further purchases.reopen_sale
: Reactivates a closed sale.update_sale_price
: Updates the price per NFT for an active sale.has_nft
: Checks if an NFT is listed in a sale.get_nft_count
: Returns the total number of NFTs in a sale.get_available_nft_count
: Returns the number of available NFTs in a sale.get_sale_balance
: Returns the current balance of funds in a sale.get_sale_info
: Returns key information about a sale, including creator, NFT count, price, and status.get_full_sale_status
: Returns comprehensive information about a sale, including creator, NFT count, price, status, and balance.
Events:
SaleCreated
: Emitted when a new sale is created.NFTPurchased
: Emitted when NFTs are purchased from a sale.PriceUpdateEvent
: Emitted when the price of an NFT in a sale is updated.CurrencyWithdrawn
: Emitted when funds are withdrawn from a sale.CurrencyWithdrawSplit
: Emitted for each recipient when funds are split during withdrawal.NFTListingEvent
: Emitted when an NFT is listed in a sale.TransferEvent
: Emitted when an NFT is transferred.BatchTransferEvent
: Emitted when multiple NFTs are transferred.SaleStatusChanged
: Emitted when the status of a sale changes (open/closed).PriceUpdated
: Emitted when the price of an NFT in a sale is updated.
This module provides a streamlined and efficient way to manage NFT sales within the ART20 ecosystem. By leveraging its features, creators and collectors can easily buy and sell NFTs, contributing to a more dynamic and accessible marketplace. Trade Features
The NFTPool
and associated functions in the SALE
module provide a robust system for trading ART20 NFTs using an order book model. This enables buyers and sellers to interact directly with each other by placing bids and asks, facilitating price discovery and creating a more dynamic marketplace.
Key Features:
Order Book Model: The
NFTPool
object acts as an order book, storing buy (bid) and sell (ask) orders for NFTs within a specific collection.Order Creation: Sellers can create sell orders (
create_sell_order
) by specifying the quantity of NFTs they want to sell and the price per NFT. Buyers can create buy orders (create_buy_order
) by indicating the quantity they want to buy and the maximum price they are willing to pay.Order Matching: The
match_orders
function automatically matches compatible buy and sell orders based on price and time priority. This ensures fair and efficient trade execution.Order Cancellation: Both buyers and sellers can cancel their existing orders (
cancel_order
) if they wish to withdraw from the market.Price Information: The module provides functions to retrieve the best bid (
get_best_bid
), best ask (get_best_ask
), and spread (get_spread
) for a given pool, aiding in price discovery and market analysis.Order Queries: Users can query their own orders (
get_user_orders
) or retrieve all active bids and asks (get_all_bids
,get_all_asks
) within a pool.
Functions:
create_trade_pool
: Creates a new NFT trading pool for a specific collection and currency.create_sell_order
: Creates a sell order for a specified quantity of NFTs at a given price.create_buy_order
: Creates a buy order for a specified quantity of NFTs at a given price.cancel_order
: Cancels an existing bid or ask order.match_orders
: Matches compatible buy and sell orders and executes trades.get_best_bid
: Returns the highest current bid price in the pool.get_best_ask
: Returns the lowest current ask price in the pool.get_spread
: Returns the difference between the best bid and best ask.get_user_orders
: Returns all active orders for a specific user.get_all_asks
: Returns all active sell orders in the pool.get_all_bids
: Returns all active buy orders in the pool.
Events:
PoolCreatedEvent
: Emitted when a new trading pool is created.OrderCanceled
: Emitted when an order is canceled.TradeExecuted
: Emitted when a trade is executed between a buyer and seller.
These trade features provide a flexible and efficient platform for buying and selling ART20 NFTs. By utilizing the order book model and automated matching, the module promotes a more dynamic and transparent marketplace experience.
Last updated