Skip to content

Commit 55d511c

Browse files
author
Jon Tzeng
committed
Pad payment amounts by 0.00000002
1 parent 3b39573 commit 55d511c

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- added: Quote ID display in gift card transaction details with card-level copy
1818
- changed: Distinguish network vs service errors in gift card scenes
1919
- changed: Lock network fee to high priority for gift card purchases
20+
- changed: Pad gift card purchase quantity by 0.00000002 to mitigate underpayments
2021
- changed: Manage tokens scene saves changes on explicit save instead of live toggling
2122
- changed: Unify split wallet scene titles and add chain-specific descriptions for EVM and UTXO splits
2223
- changed: ramps: Infinite buy support enabled

src/components/scenes/GiftCardPurchaseScene.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useQuery } from '@tanstack/react-query'
2-
import { ceil, mul } from 'biggystring'
2+
import { add, ceil, mul } from 'biggystring'
33
import type { EdgeTransaction, EdgeTxActionGiftCard } from 'edge-core-js'
44
import * as React from 'react'
55
import {
@@ -497,8 +497,13 @@ export const GiftCardPurchaseScene: React.FC<Props> = props => {
497497
]?.denominations[0]?.multiplier ?? '1'
498498
: wallet.currencyInfo.denominations[0]?.multiplier ?? '1'
499499

500-
// quantity from API is in decimal units, convert to native
501-
const quantity = orderResponse.quantity.toFixed(DECIMAL_PRECISION)
500+
// Quantity from API is in decimal units, convert to native.
501+
// HACK: Pad by 0.00000002 to guarantee we never underpay due to either
502+
// unexplained drifts on our side or unreported drifts on their side.
503+
const quantity = add(
504+
orderResponse.quantity.toFixed(DECIMAL_PRECISION),
505+
'0.00000002'
506+
)
502507
const nativeAmount = String(ceil(mul(quantity, multiplier), 0))
503508

504509
// Calculate expiry time (quoteExpiry is Unix timestamp in milliseconds)

0 commit comments

Comments
 (0)