Hi guys, when migrating my DEX contract which has 1 error which I don’t know how to fix as it underlines the last curly bracket of the contract brackets, and the terminal outputs
CompileError: ParserError: Function, variable, struct or modifier declaration expected.
--> project:/contracts/Dex.sol:76:2:
|
76 | }
| ^
Compilation failed. See above.
at C:\Users\maksd\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\compile-solidity\dist\run.js:64:1
at Generator.next (<anonymous>)
at fulfilled (C:\Users\maksd\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\compile-solidity\dist\run.js:4:43)
This is my contract code.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
import "../contracts/Wallet.sol";
contract Dex is Wallet {
using SafeMath for uint256;
enum Side {
BUY,
SELL
}
struct Order {
uint id;
address trader;
Side side;
bytes32 ticker;
uint quant;
uint price;
}
mapping(bytes32 => mapping(uint => Order[])) public OrderBook;
uint public nextOrderId = 0;
function getOrderBook(bytes32 ticker, Side side) public view returns(Order[] memory){
return OrderBook[ticker][uint(side)];
}
function createLimitOrder(Side side, bytes32 ticker, uint amount, uint price) public {
if(side == Side.BUY){
require(balances[msg.sender]["ETH"] >= amount.mul(price));
}
else if(side == Side.SELL){
require(balances[msg.sender][ticker] >= amount);
}
Order[] storage orders = orderBook[ticker][uint(side)];
orders.push(
Order(nextOrderId, msg.sender, side, ticker, amount, price)
);
uint i = orders.length > 0 ? orders.length -1 : 0;
if(side == Side.BUY){
while(i > 0){
if(orders[i - 1].price > orders[i].price){
break;
}
Orders memory orderToMove = orders[i-1];
orders[i-1] = orders[i];
orders[i] = orderToMove;
i--;
}
}
else if(side == Side.SELL){
while(i > 0){
if(orders[i - 1].price < orders[i].price){
break;
}
Orders memory orderToMove = orders[i-1];
orders[i-1] = orders[i];
orders[i] = orderToMove;
i--;
}
nextOrderId++;
}
}
Would appreciate it if anyone could help, thanks.