RewardRegistry Contract Documentation
Overview
The RewardRegistry contract manages store-specific reward allocations in the TRASH Protocol. It allows store owners to add, remove, or replace reward allocations for their stores. It also enables the governance authority to approve or revoke allocations. This contract relies on a combination of permissions, store ownership verification, and allocation management for secure and efficient reward allocation.
Inherited Contracts
- AllocationApproved: Manages the approval and revocation of store allocations.
- StoreAllocation: Handles the addition, removal, and replacement of store allocations.
- StoreOwnership: Verifies store ownership for actions related to allocations.
- Permissions: Ensures role-based access control for governance and store ownership.
- NoETH: Prevents the contract from accepting Ether.
Functions
initialize(address _registryAddress)
- Description: Initializes the contract by setting the registry address. This registry manages permissions and interactions with other protocol components.
- Parameters:
_registryAddress: The address of the registry store contract.- Reverts:
CantSetZeroAddress: If the registry address is the zero address.
addToStoreAllocation(uint256 storeId, uint256 allocation)
- Description: Adds a reward allocation to the specified store. Only the store owner can add to the allocation.
- Parameters:
storeId: The ID of the store.allocation: The reward allocation to be added for the store.- Modifiers:
onlyOwnerOfStore: Ensures only the store owner can call this function.
replaceStoreAllocation(uint256 storeId, uint256[] memory allocation)
- Description: Replaces the reward allocations for the specified store. Only the store owner can replace the allocation.
- Parameters:
storeId: The ID of the store.allocation: The new reward allocation to replace the current one.- Modifiers:
onlyOwnerOfStore: Ensures only the store owner can call this function.
removeStoreAllocation(uint256 storeId)
- Description: Removes the reward allocation for the specified store. Only the store owner can remove the allocation.
- Parameters:
storeId: The ID of the store.- Modifiers:
onlyOwnerOfStore: Ensures only the store owner can call this function.
approveStoreAllocation(uint256 storeId)
- Description: Approves the reward allocation for the specified store. Only addresses with the Governance role can approve allocations.
- Parameters:
storeId: The ID of the store.- Modifiers:
onlyGovernance: Ensures only governance can call this function.- Emits:
TokenAllocationApproved: Emitted when a store's reward allocation is approved.
revokeAllocationApproval(uint256 storeId)
- Description: Revokes the approval of the reward allocation for the specified store. Only addresses with the Governance role can revoke approvals.
- Parameters:
storeId: The ID of the store.- Modifiers:
onlyGovernance: Ensures only governance can call this function.- Emits:
TokenAllocationApprovalRevoked: Emitted when a store's reward allocation approval is revoked.
Supporting Abstract Contracts
AllocationApproved
- Description: Manages the approval and revocation of reward allocations for stores.
Internal Functions - AllocationApproved
-
_approveStoreAllocation(uint256 storeId): -
Approves the reward allocation for the specified store and emits
TokenAllocationApproved. -
_revokeAllocationApproval(uint256 storeId): -
Revokes the approval of the reward allocation for the specified store and emits
TokenAllocationApprovalRevoked. -
isRewardAllocationApproved(uint256 storeId): - Checks if the reward allocation for the specified store is approved.
StoreAllocation
- Description: Handles the management of store reward allocations, including adding, removing, and replacing allocations.
Internal Functions - StoreAllocation
-
_addToStoreAllocation(uint256 storeId, uint256 allocation): -
Adds a new reward allocation to the specified store and revokes its previous approval.
-
_removeStoreAllocation(uint256 storeId): -
Removes the reward allocation for the specified store.
-
_replaceStoreAllocation(uint256 storeId, uint256[] memory allocation): -
Replaces the reward allocation for the specified store and revokes its previous approval.
-
getStoreAllocation(uint256 storeId): - Returns the reward allocation for the specified store.
StoreOwnership
- Description: Verifies that the caller is the owner of the specified store. This ensures only store owners can manage allocations.
Modifier
onlyOwnerOfStore(uint256 storeId):- Ensures that only the owner of the specified store can call the function. Reverts with
NotOwnerOfStoreif the caller is not the store owner.
Errors
- CantSetZeroAddress: Thrown when a zero address is provided where a valid address is expected.
- NotOwnerOfStore: Thrown when a non-owner attempts to perform actions restricted to store owners.
Events
TokenAllocationApproved(uint256 indexed storeId)
- Description: Emitted when a store's reward allocation is approved.
- Parameters:
storeId: The ID of the store whose allocation was approved.
TokenAllocationApprovalRevoked(uint256 indexed storeId)
- Description: Emitted when a store's reward allocation approval is revoked.
- Parameters:
storeId: The ID of the store whose allocation approval was revoked.
Conclusion
The RewardRegistry contract is a crucial component of the TRASH Protocol, managing the reward allocations for stores. It allows store owners to securely manage their store's reward allocations, while governance oversees and approves these allocations. The contract relies on various modular components for efficient and secure reward allocation management.