Skip to content

Commit

Permalink
fix: add more events
Browse files Browse the repository at this point in the history
  • Loading branch information
ankurdubey521 committed Jul 3, 2023
1 parent aed640d commit 10c8997
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/transaction-allocator/common/interfaces/ITAHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pragma solidity 0.8.19;

import {RelayerAddress, TokenAddress, RelayerState} from "../TATypes.sol";
import {FixedPointType} from "src/library/FixedPointArithmetic.sol";

/// @title ITAHelpers
interface ITAHelpers {
Expand All @@ -13,4 +14,5 @@ interface ITAHelpers {

event DelegatorRewardsAdded(RelayerAddress indexed _relayer, TokenAddress indexed _token, uint256 indexed _amount);
event NewRelayerState(bytes32 indexed relayerStateHash, RelayerState relayerState);
event RelayerProtocolSharesBurnt(RelayerAddress indexed relayerAddress, FixedPointType indexed sharesBurnt);
}
2 changes: 2 additions & 0 deletions src/transaction-allocator/modules/delegation/TADelegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ contract TADelegation is TADelegationGetters, TAHelpers, ITADelegation {
rs.totalUnpaidProtocolRewards = updatedTotalUnpaidProtocolRewards - relayerRewards - delegatorRewards;
rs.totalProtocolRewardShares = rs.totalProtocolRewardShares - sharesToBurn;
relayerInfo.rewardShares = relayerInfo.rewardShares - sharesToBurn;

emit RelayerProtocolSharesBurnt(_relayer, sharesToBurn);
}

/// @inheritdoc ITADelegation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ contract TATransactionAllocation is ITATransactionAllocation, TAHelpers, TATrans
uint256 penalty = _calculatePenalty(stake);

// Initialize protocol reward state cache if not already done
// TODO: Test this thoroughly
if (_state.updatedSharePrice == FP_ZERO) {
_state.updatedUnpaidProtocolRewards = _getLatestTotalUnpaidProtocolRewardsAndUpdateUpdatedTimestamp();
_state.updatedSharePrice = _protocolRewardRelayerSharePrice(_state.updatedUnpaidProtocolRewards);
Expand Down Expand Up @@ -458,9 +457,10 @@ contract TATransactionAllocation is ITATransactionAllocation, TAHelpers, TATrans
_relayerInfo.rewardShares = _relayerInfo.rewardShares - protocolRewardSharesBurnt;

_state.totalProtocolRewardSharesBurnt = _state.totalProtocolRewardSharesBurnt + protocolRewardSharesBurnt;

emit RelayerProtocolSharesBurnt(_relayerAddress, protocolRewardSharesBurnt);
}

// TODO: Emit shares burnt
emit RelayerPenalized(_relayerAddress, updatedStake, _penalty);
}

Expand Down Expand Up @@ -503,6 +503,8 @@ contract TATransactionAllocation is ITATransactionAllocation, TAHelpers, TATrans

_state.totalProtocolRewardSharesBurnt = _state.totalProtocolRewardSharesBurnt + protocolRewardSharesBurnt;
_state.totalProtocolRewardsPaid += relayerRewards + delegatorRewards;

emit RelayerProtocolSharesBurnt(_relayerAddress, protocolRewardSharesBurnt);
}

// Penalize the relayer
Expand Down

0 comments on commit 10c8997

Please sign in to comment.