Skip to content

Commit

Permalink
PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
asselstine committed May 19, 2022
1 parent f64ecb3 commit f938846
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
23 changes: 16 additions & 7 deletions contracts/GaugeReward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ contract GaugeReward is IGaugeReward, IPrizePoolLiquidatorListener, Multicall {
* @param gaugeController Address of the GaugeController
* @param vault Address of the Vault
*/
event Deployed(IGaugeController indexed gaugeController, address indexed vault);
event Deployed(
IGaugeController indexed gaugeController,
address indexed vault,
address indexed liquidator,
uint32 stakerCut
);

/**
* @notice Emitted when rewards token are added to a gauge
Expand Down Expand Up @@ -138,13 +143,19 @@ contract GaugeReward is IGaugeReward, IPrizePoolLiquidatorListener, Multicall {
require(address(_gaugeController) != address(0), "GReward/GC-not-zero-address");
require(address(_vault) != address(0), "GReward/Vault-not-zero-address");
require(_stakerCut < 1e9, "GReward/staker-cut-lt-1e9");
require(_liquidator != address(0), "GReward/liq-not-zero-address");

gaugeController = _gaugeController;
vault = _vault;
stakerCut = _stakerCut;
liquidator = _liquidator;

emit Deployed(_gaugeController, _vault);
emit Deployed(
_gaugeController,
_vault,
_liquidator,
_stakerCut
);
}

/* ============ External Functions ============ */
Expand All @@ -162,13 +173,11 @@ contract GaugeReward is IGaugeReward, IPrizePoolLiquidatorListener, Multicall {
* @notice Add rewards denominated in `token` for the given `gauge`.
* @dev Called by the liquidation contract anytime tokens are liquidated.
* @dev Will push token to the `gaugeRewardTokens` mapping if different from the current one.
* @param prizePool The prize pool whose tickets are being sold
* @param ticket The address of the tickets that were sold
* @param ticketAmount The amount of tickets that were sold
* @param token The address of the token that the tickets were sold for
* @param tokenAmount The amount of tokens that the tickets were sold for
*/
function afterSwap(IPrizePool prizePool, ITicket ticket, uint256 ticketAmount, IERC20 token, uint256 tokenAmount) external override {
function afterSwap(IPrizePool, ITicket ticket, uint256, IERC20 token, uint256 tokenAmount) external override {
require(msg.sender == liquidator, "GReward/only-liquidator");

address gauge = address(ticket);
Expand All @@ -193,7 +202,7 @@ contract GaugeReward is IGaugeReward, IPrizePoolLiquidatorListener, Multicall {
uint256 _oldStakeBalance
) external override onlyGaugeController {
RewardToken memory _rewardToken = _claimPastRewards(_gauge, _user, _oldStakeBalance);
if (_rewardToken.token != IERC20(address(0))) {
if (address(_rewardToken.token) != address(0)) {
_claim(_gauge, _rewardToken.token, _user, _oldStakeBalance, false);
}
userLastClaimedTimestamp[_user] = block.timestamp;
Expand Down Expand Up @@ -330,7 +339,7 @@ contract GaugeReward is IGaugeReward, IPrizePoolLiquidatorListener, Multicall {
_latestRewardToken = _rewardToken;
}

if (_rewardToken.timestamp > _userLastClaimedTimestamp && _userLastClaimedTimestamp > 0) {
if (_userLastClaimedTimestamp > 0 && _rewardToken.timestamp > _userLastClaimedTimestamp) {
_claim(_gauge, _rewardToken.token, _user, _stakeBalance, true);
} else {
break;
Expand Down
7 changes: 6 additions & 1 deletion test/GaugeReward.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ describe('GaugeReward', () => {

await expect(gaugeReward.deployTransaction)
.to.emit(gaugeReward, 'Deployed')
.withArgs(gaugeController.address, vault.address);
.withArgs(
gaugeController.address,
vault.address,
liquidator.address,
ethers.utils.parseUnits('0.1', 9)
);
});

it('should fail if GaugeController is address zero', async () => {
Expand Down

0 comments on commit f938846

Please sign in to comment.