Skip to content

Commit

Permalink
Merge pull request #1385 from emeraldpay/feature/always-allow-lower-fee
Browse files Browse the repository at this point in the history
problem: not allowing to set fee lesser than the current average low fee
  • Loading branch information
splix authored Dec 9, 2024
2 parents fdef4b3 + 5008593 commit e842c0a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/store/src/txstash/handler/blockchain/ethereum/fee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export const fetchFee: EntryHandler<EthereumEntry, Promise<void>> =
[],
);

const defaultFee = application.selectors.getDefaultFee<string>(state, blockchain);
if (highFee.max.eq(0)) {
const defaultFee = application.selectors.getDefaultFee<string>(state, blockchain);

const defaults: workflow.EthereumFeeRange<string> = {
stdMaxGasPrice: defaultFee?.max ?? '0',
Expand All @@ -109,9 +109,19 @@ export const fetchFee: EntryHandler<EthereumEntry, Promise<void>> =
}
}
} else {

// User may want to set a low fee even lower that the current averages because he is okay to wait longer
// Here we make sure we set the smaller of the two, the Default MIN and the current Average MIN
let min: string;
if (defaultFee?.min != null && defaultFee.min !== '0' && new BigNumber(defaultFee.min) < lowFee.max) {
min = defaultFee.min;
} else {
min = lowFee.max.toString()
}

const fee: workflow.EthereumFeeRange<string> = {
stdMaxGasPrice: stdFee.max.toString(),
lowMaxGasPrice: lowFee.max.toString(),
lowMaxGasPrice: min,
highMaxGasPrice: highFee.max.toString(),
stdPriorityGasPrice: stdFee.priority.toString(),
lowPriorityGasPrice: lowFee.priority.toString(),
Expand Down

0 comments on commit e842c0a

Please sign in to comment.