Tadle

Tadle
DeFiFoundry
27,750 USDC
View results
Submission Details
Severity: high
Invalid

Wrong boolean value is being parsed in the calculation of totalDepositAmount in `PreMarkets.sol#abortAskOffer`

Summary

In PreMarkets.sol#abortAskOffer, during the calculation of totalDepositAmount wrong value gets parsed

Vulnerability Details

PreMarkets.sol#abortAskOffer calculates totalDepositAmount by internally calling offerlibraries.sol#getDepositAmount()

...
uint256 totalDepositAmount = OfferLibraries.getDepositAmount(
offerInfo.offerType,
offerInfo.collateralRate,
totalUsedAmount,
false,
Math.Rounding.Ceil
...

it parses false boolean value to getDepositAmount

function getDepositAmount(
OfferType _offerType,
uint256 _collateralRate,
uint256 _amount,
bool _isMaker,
Math.Rounding _rounding
) internal pure returns (uint256) {
/// @dev bid offer
if (_offerType == OfferType.Bid && _isMaker) {
return _amount;
}
/// @dev ask order
if (_offerType == OfferType.Ask && !_isMaker) {
return _amount;
}
...

which as you can see represents whether the caller is from a maker or not and abortaskOffer is a function that can be called only by the maker which makes this value incorrect leading to wrong calculations being done.
This function's output is consumed by a refundAmountCheck

Impact

The incorrect refund amount will be calculated.

Tools Used

Manual review

Recommendations

uint256 totalDepositAmount = OfferLibraries.getDepositAmount(
offerInfo.offerType,
offerInfo.collateralRate,
totalUsedAmount,
- false,
+ true,
Math.Rounding.Ceil
);
Updates

Lead Judging Commences

0xnevi Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-PreMarkets-abortAskOffer-isMaker-false

Valid high severity, the `totalDepositAmount` of collateral computed from the amount of point used (posted to transact) should use the same isMaker flag as when computing the original collateral deposited by maker, if not, the amount available for withdrawal during abortion will be overestimated

Appeal created

0xnevi Lead Judge
about 1 year ago
0xnevi Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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