## Summary
The `PreMarkets::listOffer` function in the Solidity contract is intended to allow the listing of only "ask" offers for a given stock. However, there was an issue where the function mistakenly checked for "bid" offers instead, which could potentially lead to incorrect offers being listed.
## Vulnerability Details
The vulnerability is located in the withdraw function, defined as follows:
```javascript
/**
* @notice list offer
* @param _stock stock address
* @param _amount the amount of offer
* @param _collateralRate offer collateral rate
* @dev Only stock owner can list offer
* @dev Market place must be online
* @dev Only ask offer can be listed
*/
function listOffer(
address _stock,
uint256 _amount,
uint256 _collateralRate
) external payable {
.
.
.
if (stockInfo.stockType != StockType.Bid) {
revert InvalidStockType(StockType.Bid, stockInfo.stockType);
}
.
.
.
}
```
The function was originally designed to allow only "ask" offers to be listed. However, the code mistakenly checked for the "bid" offer type instead, which could result in an invalid type of offer being listed.
## Impact
```
@> Incorrect Offer Listings: The incorrect check for the "bid" type instead of "ask" could allow unintended offers to be listed, leading to potential business logic flaws and incorrect operations within the marketplace.
```
## Tools Used
- Manual code review
## Recommended Mitigation
To mitigate this vulnerability, modify the code to ensure that the function only allows "ask" offers to be listed. The corrected line should be:
```diff
function listOffer(
address _stock,
uint256 _amount,
uint256 _collateralRate
) external payable {
.
.
.
- if (stockInfo.stockType != StockType.Bid) {
- revert InvalidStockType(StockType.Bid, stockInfo.stockType);
- }
+ if (stockInfo.stockType != StockType.Ask) {
+ revert InvalidStockType(StockType.Ask, stockInfo.stockType);
+ }
.
.
.
}
```