// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import "../../contract-registry/IContractEntity.sol"; import "../Listings.sol"; interface IListingManager is IContractEntity { /** * @dev Thrown when the message sender is not renting manager. */ error CallerIsNotRentingManager(); /** * @dev Thrown when the message sender does not own LISTING_WIZARD role and is not lister. * @param listingId The Listing ID. * @param account The account that was checked. */ error AccountIsNotAuthorizedOperatorForListingManagement(uint256 listingId, address account); /** * @dev Thrown when the message sender does not own LISTING_WIZARD role */ error AccountIsNotListingWizard(address account); /** * @dev Thrown when assets array is empty. */ error EmptyAssetsArray(); /** * @dev Thrown when asset collection is mismatched in one of the assets from assets array. */ error AssetCollectionMismatch(); /** * @dev Thrown when the original asset cannot be withdrawn because of active rentals * or other activity that requires asset to stay in the vault. */ error AssetIsLocked(); /** * @dev Thrown when the configurator returns a payment beneficiary different from lister. */ error OnlyImmediatePayoutSupported(); /** * @dev Thrown when the Listing with `listingId` * is not registered among present or historical Listings, * meaning it has never existed. * @param listingId The ID of Listing that never existed. */ error ListingNeverExisted(uint256 listingId); /** * @dev Emitted when a new listing is created. * @param listingId Listing ID. * @param lister Lister account address. * @param assets Listing asset. * @param params Listing params. * @param maxLockPeriod The maximum amount of time the original asset owner can wait before getting the asset back. */ event ListingCreated( uint256 indexed listingId, address indexed lister, Assets.Asset[] assets, Listings.Params params, uint32 maxLockPeriod ); /** * @dev Emitted when the listing is no longer available for renting. * @param listingId Listing ID. * @param lister Lister account address. * @param unlocksAt The earliest possible time when the asset can be returned to the owner. */ event ListingDisabled(uint256 indexed listingId, address indexed lister, uint32 unlocksAt); /** * @dev Emitted when the asset is returned to the `lister`. * @param listingId Listing ID. * @param lister Lister account address. * @param assets Returned assets. */ event ListingWithdrawal(uint256 indexed listingId, address indexed lister, Assets.Asset[] assets); /** * @dev Emitted when the listing is paused. * @param listingId Listing ID. */ event ListingPaused(uint256 indexed listingId); /** * @dev Emitted when the listing pause is lifted. * @param listingId Listing ID. */ event ListingUnpaused(uint256 indexed listingId); /** * @dev Creates new listing. * Emits an {ListingCreated} event. * @param assets Assets to be listed. * @param params Listing params. * @param maxLockPeriod The maximum amount of time the original asset owner can wait before getting the asset back. * @param immediatePayout Indicates whether the rental fee must be transferred to the lister on every renting. * If FALSE, the rental fees get accumulated until withdrawn manually. * @return listingId New listing ID. */ function createListing( Assets.Asset[] calldata assets, Listings.Params calldata params, uint32 maxLockPeriod, bool immediatePayout ) external returns (uint256 listingId); /** * @dev Updates listing lock time for Listing. * @param listingId Listing ID. * @param unlockTimestamp Timestamp when asset would be unlocked. */ function addLock(uint256 listingId, uint32 unlockTimestamp) external; /** * @dev Marks the assets as being delisted. This operation in irreversible. * After delisting, the asset can only be withdrawn when it has no active rentals. * Emits an {AssetDelisted} event. * @param listingId Listing ID. */ function disableListing(uint256 listingId) external; /** * @dev Returns the asset back to the lister. * Emits an {AssetWithdrawn} event. * @param listingId Listing ID. */ function withdrawListingAssets(uint256 listingId) external; /** * @dev Puts the listing on pause. * Emits a {ListingPaused} event. * @param listingId Listing ID. */ function pauseListing(uint256 listingId) external; /** * @dev Lifts the listing pause. * Emits a {ListingUnpaused} event. * @param listingId Listing ID. */ function unpauseListing(uint256 listingId) external; /** * @dev Returns the Listing details by the `listingId`. * Performs a look up among both * present (contains listed and delisted, but not yet withdrawn Listings) * and historical ones (withdrawn Listings only). * @param listingId Listing ID. * @return Listing details. */ function listingInfo(uint256 listingId) external view returns (Listings.Listing memory); /** * @dev Reverts if Listing is * neither registered among present ones nor listed. * @param listingId Listing ID. */ function checkRegisteredAndListed(uint256 listingId) external view; /** * @dev Reverts if the provided `account` does not own LISTING_WIZARD role. * @param account The account to check ownership for. */ function checkIsListingWizard(address account) external view; /** * @dev Returns the number of currently registered listings. * @return Listing count. */ function listingCount() external view returns (uint256); /** * @dev Returns the paginated list of currently registered listings. * @param offset Starting index. * @param limit Max number of items. * @return Listing IDs. * @return Listings. */ function listings(uint256 offset, uint256 limit) external view returns (uint256[] memory, Listings.Listing[] memory); /** * @dev Returns the number of currently registered listings for the particular lister account. * @param lister Lister address. * @return Listing count. */ function userListingCount(address lister) external view returns (uint256); /** * @dev Returns the paginated list of currently registered listings for the particular lister account. * @param lister Lister address. * @param offset Starting index. * @param limit Max number of items. * @return Listing IDs. * @return Listings. */ function userListings( address lister, uint256 offset, uint256 limit ) external view returns (uint256[] memory, Listings.Listing[] memory); /** * @dev Returns the number of currently registered listings for the particular original asset address. * @param original Original asset address. * @return Listing count. */ function assetListingCount(address original) external view returns (uint256); /** * @dev Returns the paginated list of currently registered listings for the particular original asset address. * @param original Original asset address. * @param offset Starting index. * @param limit Max number of items. * @return Listing IDs. * @return Listings. */ function assetListings( address original, uint256 offset, uint256 limit ) external view returns (uint256[] memory, Listings.Listing[] memory); }