DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: low
Valid

indexToken should be swapped to collateralToken before Compound action

Summary

indexToken should be swapped to collateralToken before Compound action

Vulnerability Details

The Compound action is used to move idle funds in vault to deposit into GMX. These funds can either be from funding fees or adl/liquidation.

For positive funding fees, it will be collected in indexToken, and needs to be swapped to collateralToken before compounding.

https://github.com/CodeHawks-Contests/2025-02-gamma/blob/main/contracts/PerpetualVault.sol#L399

} else if (positionIsClosed == false && _isFundIdle()) {
@> flow = FLOW.COMPOUND;
if (_isLongOneLeverage(beenLong)) {
_runSwap(metadata, true, prices);
} else {
(uint256 acceptablePrice) = abi.decode(metadata[0], (uint256));
_createIncreasePosition(beenLong, acceptablePrice, prices);
}
}

Impact

Some funding fees will be left idle in PerpetualVault as indexToken.

Tools Used

N/A

Recommendations

Also perform the indexToken->collateralToken dex swap before the compound action.

Updates

Lead Judging Commences

n0kto Lead Judge 5 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding_compound_does_not_used_indexToken

Likelihood: Low/Medium, during FLOW.COMPOUND. Impact: Low, no use of the index tokens during a compound (funding fees, liquidation)

Appeal created

riceee Auditor
5 months ago
n0kto Lead Judge
4 months ago
n0kto Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding_compound_does_not_used_indexToken

Likelihood: Low/Medium, during FLOW.COMPOUND. Impact: Low, no use of the index tokens during a compound (funding fees, liquidation)

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.