From f67e917e9a1da08c051a1894473d88fbcc79e9cf Mon Sep 17 00:00:00 2001 From: jorbuedo Date: Wed, 11 Oct 2023 13:50:44 +0200 Subject: [PATCH] fix: Get market price of each pool, not the selected (#2752) --- .../SelectPoolFromList/SelectPoolFromList.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/wallet-mobile/src/features/Swap/common/SelectPool/SelectPoolFromList/SelectPoolFromList.tsx b/apps/wallet-mobile/src/features/Swap/common/SelectPool/SelectPoolFromList/SelectPoolFromList.tsx index 50ae7bd8de..920cb9efe6 100644 --- a/apps/wallet-mobile/src/features/Swap/common/SelectPool/SelectPoolFromList/SelectPoolFromList.tsx +++ b/apps/wallet-mobile/src/features/Swap/common/SelectPool/SelectPoolFromList/SelectPoolFromList.tsx @@ -1,4 +1,4 @@ -import {useSwap} from '@yoroi/swap' +import {getMarketPrice, useSwap} from '@yoroi/swap' import {Swap} from '@yoroi/types' import React, {useState} from 'react' import {StyleSheet, Text, TouchableOpacity, View} from 'react-native' @@ -32,6 +32,8 @@ export const SelectPoolFromList = ({pools = []}: Props) => { const sellTokenInfo = useTokenInfo({wallet, tokenId: orderData.amounts.sell.tokenId}) const buyTokenInfo = useTokenInfo({wallet, tokenId: orderData.amounts.buy.tokenId}) const denomination = (sellTokenInfo.decimals ?? 0) - (buyTokenInfo.decimals ?? 0) + const tokenToSellName = sellTokenInfo.ticker ?? sellTokenInfo.name + const tokenToBuyName = buyTokenInfo.ticker ?? buyTokenInfo.name const handleOnPoolSelection = (pool: Swap.Pool) => { track.swapPoolChanged() @@ -75,14 +77,14 @@ export const SelectPoolFromList = ({pools = []}: Props) => { - {strings.price} + {strings.marketPrice} - {Quantities.format( - orderData.selectedPoolCalculation?.prices.market ?? Quantities.zero, + {`${Quantities.format( + getMarketPrice(pool, orderData.amounts.sell) ?? Quantities.zero, denomination, PRECISION, - )} + )} ${tokenToSellName}/${tokenToBuyName}`}