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.
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.
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.
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.
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.
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.
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.
The lack of length checks and dependencies on external factors might result in inefficiencies, unexpected behavior, or reliance on external services' correct functioning.
The analysis is based on manual code inspection, and findings are cross-checked with related test scripts.
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.
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.
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.
Role Assignment Carefully:
Assign the EUROs BURNER_ROLE
carefully, ensuring that only trusted entities have this permission to prevent potential misuse.
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.
Gas Efficiency Consideration:
Evaluate gas efficiency in critical functions, especially those that might be executed frequently, and optimize where necessary.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.