Skip to main content

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    source_key = "crates/icydb/src/base/types/finance.rs::newtype::1",
19    primitive = "Decimal",
20    item(prim = "Decimal", scale = 2),
21    ty(
22        normalizer(path = "base::normalizer::num::RoundDecimalPlaces", args(2)),
23        validator(path = "base::validator::decimal::MaxDecimalPlaces", args(2)),
24        validator(path = "base::validator::num::Gte", args(0))
25    )
26)]
27pub struct Usd {}
28
29///
30/// E8s
31///
32/// Decimal amount constrained to at most 8 decimal places and non-negative.
33///
34
35#[newtype(
36    source_key = "crates/icydb/src/base/types/finance.rs::newtype::2",
37    primitive = "Decimal",
38    item(prim = "Decimal", scale = 8),
39    ty(
40        validator(path = "base::validator::decimal::MaxDecimalPlaces", args(8)),
41        validator(path = "base::validator::num::Gte", args(0))
42    )
43)]
44pub struct E8s {}
45
46///
47/// E18s
48///
49/// Decimal amount constrained to at most 18 decimal places and non-negative.
50///
51
52#[newtype(
53    source_key = "crates/icydb/src/base/types/finance.rs::newtype::3",
54    primitive = "Decimal",
55    item(prim = "Decimal", scale = 18),
56    ty(
57        validator(path = "base::validator::decimal::MaxDecimalPlaces", args(18)),
58        validator(path = "base::validator::num::Gte", args(0))
59    )
60)]
61pub struct E18s {}