The ParaSwapUtils._validateCallData()
function attempts to validate the receiver address from Paraswap's simpleSwap()
calldata, but incorrectly reads expectedAmount
instead. This causes all validation checks to fail since it compares a uint256 value (implicitly cast to address) with address(this)
, effectively blocking all Paraswap operations in the PerpetualVault contract.
The _validateCallData()
function attempts to validate the calldata by checking if the receiver matches address(this)
:
The SimpleData struct layout shows that offset 196 actually points to expectedAmount
:
Two critical issues:
The SimpleData struct doesn't contain a receiver field
The function reads expectedAmount
(a uint256) and implicitly casts it to address before comparison
The probability of a uint256 value matching address(this)
is practically zero.
This validation error causes a complete denial of service for all Paraswap operations in the PerpetualVault contract. Users cannot perform deposits or withdrawals that require token swaps through Paraswap, as all such transactions will revert at the validation step. This effectively breaks core functionality of the protocol when Paraswap integration is needed.
Manual Review
Remove the receiver validation since SimpleData doesn't contain such a field. If additional validation is required, it should be based on actual fields in the SimpleData struct:
If receiver validation is deemed necessary, ensure proper documentation of the receiver's location in the calldata and verify that the validation logic aligns with Paraswap's actual implementation.
Keepers use megaSwap with this struct: struct MegaSwapSellData { address fromToken; uint256 fromAmount; uint256 toAmount; uint256 expectedAmount; address payable beneficiary; Utils.MegaSwapPath[] path; address payable partner; uint256 feePercent; bytes permit; uint256 deadline; bytes16 uuid; } 32 first bytes of callData bytes array → length of the bytes array. 4 bytes selector, 32 bytes → offset of the struct → 68 bytes before the fromToken.
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.