FantomAuction.sol

Documentation for FantomAuction.sol


Overview

FantomAuction is a contract that allows users to create and participate in Digital Asset auctions on the Fantom blockchain. It encompasses a wide range of features including the creation of auctions, bidding, withdrawal of bids, and rewarding of auction winners. The contract also incorporates fee collection and is resistant to reentrancy attacks.

Key Features

  • Starting and managing auctions

  • Placing bids

  • Withdrawing bids

  • Rewarding auction winners

  • Cancelling auctions

  • Collecting platform and royalty fees

  • Prevents reentrancy attacks

Structs

  • Auction: Contains details like the owner, pay token, prices, and timing.

  • HighestBid: Keeps track of the highest bidder, bid amount, and time for each Digital Asset auction.

Mappings

  • auctions: Maps a Digital Asset address and tokenId to an Auction struct.

  • highestBids: Maps a Digital Asset address and tokenId to an array of HighestBid structs.

  • expectedTokenAmounts: Keeps track of the expected balance of ERC20 tokens held by the contract, mainly for withdrawals.

Events

  • AuctionCreated: Emitted when a new auction is initiated.

  • BidPlaced: Emitted when a bid is placed.

  • BidWithdrawn: Emitted when a bid is withdrawn.

  • AuctionResulted: Emitted when an auction is concluded and the winner is rewarded.

  • AuctionCancelled: Emitted when an auction is cancelled.

  • Additional events are emitted for parameter updates like bid lock time, etc.

Modifiers

  • whenNotPaused: Reverts if the contract is paused.

  • isVerified: Reverts if the caller is not KYC verified.

  • nonReentrant: Uses ReentrancyGuard to prevent reentrant calls.

Methods

  • createAuction: Initiates a new Digital Asset auction, collecting fees in ERC20 tokens.

  • placeBid: Allows a user to place a bid on a Digital Asset, using ERC20 tokens.

  • withdrawBid: Enables withdrawal of a bid after the lock period, returning ERC20 tokens.

  • resultAuction: Concludes an auction, rewards the winner, and collects fees in ERC20 tokens.

  • cancelAuction: Cancels an existing auction and refunds the highest bidder's ERC20 tokens.

  • Various admin methods for contract management and address registry updates.

Access Control

  • Owner Only: Exclusive access to certain administrative functions.

  • Owner and Digital Asset Owner: Can result and cancel auctions, and update parameters.

  • Public: Methods for placing and withdrawing bids, and querying auction details.

Inherited Contracts

  • Ownable: For ownership management.

  • ReentrancyGuard: To prevent reentrant calls.

Payment System and Fees

  • Tokens for Payments: All transactions in this contract are conducted using approved ERC20 tokens. No native FTM, or ETH tokens are involved.

  • Fees: The contract handles platformFee and royaltyFee, which are collected in approved ERC20 tokens.

ERC-20 Token Initialization

The contract does not initialize ERC-20 tokens. It uses the IERC20Upgradeable and SafeERC20Upgradeable libraries from OpenZeppelin for safe ERC-20 token operations. The specific ERC-20 token used for payments is determined when auctions are created and can be updated using contract methods.


Last updated