code-423n4 / 2021-04-marginswap-findings

1 stars 0 forks source link

Duplicated Code In Admin.viewCurrentMaintenanceStaker() #69

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

jvaqa

Vulnerability details

Duplicated Code In Admin.viewCurrentMaintenanceStaker()

Impact

There are four lines of code that are duplicated in viewCurrentMaintenanceStaker

Recommended Mitigation Steps

Change this:

if (maintenanceStakePerBlock > currentStake) { // skip staker = nextMaintenanceStaker[staker]; currentStake = getMaintenanceStakerStake(staker); } else { startBlock += currentStake / maintenanceStakePerBlock; staker = nextMaintenanceStaker[staker]; currentStake = getMaintenanceStakerStake(staker); }

To this:

if (maintenanceStakePerBlock <= currentStake) { startBlock += currentStake / maintenanceStakePerBlock; } staker = nextMaintenanceStaker[staker]; currentStake = getMaintenanceStakerStake(staker);