Skip to content

Commit

Permalink
docs: create xdc documents
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Mar 24, 2023
1 parent 274c80b commit 114492e
Show file tree
Hide file tree
Showing 8 changed files with 1,188 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# User guide for xdc

## Original README

Here is [the original README.md](../README.original.md).

## Documents for xdc

- [Fresh install](./install.md)
- [Upgrade old version](./upgrade.md)
- [Run hummingbot](./run.md)
- [Setup test enviroment](./setup-test-enviroment.md)
- [Test xdc chain](./test-xdc-chain.md)
- [Test xsswap exchange](./test-xsswap.md)
- [Test globiance exchange](./test-globiance.md)
123 changes: 123 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Install hummingbot

## 1. Environment

- OS: Ubuntu 22.04
- hummingbot: v1.13.0

## 2. Install dependencies

```shell
sudo apt update -y
sudo apt install -y build-essential curl git httpie jq wget
```

## 3. Install Miniconda3

```shell
cd ${HOME}
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh -b -u
./miniconda3/bin/conda init
# Reload .bashrc to register "conda" command
exec bash
conda install -y conda-build
```

## 4. Install client

### 4.1 Install client

```shell
cd ${HOME}
git clone https://github.com/Carry-So/hummingbot.git
cd hummingbot
git checkout xdc-release-1.13.0
./clean
./install
conda activate hummingbot
./compile
```

### 4.2 Start client

Start hummingbot by run command:

```shell
cd ${HOME}/hummingbot
bin/hummingbot.py
```

Setup your password when first login, refer to https://docs.hummingbot.org/operation/password/#creating-a-password.

### 4.3 generate certificates

Then run command `gateway generate-certs` in the input panel to generate self-signed certificates, refer to https://docs.hummingbot.org/gateway/installation/#generate-certs.

