Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed up GaugeReward test #269

Merged
merged 5 commits into from
May 19, 2022
Merged

Conversation

asselstine
Copy link
Contributor

No description provided.

@linear
Copy link

linear bot commented May 19, 2022

POOL-2284 Update GaugeRewards contract

  • transfer tokens from vault instead of keeping track of users claimed amount
  • set a variable to track the percentage of liquidation
  • addRewards → afterSwap interprets gauge as ticket and takes a cut from liquidation

contracts/GaugeReward.sol Outdated Show resolved Hide resolved
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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a require for _liquidator different than address zero.


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

emit Deployed(_gaugeController, _vault);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emit _liquidator and _stakerCut in event.

address(this),
type(uint256).max - _token.allowance(_vaultAddress, address(this))
);
function afterSwap(IPrizePool prizePool, ITicket ticket, uint256 ticketAmount, IERC20 token, uint256 tokenAmount) external override {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove prizePool and ticketAmount params if not used.

type(uint256).max - _token.allowance(_vaultAddress, address(this))
);
function afterSwap(IPrizePool prizePool, ITicket ticket, uint256 ticketAmount, IERC20 token, uint256 tokenAmount) external override {
require(msg.sender == liquidator, "GReward/only-liquidator");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a modifier instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That code isn't used anywhere else- refactoring it into a modifier doesn't make sense

RewardToken memory _rewardToken = _claimPastRewards(_gauge, _user, _oldStakeBalance);

_claim(_gauge, _rewardToken.token, _user, _oldStakeBalance, false);
if (_rewardToken.token != IERC20(address(0))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (_rewardToken.token != IERC20(address(0))) {
if (address(_rewardToken.token) != address(0)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean....same difference right?

_latestRewardToken = _rewardToken;
}

if (_rewardToken.timestamp > _userLastClaimedTimestamp) {
if (_rewardToken.timestamp > _userLastClaimedTimestamp && _userLastClaimedTimestamp > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for 0 first.

Suggested change
if (_rewardToken.timestamp > _userLastClaimedTimestamp && _userLastClaimedTimestamp > 0) {
if (_userLastClaimedTimestamp > 0 && _rewardToken.timestamp > _userLastClaimedTimestamp) {


_pushRewardToken(_gauge, _token);
address gauge = address(ticket);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty confusing. I still don't understand what the gauge is referring to in this contract.
Cause here, it means that we add rewards for a ticket and not a gauge?

@PierrickGT PierrickGT merged commit 47106f3 into staging May 19, 2022
@PierrickGT PierrickGT deleted the pool-2284-update-gaugerewards-contract branch May 19, 2022 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants