Skip to content

Commit

Permalink
fix: router swap usd calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
amytsang committed Oct 31, 2024
1 parent cbb88c6 commit 5ada25f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions apps/main/src/components/FieldHelperUsdRate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ import isNaN from 'lodash/isNaN'
import isUndefined from 'lodash/isUndefined'
import styled from 'styled-components'

import { formatNumber, formatNumberUsdRate } from '@/ui/utils'
import { BN, formatNumber, formatNumberUsdRate } from '@/ui/utils'

import Chip from '@/ui/Typography/Chip'
import { BD } from '@/shared/curve-lib'

const FieldHelperUsdRate = ({ amount, usdRate }: { amount: string; usdRate: number | undefined }) => {
const usdRateTotal = useMemo(() => {
let total = ''

if (!isUndefined(usdRate) && !isNaN(usdRate) && +usdRate > 0 && +amount > 0) {
total = BD.from(usdRate).times(BD.from(amount)).toString()
total = BN(usdRate).multipliedBy(amount).toString()
}
return total
}, [usdRate, amount])
Expand Down

0 comments on commit 5ada25f

Please sign in to comment.