Skip to content

Commit fe070ba

Browse files
committed
feat(price-pusher): add gas multiplier cap for evm
1 parent f224486 commit fe070ba

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

price_pusher/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/price-pusher",
3-
"version": "5.4.11",
3+
"version": "5.5.0",
44
"description": "Pyth Price Pusher",
55
"homepage": "https://pyth.network",
66
"main": "lib/index.js",

price_pusher/src/evm/command.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,22 @@ export default {
3636
} as Options,
3737
"override-gas-price-multiplier": {
3838
description:
39-
"Multiply the gas price by this number if the transaction is not landing to override it. Default to 1.1",
39+
"Multiply the previous gas price by this number if the transaction is not landing to override. " +
40+
"Please note that the gas price can grow exponentially on consecutive failures; " +
41+
"to set a cap on the multiplier, use the `override-gas-price-multiplier-cap` option." +
42+
"Default to 1.1",
4043
type: "number",
4144
required: false,
4245
default: 1.1,
4346
} as Options,
47+
"override-gas-price-multiplier-cap": {
48+
description:
49+
"Maximum gas price multiplier to use in override compared to the RPC returned " +
50+
"gas price. Default to 5",
51+
type: "number",
52+
required: false,
53+
default: 5,
54+
} as Options,
4455
...options.priceConfigFile,
4556
...options.priceServiceEndpoint,
4657
...options.mnemonicFile,
@@ -61,6 +72,7 @@ export default {
6172
customGasStation,
6273
txSpeed,
6374
overrideGasPriceMultiplier,
75+
overrideGasPriceMultiplierCap,
6476
} = argv;
6577

6678
const priceConfigs = readPriceConfigFile(priceConfigFile);
@@ -106,6 +118,7 @@ export default {
106118
priceServiceConnection,
107119
pythContractFactory,
108120
overrideGasPriceMultiplier,
121+
overrideGasPriceMultiplierCap,
109122
gasStation
110123
);
111124

price_pusher/src/evm/evm.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export class EvmPricePusher implements IPricePusher {
129129
private connection: PriceServiceConnection,
130130
pythContractFactory: PythContractFactory,
131131
private overrideGasPriceMultiplier: number,
132+
private overrideGasPriceMultiplierCap: number,
132133
customGasStation?: CustomGasStation
133134
) {
134135
this.customGasStation = customGasStation;
@@ -200,7 +201,10 @@ export class EvmPricePusher implements IPricePusher {
200201
}
201202

202203
if (gasPriceToOverride !== undefined && gasPriceToOverride > gasPrice) {
203-
gasPrice = gasPriceToOverride;
204+
gasPrice = Math.min(
205+
gasPriceToOverride,
206+
gasPrice * this.overrideGasPriceMultiplierCap
207+
);
204208
}
205209

206210
const txNonce = lastExecutedNonce + 1;

0 commit comments

Comments
 (0)