The contract allows sellers to set any price, which could lead to market manipulation by setting extremely low or high prices, potentially for sandwich attacks or other manipulative strategies.
1. Market Manipulation: Sellers can set misleading prices to exploit other users or the market.
2. Loss of Trust: If users see wild price discrepancies, they might question the reliability of the platform.
3. Ecosystem Health: Such manipulations could destabilize the token economy around NFTs on the platform, deterring new users and reducing liquidity.
Implement price sanity checks using an oracle or historical data:
Code Snippet:
```solidity
function sellErc20(address nftPegged, uint256 price, uint256 amount) external {
// ... existing checks ...
require(price > getMinPrice(nftPegged) && price < getMaxPrice(nftPegged), "Price out of acceptable range");
// ... rest of the function ...
}
function getMinPrice(address nft) internal view returns (uint256) {
// Example logic, could be integrated with an oracle or historical data
return 1 ether; // Minimum price, for example
}
function getMaxPrice(address nft) internal view returns (uint256) {
// Example logic, could be integrated with an oracle or historical data
return 1000 ether; // Maximum price, for example
}
```