charli3_dendrite 1.1.1.dev1__tar.gz → 1.1.1.dev2__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.
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/LICENSE +21 -21
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/PKG-INFO +2 -2
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/README.md +202 -202
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/pyproject.toml +52 -52
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/__init__.py +18 -18
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/backend/__init__.py +128 -128
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/backend/backend_base.py +205 -205
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/backend/blockfrost/__init__.py +394 -394
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/backend/blockfrost/models.py +47 -47
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/backend/dbsync/__init__.py +754 -754
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/backend/dbsync/models.py +177 -177
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/backend/ogmios_kupo/__init__.py +564 -564
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/backend/ogmios_kupo/models.py +84 -84
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/backend/utils.py +42 -42
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dataclasses/__init__.py +1 -1
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dataclasses/datums.py +170 -170
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dataclasses/models.py +273 -273
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/amm/__init__.py +1 -1
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/amm/amm_base.py +517 -517
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/amm/amm_types.py +427 -427
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/amm/minswap.py +1130 -1130
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/amm/muesli.py +334 -334
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/amm/spectrum.py +416 -416
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/amm/sundae.py +726 -726
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/amm/vyfi.py +343 -343
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/amm/wingriders.py +407 -407
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/core/__init__.py +1 -1
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/core/base.py +251 -251
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/core/errors.py +25 -25
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/ob/axo.py +695 -695
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/ob/geniusyield.py +761 -761
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/ob/ob_base.py +420 -420
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/utility.py +169 -169
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/dexs/__init__.py +0 -0
- {charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/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
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: charli3_dendrite
|
|
3
|
-
Version: 1.1.1.
|
|
3
|
+
Version: 1.1.1.dev2
|
|
4
4
|
Summary:
|
|
5
5
|
Author: Elder Millenial
|
|
6
6
|
Author-email: eldermillenial@protonmail.com
|
|
@@ -9,7 +9,7 @@ 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
|
-
Requires-Dist: blockfrost-python (>=0.
|
|
12
|
+
Requires-Dist: blockfrost-python (>=0.6.0,<0.7.0)
|
|
13
13
|
Requires-Dist: ogmios (==1.1.1)
|
|
14
14
|
Requires-Dist: psycopg[binary,pool] (>=3.1.13,<4.0.0)
|
|
15
15
|
Requires-Dist: pycardano (==0.11.1)
|
|
@@ -1,202 +1,202 @@
|
|
|
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/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,52 +1,52 @@
|
|
|
1
|
-
[tool.poetry]
|
|
2
|
-
name = "charli3_dendrite"
|
|
3
|
-
version = "1.1.1-
|
|
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.
|
|
17
|
-
ogmios = "1.1.1"
|
|
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
|
-
bump2version = "^1.0.1"
|
|
25
|
-
isort = "^5.13.2"
|
|
26
|
-
flake8 = "^6.1.0"
|
|
27
|
-
mypy = "^1.7.1"
|
|
28
|
-
pytest = "^7.4.3"
|
|
29
|
-
pytest-benchmark = "^4.0.0"
|
|
30
|
-
pytest-dependency = "^0.5.1"
|
|
31
|
-
pytest-xdist = "^3.6.1"
|
|
32
|
-
mkdocs = "^1.6.0"
|
|
33
|
-
mkdocs-material = "^9.5.32"
|
|
34
|
-
mkdocstrings = {extras = ["python"], version = "^0.25.2"}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[tool.poetry.group.devs.dependencies]
|
|
38
|
-
pytest-subtests = "^0.11.0"
|
|
39
|
-
|
|
40
|
-
[build-system]
|
|
41
|
-
requires = ["poetry-core"]
|
|
42
|
-
build-backend = "poetry.core.masonry.api"
|
|
43
|
-
|
|
44
|
-
[tool.isort]
|
|
45
|
-
profile = "black"
|
|
46
|
-
|
|
47
|
-
[tool.mypy]
|
|
48
|
-
plugins = [
|
|
49
|
-
|
|
50
|
-
[[tool.mypy.overrides]]
|
|
51
|
-
module = ["pycardano","pycardano.*", "dotenv", "nox"]
|
|
52
|
-
ignore_missing_imports = true
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "charli3_dendrite"
|
|
3
|
+
version = "1.1.1-dev2"
|
|
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
|
+
ogmios = "1.1.1"
|
|
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
|
+
bump2version = "^1.0.1"
|
|
25
|
+
isort = "^5.13.2"
|
|
26
|
+
flake8 = "^6.1.0"
|
|
27
|
+
mypy = "^1.7.1"
|
|
28
|
+
pytest = "^7.4.3"
|
|
29
|
+
pytest-benchmark = "^4.0.0"
|
|
30
|
+
pytest-dependency = "^0.5.1"
|
|
31
|
+
pytest-xdist = "^3.6.1"
|
|
32
|
+
mkdocs = "^1.6.0"
|
|
33
|
+
mkdocs-material = "^9.5.32"
|
|
34
|
+
mkdocstrings = { extras = ["python"], version = "^0.25.2" }
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
[tool.poetry.group.devs.dependencies]
|
|
38
|
+
pytest-subtests = "^0.11.0"
|
|
39
|
+
|
|
40
|
+
[build-system]
|
|
41
|
+
requires = ["poetry-core"]
|
|
42
|
+
build-backend = "poetry.core.masonry.api"
|
|
43
|
+
|
|
44
|
+
[tool.isort]
|
|
45
|
+
profile = "black"
|
|
46
|
+
|
|
47
|
+
[tool.mypy]
|
|
48
|
+
plugins = ["pydantic.mypy"]
|
|
49
|
+
|
|
50
|
+
[[tool.mypy.overrides]]
|
|
51
|
+
module = ["pycardano", "pycardano.*", "dotenv", "nox"]
|
|
52
|
+
ignore_missing_imports = true
|
{charli3_dendrite-1.1.1.dev1 → charli3_dendrite-1.1.1.dev2}/src/charli3_dendrite/__init__.py
RENAMED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# noqa
|
|
2
|
-
from charli3_dendrite.dexs.amm.minswap import MinswapCPPState
|
|
3
|
-
from charli3_dendrite.dexs.amm.minswap import MinswapDJEDiUSDStableState
|
|
4
|
-
from charli3_dendrite.dexs.amm.minswap import MinswapDJEDUSDCStableState
|
|
5
|
-
from charli3_dendrite.dexs.amm.minswap import MinswapDJEDUSDMStableState
|
|
6
|
-
from charli3_dendrite.dexs.amm.minswap import MinswapV2CPPState
|
|
7
|
-
from charli3_dendrite.dexs.amm.muesli import MuesliSwapCLPState
|
|
8
|
-
from charli3_dendrite.dexs.amm.muesli import MuesliSwapCPPState
|
|
9
|
-
from charli3_dendrite.dexs.amm.spectrum import SpectrumCPPState
|
|
10
|
-
from charli3_dendrite.dexs.amm.sundae import SundaeSwapCPPState
|
|
11
|
-
from charli3_dendrite.dexs.amm.sundae import SundaeSwapV3CPPState
|
|
12
|
-
from charli3_dendrite.dexs.amm.vyfi import VyFiCPPState
|
|
13
|
-
from charli3_dendrite.dexs.amm.wingriders import WingRidersCPPState
|
|
14
|
-
from charli3_dendrite.dexs.amm.wingriders import WingRidersSSPState
|
|
15
|
-
from charli3_dendrite.dexs.ob.axo import AxoOBMarketState
|
|
16
|
-
from charli3_dendrite.dexs.ob.geniusyield import GeniusYieldOrderBook
|
|
17
|
-
from charli3_dendrite.dexs.ob.geniusyield import GeniusYieldOrderState
|
|
18
|
-
from charli3_dendrite.utility import Assets
|
|
1
|
+
# noqa
|
|
2
|
+
from charli3_dendrite.dexs.amm.minswap import MinswapCPPState
|
|
3
|
+
from charli3_dendrite.dexs.amm.minswap import MinswapDJEDiUSDStableState
|
|
4
|
+
from charli3_dendrite.dexs.amm.minswap import MinswapDJEDUSDCStableState
|
|
5
|
+
from charli3_dendrite.dexs.amm.minswap import MinswapDJEDUSDMStableState
|
|
6
|
+
from charli3_dendrite.dexs.amm.minswap import MinswapV2CPPState
|
|
7
|
+
from charli3_dendrite.dexs.amm.muesli import MuesliSwapCLPState
|
|
8
|
+
from charli3_dendrite.dexs.amm.muesli import MuesliSwapCPPState
|
|
9
|
+
from charli3_dendrite.dexs.amm.spectrum import SpectrumCPPState
|
|
10
|
+
from charli3_dendrite.dexs.amm.sundae import SundaeSwapCPPState
|
|
11
|
+
from charli3_dendrite.dexs.amm.sundae import SundaeSwapV3CPPState
|
|
12
|
+
from charli3_dendrite.dexs.amm.vyfi import VyFiCPPState
|
|
13
|
+
from charli3_dendrite.dexs.amm.wingriders import WingRidersCPPState
|
|
14
|
+
from charli3_dendrite.dexs.amm.wingriders import WingRidersSSPState
|
|
15
|
+
from charli3_dendrite.dexs.ob.axo import AxoOBMarketState
|
|
16
|
+
from charli3_dendrite.dexs.ob.geniusyield import GeniusYieldOrderBook
|
|
17
|
+
from charli3_dendrite.dexs.ob.geniusyield import GeniusYieldOrderState
|
|
18
|
+
from charli3_dendrite.utility import Assets
|