nautilus_model/python/defi/
size_estimator.rs1use pyo3::prelude::*;
19
20use crate::defi::pool_analysis::size_estimator::SizeForImpactResult;
21
22#[pymethods]
23#[pyo3_stub_gen::derive::gen_stub_pymethods]
24impl SizeForImpactResult {
25 #[getter]
26 #[pyo3(name = "target_impact_bps")]
27 fn py_target_impact_bps(&self) -> u32 {
28 self.target_impact_bps
29 }
30
31 #[getter]
32 #[pyo3(name = "size")]
33 fn py_size(&self) -> String {
34 self.size.to_string()
35 }
36
37 #[getter]
38 #[pyo3(name = "actual_impact_bps")]
39 fn py_actual_impact_bps(&self) -> u32 {
40 self.actual_impact_bps
41 }
42
43 #[getter]
44 #[pyo3(name = "zero_for_one")]
45 fn py_zero_for_one(&self) -> bool {
46 self.zero_for_one
47 }
48
49 #[getter]
50 #[pyo3(name = "iterations")]
51 fn py_iterations(&self) -> u32 {
52 self.iterations
53 }
54
55 #[getter]
56 #[pyo3(name = "converged")]
57 fn py_converged(&self) -> bool {
58 self.converged
59 }
60
61 #[getter]
62 #[pyo3(name = "expansion_count")]
63 fn py_expansion_count(&self) -> u32 {
64 self.expansion_count
65 }
66
67 #[getter]
68 #[pyo3(name = "initial_high")]
69 fn py_initial_high(&self) -> String {
70 self.initial_high.to_string()
71 }
72
73 #[getter]
74 #[pyo3(name = "final_low")]
75 fn py_final_low(&self) -> String {
76 self.final_low.to_string()
77 }
78
79 #[getter]
80 #[pyo3(name = "final_high")]
81 fn py_final_high(&self) -> String {
82 self.final_high.to_string()
83 }
84
85 #[pyo3(name = "within_tolerance")]
87 fn py_within_tolerance(&self, tolerance_bps: u32) -> bool {
88 self.within_tolerance(tolerance_bps)
89 }
90
91 #[pyo3(name = "accuracy_percent")]
96 fn py_accuracy_percent(&self) -> f64 {
97 self.accuracy_percent()
98 }
99
100 fn __str__(&self) -> String {
101 format!(
102 "SizeForImpactResult(target={}bps, actual={}bps, size={}, converged={}, iterations={})",
103 self.target_impact_bps,
104 self.actual_impact_bps,
105 self.size,
106 self.converged,
107 self.iterations,
108 )
109 }
110
111 fn __repr__(&self) -> String {
112 format!("{self:?}")
113 }
114}