// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import "./Accounts.sol"; import "./token-quote/ITokenQuote.sol"; import "./distributors/ERC20RewardDistributionHelper.sol"; import "../listing/Listings.sol"; interface IPaymentManager { /** * @notice Describes the earning type. */ enum EarningType { LISTER_FIXED_FEE, LISTER_EXTERNAL_ERC20_REWARD, RENTER_EXTERNAL_ERC20_REWARD, UNIVERSE_FIXED_FEE, UNIVERSE_EXTERNAL_ERC20_REWARD, PROTOCOL_FIXED_FEE, PROTOCOL_EXTERNAL_ERC20_REWARD } /** * @dev Emitted when a user has earned some amount tokens. * @param user Address of the user that earned some amount. * @param earningType Describes the type of the user. * @param paymentToken The currency that the user has earned. * @param amount The amount of tokens that the user has earned. */ event UserEarned( address indexed user, EarningType indexed earningType, address indexed paymentToken, uint256 amount ); /** * @dev Emitted when the universe has earned some amount of tokens. * @param universeId ID of the universe that earned the tokens. * @param earningType Describes the type of the user. * @param paymentToken The currency that the user has earned. * @param amount The amount of tokens that the user has earned. */ event UniverseEarned( uint256 indexed universeId, EarningType indexed earningType, address indexed paymentToken, uint256 amount ); /** * @dev Emitted when the protocol has earned some amount of tokens. * @param earningType Describes the type of the user. * @param paymentToken The currency that the user has earned. * @param amount The amount of tokens that the user has earned. */ event ProtocolEarned(EarningType indexed earningType, address indexed paymentToken, uint256 amount); /** * @dev Redirects handle rental payment from RentingManager to Accounts.Registry * @param rentingParams Renting params. * @param fees Rental fees. * @param payer Address of the rent payer. * @param maxPaymentAmount Maximum payment amount. * @param tokenQuote Encoded token quote data. * @param tokenQuoteSignature Encoded ECDSA signature for checking token quote data for validity. * @return rentalEarnings Payment token earnings. * @return paymentTokenData Payment token data. */ function handleRentalPayment( Rentings.Params calldata rentingParams, Rentings.RentalFees calldata fees, address payer, uint256 maxPaymentAmount, bytes calldata tokenQuote, bytes calldata tokenQuoteSignature ) external returns (Accounts.RentalEarnings memory rentalEarnings, ITokenQuote.PaymentTokenData memory paymentTokenData); /** * @dev Redirects handle external ERC20 reward payment from ERC20RewardDistributor to Accounts.Registry. * Metahub must have enough funds to cover the distribution. * ERC20RewardDistributor makes sure of that. * @param listing Represents, related to the distribution, listing. * @param agreement Represents, related to the distribution, agreement. * @param rentalExternalERC20RewardFees Represents calculated fees based on all terms applied to external reward. */ function handleExternalERC20Reward( Listings.Listing memory listing, Rentings.Agreement memory agreement, ERC20RewardDistributionHelper.RentalExternalERC20RewardFees memory rentalExternalERC20RewardFees ) external returns (Accounts.RentalEarnings memory rentalExternalRewardEarnings); /** * @dev Transfers the specific `amount` of `token` from a protocol balance to an arbitrary address. * @param token The token address. * @param amount The amount to be withdrawn. * @param to The payee address. */ function withdrawProtocolFunds( address token, uint256 amount, address to ) external; /** * @dev Transfers the specific `amount` of `token` from a universe balance to an arbitrary address. * @param universeId The universe ID. * @param token The token address. * @param amount The amount to be withdrawn. * @param to The payee address. */ function withdrawUniverseFunds( uint256 universeId, address token, uint256 amount, address to ) external; /** * @dev Transfers the specific `amount` of `token` from a user balance to an arbitrary address. * @param token The token address. * @param amount The amount to be withdrawn. * @param to The payee address. */ function withdrawFunds( address token, uint256 amount, address to ) external; /** * @dev Returns the amount of `token`, currently accumulated by the protocol. * @param token The token address. * @return Balance of `token`. */ function protocolBalance(address token) external view returns (uint256); /** * @dev Returns the list of protocol balances in various tokens. * @return List of balances. */ function protocolBalances() external view returns (Accounts.Balance[] memory); /** * @dev Returns the amount of `token`, currently accumulated by the universe. * @param universeId The universe ID. * @param token The token address. * @return Balance of `token`. */ function universeBalance(uint256 universeId, address token) external view returns (uint256); /** * @dev Returns the list of universe balances in various tokens. * @param universeId The universe ID. * @return List of balances. */ function universeBalances(uint256 universeId) external view returns (Accounts.Balance[] memory); /** * @dev Returns the amount of `token`, currently accumulated by the user. * @param account The account to query the balance for. * @param token The token address. * @return Balance of `token`. */ function balance(address account, address token) external view returns (uint256); /** * @dev Returns the list of user balances in various tokens. * @param account The account to query the balance for. * @return List of balances. */ function balances(address account) external view returns (Accounts.Balance[] memory); }