nautilus_model/python/defi/
enums.rs1use std::str::FromStr;
19
20use nautilus_core::python::to_pyvalue_err;
21use pyo3::{PyTypeInfo, prelude::*, types::PyType};
22
23use crate::{
24 defi::{chain::Blockchain, data::PoolLiquidityUpdateType, dex::AmmType},
25 python::common::EnumIterator,
26};
27
28#[pymethods]
29impl Blockchain {
30 #[new]
31 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
32 let t = Self::type_object(py);
33 Self::py_from_str(&t, value)
34 }
35
36 fn __hash__(&self) -> isize {
37 *self as isize
38 }
39
40 fn __repr__(&self) -> String {
41 format!(
42 "<{}.{}: '{}'>",
43 stringify!(Blockchain),
44 self.name(),
45 self.value(),
46 )
47 }
48
49 fn __str__(&self) -> String {
50 self.to_string()
51 }
52
53 #[getter]
54 #[must_use]
55 pub fn name(&self) -> String {
56 self.to_string()
57 }
58
59 #[getter]
60 #[must_use]
61 pub fn value(&self) -> u8 {
62 *self as u8
63 }
64
65 #[classmethod]
66 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
67 EnumIterator::new::<Self>(py)
68 }
69
70 #[classmethod]
71 #[pyo3(name = "from_str")]
72 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
73 let data_str: &str = data.extract()?;
74 let tokenized = data_str.to_uppercase();
75 Self::from_str(&tokenized).map_err(to_pyvalue_err)
76 }
77
78 #[classattr]
79 #[pyo3(name = "ABSTRACT")]
80 fn py_abstract() -> Self {
81 Self::Abstract
82 }
83
84 #[classattr]
85 #[pyo3(name = "ARBITRUM")]
86 fn py_arbitrum() -> Self {
87 Self::Arbitrum
88 }
89
90 #[classattr]
91 #[pyo3(name = "ARBITRUM_NOVA")]
92 fn py_arbitrum_nova() -> Self {
93 Self::ArbitrumNova
94 }
95
96 #[classattr]
97 #[pyo3(name = "ARBITRUM_SEPOLIA")]
98 fn py_arbitrum_sepolia() -> Self {
99 Self::ArbitrumSepolia
100 }
101
102 #[classattr]
103 #[pyo3(name = "AURORA")]
104 fn py_aurora() -> Self {
105 Self::Aurora
106 }
107
108 #[classattr]
109 #[pyo3(name = "AVALANCHE")]
110 fn py_avalanche() -> Self {
111 Self::Avalanche
112 }
113
114 #[classattr]
115 #[pyo3(name = "BASE")]
116 fn py_base() -> Self {
117 Self::Base
118 }
119
120 #[classattr]
121 #[pyo3(name = "BASE_SEPOLIA")]
122 fn py_base_sepolia() -> Self {
123 Self::BaseSepolia
124 }
125
126 #[classattr]
127 #[pyo3(name = "BERACHAIN")]
128 fn py_berachain() -> Self {
129 Self::Berachain
130 }
131
132 #[classattr]
133 #[pyo3(name = "BERACHAIN_BARTIO")]
134 fn py_berachain_bartio() -> Self {
135 Self::BerachainBartio
136 }
137
138 #[classattr]
139 #[pyo3(name = "BLAST")]
140 fn py_blast() -> Self {
141 Self::Blast
142 }
143
144 #[classattr]
145 #[pyo3(name = "BLAST_SEPOLIA")]
146 fn py_blast_sepolia() -> Self {
147 Self::BlastSepolia
148 }
149
150 #[classattr]
151 #[pyo3(name = "BOBA")]
152 fn py_boba() -> Self {
153 Self::Boba
154 }
155
156 #[classattr]
157 #[pyo3(name = "BSC")]
158 fn py_bsc() -> Self {
159 Self::Bsc
160 }
161
162 #[classattr]
163 #[pyo3(name = "BSC_TESTNET")]
164 fn py_bsc_testnet() -> Self {
165 Self::BscTestnet
166 }
167
168 #[classattr]
169 #[pyo3(name = "CELO")]
170 fn py_celo() -> Self {
171 Self::Celo
172 }
173
174 #[classattr]
175 #[pyo3(name = "CHILIZ")]
176 fn py_chiliz() -> Self {
177 Self::Chiliz
178 }
179
180 #[classattr]
181 #[pyo3(name = "CITREA_TESTNET")]
182 fn py_citrea_testnet() -> Self {
183 Self::CitreaTestnet
184 }
185
186 #[classattr]
187 #[pyo3(name = "CURTIS")]
188 fn py_curtis() -> Self {
189 Self::Curtis
190 }
191
192 #[classattr]
193 #[pyo3(name = "CYBER")]
194 fn py_cyber() -> Self {
195 Self::Cyber
196 }
197
198 #[classattr]
199 #[pyo3(name = "DARWINIA")]
200 fn py_darwinia() -> Self {
201 Self::Darwinia
202 }
203
204 #[classattr]
205 #[pyo3(name = "ETHEREUM")]
206 fn py_ethereum() -> Self {
207 Self::Ethereum
208 }
209
210 #[classattr]
211 #[pyo3(name = "FANTOM")]
212 fn py_fantom() -> Self {
213 Self::Fantom
214 }
215
216 #[classattr]
217 #[pyo3(name = "FLARE")]
218 fn py_flare() -> Self {
219 Self::Flare
220 }
221
222 #[classattr]
223 #[pyo3(name = "FRAXTAL")]
224 fn py_fraxtal() -> Self {
225 Self::Fraxtal
226 }
227
228 #[classattr]
229 #[pyo3(name = "FUJI")]
230 fn py_fuji() -> Self {
231 Self::Fuji
232 }
233
234 #[classattr]
235 #[pyo3(name = "GALADRIEL_DEVNET")]
236 fn py_galadriel_devnet() -> Self {
237 Self::GaladrielDevnet
238 }
239
240 #[classattr]
241 #[pyo3(name = "GNOSIS")]
242 fn py_gnosis() -> Self {
243 Self::Gnosis
244 }
245
246 #[classattr]
247 #[pyo3(name = "GNOSIS_CHIADO")]
248 fn py_gnosis_chiado() -> Self {
249 Self::GnosisChiado
250 }
251
252 #[classattr]
253 #[pyo3(name = "GNOSIS_TRACES")]
254 fn py_gnosis_traces() -> Self {
255 Self::GnosisTraces
256 }
257
258 #[classattr]
259 #[pyo3(name = "HARMONY_SHARD_0")]
260 fn py_harmony_shard_0() -> Self {
261 Self::HarmonyShard0
262 }
263
264 #[classattr]
265 #[pyo3(name = "HOLESKY")]
266 fn py_holesky() -> Self {
267 Self::Holesky
268 }
269
270 #[classattr]
271 #[pyo3(name = "HOLESKY_TOKEN_TEST")]
272 fn py_holesky_token_test() -> Self {
273 Self::HoleskyTokenTest
274 }
275
276 #[classattr]
277 #[pyo3(name = "HYPERLIQUID")]
278 fn py_hyperliquid() -> Self {
279 Self::Hyperliquid
280 }
281
282 #[classattr]
283 #[pyo3(name = "HYPERLIQUID_TEMP")]
284 fn py_hyperliquid_temp() -> Self {
285 Self::HyperliquidTemp
286 }
287
288 #[classattr]
289 #[pyo3(name = "INK")]
290 fn py_ink() -> Self {
291 Self::Ink
292 }
293
294 #[classattr]
295 #[pyo3(name = "INTERNAL_TEST_CHAIN")]
296 fn py_internal_test_chain() -> Self {
297 Self::InternalTestChain
298 }
299
300 #[classattr]
301 #[pyo3(name = "KROMA")]
302 fn py_kroma() -> Self {
303 Self::Kroma
304 }
305
306 #[classattr]
307 #[pyo3(name = "LINEA")]
308 fn py_linea() -> Self {
309 Self::Linea
310 }
311
312 #[classattr]
313 #[pyo3(name = "LISK")]
314 fn py_lisk() -> Self {
315 Self::Lisk
316 }
317
318 #[classattr]
319 #[pyo3(name = "LUKSO")]
320 fn py_lukso() -> Self {
321 Self::Lukso
322 }
323
324 #[classattr]
325 #[pyo3(name = "LUKSO_TESTNET")]
326 fn py_lukso_testnet() -> Self {
327 Self::LuksoTestnet
328 }
329
330 #[classattr]
331 #[pyo3(name = "MANTA")]
332 fn py_manta() -> Self {
333 Self::Manta
334 }
335
336 #[classattr]
337 #[pyo3(name = "MANTLE")]
338 fn py_mantle() -> Self {
339 Self::Mantle
340 }
341
342 #[classattr]
343 #[pyo3(name = "MEGAETH_TESTNET")]
344 fn py_megaeth_testnet() -> Self {
345 Self::MegaethTestnet
346 }
347
348 #[classattr]
349 #[pyo3(name = "MERLIN")]
350 fn py_merlin() -> Self {
351 Self::Merlin
352 }
353
354 #[classattr]
355 #[pyo3(name = "METALL2")]
356 fn py_metall2() -> Self {
357 Self::Metall2
358 }
359
360 #[classattr]
361 #[pyo3(name = "METIS")]
362 fn py_metis() -> Self {
363 Self::Metis
364 }
365
366 #[classattr]
367 #[pyo3(name = "MEV_COMMIT")]
368 fn py_mev_commit() -> Self {
369 Self::MevCommit
370 }
371
372 #[classattr]
373 #[pyo3(name = "MODE")]
374 fn py_mode() -> Self {
375 Self::Mode
376 }
377
378 #[classattr]
379 #[pyo3(name = "MONAD_TESTNET")]
380 fn py_monad_testnet() -> Self {
381 Self::MonadTestnet
382 }
383
384 #[classattr]
385 #[pyo3(name = "MONAD_TESTNET_BACKUP")]
386 fn py_monad_testnet_backup() -> Self {
387 Self::MonadTestnetBackup
388 }
389
390 #[classattr]
391 #[pyo3(name = "MOONBASE_ALPHA")]
392 fn py_moonbase_alpha() -> Self {
393 Self::MoonbaseAlpha
394 }
395
396 #[classattr]
397 #[pyo3(name = "MOONBEAM")]
398 fn py_moonbeam() -> Self {
399 Self::Moonbeam
400 }
401
402 #[classattr]
403 #[pyo3(name = "MORPH")]
404 fn py_morph() -> Self {
405 Self::Morph
406 }
407
408 #[classattr]
409 #[pyo3(name = "MORPH_HOLESKY")]
410 fn py_morph_holesky() -> Self {
411 Self::MorphHolesky
412 }
413
414 #[classattr]
415 #[pyo3(name = "OPBNB")]
416 fn py_opbnb() -> Self {
417 Self::Opbnb
418 }
419
420 #[classattr]
421 #[pyo3(name = "OPTIMISM")]
422 fn py_optimism() -> Self {
423 Self::Optimism
424 }
425
426 #[classattr]
427 #[pyo3(name = "OPTIMISM_SEPOLIA")]
428 fn py_optimism_sepolia() -> Self {
429 Self::OptimismSepolia
430 }
431
432 #[classattr]
433 #[pyo3(name = "PHAROS_DEVNET")]
434 fn py_pharos_devnet() -> Self {
435 Self::PharosDevnet
436 }
437
438 #[classattr]
439 #[pyo3(name = "POLYGON")]
440 fn py_polygon() -> Self {
441 Self::Polygon
442 }
443
444 #[classattr]
445 #[pyo3(name = "POLYGON_AMOY")]
446 fn py_polygon_amoy() -> Self {
447 Self::PolygonAmoy
448 }
449
450 #[classattr]
451 #[pyo3(name = "POLYGON_ZKEVM")]
452 fn py_polygon_zkevm() -> Self {
453 Self::PolygonZkEvm
454 }
455
456 #[classattr]
457 #[pyo3(name = "ROOTSTOCK")]
458 fn py_rootstock() -> Self {
459 Self::Rootstock
460 }
461
462 #[classattr]
463 #[pyo3(name = "SAAKURU")]
464 fn py_saakuru() -> Self {
465 Self::Saakuru
466 }
467
468 #[classattr]
469 #[pyo3(name = "SCROLL")]
470 fn py_scroll() -> Self {
471 Self::Scroll
472 }
473
474 #[classattr]
475 #[pyo3(name = "SEPOLIA")]
476 fn py_sepolia() -> Self {
477 Self::Sepolia
478 }
479
480 #[classattr]
481 #[pyo3(name = "SHIMMER_EVM")]
482 fn py_shimmer_evm() -> Self {
483 Self::ShimmerEvm
484 }
485
486 #[classattr]
487 #[pyo3(name = "SONEIUM")]
488 fn py_soneium() -> Self {
489 Self::Soneium
490 }
491
492 #[classattr]
493 #[pyo3(name = "SOPHON")]
494 fn py_sophon() -> Self {
495 Self::Sophon
496 }
497
498 #[classattr]
499 #[pyo3(name = "SOPHON_TESTNET")]
500 fn py_sophon_testnet() -> Self {
501 Self::SophonTestnet
502 }
503
504 #[classattr]
505 #[pyo3(name = "SUPERSEED")]
506 fn py_superseed() -> Self {
507 Self::Superseed
508 }
509
510 #[classattr]
511 #[pyo3(name = "UNICHAIN")]
512 fn py_unichain() -> Self {
513 Self::Unichain
514 }
515
516 #[classattr]
517 #[pyo3(name = "UNICHAIN_SEPOLIA")]
518 fn py_unichain_sepolia() -> Self {
519 Self::UnichainSepolia
520 }
521
522 #[classattr]
523 #[pyo3(name = "XDC")]
524 fn py_xdc() -> Self {
525 Self::Xdc
526 }
527
528 #[classattr]
529 #[pyo3(name = "XDC_TESTNET")]
530 fn py_xdc_testnet() -> Self {
531 Self::XdcTestnet
532 }
533
534 #[classattr]
535 #[pyo3(name = "ZETA")]
536 fn py_zeta() -> Self {
537 Self::Zeta
538 }
539
540 #[classattr]
541 #[pyo3(name = "ZIRCUIT")]
542 fn py_zircuit() -> Self {
543 Self::Zircuit
544 }
545
546 #[classattr]
547 #[pyo3(name = "ZKSYNC")]
548 fn py_zksync() -> Self {
549 Self::ZKsync
550 }
551
552 #[classattr]
553 #[pyo3(name = "ZORA")]
554 fn py_zora() -> Self {
555 Self::Zora
556 }
557}
558
559#[pymethods]
560impl AmmType {
561 #[new]
562 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
563 let t = Self::type_object(py);
564 Self::py_from_str(&t, value)
565 }
566
567 fn __hash__(&self) -> isize {
568 *self as isize
569 }
570
571 fn __repr__(&self) -> String {
572 format!(
573 "<{}.{}: '{}'>",
574 stringify!(AmmType),
575 self.name(),
576 self.value(),
577 )
578 }
579
580 fn __str__(&self) -> String {
581 self.to_string()
582 }
583
584 #[getter]
585 #[must_use]
586 pub fn name(&self) -> String {
587 self.to_string()
588 }
589
590 #[getter]
591 #[must_use]
592 pub fn value(&self) -> u8 {
593 *self as u8
594 }
595
596 #[classmethod]
597 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
598 EnumIterator::new::<Self>(py)
599 }
600
601 #[classmethod]
602 #[pyo3(name = "from_str")]
603 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
604 let data_str: &str = data.extract()?;
605 Self::from_str(data_str).map_err(to_pyvalue_err)
606 }
607
608 #[classattr]
609 #[pyo3(name = "CPAMM")]
610 fn py_cpamm() -> Self {
611 Self::CPAMM
612 }
613
614 #[classattr]
615 #[pyo3(name = "CLAMM")]
616 fn py_clamm() -> Self {
617 Self::CLAMM
618 }
619
620 #[classattr]
621 #[pyo3(name = "CLAM_ENHANCED")]
622 fn py_clam_enhanced() -> Self {
623 Self::CLAMEnhanced
624 }
625
626 #[classattr]
627 #[pyo3(name = "STABLE_SWAP")]
628 fn py_stable_swap() -> Self {
629 Self::StableSwap
630 }
631
632 #[classattr]
633 #[pyo3(name = "WEIGHTED_POOL")]
634 fn py_weighted_pool() -> Self {
635 Self::WeightedPool
636 }
637
638 #[classattr]
639 #[pyo3(name = "COMPOSABLE_POOL")]
640 fn py_composable_pool() -> Self {
641 Self::ComposablePool
642 }
643}
644
645#[pymethods]
646impl PoolLiquidityUpdateType {
647 #[new]
648 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
649 let t = Self::type_object(py);
650 Self::py_from_str(&t, value)
651 }
652
653 fn __hash__(&self) -> isize {
654 *self as isize
655 }
656
657 fn __repr__(&self) -> String {
658 format!(
659 "<{}.{}: '{}'>",
660 stringify!(PoolLiquidityUpdateType),
661 self.name(),
662 self.value(),
663 )
664 }
665
666 fn __str__(&self) -> String {
667 self.to_string()
668 }
669
670 #[getter]
671 #[must_use]
672 pub fn name(&self) -> String {
673 self.to_string()
674 }
675
676 #[getter]
677 #[must_use]
678 pub fn value(&self) -> u8 {
679 *self as u8
680 }
681
682 #[classmethod]
683 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
684 EnumIterator::new::<Self>(py)
685 }
686
687 #[classmethod]
688 #[pyo3(name = "from_str")]
689 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
690 let data_str: &str = data.extract()?;
691 Self::from_str(data_str).map_err(to_pyvalue_err)
692 }
693
694 #[classattr]
695 #[pyo3(name = "MINT")]
696 fn py_mint() -> Self {
697 Self::Mint
698 }
699
700 #[classattr]
701 #[pyo3(name = "BURN")]
702 fn py_burn() -> Self {
703 Self::Burn
704 }
705}