Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atharv - Incorrect Handling of Base Pool Caps in Superpool.sol Could Lead to Suboptimal Fund Distribution. #538

Closed
sherlock-admin2 opened this issue Aug 24, 2024 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A Medium severity issue. Reward A payout will be made for this issue

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Aug 24, 2024

Atharv

High

Incorrect Handling of Base Pool Caps in Superpool.sol Could Lead to Suboptimal Fund Distribution.

Summary

In the Superpool.sol contract, the current implementation of the deposit() function and its sub-functions may lead to suboptimal fund distribution across the base pools. Specifically, the method for checking and handling the base pool cap is flawed, potentially leaving some base pools underfunded even when they have available capacity.

Vulnerability Detail

The deposit() function in Superpool.sol handles user deposits and distributes them across various base pools using the _deposit() and _supplyToPools() functions. This function goes through depositQueue and deposits into each pool. During this process, the code calculates how much can be deposited into each base pool by considering the cap of the pool(poolCapFor) and the current total assets within it.

However, the current implementation doesn't properly handle the scenario where a base pool has not reached its cap. If the amount to be supplied (supplyAmt) exceeds the available capacity of a base pool (i.e., basepoolCap - total assets in the pool), the deposit is skipped entirely for that pool. This can lead to an inefficient distribution of funds, as the pool still has available capacity that could have been utilized.

If supplyAmt > basepoolCap - total assets in the pool we are not transferring the amount to that pool and going for next but we can transfer the basepoolCap - total assets in the pool amount.

Impact

This vulnerability cannot distribute funds to the basePools according to strategies leading to earn less interest and hence loss of rewards/interest for the lenders. Breaks the logic of depositQueue ordering.

Code Snippet

https://github.com/sherlock-audit/2024-08-sentiment-v2/blob/main/protocol-v2/src/SuperPool.sol#L524

Tool used

Manual Review

Recommendation

Add the condition in _supplyToPools() function

if (supplyAmt > basepoolCap - total assets in the basepool) {
    supplyAmt = basepoolCap - total assets in that base pool
}

Duplicate of #178

@github-actions github-actions bot closed this as completed Sep 5, 2024
@github-actions github-actions bot added Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A Medium severity issue. labels Sep 5, 2024
@sherlock-admin4 sherlock-admin4 changed the title Small Wool Squid - Incorrect Handling of Base Pool Caps in Superpool.sol Could Lead to Suboptimal Fund Distribution. Atharv - Incorrect Handling of Base Pool Caps in Superpool.sol Could Lead to Suboptimal Fund Distribution. Sep 15, 2024
@sherlock-admin4 sherlock-admin4 added the Reward A payout will be made for this issue label Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A Medium severity issue. Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

2 participants