Skip to content
Open
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
4 changes: 2 additions & 2 deletions maker.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Builder stage
#
FROM node:16 AS builder
FROM node:20 AS builder

# Use non-root user to avoid unexpected npm behaviors.
RUN groupadd -r perp && useradd --no-log-init --create-home -r -g perp perp
Expand All @@ -18,7 +18,7 @@ RUN npm run build
#
# Production stage
#
FROM node:16-alpine
FROM node:20-alpine

# Use non-root user to avoid unexpected npm behaviors.
RUN addgroup perp && adduser -G perp -S -s /bin/sh -D perp perp
Expand Down
2 changes: 1 addition & 1 deletion serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ useDotenv: true
provider:
name: aws
stackName: ${self:service}
runtime: nodejs16.x
runtime: nodejs20.x
memorySize: 512
versionFunctions: false
stage: ${opt:stage, 'production'}
Expand Down
40 changes: 21 additions & 19 deletions src/maker/Maker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,28 @@ export class Maker extends BotService {

async makerRoutine() {
while (true) {
// TODO: use Promise.all()
for (const market of Object.values(this.marketMap)) {
try {
const gasPrice = await this.ethService.getGasPrice()
const adjustMaxGasPrice = Big(config.ADJUST_MAX_GAS_PRICE_GWEI)
if (gasPrice.gt(adjustMaxGasPrice)) {
this.log.jwarn({
event: "GasPriceExceed",
params: { gasPrice: +gasPrice, maxGasPrice: +adjustMaxGasPrice },
})
continue
}
await this.refreshOrders(market)
await this.adjustLiquidity(market)
} catch (err: any) {
await this.log.jerror({
event: "AdjustLiquidityError",
params: { err: err.toString() },
const gasPrice = await this.ethService.getGasPrice()
const adjustMaxGasPrice = Big(config.ADJUST_MAX_GAS_PRICE_GWEI)

if (gasPrice.gt(adjustMaxGasPrice)) {
this.log.jwarn({
event: "GasPriceExceed",
params: { gasPrice: +gasPrice, maxGasPrice: +adjustMaxGasPrice },
})
} else {
await Promise.all(
Object.values(this.marketMap).map(async (market) => {
try {
await this.refreshOrders(market)
await this.adjustLiquidity(market)
} catch (err: any) {
await this.log.jerror({
event: "AdjustLiquidityError",
params: { market: market.name, err: err.toString() },
})
}
})
}
)
}
await sleep(config.PRICE_CHECK_INTERVAL_SEC * 1000)
}
Expand Down