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
40 changes: 22 additions & 18 deletions src/connectors/dexalot/dexalot.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
ClobBatchUpdateRequest,
ClobDeleteOrderRequest,
ClobDeleteOrderRequestExtract,
ClobGetOrderRequest,
ClobGetOrderResponse,
ClobMarketsRequest,
ClobOrderbookRequest,
ClobTickerRequest,
ClobGetOrderRequest,
ClobPostOrderRequest,
ClobDeleteOrderRequest,
ClobGetOrderResponse,
ClobBatchUpdateRequest,
ClobTickerRequest,
CreateOrderParam,
ClobDeleteOrderRequestExtract,
} from '../../clob/clob.requests';
import {
CLOBish,
Expand All @@ -32,11 +32,12 @@ import { indexOf } from 'lodash';
import path from 'path';
import { rootPath } from '../../paths';
import {
parseMarkerInfo,
createBook,
parseOrderInfo,
fromUtf8,
parseMarkerInfo,
parseOrderInfo,
} from './dexalot.utils';
import { TransactionResponse } from '@ethersproject/providers';

export class DexalotCLOB implements CLOBish {
private static _instances: LRUCache<string, DexalotCLOB>;
Expand All @@ -63,6 +64,7 @@ export class DexalotCLOB implements CLOBish {
public get tradePairsContract(): Contract {
return this._tradePairsContract;
}

public set tradePairsContract(value: Contract) {
this._tradePairsContract = value;
}
Expand Down Expand Up @@ -274,10 +276,7 @@ export class DexalotCLOB implements CLOBish {
req.orderType === 'LIMIT_MAKER' ? TimeInForce.PO : TimeInForce.GTC
);
txData.gasLimit = BigNumber.from(String(this._conf.gasLimitEstimate));
const txResponse = await EVMTxBroadcaster.getInstance(
this._chain,
req.address
).broadcast(txData);
const txResponse = await this.broadcastTransaction(req, txData);
return { txHash: txResponse.hash, clientOrderID };
}

Expand All @@ -289,10 +288,7 @@ export class DexalotCLOB implements CLOBish {
req.orderId
);
txData.gasLimit = BigNumber.from(String(this._conf.gasLimitEstimate));
const txResponse = await EVMTxBroadcaster.getInstance(
this._chain,
req.address
).broadcast(txData);
const txResponse = await this.broadcastTransaction(req, txData);
return { txHash: txResponse.hash };
}

Expand Down Expand Up @@ -331,11 +327,19 @@ export class DexalotCLOB implements CLOBish {
txData = await this.buildDeleteOrder(req.cancelOrderParams);

txData.gasLimit = BigNumber.from(String(this._conf.gasLimitEstimate));
const txResponse = await EVMTxBroadcaster.getInstance(
const txResponse = await this.broadcastTransaction(req, txData);
return { txHash: txResponse.hash, clientOrderID: data.clientOrderID };
}

async broadcastTransaction(
req: ClobBatchUpdateRequest,
txData: PopulatedTransaction
): Promise<TransactionResponse> {
logger.debug(`Broadcasting tx: ${JSON.stringify(txData)}`);
return await EVMTxBroadcaster.getInstance(
this._chain,
req.address
).broadcast(txData);
return { txHash: txResponse.hash, clientOrderID: data.clientOrderID };
}

public async buildPostOrder(
Expand Down
5 changes: 3 additions & 2 deletions src/services/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import appRoot from 'app-root-path';
import { ConfigManagerV2 } from './config-manager-v2';

dayjs.extend(utc);

const { LEVEL, MESSAGE } = require('triple-beam');
Expand Down Expand Up @@ -52,15 +53,15 @@ const getLogPath = () => {
};

const allLogsFileTransport = new DailyRotateFile({
level: 'info',
level: 'debug',
filename: `${getLogPath()}/logs_gateway_app.log.%DATE%`,
datePattern: 'YYYY-MM-DD',
handleExceptions: true,
handleRejections: true,
});

export const logger = winston.createLogger({
level: 'info',
level: 'debug',
format: logFileFormat,
exitOnError: false,
transports: [allLogsFileTransport],
Expand Down