Skip to content

Commit

Permalink
Bound base max gas price for harvesting
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed Mar 21, 2024
1 parent b6869d7 commit 73bbede
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ const defaultAccount: RpcConfig['account'] = {
};
const defaultTransactionConfig: RpcConfig['transaction'] = {
type: 'eip1559' as const,
maxGasPricePerTransactionWei: null,
maxNativePerTransactionWei: null,
totalTries: 1, // by default, only try the trx once
retryGasMultiplier: 1.2, // up gas by 20% on each retry
baseFeeMultiplier: 1.25, // 25% above base fee
Expand Down Expand Up @@ -295,6 +297,10 @@ export const RPC_CONFIG: Record<Chain, RpcConfig> = {
// example of a non bridging transaction: https://basescan.org/tx/0x4c06da47f27a0910737c6efe0ca54b493e0ab081effa8caa4641e11d458bff19
forceGasLimit: 1_500_000n,
},
transaction: {
...defaultTransactionConfig,
maxGasPricePerTransactionWei: ONE_GWEI,
},
},
bsc: {
...defaultConfig,
Expand Down
2 changes: 0 additions & 2 deletions src/lib/harvest-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ export async function harvestChain({
}

if (
rpcConfig.transaction.type === 'legacy' &&
rpcConfig.transaction.maxNativePerTransactionWei &&
item.simulation.gas.transactionCostEstimationWei > rpcConfig.transaction.maxNativePerTransactionWei
) {
Expand All @@ -315,7 +314,6 @@ export async function harvestChain({
}

if (
rpcConfig.transaction.type === 'legacy' &&
rpcConfig.transaction.maxGasPricePerTransactionWei &&
item.simulation.gas.gasPrice > rpcConfig.transaction.maxGasPricePerTransactionWei
) {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/rpc-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export type RpcConfig = {
}
| {
type: 'eip1559';
maxNativePerTransactionWei: bigint | null;
maxGasPricePerTransactionWei: bigint | null;
}
) & {
// @see aggressivelyWriteContract
Expand Down

0 comments on commit 73bbede

Please sign in to comment.