From fe070baa489f47e09f66fe25775013d20e479ff8 Mon Sep 17 00:00:00 2001 From: Ali Behjati Date: Tue, 10 Oct 2023 13:02:32 +0200 Subject: [PATCH] feat(price-pusher): add gas multiplier cap for evm --- package-lock.json | 2 +- price_pusher/package.json | 2 +- price_pusher/src/evm/command.ts | 15 ++++++++++++++- price_pusher/src/evm/evm.ts | 6 +++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1f34f303..3528913d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56011,7 +56011,7 @@ }, "price_pusher": { "name": "@pythnetwork/price-pusher", - "version": "5.4.11", + "version": "5.5.0", "license": "Apache-2.0", "dependencies": { "@injectivelabs/sdk-ts": "1.10.72", diff --git a/price_pusher/package.json b/price_pusher/package.json index a6260ec1..7d3244f6 100644 --- a/price_pusher/package.json +++ b/price_pusher/package.json @@ -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", diff --git a/price_pusher/src/evm/command.ts b/price_pusher/src/evm/command.ts index bc8b90cd..57f61bbf 100644 --- a/price_pusher/src/evm/command.ts +++ b/price_pusher/src/evm/command.ts @@ -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, @@ -61,6 +72,7 @@ export default { customGasStation, txSpeed, overrideGasPriceMultiplier, + overrideGasPriceMultiplierCap, } = argv; const priceConfigs = readPriceConfigFile(priceConfigFile); @@ -106,6 +118,7 @@ export default { priceServiceConnection, pythContractFactory, overrideGasPriceMultiplier, + overrideGasPriceMultiplierCap, gasStation ); diff --git a/price_pusher/src/evm/evm.ts b/price_pusher/src/evm/evm.ts index d1b327c5..fbe88f82 100644 --- a/price_pusher/src/evm/evm.ts +++ b/price_pusher/src/evm/evm.ts @@ -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; @@ -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;