Skip to content

Commit a195d88

Browse files
authored
Merge pull request #9 from PathX-Projects/development
v2.0.2 - See description
2 parents c49a303 + 8f575fc commit a195d88

25 files changed

+1549
-241
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,5 @@ cython_debug/
150150
package_testing.ipynb
151151
Result/*
152152
dev_ref/*
153-
testing.py
154-
tests/report.csv
153+
testing*
154+
examples/report.csv

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
recursive-include alpha_homora_v2/abi *
2-
recursive-include alpha_homora_v2/resources *
2+
recursive-include alpha_homora_v2/resources *
3+
include requirements.txt

README.md

Lines changed: 60 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<!-- PROJECT HEADER -->
22
<div align="center">
3-
<a href ="https://homora-v2.alphaventuredao.io/"><img src="img/ahv2.png" alt="Alpha Homora V2 Logo" height="200"></a>
4-
<br></br>
3+
<a href ="https://homora-v2.alphaventuredao.io/"><img src="https://dappimg.com/media/image/dapp/bd46bacaa4f045d491d2723340590edf.blob" alt="Alpha Homora V2 Logo" height="200"></a>
4+
<br/>
55
<h2 align="center"><strong>Alpha-Homora-V2-Python</strong></h2>
6+
<a href="https://homora-v2.alphaventuredao.io/"><img src="https://img.shields.io/website?down_color=red&down_message=Disconnected&label=Alpha%20Homora%20V2&up_color=blue&up_message=Online&url=https%3A%2F%2Fhomora-v2.alphaventuredao.io%2F"/></a>
7+
<img src="https://img.shields.io/badge/Python-3.9%2B-yellow"/>
8+
<a href="https://github.com/PathX-Projects/Alpha-Homora-V2-Python/issues"><img src="https://img.shields.io/github/issues/PathX-Projects/Alpha-Homora-V2-Python?color=red"/></a>
69
<p align="center">
7-
A Python3.9+ package that models open Alpha Homora V2 positions to simplify interaction with their smart contracts in your Python projects.
10+
A Python3.9+ package that wraps Alpha Homora V2 positions to simplify interaction with their smart contracts in your Python projects.
811
</p>
912
<h3><strong>Current Features</strong></h3>
10-
<i>Get Rewards Value | Get Position Value | Get Debt Ratio | Get LP Info | <del>Get Current APY</del></i><br>
11-
<i>Harvest Rewards | Close Position</i><br>
13+
<i>Rewards Value | Position Value | Debt & Leverage Ratio | Pool Info | Current APY</i><br>
14+
<i>Harvest Rewards | Close Position | Add & Remove Liquidity</i><br>
1215
<h3><strong>Current Supported Networks</strong></h3>
1316
<i>Avalanche</i><br>
1417
<i><del>Ethereum</del> (WIP)</i><br>
@@ -21,6 +24,9 @@
2124
<ol>
2225
<li><a href="#installation">Installation</a></li>
2326
<li><a href="#usage">Usage</a></li>
27+
<ol>
28+
<li><a href="#avalanche">Avalanche</a></li>
29+
</ol>
2430
<li><a href="#uninstallation">Uninstallation</a></li>
2531
<li><a href="#roadmap">Roadmap</a></li>
2632
<li><a href="#contribution">Contribution</a></li>
@@ -33,38 +39,37 @@ This package is set up to be installed using the `pip` package manager.
3339

3440
1. Ensure that you have Python 3.9+ installed. If not, you can download [here](https://www.python.org/downloads/release/python-3912/). The syntax is dependent on features added in this recent version.
3541

36-
2. Install the package using pip (you must use the git+url as this project is private and not listed on PyPi):
42+
2. Install the package using pip:
3743
```bash
38-
pip install git+https://github.com/PathX-Projects/Alpha-Homora-V2-Python.git
44+
pip install --upgrade alpha-homora-v2
3945
```
4046

41-
***Note:*** You may need to provide your git credentials depending on the repository privacy settings. In the event, if you need help generating a personal access token see [here](https://catalyst.zoho.com/help/tutorials/githubbot/generate-access-token.html)
42-
43-
3. After install, the package will be available to you in your local Python environment as ***alpha_homora_v2***
47+
3. After install, the package will be available to you in your local Python environment as ***alpha-homora-v2***
4448

4549
When updates are made to the package, the version will automatically be incremented so that in order to get the newest version on your end, you can simply use the same installation command and your pip will detect and update to the newest version.
4650

4751
## Usage
4852

4953
How to use the package:
5054

51-
### For Avalanche Positions:
55+
### Avalanche:
5256

53-
1. Import the package into your Python script:
57+
1. Import the AvalanchePosition class into your Python script:
5458
```python
55-
from alpha_homora_v2.util import get_web3_provider
56-
from alpha_homora_v2.position import AvalanchePosition
59+
from alpha_homora_v2 import AvalanchePosition
5760
```
5861

59-
2. **(Optional)** Create your Web3 provider object to interact with the network:
62+
2. **(Optional)** Instantiate your custom Web3 provider object to interact with the network:
6063
```python
64+
from alpha_homora_v2.util import get_web3_provider
65+
6166
NETWORK_RPC_URL = "your_rpc_url"
6267
provider = get_web3_provider(NETWORK_RPC_URL)
6368
```
6469
3. Creating an [AvalanchePosition](alpha_homora_v2/position.py) instance requires the following:
6570
- Your position ID (an integer)
6671
- This ID should match your position on Alpha Homora, without the "#"
67-
- ![demo](img/id_highlight.png)
72+
![demo](https://github.com/PathX-Projects/Alpha-Homora-V2-Python/blob/main/img/id_highlight.png?raw=true)
6873

6974
<!--- DEPRECATED
7075
- The token symbol/pair (a string)
@@ -102,10 +107,31 @@ How to use the package:
102107
# NOTE: Passing the private key is optional, but required if you want to use transactional methods on the returned AvalanchePosition object(s).
103108
```
104109
5. Use your position instance(s) to interact with the Alpha Homora V2 position smart contracts on the network:
110+
- Transactional Methods:
111+
- Return a [TransactionReceipt](alpha_homora_v2/receipt.py) object upon success
112+
- Private wallet key ***required*** for use to sign transactions
113+
- See the documentation in the [AvalanchePosition](alpha_homora_v2/position.py) class for function parameters.
114+
```python
115+
# Add liquidity to the LP
116+
position.add(params)
117+
118+
# Remove liquidity from the LP
119+
position.remove(params)
120+
121+
# Harvest available rewards:
122+
position.harvest()
123+
124+
# Close the position:
125+
position.close()
126+
```
105127
- Informational Methods
106128
- Return JSON data
107129
- Private wallet key ***not required*** for use
130+
- See [`examples/position_info.ipynb`](https://github.com/PathX-Projects/Alpha-Homora-V2-Python/blob/development/examples/avalanche/position_info.ipynb) for output examples.
108131
```python
132+
# Get position value (equity, debt, and position value):
133+
position.get_position_value()
134+
109135
# Get value of harvestable rewards:
110136
position.get_rewards_value()
111137
@@ -115,25 +141,23 @@ How to use the package:
115141
# Get the current leverage ratio:
116142
position.get_leverage_ratio()
117143
118-
# Get position value (equity, debt, and position value):
119-
position.get_position_value()
120-
121-
# (WIP) Get current pool APY (Only returns trading and farmng APY)
144+
# Get current pool APY
122145
position.get_current_apy()
123146
147+
# Get underlying tokens and LP for the pool:
148+
position.get_pool_tokens()
149+
150+
# Get the debt of each token in the position (token, debt_uint256, debt_token, debt_usd):
151+
position.get_tokens_debts()
152+
# Alternatively, get the debt of a single token:
153+
position.get_token_debts(token_address)
154+
155+
# Get all token borrow rates from CREAM:
156+
position.get_cream_borrow_rates()
157+
124158
# get LP pool info:
125159
position.pool
126160
```
127-
- Transactional Methods:
128-
- Return a [TransactionReceipt](alpha_homora_v2/receipt.py) object upon success
129-
- Private wallet key ***required*** for use to sign transactions
130-
```python
131-
# Harvest available rewards:
132-
position.claim_all_rewards()
133-
134-
# Close the position:
135-
position.close()
136-
```
137161

138162
## Uninstallation:
139163

@@ -144,25 +168,26 @@ pip uninstall alpha-homora-v2
144168

145169
## Features:
146170

147-
- [ ] Avalanche:
171+
- [x] Avalanche:
148172
- [x] Get all open positions by owner wallet address
149173
- [x] Harvest Position Rewards
150174
- [x] Close Position
151175
- [x] Get position value of equity and debt
152176
- [x] Get current debt ratio
153177
- [x] Get outstanding rewards value in native rewards token and USD
154-
- [ ] Get current pool APY
155-
- [ ] Add Liquidity
156-
- [ ] Remove Liquidity
178+
- [x] Add Liquidity
179+
- [x] Remove Liquidity
180+
- [x] Get aggregate pool APY (incl. borrowAPY)
157181
- [ ] Ethereum:
182+
- [ ] Get all open positions by owner wallet address
158183
- [ ] Harvest Position Rewards
159184
- [ ] Close Position
160185
- [ ] Get position value of equity and debt
161186
- [ ] Get current debt ratio
162187
- [ ] Get outstanding rewards value in native rewards token and USD
163-
- [ ] Get current pool APY
164188
- [ ] Add Liquidity
165189
- [ ] Remove Liquidity
190+
- [ ] Get aggregate pool APY (incl. borrowAPY)
166191

167192
## Contribution:
168193

alpha_homora_v2/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .position import AvalanchePosition
2+
3+
__version__ = "2.0.2"
4+

alpha_homora_v2/_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Default RPC URLS:
2+
AVAX_RPC_URL = "https://api.avax.network/ext/bc/C/rpc"

0 commit comments

Comments
 (0)