From 91b0f24b9cf6fe17f910c86a9df2db7de170bc6d Mon Sep 17 00:00:00 2001 From: "clandestine.eth" <96172957+0xClandestine@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:50:47 -0400 Subject: [PATCH] feat: uniprint --- src/contracts/core/RewardsCoordinator.sol | 25 ++++++++++++++ .../interfaces/IRewardsCoordinator.sol | 34 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/src/contracts/core/RewardsCoordinator.sol b/src/contracts/core/RewardsCoordinator.sol index 562df4cb7..4334f9ea9 100644 --- a/src/contracts/core/RewardsCoordinator.sol +++ b/src/contracts/core/RewardsCoordinator.sol @@ -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; @@ -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, diff --git a/src/contracts/interfaces/IRewardsCoordinator.sol b/src/contracts/interfaces/IRewardsCoordinator.sol index dd95ff5cb..43091d78f 100644 --- a/src/contracts/interfaces/IRewardsCoordinator.sol +++ b/src/contracts/interfaces/IRewardsCoordinator.sol @@ -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 @@ -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,