Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ancestors hash and royalty context requirement from royalty LAP policy #4

Merged
merged 8 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ interface IAncestorsVaultLAP {
/// @notice Claims all available royalty nfts and accrued royalties for an ancestor of a given ipId
/// @param ipId The ipId of the ancestors vault to claim from
/// @param claimerIpId The claimer ipId is the ancestor address that wants to claim
/// @param ancestors The ancestors for the selected ipId
/// @param ancestorsRoyalties The royalties of the ancestors for the selected ipId
/// @param tokens The ERC20 tokens to withdraw
function claim(
address ipId,
address claimerIpId,
address[] calldata ancestors,
uint32[] calldata ancestorsRoyalties,
ERC20[] calldata tokens
) external;
function claim(address ipId, address claimerIpId, ERC20[] calldata tokens) external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ import { IRoyaltyPolicy } from "../../../../interfaces/modules/royalty/policies/

/// @title RoyaltyPolicy interface
interface IRoyaltyPolicyLAP is IRoyaltyPolicy {
/// @notice Initializes a royalty policy LAP for a given IP asset
/// @param targetAncestors The expected ancestors addresses of an ipId
/// @param targetRoyaltyAmount The expected royalties of each of the ancestors for a given ipId
/// @param parentAncestors1 The addresses of the ancestors of the first parent
/// @param parentAncestors2 The addresses of the ancestors of the second parent
/// @param parentAncestorsRoyalties1 The royalties of each of the ancestors of the first parent
/// @param parentAncestorsRoyalties2 The royalties of each of the ancestors of the second parent
struct InitParams {
address[] targetAncestors;
uint32[] targetRoyaltyAmount;
address[] parentAncestors1;
address[] parentAncestors2;
uint32[] parentAncestorsRoyalties1;
uint32[] parentAncestorsRoyalties2;
}

/// @notice Event emitted when a policy is initialized
/// @param ipId The ID of the IP asset that the policy is being initialized for
/// @param splitClone The split clone address
Expand All @@ -39,26 +23,6 @@ interface IRoyaltyPolicyLAP is IRoyaltyPolicy {
uint32[] targetRoyaltyAmount
);

/// @notice Returns the royalty data for a given IP asset
/// @param ipId The ID of the IP asset
/// @return isUnlinkable Indicates if the ipId is unlinkable to new parents
/// @return splitClone The address of the liquid split clone contract for a given ipId
/// @return ancestorsVault The address of the ancestors vault contract for a given ipId
/// @return royaltyStack The royalty stack of a given ipId is the sum of the royalties to be paid to each ancestors
/// @return ancestorsHash The hash of the unique ancestors addresses and royalties arrays
function royaltyData(
address ipId
)
external
view
returns (
bool isUnlinkable,
address splitClone,
address ancestorsVault,
uint32 royaltyStack,
bytes32 ancestorsHash
);

/// @notice Returns the percentage scale - 1000 rnfts represents 100%
function TOTAL_RNFT_SUPPLY() external view returns (uint32);

Expand Down Expand Up @@ -115,14 +79,18 @@ interface IRoyaltyPolicyLAP is IRoyaltyPolicy {
/// @notice Claims available royalty nfts and accrued royalties for an ancestor of a given ipId
/// @param ipId The ipId of the ancestors vault to claim from
/// @param claimerIpId The claimer ipId is the ancestor address that wants to claim
/// @param ancestors The ancestors for the selected ipId
/// @param ancestorsRoyalties The royalties of the ancestors for the selected ipId
/// @param tokens The ERC20 tokens to withdraw
function claimFromAncestorsVault(
address ipId,
address claimerIpId,
address[] calldata ancestors,
uint32[] calldata ancestorsRoyalties,
ERC20[] calldata tokens
) external;
function claimFromAncestorsVault(address ipId, address claimerIpId, ERC20[] calldata tokens) external;

/// @notice Returns the royalty data for a given IP asset
/// @param ipId The ID of the IP asset
/// @return isUnlinkable Indicates if the ipId is unlinkable to new parents
/// @return splitClone The address of the liquid split clone contract for a given ipId
/// @return ancestorsVault The address of the ancestors vault contract for a given ipId
/// @return royaltyStack The royalty stack of a given ipId is the sum of the royalties to be paid to each ancestors
/// @return targetAncestors The ip ancestors array
/// @return targetRoyaltyAmount The ip royalty amount array
function getRoyaltyData(
address ipId
) external view returns (bool, address, address, uint32, address[] memory, uint32[] memory);
}
12 changes: 1 addition & 11 deletions contracts/lib/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ library Errors {
error DisputeModule__NotInDisputeState();
error DisputeModule__NotAbleToResolve();
error DisputeModule__NotRegisteredIpId();
error DisputeModule__UnauthorizedAccess();

error ArbitrationPolicySP__ZeroDisputeModule();
error ArbitrationPolicySP__ZeroPaymentToken();
Expand All @@ -214,7 +213,6 @@ library Errors {
error RoyaltyModule__ZeroLicensingModule();
error RoyaltyModule__CanOnlyMintSelectedPolicy();
error RoyaltyModule__NoParentsOnLinking();
error RoyaltyModule__NotRegisteredIpId();

error RoyaltyPolicyLAP__ZeroRoyaltyModule();
error RoyaltyPolicyLAP__ZeroLiquidSplitFactory();
Expand All @@ -224,26 +222,18 @@ library Errors {
error RoyaltyPolicyLAP__AboveParentLimit();
error RoyaltyPolicyLAP__AboveAncestorsLimit();
error RoyaltyPolicyLAP__AboveRoyaltyStackLimit();
error RoyaltyPolicyLAP__InvalidAncestorsLength();
error RoyaltyPolicyLAP__InvalidAncestors();
error RoyaltyPolicyLAP__InvalidRoyaltyAmountLength();
error RoyaltyPolicyLAP__InvalidAncestorsHash();
error RoyaltyPolicyLAP__InvalidParentRoyaltiesLength();
error RoyaltyPolicyLAP__InvalidAncestorsRoyalty();
error RoyaltyPolicyLAP__ImplementationAlreadySet();
error RoyaltyPolicyLAP__ZeroAncestorsVaultImpl();
error RoyaltyPolicyLAP__NotFullOwnership();
error RoyaltyPolicyLAP__UnlinkableToParents();
error RoyaltyPolicyLAP__TransferFailed();
error RoyaltyPolicyLAP__LastPositionNotAbleToMintLicense();

error AncestorsVaultLAP__ZeroRoyaltyPolicyLAP();
error AncestorsVaultLAP__AlreadyClaimed();
error AncestorsVaultLAP__InvalidAncestorsHash();
error AncestorsVaultLAP__InvalidClaimer();
error AncestorsVaultLAP__InvalidVault();
error AncestorsVaultLAP__ClaimerNotAnAncestor();
error AncestorsVaultLAP__ERC20BalanceNotZero();
error AncestorsVaultLAP__TransferFailed();

////////////////////////////////////////////////////////////////////////////
// ModuleRegistry //
Expand Down
27 changes: 12 additions & 15 deletions contracts/modules/royalty/policies/AncestorsVaultLAP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,19 @@ contract AncestorsVaultLAP is IAncestorsVaultLAP, ERC1155Holder, ReentrancyGuard
/// @notice Claims all available royalty nfts and accrued royalties for an ancestor of a given ipId
/// @param ipId The ipId of the ancestors vault to claim from
/// @param claimerIpId The claimer ipId is the ancestor address that wants to claim
/// @param ancestors The ancestors for the selected ipId
/// @param ancestorsRoyalties The royalties of the ancestors for the selected ipId
/// @param tokens The ERC20 tokens to withdraw
function claim(
address ipId,
address claimerIpId,
address[] calldata ancestors,
uint32[] calldata ancestorsRoyalties,
ERC20[] calldata tokens
) external nonReentrant {
(, address splitClone, address ancestorsVault, , bytes32 ancestorsHash) = ROYALTY_POLICY_LAP.royaltyData(ipId);
function claim(address ipId, address claimerIpId, ERC20[] calldata tokens) external nonReentrant {
(
,
address splitClone,
address ancestorsVault,
,
address[] memory ancestors,
uint32[] memory ancestorsRoyalties
) = ROYALTY_POLICY_LAP.getRoyaltyData(ipId);

if (isClaimed[ipId][claimerIpId]) revert Errors.AncestorsVaultLAP__AlreadyClaimed();
if (address(this) != ancestorsVault) revert Errors.AncestorsVaultLAP__InvalidClaimer();
if (keccak256(abi.encodePacked(ancestors, ancestorsRoyalties)) != ancestorsHash)
revert Errors.AncestorsVaultLAP__InvalidAncestorsHash();
if (address(this) != ancestorsVault) revert Errors.AncestorsVaultLAP__InvalidVault();

// transfer the rnfts to the claimer accrued royalties to the claimer IpId address
_transferRnftsAndAccruedTokens(claimerIpId, splitClone, ancestors, ancestorsRoyalties, tokens);
Expand All @@ -69,8 +66,8 @@ contract AncestorsVaultLAP is IAncestorsVaultLAP, ERC1155Holder, ReentrancyGuard
function _transferRnftsAndAccruedTokens(
address claimerIpId,
address splitClone,
address[] calldata ancestors,
uint32[] calldata ancestorsRoyalties,
address[] memory ancestors,
uint32[] memory ancestorsRoyalties,
ERC20[] calldata tokens
) internal {
(uint32 index, bool isIn) = ArrayUtils.indexOf(ancestors, claimerIpId);
Expand Down
Loading