Skip to content

Commit

Permalink
remove redundant functions
Browse files Browse the repository at this point in the history
  • Loading branch information
akshatmittal committed Apr 22, 2024
1 parent 53740fd commit cec0f09
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 41 deletions.
16 changes: 0 additions & 16 deletions contracts/rewards/GenericMultiRewardsVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,6 @@ contract GenericMultiRewardsVault is ERC4626, Ownable {
return shares;
}

function deposit(uint256 _amount) external returns (uint256) {
return deposit(_amount, msg.sender);
}

function mint(uint256 _amount) external returns (uint256) {
return mint(_amount, msg.sender);
}

function withdraw(uint256 _amount) external returns (uint256) {
return withdraw(_amount, msg.sender, msg.sender);
}

function redeem(uint256 _amount) external returns (uint256) {
return redeem(_amount, msg.sender, msg.sender);
}

function _deposit(
address caller,
address receiver,
Expand Down
50 changes: 25 additions & 25 deletions test/GenericMultiRewardsVault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ERC20Mock } from "@test/mocks/ERC20Mock.sol";
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";

import { GenericMultiRewardsVault, IERC20, IERC20Metadata } from "@src/rewards/GenericMultiRewardsVault.sol";
import { Errors, Events } from "@src/rewards/Definitions.sol";
import { Errors, Events } from "@src/rewards/definitions.sol";

