diff --git a/contracts/GaugeController.sol b/contracts/GaugeController.sol index 83e1fecb..a7ae2066 100644 --- a/contracts/GaugeController.sol +++ b/contracts/GaugeController.sol @@ -65,17 +65,70 @@ contract GaugeController is IGaugeController, Ownable { /// @notice Governance scale set for existing Gauge. mapping(address => TwabLib.Account) internal gaugeScaleTwabs; + /** + * @notice Event emitted when the contract is deployed + * @param token Address of the token being staked in the gauge + */ + event Deployed(IERC20 token, IGaugeReward gaugeReward, address owner); + /** * @notice Emitted when GaugeReward address is set/updated * @param gaugeReward Address of the newly set GaugeReward contract - */ + */ event GaugeRewardSet(IGaugeReward gaugeReward); /** - * @notice Event emitted when the contract is deployed - * @param token Address of the token being staked in the gauge + * @notice Emitted when User deposits 'token' into the gauge. + * @param user Address of the user who deposited 'token' into the GaugeController + * @param amount Amount of 'token' deposited into the GaugeController */ - event Deployed(IERC20 token, IGaugeReward gaugeReward, address owner); + event TokenDeposited(address indexed user, uint256 amount); + + /** + * @notice Emitted when User withdraws 'token' from the gauge. + * @param user Address of the user who withdrew 'token' from the GaugeController + * @param amount Amount of 'token' withdrawn from the GaugeController + */ + event TokenWithdrawn(address indexed user, uint256 amount); + + /** + * @notice Emitted when User increases a Gauge weight. + * @param user User address + * @param gauge Existing Gauge address + * @param amount Amount of 'balance' debited from the User and credited to the Gauge + */ + event GaugeIncreased(address indexed user, address indexed gauge, uint256 amount); + + /** + * @notice Emitted when User decrease a Gauge weight. + * @param user User address + * @param gauge Existing Gauge address + * @param amount Amount of 'balance' debited from the Gauge and credited to the User + */ + event GaugeDecreased(address indexed user, address indexed gauge, uint256 amount); + + /** + * @notice Emitted when an Authorized User adds a new Gauge to the GaugeController + * @param user Authorized address + * @param gauge New Gauge address + */ + event GaugeAdded(address indexed user, address gauge); + + /** + * @notice Emitted when an Authorized User removes an existing Gauge from the GaugeController + * @param user Authorized address + * @param gauge Gauge address + */ + event GaugeRemoved(address indexed user, address indexed gauge); + + /** + * @notice Emitted when an Authorized User sets an existing Gauge 'scale' weight. + * @param user Authorized address + * @param gauge Gauge address + * @param scale New Gauge scale + * @param oldScale Old Gauge scale + */ + event GaugeScaleSet(address indexed user, address indexed gauge, uint256 scale, uint256 oldScale); /* ================================================================================ */ /* Constructor & Modifiers */ @@ -85,6 +138,7 @@ contract GaugeController is IGaugeController, Ownable { * @notice GaugeController Construction * @param _token ERC20 contract address (used to weight gauges) * @param _gaugeReward GaugeReward to store ERC20 balances for stakers + * @param _owner Address of authorized owner */ constructor ( IERC20 _token, @@ -132,6 +186,7 @@ contract GaugeController is IGaugeController, Ownable { function deposit(address _to, uint256 _amount) public { balances[_to] += _amount; token.transferFrom(msg.sender, address(this), _amount); + emit TokenDeposited(msg.sender, _amount); } /** @@ -141,6 +196,7 @@ contract GaugeController is IGaugeController, Ownable { function withdraw(uint256 _amount) public { balances[msg.sender] -= _amount; token.transfer(msg.sender, _amount); + emit TokenWithdrawn(msg.sender, _amount); } /** @@ -157,6 +213,7 @@ contract GaugeController is IGaugeController, Ownable { ) = TwabLib.increaseBalance(gaugeTwab, _amount.toUint208(), uint32(block.timestamp)); gaugeTwab.details = twabDetails; gaugeReward.afterIncreaseGauge(_gauge, msg.sender, uint256(twabDetails.balance) - _amount); + emit GaugeIncreased(msg.sender, _gauge, _amount); } /** @@ -173,6 +230,7 @@ contract GaugeController is IGaugeController, Ownable { ) = TwabLib.decreaseBalance(gaugeTwab, _amount.toUint208(), "insuff", uint32(block.timestamp)); gaugeTwab.details = twabDetails; gaugeReward.afterDecreaseGauge(_gauge, msg.sender, uint256(twabDetails.balance) + _amount); + emit GaugeDecreased(msg.sender, _gauge, _amount); } /// @TODO: Add Governance/Executive authorization modifier/function. @@ -206,6 +264,7 @@ contract GaugeController is IGaugeController, Ownable { twabDetails,, ) = TwabLib.decreaseBalance(gaugeScaleTwab, twabDetails.balance, "insuff", uint32(block.timestamp)); gaugeScaleTwab.details = twabDetails; + emit GaugeRemoved(msg.sender, _gauge); } /** @@ -215,7 +274,6 @@ contract GaugeController is IGaugeController, Ownable { function setGaugeReward(IGaugeReward _gaugeReward) external onlyOwner { require(address(_gaugeReward) != address(0), "GC/GaugeReward-not-zero-address"); gaugeReward = _gaugeReward; - emit GaugeRewardSet(_gaugeReward); } @@ -238,6 +296,7 @@ contract GaugeController is IGaugeController, Ownable { ) = TwabLib.increaseBalance(gaugeScaleTwab, _scale.toUint208() - twabDetails.balance, uint32(block.timestamp)); } gaugeScaleTwab.details = twabDetails; + emit GaugeScaleSet(msg.sender, _gauge, _scale, twabDetails.balance); } /// @inheritdoc IGaugeController @@ -306,6 +365,7 @@ contract GaugeController is IGaugeController, Ownable { uint32(block.timestamp) ); gaugeScaleTwab.details = twabDetails; + emit GaugeAdded(msg.sender, _gauge); } function _getAverageGaugeBalanceBetween(address _gauge, uint256 _startTime, uint256 _endTime) internal view returns (uint256) {