diff options
| author | Adam Soltys <[email protected]> | 2023-03-28 22:45:09 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-03-28 22:45:09 -0700 |
| commit | 50d35a648da37453fb2446eeab4362a4d161725e (patch) | |
| tree | e420152b8d408139ae953de231fd658b90bc383b | |
| parent | ab49b84a8ab11b33735167fcc04b6f54a8c14a27 (diff) | |
| download | coinos-server-50d35a648da37453fb2446eeab4362a4d161725e.tar.gz coinos-server-50d35a648da37453fb2446eeab4362a4d161725e.zip | |
define equivalent rate
| -rw-r--r-- | lib/payments.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/payments.js b/lib/payments.js index a48a187b..6e2e3a99 100644 --- a/lib/payments.js +++ b/lib/payments.js @@ -33,9 +33,12 @@ export let debit = async ( let invoice = await g(`invoice:${hash}`); if (invoice) { ref = invoice.uid; + + let equivalentRate = + invoice.rate * (store.rates[currency] / store.rates[invoice.currency]); + if (Math.abs(invoice.rate / store.rates[invoice.currency] - 1) < 0.01) { - rate = - invoice.rate * (store.rates[currency] / store.rates[invoice.currency]); + rate = equivalentRate; } else { warn("rate slipped", hash, invoice.rate, equivalentRate); } |
