From 79e87787bd5056687a5ea12b9410debd5b76d5c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Tesa=C5=99?= Date: Mon, 1 Apr 2024 23:52:36 +0200 Subject: [PATCH] Rename recommendedGasPriceMultipler to baseGasPriceMultiplier --- README.md | 4 ++-- config/airseeker.example.json | 2 +- .../airseeker/airseeker.example.json | 2 +- src/config/schema.test.ts | 2 +- src/config/schema.ts | 8 ++++---- src/gas-price/gas-price.test.ts | 6 +++--- src/gas-price/gas-price.ts | 14 +++++++------- test/fixtures/mock-config.ts | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index e53819cc..e720e730 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ Example of a scaling computation: ```js // Parameters: -// - recommendedGasPriceMultiplier = 1.2 +// - baseGasPriceMultiplier = 1.2 // - maxScalingMultiplier = 2 // - scalingWindow = 300 // @@ -201,7 +201,7 @@ Example of a scaling computation: 1.2 + (2 - 1.2) * (2.5 / 5) = 1.6 ``` -###### `recommendedGasPriceMultiplier` +###### `baseGasPriceMultiplier` The base multiplier used to compute the gas price. Used to multiply the latest (or sanitized) gas price. diff --git a/config/airseeker.example.json b/config/airseeker.example.json index 71f4b285..d2cde8e4 100644 --- a/config/airseeker.example.json +++ b/config/airseeker.example.json @@ -13,7 +13,7 @@ } }, "gasSettings": { - "recommendedGasPriceMultiplier": 1.5, + "baseGasPriceMultiplier": 1.5, "sanitizationSamplingWindow": 900, "sanitizationPercentile": 80, "scalingWindow": 120, diff --git a/local-test-configuration/airseeker/airseeker.example.json b/local-test-configuration/airseeker/airseeker.example.json index fe09562d..f6e85515 100644 --- a/local-test-configuration/airseeker/airseeker.example.json +++ b/local-test-configuration/airseeker/airseeker.example.json @@ -12,7 +12,7 @@ } }, "gasSettings": { - "recommendedGasPriceMultiplier": 1.5, + "baseGasPriceMultiplier": 1.5, "sanitizationSamplingWindow": 900, "sanitizationPercentile": 80, "scalingWindow": 120, diff --git a/src/config/schema.test.ts b/src/config/schema.test.ts index 3a9d95f6..e2ffbb64 100644 --- a/src/config/schema.test.ts +++ b/src/config/schema.test.ts @@ -8,7 +8,7 @@ import { chainsSchema, configSchema, deviationThresholdCoefficientSchema } from import { interpolateSecrets } from './utils'; const gasSettings = { - recommendedGasPriceMultiplier: 1.5, + baseGasPriceMultiplier: 1.5, sanitizationSamplingWindow: 900, sanitizationPercentile: 80, scalingWindow: 120, diff --git a/src/config/schema.ts b/src/config/schema.ts index 1914be5d..353b8a34 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -37,18 +37,18 @@ export type Contracts = z.infer; export const gasSettingsSchema = z .object({ - recommendedGasPriceMultiplier: z.number().positive(), + baseGasPriceMultiplier: z.number().positive(), sanitizationSamplingWindow: z.number().positive(), sanitizationPercentile: z.number().positive(), scalingWindow: z.number().positive(), maxScalingMultiplier: z.number().positive(), }) .superRefine((gasSettings, ctx) => { - if (gasSettings.recommendedGasPriceMultiplier > gasSettings.maxScalingMultiplier) { + if (gasSettings.baseGasPriceMultiplier > gasSettings.maxScalingMultiplier) { ctx.addIssue({ code: 'custom', - message: 'recommendedGasPriceMultiplier must be less than or equal to maxScalingMultiplier.', - path: ['recommendedGasPriceMultiplier'], + message: 'baseGasPriceMultiplier must be less than or equal to maxScalingMultiplier.', + path: ['baseGasPriceMultiplier'], }); } diff --git a/src/gas-price/gas-price.test.ts b/src/gas-price/gas-price.test.ts index 94b597b5..504a1b1e 100644 --- a/src/gas-price/gas-price.test.ts +++ b/src/gas-price/gas-price.test.ts @@ -166,7 +166,7 @@ describe(getRecommendedGasPrice.name, () => { const gasPrice = getRecommendedGasPrice(chainId, providerName, sponsorWalletAddress); - expect(gasPrice).toStrictEqual(ethers.parseUnits('14.1', 'gwei')); // The price is multiplied by the recommendedGasPriceMultiplier. + expect(gasPrice).toStrictEqual(ethers.parseUnits('14.1', 'gwei')); // The price is multiplied by the baseGasPriceMultiplier. expect(logger.warn).toHaveBeenCalledTimes(1); expect(logger.warn).toHaveBeenNthCalledWith(1, 'Sanitizing gas price.', { gasPrice: '10000000000', @@ -186,7 +186,7 @@ describe(getRecommendedGasPrice.name, () => { const gasPrice = getRecommendedGasPrice(chainId, providerName, sponsorWalletAddress); - expect(gasPrice).toStrictEqual(ethers.parseUnits('15', 'gwei')); // The price is multiplied by the recommendedGasPriceMultiplier. + expect(gasPrice).toStrictEqual(ethers.parseUnits('15', 'gwei')); // The price is multiplied by the baseGasPriceMultiplier. expect(logger.warn).toHaveBeenCalledTimes(1); expect(logger.warn).toHaveBeenNthCalledWith( 1, @@ -215,7 +215,7 @@ describe(getRecommendedGasPrice.name, () => { const gasPrice = getRecommendedGasPrice(chainId, providerName, sponsorWalletAddress); expect(latestStoredGasPrice).toStrictEqual(ethers.parseUnits('7.1', 'gwei')); - expect(gasPrice).toStrictEqual(ethers.parseUnits('10.65', 'gwei')); // The price is multiplied by the recommendedGasPriceMultiplier. + expect(gasPrice).toStrictEqual(ethers.parseUnits('10.65', 'gwei')); // The price is multiplied by the baseGasPriceMultiplier. expect(logger.warn).toHaveBeenCalledTimes(0); }); diff --git a/src/gas-price/gas-price.ts b/src/gas-price/gas-price.ts index 32847495..8163e8c7 100644 --- a/src/gas-price/gas-price.ts +++ b/src/gas-price/gas-price.ts @@ -86,19 +86,19 @@ export const getPercentile = (percentile: number, array: bigint[]) => { /** * Calculates the multiplier to use for pending transactions. - * @param recommendedGasPriceMultiplier + * @param baseGasPriceMultiplier * @param maxScalingMultiplier * @param lag * @param scalingWindow */ export const calculateScalingMultiplier = ( - recommendedGasPriceMultiplier: number, + baseGasPriceMultiplier: number, maxScalingMultiplier: number, lag: number, scalingWindow: number ) => Math.min( - recommendedGasPriceMultiplier + (maxScalingMultiplier - recommendedGasPriceMultiplier) * (lag / scalingWindow), + baseGasPriceMultiplier + (maxScalingMultiplier - baseGasPriceMultiplier) * (lag / scalingWindow), maxScalingMultiplier ); @@ -147,7 +147,7 @@ export const getRecommendedGasPrice = (chainId: string, providerName: string, sp const { gasPrices, sponsorLastUpdateTimestamp } = state.gasPrices[chainId]![providerName]!; const { gasSettings: { - recommendedGasPriceMultiplier, + baseGasPriceMultiplier, sanitizationPercentile, sanitizationSamplingWindow, scalingWindow, @@ -172,7 +172,7 @@ export const getRecommendedGasPrice = (chainId: string, providerName: string, sp if (lastUpdateTimestamp) { const pendingPeriod = Math.floor(Date.now() / 1000) - lastUpdateTimestamp; const scalingMultiplier = calculateScalingMultiplier( - recommendedGasPriceMultiplier, + baseGasPriceMultiplier, maxScalingMultiplier, pendingPeriod, scalingWindow @@ -212,8 +212,8 @@ export const getRecommendedGasPrice = (chainId: string, providerName: string, sp gasPrice: latestGasPrice.toString(), percentileGasPrice: percentileGasPrice.toString(), }); - return multiplyBigNumber(percentileGasPrice, recommendedGasPriceMultiplier); + return multiplyBigNumber(percentileGasPrice, baseGasPriceMultiplier); } - return multiplyBigNumber(latestGasPrice, recommendedGasPriceMultiplier); + return multiplyBigNumber(latestGasPrice, baseGasPriceMultiplier); }; diff --git a/test/fixtures/mock-config.ts b/test/fixtures/mock-config.ts index 93ec9193..c88a1353 100644 --- a/test/fixtures/mock-config.ts +++ b/test/fixtures/mock-config.ts @@ -15,7 +15,7 @@ export const generateTestConfig = (): Config => ({ }, providers: { hardhat: { url: 'http://127.0.0.1:8545' } }, gasSettings: { - recommendedGasPriceMultiplier: 1.5, + baseGasPriceMultiplier: 1.5, sanitizationPercentile: 80, sanitizationSamplingWindow: 900, maxScalingMultiplier: 2,