Skip to content

Commit

Permalink
set fees to zero for base fee zero chains
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Aug 1, 2023
1 parent ed779e9 commit 70cda15
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/utils/transaction/prepareRequest.ts
Expand Up @@ -78,10 +78,16 @@ export async function prepareRequest<

// EIP-1559 fees
if (typeof maxFeePerGas === 'undefined') {
// Set a buffer of 1.2x on top of the base fee to account for fluctuations.
request.maxPriorityFeePerGas = maxPriorityFeePerGas ?? defaultTip
request.maxFeePerGas =
(block.baseFeePerGas * 120n) / 100n + request.maxPriorityFeePerGas
// Set fees to zero when running anvil with zero base fee
if (block.baseFeePerGas === 0n) {
request.maxFeePerGas = 0n
request.maxPriorityFeePerGas = 0n
} else {
// Set a buffer of 1.2x on top of the base fee to account for fluctuations.
request.maxPriorityFeePerGas = maxPriorityFeePerGas ?? defaultTip
request.maxFeePerGas =
(block.baseFeePerGas * 120n) / 100n + request.maxPriorityFeePerGas
}
} else {
if (
typeof maxPriorityFeePerGas === 'undefined' &&
Expand Down

0 comments on commit 70cda15

Please sign in to comment.