nautilus_model/python/defi/
quote.rs1use pyo3::prelude::*;
17
18use crate::defi::pool_analysis::quote::SwapQuote;
19
20#[pymethods]
21#[pyo3_stub_gen::derive::gen_stub_pymethods]
22impl SwapQuote {
23 #[getter]
24 #[pyo3(name = "amount0")]
25 fn py_amount0(&self) -> String {
26 self.amount0.to_string()
27 }
28
29 #[getter]
30 #[pyo3(name = "amount1")]
31 fn py_amount1(&self) -> String {
32 self.amount1.to_string()
33 }
34
35 #[getter]
36 #[pyo3(name = "sqrt_price_before_x96")]
37 fn py_sqrt_price_before_x96(&self) -> String {
38 self.sqrt_price_before_x96.to_string()
39 }
40
41 #[getter]
42 #[pyo3(name = "sqrt_price_after_x96")]
43 fn py_sqrt_price_after_x96(&self) -> String {
44 self.sqrt_price_after_x96.to_string()
45 }
46
47 #[getter]
48 #[pyo3(name = "tick_before")]
49 fn py_tick_before(&self) -> i32 {
50 self.tick_before
51 }
52
53 #[getter]
54 #[pyo3(name = "tick_after")]
55 fn py_tick_after(&self) -> i32 {
56 self.tick_after
57 }
58
59 #[getter]
60 #[pyo3(name = "liquidity_after")]
61 fn py_liquidity_after(&self) -> u128 {
62 self.liquidity_after
63 }
64
65 #[getter]
66 #[pyo3(name = "fee_growth_global_after")]
67 fn py_fee_growth_global_after(&self) -> String {
68 self.fee_growth_global_after.to_string()
69 }
70
71 #[getter]
72 #[pyo3(name = "lp_fee")]
73 fn py_lp_fee(&self) -> String {
74 self.lp_fee.to_string()
75 }
76
77 #[getter]
78 #[pyo3(name = "protocol_fee")]
79 fn py_protocol_fee(&self) -> String {
80 self.protocol_fee.to_string()
81 }
82
83 #[getter]
84 #[pyo3(name = "crossed_ticks_count")]
85 fn py_crossed_ticks_count(&self) -> usize {
86 self.crossed_ticks.len()
87 }
88
89 #[pyo3(name = "zero_for_one")]
93 fn py_zero_for_one(&self) -> bool {
94 self.zero_for_one()
95 }
96
97 #[pyo3(name = "total_fee")]
99 fn py_total_fee(&self) -> String {
100 self.total_fee().to_string()
101 }
102
103 #[pyo3(name = "total_crossed_ticks")]
108 fn py_total_crossed_ticks(&self) -> u32 {
109 self.total_crossed_ticks()
110 }
111
112 #[pyo3(name = "get_output_amount")]
114 fn py_get_output_amount(&self) -> String {
115 self.get_output_amount().to_string()
116 }
117
118 fn __str__(&self) -> String {
119 format!(
120 "SwapQuote(amount0={}, amount1={}, tick_before={}, tick_after={}, liquidity_after={}, total_fee={})",
121 self.amount0,
122 self.amount1,
123 self.tick_before,
124 self.tick_after,
125 self.liquidity_after,
126 self.total_fee()
127 )
128 }
129
130 fn __repr__(&self) -> String {
131 format!("{self:?}")
132 }
133}