diff --git a/contracts/strategies/_poc/hedgey/HedgeyRFPCommitteeStrategy.sol b/contracts/strategies/_poc/hedgey/HedgeyRFPCommitteeStrategy.sol index 6327b97c4..393337ea4 100644 --- a/contracts/strategies/_poc/hedgey/HedgeyRFPCommitteeStrategy.sol +++ b/contracts/strategies/_poc/hedgey/HedgeyRFPCommitteeStrategy.sol @@ -4,6 +4,7 @@ pragma solidity 0.8.19; // Core Contracts import {RFPCommitteeStrategy} from "../../rfp-committee/RFPCommitteeStrategy.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import {IAllo} from "contracts/core/interfaces/IAllo.sol"; // Internal Libraries import {Metadata} from "../../../core/libraries/Metadata.sol"; @@ -117,6 +118,44 @@ contract HedgeyRFPCommitteeStrategy is RFPCommitteeStrategy { /// ============ Internal ============== /// ==================================== + /// @notice Distribute the upcoming milestone to acceptedRecipientId. + /// @dev '_sender' must be a pool manager to distribute. + /// @param _sender The sender of the distribution + function _distribute(address[] memory, bytes memory, address _sender) + internal + virtual + override + onlyInactivePool + onlyPoolManager(_sender) + { + // check to make sure there is a pending milestone + if (upcomingMilestone >= milestones.length) revert INVALID_MILESTONE(); + + IAllo.Pool memory pool = allo.getPool(poolId); + Milestone storage milestone = milestones[upcomingMilestone]; + Recipient memory recipient = _recipients[acceptedRecipientId]; + + // Check if the milestone is pending + if (milestone.milestoneStatus != Status.Pending) revert INVALID_MILESTONE(); + + // Calculate the amount to be distributed for the milestone + uint256 amount = (recipient.proposalBid * milestone.amountPercentage) / 1e18; + + // Get the pool, subtract the amount and transfer to the recipient + poolAmount -= amount; + _transferAmount(pool.token, recipient.recipientAddress, amount); + + // Set the milestone status to 'Accepted' + milestone.milestoneStatus = Status.Accepted; + + // Increment the upcoming milestone + upcomingMilestone++; + + // Emit events for the milestone and the distribution + emit MilestoneStatusChanged(upcomingMilestone, Status.Accepted); + emit Distributed(acceptedRecipientId, recipient.recipientAddress, amount, _sender); + } + function _transferAmount(address _token, address _recipient, uint256 _amount) internal { IERC20(_token).approve(hedgeyContract, _amount);