Skip to content

Commit

Permalink
feat(suite): standard priority fees in trading
Browse files Browse the repository at this point in the history
  • Loading branch information
enjojoy committed Feb 26, 2025
1 parent bea7345 commit 56841db
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/suite/src/hooks/wallet/useTradingRecomposeAndSign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export const useTradingRecomposeAndSign = () => {
setMaxOutputId: !composed.token?.contract ? setMaxOutputId : undefined,
selectedFee,
feePerUnit: composed.feePerByte,
maxFeePerGas: composed.maxFeePerGas,
maxPriorityFeePerGas: composed.maxPriorityFeePerGas,
feeLimit: composed.feeLimit || '',
estimatedFeeLimit: composed.estimatedFeeLimit,
options,
Expand Down Expand Up @@ -124,6 +126,7 @@ export const useTradingRecomposeAndSign = () => {

return;
}
//TODO priority
formState.feeLimit = normalLevels.normal.feeLimit;
}

Expand Down
8 changes: 7 additions & 1 deletion packages/suite/src/reducers/wallet/tradingReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ import { Action } from 'src/types/suite';
export interface ComposedTransactionInfo {
composed?: Pick<
PrecomposedTransactionFinal,
'feePerByte' | 'estimatedFeeLimit' | 'feeLimit' | 'token' | 'fee'
| 'feePerByte'
| 'estimatedFeeLimit'
| 'feeLimit'
| 'token'
| 'fee'
| 'maxFeePerGas'
| 'maxPriorityFeePerGas'
>;
selectedFee?: FeeLevel['label'];
}
Expand Down
15 changes: 14 additions & 1 deletion suite-common/wallet-utils/src/sendFormUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,20 @@ const getFeeLevels = ({ feeInfo, networkType }: GetFeeInfoProps) => {
blocks: -1,
});

if (networkType === 'ethereum') {
const isEthereum = networkType === 'ethereum';
const isEip1559 = feeInfo.levels.some(level => level.maxPriorityFeePerGas);

if (isEthereum) {
if (isEip1559) {
return levels.map(level => ({
...level,
feePerUnit: level.feePerUnit,
maxFeePerGas: level.maxFeePerGas,
maxPriorityFeePerGas: level.maxPriorityFeePerGas,
feeLimit: level.feeLimit,
}));
}

// convert wei to gwei
return levels.map(level => {
const gwei = new BigNumber(fromWei(level.feePerUnit || '0', 'gwei'));
Expand Down

0 comments on commit 56841db

Please sign in to comment.