From b4cf01acd1815e35f528985a90b7584ef648ab3f Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:20:36 +0300 Subject: [PATCH] feat: limit orders constraint delta to 999% max (#8419) --- .../LimitOrder/components/LimitOrderConfig.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/MultiHopTrade/components/LimitOrder/components/LimitOrderConfig.tsx b/src/components/MultiHopTrade/components/LimitOrder/components/LimitOrderConfig.tsx index 4d7b3b85e87..eeb6fc633b0 100644 --- a/src/components/MultiHopTrade/components/LimitOrder/components/LimitOrderConfig.tsx +++ b/src/components/MultiHopTrade/components/LimitOrder/components/LimitOrderConfig.tsx @@ -26,7 +26,7 @@ import { SwapIcon } from 'components/Icons/SwapIcon' import { Text } from 'components/Text' import { useActions } from 'hooks/useActions' import { useLocaleFormatter } from 'hooks/useLocaleFormatter/useLocaleFormatter' -import { bn } from 'lib/bignumber/bignumber' +import { BigNumber, bn } from 'lib/bignumber/bignumber' import { assertUnreachable } from 'lib/utils' import { ExpiryOption, @@ -209,7 +209,10 @@ export const LimitOrderConfig = ({ ) const renderDelta = useMemo(() => { - const prefix = delta.gt(0) ? '+' : '' + const prefix = (() => { + if (delta.gte('999')) return '>' + return delta.gt(0) ? '+' : '' + })() if ( bnOrZero(limitPrice.buyAssetDenomination).isZero() || @@ -219,10 +222,12 @@ export const LimitOrderConfig = ({ if (isLoading) return null if (delta.isZero()) return null + const deltaOrDefault = BigNumber.minimum(999, delta).toFixed(2) + return ( ({prefix} - {delta.toFixed(2)}%) + {deltaOrDefault}%) ) }, [delta, isLoading, limitPrice, marketPriceBuyAsset])