Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem: not allowing to set fee lesser than the current average low fee #1385

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading