Skip to content

Commit 96b7c6e

Browse files
committed
code review comments
1 parent f66d358 commit 96b7c6e

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

contracts/TokenGeyser.sol

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ contract TokenGeyser is IStaking, Ownable {
3535
// amount: Unlocked tokens, total: Total locked tokens
3636
event TokensUnlocked(uint256 amount, uint256 total);
3737

38-
TokenPool public stakingPool;
38+
TokenPool private _stakingPool;
3939
TokenPool private _unlockedPool;
4040
TokenPool private _lockedPool;
4141

@@ -110,7 +110,7 @@ contract TokenGeyser is IStaking, Ownable {
110110
require(bonusPeriodSec_ != 0, 'TokenGeyser: bonus period is zero');
111111
require(initialSharesPerToken > 0, 'TokenGeyser: initialSharesPerToken is zero');
112112

113-
stakingPool = new TokenPool(stakingToken);
113+
_stakingPool = new TokenPool(stakingToken);
114114
_unlockedPool = new TokenPool(distributionToken);
115115
_lockedPool = new TokenPool(distributionToken);
116116
startBonus = startBonus_;
@@ -123,7 +123,7 @@ contract TokenGeyser is IStaking, Ownable {
123123
* @return The token users deposit as stake.
124124
*/
125125
function getStakingToken() public view returns (IERC20) {
126-
return stakingPool.token();
126+
return _stakingPool.token();
127127
}
128128

129129
/**
@@ -186,7 +186,7 @@ contract TokenGeyser is IStaking, Ownable {
186186
// _lastAccountingTimestampSec = now;
187187

188188
// interactions
189-
require(stakingPool.token().transferFrom(staker, address(stakingPool), amount),
189+
require(_stakingPool.token().transferFrom(staker, address(_stakingPool), amount),
190190
'TokenGeyser: transfer into staking pool failed');
191191

192192
emit Staked(beneficiary, amount, totalStakedFor(beneficiary), "");
@@ -266,7 +266,7 @@ contract TokenGeyser is IStaking, Ownable {
266266
// _lastAccountingTimestampSec = now;
267267

268268
// interactions
269-
require(stakingPool.transfer(msg.sender, amount),
269+
require(_stakingPool.transfer(msg.sender, amount),
270270
'TokenGeyser: transfer out of staking pool failed');
271271
require(_unlockedPool.transfer(msg.sender, rewardAmount),
272272
'TokenGeyser: transfer out of unlocked pool failed');
@@ -328,7 +328,7 @@ contract TokenGeyser is IStaking, Ownable {
328328
* @return The total number of deposit tokens staked globally, by all users.
329329
*/
330330
function totalStaked() public view returns (uint256) {
331-
return stakingPool.balance();
331+
return _stakingPool.balance();
332332
}
333333

334334
/**
@@ -503,10 +503,14 @@ contract TokenGeyser is IStaking, Ownable {
503503

504504
/**
505505
* @dev Lets the owner rescue funds air-dropped to the staking pool.
506+
* @param _tokenToRescue Address of the token to be rescued.
507+
* @param to Address to which the rescued funds are to be sent.
508+
* @param amount Amount of tokens to be rescued.
509+
* @return Transfer success.
506510
*/
507511
function rescueFundsFromStakingPool(address _tokenToRescue, address to, uint256 amount)
508512
public onlyOwner returns (bool) {
509513

510-
return stakingPool.rescueFunds(_tokenToRescue, to, amount);
514+
return _stakingPool.rescueFunds(_tokenToRescue, to, amount);
511515
}
512516
}

test/staking.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,15 @@ describe('rescueFundsFromStakingPool', function () {
237237
const dist = await TokenGeyser.new(ampl.address, ampl.address, 10, startBonus, bonusPeriod,
238238
InitialSharesPerToken);
239239

240-
const stakingPool = await dist.stakingPool.call();
241-
242240
await ampl.approve(dist.address, $AMPL(100));
243241
await dist.stake($AMPL(100), []);
244242

243+
const transfers = await ampl.contract.getPastEvents('Transfer');
244+
const transferLog = transfers[transfers.length - 1];
245+
const stakingPool = transferLog.returnValues.to;
246+
247+
expect(await ampl.balanceOf.call(stakingPool)).to.be.bignumber.equal($AMPL(100));
248+
245249
const token = await MockERC20.new(1000);
246250
await token.transfer(stakingPool, 1000);
247251

@@ -255,6 +259,8 @@ describe('rescueFundsFromStakingPool', function () {
255259
dist.rescueFundsFromStakingPool(ampl.address, anotherAccount, $AMPL(10)),
256260
'TokenPool: Cannot claim token held by the contract'
257261
);
262+
263+
expect(await ampl.balanceOf.call(stakingPool)).to.be.bignumber.equal($AMPL(100));
258264
})
259265
});
260266
});

0 commit comments

Comments
 (0)