Skip to content

Commit

Permalink
feat: fixed properly counting of min/max
Browse files Browse the repository at this point in the history
  • Loading branch information
milan-bc committed Jul 20, 2020
1 parent 0ee5bf8 commit 294442e
Showing 1 changed file with 12 additions and 4 deletions.
@@ -1,4 +1,5 @@
import { convertBaseToStandard } from 'data/components/exchange/services'
import { Props } from './template.success'
import { SBCheckoutFormValuesType } from 'data/types'
import { SBPairType, SBPaymentMethodType } from 'core/types'
import BigNumber from 'bignumber.js'
Expand All @@ -18,6 +19,9 @@ export const getMaxMin = (

const max = BigNumber.minimum(method.limits.max, pair.buyMax).toString()

// eslint-disable-next-line
console.log('max', max)

return convertBaseToStandard('FIAT', max)
case 'min':
const defaultMin = convertBaseToStandard('FIAT', 0)
Expand All @@ -34,11 +38,13 @@ export const getMaxMin = (
export const maximumAmount = (
value: string,
allValues: SBCheckoutFormValuesType,
pair: SBPairType,
method?: SBPaymentMethodType
restProps: Props
) => {
if (!value) return true

const { pair, method } = restProps
if (!method) return true

return Number(value) > Number(getMaxMin(pair, 'max', allValues))
? 'ABOVE_MAX'
: false
Expand All @@ -47,11 +53,13 @@ export const maximumAmount = (
export const minimumAmount = (
value: string,
allValues: SBCheckoutFormValuesType,
pair: SBPairType,
method?: SBPaymentMethodType
restProps: Props
) => {
if (!value) return true

const { pair, method } = restProps
if (!method) return true

return Number(value) < Number(getMaxMin(pair, 'min', allValues))
? 'BELOW_MIN'
: false
Expand Down

0 comments on commit 294442e

Please sign in to comment.