refactor: rename grossSats → principalSats for terminology consistency
"Gross" was operator-vs-customer ambiguous (cash-out: customer's gross payment = principal + commission, not the variable's value). atm-tui already settled on "principal" for the same quantity (bitspire/atm-tui src/db.zig:166-171, src/main.zig:98,716), and #44's Payment.extra proposal will surface it as `principal_sats` on the kind-21000 wire. Aligning the internal name removes one translation step across DB → TUI → state machine → wire envelope. Pure mechanical rename — no behavioral change. Also rewrites the computeFeeSats JSDoc to drop the "gross"/"net" framing and document the principalSats / on-wire satsAmount relationship explicitly. Refs aiolabs/lamassu-next#44 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
53b0d382e8
commit
ec14bb16c6
3 changed files with 25 additions and 22 deletions
|
|
@ -189,9 +189,9 @@ export function createATMMachine(
|
|||
satsAmount: ({ context }) => {
|
||||
if (context.exchangeRate === 0) return 0
|
||||
const fiatDollars = context.fiatCents / 100
|
||||
const grossSats = Math.floor(fiatDollars * context.exchangeRate)
|
||||
const fee = Math.floor(grossSats * context.feePercent)
|
||||
return grossSats - fee
|
||||
const principalSats = Math.floor(fiatDollars * context.exchangeRate)
|
||||
const fee = Math.floor(principalSats * context.feePercent)
|
||||
return principalSats - fee
|
||||
},
|
||||
}),
|
||||
calculateDispenseAmounts: assign({
|
||||
|
|
@ -324,10 +324,10 @@ export function createATMMachine(
|
|||
satsAmount: ({ context }) => {
|
||||
if (context.exchangeRate === 0) return 0
|
||||
const fiatDollars = context.fiatCents / 100
|
||||
const grossSats = Math.floor(fiatDollars * context.exchangeRate)
|
||||
const principalSats = Math.floor(fiatDollars * context.exchangeRate)
|
||||
// For cash-out, user pays the sats, so fee is added
|
||||
const fee = Math.floor(grossSats * context.feePercent)
|
||||
return grossSats + fee
|
||||
const fee = Math.floor(principalSats * context.feePercent)
|
||||
return principalSats + fee
|
||||
},
|
||||
}),
|
||||
calculateDispenseFromSelection: assign({
|
||||
|
|
@ -372,9 +372,9 @@ export function createATMMachine(
|
|||
// cash we can't cover with sats
|
||||
if (context.availableBalance <= 0 || context.exchangeRate === 0) return false
|
||||
const newFiatCents = context.fiatCents + event.denomination * 100
|
||||
const grossSats = Math.floor((newFiatCents / 100) * context.exchangeRate)
|
||||
const fee = Math.floor(grossSats * context.feePercent)
|
||||
return grossSats - fee <= context.availableBalance
|
||||
const principalSats = Math.floor((newFiatCents / 100) * context.exchangeRate)
|
||||
const fee = Math.floor(principalSats * context.feePercent)
|
||||
return principalSats - fee <= context.availableBalance
|
||||
},
|
||||
// Cash-out guards
|
||||
hasSelectedAmount: ({ context }) => context.cashOutSelection.length > 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue