Skip to content

Commit

Permalink
chore(voucher): better accuracy for exchange rate (#4501)
Browse files Browse the repository at this point in the history
rebase
  • Loading branch information
siddhart1o1 authored Jun 5, 2024
1 parent 9452261 commit 0091351
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apps/voucher/hooks/use-currency-exchange-rate.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useCurrencyConversionEstimationQuery } from "@/lib/graphql/generated"
import { convertCurrency } from "@/lib/utils"

export const useCurrencyExchangeRate = ({
currency,
Expand All @@ -9,13 +8,14 @@ export const useCurrencyExchangeRate = ({
commissionPercentage: number
}) => {
const { data: currencyDataForOneUnit } = useCurrencyConversionEstimationQuery({
variables: { amount: 1, currency },
variables: { amount: 1000, currency },
context: { endpoint: "GALOY" },
fetchPolicy: "no-cache",
})
const usdToCurrencyRate = convertCurrency.centsToUsd({
cents: currencyDataForOneUnit?.currencyConversionEstimation.usdCentAmount,
})

const usdToCurrencyRate =
currencyDataForOneUnit?.currencyConversionEstimation.usdCentAmount / 1000 / 100.0

const voucherValueAfterCommission = usdToCurrencyRate * (1 - commissionPercentage / 100)
return 1 / voucherValueAfterCommission
}

0 comments on commit 0091351

Please sign in to comment.