Closed code423n4 closed 1 year ago
A long position can't be opened while longOi is zero.
TriHaz marked the issue as sponsor disputed
Per disussion on #504 We are missing proof here as well
GalloDaSballo marked the issue as unsatisfactory: Insufficient proof
Lines of code
https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/Position.sol#L41-L65
Vulnerability details
Impact
The trade's accumulated interest may result smaller than expected when long open interest is zero.
Proof of Concept
https://github.com/code-423n4/2022-12-tigris/blob/0cb05a462e78c4470662e9d9a4f9ab587f266bb5/contracts/Position.sol#L41-L65
The
if
at line 47 in Position.sol is an and condition between the direction of the trade and the long open interest for the asset/tig asset pair, so if the long open interest is zero, theelse
branch at line 54 will be executed no matter what is the direction of the trade. As a result, the_pendingFunding
value will be nonzero and added to the_trade.accInterest
at line 62. Note that the inverse condition is not true, i.e. if direction is short and short open interest is zero then_pendingFunding
is zero.In conclusion if trade direction is true and long open interest is zero, the trade is losing interest because the calculated
_pendingFunding
for short open interest is then sign inverted and added to the_trade.accInterest
at line line 62.Tools Used
Manual review
Recommended Mitigation Steps
or