Skip to content

Commit

Permalink
chore(vouhcer): update voucher amount calculation (#4549)
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhart1o1 authored Jul 23, 2024
1 parent 1a49cdb commit 9e49bf6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ export const handleBtcWalletPayment = async ({
const voucherAmountInCents = Number(
amountCalculator.voucherAmountAfterPlatformFeesAndCommission
.fromCommission({
voucherPrice: salesAmountInCents,
platformFeesInPpm: env.PLATFORM_FEES_IN_PPM,
voucherAmountAfterCommission: amountPaidToEscrowInCents,
})
Expand Down
4 changes: 3 additions & 1 deletion apps/voucher/lib/amount-calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ export const amountCalculator = {
fromCommission: ({
voucherAmountAfterCommission,
platformFeesInPpm,
voucherPrice,
}: {
voucherAmountAfterCommission: number
platformFeesInPpm: number
voucherPrice: number
}) => {
const platformFees = voucherAmountAfterCommission * (platformFeesInPpm / 1000000)
const platformFees = voucherPrice * (platformFeesInPpm / 1000000)
const result = voucherAmountAfterCommission - platformFees
return Math.max(result, 0)
},
Expand Down

0 comments on commit 9e49bf6

Please sign in to comment.