Skip to content
This repository was archived by the owner on Feb 25, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
6833f5e
refactor common variables across routes
Nov 9, 2020
b34e570
Update input param and readme
Nov 9, 2020
519dcab
(fix) Remove undefined current gas price param
Nov 9, 2020
ce04a69
(feat) Refactor routes to use middleware peer connection check
Nov 11, 2020
647b867
(feat) fixes #2557: makes ETH routes non Balancer specific
fengtality Nov 13, 2020
1137584
Update global config setting; Refactor Terra endpoints
Nov 13, 2020
3fa27df
Merge branch 'feat/refactor_common_variables' into feat/terra_api
Nov 13, 2020
4634405
Update secret param, Add postman collection & environment
Nov 13, 2020
f3d508a
Return token swap info in price & trade. Refactor route functions
Nov 14, 2020
bf51849
Add trade_type to price endpoint param
Nov 14, 2020
a43ef33
(fix) price look up error.
Nov 15, 2020
2f7eaef
(fix) Remove token info from price lookup
Nov 15, 2020
8fcc13d
(fix) incorrect sell trade offer amount
Nov 15, 2020
991f020
(fix) add approve and allowances to balancer routes
fengtality Nov 16, 2020
23c30b3
(feat) add uniswap gateway
vic-en Nov 16, 2020
9d11771
Merge branch 'development' of https://github.com/CoinAlpha/gateway-ap…
vic-en Nov 16, 2020
6347884
(feat) update uniswap and modified eth route to be non balancer specific
vic-en Nov 18, 2020
32f8863
(cleanup) remove additions to balancer.routes
vic-en Nov 18, 2020
90ddf3b
(feat) rename BALANCER_NETWORK to ETHEREUM_CHAIN and make eth routes …
vic-en Nov 18, 2020
feee7b6
(feat) update argument description for approval related routes
vic-en Nov 18, 2020
b192023
(feat) update argument description for approval related routes 2
vic-en Nov 18, 2020
08f0559
Merge pull request #10 from CoinAlpha/feat/2557
fengtality Nov 18, 2020
c78eace
Merge branch 'development' of https://github.com/CoinAlpha/gateway-ap…
vic-en Nov 19, 2020
b53f354
(fix) minor fixes
fengtality Nov 20, 2020
d2a6efa
(fix) clean up code and add balancer/uniswap addresses
fengtality Nov 20, 2020
4d8810d
(feat) balancer dynamic gas
fengtality Nov 20, 2020
e28db41
(fix) provide appropraite token address when swapping out
vic-en Nov 20, 2020
1de1730
Merge branch 'feat/uniswap_gateway' of https://github.com/CoinAlpha/g…
vic-en Nov 20, 2020
9037859
Add gas price preset, return tx fee in price
Nov 20, 2020
f2e8f73
(fix) remove unused test address config
Nov 20, 2020
b3ef56e
Merge pull request #12 from CoinAlpha/feat/uniswap_gateway
fengtality Nov 20, 2020
68ceced
(refactor) refactor price routes to use execution price from Uniswap'…
vic-en Nov 23, 2020
2168cb7
(feat) balancer dynamic gas calc
fengtality Nov 24, 2020
840f9f8
(fix) parse amout correctly
vic-en Nov 24, 2020
36ae4b4
(fix) minor fixes + changed gasLimit to 150k
fengtality Nov 24, 2020
05aae21
(cleanup) remove debug statement
fengtality Nov 25, 2020
cf789cf
use custom gasLimit for Uniswap
fengtality Nov 25, 2020
4608bf6
(fix) Gas calculation not set correctly
Nov 27, 2020
902031c
Merge pull request #15 from CoinAlpha/balancer-fixes
fengtality Nov 27, 2020
30c8aa0
Merge pull request #14 from CoinAlpha/refactor/refactor_uniswap_price…
fengtality Nov 27, 2020
55b2746
(fix) Remove comments & unused variables
Dec 1, 2020
d87bbae
(feat) Add application label to dockerfile
Dec 1, 2020
44021e7
Merge pull request #17 from CoinAlpha/feat/terra_api
gyozajiro Dec 1, 2020
d0ecd2f
(feat) update eth routes to handle token decimals properlly
vic-en Dec 2, 2020
d5c8914
(feat) poll for eth tx
fengtality Dec 4, 2020
638c1da
(feat) Dynamic gas limit based-on max swaps.
Dec 7, 2020
3c9fd6a
Merge pull request #18 from CoinAlpha/feat/modify_eth_routes_to_take_…
fengtality Dec 7, 2020
cd2e744
(feat) Add gasLimit to uniswap. Default all network to mainnet
Dec 8, 2020
5a074d5
Merge pull request #21 from CoinAlpha/feat/dynamic_balancer_gas_price
gyozajiro Dec 8, 2020
7bdf537
Merge pull request #20 from CoinAlpha/feat/poll-for-eth-tx
gyozajiro Dec 9, 2020
16c5b22
(fix) Incorrect http response code 500 on successful tx
Dec 10, 2020
f80f208
Merge pull request #22 from CoinAlpha/fix/incorrect_http_code_success_tx
Nullably Dec 10, 2020
e269a20
(feat) Set approval gas limit to 50000
Dec 17, 2020
f34a2b1
Merge pull request #24 from CoinAlpha/feat/set_approval_gas_limit
fengtality Dec 17, 2020
871a6f5
(fix) No pool http 500 error code. Fixate gas to prevent default value
Dec 17, 2020
1b3d6dd
Merge pull request #25 from CoinAlpha/fix/no_pool_code_500_error
gyozajiro Dec 17, 2020
c9543f7
(refactor) Use HB instance ID memo. Add uniswap insufficient pool msg
Dec 17, 2020
5559189
Merge pull request #26 from CoinAlpha/refactor/hb_instance_id_uniswap…
gyozajiro Dec 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ npm-debug.log
*.env
*.env.*
# except the example .env.example
!.env.example
!.env.example

