feat: configurable fee rates via VITE_CASH_IN_FEE and VITE_CASH_OUT_FEE

Accepts percentage (5.55) or decimal (0.0555) — auto-detected by
whether the value is >= 1. Defaults to 3.33% cash-in, 7.77% cash-out.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-04-05 14:03:32 -04:00
commit 2a2faf41ef
4 changed files with 31 additions and 3 deletions

View file

@ -260,6 +260,8 @@ export const useAtmStore = defineStore('atm', () => {
const allowMockFallback = ref(true) // default true for browser dev
const initError = ref<string | null>(null) // fatal error → maintenance screen
const fiatCode = ref('USD')
const cashInFeeRate = ref(0.0333)
const cashOutFeeRate = ref(0.0777)
const machineModel = ref('atm')
const useLiveServices = ref(false)
const connectionStatus = ref<'disconnected' | 'connecting' | 'connected' | 'error'>(
@ -359,7 +361,11 @@ export const useAtmStore = defineStore('atm', () => {
// Actions
function initialize(services: ATMServices = mockServices) {
atmServicesRef = services
const machine = createATMMachine(services, { currency: fiatCode.value })
const machine = createATMMachine(services, {
currency: fiatCode.value,
cashInFeeRate: cashInFeeRate.value,
cashOutFeeRate: cashOutFeeRate.value,
})
actor.value = createActor(machine)
// Track previous state to detect transitions into 'complete'
@ -925,6 +931,9 @@ export const useAtmStore = defineStore('atm', () => {
machineModel.value = model
const runtimeFiatCode = runtimeConfig.fiatCode || 'USD'
fiatCode.value = runtimeFiatCode
if (runtimeConfig.cashInFeeRate !== undefined) cashInFeeRate.value = runtimeConfig.cashInFeeRate
if (runtimeConfig.cashOutFeeRate !== undefined)
cashOutFeeRate.value = runtimeConfig.cashOutFeeRate
// Build device config from runtime values
const { getDeviceConfig, toHalConfig, MACHINE_PRESETS } = await import('@/config')

View file

@ -16,6 +16,8 @@ export interface RuntimeConfig {
allowMockFallback: boolean
operatorPubkeys: string
maintenanceMode: boolean
cashInFeeRate: number
cashOutFeeRate: number
}
export interface AtmSecrets {