Skip to content

Commit 19415ef

Browse files
committed
v1.0.0 - Major Improvements (See desc)
- Added default network RPC url - Removed the need to provide a DEX - Fixed rewards check for Trader Joe positions - Integrated transaction receipt class - Multiple other small bugfixes and improvements
1 parent 385c0fc commit 19415ef

14 files changed

Lines changed: 2876 additions & 145 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,4 @@ package_testing.ipynb
151151
Result/*
152152
dev_ref/*
153153
testing.py
154+
tests/report.csv

README.md

Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<h3><strong>Current Supported Networks</strong></h3>
1313
<i>Avalanche</i><br>
1414
<i><del>Ethereum</del> (WIP)</i><br>
15-
<i><del>Fantom</del> (WIP)</i><br>
1615
</div>
1716
<br>
1817

@@ -56,15 +55,12 @@ How to use the package:
5655
from alpha_homora_v2.position import AvalanchePosition
5756
```
5857

59-
2. Create your Web3 provider object to interact with the network:
58+
2. **(Optional)** Create your Web3 provider object to interact with the network:
6059
```python
6160
NETWORK_RPC_URL = "your_rpc_url"
62-
63-
provider = get_provider(NETWORK_RPC_URL)
61+
provider = get_web3_provider(NETWORK_RPC_URL)
6462
```
65-
6663
3. Creating an [AvalanchePosition](alpha_homora_v2/position.py) instance requires the following:
67-
- A web3 provider object
6864
- Your position ID (an integer)
6965
- This ID should match your position on Alpha Homora, without the "#"
7066
- ![demo](img/id_highlight.png)
@@ -74,26 +70,39 @@ How to use the package:
7470
- This parameter should exactly match the token symbol/pair displayed on your Alpha Homora as shown below.
7571
- ![demo](img/token_highlight.png)
7672
-->
77-
73+
<!--- DEPRECATED
7874
- The DEX identifier (a string)
7975
- This parameter should exactly match the DEX identifier displayed on your Alpha Homora position as shown below.
8076
- ![demo](img/dex_highlight.png)
81-
- your public and private wallet keys (both a string)
82-
- Your private key is required to sign transactions
77+
-->
78+
79+
- your public wallet key
80+
- **(Optional)** your private wallet key
81+
- Your private key is required to sign transactional methods
82+
- **(Optional)** A web3 provider object
83+
- If none is passed, an HTTP provider will be created with the [default Avalanche RPC URL](https://api.avax.network/ext/bc/C/rpc)
8384

8485
Once you've gathered all of these variables, you can create the position instance like this example below:
8586
```python
8687
position = AvalanchePosition(
87-
web3_provider=provider,
8888
position_id=11049,
89-
dex="Pangolin V2",
9089
owner_wallet_address="0x...",
91-
owner_private_key="123abc456efg789hij..." # (Optional - see step 4)
92-
)
90+
owner_private_key="123abc456efg789hij...", # <- Optional - see step 4
91+
web3_provider=provider) # <- Optional If you'd like to use a custom provider
9392
```
94-
4. Use your position instance to interact with the Alpha Homora V2 position smart contracts on the network:
93+
4. Alternatively, get all open positions ([AvalanchePosition](alpha_homora_v2/position.py) objects) by owner wallet address:
94+
```python
95+
from alpha_homora_v2.position import get_avax_positions_by_owner
96+
97+
positions = get_avax_positions_by_owner(owner_address="owner_wallet_address",
98+
owner_private_key="owner_private_key", # <- Optional
99+
web3_provider=provider) # <- Optional
100+
101+
# NOTE: Passing the private key is optional, but required if you want to use transactional methods on the returned AvalanchePosition object(s).
102+
```
103+
5. Use your position instance(s) to interact with the Alpha Homora V2 position smart contracts on the network:
95104
- Informational Methods
96-
- Return data like a JSON API
105+
- Return JSON data
97106
- Private wallet key ***not required*** for use
98107
```python
99108
# Get value of harvestable rewards:
@@ -102,17 +111,20 @@ How to use the package:
102111
# Get current debt ratio:
103112
position.get_debt_ratio()
104113

114+
# Get the current leverage ratio:
115+
position.get_leverage_ratio()
116+
105117
# Get position value (equity, debt, and position value):
106118
position.get_position_value()
107119

108-
# get LP pool info:
109-
position.get_pool_info()
110-
111-
# (WIP) Get current pool APY
120+
# (WIP) Get current pool APY (Only returns trading and farmng APY)
112121
position.get_current_apy()
122+
123+
# get LP pool info:
124+
position.pool
113125
```
114126
- Transactional Methods:
115-
- Return a [TransactionReceipt](alpha_homora_v2/receipt.py) object with success
127+
- Return a [TransactionReceipt](alpha_homora_v2/receipt.py) object upon success
116128
- Private wallet key ***required*** for use to sign transactions
117129
```python
118130
# Harvest available rewards:
@@ -129,15 +141,26 @@ Uninstall the package like any other Python package using the pip uninstall comm
129141
pip uninstall alpha-homora-v2
130142
```
131143
132-
## Roadmap:
133-
134-
- [x] Get position value of equity and debt
135-
- [x] Get current debt ratio
136-
- [ ] Get outstanding rewards value in native rewards token and USD
137-
- [x] Pangolin V2
138-
- [ ] Trader Joe
139-
- [ ] Get current pool APY
140-
- [ ] Integrate with All Supported Alpha Homora V2 Networks:
141-
- [x] Avalanche
142-
- [ ] Ethereum
143-
- [ ] Fantom
144+
## Feature Roadmap:
145+
146+
- [ ] Avalanche:
147+
- [x] Get all open positions by owner wallet address
148+
- [x] Harvest Position Rewards
149+
- [x] Close Position
150+
- [x] Get position value of equity and debt
151+
- [x] Get current debt ratio
152+
- [ ] Get outstanding rewards value in native rewards token and USD
153+
- [x] Pangolin V2
154+
- [ ] Trader Joe
155+
- [ ] Get current pool APY
156+
- [ ] Add Liquidity
157+
- [ ] Remove Liquidity
158+
- [ ] Ethereum:
159+
- [ ] Harvest Position Rewards
160+
- [ ] Close Position
161+
- [ ] Get position value of equity and debt
162+
- [ ] Get current debt ratio
163+
- [ ] Get outstanding rewards value in native rewards token and USD
164+
- [ ] Get current pool APY
165+
- [ ] Add Liquidity
166+
- [ ] Remove Liquidity
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
[
2+
{
3+
"inputs": [
4+
{
5+
"internalType": "uint256",
6+
"name": "",
7+
"type": "uint256"
8+
}
9+
],
10+
"name": "poolInfo",
11+
"outputs": [
12+
{
13+
"internalType": "contract IERC20",
14+
"name": "lpToken",
15+
"type": "address"
16+
},
17+
{
18+
"internalType": "uint96",
19+
"name": "allocPoint",
20+
"type": "uint96"
21+
},
22+
{
23+
"internalType": "uint256",
24+
"name": "accJoePerShare",
25+
"type": "uint256"
26+
},
27+
{
28+
"internalType": "uint256",
29+
"name": "accJoePerFactorPerShare",
30+
"type": "uint256"
31+
},
32+
{
33+
"internalType": "uint64",
34+
"name": "lastRewardTimestamp",
35+
"type": "uint64"
36+
},
37+
{
38+
"internalType": "contract IRewarder",
39+
"name": "rewarder",
40+
"type": "address"
41+
},
42+
{
43+
"internalType": "uint32",
44+
"name": "veJoeShareBp",
45+
"type": "uint32"
46+
},
47+
{
48+
"internalType": "uint256",
49+
"name": "totalFactor",
50+
"type": "uint256"
51+
},
52+
{
53+
"internalType": "uint256",
54+
"name": "totalLpSupply",
55+
"type": "uint256"
56+
}
57+
],
58+
"stateMutability": "view",
59+
"type": "function"
60+
},
61+
{
62+
"inputs": [
63+
{
64+
"internalType": "uint256",
65+
"name": "",
66+
"type": "uint256"
67+
},
68+
{
69+
"internalType": "address",
70+
"name": "",
71+
"type": "address"
72+
}
73+
],
74+
"name": "userInfo",
75+
"outputs": [
76+
{
77+
"internalType": "uint256",
78+
"name": "amount",
79+
"type": "uint256"
80+
},
81+
{
82+
"internalType": "uint256",
83+
"name": "rewardDebt",
84+
"type": "uint256"
85+
},
86+
{
87+
"internalType": "uint256",
88+
"name": "factor",
89+
"type": "uint256"
90+
}
91+
],
92+
"stateMutability": "view",
93+
"type": "function"
94+
}
95+
]

0 commit comments

Comments
 (0)