TLAuctionHouse

Git Source

Inherits: Ownable, Pausable, ReentrancyGuard, RoyaltyPayoutHelper, ITLAuctionHouseEvents, AuctionHouseErrors

Author: transientlabs.xyz

Transient Labs Auction House with Reserve Auctions and Buy Now Sales for ERC-721 tokens

State Variables

VERSION

string public constant VERSION = "2.3.0";

EXTENSION_TIME

uint256 public constant EXTENSION_TIME = 15 minutes;

BASIS

uint256 public constant BASIS = 10_000;

protocolFeeReceiver

address public protocolFeeReceiver;

minBidIncreasePerc

uint256 public minBidIncreasePerc;

minBidIncreaseLimit

uint256 public minBidIncreaseLimit;

protocolFeePerc

uint256 public protocolFeePerc;

protocolFeeLimit

uint256 public protocolFeeLimit;

_auctions

mapping(address => mapping(uint256 => Auction)) internal _auctions;

_sales

mapping(address => mapping(uint256 => Sale)) internal _sales;

Functions

constructor

constructor(
    address initOwner,
    address initSanctionsOracle,
    address initWethAddress,
    address initRoyaltyEngineAddress,
    address initProtocolFeeReceiver,
    uint256 initMinBidIncreasePerc,
    uint256 initMinBidIncreaseLimit,
    uint256 initProtocolFeePerc,
    uint256 initProtocolFeeLimit
)
    Ownable(initOwner)
    Pausable
    ReentrancyGuard
    RoyaltyPayoutHelper(initSanctionsOracle, initWethAddress, initRoyaltyEngineAddress);

setRoyaltyEngine

Function to set a new royalty engine address

Requires owner

function setRoyaltyEngine(address newRoyaltyEngine) external onlyOwner;

Parameters

NameTypeDescription
newRoyaltyEngineaddressThe new royalty engine address

setWethAddress

Function to set a new weth address

Requires owner

function setWethAddress(address newWethAddress) external onlyOwner;

Parameters

NameTypeDescription
newWethAddressaddressThe new weth address

setMinBidIncreaseSettings

Function to set the min bid increase settings

Requires owner

function setMinBidIncreaseSettings(uint256 newMinBidIncreasePerc, uint256 newMinBidIncreaseLimit) external onlyOwner;

Parameters

NameTypeDescription
newMinBidIncreasePercuint256The new minimum bid increase nominal percentage, out of BASIS
newMinBidIncreaseLimituint256The new minimum bid increase absolute limit

setProtocolFeeSettings

Function to set the protocol fee settings

Requires owner

function setProtocolFeeSettings(address newProtocolFeeReceiver, uint256 newProtocolFeePerc, uint256 newProtocolFeeLimit)
    external
    onlyOwner;

Parameters

NameTypeDescription
newProtocolFeeReceiveraddressThe new protocol fee receiver
newProtocolFeePercuint256The new protocol fee percentage, out of BASIS
newProtocolFeeLimituint256The new protocol fee limit

pause

Function to pause the contract

Requires owner

function pause(bool status) external onlyOwner;

Parameters

NameTypeDescription
statusboolThe boolean to set the internal pause variable

setSanctionsOracle

Function to set the sanctions oracle

Requires owner

function setSanctionsOracle(address newOracle) external onlyOwner;

Parameters

NameTypeDescription
newOracleaddressThe new oracle address

configureAuction

Function to configure an auction

*Requires the following items to be true

  • contract is not paused
  • the auction hasn't been configured yet for the current token owner
  • msg.sender is the owner of the token
  • auction house is approved for all
  • payoutReceiver isn't the zero address*
function configureAuction(
    address nftAddress,
    uint256 tokenId,
    address payoutReceiver,
    address currencyAddress,
    uint256 reservePrice,
    uint256 auctionOpenTime,
    uint256 duration,
    bool reserveAuction
) external whenNotPaused nonReentrant;

Parameters

NameTypeDescription
nftAddressaddressThe nft contract address
tokenIduint256The nft token id
payoutReceiveraddressThe address that receives the payout from the auction
currencyAddressaddressThe currency to use
reservePriceuint256The auction reserve price
auctionOpenTimeuint256The time at which bidding is allowed
durationuint256The duration of the auction after it is started
reserveAuctionboolA flag dictating if the auction is a reserve auction or regular scheduled auction

cancelAuction

Function to cancel an auction

*Requires the following to be true

  • msg.sender to be the auction seller
  • the auction cannot be started*
function cancelAuction(address nftAddress, uint256 tokenId) external nonReentrant;

Parameters

NameTypeDescription
nftAddressaddressThe nft contract address
tokenIduint256The nft token id

bid

Function to bid on an auction

*Requires the following to be true

  • contract is not paused
  • block.timestamp is greater than the auction open timestamp
  • bid meets or exceeds the reserve price / min bid price
  • msg.sender has attached enough eth/erc20 as specified by amount
  • protocol fee has been supplied, if needed*
function bid(address nftAddress, uint256 tokenId, uint256 amount) external payable whenNotPaused nonReentrant;

Parameters

NameTypeDescription
nftAddressaddressThe nft contract address
tokenIduint256The nft token id
amountuint256The amount to bid in the currency address set in the auction

settleAuction

Function to settle an auction

Can be called by anyone

*Requires the following to be true

  • auction has been started
  • auction has ended*
function settleAuction(address nftAddress, uint256 tokenId) external nonReentrant;

Parameters

NameTypeDescription
nftAddressaddressThe nft contract address
tokenIduint256The nft token id

configureSale

Function to configure a buy now sale

