Name - BRIHAT
Symbol - BRT
This is a decentralized exchange (DEX) smart contract written in Solidity. It allows users to buy and sell tokens at different prices determined by the contract owner.
Solidity ^0.8.0
IERC20 contract interface
This project is licensed under the terms of the GPL-3.0 license. See the LICENSE file for more information.
Users can sell tokens at a desired price.
The contract maintains a list of best prices in increasing order.
Each price in the list is mapped to the address of the seller offering that price.
Users can buy tokens at the best available price.
QuickSort algorithm is used to sort the list of prices.
Clone the repository.
Install Solidity compiler.
Import the IERC20 contract.
Deploy the DEX contract with the following parameters:
_token: The address of the ERC20 token contract.
_price: The initial price set by the owner.
getBalance(address _add): Returns the token balance of the specified address.
sell(uint _tokens, uint _price): Allows a user to sell tokens at the desired price.
getBestPrice(uint _tokens): Returns the best available price for buying the specified number of tokens.
buy(uint _tokens): Allows a user to buy tokens at the best available price.
onlyOwner: Ensures that a function can only be called by the contract owner.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the terms of the GPL-3.0 license. See the LICENSE file for more information.