"position" function returns inaccurate values after "deletePendingStake" has been called at least once.
In "LiquidationPool.sol" the function "deletePendingStake":
shifts elements in the "pendingStakes" array when deleting a stake which causes the order of stakes in the array to change.
Lets look at the "position" function:
It retrieves information about the pending stakes of a holder by calling the function "holderPendingStakes".
"holderPendingStakes":
iterates over the "pendingStakes" array, assuming a certain order of stakes. If the order in the array has changed due to deletions, the function might not calculate correctly "_pendingTST" and "_pendingEUROs" for a given holder. This means that when updating "_position.EUROs" and "_position.TST", the function "position" will use inaccurate pending stakes data, leading to incorrect results in the final "_position" struct.
Users won't be able to see an accurate representation of their positions
manual review
Consider modifying "holderPendingStakes" to check each element in the "pendingStakes" array without assuming a specific order. One approach could be using a mapping to store pending stakes for each holder, allowing for efficient retrieval without relying on array order.
Or consider a different method for deleting pending stakes that doesn't change the order of the elements in the array. One way would be by swapping the stake to be deleted with the last element in the array and then popping the last element. Here is an example of how it could look:
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.