The afterLiquidationExecution()
function fails to update positionIsClosed
to true
after a position is fully liquidated. This results in the vault incorrectly assuming that a position is still active, leading to unexpected contract behavior, including preventing deposits, interfering with subsequent position openings, and causing logical inconsistencies in the vault's operation.
The afterLiquidationExecution()
function is triggered after a liquidation or automatic deleveraging (ADL) event. It performs the following key actions:
Ensures that only the GMX proxy can call it.
Pauses deposits after liquidation.
Retrieves the current position size (sizeInTokens
).
If sizeInTokens == 0
, it deletes the curPositionKey
, indicating that the position has been removed.
Updates the flow
state depending on whether it was previously in a NONE
, DEPOSIT
, or WITHDRAW
state.
positionIsClosed
is Never Set to true
The function correctly deletes curPositionKey
but fails to explicitly update positionIsClosed = true
.
This means the contract still assumes there is an active position when it has already been liquidated.
Incorrect Vault State
The vault may still believe a position is open after liquidation, leading to incorrect decision-making in other contract functions.
Deposits May Be Blocked Indefinitely
Functions that check positionIsClosed
before allowing deposits may prevent new deposits even when no position exists.
Withdrawals May Fail or Be Handled Incorrectly
Since the contract still thinks a position is open, it may attempt to close a non-existent position, leading to execution failures.
Inconsistent Contract Behavior
Functions that depend on accurate position tracking (e.g., compounding, withdrawals, or new position openings) may malfunction or revert unexpectedly.
Manual Code Review
positionIsClosed = true
After LiquidationModify afterLiquidationExecution()
to ensure positionIsClosed
is properly updated.
positionIsClosed
Before Allowing Certain ActionsEnsure other functions check positionIsClosed
before allowing deposits, withdrawals, or position openings.
Example Fix:
To improve off-chain tracking, emit an event to log the position’s closure.
Proposed Event:
Modify afterLiquidationExecution()
to emit the event:
"// keep the positionIsClosed value so that let the keeper be able to create an order again with the liquidated fund" Liquidation can send some remaining tokens. No real impact here.
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.