Skip to content
This repository was archived by the owner on Feb 25, 2023. It is now read-only.

Commit a85e2f3

Browse files
authored
Merge pull request #27 from CoinAlpha/development
release / v0.2.0 sync dev => master
2 parents 998b6c6 + 5559189 commit a85e2f3

26 files changed

+3507
-366
lines changed

.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ npm-debug.log
66
*.env
77
*.env.*
88
# except the example .env.example
9-
!.env.example
9+
!.env.example
10+
11+
# Gateway API files
12+
*.pem

.env.example

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,48 @@
1-
# Configuration file
2-
31
APPNAME=Hummingbot Gateway API
42
NODE_ENV=dev
53
PORT=5000
6-
PROTOCOLS=["celo", "terra", "balancer", "eth"]
74

85
# use only if ip whitelist is required for local or docker instance
96
# note that docker instance does not use 127.0.0.1 address
107
# ipv6 format for locahost ["::ffff:127.0.0.1", "::ffff:1", "fe80::1", "::1"]
118
IP_WHITELIST=
129

10+
HUMMINGBOT_INSTANCE_ID={client_id}
11+
1312
# Celo
1413

1514
# Terra
16-
TERRA_LCD_URL=https://tequila-lcd.terra.dev
17-
TERRA_CHAIN=tequila-0004
18-
19-
# Balancer
20-
# - network: mainnet, kovan, etc
15+
# - mainnet: https://lcd.terra.dev
16+
# - mainnet chain: columbus-4
17+
# - testnet: https://tequila-lcd.terra.dev
18+
# - testnet chain: tequila-0004
19+
TERRA_LCD_URL={testnet_lcd_url}
20+
TERRA_CHAIN={testnet_chain_id}
21+
22+
# Ethereum
23+
# - chain: mainnet, kovan, etc
2124
# - rpc url: infura or other rpc url
22-
BALANCER_NETWORK={network}
23-
ETHEREUM_RPC_URL=https://{network}.infura.io/v3/{api_key}
25+
ETHEREUM_CHAIN={chain}
26+
ETHEREUM_RPC_URL=https://{chain}.infura.io/v3/{api_key}
2427

25-
# subgraph_network:
28+
# Balancer
29+
# subgraph_chain
2630
# Reference: https://docs.balancer.finance/sor/development#subgraph
2731
# - mainnet: balancer
2832
# - kovan: balancer-kovan
2933
# Note: REACT_APP_SUBGRAPH_URL used by @balancer-labs/sor
30-
REACT_APP_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/balancer-labs/{subgraph_network}
34+
REACT_APP_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/balancer-labs/{subgraph_chain}
3135

3236
# exchange_proxy:
3337
# Reference: https://docs.balancer.finance/smart-contracts/addresses
34-
# - kovan: 0x4e67bf5bD28Dd4b570FBAFe11D0633eCbA2754Ec
3538
# - mainnet: 0x3E66B66Fd1d0b02fDa6C811Da9E0547970DB2f21
39+
# - kovan: 0x4e67bf5bD28Dd4b570FBAFe11D0633eCbA2754Ec
3640
EXCHANGE_PROXY={exchange_proxy}
3741

42+
# Uniswap
43+
# Reference: https://uniswap.org/docs/v2/smart-contracts/router02/
44+
UNISWAP_ROUTER=0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
45+
3846
# cert
3947
CERT_PATH={full_path_to_certs_folder}
4048
CERT_PASSPHRASE={passphrase}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ npm-debug.log
2121
dist/
2222

2323
# cert
24-
certs/
2524
*.pem
2625
*.srl
2726
*.key

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM node:10.22.0-alpine
22

3+
# Set labels
4+
LABEL application="gateway-api"
5+
36
# app directory
47
WORKDIR /usr/src/app
58

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ We created hummingbot to promote **decentralized market-making**: enabling membe
1818

1919
### Install Hummingbot
2020

