L01-
PERFORMUPKEEP IN THE LIQUIDATION FUNCTION FAILS TO DECODE THE ADDRESS OF THE CONTRACT AND VERIFY ACCORDING
Summary
The `performUpkeep` function is currently not properly verifying the `performData` input. This function has been restricted by the `onlyForwarder` modifier, but the data within `performData` is not validated, leading to potential risks. To mitigate this, the `performData` should be decoded and validated to ensure it originates from the correct source.
Based on the IAutomation interface-
Contracts are always advised to verify the data passed. Line 11 Always validate the data passed in.
But based on current implementation these data are not verfied
But when we use this data we fail to return address(this) and validate
This issue is classified as low severity due to the `onlyForwarder` restriction. However, failing to validate `performData` can still introduce potential risks, such as executing unintended liquidations.
- Solidity code analysis
- Review of the Chainlink Automation (Keepers) documentation
1. **Validate `performData`**: Decode `performData` and verify that it includes expected values, such as the correct contract address.
2. **Update `performUpkeep` Logic**: Modify the `performUpkeep` function to validate the decoded data before proceeding with any actions.
L02-
Nonce Management for Take Profit/Stop Limit Orders: Automation Required
Summary
The current system relies on users to manually increase the nonce when placing Take Profit (TP) or Stop Limit (SL) orders. According to the developer's intention, the nonce should be increased automatically when TP/SL are being filled. This report outlines the necessity for automating nonce increments for TP/SL orders to ensure seamless order execution.
Nonce management is crucial in trading systems to ensure the correct sequence of order execution. A nonce is a unique number that increases with each order to prevent replay attacks and ensure that newer orders invalidate older ones. However, the current implementation requires users to manually increase the nonce for TP/SL orders, which can lead to the following issues:
1. **User Dependency**: Relying on users to manually increase the nonce introduces the risk of human error. Users may forget or incorrectly set the nonce, leading to unintended order executions.
2. **Inconsistent Order Execution**: If the nonce is not increased, older limit orders may still be filled/ although the structhash adds a added layer of protection to handle this, thus no issue here.
3. **Developer's Intent**: The developer's comments indicate that the nonce should be increased for every TP/SL order to prevent older limit orders from being filled. This should be automated to align with the intended functionality.
**Code Snippet and Practical Example:**
In the current implementation, the increaseNonce function should be called automatically whenever a TP/SL order is placed. This ensures that the nonce is correctly incremented, maintaining the correct order sequence.
Ensuring that nonce management is automated for these orders is crucial based on developer's intension.
- Manual Solidity code analysis
Modify the order placement logic to include an automatic nonce increment for TP/SL orders:
Check if an order reduces a position if it does we should increment nonce.
L03-
Discrepancies in Long and Short Open Interest Calculation
This report addresses a discrepancy in the calculation of long and short open interest in the market. The current implementation may result in incorrect values for short open interest due to inconsistent handling of negative values, leading to potential inaccuracies in the display of open interest data.
The function `getOpenInterest` calculates the long and short open interest for a given market. It involves computing the half skew, half open interest, and then deriving the long and short open interests. However, there is an inconsistency in how negative values are handled for long and short open interest.
**Code Snippet:**
**Explanation:**
1. **Long Open Interest Calculation:**
- If `halfOpenInterest.add(halfSkew)` is less than zero, `longsOpenInterest` is set to zero.
- Otherwise, it is set to the calculated value.
2. **Short Open Interest Calculation:**
- Here, the calculation involves taking the absolute value, which can lead to non-zero values even when the input is positive already.
**Issue:**
- There is an inconsistency: when `halfOpenInterest.add(halfSkew)` is negative for long open interest, it is set to zero. However, for short open interest, the absolute value is taken, potentially resulting in incorrect values for values that are already positive.
The incorrect calculation of short open interest can lead to inaccurate data representation, which can mislead users and traders about the market conditions. This discrepancy can affect decision-making and risk assessment.
- Solidity code analysis
- Mathematical verification
1. **Consistent Handling of positive Values for short open interest:**
**Proposed Solution:**
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.