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
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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PORT=5000
# ipv6 format for locahost ["::ffff:127.0.0.1", "::ffff:1", "fe80::1", "::1"]
IP_WHITELIST=

HUMMINGBOT_CLIENT_ID={client_id}
HUMMINGBOT_INSTANCE_ID={client_id}

# Celo

Expand Down
20 changes: 16 additions & 4 deletions src/routes/uniswap.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,14 @@ router.post('/sell-price', async (req, res) => {
} catch (err) {
debug(err)
let reason
err.reason ? reason = err.reason : reason = statusMessages.operation_error
res.status(500).json({
let err_code = 500
if (Object.keys(err).includes('isInsufficientReservesError')) {
err_code = 200
reason = statusMessages.insufficient_reserves + ' in Sell at Uniswap'
} else {
err.reason ? reason = err.reason : reason = statusMessages.operation_error
}
res.status(err_code).json({
error: reason,
message: err
})
Expand Down Expand Up @@ -140,8 +146,14 @@ router.post('/buy-price', async (req, res) => {
} catch (err) {
debug(err)
let reason
err.reason ? reason = err.reason : reason = statusMessages.operation_error
res.status(500).json({
let err_code = 500
if (Object.keys(err).includes('isInsufficientReservesError')) {
err_code = 200
reason = statusMessages.insufficient_reserves + ' in Buy at Uniswap'
} else {
err.reason ? reason = err.reason : reason = statusMessages.operation_error
}
res.status(err_code).json({
error: reason,
message: err
})
Expand Down
8 changes: 6 additions & 2 deletions src/services/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const statusMessages = {
operation_error: 'Operation Error',
no_pool_available: 'No Pool Available',
invalid_token_symbol: 'Invalid Token Symbol',
insufficient_reserves: 'Insufficient Liquidity Reserves',
}

export const latency = (startTime, endTime) => parseFloat((endTime - startTime) / 1000)
Expand Down Expand Up @@ -71,8 +72,11 @@ export const strToDecimal = (str) => parseInt(str) / 100;

export const getHummingbotMemo = () => {
const prefix = 'hbot'
const clientId = process.env.HUMMINGBOT_CLIENT_ID || ''
return [prefix, clientId].join('-')
const clientId = process.env.HUMMINGBOT_INSTANCE_ID
if ((typeof clientId !== 'undefined' && clientId != null) && clientId !== '') {
return [prefix, clientId].join('-')
}
return prefix
}

export const loadConfig = () => {
Expand Down