Skip to content

Commit b964084

Browse files
committed
bugfixes
1 parent 1ed70f1 commit b964084

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ How to use the package:
5959
from alpha_homora_v2 import AvalanchePosition
6060
```
6161

62-
2. **(Optional)** Instantiate your custom Web3 provider object to interact with the network:
62+
<!-- 2. **(Optional)** Instantiate your custom Web3 provider object to interact with the network:
6363
```python
6464
from alpha_homora_v2.util import get_web3_provider
6565
6666
NETWORK_RPC_URL = "your_rpc_url"
6767
provider = get_web3_provider(NETWORK_RPC_URL)
68-
```
68+
``` -->
6969
3. Creating an [AvalanchePosition](alpha_homora_v2/position.py) instance requires the following:
7070
- Your position ID (an integer)
7171
- This ID should match your position on Alpha Homora, without the "#"
@@ -85,24 +85,24 @@ How to use the package:
8585
- your public wallet key
8686
- **(Optional)** your private wallet key
8787
- Your private key is required to sign transactional methods
88-
- **(Optional)** A web3 provider object
89-
- If none is passed, an HTTP provider will be created with the [default Avalanche RPC URL](https://api.avax.network/ext/bc/C/rpc)
88+
<!-- - **(Optional)** A web3 provider object
89+
- If none is passed, an HTTP provider will be created with the [default Avalanche RPC URL](https://api.avax.network/ext/bc/C/rpc) -->
9090

9191
Once you've gathered all of these variables, you can create the position instance like this example below:
9292
```python
9393
position = AvalanchePosition(
9494
position_id=11049,
9595
owner_wallet_address="0x...",
96-
owner_private_key="123abc456efg789hij...", # <- Optional - see step 4
97-
web3_provider=provider) # <- Optional If you'd like to use a custom provider
96+
owner_private_key="123abc456efg789hij...") # <- Optional - see step 4
9897
```
98+
<!-- web3_provider=provider) # <- Optional If you'd like to use a custom provider -->
9999
4. Alternatively, get all open positions ([AvalanchePosition](alpha_homora_v2/position.py) objects) by owner wallet address:
100100
```python
101101
from alpha_homora_v2.position import get_avax_positions_by_owner
102102
103103
positions = get_avax_positions_by_owner(owner_address="owner_wallet_address",
104104
owner_private_key="owner_private_key", # <- Optional
105-
web3_provider=provider) # <- Optional
105+
)
106106
107107
# NOTE: Passing the private key is optional, but required if you want to use transactional methods on the returned AvalanchePosition object(s).
108108
```
@@ -148,7 +148,7 @@ How to use the package:
148148
position.get_pool_tokens()
149149
150150
# Get the debt of each token in the position (token, debt_uint256, debt_token, debt_usd):
151-
position.get_tokens_debts()
151+
position.get_token_debts()
152152
# Alternatively, get the debt of a single token:
153153
position.get_token_debts(token_address)
154154

alpha_homora_v2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .position import AvalanchePosition
22

3-
__version__ = "2.0.2"
3+
__version__ = "2.0.3"
44

alpha_homora_v2/position.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,11 @@ def get_position_value(self) -> dict:
380380
"debt_avax": debt_value_avax, "debt_usd": debt_value_usd,
381381
"position_avax": position_value_avax, "position_usd": position_value_usd}
382382

383-
def get_token_debts(self) -> list[tuple[ARC20Token, int, float, float]]:
383+
def get_token_debts(self, address: str = None) -> list[tuple[ARC20Token, int, float, float]]:
384384
"""
385-
Returns the debt amount per token for the position
385+
Returns the debt amount per token for the position.
386+
387+
:param address: (str) Optional address to get debt for a specific token
386388
387389
:return: list of tuples containing:
388390
- ARC20Token object
@@ -396,6 +398,9 @@ def get_token_debts(self) -> list[tuple[ARC20Token, int, float, float]]:
396398

397399
debt_output = []
398400
for token, debt in zip(r[0], r[1]):
401+
if address is not None and address.lower() != token.lower():
402+
continue
403+
399404
arc20_token = self.get_token(token)
400405
decimals = arc20_token.decimals()
401406
debt_token = debt / 10 ** decimals
@@ -406,6 +411,9 @@ def get_token_debts(self) -> list[tuple[ARC20Token, int, float, float]]:
406411
debt_usd = 0
407412
debt_output.append((arc20_token, debt, debt_token, debt_usd))
408413

414+
if len(debt_output) == 0:
415+
raise ValueError("Could not find a debt token matching the address: {}".format(address))
416+
409417
return debt_output
410418

411419
""" -------------------- UTILITY METHODS: -------------------- """

0 commit comments

Comments
 (0)