icydb_model/base/types/finance.rs
1//! Module: base::types::finance
2//!
3//! Responsibility: base domain type declarations.
4//! Does not own: runtime storage, query execution, or validator implementation internals.
5//! Boundary: declares macro-modeled domain wrappers and records for downstream schemas.
6
7use crate::prelude::*;
8
9///
10/// Usd
11///
12/// Decimal amount denominated in USD.
13/// - Enforces at most 2 decimal places.
14/// - Must be non-negative.
15///
16
17#[newtype(
18 item(prim = "Decimal", scale = 2),
19 ty(
20 normalizer(path = "base::normalizer::num::RoundDecimalPlaces", args(2)),
21 rule(name = "nonnegative", numeric_minimum_inclusive(value = 0))
22 )
23)]
24pub struct Usd {}
25
26///
27/// E8s
28///
29/// Decimal amount constrained to at most 8 decimal places and non-negative.
30///
31
32#[newtype(
33 item(prim = "Decimal", scale = 8),
34 ty(rule(name = "nonnegative", numeric_minimum_inclusive(value = 0)))
35)]
36pub struct E8s {}
37
38///
39/// E18s
40///
41/// Decimal amount constrained to at most 18 decimal places and non-negative.
42///
43
44#[newtype(
45 item(prim = "Decimal", scale = 18),
46 ty(rule(name = "nonnegative", numeric_minimum_inclusive(value = 0)))
47)]
48pub struct E18s {}