diff --git a/src/Billboard/Billboard.sol b/src/Billboard/Billboard.sol index f620c57..3656213 100644 --- a/src/Billboard/Billboard.sol +++ b/src/Billboard/Billboard.sol @@ -382,8 +382,5 @@ contract Billboard is IBillboard { // transfer bid price and tax back to the bidder registry.transferAmount(msg.sender, amount); - - // emit BidWithdrawn - registry.emitBidWithdrawn(tokenId_, auctionId_, msg.sender, _bid.price, _bid.tax); } } diff --git a/src/Billboard/BillboardRegistry.sol b/src/Billboard/BillboardRegistry.sol index ce48fb5..7c9c1c5 100644 --- a/src/Billboard/BillboardRegistry.sol +++ b/src/Billboard/BillboardRegistry.sol @@ -9,55 +9,44 @@ import "./IBillboardRegistry.sol"; contract BillboardRegistry is IBillboardRegistry, ERC721 { using Counters for Counters.Counter; + Counters.Counter public lastTokenId; - // access control address public operator; - Counters.Counter public lastTokenId; - + // token to be used for auction IERC20 public immutable token; - uint256 public taxRate; - uint64 public leaseTerm; // tokenId => Board mapping(uint256 => Board) public boards; - // tokenId => auctionId => Auction - mapping(uint256 => mapping(uint256 => Auction)) public boardAuctions; + // tokenId => address => whitelisted + mapping(uint256 => mapping(address => bool)) public boardWhitelists; - // tokenId => nextAuctionId (start from 1 if exists) - mapping(uint256 => uint256) public nextBoardAuctionId; + // tokenId => epoch => bidder + mapping(uint256 => mapping(uint256 => address)) public auctionHiggestBidder; - // tokenId => auctionId => bidders + // tokenId => epoch => bidders mapping(uint256 => mapping(uint256 => address[])) public auctionBidders; - // tokenId => auctionId => bidder => Bid + // tokenId => epoch => bidder => Bid mapping(uint256 => mapping(uint256 => mapping(address => Bid))) public auctionBids; // board creator => TaxTreasury mapping(address => TaxTreasury) public taxTreasury; - constructor( - address token_, - address operator_, - uint256 taxRate_, - uint64 leaseTerm_, - string memory name_, - string memory symbol_ - ) ERC721(name_, symbol_) { + ////////////////////////////// + /// Constructor + ////////////////////////////// + constructor(address token_, address operator_, string memory name_, string memory symbol_) ERC721(name_, symbol_) { require(operator_ != address(0), "Zero address"); require(token_ != address(0), "Zero address"); - - token = IERC20(token_); operator = operator_; - taxRate = taxRate_; - leaseTerm = leaseTerm_; + token = IERC20(token_); } ////////////////////////////// /// Modifier ////////////////////////////// - modifier isFromOperator() { require(msg.sender == operator, "Operator"); _; @@ -78,9 +67,12 @@ contract BillboardRegistry is IBillboardRegistry, ERC721 { ////////////////////////////// /// Board ////////////////////////////// - /// @inheritdoc IBillboardRegistry - function mintBoard(address to_) external isFromOperator returns (uint256 tokenId) { + function newBoard( + address to_, + uint256 taxRate_, + uint256 epochInterval_ + ) external isFromOperator returns (uint256 tokenId) { lastTokenId.increment(); tokenId = lastTokenId.current(); @@ -90,170 +82,147 @@ contract BillboardRegistry is IBillboardRegistry, ERC721 { creator: to_, name: "", description: "", + imageURI: "", location: "", - contentURI: "", - redirectURI: "" + taxRate: taxRate_, + epochInterval: epochInterval_, + createdAt: block.number }); - } - - /// @inheritdoc IBillboardRegistry - function safeTransferByOperator(address from_, address to_, uint256 tokenId_) external isFromOperator { - _safeTransfer(from_, to_, tokenId_, ""); - } - /// @inheritdoc IBillboardRegistry - function getBoard(uint256 tokenId_) external view returns (Board memory board) { - board = boards[tokenId_]; + emit BoardCreated(tokenId, to_, taxRate_, epochInterval_); } /// @inheritdoc IBillboardRegistry - function setBoardName(uint256 tokenId_, string calldata name_) external isFromOperator { + function setBoard( + uint256 tokenId_, + string calldata name_, + string calldata description_, + string calldata imageURI_, + string calldata location_ + ) external isFromOperator { boards[tokenId_].name = name_; - emit BoardNameUpdated(tokenId_, name_); - } - - /// @inheritdoc IBillboardRegistry - function setBoardDescription(uint256 tokenId_, string calldata description_) external isFromOperator { boards[tokenId_].description = description_; - emit BoardDescriptionUpdated(tokenId_, description_); - } - - /// @inheritdoc IBillboardRegistry - function setBoardLocation(uint256 tokenId_, string calldata location_) external isFromOperator { + boards[tokenId_].imageURI = imageURI_; boards[tokenId_].location = location_; - emit BoardLocationUpdated(tokenId_, location_); - } - - /// @inheritdoc IBillboardRegistry - function setBoardContentURI(uint256 tokenId_, string calldata contentURI_) external isFromOperator { - boards[tokenId_].contentURI = contentURI_; - emit BoardContentURIUpdated(tokenId_, contentURI_); - } - - function setBoardRedirectURI(uint256 tokenId_, string calldata redirectURI_) external isFromOperator { - boards[tokenId_].redirectURI = redirectURI_; - emit BoardRedirectURIUpdated(tokenId_, redirectURI_); + emit BoardUpdated(tokenId_, name_, description_, imageURI_, location_); } ////////////////////////////// - /// Auction + /// Auction & Bid ////////////////////////////// - /// @inheritdoc IBillboardRegistry - function getAuction(uint256 tokenId_, uint256 auctionId_) external view returns (Auction memory auction) { - auction = boardAuctions[tokenId_][auctionId_]; + function getBidCount(uint256 tokenId_, uint256 epoch_) external view returns (uint256 count) { + count = auctionBidders[tokenId_][epoch_].length; } /// @inheritdoc IBillboardRegistry - function newAuction( + function newBid( uint256 tokenId_, - uint64 startAt_, - uint64 endAt_ - ) external isFromOperator returns (uint256 newAuctionId) { - nextBoardAuctionId[tokenId_]++; - - newAuctionId = nextBoardAuctionId[tokenId_]; - - boardAuctions[tokenId_][newAuctionId] = Auction({ - startAt: startAt_, - endAt: endAt_, - leaseStartAt: 0, - leaseEndAt: 0, - highestBidder: address(0) + uint256 epoch_, + address bidder_, + uint256 price_, + uint256 tax_, + string calldata contentURI_, + string calldata redirectURI_ + ) external isFromOperator { + Bid memory _bid = Bid({ + price: price_, + tax: tax_, + contentURI: contentURI_, + redirectURI: redirectURI_, + createdAt: block.number, + updatedAt: block.number, + isWithdrawn: false, + isWon: false }); - emit AuctionCreated(tokenId_, newAuctionId, startAt_, endAt_); - } + // add to auction bids + auctionBids[tokenId_][epoch_][bidder_] = _bid; - /// @inheritdoc IBillboardRegistry - function setAuctionLease( - uint256 tokenId_, - uint256 auctionId_, - uint64 leaseStartAt_, - uint64 leaseEndAt_ - ) external isFromOperator { - boardAuctions[tokenId_][auctionId_].leaseStartAt = leaseStartAt_; - boardAuctions[tokenId_][auctionId_].leaseEndAt = leaseEndAt_; - } + // add to auction bidders if new bid + auctionBidders[tokenId_][epoch_].push(bidder_); - /// @inheritdoc IBillboardRegistry - function getBidCount(uint256 tokenId_, uint256 auctionId_) external view returns (uint256 count) { - count = auctionBidders[tokenId_][auctionId_].length; - } + _setHiggestBidder(tokenId_, epoch_, price_, bidder_); - /// @inheritdoc IBillboardRegistry - function getBid(uint256 tokenId_, uint256 auctionId_, address bidder_) external view returns (Bid memory bid) { - bid = auctionBids[tokenId_][auctionId_][bidder_]; + emit BidUpdated(tokenId_, epoch_, bidder_, price_, tax_, contentURI_, redirectURI_); } /// @inheritdoc IBillboardRegistry - function newBid( + function setBid( uint256 tokenId_, - uint256 auctionId_, + uint256 epoch_, address bidder_, uint256 price_, - uint256 tax_ + uint256 tax_, + string calldata contentURI_, + string calldata redirectURI_ ) external isFromOperator { - Bid memory _bid = Bid({price: price_, tax: tax_, placedAt: block.number, isWithdrawn: false, isWon: false}); + Bid memory _bid = auctionBids[tokenId_][epoch_][bidder_]; + require(_bid.createdAt != 0, "Bid not found"); - // add to auction bids - auctionBids[tokenId_][auctionId_][bidder_] = _bid; + _bid.price = price_; + _bid.tax = tax_; + _bid.contentURI = contentURI_; + _bid.redirectURI = redirectURI_; + _bid.updatedAt = block.number; + + _setHiggestBidder(tokenId_, epoch_, price_, bidder_); - // add to auction bidders - auctionBidders[tokenId_][auctionId_].push(bidder_); + emit BidUpdated(tokenId_, epoch_, bidder_, price_, tax_, contentURI_, redirectURI_); + } - // set auction highest bidder if no highest bidder or price is higher. - // - // Note: for same price, the first bidder will always be - // the highest bidder since the block.number is always greater. - address highestBidder = boardAuctions[tokenId_][auctionId_].highestBidder; - Bid memory highestBid = auctionBids[tokenId_][auctionId_][highestBidder]; + // Set auction highest bidder if no highest bidder or price is higher. + // + // Note: for same price, the first bidder will always be + // the highest bidder since the block.number is always greater. + function _setHiggestBidder(uint256 tokenId_, uint256 epoch_, uint256 price_, address bidder_) internal { + address highestBidder = auctionHiggestBidder[tokenId_][epoch_]; + Bid memory highestBid = auctionBids[tokenId_][epoch_][highestBidder]; if (highestBidder == address(0) || price_ > highestBid.price) { - boardAuctions[tokenId_][auctionId_].highestBidder = bidder_; + auctionHiggestBidder[tokenId_][epoch_] = bidder_; } - - emit BidCreated(tokenId_, auctionId_, bidder_, price_, tax_); } /// @inheritdoc IBillboardRegistry - function setBidWon(uint256 tokenId_, uint256 auctionId_, address bidder_, bool isWon_) external isFromOperator { - auctionBids[tokenId_][auctionId_][bidder_].isWon = isWon_; - - emit BidWon(tokenId_, auctionId_, bidder_); + function setBidWon(uint256 tokenId_, uint256 epoch_, address bidder_, bool isWon_) external isFromOperator { + auctionBids[tokenId_][epoch_][bidder_].isWon = isWon_; + emit BidWon(tokenId_, epoch_, bidder_); } /// @inheritdoc IBillboardRegistry function setBidWithdrawn( uint256 tokenId_, - uint256 auctionId_, + uint256 epoch_, address bidder_, bool isWithdrawn_ ) external isFromOperator { - auctionBids[tokenId_][auctionId_][bidder_].isWithdrawn = isWithdrawn_; + auctionBids[tokenId_][epoch_][bidder_].isWithdrawn = isWithdrawn_; + emit BidWithdrawn(tokenId_, epoch_, msg.sender); } - /// @inheritdoc IBillboardRegistry - function transferAmount(address to_, uint256 amount_) external isFromOperator { - require(to_ != address(0), "Zero address"); + ////////////////////////////// + /// Tax & Withdraw + ////////////////////////////// - require(token.transfer(to_, amount_), "Failed token transfer"); + /// @inheritdoc IBillboardRegistry + function setTaxTreasury(address owner_, uint256 accumulated_, uint256 withdrawn_) external isFromOperator { + taxTreasury[owner_].accumulated = accumulated_; + taxTreasury[owner_].withdrawn = withdrawn_; } ////////////////////////////// - /// Tax & Withdraw + /// Transfer ////////////////////////////// /// @inheritdoc IBillboardRegistry - function setTaxRate(uint256 taxRate_) external isFromOperator { - taxRate = taxRate_; - - emit TaxRateUpdated(taxRate_); + function transferTokenByOperator(address to_, uint256 amount_) external isFromOperator { + require(to_ != address(0), "Zero address"); + require(token.transfer(to_, amount_), "Failed token transfer"); } /// @inheritdoc IBillboardRegistry - function setTaxTreasury(address owner_, uint256 accumulated_, uint256 withdrawn_) external isFromOperator { - taxTreasury[owner_].accumulated = accumulated_; - taxTreasury[owner_].withdrawn = withdrawn_; + function safeTransferByOperator(address from_, address to_, uint256 tokenId_) external isFromOperator { + _safeTransfer(from_, to_, tokenId_, ""); } ////////////////////////////// @@ -264,7 +233,8 @@ contract BillboardRegistry is IBillboardRegistry, ERC721 { * @notice See {IERC721-tokenURI}. */ function tokenURI(uint256 tokenId_) public view override(ERC721) returns (string memory uri) { - return boards[tokenId_].contentURI; + // TODO + // return boards[tokenId_].contentURI; } /** @@ -279,25 +249,8 @@ contract BillboardRegistry is IBillboardRegistry, ERC721 { ////////////////////////////// /// @inheritdoc IBillboardRegistry - function emitAuctionCleared( - uint256 tokenId_, - uint256 auctionId_, - address highestBidder_, - uint64 leaseStartAt_, - uint64 leaseEndAt_ - ) external { - emit AuctionCleared(tokenId_, auctionId_, highestBidder_, leaseStartAt_, leaseEndAt_); - } - - /// @inheritdoc IBillboardRegistry - function emitBidWithdrawn( - uint256 tokenId_, - uint256 auctionId_, - address bidder_, - uint256 price_, - uint256 tax_ - ) external { - emit BidWithdrawn(tokenId_, auctionId_, bidder_, price_, tax_); + function emitAuctionCleared(uint256 tokenId_, uint256 epoch_, address highestBidder_) external { + emit AuctionCleared(tokenId_, epoch_, highestBidder_); } /// @inheritdoc IBillboardRegistry diff --git a/src/Billboard/IBillboard.sol b/src/Billboard/IBillboard.sol index 18e3ffc..bd5d735 100644 --- a/src/Billboard/IBillboard.sol +++ b/src/Billboard/IBillboard.sol @@ -41,26 +41,21 @@ interface IBillboard { /// Access control ////////////////////////////// - /** - * @notice Toggle for operation access. - * - * @param value_ Value of access state. - */ - function setIsOpened(bool value_) external; - /** * @notice Add address to white list. * - * @param value_ Address of user will be added into white list. + * @param tokenId_ Token ID. + * @param address_ Address of user will be added into whitelist. */ - function addToWhitelist(address value_) external; + function addToWhitelist(uint256 tokenId_, address address_) external; /** * @notice Remove address from white list. * - * @param value_ Address of user will be removed from white list. + * @param tokenId_ Token ID. + * @param address_ Address of user will be removed from whitelist. */ - function removeFromWhitelist(address value_) external; + function removeFromWhitelist(uint256 tokenId_, address address_) external; ////////////////////////////// /// Board @@ -71,12 +66,12 @@ interface IBillboard { * * @param to_ Address of the new board receiver. */ - function mintBoard(address to_) external returns (uint256 tokenId); + function newBoard(address to_) external returns (uint256 tokenId); /** * @notice Get a board data. * - * @param tokenId_ Token ID of a board. + * @param tokenId_ Token ID. * * @return board Board data. */ @@ -85,7 +80,7 @@ interface IBillboard { /** * @notice Set the name of a board by board creator. * - * @param tokenId_ Token ID of a board. + * @param tokenId_ Token ID. * @param name_ Board name. */ function setBoardName(uint256 tokenId_, string calldata name_) external; @@ -93,7 +88,7 @@ interface IBillboard { /** * @notice Set the name of a board by board creator. * - * @param tokenId_ Token ID of a board. + * @param tokenId_ Token ID. * @param description_ Board description. */ function setBoardDescription(uint256 tokenId_, string calldata description_) external; @@ -101,48 +96,48 @@ interface IBillboard { /** * @notice Set the location of a board by board creator. * - * @param tokenId_ Token ID of a board. + * @param tokenId_ Token ID. * @param location_ Digital address where a board located. */ function setBoardLocation(uint256 tokenId_, string calldata location_) external; /** - * @notice Set the content URI and redirect URI of a board by the tenant + * @notice Set the image of a board by board creator. * - * @param tokenId_ Token ID of a board. - * @param contentURI_ Content URI of a board. + * @param tokenId_ Token ID. + * @param uri_ URI of the image. */ - function setBoardContentURI(uint256 tokenId_, string calldata contentURI_) external; + function setBoardImage(uint256 tokenId_, string calldata uri_) external; /** - * @notice Set the redirect URI and redirect URI of a board by the tenant + * @notice Set the (AD) content URI of a board by the tenant * - * @param tokenId_ Token ID of a board. + * @param tokenId_ Token ID. + * @param epoch_ Epoch. + * @param contentURI_ Content URI. + */ + function setBoardContentURI(uint256 tokenId_, uint256 epoch_, string calldata contentURI_) external; + + /** + * @notice Set the (AD) redirect URI of a board by the tenant + * + * @param tokenId_ Token ID. + * @param epoch_ Epoch. * @param redirectURI_ Redirect URI when users clicking. */ - function setBoardRedirectURI(uint256 tokenId_, string calldata redirectURI_) external; + function setBoardRedirectURI(uint256 tokenId_, uint256 epoch_, string calldata redirectURI_) external; ////////////////////////////// /// Auction ////////////////////////////// /** - * @notice Get auction of a board by auction ID. - * - * @param tokenId_ Token ID of a board. - * @param auctionId_ Auction ID of a board. - */ - function getAuction( - uint256 tokenId_, - uint256 auctionId_ - ) external view returns (IBillboardRegistry.Auction memory auction); - - /** - * @notice Clear the next auction of a board. + * @notice Clear an auction by a given epoch. * - * @param tokenId_ Token ID of a board. + * @param tokenId_ Token ID. + * @param epoch_ Epoch. */ - function clearAuction(uint256 tokenId_) external returns (uint256 price, uint256 tax); + function clearAuction(uint256 tokenId_, uint256 epoch_) external returns (uint256 price, uint256 tax); /** * @notice Clear the next auction of mutiple boards. @@ -154,9 +149,9 @@ interface IBillboard { ) external returns (uint256[] memory prices, uint256[] memory taxes); /** - * @notice Place bid for the next auction of a board. + * @notice Place bid for the next auction. * - * @param tokenId_ Token ID of a board. + * @param tokenId_ Token ID. * @param amount_ Amount of a bid. */ function placeBid(uint256 tokenId_, uint256 amount_) external payable; @@ -164,11 +159,11 @@ interface IBillboard { /** * @notice Get bid of a board auction by auction ID. * - * @param tokenId_ Token ID of a board. - * @param auctionId_ Auction ID of a board. + * @param tokenId_ Token ID. + * @param auctionId_ Auction ID. * @param bidder_ Address of a bidder. * - * @return bid Bid of a board. + * @return bid Bid. */ function getBid( uint256 tokenId_, @@ -179,15 +174,15 @@ interface IBillboard { /** * @notice Get bids of a board auction by auction ID. * - * @param tokenId_ Token ID of a board. - * @param auctionId_ Auction ID of a board. + * @param tokenId_ Token ID. + * @param auctionId_ Auction ID. * @param limit_ Limit of returned bids. * @param offset_ Offset of returned bids. * * @return total Total number of bids. * @return limit Limit of returned bids. * @return offset Offset of returned bids. - * @return bids Bids of a board. + * @return bids Bids. */ function getBids( uint256 tokenId_, @@ -222,7 +217,7 @@ interface IBillboard { function calculateTax(uint256 amount_) external returns (uint256 tax); /** - * @notice Withdraw accumulated taxation of a board. + * @notice Withdraw accumulated taxation. * */ function withdrawTax() external returns (uint256 tax); @@ -230,8 +225,8 @@ interface IBillboard { /** * @notice Withdraw bid that were not won by auction id; * - * @param tokenId_ Token ID of a board. - * @param auctionId_ Auction ID of a board. + * @param tokenId_ Token ID. + * @param auctionId_ Auction ID. */ function withdrawBid(uint256 tokenId_, uint256 auctionId_) external; } diff --git a/src/Billboard/IBillboardRegistry.sol b/src/Billboard/IBillboardRegistry.sol index 4c0a59f..9a4a4ea 100644 --- a/src/Billboard/IBillboardRegistry.sol +++ b/src/Billboard/IBillboardRegistry.sol @@ -19,121 +19,73 @@ interface IBillboardRegistry is IERC721 { event OperatorUpdated(address indexed operator); /** - * @notice Board name is updated. + * @notice Board is created. * - * @param tokenId Token ID of the board. - * @param name New name of the board. - */ - event BoardNameUpdated(uint256 indexed tokenId, string name); - - /** - * @notice Board description is updated. - * - * @param tokenId Token ID of the board. - * @param description New description of the board. - */ - event BoardDescriptionUpdated(uint256 indexed tokenId, string description); - - /** - * @notice Board location is updated. - * - * @param tokenId Token ID of the board. - * @param location New location of the board. + * @param tokenId Token ID of the board + * @param to Address of the board owner. + * @param taxRate Tax rate of the board. + * @param epochInterval Epoch interval of the board. */ - event BoardLocationUpdated(uint256 indexed tokenId, string location); + event BoardCreated(uint256 indexed tokenId, address indexed to, uint256 taxRate, uint256 epochInterval); /** - * @notice Board content URI is updated. + * @notice Board data is updated. * * @param tokenId Token ID of the board. - * @param contentURI New content URI of the board. + * @param name Name of the board. + * @param description Description of the board. + * @param imageURI Image URI of the board. + * @param location Location of the board. */ - event BoardContentURIUpdated(uint256 indexed tokenId, string contentURI); - - /** - * @notice Board redirect URI is updated. - * - * @param tokenId Token ID of the board. - * @param redirectURI New redirect URI of the board. - */ - event BoardRedirectURIUpdated(uint256 indexed tokenId, string redirectURI); - - /** - * @notice Global tax rate is updated. - * - * @param taxRate New tax rate. - */ - event TaxRateUpdated(uint256 taxRate); - - /** - * @notice Auction is created. - * - * @param tokenId Token ID of the board. - * @param auctionId Auction ID of the auction. - * @param startAt Start time of the auction. - * @param endAt End time of the auction. - */ - event AuctionCreated(uint256 indexed tokenId, uint256 indexed auctionId, uint64 startAt, uint64 endAt); + event BoardUpdated(uint256 indexed tokenId, string name, string description, string imageURI, string location); /** * @notice Auction is cleared. * * @param tokenId Token ID of the board. - * @param auctionId Auction ID of the auction. + * @param epoch Epoch of the auction. * @param highestBidder Highest bidder of the auction. - * @param leaseStartAt Start time of the lease. - * @param leaseEndAt End time of the lease. */ - event AuctionCleared( - uint256 indexed tokenId, - uint256 indexed auctionId, - address indexed highestBidder, - uint64 leaseStartAt, - uint64 leaseEndAt - ); + event AuctionCleared(uint256 indexed tokenId, uint256 indexed epoch, address indexed highestBidder); /** - * @notice Bid is created. + * @notice Bid is created or updated. * * @param tokenId Token ID of the board. - * @param auctionId Auction ID of the auction. + * @param epoch Epoch of the auction. * @param bidder Bidder of the auction. * @param price Price of the bid. * @param tax Tax of the bid. + * @param contentURI Content URI of the bid. + * @param redirectURI Redirect URI of the bid. */ - event BidCreated( + event BidUpdated( uint256 indexed tokenId, - uint256 indexed auctionId, + uint256 indexed epoch, address indexed bidder, uint256 price, - uint256 tax + uint256 tax, + string contentURI, + string redirectURI ); /** * @notice Bid is won. * * @param tokenId Token ID of the board. - * @param auctionId Auction ID of the auction. + * @param epoch Epoch of the auction. * @param bidder Bidder of the auction. */ - event BidWon(uint256 indexed tokenId, uint256 indexed auctionId, address indexed bidder); + event BidWon(uint256 indexed tokenId, uint256 indexed epoch, address indexed bidder); /** * @notice Bid is withdrawn. * * @param tokenId Token ID of the board. - * @param auctionId Auction ID of the auction. + * @param epoch Epoch of the auction. * @param bidder Bidder of the auction. - * @param price Price of the bid. - * @param tax Tax of the bid. */ - event BidWithdrawn( - uint256 indexed tokenId, - uint256 indexed auctionId, - address indexed bidder, - uint256 price, - uint256 tax - ); + event BidWithdrawn(uint256 indexed tokenId, uint256 indexed epoch, address indexed bidder); /** * @notice Tax is withdrawn. @@ -148,26 +100,25 @@ interface IBillboardRegistry is IERC721 { ////////////////////////////// struct Board { + // immutable data address creator; + uint256 taxRate; + uint256 epochInterval; // in blocks + uint256 createdAt; // gensis epoch, block number + // mutable data string name; string description; + string imageURI; string location; - string contentURI; - string redirectURI; - } - - struct Auction { - uint64 startAt; // block number - uint64 endAt; // block number - uint64 leaseStartAt; // block number - uint64 leaseEndAt; // block number - address highestBidder; } struct Bid { uint256 price; uint256 tax; - uint256 placedAt; // block number + string contentURI; + string redirectURI; + uint256 createdAt; // block number + uint256 updatedAt; // block number bool isWon; bool isWithdrawn; } @@ -191,180 +142,144 @@ interface IBillboardRegistry is IERC721 { /** * @notice Mint a new board (NFT). * - * @param to_ Address of the new board receiver. + * @param to_ Address of the board owner. + * @param taxRate_ Tax rate of the new board. + * @param epochInterval_ Epoch interval of the new board. * * @return tokenId Token ID of the new board. */ - function mintBoard(address to_) external returns (uint256 tokenId); - - /** - * @notice Transfer a board (NFT) by the operator. - * - * @param from_ Address of the board sender. - * @param to_ Address of the board receiver. - * @param tokenId_ Token ID of the board. - */ - function safeTransferByOperator(address from_, address to_, uint256 tokenId_) external; + function newBoard(address to_, uint256 taxRate_, uint256 epochInterval_) external returns (uint256 tokenId); /** - * @notice Get a board - * - * @param tokenId_ Token ID of a board. - */ - function getBoard(uint256 tokenId_) external view returns (Board memory board); - - /** - * @notice Set the name of a board by board creator. + * @notice Set metadata of a board. * * @param tokenId_ Token ID of a board. * @param name_ Board name. - */ - function setBoardName(uint256 tokenId_, string calldata name_) external; - - /** - * @notice Set the name of a board by board creator. - * - * @param tokenId_ Token ID of a board. * @param description_ Board description. + * @param imageURI_ Image URI of a board. + * @param location_ Location of a board. */ - function setBoardDescription(uint256 tokenId_, string calldata description_) external; - - /** - * @notice Set the location of a board by board creator. - * - * @param tokenId_ Token ID of a board. - * @param location_ Digital address where a board located. - */ - function setBoardLocation(uint256 tokenId_, string calldata location_) external; - - /** - * @notice Set the content URI and redirect URI of a board by the tenant - * - * @param tokenId_ Token ID of a board. - * @param contentURI_ Content URI of a board. - */ - function setBoardContentURI(uint256 tokenId_, string calldata contentURI_) external; - - /** - * @notice Set the redirect URI and redirect URI of a board by the tenant - * - * @param tokenId_ Token ID of a board. - * @param redirectURI_ Redirect URI when users clicking. - */ - function setBoardRedirectURI(uint256 tokenId_, string calldata redirectURI_) external; + function setBoard( + uint256 tokenId_, + string calldata name_, + string calldata description_, + string calldata imageURI_, + string calldata location_ + ) external; ////////////////////////////// - /// Auction + /// Auction & Bid ////////////////////////////// - - /** - * @notice Get an auction - * - * @param tokenId_ Token ID of a board. - * @param auctionId_ Token ID of a board. - */ - function getAuction(uint256 tokenId_, uint256 auctionId_) external view returns (Auction memory auction); - /** - * @notice Create new auction + * @notice Get bid count of an auction * * @param tokenId_ Token ID of a board. - * @param startAt_ Start time of an auction. - * @param endAt_ End time of an auction. - */ - function newAuction(uint256 tokenId_, uint64 startAt_, uint64 endAt_) external returns (uint256 auctionId); - - /** - * @notice Set the data of an auction + * @param epoch_ Epoch. * - * @param tokenId_ Token ID of a board. - * @param auctionId_ Token ID of a board. - * @param leaseStartAt_ Start time of an board lease. - * @param leaseEndAt_ End time of an board lease. + * @return count Count of bids. */ - function setAuctionLease(uint256 tokenId_, uint256 auctionId_, uint64 leaseStartAt_, uint64 leaseEndAt_) external; + function getBidCount(uint256 tokenId_, uint256 epoch_) external view returns (uint256 count); /** - * @notice Get bid count of an auction + * @notice Create or update a bid * * @param tokenId_ Token ID of a board. - * @param auctionId_ Auction ID of an auction. + * @param epoch_ Epoch of an auction. + * @param bidder_ Bidder of an auction. + * @param price_ Price of a bid. + * @param tax_ Tax of a bid. */ - function getBidCount(uint256 tokenId_, uint256 auctionId_) external view returns (uint256 count); + function setBid(uint256 tokenId_, uint256 epoch_, address bidder_, uint256 price_, uint256 tax_) external; /** - * @notice Get a bid of an auction + * @notice Create or update a bid * * @param tokenId_ Token ID of a board. - * @param auctionId_ Auction ID of an auction. + * @param epoch_ Epoch of an auction. * @param bidder_ Bidder of an auction. + * @param price_ Price of a bid. + * @param tax_ Tax of a bid. + * @param contentURI_ Content URI of a bid. + * @param redirectURI_ Redirect URI of a bid. */ - function getBid(uint256 tokenId_, uint256 auctionId_, address bidder_) external view returns (Bid memory bid); + function setBid( + uint256 tokenId_, + uint256 epoch_, + address bidder_, + uint256 price_, + uint256 tax_, + string calldata contentURI_, + string calldata redirectURI_ + ) external; /** - * @notice Create new bid and add it to auction - * - * 1. Create new bid: `new Bid()` - * 2. Add bid to auction: - * - `auction.bids[bidder] = bid` - * - `auction.bidders.push(bidder)` - * - if any `auction.highestBidder = bidder` + * @notice Set the content URI and redirect URI of a board. * * @param tokenId_ Token ID of a board. - * @param auctionId_ Auction ID of an auction. - * @param bidder_ Bidder of an auction. - * @param price_ Price of a bid. - * @param tax_ Tax of a bid. + * @param epoch_ Epoch. + * @param contentURI_ Content URI of a board. + * @param redirectURI_ Redirect URI of a board. */ - function newBid(uint256 tokenId_, uint256 auctionId_, address bidder_, uint256 price_, uint256 tax_) external; + function setBidURIs( + uint256 tokenId_, + uint256 epoch_, + string calldata contentURI_, + string calldata redirectURI_ + ) external; /** * @notice Set isWon of a bid * * @param tokenId_ Token ID of a board. - * @param auctionId_ Auction ID of an auction. + * @param epoch_ Epoch of an auction. * @param bidder_ Bidder of an auction. * @param isWon_ Whether a bid is won. */ - function setBidWon(uint256 tokenId_, uint256 auctionId_, address bidder_, bool isWon_) external; + function setBidWon(uint256 tokenId_, uint256 epoch_, address bidder_, bool isWon_) external; /** * @notice Set isWithdrawn of a bid * * @param tokenId_ Token ID of a board. - * @param auctionId_ Auction ID of an auction. + * @param epoch_ Epoch of an auction. * @param bidder_ Bidder of an auction. * @param isWithdrawn_ Whether a bid is won. */ - function setBidWithdrawn(uint256 tokenId_, uint256 auctionId_, address bidder_, bool isWithdrawn_) external; + function setBidWithdrawn(uint256 tokenId_, uint256 epoch_, address bidder_, bool isWithdrawn_) external; + + ////////////////////////////// + /// Tax & Withdraw + ////////////////////////////// /** - * @notice Transfer amount to a receiver. + * @notice Set the tax treasury. * - * @param to_ Address of a receiver. - * @param amount_ Amount. + * @param owner_ Address of a treasury owner. + * @param accumulated_ Accumulated tax. + * @param withdrawn_ Withdrawn tax. */ - function transferAmount(address to_, uint256 amount_) external; + function setTaxTreasury(address owner_, uint256 accumulated_, uint256 withdrawn_) external; ////////////////////////////// - /// Tax & Withdraw + /// Transfer ////////////////////////////// /** - * @notice Set the global tax rate. + * @notice Transfer a board (NFT). * - * @param taxRate_ Tax rate. + * @param from_ Address of the board sender. + * @param to_ Address of the board receiver. + * @param tokenId_ Token ID of the board. */ - function setTaxRate(uint256 taxRate_) external; + function safeTransferByOperator(address from_, address to_, uint256 tokenId_) external; /** - * @notice Set the tax treasury. + * @notice Transfer amount of token to a receiver. * - * @param owner_ Address of a treasury owner. - * @param accumulated_ Accumulated tax. - * @param withdrawn_ Withdrawn tax. + * @param to_ Address of a receiver. + * @param amount_ Amount. */ - function setTaxTreasury(address owner_, uint256 accumulated_, uint256 withdrawn_) external; + function transferTokenByOperator(address to_, uint256 amount_) external; ////////////////////////////// /// Event emission @@ -374,35 +289,10 @@ interface IBillboardRegistry is IERC721 { * @notice Emit `AuctionCleared` event. * * @param tokenId_ Token ID of a board. - * @param auctionId_ Auction ID of an auction. + * @param epoch_ Epoch of an auction. * @param highestBidder_ Highest bidder of an auction. - * @param leaseStartAt_ Start time of an board lease. - * @param leaseEndAt_ End time of an board lease. */ - function emitAuctionCleared( - uint256 tokenId_, - uint256 auctionId_, - address highestBidder_, - uint64 leaseStartAt_, - uint64 leaseEndAt_ - ) external; - - /** - * @notice Emit `BidWithdrawn` event. - * - * @param tokenId_ Token ID of a board. - * @param auctionId_ Auction ID of an auction. - * @param bidder_ Bidder of an auction. - * @param price_ Price of a bid. - * @param tax_ Tax of a bid. - */ - function emitBidWithdrawn( - uint256 tokenId_, - uint256 auctionId_, - address bidder_, - uint256 price_, - uint256 tax_ - ) external; + function emitAuctionCleared(uint256 tokenId_, uint256 epoch_, address highestBidder_) external; /** * @notice Emit `TaxWithdrawn` event.