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

chore: added fefee summary tx #2832

Merged
merged 1 commit into from
Oct 25, 2023
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {getPoolUrlByProvider, useSwap} from '@yoroi/swap'
import {Swap} from '@yoroi/types'
import {capitalize} from 'lodash'
import React from 'react'
import {StyleSheet, TouchableOpacity, View} from 'react-native'
Expand All @@ -19,16 +18,20 @@ export const TransactionSummary = () => {
const strings = useStrings()
const wallet = useSelectedWallet()
const {orderData} = useSwap()
const {amounts, selectedPoolCalculation} = orderData
const {amounts, selectedPoolCalculation: calculation} = orderData
const {openModal} = useModal()

// should never happen
if (!calculation) throw new Error('No selected pool calculation')
const {pool, cost} = calculation

const buyTokenInfo = useTokenInfo({wallet, tokenId: amounts.buy.tokenId})
const tokenToBuyName = buyTokenInfo.ticker ?? buyTokenInfo.name
const label = `${Quantities.format(amounts.buy.quantity, buyTokenInfo.decimals ?? 0)} ${tokenToBuyName}`
const poolProviderFormatted = capitalize(selectedPoolCalculation?.pool.provider)
const poolUrl = getPoolUrlByProvider(selectedPoolCalculation?.pool.provider as Swap.SupportedProvider)
const poolProviderFormatted = capitalize(pool.provider)
const poolUrl = getPoolUrlByProvider(pool.provider)

const poolIcon = <PoolIcon providerId={selectedPoolCalculation?.pool.provider as Swap.SupportedProvider} size={18} />
const poolIcon = <PoolIcon providerId={pool.provider} size={18} />

const feesInfo = [
{
Expand All @@ -37,25 +40,24 @@ export const TransactionSummary = () => {
},
{
label: strings.swapMinAdaTitle,
value: `${Quantities.format(
selectedPoolCalculation?.cost?.deposit?.quantity ?? Quantities.zero,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these checks now happen in the calculations.

Number(wallet.primaryTokenInfo.decimals),
)} ${wallet.primaryTokenInfo.ticker}`,
value: `${Quantities.format(cost.deposit.quantity, wallet.primaryTokenInfo.decimals ?? 0)} ${
wallet.primaryTokenInfo.ticker
}`,
info: strings.swapMinAda,
},
{
label: strings.swapMinReceivedTitle,
value: `${Quantities.format(
selectedPoolCalculation?.buyAmountWithSlippage?.quantity ?? Quantities.zero,
calculation.buyAmountWithSlippage.quantity,
buyTokenInfo.decimals ?? 0,
)} ${tokenToBuyName}`,
info: strings.swapMinReceived,
},
{
label: strings.swapFeesTitle,
value: `${Quantities.format(
selectedPoolCalculation?.cost?.batcherFee?.quantity ?? Quantities.zero, // TODO: Show all fees
Number(wallet.primaryTokenInfo.decimals),
Quantities.sum([cost.batcherFee.quantity, cost.frontendFeeInfo.fee.quantity]),
wallet.primaryTokenInfo.decimals ?? 0,
)} ${wallet.primaryTokenInfo.ticker}`,
info: strings.swapFees,
},
Expand Down