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        rule(
24            source_key = "icydb.base.rule.finance.usd.nonnegative.v1",
25            kind = "numeric_minimum_inclusive",
26            args(0)
27        )
28    )
29)]
30pub struct Usd {}
31
32///
33/// E8s
34///
35/// Decimal amount constrained to at most 8 decimal places and non-negative.
36///
37
38#[newtype(
39    source_key = "crates/icydb/src/base/types/finance.rs::newtype::2",
40    primitive = "Decimal",
41    item(prim = "Decimal", scale = 8),
42    ty(rule(
43        source_key = "icydb.base.rule.finance.e8s.nonnegative.v1",
44        kind = "numeric_minimum_inclusive",
45        args(0)
46    ))
47)]
48pub struct E8s {}
49
50///
51/// E18s
52///
53/// Decimal amount constrained to at most 18 decimal places and non-negative.
54///
55
56#[newtype(
57    source_key = "crates/icydb/src/base/types/finance.rs::newtype::3",
58    primitive = "Decimal",
59    item(prim = "Decimal", scale = 18),
60    ty(rule(
61        source_key = "icydb.base.rule.finance.e18s.nonnegative.v1",
62        kind = "numeric_minimum_inclusive",
63        args(0)
64    ))
65)]
66pub struct E18s {}