The RFPSimpleStrategy
contract represents a smart contract for Request for Proposal (RFP) allocation with milestone submission and management. It extends the capabilities of the BaseStrategy
contract and integrates features specifically tailored for managing recipient registration, milestone submissions, and reviews for RFPs. The contract also incorporates the ReentrancyGuard
library to prevent reentrant attacks.
sequenceDiagram
participant Alice
participant PoolManager
participant Allo
participant RFPSimpleStrategy
PoolManager->>Allo: createPool() with RFPSimple
Allo-->>PoolManager: poolId
Alice->>+Allo: registerRecipient()
Allo->>RFPSimpleStrategy: registerRecipient()
RFPSimpleStrategy-->>Allo: recipient1
Allo-->>-Alice: recipientId1
PoolManager->>+Allo: allocate() (accepts a recipient and allocate proposal bid)
Allo-->>-RFPSimpleStrategy: allocate() (accepts a recipient and allocate proposal bid)
PoolManager->> RFPSimpleStrategy: setMilestones()
Alice->> RFPSimpleStrategy: submitUpcomingMilestone()
PoolManager->> RFPSimpleStrategy: rejectMilestone()
Alice->> RFPSimpleStrategy: submitUpcomingMilestone()
PoolManager->>+Allo: distribute() ( mnextilestone for recipient)
Allo-->>-RFPSimpleStrategy: distribute() (next milestone for recipient)
PoolManager->>RFPSimpleStrategy: setPoolActive() to close pool
- License: The
RFPSimpleStrategy
contract operates under the AGPL-3.0-only License, fostering open-source usage under specific terms. - Solidity Version: Developed using Solidity version 0.8.19, capitalizing on the latest Ethereum smart contract functionalities.
- External Libraries: Utilizes the
ReentrancyGuard
library from the OpenZeppelin contracts to prevent reentrant attacks. - Interfaces: Imports interfaces from the Allo core and external libraries.
- Internal Libraries: Imports the
Metadata
library from the Allo core for metadata management.
Recipient
: Contains recipient-related data, such as the recipient's address, proposal bid, use of registry anchor, and status.Milestone
: Holds details about a milestone, including the amount percentage, metadata, and status.
INVALID_MILESTONE
: Thrown when a milestone is invalid.MILESTONE_ALREADY_ACCEPTED
: Thrown when a milestone is already accepted.EXCEEDING_MAX_BID
: Thrown when a proposal bid exceeds the maximum bid.MILESTONES_ALREADY_SET
: Thrown when milestones are already set or approved.AMOUNT_TOO_LOW
: Thrown when the max bid increase amount is too low.
MaxBidIncreased
: Emitted when the maximum bid is increased.MilestoneSubmitted
: Emitted when a milestone is submitted.MilestoneStatusChanged
: Emitted for the status change of a milestone.MilestonesSet
: Emitted when milestones are set.
useRegistryAnchor
: Flag indicating whether to use the registry anchor for recipient registration.metadataRequired
: Flag indicating whether metadata is required for recipient registration.acceptedRecipientId
: The accepted recipient who can submit milestones._registry
: Reference to the Allo registry contract.maxBid
: The maximum bid for the RFP pool.upcomingMilestone
: Index of the upcoming milestone._recipientIds
: Collection of recipient addresses.milestones
: Collection of submitted milestones._recipients
: Mapping from recipient addresses to recipient data.
The constructor initializes the strategy by accepting the address of the IAllo
contract and a name.
The initialize
function decodes and initializes parameters passed during strategy creation. It sets specific strategy variables and the pool to active.
getRecipient
: Retrieves recipient details.getMilestone
: Retrieves milestone details.getMilestoneStatus
: Retrieves the status of a milestone.
setMilestones
: Sets milestones for the accepted recipient.submitUpcomingMilestone
: Submits a milestone for the accepted recipient.rejectMilestone
: Rejects a pending milestone.increaseMaxBid
: Updates the maximum bid for the RFP pool.withdraw
: Allows pool managers to withdraw funds from the pool.
_registerRecipient
: Handles recipient registration, processing the provided data._allocate
: Allocates funds to the accepted recipient._distribute
: Distributes upcoming milestone funds to the accepted recipient.
- Recipient or Profile Owner initiates a registration request.
- If
useRegistryAnchor
is enabled:- Submits recipient ID, proposal bid, and metadata.
- Verifies sender's authorization.
- Validates the provided data.
- Registers recipient as "Pending" with provided details.
- Emits
Registered
event.
- If
useRegistryAnchor
is disabled:- Submits recipient address, registry anchor, proposal bid, and metadata.
- Determines if the registry anchor is being used.
- Verifies sender's authorization.
- Validates the provided data.
- Registers recipient as "Pending" with provided details.
- Emits
Registered
event.
- Pool Manager initiates a milestone setting request.
- Verifies if sender is authorized to set milestones.
- Checks if upcoming milestone is not already set.
- Sets provided milestones for the accepted recipient.
- Emits
MilestonesSet
event.
- Recipient initiates a milestone proof submission.
- Verifies if sender is authorized to submit the proof.
- Checks if upcoming milestone is valid.
- Updates milestone's metadata and status to "Pending".
- Emits
MilestoneSubmitted
event.
- Pool Manager initiates a milestone rejection request.
- Verifies if sender is authorized to reject milestones.
- Checks if milestone is not already accepted.
- Changes milestone status to "Rejected".
- Emits
MilestoneStatusChanged
event.
- Pool Manager initiates a max bid update request.
- Verifies if sender is authorized to update the max bid.
- Ensures the new max bid is higher than the current max bid.
- Updates the max bid.
- Emits
MaxBidIncreased
event.
- Pool Manager initiates a milestone distribution request.
- Verifies if sender is authorized to distribute funds.
- Checks if a pending milestone exists.
- Calculates the amount to distribute based on the accepted recipient's proposal bid and milestone percentage.
- Transfers the calculated amount to the accepted recipient.
- Changes the milestone status to "Accepted".
- Emits
MilestoneStatusChanged
andDistributed
events.
- Pool Manager initiates a withdrawal request.
- Verifies if sender is authorized to withdraw funds.
- Checks if the pool is inactive.
- Decreases the pool amount by the requested withdrawal amount.
- Transfers the requested amount to the sender.