44 <br ></br >
55 <h2 align =" center " ><strong >Alpha-Homora-V2-Python</strong ></h2 >
66 <p align="center">
7- A Python3.9+ package that models Alpha Homora V2 positions to simplify interaction with their smart contracts in your Python projects.
7+ A Python3.9+ package that models open Alpha Homora V2 positions to simplify interaction with their smart contracts in your Python projects.
88 </p>
99 <h3><strong>Current Features</strong></h3>
10- <i>Get Rewards Value | Get Position Value | Get Debt Ratio | Get LP Info</i><br>
10+ <i>Get Rewards Value | Get Position Value | Get Debt Ratio | Get LP Info | <del>Get Current APY</del> </i><br>
1111 <i>Harvest Rewards | Close Position</i><br>
12- <h3><strong>Current Supported DEXes </strong></h3>
13- <i>Pangolin V2 on Avalanche</i><br>
14- <i>Trader Joe on Avalanche </i><br>
12+ <h3><strong>Current Supported Networks </strong></h3>
13+ <i>Avalanche</i><br>
14+ <i><del>Ethereum</del> (WIP) </i><br>
1515</div >
1616<br >
1717
@@ -47,21 +47,20 @@ When updates are made to the package, the version will automatically be incremen
4747
4848How to use the package:
4949
50+ # ## For Avalanche Positions:
51+
50521. Import the package into your Python script:
5153 ` ` ` python
5254 from alpha_homora_v2.util import get_web3_provider
53- from alpha_homora_v2.position import AlphaHomoraV2Position
55+ from alpha_homora_v2.position import AvalanchePosition
5456 ` ` `
5557
56- 2. Create your Web3 provider object to interact with the network:
58+ 2. ** (Optional) ** Create your Web3 provider object to interact with the network:
5759 ` ` ` python
5860 NETWORK_RPC_URL = " your_rpc_url"
59-
6061 provider = get_web3_provider(NETWORK_RPC_URL)
6162 ` ` `
62-
63- 3. Creating an [AlphaHomoraV2Position](alpha_homora_v2/position.py) instance requires the following:
64- - A web3 provider object
63+ 3. Creating an [AvalanchePosition](alpha_homora_v2/position.py) instance requires the following:
6564 - Your position ID (an integer)
6665 - This ID should match your position on Alpha Homora, without the " #"
6766 - ! [demo](img/id_highlight.png)
@@ -71,48 +70,69 @@ How to use the package:
7170 - This parameter should exactly match the token symbol/pair displayed on your Alpha Homora as shown below.
7271 - ! [demo](img/token_highlight.png)
7372 -->
74-
73+ < ! --- DEPRECATED
7574 - The DEX identifier (a string)
7675 - This parameter should exactly match the DEX identifier displayed on your Alpha Homora position as shown below.
7776 - ! [demo](img/dex_highlight.png)
78- - your public and private wallet keys (both a string)
79- - 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)
8084
8185 Once you' ve gathered all of these variables, you can create the position instance like this example below:
8286 ```python
83- position = AlphaHomoraV2Position(
84- web3_provider=provider,
87+ position = AvalanchePosition(
8588 position_id=11049,
86- dex="Pangolin V2",
8789 owner_wallet_address="0x...",
88- owner_private_key="123abc456efg789hij..." # (Optional - see step 4)
89- )
90- ```
91- 4. Use your position instance to interact with the Alpha Homora V2 position smart contracts on the network:
92- ```python
93- """ Informational Methods (Private Key not Required) """
94- # Get value of harvestable rewards:
95- position.get_rewards_value()
96-
97- # Get current debt ratio:
98- position.get_debt_ratio()
99-
100- # Get position value (equity, debt, and position value):
101- position.get_position_value()
102-
103- # get LP pool info:
104- position.get_pool_info()
105-
106- # (WIP) Get current pool APY
107- position.get_current_apy()
108-
109- """ Transactional Methods (Private Key Required) """
110- # Harvest available rewards:
111- position.claim_all_rewards()
112-
113- # Close the position:
114- position.close()
90+ owner_private_key="123abc456efg789hij...", # <- Optional - see step 4
91+ web3_provider=provider) # <- Optional If you' d like to use a custom provider
11592 ` ` `
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:
104+ - Informational Methods
105+ - Return JSON data
106+ - Private wallet key *** not required*** for use
107+ ` ` ` python
108+ # Get value of harvestable rewards:
109+ position.get_rewards_value ()
110+
111+ # Get current debt ratio:
112+ position.get_debt_ratio ()
113+
114+ # Get the current leverage ratio:
115+ position.get_leverage_ratio ()
116+
117+ # Get position value (equity, debt, and position value):
118+ position.get_position_value ()
119+
120+ # (WIP) Get current pool APY (Only returns trading and farmng APY)
121+ position.get_current_apy ()
122+
123+ # get LP pool info:
124+ position.pool
125+ ` ` `
126+ - Transactional Methods:
127+ - Return a [TransactionReceipt](alpha_homora_v2/receipt.py) object upon success
128+ - Private wallet key *** required*** for use to sign transactions
129+ ` ` ` python
130+ # Harvest available rewards:
131+ position.claim_all_rewards ()
132+
133+ # Close the position:
134+ position.close ()
135+ ` ` `
116136
117137# # Uninstallation:
118138
@@ -121,15 +141,26 @@ Uninstall the package like any other Python package using the pip uninstall comm
121141pip uninstall alpha-homora-v2
122142` ` `
123143
124- ## Roadmap:
125-
126- 1. ~~Get position value of equity and debt~~
127- 2. ~~Get current debt ratio~~
128- 3. Get outstanding rewards value in native rewards token and USD
129- - ~~Pangolin V2~~
130- - Trader Joe
131- 4. Get current pool APY
132- 5. Integrate with Alpha Homora V2 Networks:
133- - ~~Avalanche~~
134- - Ethereum
135- - 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
0 commit comments