Closed sherlock-admin2 closed 9 months ago
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid
Invalid, no issue here, oldCreditor
is first cached with the original creditor before replacement as seen here
Topmark
medium
Wrong Implementation in the openMarginAccount Function
Summary
Wrong Implementation in the openMarginAccount Function of the AccountV1 contract as New MarginAccount is Opened before closing new One instead of the other way round
Vulnerability Detail
The code provided above shows how openMarginAccount(...) function is implemented, as pointed out in the pointer above the Protocol Opned a new MarginAccount before closing the old MarginAccount, this could cause problem for the protocol due to clashing of variable state values between the old data and the new data, before A new Margin would be opened the old one should be closed first to avoid counter interactions
Impact
Wrong Implementation in the openMarginAccount Function of the AccountV1 contract as New MarginAccount is Opened before closing new One instead of the other way round
Code Snippet
https://github.com/sherlock-audit/2023-12-arcadia/blob/main/accounts-v2/src/accounts/AccountV1.sol#L337-L344
Tool used
Manual Review
Recommendation
Protocol should make necessary adjustments to ensure a new openMarginAccount is only opened after the old one has been closed