Skip to content

Commit

Permalink
style rule
Browse files Browse the repository at this point in the history
  • Loading branch information
anajuliabit committed Jun 28, 2024
1 parent 301d90e commit 4f40f84
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/staking-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

## Immutable Variables

- `STAKING_TOKEN`: the SHU token address
- `stakingToken`: the SHU token address

The staking token must be immutable. If the DAO changes the staking token, the
keypers will not be able to withdrawn their old stakes.
Expand Down
24 changes: 10 additions & 14 deletions src/Staking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ contract Staking is ERC20VotesUpgradeable, Ownable2StepUpgradeable {
using FixedPointMathLib for uint256;
using EnumerableSet for EnumerableSet.UintSet;

/*//////////////////////////////////////////////////////////////
IMMUTABLES
//////////////////////////////////////////////////////////////*/

/// @notice the staking token, i.e. SHU
/// @dev set in initialize, can't be changed
IERC20 public STAKING_TOKEN;

/*//////////////////////////////////////////////////////////////
VARIABLES
//////////////////////////////////////////////////////////////*/
Expand All @@ -35,6 +27,10 @@ contract Staking is ERC20VotesUpgradeable, Ownable2StepUpgradeable {
/// @dev only owner can change
IRewardsDistributor public rewardsDistributor;

/// @notice the staking token, i.e. SHU
/// @dev set in initialize, can't be changed
IERC20 public stakingToken;

/// @notice the lock period in seconds
/// @dev only owner can change
uint256 public lockPeriod;
Expand Down Expand Up @@ -157,7 +153,7 @@ contract Staking is ERC20VotesUpgradeable, Ownable2StepUpgradeable {
/// @notice Update rewards for a keyper
modifier updateRewards() {
// Distribute rewards
rewardsDistributor.distributeReward(address(STAKING_TOKEN));
rewardsDistributor.distributeReward(address(stakingToken));

_;
}
Expand Down Expand Up @@ -186,7 +182,7 @@ contract Staking is ERC20VotesUpgradeable, Ownable2StepUpgradeable {
// Transfer ownership to the DAO contract
_transferOwnership(newOwner);

STAKING_TOKEN = IERC20(stakingToken);
stakingToken = IERC20(stakingToken);
rewardsDistributor = IRewardsDistributor(_rewardsDistributor);
lockPeriod = _lockPeriod;
minStake = _minStake;
Expand Down Expand Up @@ -241,7 +237,7 @@ contract Staking is ERC20VotesUpgradeable, Ownable2StepUpgradeable {
/////////////////////////// INTERACTIONS ///////////////////////////

// Lock the SHU in the contract
STAKING_TOKEN.safeTransferFrom(keyper, address(this), amount);
stakingToken.safeTransferFrom(keyper, address(this), amount);

emit Staked(keyper, amount, sharesToMint, lockPeriod);

Expand Down Expand Up @@ -365,7 +361,7 @@ contract Staking is ERC20VotesUpgradeable, Ownable2StepUpgradeable {

_burn(keyper, shares);

STAKING_TOKEN.safeTransfer(keyper, rewards);
stakingToken.safeTransfer(keyper, rewards);

emit RewardsClaimed(keyper, rewards);
}
Expand Down Expand Up @@ -515,7 +511,7 @@ contract Staking is ERC20VotesUpgradeable, Ownable2StepUpgradeable {

/// @notice Get the amount of SHU staked for all keypers
function totalAssets() public view virtual returns (uint256) {
return STAKING_TOKEN.balanceOf(address(this));
return stakingToken.balanceOf(address(this));
}

/// @notice Get the stake ids belonging to a keyper
Expand Down Expand Up @@ -571,7 +567,7 @@ contract Staking is ERC20VotesUpgradeable, Ownable2StepUpgradeable {
}

// Transfer the SHU to the keyper
STAKING_TOKEN.safeTransfer(keyper, amount);
stakingToken.safeTransfer(keyper, amount);

emit Unstaked(keyper, amount, shares);
}
Expand Down
2 changes: 1 addition & 1 deletion test/Staking.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ contract Initializer is StakingTest {
function test_Initialize() public view {
assertEq(staking.owner(), address(this), "Wrong owner");
assertEq(
address(staking.STAKING_TOKEN()),
address(staking.stakingToken()),
address(govToken),
"Wrong staking token"
);
Expand Down

0 comments on commit 4f40f84

Please sign in to comment.