Skip to content

Commit

Permalink
feat(price-pusher): add gas multiplier cap for evm
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-bahjati committed Oct 10, 2023
1 parent f224486 commit fe070ba
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion price_pusher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/price-pusher",
"version": "5.4.11",
"version": "5.5.0",
"description": "Pyth Price Pusher",
"homepage": "https://pyth.network",
"main": "lib/index.js",
Expand Down
15 changes: 14 additions & 1 deletion price_pusher/src/evm/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,22 @@ export default {
} as Options,
"override-gas-price-multiplier": {
description:
"Multiply the gas price by this number if the transaction is not landing to override it. Default to 1.1",
"Multiply the previous gas price by this number if the transaction is not landing to override. " +
"Please note that the gas price can grow exponentially on consecutive failures; " +
"to set a cap on the multiplier, use the `override-gas-price-multiplier-cap` option." +
"Default to 1.1",
type: "number",
required: false,
default: 1.1,
} as Options,
"override-gas-price-multiplier-cap": {
description:
"Maximum gas price multiplier to use in override compared to the RPC returned " +
"gas price. Default to 5",
type: "number",
required: false,
default: 5,
} as Options,
...options.priceConfigFile,
...options.priceServiceEndpoint,
...options.mnemonicFile,
Expand All @@ -61,6 +72,7 @@ export default {
customGasStation,
txSpeed,
overrideGasPriceMultiplier,
overrideGasPriceMultiplierCap,
} = argv;

const priceConfigs = readPriceConfigFile(priceConfigFile);
Expand Down Expand Up @@ -106,6 +118,7 @@ export default {
priceServiceConnection,
pythContractFactory,
overrideGasPriceMultiplier,
overrideGasPriceMultiplierCap,
gasStation
);

Expand Down
6 changes: 5 additions & 1 deletion price_pusher/src/evm/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class EvmPricePusher implements IPricePusher {
private connection: PriceServiceConnection,
pythContractFactory: PythContractFactory,
private overrideGasPriceMultiplier: number,
private overrideGasPriceMultiplierCap: number,
customGasStation?: CustomGasStation
) {
this.customGasStation = customGasStation;
Expand Down Expand Up @@ -200,7 +201,10 @@ export class EvmPricePusher implements IPricePusher {
}

if (gasPriceToOverride !== undefined && gasPriceToOverride > gasPrice) {
gasPrice = gasPriceToOverride;
gasPrice = Math.min(
gasPriceToOverride,
gasPrice * this.overrideGasPriceMultiplierCap
);
}

const txNonce = lastExecutedNonce + 1;
Expand Down

0 comments on commit fe070ba

Please sign in to comment.