The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: low
Invalid

Wrong handling of staked position

Summary

The function LiquidationPool::stake makes wrong calculation which can block holders.

Vulnerability Details

The stake function returns the smaller value of _position.TST and _position.EUROs.

function stake(Position memory _position) private pure returns (uint256) {
return _position.TST > _position.EUROs ? _position.EUROs : _position.TST;
}

This does not seem right, because if an user has deposited only TST and no EUROs, the function will return 0. This will affect the holder badly.

First lets take a look at LiquidityPool::getStakeTotal:

function getStakeTotal() private view returns (uint256 _stakes) {
for (uint256 i = 0; i < holders.length; i++) {
Position memory _position = positions[holders[i]];
_stakes += stake(_position);
}
}

We can see that this function is used to get to total amount of holder's stakes. Lets imagine he has only 1 position with 100 TST and 0 EUROs. The function will return 0, because stake() takes the smallest value.

Now lets look at LiquidationPool::distributeAssets, in particular this line:

uint256 _positionStake = stake(_position);

If again the current position has 100 TST and 0 EUROs, the following check will fail:

if (_positionStake > 0)

This means that the holder of the position will not receive rewards for this position as this line will never be reached:

rewards[abi.encodePacked(_position.holder, asset.token.symbol)] += _portion;

Impact

Wrong accounting of position will result in the holder receiving no rewards.

Tools Used

Manual Review

Recommendations

Adjust the stake function to consider both TST and EUROs in a position:

function stake(Position memory _position) private pure returns (uint256) {
- return _position.TST > _position.EUROs ? _position.EUROs : _position.TST;
+ return _position.TST + _position.EUROs;
}
Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

informational/invalid

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.