From 5621cba2919dfd53d78e2eff53a75cba35858786 Mon Sep 17 00:00:00 2001 From: Spablob Date: Wed, 31 Jan 2024 14:34:29 -0800 Subject: [PATCH] add interfaces --- .../modules/royalty/IRoyaltyModule.sol | 44 +++++++++++++++---- .../modules/royalty/policies/IClaimerLS.sol | 21 +++++++++ .../royalty/policies/ILiquidSplitClone.sol | 16 +++++++ .../royalty/policies/ILiquidSplitMain.sol | 9 ++++ .../royalty/policies/IRoyaltyPolicy.sol | 5 ++- .../royalty/policies/IRoyaltyPolicyLS.sol | 38 ++++++++++++++++ 6 files changed, 123 insertions(+), 10 deletions(-) create mode 100644 contracts/interfaces/modules/royalty/policies/IClaimerLS.sol create mode 100644 contracts/interfaces/modules/royalty/policies/IRoyaltyPolicyLS.sol diff --git a/contracts/interfaces/modules/royalty/IRoyaltyModule.sol b/contracts/interfaces/modules/royalty/IRoyaltyModule.sol index a75f8bb23..7e34caee0 100644 --- a/contracts/interfaces/modules/royalty/IRoyaltyModule.sol +++ b/contracts/interfaces/modules/royalty/IRoyaltyModule.sol @@ -3,23 +3,51 @@ pragma solidity ^0.8.23; /// @title RoyaltyModule interface interface IRoyaltyModule { + /// @notice Event emitted when a royalty policy is whitelisted + /// @param royaltyPolicy The address of the royalty policy + /// @param allowed Indicates if the royalty policy is whitelisted or not + event RoyaltyPolicyWhitelistUpdated(address royaltyPolicy, bool allowed); + + /// @notice Event emitted when a royalty token is whitelisted + /// @param token The address of the royalty token + /// @param allowed Indicates if the royalty token is whitelisted or not + event RoyaltyTokenWhitelistUpdated(address token, bool allowed); + + /// @notice Event emitted when a royalty policy is set + /// @param ipId The ipId + /// @param royaltyPolicy The address of the royalty policy + /// @param data The data to initialize the policy + event RoyaltyPolicySet(address ipId, address royaltyPolicy, bytes data); + + /// @notice Event emitted when royalties are paid + /// @param receiverIpId The ipId that receives the royalties + /// @param payerIpId The ipId that pays the royalties + /// @param sender The address that pays the royalties on behalf of the payer ipId + /// @param token The token that is used to pay the royalties + /// @param amount The amount that is paid + event RoyaltyPaid(address receiverIpId, address payerIpId, address sender, address token, uint256 amount); + /// @notice Whitelist a royalty policy /// @param royaltyPolicy The address of the royalty policy /// @param allowed Indicates if the royalty policy is whitelisted or not function whitelistRoyaltyPolicy(address royaltyPolicy, bool allowed) external; + /// @notice Whitelist a royalty token + /// @param token The token address + /// @param allowed Indicates if the token is whitelisted or not + function whitelistRoyaltyToken(address token, bool allowed) external; + /// @notice Sets the royalty policy for an ipId /// @param ipId The ipId /// @param royaltyPolicy The address of the royalty policy + /// @param parentIpIds The parent ipIds /// @param data The data to initialize the policy - function setRoyaltyPolicy(address ipId, address royaltyPolicy, bytes calldata data) external; + function setRoyaltyPolicy(address ipId, address royaltyPolicy, address[] calldata parentIpIds, bytes calldata data) external; - /// @notice Allows an IPAccount to pay royalties - /// @param ipId The ipId - /// @param token The token to pay the royalties in + /// @notice Allows a sender to to pay royalties on behalf of an ipId + /// @param receiverIpId The ipId that receives the royalties + /// @param payerIpId The ipId that pays the royalties + /// @param token The token to use to pay the royalties /// @param amount The amount to pay - function payRoyalty(address ipId, address token, uint256 amount) external; - - /// @notice Gets the royalty policy for a given ipId - function royaltyPolicies(address ipId) external view returns (address royaltyPolicy); + function payRoyaltyOnBehalf(address receiverIpId, address payerIpId, address token, uint256 amount) external; } \ No newline at end of file diff --git a/contracts/interfaces/modules/royalty/policies/IClaimerLS.sol b/contracts/interfaces/modules/royalty/policies/IClaimerLS.sol new file mode 100644 index 000000000..f85d9bc78 --- /dev/null +++ b/contracts/interfaces/modules/royalty/policies/IClaimerLS.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.23; + +import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +/// @title Liquid split policy claimer interface +interface IClaimerLS { + /// @notice Event emitted when a claim is made + /// @param path The path from the ipId to the claimer + /// @param claimer The claimer ipId address + /// @param withdrawETH Indicates if the claimer wants to withdraw ETH + /// @param tokens The ERC20 tokens to withdraw + event Claimed(address[] path, address claimer, bool withdrawETH, ERC20[] tokens); + + /// @notice Allows an ipId to claim their rnfts and accrued royalties + /// @param path The path of the ipId + /// @param claimerIpId The ipId of the claimer + /// @param withdrawETH Indicates if the claimer wants to withdraw ETH + /// @param tokens The ERC20 tokens to withdraw + function claim(address[] calldata path, address claimerIpId, bool withdrawETH, ERC20[] calldata tokens) external; +} \ No newline at end of file diff --git a/contracts/interfaces/modules/royalty/policies/ILiquidSplitClone.sol b/contracts/interfaces/modules/royalty/policies/ILiquidSplitClone.sol index f8ece07cb..61cff364f 100644 --- a/contracts/interfaces/modules/royalty/policies/ILiquidSplitClone.sol +++ b/contracts/interfaces/modules/royalty/policies/ILiquidSplitClone.sol @@ -8,4 +8,20 @@ interface ILiquidSplitClone { /// @param accounts The accounts to distribute to /// @param distributorAddress The distributor address function distributeFunds(address token, address[] calldata accounts, address distributorAddress) external; + + /// @notice Transfers rnft tokens + /// @param from The address to transfer from + /// @param to The address to transfer to + /// @param id The token id + /// @param amount The amount to transfer + /// @param data Custom data + function safeTransferFrom( + address from, + address to, + uint256 id, + uint256 amount, + bytes calldata data + ) external; + + function balanceOf(address account, uint256 id) external view returns (uint256); } \ No newline at end of file diff --git a/contracts/interfaces/modules/royalty/policies/ILiquidSplitMain.sol b/contracts/interfaces/modules/royalty/policies/ILiquidSplitMain.sol index ba1380935..5e89b83c6 100644 --- a/contracts/interfaces/modules/royalty/policies/ILiquidSplitMain.sol +++ b/contracts/interfaces/modules/royalty/policies/ILiquidSplitMain.sol @@ -14,4 +14,13 @@ interface ILiquidSplitMain { uint256 withdrawETH, ERC20[] calldata tokens ) external; + + /// @notice Gets the ETH balance of an account + /// @param account The account to get the ETH balance of + function getETHBalance(address account) external view returns (uint256); + + /// @notice Gets the ERC20 balance of an account + /// @param account The account to get the ERC20 balance of + /// @param token The token to get the balance of + function getERC20Balance(address account, ERC20 token) external view returns (uint256); } \ No newline at end of file diff --git a/contracts/interfaces/modules/royalty/policies/IRoyaltyPolicy.sol b/contracts/interfaces/modules/royalty/policies/IRoyaltyPolicy.sol index ad97f6b61..5d4142002 100644 --- a/contracts/interfaces/modules/royalty/policies/IRoyaltyPolicy.sol +++ b/contracts/interfaces/modules/royalty/policies/IRoyaltyPolicy.sol @@ -5,8 +5,9 @@ pragma solidity ^0.8.23; interface IRoyaltyPolicy { /// @notice Initializes the royalty policy /// @param ipId The ipId - /// @param data The data to initialize the policy - function initPolicy(address ipId, bytes calldata data) external; + /// @param parentsIpIds The parent ipIds + /// @param data The data to initialize the policy + function initPolicy(address ipId, address[] calldata parentsIpIds, bytes calldata data) external; /// @notice Allows to pay a royalty /// @param caller The caller diff --git a/contracts/interfaces/modules/royalty/policies/IRoyaltyPolicyLS.sol b/contracts/interfaces/modules/royalty/policies/IRoyaltyPolicyLS.sol new file mode 100644 index 000000000..5f856f82a --- /dev/null +++ b/contracts/interfaces/modules/royalty/policies/IRoyaltyPolicyLS.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.23; + +import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +import { IRoyaltyPolicy } from "contracts/interfaces/modules/royalty/policies/IRoyaltyPolicy.sol"; + +/// @title RoyaltyPolicy interface +interface IRoyaltyPolicyLS is IRoyaltyPolicy { + /// @notice Gets the royalty data + /// @param ipId The ipId + /// @return splitClone The split clone address + /// claimer The claimer address + /// royaltyStack The royalty stack + /// minRoyalty The min royalty + function royaltyData(address ipId) external view returns (address splitClone, address claimer, uint32 royaltyStack, uint32 minRoyalty); + + /// @notice Distributes funds to the accounts in the LiquidSplitClone contract + /// @param ipId The ipId + /// @param token The token to distribute + /// @param accounts The accounts to distribute to + /// @param distributorAddress The distributor address + function distributeFunds( + address ipId, + address token, + address[] calldata accounts, + address distributorAddress + ) external; + + /// @notice Claims the available royalties for a given account + /// @param account The account to claim for + /// @param withdrawETH The amount of ETH to withdraw + /// @param tokens The tokens to withdraw + function claimRoyalties(address account, uint256 withdrawETH, ERC20[] calldata tokens) external; + + /// @notice Gets liquid split main address + function LIQUID_SPLIT_MAIN() external view returns (address); +} \ No newline at end of file