Custom Currencies and Rules
This document describes the custom auction currency architecture, normalization model, and rule evaluation behavior.
Data model summary
Core schema additions:
AuctionCurrencyProfile- Auction-scoped currency definitions
- Conversion rate to base unit
- Fraction policy and precision
- Input mode (
SCALARorDENOMINATION) - Optional denomination config
AuctionCurrencyRule- Structured, typed rule configs
- No executable user code
BidnormalizedAmountenteredRepresentationcurrencyProfileId
AuctionItemminBidConstraintminBidNormalizedminIncrementNormalized
Rule engine behavior
Rule evaluator is implemented in src/lib/services/auction-currency-rule.service.ts.
Supported rule types:
MIN_INCREMENTMIN_COMPONENT_RATIOREQUIRED_DENOMINATION- implicit
EQUAL_NOT_HIGHERrejection
Evaluation returns deterministic violation payloads consumed by API and UI.
Normalization strategy
- Every bid is normalized to base units before comparison.
- Scalar mode normalizes from entered numeric amount.
- Denomination mode normalizes by configured denomination factors.
- Highest-bid ordering must always use normalized values.
Do not introduce free-form formula execution for bid evaluation. Keep rule logic structured and typed.
API endpoints
Auction currency management endpoints:
GET /api/auctions/[id]/currenciesPOST /api/auctions/[id]/currenciesPATCH /api/auctions/[id]/currencies/[currencyId]DELETE /api/auctions/[id]/currencies/[currencyId]
Bid placement accepts profile-aware payloads:
amount(scalar mode)enteredRepresentation(denomination mode)currencyProfileId
Rule failures return structured details in details.violations.
Migration notes
- Migration is additive and preserves legacy amount fields.
- Existing auctions without custom profiles continue to behave with legacy paths.
- Run
npm run db:generateafter schema changes. - For local development seed data, representative currency profiles and rules are created in
prisma/seed.ts.
Last updated on