Skip to content

Commit

Permalink
fix: custom transfer function
Browse files Browse the repository at this point in the history
  • Loading branch information
ilpepepig committed Aug 21, 2024
1 parent 53e0306 commit 32fbcb2
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions contracts/strategies/_poc/hedgey/HedgeyRFPCommitteeStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 32fbcb2

Please sign in to comment.