# Gateway API files
*.pem
34 changes: 21 additions & 13 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
# Configuration file

APPNAME=Hummingbot Gateway API
NODE_ENV=dev
PORT=5000
PROTOCOLS=["celo", "terra", "balancer", "eth"]

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

HUMMINGBOT_INSTANCE_ID={client_id}

# Celo

# Terra
TERRA_LCD_URL=https://tequila-lcd.terra.dev
TERRA_CHAIN=tequila-0004

# Balancer
# - network: mainnet, kovan, etc
# - mainnet: https://lcd.terra.dev
# - mainnet chain: columbus-4
# - testnet: https://tequila-lcd.terra.dev
# - testnet chain: tequila-0004
TERRA_LCD_URL={testnet_lcd_url}
TERRA_CHAIN={testnet_chain_id}

# Ethereum
# - chain: mainnet, kovan, etc
# - rpc url: infura or other rpc url
BALANCER_NETWORK={network}
ETHEREUM_RPC_URL=https://{network}.infura.io/v3/{api_key}
ETHEREUM_CHAIN={chain}
ETHEREUM_RPC_URL=https://{chain}.infura.io/v3/{api_key}

# subgraph_network:
# Balancer
# subgraph_chain
# Reference: https://docs.balancer.finance/sor/development#subgraph
# - mainnet: balancer
# - kovan: balancer-kovan
# Note: REACT_APP_SUBGRAPH_URL used by @balancer-labs/sor
REACT_APP_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/balancer-labs/{subgraph_network}
REACT_APP_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/balancer-labs/{subgraph_chain}

# exchange_proxy:
# Reference: https://docs.balancer.finance/smart-contracts/addresses
# - kovan: 0x4e67bf5bD28Dd4b570FBAFe11D0633eCbA2754Ec
# - mainnet: 0x3E66B66Fd1d0b02fDa6C811Da9E0547970DB2f21
# - kovan: 0x4e67bf5bD28Dd4b570FBAFe11D0633eCbA2754Ec
EXCHANGE_PROXY={exchange_proxy}

# Uniswap
# Reference: https://uniswap.org/docs/v2/smart-contracts/router02/
UNISWAP_ROUTER=0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D

# cert
CERT_PATH={full_path_to_certs_folder}
CERT_PASSPHRASE={passphrase}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ npm-debug.log
dist/

# cert
certs/
*.pem
*.srl
*.key
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM node:10.22.0-alpine

# Set labels
LABEL application="gateway-api"

# app directory
WORKDIR /usr/src/app

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ We created hummingbot to promote **decentralized market-making**: enabling membe

### Install Hummingbot

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

### Get support
- Chat with our support team on [Discord](https://discord.hummingbot.io)
Expand Down
2 changes: 1 addition & 1 deletion certs/readme.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
certs dir
certs dir for local testing only
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@uniswap/sdk": "^3.0.3",
"@balancer-labs/sor": "^0.3.3",
"@terra-money/terra.js": "^0.5.8",
"bignumber.js": "^9.0.0",
Expand Down
2 changes: 1 addition & 1 deletion setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This can be used as a common API server to handle transactions that requires cus
## Development Requirements

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

```bash
Expand Down
24 changes: 11 additions & 13 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import bodyParser from 'body-parser'
import express from 'express'
import helmet from 'helmet'
import { statusMessages } from './services/utils';
import { validateAccess } from './services/access';
import { IpFilter } from 'express-ipfilter'

// Routes
Expand All @@ -11,6 +12,7 @@ import balancerRoutes from './routes/balancer.route'
// import celoRoutes from './routes/celo.route'
import ethRoutes from './routes/eth.route'
import terraRoutes from './routes/terra.route'
import uniswapRoutes from './routes/uniswap.route'

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

app.use(validateAccess)

// mount all routes to this path
app.use('/api', apiRoutes);
app.use('/eth', ethRoutes);
// app.use('/celo', celoRoutes);
app.use('/terra', terraRoutes);
app.use('/balancer', balancerRoutes);
app.use('/uniswap', validateAccess, uniswapRoutes);
app.use('/api', validateAccess, apiRoutes);
app.use('/eth', validateAccess, ethRoutes);
// app.use('/celo', validateAccess, celoRoutes);
app.use('/terra', validateAccess, terraRoutes);
app.use('/balancer', validateAccess, balancerRoutes);

app.get('/', (req, res, next) => {
const cert = req.connection.getPeerCertificate()
if (req.client.authorized) {
next()
} else if (cert.subject) {
res.status(403).send({ error: statusMessages.ssl_cert_invalid })
} else {
res.status(401).send({ error: statusMessages.ssl_cert_required })
}
res.send('ok')
})

/**
Expand Down
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ if (result.error) {
const env = process.env.NODE_ENV
const port = process.env.PORT
const certPassphrase = process.env.CERT_PASSPHRASE
const balancerNetwork = process.env.BALANCER_NETWORK
const ethereumChain = process.env.ETHEREUM_CHAIN
const terraChain = process.env.TERRA_CHAIN
let certPath = process.env.CERT_PATH

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

console.log('server: gateway-api | port:', port, '| balancer-network:', balancerNetwork);
console.log('server: gateway-api | port:', port)
console.log(' - ethereum-chain:', ethereumChain)
console.log(' - terra-chain:', terraChain)
Loading