Skip to content

Commit

Permalink
fix undefined gasPrice (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngmachado committed Apr 18, 2023
1 parent 7c78e57 commit 0e70e5f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
8 changes: 3 additions & 5 deletions src/transaction/gas.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ class Gas {
let hitGasPriceLimit = false;
if (this.app.config.MAX_GAS_PRICE !== undefined &&
parseInt(gasPrice) >= this.app.config.MAX_GAS_PRICE
) {
this.app.logger.warn(`Hit gas price limit of ${this.app.config.MAX_GAS_PRICE}`);
this.app.notifier.sendNotification(`Hit gas price limit of ${this.app.config.MAX_GAS_PRICE}`);
)
{
hitGasPriceLimit = true;
}
return {
Expand All @@ -42,8 +41,7 @@ class Gas {
};
} catch (err) {
return {
error: this.app.Errors.EVMErrorParser(err),
gasPrice: undefined
error: this.app.Errors.EVMErrorParser(err)
};
}
}
Expand Down
26 changes: 20 additions & 6 deletions src/web3client/liquidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,19 @@ class Liquidator {
if (await this.isPossibleToClose(job.superToken, job.sender, job.receiver, job.pppmode)) {
try {
const txData = this.app.protocol.generateDeleteStreamTxData(job.superToken, job.sender, job.receiver);
const baseGasPrice = await this.app.gasEstimator.getCappedGasPrice();
// if we hit the gas price limit, we stop the liquidation job
const baseGasPrice = await this.app.gasEstimator.getCappedGasPrice(); // will internally trhow and catch parse error a field

// if we hit the gas price limit or estimation error, we stop the liquidation job and return to main loop
if(baseGasPrice.error) {
this.app.logger.error(baseGasPrice.error);
return;
}
if(baseGasPrice.hitGasPriceLimit) {
this.app.logger.warn(`Hit gas price limit of ${this.app.config.MAX_GAS_PRICE}`);
this.app.notifier.sendNotification(`Hit gas price limit of ${this.app.config.MAX_GAS_PRICE}`);
return;
}

const txObject = {
retry: 1,
step: this.app.config.RETRY_GAS_MULTIPLIER,
Expand Down Expand Up @@ -166,10 +174,16 @@ class Liquidator {
try {
const txData = this.app.protocol.generateBatchLiquidationTxData(superToken, senders, receivers);
const baseGasPrice = await this.app.gasEstimator.getCappedGasPrice();
// if we hit the gas price limit, we stop the liquidation job
if(baseGasPrice.hitGasPriceLimit) {
return;
}
// if we hit the gas price limit or estimation error, we stop the liquidation job and return to main loop
if(baseGasPrice.error) {
this.app.logger.error(baseGasPrice.error);
return;
}
if(baseGasPrice.hitGasPriceLimit) {
this.app.logger.warn(`Hit gas price limit of ${this.app.config.MAX_GAS_PRICE}`);
this.app.notifier.sendNotification(`Hit gas price limit of ${this.app.config.MAX_GAS_PRICE}`);
return;
}
const txObject = {
retry: 1,
step: this.app.config.RETRY_GAS_MULTIPLIER,
Expand Down

0 comments on commit 0e70e5f

Please sign in to comment.