Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix undefined gasPrice #207

Merged
merged 1 commit into from
Apr 18, 2023
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
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