feat(price-pusher): add gas multiplier cap for evm
This commit is contained in:
parent
f224486ae2
commit
fe070baa48
|
@ -56011,7 +56011,7 @@
|
||||||
},
|
},
|
||||||
"price_pusher": {
|
"price_pusher": {
|
||||||
"name": "@pythnetwork/price-pusher",
|
"name": "@pythnetwork/price-pusher",
|
||||||
"version": "5.4.11",
|
"version": "5.5.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@injectivelabs/sdk-ts": "1.10.72",
|
"@injectivelabs/sdk-ts": "1.10.72",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@pythnetwork/price-pusher",
|
"name": "@pythnetwork/price-pusher",
|
||||||
"version": "5.4.11",
|
"version": "5.5.0",
|
||||||
"description": "Pyth Price Pusher",
|
"description": "Pyth Price Pusher",
|
||||||
"homepage": "https://pyth.network",
|
"homepage": "https://pyth.network",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
|
|
|
@ -36,11 +36,22 @@ export default {
|
||||||
} as Options,
|
} as Options,
|
||||||
"override-gas-price-multiplier": {
|
"override-gas-price-multiplier": {
|
||||||
description:
|
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",
|
type: "number",
|
||||||
required: false,
|
required: false,
|
||||||
default: 1.1,
|
default: 1.1,
|
||||||
} as Options,
|
} 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.priceConfigFile,
|
||||||
...options.priceServiceEndpoint,
|
...options.priceServiceEndpoint,
|
||||||
...options.mnemonicFile,
|
...options.mnemonicFile,
|
||||||
|
@ -61,6 +72,7 @@ export default {
|
||||||
customGasStation,
|
customGasStation,
|
||||||
txSpeed,
|
txSpeed,
|
||||||
overrideGasPriceMultiplier,
|
overrideGasPriceMultiplier,
|
||||||
|
overrideGasPriceMultiplierCap,
|
||||||
} = argv;
|
} = argv;
|
||||||
|
|
||||||
const priceConfigs = readPriceConfigFile(priceConfigFile);
|
const priceConfigs = readPriceConfigFile(priceConfigFile);
|
||||||
|
@ -106,6 +118,7 @@ export default {
|
||||||
priceServiceConnection,
|
priceServiceConnection,
|
||||||
pythContractFactory,
|
pythContractFactory,
|
||||||
overrideGasPriceMultiplier,
|
overrideGasPriceMultiplier,
|
||||||
|
overrideGasPriceMultiplierCap,
|
||||||
gasStation
|
gasStation
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ export class EvmPricePusher implements IPricePusher {
|
||||||
private connection: PriceServiceConnection,
|
private connection: PriceServiceConnection,
|
||||||
pythContractFactory: PythContractFactory,
|
pythContractFactory: PythContractFactory,
|
||||||
private overrideGasPriceMultiplier: number,
|
private overrideGasPriceMultiplier: number,
|
||||||
|
private overrideGasPriceMultiplierCap: number,
|
||||||
customGasStation?: CustomGasStation
|
customGasStation?: CustomGasStation
|
||||||
) {
|
) {
|
||||||
this.customGasStation = customGasStation;
|
this.customGasStation = customGasStation;
|
||||||
|
@ -200,7 +201,10 @@ export class EvmPricePusher implements IPricePusher {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gasPriceToOverride !== undefined && gasPriceToOverride > gasPrice) {
|
if (gasPriceToOverride !== undefined && gasPriceToOverride > gasPrice) {
|
||||||
gasPrice = gasPriceToOverride;
|
gasPrice = Math.min(
|
||||||
|
gasPriceToOverride,
|
||||||
|
gasPrice * this.overrideGasPriceMultiplierCap
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const txNonce = lastExecutedNonce + 1;
|
const txNonce = lastExecutedNonce + 1;
|
||||||
|
|
Loading…
Reference in New Issue