*Requires the following to be true

  • contract is not paused
  • the sale hasn't been configured yet by the current token owner
  • an auction hasn't been started - this is captured by token ownership
  • msg.sender is the owner of the token
  • auction house is approved for all
  • payoutReceiver isn't the zero address*
function configureSale(
    address nftAddress,
    uint256 tokenId,
    address payoutReceiver,
    address currencyAddress,
    uint256 price,
    uint256 saleOpenTime
) external whenNotPaused nonReentrant;

Parameters

NameTypeDescription
nftAddressaddressThe nft contract address
tokenIduint256The nft token id
payoutReceiveraddressThe address that receives the payout from the sale
currencyAddressaddressThe currency to use
priceuint256The sale price
saleOpenTimeuint256The time at which the sale opens

cancelSale

Function to cancel a sale

Requires msg.sender to be the token owner

function cancelSale(address nftAddress, uint256 tokenId) external nonReentrant;

Parameters

NameTypeDescription
nftAddressaddressThe nft contract address
tokenIduint256The nft token id

buyNow

Function to buy a token

*Requires the following to be true

  • contract is not paused
  • block.timestamp is greater than the sale open timestamp
  • msg.sender has attached enough eth/erc20 as specified by the sale
  • protocol fee has been supplied, if needed*
function buyNow(address nftAddress, uint256 tokenId) external payable whenNotPaused nonReentrant;

Parameters

NameTypeDescription
nftAddressaddressThe nft contract address
tokenIduint256The nft token id

getSale

function to get a sale

function getSale(address nftAddress, uint256 tokenId) external view returns (Sale memory);

Parameters

NameTypeDescription
nftAddressaddressThe nft contract address
tokenIduint256The nft token id

Returns

NameTypeDescription
<none>Salesale The sale struct

getAuction

function to get an auction

function getAuction(address nftAddress, uint256 tokenId) external view returns (Auction memory);

Parameters

NameTypeDescription
nftAddressaddressThe nft contract address
tokenIduint256The nft token id

Returns

NameTypeDescription
<none>Auctionauction The auction struct

calcNextMinBid

function to get the next minimum bid price for an auction

function calcNextMinBid(address nftAddress, uint256 tokenId) external view returns (uint256);

Parameters

NameTypeDescription
nftAddressaddressThe nft contract address
tokenIduint256The nft token id

Returns

NameTypeDescription
<none>uint256uint256 The next minimum bid required

calcProtocolFee

function to calculate the protocol fee

function calcProtocolFee(uint256 amount) external view returns (uint256);

Parameters

NameTypeDescription
amountuint256The value to calculate the fee for

Returns

NameTypeDescription
<none>uint256uint256 The calculated fee

_setMinBidIncreaseSettings

Internal function to set the min bid increase settings

function _setMinBidIncreaseSettings(uint256 newMinBidIncreasePerc, uint256 newMinBidIncreaseLimit) internal;

Parameters

NameTypeDescription
newMinBidIncreasePercuint256The new minimum bid increase nominal percentage, out of BASIS
newMinBidIncreaseLimituint256The new minimum bid increase absolute limit

_setProtocolFeeSettings

Internal function to set the protocol fee settings

function _setProtocolFeeSettings(
    address newProtocolFeeReceiver,
    uint256 newProtocolFeePerc,
    uint256 newProtocolFeeLimit
) internal;

Parameters

NameTypeDescription
newProtocolFeeReceiveraddressThe new protocol fee receiver
newProtocolFeePercuint256The new protocol fee percentage, out of BASIS
newProtocolFeeLimituint256The new protocol fee limit

_checkTokenOwnership

Internal function to check if a token is owned by an address

function _checkTokenOwnership(IERC721 nft, uint256 tokenId, address potentialTokenOwner) internal view returns (bool);

Parameters

NameTypeDescription
nftIERC721The nft contract
tokenIduint256The nft token id
potentialTokenOwneraddressThe potential token owner to check against

Returns

NameTypeDescription
<none>boolbool Indication of if the address in quesion is the owner of the token

_checkAuctionHouseApproval

Internal function to check if the auction house is approved for all

function _checkAuctionHouseApproval(IERC721 nft, address seller) internal view returns (bool);

Parameters

NameTypeDescription
nftIERC721The nft contract
selleraddressThe seller to check against

Returns

NameTypeDescription
<none>boolbool Indication of if the auction house is approved for all by the seller

_checkPayoutReceiver

Internal function to check if a payout address is a valid address

function _checkPayoutReceiver(address payoutReceiver) internal pure returns (bool);

Parameters

NameTypeDescription
payoutReceiveraddressThe payout address to check

Returns

NameTypeDescription
<none>boolbool Indication of if the payout address is not the zero address

_calcNextMinBid

Internal function to calculate the next min bid price

function _calcNextMinBid(uint256 currentBid) internal view returns (uint256 nextMinBid);

Parameters

NameTypeDescription
currentBiduint256The current bid

Returns

NameTypeDescription
nextMinBiduint256The next minimum bid

_calcProtocolFee

Internal function to calculate the protocol fee

function _calcProtocolFee(uint256 amount) internal view returns (uint256 fee);

Parameters

NameTypeDescription
amountuint256The value of the sale

Returns

NameTypeDescription
feeuint256The protocol fee

_payout

Internal function to payout from the contract

function _payout(address nftAddress, uint256 tokenId, address currencyAddress, uint256 amount, address payoutReceiver)
    internal;

Parameters

NameTypeDescription
nftAddressaddressThe nft contract address
tokenIduint256The token id
currencyAddressaddressThe currency address (ZERO ADDRESS == ETH)
amountuint256The sale/auction end price
payoutReceiveraddressThe receiver for the sale payout (what's remaining after royalties)