From ffc07d6ed025c8127b24082e4aaf32c20f9911b1 Mon Sep 17 00:00:00 2001 From: kuba80-02 Date: Sun, 29 Dec 2024 11:34:45 +0100 Subject: [PATCH] Add new warn label --- src/components/Swap/Swap.tsx | 19 +++++++++++++++++-- src/components/Swap/style.ts | 15 +++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/components/Swap/Swap.tsx b/src/components/Swap/Swap.tsx index 3914c25f..2a44a562 100644 --- a/src/components/Swap/Swap.tsx +++ b/src/components/Swap/Swap.tsx @@ -41,7 +41,7 @@ import { useNavigate } from 'react-router-dom' import { PoolWithAddress } from '@store/reducers/pools' import { PublicKey } from '@solana/web3.js' import { Decimal, Tick, Tickmap } from '@invariant-labs/sdk/lib/market' -import { fromFee, SimulationStatus } from '@invariant-labs/sdk/lib/utils' +import { DECIMAL, fromFee, SimulationStatus } from '@invariant-labs/sdk/lib/utils' import { TooltipHover } from '@components/TooltipHover/TooltipHover' export interface Pools { @@ -591,6 +591,11 @@ export const Swap: React.FC = ({ void setSimulateAmount() }, [isFetchingNewPool]) + const IS_ERROR_LABEL_SHOW = + +printBN(simulateResult.priceImpact, DECIMAL - 2) > 25 || + tokens[tokenFrom?.toString() ?? '']?.isUnknown || + tokens[tokenTo?.toString() ?? '']?.isUnknown + return ( {/* {wrappedETHAccountExist && ( @@ -810,7 +815,16 @@ export const Swap: React.FC = ({ network={network} /> - + + {+printBN(simulateResult.priceImpact, DECIMAL - 2) > 25 && ( + + + {(+printBN(simulateResult.priceImpact, DECIMAL - 2)).toFixed(2)}% Price impact + + + )} {tokens[tokenFrom?.toString() ?? '']?.isUnknown && ( = ({ )} +