1use crate::types::{
7 AMLPatternResult, CircularFlowResult, Entity, EntityResolutionResult, KYCFactors, KYCResult,
8 MonitoringResult, MonitoringRule, PEPEntry, PEPResult, RapidMovementResult, ReciprocityResult,
9 SanctionsEntry, SanctionsResult, TimeWindow, Transaction,
10};
11use serde::{Deserialize, Serialize};
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
19pub struct CircularFlowInput {
20 pub transactions: Vec<Transaction>,
22 pub min_amount: f64,
24}
25
26impl CircularFlowInput {
27 pub fn new(transactions: Vec<Transaction>, min_amount: f64) -> Self {
29 Self {
30 transactions,
31 min_amount,
32 }
33 }
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
38pub struct CircularFlowOutput {
39 pub result: CircularFlowResult,
41 pub compute_time_us: u64,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47pub struct ReciprocityFlowInput {
48 pub transactions: Vec<Transaction>,
50 pub window: Option<TimeWindow>,
52 pub min_amount: f64,
54}
55
56impl ReciprocityFlowInput {
57 pub fn new(transactions: Vec<Transaction>, min_amount: f64) -> Self {
59 Self {
60 transactions,
61 window: None,
62 min_amount,
63 }
64 }
65
66 pub fn with_window(mut self, window: TimeWindow) -> Self {
68 self.window = Some(window);
69 self
70 }
71}
72
73#[derive(Debug, Clone, Serialize, Deserialize)]
75pub struct ReciprocityFlowOutput {
76 pub result: ReciprocityResult,
78 pub compute_time_us: u64,
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84pub struct RapidMovementInput {
85 pub transactions: Vec<Transaction>,
87 pub window_hours: f64,
89 pub velocity_threshold: f64,
91 pub amount_threshold: f64,
93}
94
95impl RapidMovementInput {
96 pub fn new(
98 transactions: Vec<Transaction>,
99 window_hours: f64,
100 velocity_threshold: f64,
101 amount_threshold: f64,
102 ) -> Self {
103 Self {
104 transactions,
105 window_hours,
106 velocity_threshold,
107 amount_threshold,
108 }
109 }
110}
111
112#[derive(Debug, Clone, Serialize, Deserialize)]
114pub struct RapidMovementOutput {
115 pub result: RapidMovementResult,
117 pub compute_time_us: u64,
119}
120
121#[derive(Debug, Clone, Serialize, Deserialize)]
123pub struct AMLPatternInput {
124 pub transactions: Vec<Transaction>,
126 pub structuring_threshold: f64,
128 pub structuring_window_hours: f64,
130}
131
132impl AMLPatternInput {
133 pub fn new(transactions: Vec<Transaction>) -> Self {
135 Self {
136 transactions,
137 structuring_threshold: 10_000.0,
138 structuring_window_hours: 24.0,
139 }
140 }
141
142 pub fn with_structuring_threshold(mut self, threshold: f64) -> Self {
144 self.structuring_threshold = threshold;
145 self
146 }
147}
148
149#[derive(Debug, Clone, Serialize, Deserialize)]
151pub struct AMLPatternOutput {
152 pub result: AMLPatternResult,
154 pub compute_time_us: u64,
156}
157
158#[derive(Debug, Clone, Serialize, Deserialize)]
164pub struct KYCScoringInput {
165 pub factors: KYCFactors,
167}
168
169impl KYCScoringInput {
170 pub fn new(factors: KYCFactors) -> Self {
172 Self { factors }
173 }
174}
175
176#[derive(Debug, Clone, Serialize, Deserialize)]
178pub struct KYCScoringOutput {
179 pub result: KYCResult,
181 pub compute_time_us: u64,
183}
184
185#[derive(Debug, Clone, Serialize, Deserialize)]
187pub struct EntityResolutionInput {
188 pub query: Entity,
190 pub candidates: Vec<Entity>,
192 pub min_score: f64,
194 pub max_matches: usize,
196}
197
198impl EntityResolutionInput {
199 pub fn new(query: Entity, candidates: Vec<Entity>) -> Self {
201 Self {
202 query,
203 candidates,
204 min_score: 0.7,
205 max_matches: 10,
206 }
207 }
208}
209
210#[derive(Debug, Clone, Serialize, Deserialize)]
212pub struct EntityResolutionOutput {
213 pub result: EntityResolutionResult,
215 pub compute_time_us: u64,
217}
218
219#[derive(Debug, Clone, Serialize, Deserialize)]
225pub struct SanctionsScreeningInput {
226 pub name: String,
228 pub sanctions_list: Vec<SanctionsEntry>,
230 pub min_score: f64,
232 pub max_matches: usize,
234}
235
236impl SanctionsScreeningInput {
237 pub fn new(name: String, sanctions_list: Vec<SanctionsEntry>) -> Self {
239 Self {
240 name,
241 sanctions_list,
242 min_score: 0.7,
243 max_matches: 10,
244 }
245 }
246}
247
248#[derive(Debug, Clone, Serialize, Deserialize)]
250pub struct SanctionsScreeningOutput {
251 pub result: SanctionsResult,
253 pub compute_time_us: u64,
255}
256
257#[derive(Debug, Clone, Serialize, Deserialize)]
259pub struct PEPScreeningInput {
260 pub name: String,
262 pub pep_list: Vec<PEPEntry>,
264 pub min_score: f64,
266 pub max_matches: usize,
268}
269
270impl PEPScreeningInput {
271 pub fn new(name: String, pep_list: Vec<PEPEntry>) -> Self {
273 Self {
274 name,
275 pep_list,
276 min_score: 0.7,
277 max_matches: 10,
278 }
279 }
280}
281
282#[derive(Debug, Clone, Serialize, Deserialize)]
284pub struct PEPScreeningOutput {
285 pub result: PEPResult,
287 pub compute_time_us: u64,
289}
290
291#[derive(Debug, Clone, Serialize, Deserialize)]
297pub struct TransactionMonitoringInput {
298 pub transactions: Vec<Transaction>,
300 pub rules: Vec<MonitoringRule>,
302 pub current_time: u64,
304}
305
306impl TransactionMonitoringInput {
307 pub fn new(
309 transactions: Vec<Transaction>,
310 rules: Vec<MonitoringRule>,
311 current_time: u64,
312 ) -> Self {
313 Self {
314 transactions,
315 rules,
316 current_time,
317 }
318 }
319}
320
321#[derive(Debug, Clone, Serialize, Deserialize)]
323pub struct TransactionMonitoringOutput {
324 pub result: MonitoringResult,
326 pub compute_time_us: u64,
328}
329
330#[cfg(test)]
331mod tests {
332 use super::*;
333
334 #[test]
335 fn test_circular_flow_input_builder() {
336 let input = CircularFlowInput::new(vec![], 100.0);
337 assert_eq!(input.min_amount, 100.0);
338 }
339
340 #[test]
341 fn test_aml_pattern_input_builder() {
342 let input = AMLPatternInput::new(vec![]).with_structuring_threshold(5000.0);
343 assert_eq!(input.structuring_threshold, 5000.0);
344 }
345}