charli3_dendrite 1.1.1.dev7__tar.gz → 1.1.1.dev12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/LICENSE +21 -21
  2. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/PKG-INFO +8 -5
  3. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/README.md +203 -202
  4. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/pyproject.toml +83 -51
  5. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/__init__.py +27 -18
  6. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/backend/__init__.py +128 -128
  7. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/backend/backend_base.py +205 -205
  8. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/backend/blockfrost/__init__.py +394 -394
  9. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/backend/blockfrost/models.py +47 -47
  10. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/backend/dbsync/__init__.py +1131 -754
  11. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/backend/dbsync/models.py +179 -177
  12. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/backend/ogmios_kupo/__init__.py +573 -573
  13. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/backend/ogmios_kupo/models.py +84 -84
  14. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/backend/utils.py +42 -42
  15. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dataclasses/__init__.py +1 -1
  16. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dataclasses/datums.py +170 -170
  17. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dataclasses/models.py +306 -273
  18. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/amm/__init__.py +1 -1
  19. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/amm/amm_base.py +519 -517
  20. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/amm/amm_types.py +436 -427
  21. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/amm/minswap.py +1303 -1171
  22. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/amm/muesli.py +334 -334
  23. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/amm/spectrum.py +416 -416
  24. charli3_dendrite-1.1.1.dev12/src/charli3_dendrite/dexs/amm/splash.py +700 -0
  25. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/amm/sundae.py +726 -725
  26. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/amm/vyfi.py +415 -415
  27. charli3_dendrite-1.1.1.dev12/src/charli3_dendrite/dexs/amm/wingriders.py +872 -0
  28. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/core/__init__.py +1 -1
  29. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/core/base.py +252 -251
  30. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/core/errors.py +25 -25
  31. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/ob/axo.py +778 -763
  32. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/ob/geniusyield.py +779 -761
  33. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/ob/ob_base.py +419 -420
  34. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/utility.py +169 -169
  35. charli3_dendrite-1.1.1.dev7/src/charli3_dendrite/dexs/amm/wingriders.py +0 -407
  36. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/__init__.py +0 -0
  37. {charli3_dendrite-1.1.1.dev7 → charli3_dendrite-1.1.1.dev12}/src/charli3_dendrite/dexs/ob/__init__.py +0 -0
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Charli3-Official and SteelSwap
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Charli3-Official and SteelSwap
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: charli3_dendrite
3
- Version: 1.1.1.dev7
3
+ Version: 1.1.1.dev12
4
4
  Summary:
5
5
  Author: Elder Millenial
6
6
  Author-email: eldermillenial@protonmail.com
@@ -9,11 +9,13 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Programming Language :: Python :: 3.10
10
10
  Classifier: Programming Language :: Python :: 3.11
11
11
  Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
12
13
  Requires-Dist: blockfrost-python (>=0.6.0,<0.7.0)
14
+ Requires-Dist: bump-my-version (>=1.1.4,<2.0.0)
13
15
  Requires-Dist: psycopg[binary,pool] (>=3.1.13,<4.0.0)
14
- Requires-Dist: pycardano (==0.11.1)
16
+ Requires-Dist: pycardano (==0.12.2)
15
17
  Requires-Dist: pydantic (>=2.5.2,<3.0.0)
16
- Requires-Dist: python-dotenv (==0.21.1)
18
+ Requires-Dist: python-dotenv (==1.0.1)
17
19
  Requires-Dist: requests (>=2.31.0,<3.0.0)
18
20
  Description-Content-Type: text/markdown
19
21
 
@@ -23,6 +25,7 @@ Description-Content-Type: text/markdown
23
25
  <p>
24
26
  <img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python version">
25
27
  <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License">
28
+ <img src="https://img.shields.io/pypi/dm/charli3-dendrite?style=flat-square" />
26
29
  <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs welcome">
27
30
  </p>
28
31
  </div>
