Skip to content

Commit 069ad3d

Browse files
fix: show source token amount not balance
1 parent 0d831b0 commit 069ad3d

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

app/components/UI/Bridge/Views/BatchSellReview/BatchSellReviewTokenRow.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,20 @@ describe('BatchSellReviewTokenRow', () => {
171171
expect(getByText('< 0.00001 ETH • 100%')).toBeOnTheScreen();
172172
});
173173

174+
it('renders the source amount used in the quote request', () => {
175+
const { getByText } = render(
176+
<BatchSellReviewTokenRow
177+
token={mockToken}
178+
tokenKey={mockTokenKey}
179+
percent={50}
180+
receivedAmount="123.45 USDC"
181+
onPercentChange={mockOnPercentChange}
182+
/>,
183+
);
184+
185+
expect(getByText('0.74906 ETH • 50%')).toBeOnTheScreen();
186+
});
187+
174188
it('forwards slider percent changes', () => {
175189
const { getByTestId } = render(
176190
<BatchSellReviewTokenRow

app/components/UI/Bridge/Views/BatchSellReview/BatchSellReviewTokenRow.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { formatTokenBalance } from '../../utils';
2222
import { BridgeToken } from '../../types';
2323
import { BatchSellReviewSelectorsIDs } from './BatchSellReview.testIds';
2424
import { BatchSellPercentageSlider } from './BatchSellPercentageSlider';
25+
import { getBatchSellSourceTokenAmount } from '../../hooks/useBatchSellQuoteRequest';
2526

2627
interface BatchSellReviewTokenRowProps {
2728
token: BridgeToken;
@@ -36,8 +37,9 @@ interface BatchSellReviewTokenRowProps {
3637
}
3738

3839
function getTokenBalanceText(token: BridgeToken, percent: number) {
39-
const balanceText = token.balance
40-
? `${formatTokenBalance(token.balance)} ${token.symbol}`
40+
const sourceAmount = getBatchSellSourceTokenAmount(token, percent);
41+
const balanceText = sourceAmount
42+
? `${formatTokenBalance(sourceAmount)} ${token.symbol}`
4143
: token.symbol;
4244

4345
return `${balanceText}${percent}%`;

0 commit comments

Comments
 (0)