Skip to content

Commit

Permalink
feat: uniprint
Browse files Browse the repository at this point in the history
  • Loading branch information
0xClandestine committed Aug 22, 2024
1 parent 3203b56 commit 91b0f24
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/contracts/core/RewardsCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ contract RewardsCoordinator is
uint8 internal constant PAUSED_PROCESS_CLAIM = 2;
/// @dev Index for flag that pauses submitRoots and disableRoot
uint8 internal constant PAUSED_SUBMIT_DISABLE_ROOTS = 3;
/// @dev Index for flag that pauses rewardParticipants
uint8 internal constant PAUSED_REWARD_PARTICIPANTS = 4;

/// @dev Salt for the earner leaf, meant to distinguish from tokenLeaf since they have the same sized data
uint8 internal constant EARNER_LEAF_SALT = 0;
Expand Down Expand Up @@ -173,6 +175,29 @@ contract RewardsCoordinator is
}
}

/**
* @notice Facilitates the distribution of rewards to participants through the UniPRInt V1.1 system.
* @dev The function leverages AVS-defined logic and external data for reward calculations.
* @param avs The address of the AVS responsible for managing the reward distribution.
* @param token The address of the ERC20 token used for rewards.
* @param amount The total amount of tokens to be rewarded.
* @param contentHash The keccak256 hash of the JSON manifest file that lists the earners and their rewards.
* @param contentURI The URI where the JSON manifest file is publicly accessible.
*/
function rewardParticipants(
address avs,
IERC20 token,
uint256 amount,
bytes32 contentHash,
string calldata contentURI
) external onlyWhenNotPaused(PAUSED_REWARD_PARTICIPANTS) {
// Pull `token` of `amount` from caller to this contract.
token.safeTransferFrom(msg.sender, address(this), amount);

// Emit event indicating a direct reward payment.
emit DirectRewardPayment(msg.sender, avs, token, amount, contentHash, contentURI);
}

/**
* @notice Claim rewards against a given root (read from _distributionRoots[claim.rootIndex]).
* Earnings are cumulative so earners don't have to claim against all distribution roots they have earnings for,
Expand Down
34 changes: 34 additions & 0 deletions src/contracts/interfaces/IRewardsCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,23 @@ interface IRewardsCoordinator {
uint256 claimedAmount
);

/// @notice Emitted when a direct reward payment is initiated through the UniPRInt V1.1 system.
/// @dev Supports programmatic rewards for AVS performance, EIGEN incentives, and more.
/// @param sender The address that initiated the reward payment (msg.sender).
/// @param avs The address of the AVS managing this reward.
/// @param token The address of the ERC20 token used for payment.
/// @param amount The total amount of tokens transferred to the RewardsCoordinator.
/// @param contentHash The keccak256 hash of the JSON manifest file listing the earners and amounts.
/// @param contentURI The publicly addressable URI pointing to the JSON manifest file.
event DirectRewardPayment(
address indexed sender,
address indexed avs,
IERC20 token,
uint256 amount,
bytes32 contentHash,
string contentURI
);

/**
*
* VIEW FUNCTIONS
Expand Down Expand Up @@ -267,6 +284,23 @@ interface IRewardsCoordinator {
*/
function createRewardsForAllSubmission(RewardsSubmission[] calldata rewardsSubmission) external;

/**
* @notice Facilitates the distribution of rewards to participants through the UniPRInt V1.1 system.
* @dev The function leverages AVS-defined logic and external data for reward calculations.
* @param avs The address of the AVS responsible for managing the reward distribution.
* @param token The address of the ERC20 token used for rewards.
* @param totalAmount The total amount of tokens to be transferred to the RewardsCoordinator.
* @param contentHash The keccak256 hash of the JSON manifest file that lists the earners and their rewards.
* @param contentURI The URI where the JSON manifest file is publicly accessible.
*/
function rewardParticipants(
address avs,
IERC20 token,
uint256 totalAmount,
bytes32 contentHash,
string calldata contentURI
) external;

/**
* @notice Claim rewards against a given root (read from _distributionRoots[claim.rootIndex]).
* Earnings are cumulative so earners don't have to claim against all distribution roots they have earnings for,
Expand Down

0 comments on commit 91b0f24

Please sign in to comment.