// Test Suite based on Popcorn DAO's MultiRewardStaking
// See: https://github.com/Popcorn-Limited/contracts/blob/d029c413239735f58b0adcead11fdbe8f69a0e34/test/MultiRewardStaking.t.sol
Expand Down Expand Up @@ -213,13 +213,13 @@ contract GenericMultiRewardsVaultTest is Test {

vm.startPrank(alice);
stakingToken.approve(address(staking), 5 ether);
staking.deposit(1 ether);
staking.deposit(1 ether, alice);

// 10% of rewards paid out
vm.warp(block.timestamp + 10);

uint256 callTimestamp = block.timestamp;
staking.deposit(1 ether);
staking.deposit(1 ether, alice);

(, , uint48 lastUpdatedTimestamp, , uint256 index, uint256 ONE) = staking.rewardInfos(iRewardToken1);
// console2.log(index);
Expand All @@ -235,7 +235,7 @@ contract GenericMultiRewardsVaultTest is Test {
vm.warp(block.timestamp + 10);

callTimestamp = block.timestamp;
staking.mint(2 ether);
staking.mint(2 ether, alice);

(, , lastUpdatedTimestamp, , index, ) = staking.rewardInfos(iRewardToken1);
assertEq(uint256(index), (25 * ONE) / 10);
Expand All @@ -248,7 +248,7 @@ contract GenericMultiRewardsVaultTest is Test {
vm.warp(block.timestamp + 70);

callTimestamp = block.timestamp;
staking.withdraw(2 ether);
staking.withdraw(2 ether, alice, alice);

(, , lastUpdatedTimestamp, , index, ) = staking.rewardInfos(iRewardToken1);
assertEq(uint256(index), (425 * ONE) / 100);
Expand All @@ -261,7 +261,7 @@ contract GenericMultiRewardsVaultTest is Test {
vm.warp(block.timestamp + 10);

callTimestamp = block.timestamp;
staking.redeem(1 ether);
staking.redeem(1 ether, alice, alice);

(, , lastUpdatedTimestamp, , index, ) = staking.rewardInfos(iRewardToken1);
assertEq(uint256(index), (475 * ONE) / 100);
Expand All @@ -277,12 +277,12 @@ contract GenericMultiRewardsVaultTest is Test {

vm.startPrank(alice);
stakingToken.approve(address(staking), 5 ether);
staking.deposit(1 ether);
staking.deposit(1 ether, alice);

vm.warp(block.timestamp + 10);

uint256 callTimestamp = block.timestamp;
staking.deposit(1 ether);
staking.deposit(1 ether, alice);

// RewardsToken 1 -- 10% accrued
(, , uint48 lastUpdatedTimestampReward1, , uint256 indexReward1, uint256 reward1ONE) = staking.rewardInfos(
Expand All @@ -302,7 +302,7 @@ contract GenericMultiRewardsVaultTest is Test {
vm.warp(block.timestamp + 10);

callTimestamp = block.timestamp;
staking.deposit(2 ether);
staking.deposit(2 ether, alice);

// RewardsToken 1 -- 20% accrued
(, , lastUpdatedTimestampReward1, , indexReward1, ) = staking.rewardInfos(iRewardToken1);
Expand All @@ -325,7 +325,7 @@ contract GenericMultiRewardsVaultTest is Test {
vm.warp(block.timestamp + 80);

callTimestamp = block.timestamp;
staking.deposit(1 ether);
staking.deposit(1 ether, alice);

// RewardsToken 1 -- 100% accrued
(, , lastUpdatedTimestampReward1, , indexReward1, ) = staking.rewardInfos(iRewardToken1);
Expand Down Expand Up @@ -354,7 +354,7 @@ contract GenericMultiRewardsVaultTest is Test {

vm.startPrank(alice);
stakingToken.approve(address(staking), 5 ether);
staking.deposit(1 ether);
staking.deposit(1 ether, alice);

// 10% of rewards paid out
vm.warp(block.timestamp + 10);
Expand All @@ -378,15 +378,15 @@ contract GenericMultiRewardsVaultTest is Test {

vm.startPrank(alice);
stakingToken.approve(address(staking), 2 ether);
staking.deposit(1 ether);
staking.deposit(1 ether, alice);
vm.stopPrank();

// 100% of rewards paid out
vm.warp(block.timestamp + 100);

uint256 callTimestamp = block.timestamp;
vm.prank(alice);
staking.deposit(1 ether);
staking.deposit(1 ether, alice);

(, , uint48 lastUpdatedTimestamp, , uint256 index, uint256 ONE) = staking.rewardInfos(iRewardToken1);
assertEq(uint256(index), 11 * ONE);
Expand All @@ -400,7 +400,7 @@ contract GenericMultiRewardsVaultTest is Test {

callTimestamp = block.timestamp;
vm.prank(alice);
staking.withdraw(1 ether);
staking.withdraw(1 ether, alice, alice);

(, , lastUpdatedTimestamp, , index, ) = staking.rewardInfos(iRewardToken1);
assertEq(uint256(index), 11 * ONE);
Expand All @@ -422,7 +422,7 @@ contract GenericMultiRewardsVaultTest is Test {
vm.warp(block.timestamp + 10);

uint256 callTimestamp = block.timestamp;
staking.deposit(1 ether);
staking.deposit(1 ether, alice);

(, , uint48 lastUpdatedTimestamp, , uint256 index, uint256 ONE) = staking.rewardInfos(iRewardToken1);
// Accrual doesnt start until someone deposits -- TODO does this change some of the rewardsEnd and rewardsSpeed assumptions?
Expand Down Expand Up @@ -451,11 +451,11 @@ contract GenericMultiRewardsVaultTest is Test {
// 80% of rewards paid out
vm.warp(block.timestamp + 70);

staking.withdraw((5 * ONE) / 10);
staking.withdraw((5 * ONE) / 10, alice, alice);
vm.stopPrank();
vm.prank(bob);
callTimestamp = block.timestamp;
staking.withdraw((5 * ONE) / 10);
staking.withdraw((5 * ONE) / 10, bob, bob);

(, , lastUpdatedTimestamp, , index, ) = staking.rewardInfos(iRewardToken1);
assertEq(uint256(index), ONE + (ONE * 10) / 3);
Expand Down Expand Up @@ -621,7 +621,7 @@ contract GenericMultiRewardsVaultTest is Test {
stakingToken.approve(address(staking), 1 ether);

vm.prank(alice);
staking.deposit(1 ether);
staking.deposit(1 ether, alice);

// 10% of rewards paid out
vm.warp(block.timestamp + 10);
Expand All @@ -633,13 +633,13 @@ contract GenericMultiRewardsVaultTest is Test {
// Half Accrual (from original)
staking.changeRewardSpeed(iRewardToken1, (5 * ONE) / 100);
vm.prank(bob);
staking.deposit(1 ether);
staking.deposit(1 ether, bob);

// 50% of rewards paid out
vm.warp(block.timestamp + 40);

vm.prank(alice);
staking.withdraw(1 ether);
staking.withdraw(1 ether, alice, alice);

// Check Alice RewardsState
(, , uint48 lastUpdatedTimestamp, , uint256 index, ) = staking.rewardInfos(iRewardToken1);
Expand All @@ -649,7 +649,7 @@ contract GenericMultiRewardsVaultTest is Test {
assertEq(staking.accruedRewards(alice, iRewardToken1), 4 * ONE);

vm.prank(bob);
staking.withdraw(1 ether);
staking.withdraw(1 ether, bob, bob);

// Check Bobs RewardsState
(, , lastUpdatedTimestamp, , index, ) = staking.rewardInfos(iRewardToken1);
Expand All @@ -667,7 +667,7 @@ contract GenericMultiRewardsVaultTest is Test {
vm.prank(alice);
stakingToken.approve(address(staking), 1 ether);
vm.prank(alice);
staking.deposit(1 ether);
staking.deposit(1 ether, alice);

(, uint48 rewardsEndTimestamp, , , , uint256 ONE) = staking.rewardInfos(iRewardToken1);
// StartTime 1, Rewards 10e18, RewardsPerSecond 0.1e18, RewardsEndTimeStamp 101
Expand Down Expand Up @@ -740,7 +740,7 @@ contract GenericMultiRewardsVaultTest is Test {
stakingToken.mint(address(this), 1 ether);
stakingToken.approve(address(staking), 1 ether);

staking.deposit(1 ether);
staking.deposit(1 ether, address(this));

(, uint48 oldRewardsEndTimestamp, , , , ) = staking.rewardInfos(iRewardToken1);

Expand Down Expand Up @@ -815,7 +815,7 @@ contract GenericMultiRewardsVaultTest is Test {

vm.startPrank(alice);
stakingToken.approve(address(staking), 5 ether);
staking.deposit(1 ether);
staking.deposit(1 ether, alice);

// 10% of rewards paid out
vm.warp(block.timestamp + 10);
Expand All @@ -841,7 +841,7 @@ contract GenericMultiRewardsVaultTest is Test {

vm.startPrank(alice);
stakingToken.approve(address(staking), 1 ether);
staking.deposit(1 ether);
staking.deposit(1 ether, alice);
vm.stopPrank();

staking.fundReward(iRewardToken1, 5 ether);
Expand Down

0 comments on commit cec0f09

Please sign in to comment.