Skip to content

Commit

Permalink
feat: transfer challenge reward from vault
Browse files Browse the repository at this point in the history
  • Loading branch information
sm-stack committed Jul 21, 2024
1 parent 8e092b5 commit ec5c35a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 8 additions & 2 deletions packages/contracts/contracts/L1/AssetManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -730,15 +730,21 @@ contract AssetManager is ISemver, IERC721Receiver, IAssetManager {
* @param baseReward The base reward to distribute.
* @param boostedReward The boosted reward to distribute.
* @param validatorReward The validator reward to distribute.
* @param challengeReward The challenge reward to distribute.
*/
function increaseBalanceWithReward(
address validator,
uint128 baseReward,
uint128 boostedReward,
uint128 validatorReward
uint128 validatorReward,
uint128 challengeReward
) external onlyValidatorManager {
// Distribute the reward from a designated vault to the AssetManager contract.
ASSET_TOKEN.transferFrom(VALIDATOR_REWARD_VAULT, address(this), baseReward + boostedReward + validatorReward);
ASSET_TOKEN.transferFrom(
VALIDATOR_REWARD_VAULT,
address(this),
baseReward + boostedReward + validatorReward + challengeReward
);

// If reward is distributed to SECURITY_COUNCIL, transfer it directly.
if (validator == SECURITY_COUNCIL) {
Expand Down
6 changes: 4 additions & 2 deletions packages/contracts/contracts/L1/ValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,14 @@ contract ValidatorManager is ISemver, IValidatorManager {
uint128 validatorReward
) = _calculateReward(submitter);

uint128 challengeReward = _pendingChallengeReward[outputIndex];

ASSET_MANAGER.increaseBalanceWithReward(
submitter,
baseReward,
boostedReward,
validatorReward
validatorReward,
challengeReward
);

emit RewardDistributed(
Expand All @@ -531,7 +534,6 @@ contract ValidatorManager is ISemver, IValidatorManager {
boostedReward
);

uint128 challengeReward = _pendingChallengeReward[outputIndex];
if (challengeReward > 0) {
ASSET_MANAGER.increaseBalanceWithChallenge(submitter, challengeReward);
delete _pendingChallengeReward[outputIndex];
Expand Down

0 comments on commit ec5c35a

Please sign in to comment.