The Standard

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

Bugs and Improvements in LiquidationPool Smart Contract

Summary

The LiquidationPool smart contract appears to have certain vulnerabilities and areas for improvement based on the analysis of the provided code and related test scripts.

Vulnerability Details

  1. No Length Check for Number of Stakeholders:

The contract doesn't perform a length check for the array of stakeholders (holders). This could lead to inefficiencies or even out-of-gas errors if the array becomes too large.

  1. TokenManager.getAcceptedTokens Array Length Unchecked:

While it's noted that the TokenManager.getAcceptedTokens array length is unchecked, this is considered acceptable given the administrative control over the TokenManager contract, which is expected to have a manageable number of items.

  1. Position Function Dependency on getTstTotal:

The position function depends on getTstTotal not being zero. However, if a user's position has TST, getTstTotal will always be greater than zero, potentially leading to unexpected behavior.

  1. distributeFees Function Requires EUROs Approval:

The distributeFees function requires EUROs to be approved beforehand. However, the LiquidationPoolManager approves the amount before calling the function, making the approval in distributeFees redundant.

  1. distributeAssets Function Dependencies:

The distributeAssets function has multiple dependencies, including Chainlink's EUR/USD, accurate Token/USD prices, and a non-zero collateralRate. This makes the contract highly dependent on external factors.

  1. EUROs Burner Role Permission:

The LiquidationPool requires the EUROs BURNER_ROLE permission, which is a crucial function. However, this role should be assigned carefully, considering potential security risks.

Impact

The lack of length checks and dependencies on external factors might result in inefficiencies, unexpected behavior, or reliance on external services' correct functioning.

Tools Used

The analysis is based on manual code inspection, and findings are cross-checked with related test scripts.

Recommendations

  1. Stakeholders Array Length Check:

Implement a length check for the holders array to prevent potential out-of-gas issues in scenarios with a large number of stakeholders.

  1. Dynamic Dependency Resolution:

Consider making the contract more robust by dynamically resolving dependencies, especially in functions like distributeAssets. This could involve fallback mechanisms or handling cases where external services might not return expected results.

  1. Documentation:

Clearly document the external dependencies and assumptions in the contract. Users and developers should be aware of the factors that might affect the contract's behavior.

  1. Role Assignment Carefully:

Assign the EUROs BURNER_ROLE carefully, ensuring that only trusted entities have this permission to prevent potential misuse.

  1. Test Scenarios with External Failures:

Enhance test scenarios to include cases where external services fail or return unexpected results to ensure the contract handles such situations gracefully.

  1. Gas Efficiency Consideration:

Evaluate gas efficiency in critical functions, especially those that might be executed frequently, and optimize where necessary.

Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

informational/invalid

Support

FAQs

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