Code Monkey home page Code Monkey logo

dex's Introduction

DEX Smart Contract ๐ŸŒ

Welcome to the Decentralized Exchange (DEX) Smart Contract documentation! This comprehensive guide will take you through the features and functionalities of our DEX contract, empowering you to understand and utilize it effectively. Let's dive in! ๐Ÿš€

Table of Contents

Introduction

The DEX Smart Contract enables users to trade ERC20 tokens on a decentralized platform. It's designed to provide a secure, transparent, and efficient way to exchange tokens within the Ethereum ecosystem.

Enums and Structs

  • Side: Represents the side of the trade (BUY or SELL).
  • Token: Defines token information, including ticker and address.
  • Order: Represents a trading order with various attributes.

State Variables

  • tokens: A mapping of token tickers to token information.
  • tokenList: An array of available token tickers.
  • traderBalances: Tracks the token balances of traders.
  • orderBook: Stores the order book data.
  • admin: Address of the contract administrator.
  • nextOrderId: Auto-incrementing ID for orders.
  • nextTradeId: Auto-incrementing ID for trades.
  • DAI: Ticker for DAI token.

Events

  • NewTrade: Fired when a trade is executed.

Constructor

Initializes the contract and sets the admin address.

Functions

  • getOrders: Retrieves orders for a given token and side.
  • getTokens: Retrieves information about available tokens.
  • addToken: Allows the admin to add a new token.
  • deposit: Enables users to deposit tokens into their trading balance.
  • withdraw: Allows users to withdraw tokens from their balance.
  • createLimitOrder: Users can create limit orders for trading.
  • createMarketOrder: Users can create market orders for trading.

Modifiers

  • tokenIsNotDai: Prevents trading with DAI token.
  • tokenExist: Ensures the token exists in the exchange.
  • onlyAdmin: Restricts specific functions to the admin.

Usage Examples

  • Creating a Limit Order:

    createLimitOrder("ETH", 1, 2500, Side.BUY);
  • Depositing Tokens:

    deposit(100, "ETH");
  • Withdrawing Tokens:

    withdraw(50, "ETH");
  • Getting Orders:

    getOrders("ETH", Side.SELL);

Contributing

Contributions are welcome! If you find issues or have enhancements to propose, please open a pull request. Let's make the DEX Smart Contract even better together!

License

This project is licensed under the MIT License. Feel free to use and modify the contract according to the terms.


Explore our DEX Smart Contract, enhance your trading experience, and enjoy seamless token exchange within the Ethereum network. Happy trading! ๐Ÿ“ˆ๐ŸŒ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.