Handle floating point precision in max shares you can sell.

This commit is contained in:
James Grugett 2022-03-29 14:47:23 -05:00
parent d772a20d5e
commit 74fe80fd42

View File

@ -61,7 +61,7 @@ export const sellShares = functions.runWith({ minInstances: 1 }).https.onCall(
] ]
const maxShares = outcome === 'YES' ? yesShares : noShares const maxShares = outcome === 'YES' ? yesShares : noShares
if (shares > maxShares) { if (shares > maxShares + 0.000000000001) {
return { return {
status: 'error', status: 'error',
message: `You can only sell ${maxShares} shares`, message: `You can only sell ${maxShares} shares`,