Skip to content

Commit

Permalink
feat: limit orders constraint delta to 999% max (#8419)
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre authored Dec 19, 2024
1 parent 6934990 commit b4cf01a
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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() ||
Expand All @@ -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 (
<CText color={delta.gt(0) ? 'text.success' : 'text.error'}>
({prefix}
{delta.toFixed(2)}%)
{deltaOrDefault}%)
</CText>
)
}, [delta, isLoading, limitPrice, marketPriceBuyAsset])
Expand Down

0 comments on commit b4cf01a

Please sign in to comment.