21-
- [Installation](https://docs.hummingbot.io/installation/overview/)
21+
- [Quickstart guide](https://docs.hummingbot.io/quickstart/)
22+
- [All installation options](https://docs.hummingbot.io/installation/overview/)
2223

2324
### Get support
2425
- Chat with our support team on [Discord](https://discord.hummingbot.io)

certs/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
certs dir
1+
certs dir for local testing only

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"test": "echo \"Error: no test specified\" && exit 1"
1313
},
1414
"dependencies": {
15+
"@uniswap/sdk": "^3.0.3",
1516
"@balancer-labs/sor": "^0.3.3",
1617
"@terra-money/terra.js": "^0.5.8",
1718
"bignumber.js": "^9.0.0",

setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This can be used as a common API server to handle transactions that requires cus
99
## Development Requirements
1010

1111
- NodeJS
12-
- Tested on Node v10.22.0
12+
- Tested on Node v10.22.1
1313
- https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
1414

1515
```bash

src/app.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import bodyParser from 'body-parser'
33
import express from 'express'
44
import helmet from 'helmet'
55
import { statusMessages } from './services/utils';
6+
import { validateAccess } from './services/access';
67
import { IpFilter } from 'express-ipfilter'
78

89
// Routes
@@ -11,6 +12,7 @@ import balancerRoutes from './routes/balancer.route'
1112
// import celoRoutes from './routes/celo.route'
1213
import ethRoutes from './routes/eth.route'
1314
import terraRoutes from './routes/terra.route'
15+
import uniswapRoutes from './routes/uniswap.route'
1416

1517
// terminate if environment not found
1618
const result = dotenv.config();
@@ -34,22 +36,18 @@ if (ipWhitelist) {
3436
app.use(bodyParser.json());
3537
app.use(bodyParser.urlencoded({ extended: true }));
3638

39+
app.use(validateAccess)
40+
3741
// mount all routes to this path
38-
app.use('/api', apiRoutes);
39-
app.use('/eth', ethRoutes);
40-
// app.use('/celo', celoRoutes);
41-
app.use('/terra', terraRoutes);
42-
app.use('/balancer', balancerRoutes);
42+
app.use('/uniswap', validateAccess, uniswapRoutes);
43+
app.use('/api', validateAccess, apiRoutes);
44+
app.use('/eth', validateAccess, ethRoutes);
45+
// app.use('/celo', validateAccess, celoRoutes);
46+
app.use('/terra', validateAccess, terraRoutes);
47+
app.use('/balancer', validateAccess, balancerRoutes);
4348

4449
app.get('/', (req, res, next) => {
45-
const cert = req.connection.getPeerCertificate()
46-
if (req.client.authorized) {
47-
next()
48-
} else if (cert.subject) {
49-
res.status(403).send({ error: statusMessages.ssl_cert_invalid })
50-
} else {
51-
res.status(401).send({ error: statusMessages.ssl_cert_required })
52-
}
50+
res.send('ok')
5351
})
5452

5553
/**

src/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ if (result.error) {
1919
const env = process.env.NODE_ENV
2020
const port = process.env.PORT
2121
const certPassphrase = process.env.CERT_PASSPHRASE
22-
const balancerNetwork = process.env.BALANCER_NETWORK
22+
const ethereumChain = process.env.ETHEREUM_CHAIN
23+
const terraChain = process.env.TERRA_CHAIN
2324
let certPath = process.env.CERT_PATH
2425

2526
if ((typeof certPath === 'undefined' && certPath == null) || certPath === '') {
@@ -79,4 +80,6 @@ server.listen(port)
7980
server.on('error', onError)
8081
server.on('listening', onListening)
8182

82-
console.log('server: gateway-api | port:', port, '| balancer-network:', balancerNetwork);
83+
console.log('server: gateway-api | port:', port)
84+
console.log(' - ethereum-chain:', ethereumChain)
85+
console.log(' - terra-chain:', terraChain)

0 commit comments

Comments
 (0)