IPRoyaltyVault
The IPRoyaltyVault contract manages the claiming of royalty and revenue tokens for a given IP. It allows token holders to claim their share of revenue tokens based on snapshots, and ancestors to collect their royalty tokens.
State Variables
ipId
The IP ID to which this royalty vault belongs.
tokens
The set of revenue tokens in the vault.
unclaimedRoyaltyTokens
The amount of unclaimed royalty tokens.
lastSnapshotTimestamp
The timestamp of the last snapshot.
ancestorsVaultAmount
Maps token addresses to the amount in the ancestors vault.
isCollectedByAncestor
Indicates whether an ancestor has collected their royalty tokens.
claimVaultAmount
Maps token addresses to the amount in the claim vault.
claimableAtSnapshot
Maps snapshot IDs and token addresses to the claimable amount at that snapshot.
unclaimedAtSnapshot
Maps snapshot IDs to the amount of unclaimed tokens at that snapshot.
isClaimedAtSnapshot
Indicates whether a claimer has claimed a token at a specific snapshot.
Functions
initialize
Initializer for this implementation contract.
Parameters:
name
: The name of the royalty token.symbol
: The symbol of the royalty token.totalSupply
: The total supply of the royalty token.royaltyStack
: The royalty stack of the IP asset.ipId_
: The IP ID to which this royalty vault belongs.
addIpRoyaltyVaultTokens
Adds a token to the royalty vault.
Parameters:
token
: The token address to add.
Returns:
isAdded
: True if the token was added, false if it was already in the vault.
snapshot
Takes a snapshot of the claimable revenue and royalty token amounts.
Returns:
snapshotId
: The ID of the snapshot.
claimRevenueToken
Allows token holders to claim their share of revenue tokens.
Parameters:
snapshotIds
: The snapshot IDs to claim from.token
: The revenue token to claim.
collectRoyaltyTokens
Allows ancestors to claim the royalty tokens and any accrued revenue tokens.
Parameters:
ancestorIpId
: The IP ID of the ancestor to whom the royalty tokens belong.
ipId
Returns the IP ID to which this royalty vault belongs.
Returns:
- The IP ID address.
unclaimedRoyaltyTokens
Returns the amount of unclaimed royalty tokens.
Returns:
- The amount of unclaimed royalty tokens.
lastSnapshotTimestamp
Returns the last snapshotted timestamp.
Returns:
- The last snapshot timestamp.
ancestorsVaultAmount
Returns the amount of revenue token in the ancestors vault.
Parameters:
token
: The address of the revenue token.
Returns:
- The amount of revenue token in the ancestors vault.
isCollectedByAncestor
Indicates whether the ancestor has collected the royalty tokens.
Parameters:
ancestorIpId
: The ancestor IP ID address.
Returns:
- True if the ancestor has collected the royalty tokens.
claimVaultAmount
Returns the amount of revenue token in the claim vault.
Parameters:
token
: The address of the revenue token.
Returns:
- The amount of revenue token in the claim vault.
claimableAtSnapshot
Returns the amount of revenue token claimable at a given snapshot.
Parameters:
snapshotId
: The snapshot ID.token
: The address of the revenue token.
Returns:
- The amount of revenue token claimable at the snapshot.
unclaimedAtSnapshot
Returns the amount of unclaimed revenue tokens at the snapshot.
Parameters:
snapshotId
: The snapshot ID.
Returns:
- The amount of unclaimed revenue tokens at the snapshot.
isClaimedAtSnapshot
Indicates whether the claimer has claimed the revenue tokens at a given snapshot.
Parameters:
snapshotId
: The snapshot ID.claimer
: The address of the claimer.token
: The address of the revenue token.
Returns:
- True if the claimer has claimed the revenue tokens at the snapshot.
tokens
Returns the list of revenue tokens in the vault.
Returns:
- The array of revenue token addresses.
Security Considerations
The IPRoyaltyVault contract implements several security measures:
-
Access Control: Functions for adding tokens, taking snapshots, and claiming tokens are protected with appropriate modifiers.
-
Reentrancy Protection: The
nonReentrant
modifier is used on functions that handle token transfers to prevent reentrancy attacks. -
Pausability: The contract can be paused in emergency situations using the
whenNotPaused
modifier. -
Snapshot Mechanism: The contract uses a snapshot mechanism to ensure fair distribution of revenue tokens based on holdings at specific points in time.
-
Claim Verification: The contract tracks claimed tokens to prevent double-claiming by the same address.