@@ -218,5 +221,5 @@ poetry run pytest --benchmark-disable -v --slow -n auto
218
221
  ```
219
222
 
220
223
  ## Contributing
221
- Contributions to Charli3 Dendrite are welcome! Please refer to the `CONTRIBUTING.md` file for guidelines on how to contribute to the project.
224
+ Contributions to Charli3 Dendrite are welcome! Please refer to the [CONTRIBUTING.md](./CONTRIBUTING.md) file for guidelines on how to contribute to the project.
222
225
 
@@ -1,202 +1,203 @@
1
- <div align="center">
2
- <h1 align="center">Charli3 Dendrite</h1>
3
- <p align="center">Python SDK for interacting with Cardano DEXs</p>
4
- <p>
5
- <img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python version">
6
- <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License">
7
- <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs welcome">
8
- </p>
9
- </div>
10
-
11
- ## Overview
12
-
13
- Charli3 Dendrite is a powerful Python SDK designed for seamless interaction with multiple Decentralized Exchanges (DEXs) on the Cardano blockchain. It provides a unified interface for developers to access various DEX functionalities, simplifying the process of building applications in the Cardano ecosystem.
14
-
15
- ## Key Features
16
-
17
- - 🔄 Multi-DEX Support: Integrate with Minswap, MuesliSwap, Spectrum, SundaeSwap, VyFi, GeniusYield, Axo, and WingRiders
18
- - 💧 Liquidity Pool Data: Fetch and analyze pool information across different DEXs
19
- - 💱 Swap Operations: Execute token swaps with ease
20
- - 🧩 Flexible Asset Handling: Manage various asset types and pool states efficiently
21
- - 🔗 On-chain Data Integration: Connect with DB-sync, BlockFrost, and Ogmios/Kupo
22
- - 🛠 Extensible Architecture: Easily add support for new DEXs and features
23
-
24
-
25
- ## Installation
26
-
27
- ```bash
28
- # Using pip
29
- pip install charli3_dendrite
30
-
31
- # Using Poetry
32
- poetry add charli3_dendrite
33
- ```
34
-
35
- ## Supported DEXs
36
- Charli3 Dendrite currently supports the following Cardano DEXs:
37
-
38
- - Minswap
39
- - MuesliSwap
40
- - Spectrum
41
- - SundaeSwap
42
- - VyFi
43
- - WingRiders
44
- - GeniusYield
45
- - Axo
46
-
47
- ### Not Yet Implemented
48
-
49
- - CardanoSwaps
50
- - Metadex
51
- - CSwap
52
- - TeddySwap
53
- - Cerra
54
- - SaturnSwap
55
- - Splash
56
-
57
- Each DEX is implemented as a separate module within the `charli3_dendrite.dexs.amm` package.
58
-
59
- ## Configuration
60
- Charli3 Dendrite can be configured using environment variables or a `.env` file. See `sample.env` for an example of the configuration options.
61
-
62
- ### Backend Configuration
63
-
64
- Charli3 Dendrite supports multiple backend options for interacting with the Cardano blockchain:
65
-
66
- #### DBSync Configuration
67
-
68
- To use a DBSync instance as the blockchain connection, set the following environment variables:
69
-
70
- ```bash
71
- DBSYNC_HOST="your-dbsync-host"
72
- DBSYNC_PORT="your-dbsync-port"
73
- DBSYNC_DB_NAME="your-dbsync-database-name"
74
- DBSYNC_USER="your-dbsync-username"
75
- DBSYNC_PASS="your-dbsync-password"
76
- ```
77
-
78
- #### BlockFrost Configuration
79
-
80
- To use BlockFrost as the backend, set the following environment variables:
81
-
82
- ```bash
83
- BLOCKFROST_PROJECT_ID="your-blockfrost-project-id"
84
- CARDANO_NETWORK="mainnet" # or "testnet" for the Cardano testnet
85
- ```
86
-
87
- #### Ogmios/Kupo Configuration
88
-
89
- To use Ogmios and Kupo as the backend, set the following environment variables:
90
-
91
- ```bash
92
- OGMIOS_URL="ws://your-ogmios-url:port"
93
- KUPO_URL="http://your-kupo-url:port"
94
- CARDANO_NETWORK="mainnet" # or "testnet" for the Cardano testnet
95
- ```
96
-
97
- The backend will be automatically selected based on the available environment variables. If multiple backend configurations are present, the priority order is: DBSync, BlockFrost, Ogmios/Kupo.
98
-
99
- ### Backend Limitations
100
-
101
- While Charli3 Dendrite supports multiple backends, it's important to note that the BlockFrost and Ogmios/Kupo backends have some limitations compared to the DBSync backend:
102
-
103
- - **BlockFrost Backend**: Due to limitations in the BlockFrost API, the following methods are not implemented:
104
- - `get_historical_order_utxos`
105
- - `get_order_utxos_by_block_or_tx`
106
- - `get_cancel_utxos`
107
- - `get_axo_target`
108
-
109
- - **Ogmios/Kupo Backend**: The Ogmios/Kupo backend also has limitations due to the nature of these services:
110
- - `get_historical_order_utxos`
111
- - `get_order_utxos_by_block_or_tx`
112
- - `get_cancel_utxos`
113
-
114
- These methods will raise a `NotImplementedError` when called using the BlockFrost or Ogmios/Kupo backends. If your application requires these functionalities, consider using the DBSync backend.
115
-
116
- ## Usage
117
-
118
- ### Retrieving Orders and Pool Data
119
-
120
- To retrieve orders and pool data, first configure the global backend:
121
-
122
- ```python
123
- from charli3_dendrite.backend import set_backend, get_backend
124
- from charli3_dendrite.backend.dbsync import DbsyncBackend
125
- from charli3_dendrite.backend.blockfrost import BlockFrostBackend
126
- from charli3_dendrite.backend.ogmios_kupo import OgmiosKupoBackend
127
- from pycardano import Network
128
-
129
- # Choose one of the following backends:
130
- # set_backend(DbsyncBackend())
131
- # set_backend(BlockFrostBackend("your-project-id"))
132
- set_backend(OgmiosKupoBackend("ws://ogmios-url:port", "http://kupo-url:port", Network.MAINNET))
133
-
134
- backend = get_backend()
135
- ```
136
-
137
- The `AbstractBackend` interface offers methods for interacting with the Cardano blockchain, regardless of the underlying data source. This abstraction allows seamless switching between different backends without changing your application code.
138
-
139
- To retrieve pool information, use the `pool_selector` method provided by each DEX's state class:
140
-
141
- ```python
142
- from charli3_dendrite import VyFiCPPState
143
-
144
- selector = VyFiCPPState.pool_selector()
145
- result = backend.get_pool_utxos(
146
- limit=100000,
147
- historical=False,
148
- **selector.model_dump(),
149
- )
150
- ```
151
- To process and parse the retrieved results (`list[PoolStateInfo]`), the following approach can be utilized:
152
- ```python
153
- pool_data = {}
154
- total_tvl = 0
155
- for pool in result:
156
- d = dex.model_validate(pool.model_dump())
157
- try:
158
- logger.info("Get TVL %s", d.tvl)
159
- logger.info("Price %s", d.price)
160
- logger.info("Token name of asset A: %s", d.unit_a)
161
- logger.info("Token name of asset B: %s", d.unit_b)
162
- except NoAssetsError:
163
- pass
164
- except InvalidLPError:
165
- pass
166
- except InvalidPoolError:
167
- pass
168
- except Exception as e:
169
- logger.debug(f"{dex.__name__}: {e}")
170
- ```
171
- This approach is applicable across all supported DEXs. For example, the following list of AbstractPoolState subclasses can be defined to support various DEX states:
172
- ```python
173
- DEXS: list[AbstractPoolState] = [
174
- GeniusYieldOrderState,
175
- MinswapCPPState,
176
- MinswapV2CPPState,
177
- MinswapDJEDiUSDStableState,
178
- MinswapDJEDUSDCStableState,
179
- MinswapDJEDUSDMStableState,
180
- MuesliSwapCPPState,
181
- SpectrumCPPState,
182
- SundaeSwapCPPState,
183
- SundaeSwapV3CPPState,
184
- VyFiCPPState,
185
- WingRidersCPPState,
186
- WingRidersSSPState,
187
- ]
188
- ```
189
- ## Development
190
- To set up the development environment:
191
-
192
- 1. Clone the repository
193
- 2. Install dependencies: `poetry install`
194
- 3. Set up pre-commit hooks: `pre-commit install`
195
-
196
- ## Running Tests
197
- ```bash
198
- poetry run pytest --benchmark-disable -v --slow -n auto
199
- ```
200
-
201
- ## Contributing
202
- Contributions to Charli3 Dendrite are welcome! Please refer to the `CONTRIBUTING.md` file for guidelines on how to contribute to the project.
1
+ <div align="center">
2
+ <h1 align="center">Charli3 Dendrite</h1>
3
+ <p align="center">Python SDK for interacting with Cardano DEXs</p>
4
+ <p>
5
+ <img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python version">
6
+ <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License">
7
+ <img src="https://img.shields.io/pypi/dm/charli3-dendrite?style=flat-square" />
8
+ <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs welcome">
9
+ </p>
10
+ </div>
11
+
12
+ ## Overview
13
+
14
+ Charli3 Dendrite is a powerful Python SDK designed for seamless interaction with multiple Decentralized Exchanges (DEXs) on the Cardano blockchain. It provides a unified interface for developers to access various DEX functionalities, simplifying the process of building applications in the Cardano ecosystem.
15
+
16
+ ## Key Features
17
+
18
+ - 🔄 Multi-DEX Support: Integrate with Minswap, MuesliSwap, Spectrum, SundaeSwap, VyFi, GeniusYield, Axo, and WingRiders
19
+ - 💧 Liquidity Pool Data: Fetch and analyze pool information across different DEXs
20
+ - 💱 Swap Operations: Execute token swaps with ease
21
+ - 🧩 Flexible Asset Handling: Manage various asset types and pool states efficiently
22
+ - 🔗 On-chain Data Integration: Connect with DB-sync, BlockFrost, and Ogmios/Kupo
23
+ - 🛠 Extensible Architecture: Easily add support for new DEXs and features
24
+
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ # Using pip
30
+ pip install charli3_dendrite
31
+
32
+ # Using Poetry
33
+ poetry add charli3_dendrite
34
+ ```
35
+
36
+ ## Supported DEXs
37
+ Charli3 Dendrite currently supports the following Cardano DEXs:
38
+
39
+ - Minswap
40
+ - MuesliSwap
41
+ - Spectrum
42
+ - SundaeSwap
43
+ - VyFi
44
+ - WingRiders
45
+ - GeniusYield
46
+ - Axo
47
+
48
+ ### Not Yet Implemented
49
+
50
+ - CardanoSwaps
51
+ - Metadex
52
+ - CSwap
53
+ - TeddySwap
54
+ - Cerra
55
+ - SaturnSwap
56
+ - Splash
57
+
58
+ Each DEX is implemented as a separate module within the `charli3_dendrite.dexs.amm` package.
59
+
60
+ ## Configuration
61
+ Charli3 Dendrite can be configured using environment variables or a `.env` file. See `sample.env` for an example of the configuration options.
62
+
63
+ ### Backend Configuration
64
+
65
+ Charli3 Dendrite supports multiple backend options for interacting with the Cardano blockchain:
66
+
67
+ #### DBSync Configuration
68
+
69
+ To use a DBSync instance as the blockchain connection, set the following environment variables:
70
+
71
+ ```bash
72
+ DBSYNC_HOST="your-dbsync-host"
73
+ DBSYNC_PORT="your-dbsync-port"
74
+ DBSYNC_DB_NAME="your-dbsync-database-name"
75
+ DBSYNC_USER="your-dbsync-username"
76
+ DBSYNC_PASS="your-dbsync-password"
77
+ ```
78
+
79
+ #### BlockFrost Configuration
80
+
81
+ To use BlockFrost as the backend, set the following environment variables:
82
+
83
+ ```bash
84
+ BLOCKFROST_PROJECT_ID="your-blockfrost-project-id"
85
+ CARDANO_NETWORK="mainnet" # or "testnet" for the Cardano testnet
86
+ ```
87
+
88
+ #### Ogmios/Kupo Configuration
89
+
90
+ To use Ogmios and Kupo as the backend, set the following environment variables:
91
+
92
+ ```bash
93
+ OGMIOS_URL="ws://your-ogmios-url:port"
94
+ KUPO_URL="http://your-kupo-url:port"
95
+ CARDANO_NETWORK="mainnet" # or "testnet" for the Cardano testnet
96
+ ```
97
+
98
+ The backend will be automatically selected based on the available environment variables. If multiple backend configurations are present, the priority order is: DBSync, BlockFrost, Ogmios/Kupo.
99
+
100
+ ### Backend Limitations
101
+
102
+ While Charli3 Dendrite supports multiple backends, it's important to note that the BlockFrost and Ogmios/Kupo backends have some limitations compared to the DBSync backend:
103
+
104
+ - **BlockFrost Backend**: Due to limitations in the BlockFrost API, the following methods are not implemented:
105
+ - `get_historical_order_utxos`
106
+ - `get_order_utxos_by_block_or_tx`
107
+ - `get_cancel_utxos`
108
+ - `get_axo_target`
109
+
110
+ - **Ogmios/Kupo Backend**: The Ogmios/Kupo backend also has limitations due to the nature of these services:
111
+ - `get_historical_order_utxos`
112
+ - `get_order_utxos_by_block_or_tx`
113
+ - `get_cancel_utxos`
114
+
115
+ These methods will raise a `NotImplementedError` when called using the BlockFrost or Ogmios/Kupo backends. If your application requires these functionalities, consider using the DBSync backend.
116
+
117
+ ## Usage
118
+
119
+ ### Retrieving Orders and Pool Data
120
+
121
+ To retrieve orders and pool data, first configure the global backend:
122
+
123
+ ```python
124
+ from charli3_dendrite.backend import set_backend, get_backend
125
+ from charli3_dendrite.backend.dbsync import DbsyncBackend
126
+ from charli3_dendrite.backend.blockfrost import BlockFrostBackend
127
+ from charli3_dendrite.backend.ogmios_kupo import OgmiosKupoBackend
128
+ from pycardano import Network
129
+
130
+ # Choose one of the following backends:
131
+ # set_backend(DbsyncBackend())
132
+ # set_backend(BlockFrostBackend("your-project-id"))
133
+ set_backend(OgmiosKupoBackend("ws://ogmios-url:port", "http://kupo-url:port", Network.MAINNET))
134
+
135
+ backend = get_backend()
136
+ ```
137
+
138
+ The `AbstractBackend` interface offers methods for interacting with the Cardano blockchain, regardless of the underlying data source. This abstraction allows seamless switching between different backends without changing your application code.
139
+
140
+ To retrieve pool information, use the `pool_selector` method provided by each DEX's state class:
141
+
142
+ ```python
143
+ from charli3_dendrite import VyFiCPPState
144
+
145
+ selector = VyFiCPPState.pool_selector()
146
+ result = backend.get_pool_utxos(
147
+ limit=100000,
148
+ historical=False,
149
+ **selector.model_dump(),
150
+ )
151
+ ```
152
+ To process and parse the retrieved results (`list[PoolStateInfo]`), the following approach can be utilized:
153
+ ```python
154
+ pool_data = {}
155
+ total_tvl = 0
156
+ for pool in result:
157
+ d = dex.model_validate(pool.model_dump())
158
+ try:
159
+ logger.info("Get TVL %s", d.tvl)
160
+ logger.info("Price %s", d.price)
161
+ logger.info("Token name of asset A: %s", d.unit_a)
162
+ logger.info("Token name of asset B: %s", d.unit_b)
163
+ except NoAssetsError:
164
+ pass
165
+ except InvalidLPError:
166
+ pass
167
+ except InvalidPoolError:
168
+ pass
169
+ except Exception as e:
170
+ logger.debug(f"{dex.__name__}: {e}")
171
+ ```
172
+ This approach is applicable across all supported DEXs. For example, the following list of AbstractPoolState subclasses can be defined to support various DEX states:
173
+ ```python
174
+ DEXS: list[AbstractPoolState] = [
175
+ GeniusYieldOrderState,
176
+ MinswapCPPState,
177
+ MinswapV2CPPState,
178
+ MinswapDJEDiUSDStableState,
179
+ MinswapDJEDUSDCStableState,
180
+ MinswapDJEDUSDMStableState,
181
+ MuesliSwapCPPState,
182
+ SpectrumCPPState,
183
+ SundaeSwapCPPState,
184
+ SundaeSwapV3CPPState,
185
+ VyFiCPPState,
186
+ WingRidersCPPState,
187
+ WingRidersSSPState,
188
+ ]
189
+ ```
190
+ ## Development
191
+ To set up the development environment:
192
+
193
+ 1. Clone the repository
194
+ 2. Install dependencies: `poetry install`
195
+ 3. Set up pre-commit hooks: `pre-commit install`
196
+
197
+ ## Running Tests
198
+ ```bash
199
+ poetry run pytest --benchmark-disable -v --slow -n auto
200
+ ```
201
+
202
+ ## Contributing
203
+ Contributions to Charli3 Dendrite are welcome! Please refer to the [CONTRIBUTING.md](./CONTRIBUTING.md) file for guidelines on how to contribute to the project.
@@ -1,51 +1,83 @@
1
- [tool.poetry]
2
- name = "charli3_dendrite"
3
- version = "1.1.1-dev7"
4
- description = ""
5
- authors = ["Elder Millenial <eldermillenial@protonmail.com>"]
6
- readme = "README.md"
7
- packages = [{ include = "charli3_dendrite", from = "src" }]
8
-
9
- [tool.poetry.dependencies]
10
- python = "^3.10"
11
- requests = "^2.31.0"
12
- pydantic = "^2.5.2"
13
- psycopg = { extras = ["binary", "pool"], version = "^3.1.13" }
14
- python-dotenv = "0.21.1"
15
- pycardano = "0.11.1"
16
- blockfrost-python = "^0.6.0"
17
-
18
-
19
- [tool.poetry.group.dev.dependencies]
20
- black = "^23.11.0"
21
- ruff = "^0.1.6"
22
- pre-commit = "^3.5.0"
23
- bump2version = "^1.0.1"
24
- isort = "^5.13.2"
25
- flake8 = "^6.1.0"
26
- mypy = "^1.7.1"
27
- pytest = "^7.4.3"
28
- pytest-benchmark = "^4.0.0"
29
- pytest-dependency = "^0.5.1"
30
- pytest-xdist = "^3.6.1"
31
- mkdocs = "^1.6.0"
32
- mkdocs-material = "^9.5.32"
33
- mkdocstrings = { extras = ["python"], version = "^0.25.2" }
34
-
35
-
36
- [tool.poetry.group.devs.dependencies]
37
- pytest-subtests = "^0.11.0"
38
-
39
- [build-system]
40
- requires = ["poetry-core"]
41
- build-backend = "poetry.core.masonry.api"
42
-
43
- [tool.isort]
44
- profile = "black"
45
-
46
- [tool.mypy]
47
- plugins = ["pydantic.mypy"]
48
-
49
- [[tool.mypy.overrides]]
50
- module = ["pycardano", "pycardano.*", "dotenv", "nox"]
51
- ignore_missing_imports = true
1
+ [tool.poetry]
2
+ name = "charli3_dendrite"
3
+ version = "1.1.1-dev12"
4
+ description = ""
5
+ authors = ["Elder Millenial <eldermillenial@protonmail.com>"]
6
+ readme = "README.md"
7
+ packages = [{ include = "charli3_dendrite", from = "src" }]
8
+
9
+ [tool.poetry.dependencies]
10
+ python = "^3.10"
11
+ requests = "^2.31.0"
12
+ pydantic = "^2.5.2"
13
+ psycopg = { extras = ["binary", "pool"], version = "^3.1.13" }
14
+ python-dotenv = "1.0.1"
15
+ pycardano = "0.12.2"
16
+ blockfrost-python = "^0.6.0"
17
+ bump-my-version = "^1.1.4"
18
+
19
+
20
+ [tool.poetry.group.dev.dependencies]
21
+ black = "^23.11.0"
22
+ ruff = "^0.1.6"
23
+ pre-commit = "^3.5.0"
24
+ isort = "^5.13.2"
25
+ flake8 = "^6.1.0"
26
+ mypy = "^1.7.1"
27
+ pytest = "^7.4.3"
28
+ pytest-benchmark = "^4.0.0"
29
+ pytest-dependency = "^0.5.1"
30
+ pytest-xdist = "^3.6.1"
31
+ mkdocs = "^1.6.0"
32
+ mkdocs-material = "^9.5.32"
33
+ mkdocstrings = { extras = ["python"], version = "^0.25.2" }
34
+ pytest-subtests = "^0.14.1"
35
+
36
+
37
+ [build-system]
38
+ requires = ["poetry-core"]
39
+ build-backend = "poetry.core.masonry.api"
40
+
41
+ [tool.isort]
42
+ profile = "black"
43
+
44
+ [tool.mypy]
45
+ plugins = ["pydantic.mypy"]
46
+
47
+ [[tool.mypy.overrides]]
48
+ module = ["pycardano", "pycardano.*", "dotenv", "nox"]
49
+ ignore_missing_imports = true
50
+
51
+ [tool.bumpversion]
52
+ current_version = "1.1.1-dev12"
53
+ parse = """(?x)
54
+ (?P<major>\\d+)\\.
55
+ (?P<minor>\\d+)\\.
56
+ (?P<patch>\\d+)
57
+ (\\-(?P<release>[a-z]+)(?P<dev>\\d+))?
58
+ """
59
+ serialize = [
60
+ "{major}.{minor}.{patch}-{release}{dev}",
61
+ "{major}.{minor}.{patch}",
62
+ ]
63
+ search = "{current_version}"
64
+ replace = "{new_version}"
65
+ regex = false
66
+ ignore_missing_version = false
67
+ tag = true
68
+ sign_tags = false
69
+ tag_name = "v{new_version}"
70
+ tag_message = "Bump version: {current_version} → {new_version}"
71
+ allow_dirty = false
72
+ commit = true
73
+ message = "Bump version: {current_version} → {new_version}"
74
+ commit_args = "--no-verify"
75
+
76
+ [tool.bumpversion.parts.release]
77
+ values = ["dev", "release"]
78
+ optional_value = "release"
79
+
80
+ [[tool.bumpversion.files]]
81
+ filename = "pyproject.toml"
82
+ search = "version = \"{current_version}\""
83
+ replace = "version = \"{new_version}\""