Artinals Protocol
  • Introduction
    • What is Artinals?
    • Overview of the Modules
    • Key Concepts and Terminology
  • Getting Started
    • Prerequisites
    • Cloning the Repository
    • Building and Testing the Modules
  • ART20
    • Overview and Capabilities
    • Data Structures
      • NFT
      • CollectionCap
      • UserBalance
      • TokenIdCounter
      • Dual IDs
    • Events
      • NFTMintedEvent
      • CollectionCreatedEvent
      • MetadataUpdateEvent
      • BurnEvent
      • TransferEvent
      • Additional Events
    • Functions and Entry Points
      • Initializing the Module
      • Creating Collections
      • Minting ART20 NFTs
      • Updating Metadata
      • Transfer and Burn Operations
      • Batch Operations
      • Deny List Mechanics and Authority
      • Custom Transfers
    • Value Sources (API, Oracle)
    • Best Practices & Examples
  • SALE Module
    • Purpose and Functionality
    • Interdependence
    • Price Index Module
    • Liquidity Module
    • Data Structures
      • NFTSale
      • NFTListing
  • Events
    • SaleCreated
    • NFTPurchased
    • PriceUpdateEvent
    • CurrencyWithdrawn
    • DenyList & Related Events
    • PoolCreatedEvent
    • OrderCanceled
    • OrderExecuted
  • Functions and Entry Points
    • Creating a Sale
    • Adding NFTs to a Sale
    • Purchasing NFTs from a Sale
    • Withdrawing Proceeds
    • Managing Sale State
    • Core Trading Functionality
  • Integrating with ART20
  • Examples & Best Practices
  • MARKET Module
    • Introduction
    • Testnet (Beta)
    • Smart Contract Overview
    • Data Structures
      • Trade Ledger (TradeLedger)
      • Trade Offer (TradeOffer)
      • Buy Offer (BuyOffer)
      • Ledger Registry (LedgerRegistry)
    • Event Structures
      • Offer Created (OfferCreated)
      • Offer Accepted (OfferAccepted)
      • Buy Offer Created (BuyOfferCreated)
      • Buy Offer Accepted (BuyOfferAccepted)
      • Batch Transactions
    • Event Emissions
    • Functions and Entry Points
      • Trade Ledger Management
      • Register Ledger
      • Get Trade Ledger
      • Create Sell Offer
      • Accept Sell Offer
      • Cancel Sell Offer
      • Create Buy Offer
      • Accept Buy Offer
      • Cancel Buy Offer
      • Batch Accept Sell Offers
      • Batch Accept Buy Offers
  • Security Mechanisms
  • TRADE Module
    • Introduction
    • Purpose and Ecosystem Role
    • Data Structures
      • TradingPool
      • LiquidityPosition
      • PriceOracle
      • CollectionPool
    • Events
      • PoolCreated
      • LiquidityAdded
      • LiquidityRemoved
      • TradeExecuted
      • PoolStatusChanged
      • PoolFeesUpdated
    • Functions and Entry Points
      • Creating and Managing Liquidity Pools
      • Adding/Removing Liquidity
      • Swapping NFTs and Tokens
      • Fee Mechanics and Distribution
      • Emergency Operations and Recovery
  • Working with Price Oracles
  • Metrics and Statistics (24h Volumes, TWAP, Price Impact)
  • Integration with SALE and ART20
  • Integration and Workflows
    • Typical User Journeys
      • Creating a Collection and Minting Tokens (ART20)
      • Listing and Selling NFTs (SALE)
      • Providing Liquidity and Trading NFTs (TRADE)
    • Example Scripts and Transactions
    • Interactions Between Modules
  • Security, Permissions, and Deny Lists
    • Introduction
    • Role of Deny List in ART20
    • Creator vs. Owner Permissions
    • Fee Distribution and Authority
    • Best Practices for Secure Deployment
  • Testing and Troubleshooting
    • Running Unit Tests
    • Common Issues and Solutions
    • Debugging and Emitting Debug Events
  • Advanced Topics
    • Value Sources (API Endpoints and Oracle Addresses)
    • Batch Update Operations
    • Customizing Parameters (Fees, Supply, Price Ranges)
    • Extensibility and Future Integrations
  • Appendices
    • Move Language and Sui Concepts
    • Glossary of Terms
    • Code Style and Conventions
  • Building on Top of the Artinals Contract
    • Overview
    • Package ID
    • Import Modules
    • Commom Integration Patterns
    • Best Practices
    • Common Errors and Solutions
Powered by GitBook
On this page
  1. SALE Module

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.

PreviousBest Practices & ExamplesNextInterdependence

Last updated 4 months ago