Skip to content

Commit

Permalink
Updated tests, added gas reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
The-3D committed Feb 16, 2021
1 parent 33adf3d commit bc7b3e7
Show file tree
Hide file tree
Showing 5 changed files with 530 additions and 13 deletions.
12 changes: 6 additions & 6 deletions contracts/stake/StakedTokenV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ contract StakedTokenV3 is StakedTokenV2, IStakedTokenV3, RoleManager {
bytes32 s
) external override {
IERC20WithPermit(address(STAKED_TOKEN)).permit(from, address(this), amount, deadline, v, r, s);
_stake(from, to, amount, false);
_stake(from, to, amount, true);
}

/**
Expand Down Expand Up @@ -240,14 +240,13 @@ contract StakedTokenV3 is StakedTokenV2, IStakedTokenV3, RoleManager {
* @param to Address to stake to
* @param amount Amount to claim
**/
function claimRewardsAndStake(address to, uint256 amount)
external
override
{
function claimRewardsAndStake(address to, uint256 amount) external override {
require(REWARD_TOKEN == STAKED_TOKEN, 'REWARD_TOKEN_IS_NOT_STAKED_TOKEN');

uint256 rewardsClaimed = _claimRewards(msg.sender, address(this), amount);
_stake(address(this), to, rewardsClaimed, false);
if (rewardsClaimed != 0) {
_stake(address(this), to, rewardsClaimed, false);
}
}

/**
Expand Down Expand Up @@ -380,6 +379,7 @@ contract StakedTokenV3 is StakedTokenV2, IStakedTokenV3, RoleManager {
uint256 amount
) internal returns (uint256) {
uint256 newTotalRewards = _updateCurrentUnclaimedRewards(from, balanceOf(from), false);

uint256 amountToClaim = (amount == type(uint256).max) ? newTotalRewards : amount;

stakerRewardsToClaim[from] = newTotalRewards.sub(amountToClaim, 'INVALID_AMOUNT');
Expand Down
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import '@nomiclabs/hardhat-waffle';
import '@nomiclabs/hardhat-etherscan';
import path from 'path';
import fs from 'fs';
import 'hardhat-gas-reporter';

export const BUIDLEREVM_CHAIN_ID = 31337;

Expand Down
Loading

0 comments on commit bc7b3e7

Please sign in to comment.