diff --git a/locales/base/translation.json b/locales/base/translation.json index 650496a41e9..adc33eb2746 100644 --- a/locales/base/translation.json +++ b/locales/base/translation.json @@ -2571,7 +2571,9 @@ "moreInformation": "More information", "estNetworkFee": "Est. Network Fee", "maxNetworkFee": "Max Network Fee", - "networkFeeDescription": "The network fee is required by the network to process the deposit transaction." + "networkFeeDescription": "The network fee is required by the network to process the deposit transaction.", + "networkSwapFeeDescription": "The network fee is required by the network to process the deposit transactions. The {{appName}} fee of {{appFeePercentage}}% is charged for your use of our product.", + "appSwapFee": "{{appName}} Fee" } }, "activePools": { diff --git a/src/components/RowDivider.tsx b/src/components/RowDivider.tsx index ce3e087245a..5cf5acc5b0d 100644 --- a/src/components/RowDivider.tsx +++ b/src/components/RowDivider.tsx @@ -1,15 +1,14 @@ import * as React from 'react' -import { StyleSheet, View, ViewStyle } from 'react-native' +import { StyleSheet, View } from 'react-native' import { Colors } from 'src/styles/colors' import { Spacing } from 'src/styles/styles' export interface Props { color?: Colors - style?: ViewStyle } -export default function RowDivider({ color = Colors.gray2, style }: Props) { - return +export default function RowDivider({ color = Colors.gray2 }: Props) { + return } const styles = StyleSheet.create({ diff --git a/src/earn/EarnEnterAmount.test.tsx b/src/earn/EarnEnterAmount.test.tsx index 411d890d5ee..ed45d398d2c 100644 --- a/src/earn/EarnEnterAmount.test.tsx +++ b/src/earn/EarnEnterAmount.test.tsx @@ -523,5 +523,36 @@ describe('EarnEnterAmount', () => { expect(getByText('earnFlow.enterAmount.feeBottomSheet.feeDetails')).toBeVisible() expect(getByTestId('EstNetworkFee/Value')).toBeTruthy() expect(getByTestId('MaxNetworkFee/Value')).toBeTruthy() + expect(getByText('earnFlow.enterAmount.feeBottomSheet.networkFeeDescription')).toBeVisible() + }) + + it('should show swap fees on the FeeDetailsBottomSheet when swap transaction is present', async () => { + jest.mocked(usePrepareDepositTransactions).mockReturnValue({ + prepareTransactionsResult: { + prepareTransactionsResult: mockPreparedTransaction, + swapTransaction: mockSwapTransaction, + }, + refreshPreparedTransactions: jest.fn(), + clearPreparedTransactions: jest.fn(), + prepareTransactionError: undefined, + isPreparingTransactions: false, + }) + + const { getByTestId, getByText } = render( + + + + ) + + fireEvent.press(getByTestId('LabelWithInfo/FeeLabel')) + expect(getByText('earnFlow.enterAmount.feeBottomSheet.feeDetails')).toBeVisible() + expect(getByTestId('EstNetworkFee/Value')).toBeTruthy() + expect(getByTestId('MaxNetworkFee/Value')).toBeTruthy() + expect(getByTestId('SwapFee/Value')).toBeTruthy() + expect( + getByText( + 'earnFlow.enterAmount.feeBottomSheet.networkSwapFeeDescription, {"appFeePercentage":"0.6"}' + ) + ).toBeVisible() }) }) diff --git a/src/earn/EarnEnterAmount.tsx b/src/earn/EarnEnterAmount.tsx index b5c20a3fad9..97564b078cc 100644 --- a/src/earn/EarnEnterAmount.tsx +++ b/src/earn/EarnEnterAmount.tsx @@ -439,14 +439,20 @@ function EarnEnterAmount({ route }: Props) { /> - + {tokenAmount && ( + + )} {tokenAmount && prepareTransactionsResult?.type === 'possible' && ( title: string @@ -586,8 +596,31 @@ function FeeDetailsBottomSheet({ feeCurrency?: TokenBalance estimatedFeeAmount?: BigNumber maxFeeAmount?: BigNumber + swapTransaction?: SwapTransaction | undefined + pool: EarnPosition + token: TokenBalance + tokenAmount: BigNumber }) { const { t } = useTranslation() + const depositToken = useTokenInfo(pool.dataProps.depositTokenId) + + if (!depositToken) { + // should never happen + throw new Error(`Token info not found for token ID ${pool.dataProps.depositTokenId}`) + } + + const swapFeeAmount = useMemo(() => { + if (swapTransaction && swapTransaction.appFeePercentageIncludedInPrice) { + return tokenAmount.multipliedBy( + new BigNumber(swapTransaction.appFeePercentageIncludedInPrice).shiftedBy(-2) // To convert from percentage to decimal + ) + } + }, [swapTransaction, token]) + + const descriptionContainerStyle = [ + styles.bottomSheetDescriptionContainer, + swapFeeAmount && { marginTop: Spacing.Large32 }, + ] return ( @@ -633,14 +666,40 @@ function FeeDetailsBottomSheet({ )} - - + + {swapFeeAmount && ( + + + {t('earnFlow.enterAmount.feeBottomSheet.appSwapFee')} + + + {'≈ '} + + {' ('} + + {')'} + + + )} + {t('earnFlow.enterAmount.feeBottomSheet.moreInformation')} - - {t('earnFlow.enterAmount.feeBottomSheet.networkFeeDescription')} - + {swapFeeAmount ? ( + + {t('earnFlow.enterAmount.feeBottomSheet.networkSwapFeeDescription', { + appFeePercentage: swapTransaction?.appFeePercentageIncludedInPrice, + })} + + ) : ( + + {t('earnFlow.enterAmount.feeBottomSheet.networkFeeDescription')} + + )}