minor refactoring

This commit is contained in:
Samyak Jain 2021-06-13 17:00:49 +05:30
parent d72c1480f9
commit f37a543b81
2 changed files with 10 additions and 12 deletions

View File

@ -14,4 +14,11 @@ abstract contract Helpers is DSMath, Basic {
TokenInterface constant internal rewardToken = TokenInterface(address(0)); // TODO
function getStakingContract(address stakingToken) internal view returns (address) {
IStakingRewardsFactory.StakingRewardsInfo memory stakingRewardsInfo =
stakingRewardsFactory.stakingRewardsInfoByStakingToken(stakingToken);
return IStakingRewards(stakingRewardsInfo.stakingRewards);
}
}

View File

@ -30,10 +30,7 @@ contract Main is Helpers, Events {
) external payable returns (string memory _eventName, bytes memory _eventParam) {
uint _amt = getUint(getId, amt);
IStakingRewardsFactory.StakingRewardsInfo memory stakingRewardsInfo =
stakingRewardsFactory.stakingRewardsInfoByStakingToken(stakingToken);
IStakingRewards stakingContract = IStakingRewards(stakingRewardsInfo.stakingRewards);
IStakingRewards stakingContract = IStakingRewards(getStakingContract(stakingToken));
TokenInterface stakingTokenContract = TokenInterface(stakingToken);
_amt = _amt == uint(-1) ? stakingTokenContract.balanceOf(address(this)) : _amt;
@ -64,10 +61,7 @@ contract Main is Helpers, Events {
) external payable returns (string memory _eventName, bytes memory _eventParam) {
uint _amt = getUint(getId, amt);
IStakingRewardsFactory.StakingRewardsInfo memory stakingRewardsInfo =
stakingRewardsFactory.stakingRewardsInfoByStakingToken(stakingToken);
IStakingRewards stakingContract = IStakingRewards(stakingRewardsInfo.stakingRewards);
IStakingRewards stakingContract = IStakingRewards(getStakingContract(stakingToken));
_amt = _amt == uint(-1) ? stakingContract.balanceOf(address(this)) : _amt;
uint intialBal = rewardToken.balanceOf(address(this));
@ -94,10 +88,7 @@ contract Main is Helpers, Events {
address stakingToken,
uint setId
) external payable returns (string memory _eventName, bytes memory _eventParam) {
IStakingRewardsFactory.StakingRewardsInfo memory stakingRewardsInfo =
stakingRewardsFactory.stakingRewardsInfoByStakingToken(stakingToken);
IStakingRewards stakingContract = IStakingRewards(stakingRewardsInfo.stakingRewards);
IStakingRewards stakingContract = IStakingRewards(getStakingContract(stakingToken));
uint intialBal = rewardToken.balanceOf(address(this));
stakingContract.getReward();