Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
arcoraven committed Dec 9, 2024
1 parent a2fbc6b commit 82d4924
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/utils/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const getPercentile = (arr: number[], percentile: number): number => {
return arr[index];
};

export const bigMath = {
export const BigIntMath = {
min: (a: bigint, b: bigint) => (a < b ? a : b),
max: (a: bigint, b: bigint) => (a > b ? a : b),
};
8 changes: 4 additions & 4 deletions src/worker/tasks/sendTransactionWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
isReplacementGasFeeTooLow,
wrapError,
} from "../../utils/error";
import { bigMath } from "../../utils/math";
import { BigIntMath } from "../../utils/math";
import { getChecksumAddress } from "../../utils/primitiveTypes";
import { recordMetrics } from "../../utils/prometheus";
import { redis } from "../../utils/redis/redis";
Expand Down Expand Up @@ -575,7 +575,7 @@ export function _updateGasFees(
return populatedTransaction;
}

const multiplier = bigMath.min(10n, BigInt(resendCount) * 2n);
const multiplier = BigIntMath.min(10n, BigInt(resendCount) * 2n);
const updated = { ...populatedTransaction };

// Update gas fees (unless they were explicitly overridden).
Expand All @@ -584,15 +584,15 @@ export function _updateGasFees(

if (updated.gasPrice && !overrides?.gasPrice) {
const newGasPrice = updated.gasPrice * multiplier;
updated.gasPrice = bigMath.min(newGasPrice, MAX_GAS_PRICE_WEI);
updated.gasPrice = BigIntMath.min(newGasPrice, MAX_GAS_PRICE_WEI);
}
if (updated.maxPriorityFeePerGas && !overrides?.maxPriorityFeePerGas) {
updated.maxPriorityFeePerGas *= multiplier;
}
if (updated.maxFeePerGas && !overrides?.maxFeePerGas) {
const newMaxFeePerGas =
updated.maxFeePerGas * 2n + (updated.maxPriorityFeePerGas ?? 0n);
updated.maxFeePerGas = bigMath.min(newMaxFeePerGas, MAX_GAS_PRICE_WEI);
updated.maxFeePerGas = BigIntMath.min(newMaxFeePerGas, MAX_GAS_PRICE_WEI);
}

return updated;
Expand Down

0 comments on commit 82d4924

Please sign in to comment.