![096258ea4fc1c15ad154e99d7365ea9](https://user-images.githubusercontent.com/7695325/226868318-0188180e-0515-4a37-b919-1e14f84df693.png)

## 5. Install gateway

### 5.1 Install gateway

```shell
cd ${HOME}
git clone https://github.com/Carry-So/hummingbot-gateway.git
cd hummingbot-gateway
git checkout xdc-release-1.13.0

# Install dependencies
yarn

# Complile Typescript into Javascript
yarn build
```

### 5.2 Setup gateway

Run Gateway setup script, which helps you set configs and certificates:

```shell
cd ${HOME}/hummingbot
./gateway-setup.sh
```

Below is the interactive process:

```text
=============== SETUP GATEWAY ===============
Enter path to the Hummingbot certs folder >>> /home/liudan/hummingbot/certs
Confirm if this is correct:
Copy configs FROM: /home/liudan/hummingbot-gateway/src/templates
Copy configs TO: /home/liudan/hummingbot-gateway/conf
Copy certs FROM: /home/liudan/hummingbot/certs
Copy certs TO: /home/liudan/hummingbot-gateway/certs
Do you want to proceed? [Y/N] >>> Y
Files successfully copied from /home/liudan/hummingbot-gateway/src/templates to /home/liudan/hummingbot-gateway/conf
Files successfully copied from /home/liudan/hummingbot/certs to /home/liudan/hummingbot-gateway/certs
```

### 5.3 Start gateway

Start gateway using passphrase:

```shell
cd ${HOME}/hummingbot-gateway
# yarn start --passphrase=daniel
yarn start --passphrase=<passphrase>
```

### 5.4 Test connection

The client should show: `Gateway: ONLINE` on the top of log pane(right) now. Run the command `gateway test-connection` in Hummingbot to test the connection. Now, you can type command `exit` in client to quit now. When you exit and restart client, it should automatically detect whether gateway is running and connect to it.

![1679479291584](https://user-images.githubusercontent.com/7695325/226868564-5a05c170-f142-4768-93f8-f7f545887213.png)
29 changes: 29 additions & 0 deletions docs/run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Run hummingbot

## 1. Start gateway

Run the following commands to start gateway:

```shell
cd ${HOME}/hummingbot-gateway
# yarn start --passphrase=daniel
yarn start --passphrase=<passphrase>
```

![1679479660200](https://user-images.githubusercontent.com/7695325/226870035-f060c2d7-bd1b-4d9c-9622-2344c37b48cf.png)

## 2. Start client

Run the following commands to start client:

```shell
cd ${HOME}/hummingbot
conda activate hummingbot
bin/hummingbot.py
```

## 3. Connect xsswap

Run the command `gateway connect xsswap` in client.

![1679640895282](https://user-images.githubusercontent.com/7695325/227447487-5f736dc6-85d6-41e0-807f-e644bffe1e31.png)
73 changes: 73 additions & 0 deletions docs/setup-test-enviroment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Setup test enviroment

## 1. Install dependent packages

```shell
sudo apt update
sudo apt install -y curl httpie jq
```

![1679628520407](https://user-images.githubusercontent.com/7695325/227417028-79ae7b2b-aca3-4d25-aa09-73749e8bba32.png)

The httpie is recommended to send https request in our test cases. You can use curl also.

## 2. Set environment variables

Set the following environment variables:

```shell
# address of gateway, maybe different in your environment
export SERVER="https://127.0.0.1:15888"

# POST command use JSON format
export HEADER="Content-Type: application/json"

# public key of test account, replace it with your account
export ETH_ADDRESS="0xD4CE02705041F04135f1949Bc835c1Fe0885513c"
export XDC_ADDRESS="xdcD4CE02705041F04135f1949Bc835c1Fe0885513c"

# path of certs
CERTS_PATH="${HOME}/hummingbot/certs"
export GATEWAY_CERT="${CERTS_PATH}/client_cert.pem"
export GATEWAY_KEY="${CERTS_PATH}/client_key.pem"
```

![1679627883880](https://user-images.githubusercontent.com/7695325/227415681-e8386105-76c7-44a1-825c-b0cf83fd319d.png)

## 3. Config httpie

Remember to delete this file after test.

```shell
mkdir -p ${HOME}/.config/httpie

cat > ${HOME}/.config/httpie/config.json <<EOF
{
"default_options": [
"--verify=no",
"--cert=${GATEWAY_CERT}",
"--cert-key=${GATEWAY_KEY}"
]
}
EOF

# check file content
cat ${HOME}/.config/httpie/config.json
```

![1679627737884](https://user-images.githubusercontent.com/7695325/227415370-c8e6476e-cf45-4448-90be-dbeca4be19e1.png)

![1679627793913](https://user-images.githubusercontent.com/7695325/227415471-ab024c88-7320-4732-9666-c22260dc8223.png)

## 4. Mint tokens

- I created some test tokens on apothem blockchain with [factory contract 0xfD9F33ab143b1717D4784A420eE5A93A8CbBcABd](https://explorer.apothem.network/address/xdcfD9F33ab143b1717D4784A420eE5A93A8CbBcABd#readContract). Pleas mint enough test tokes to your test account on blockchain explorer.

| Token | Decimals | Link |
| ----: | -------: | :---------------------------------------------------------------------------------------------------------------------------------------------- |
| WBTC2 | 8 | [0x01B0500f82EF188D0410a46f2E8940133E213e83](https://explorer.apothem.network/address/xdc01b0500f82ef188d0410a46f2e8940133e213e83#readContract) |
| YFI2 | 18 | [0x22e4Eb82FF59c53B275aDEacd4EE4Bc47fc4f16d](https://explorer.apothem.network/address/xdc22e4Eb82FF59c53B275aDEacd4EE4Bc47fc4f16d#readContract) |
| MKR2 | 18 | [0x258E445fEf3F41429e38ee124DA63aBfb08edc70](https://explorer.apothem.network/address/xdc258E445fEf3F41429e38ee124DA63aBfb08edc70#readContract) |
| AAVE2 | 18 | [0x3042207876c47D3c206df99b3279d97813B34Ea1](https://explorer.apothem.network/address/xdc3042207876c47D3c206df99b3279d97813B34Ea1#readContract) |
| UNI2 | 18 | [0xD9e33607d06cBB1Fef59488b9969426b10F310B8](https://explorer.apothem.network/address/xdcD9e33607d06cBB1Fef59488b9969426b10F310B8#readContract) |
| USDC2 | 6 | [0xF83B9Dc502A3F76c042b4043B6C1B5eBBE574389](https://explorer.apothem.network/address/xdcF83B9Dc502A3F76c042b4043B6C1B5eBBE574389#readContract) |
Loading

0 comments on commit 114492e

Please sign in to comment.