Skip to main content

An unofficial Python package that wraps Alpha Homora V2 position smart contracts.

Project description

Alpha Homora V2 Logo

Alpha-Homora-V2-Python

A Python3.9+ package that wraps Alpha Homora V2 positions to simplify interaction with their smart contracts in your Python projects.

Current Features

Rewards Value | Position Value | Debt & Leverage Ratio | Pool Info | Current APY
Harvest Rewards | Close Position | Add & Remove Liquidity

Current Supported Networks

Avalanche
Ethereum (WIP)

Table of Contents

  1. Installation
  2. Usage
    1. Avalanche
  3. Uninstallation
  4. Roadmap
  5. Contribution

Installation

This package is set up to be installed using the pip package manager.

  1. Ensure that you have Python 3.9+ installed. If not, you can download here. The syntax is dependent on features added in this recent version.

  2. Install the package using pip:

    pip install --upgrade alpha-homora-v2
    
  3. After install, the package will be available to you in your local Python environment as alpha-homora-v2

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.

Usage

How to use the package:

Avalanche:

  1. Import the AvalanchePosition class into your Python script:
    from alpha_homora_v2 import AvalanchePosition
    
  1. Creating an AvalanchePosition instance requires the following:

    • Your position ID (an integer)
      • This ID should match your position on Alpha Homora, without the "#" demo
    • your public wallet key
    • (Optional) your private wallet key
      • Your private key is required to sign transactional methods

    Once you've gathered all of these variables, you can create the position instance like this example below:

    position = AvalanchePosition(
               position_id=11049,
               owner_wallet_address="0x...",
               owner_private_key="123abc456efg789hij...") # <- Optional - see step 4
    
  2. Alternatively, get all open positions (AvalanchePosition objects) by owner wallet address:

    from alpha_homora_v2.position import get_avax_positions_by_owner
    
    positions = get_avax_positions_by_owner(owner_address="owner_wallet_address",
                                            owner_private_key="owner_private_key", # <- Optional
                                            )
    
    # NOTE: Passing the private key is optional, but required if you want to use transactional methods on the returned AvalanchePosition object(s).
    
  3. Use your position instance(s) to interact with the Alpha Homora V2 position smart contracts on the network:

    • Transactional Methods:
      • Return a TransactionReceipt object upon success
      • Private wallet key required for use to sign transactions
      • See the documentation in the AvalanchePosition class for function parameters.
      # Add liquidity to the LP
      position.add(params)
      
      # Remove liquidity from the LP
      position.remove(params)
      
      # Harvest available rewards:
      position.harvest()
      
      # Close the position:
      position.close()
      
    • Informational Methods
      # Get position value (equity, debt, and position value):
      position.get_position_value()
      
      # Get value of harvestable rewards:
      position.get_rewards_value()
      
      # Get current debt ratio:
      position.get_debt_ratio()
      
      # Get the current leverage ratio:
      position.get_leverage_ratio()
      
      # Get current pool APY
      position.get_current_apy()
      
      # Get underlying tokens and LP for the pool:
      position.get_pool_tokens()
      
      # Get the debt of each token in the position (token, debt_uint256, debt_token, debt_usd):
      position.get_token_debts()
      # Alternatively, get the debt of a single token:
      position.get_token_debts(token_address)
      
      # Get all token borrow rates from CREAM:
      position.get_cream_borrow_rates()
      
      # get LP pool info:
      position.pool
      

Uninstallation:

Uninstall the package like any other Python package using the pip uninstall command:

pip uninstall alpha-homora-v2

Features:

  • Avalanche:
    • Get all open positions by owner wallet address
    • Harvest Position Rewards
    • Close Position
    • Get position value of equity and debt
    • Get current debt ratio
    • Get outstanding rewards value in native rewards token and USD
    • Add Liquidity
    • Remove Liquidity
    • Get aggregate pool APY (incl. borrowAPY)
  • Ethereum:
    • Get all open positions by owner wallet address
    • Harvest Position Rewards
    • Close Position
    • Get position value of equity and debt
    • Get current debt ratio
    • Get outstanding rewards value in native rewards token and USD
    • Add Liquidity
    • Remove Liquidity
    • Get aggregate pool APY (incl. borrowAPY)

Contribution:

Contributions are welcome! Please read the contribution guidelines to learn more about how to contribute to this project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alpha-homora-v2-2.0.3.tar.gz (42.7 kB view details)

Uploaded Source

File details

Details for the file alpha-homora-v2-2.0.3.tar.gz.

File metadata

  • Download URL: alpha-homora-v2-2.0.3.tar.gz
  • Upload date:
  • Size: 42.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for alpha-homora-v2-2.0.3.tar.gz
Algorithm Hash digest
SHA256 837624818a488b04439e552465be4eed19cc01289939f53aa01e3e02c95e6c55
MD5 c5c7b77f3b3f47db0f1dad231660509e
BLAKE2b-256 6100f3525d90157680158b7482cf43e4e9df8588d98511294b4e4a6032754e52

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page