@@ -9,11 +9,12 @@ import {
99 isPublicKeyRevealedAtom ,
1010} from "atoms/fees" ;
1111import { tokenPricesFamily } from "atoms/prices/atoms" ;
12+ import { serverFeeAtom } from "atoms/settings" ;
1213import BigNumber from "bignumber.js" ;
1314import invariant from "invariant" ;
1415import { useAtomValue } from "jotai" ;
1516import { useMemo , useState } from "react" ;
16- import { GasConfig } from "types" ;
17+ import { FrontendFeeConfig , GasConfig } from "types" ;
1718import { TxKind } from "types/txKind" ;
1819import { findCheapestToken } from "./internal" ;
1920
@@ -24,6 +25,7 @@ export type TransactionFeeProps = {
2425 gasPriceTable : GasPriceTable | undefined ;
2526 onChangeGasLimit : ( value : BigNumber ) => void ;
2627 onChangeGasToken : ( value : string ) => void ;
28+ frontendFeeConfig ?: FrontendFeeConfig ;
2729} ;
2830
2931export const useTransactionFee = (
@@ -35,6 +37,7 @@ export const useTransactionFee = (
3537 const userTransparentBalances = useAtomValue ( transparentBalanceAtom ) ;
3638 const userShieldedBalances = useAtomValue ( shieldedBalanceAtom ) ;
3739 const isPublicKeyRevealed = useAtomValue ( isPublicKeyRevealedAtom ) ;
40+ const serverFee = useAtomValue ( serverFeeAtom ) ;
3841
3942 const { data : nativeToken , isLoading : isLoadingNativeToken } = useAtomValue (
4043 nativeTokenAddressAtom
@@ -137,6 +140,12 @@ export const useTransactionFee = (
137140 gasToken,
138141 } ;
139142
143+ const frontendFeeConfig = serverFee && {
144+ target : serverFee . target ,
145+ percentage : BigNumber ( serverFee . percentage ) ,
146+ maxFeeInMinDenom : serverFee . maxValue && BigNumber ( serverFee . maxValue ) ,
147+ } ;
148+
140149 const isLoading =
141150 userTransparentBalances . isLoading ||
142151 isLoadingNativeToken ||
@@ -145,6 +154,7 @@ export const useTransactionFee = (
145154
146155 return {
147156 gasConfig,
157+ frontendFeeConfig,
148158 isLoading,
149159 gasEstimate,
150160 gasPriceTable,
0 commit comments