Giter Site home page Giter Site logo

gex-smartcontract's Introduction

Glitch Decentralized Exchange - GEX

This repo includes core and peripheral contracts of the GEX.

Note

Please make sure that FEE_TO and FEE_TO_SETTER is an Externally Owned Account or a Multisig Account that support receiving the native token and be able to call abitrary smart contract methods:

  • The FEE_TO_SETTER is used to change the FEE_TO address.
  • The FEE_TO is the address that receives the protocol fee and also be used to collect dust native token (if any). (Due to the minimum transferring constant of the blockchain protocol, dust native token is locked in the router contract instead of sending back to the liquidity prodiver)

Requirements

  • node >= v14.

Install Dependencies

npm i

Compile Contracts

npm run compile

Deploy Contracts

To deploy the contracts, follow the steps below:

  1. Set up the .env file in the following format:
RPC_TESTNET=http://fullnodes-testnet-1.glitch.finance:9933
RPC_MAINNET=http://fullnodes-mainnet-1.glitch.finance:9933

PRIVATE_KEY=0x1f354d8b016d39...6a91ec894f4d14ff9075e45

FEE_TO="0x3DBC4548b4...650f3790F54481C1"
FEE_TO_SETTER="0x3DBC4548b4...650f3790F54481C1"
  • PRIVATE_KEY: The private key of the owner used for deploying the contracts.
  • FEE_TO_SETTER: The address used for configuring the fee recipient address for the protocol.
  • FEE_TO: The address used for receiving the protocol fee.
  1. Deploy the Factory contract first by running the command:
  • On testnet,
npm run deploy_factory:testnet
  • On mainnet,
npm run deploy_factory:mainnet
  • Output:
Deploying on chain ID: 43113
Deployer 0x3DBC4548b4194Ae95Ef212BB650f3790F54481C1 has balance: 3.013260121381803298

Deploying Factory contract with params:
+ feeToSetter: 0x3DBC4548b4194Ae95Ef212BB650f3790F54481C1
Factory deployed at: 0x85e36756E03f6bE7d0549F0484d43E2c92dE8c69

Setting feeTo...
+ feeTo: 0x3DBC4548b4194Ae95Ef212BB650f3790F54481C1
Set feeTo at: 0xa0c36761bd4694ffefde5e2b9c8f35fa18690e402a5c95c4c570c241c98108f3

NOTE: You must replace the default INIT_CODE_PAIR_HASH and re-compile before deploying the GEXRouter contract.
Copy 9b7a234513ebe38e9cf4936e1ce93720699a9e264ca502e2299f6c9f0a028d45 to line 38 in contracts/libraries/GEXLibrary.sol file
Then, run: npx run compile
DONE
  1. Copy the INIT_CODE_PAIR_HASH (from the above output) and paste it on line 38 in the contracts/libraries/GEXLibrary.sol file.
  • Once done, re-compile the contracts by running the command:
npm run compile
  1. Finally, deploy the Router contract and other contracts by running the following command:
  • On testnet,
npm run deploy_router:testnet
  • On mainnet,
npm run deploy_router:mainnet
  • Output:
Deploying on chain ID: 43113
Deployer 0x3DBC4548b4194Ae95Ef212BB650f3790F54481C1 has balance: 2.934922371381803298

wGLCH deploying...
wGLCH deployed at: 0xA1e499e7386308d8C12Cc406b9C62866Cc8998Be

GEXRouter01 deploying...
GEXRouter01 deployed at: 0xe2b46b6e483d1Dd422E108fE7eE5D80D5d61EA34

Multicall deploying...
Multicall deployed at: 0xA3e16EDE9d0D54400D58e3cF6266D67059F55Cb5
DONE
  1. All deployment outcomes can be found in the scripts/output/{{network}}.json file.
  • For example, scripts/output/mainnet.json
{
  "GEXFactory": {
    "address": "0x85e36756E03f6bE7d0549F0484d43E2c92dE8c69",
    "vars": {
      "INIT_CODE_PAIR_HASH": "0x9b7a234513ebe38e9cf4936e1ce93720699a9e264ca502e2299f6c9f0a028d45",
      "feeTo": "0x3DBC4548b4194Ae95Ef212BB650f3790F54481C1",
      "feeToSetter": "0x3DBC4548b4194Ae95Ef212BB650f3790F54481C1"
    }
  },
  "GEXRouter01": {
    "address": "0xe2b46b6e483d1Dd422E108fE7eE5D80D5d61EA34",
    "vars": {
      "factory": "0x85e36756E03f6bE7d0549F0484d43E2c92dE8c69",
      "WGLCH": "0xA1e499e7386308d8C12Cc406b9C62866Cc8998Be"
    }
  },
  "Multicall": {
    "address": "0xA3e16EDE9d0D54400D58e3cF6266D67059F55Cb5"
  }
}

gex-smartcontract's People

Contributors

quocphu avatar

Watchers

 avatar

Forkers

jpduvenhage

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.