Skip to content

Unofficial Python package that wraps the smart contracts governing positions on the Alpha Homora V2 DeFi platform.

License

Notifications You must be signed in to change notification settings

PathX-Projects/Alpha-Homora-V2-Python

Repository files navigation

Alpha Homora V2 Logo

Alpha-Homora-V2-Python

PyPI version

A Python3.9+ package that wraps Alpha Homora V2 yield farming 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. Overview
  2. Installation
  3. Usage
    1. Avalanche
  4. Uninstallation
  5. Roadmap
  6. Contribution

Overview:

This project aims to simplify interaction with Alpha Homora V2's yield farming position smart contracts in your Python projects by packaging all of the necessary functionality and more into a single Python package built on top of web3.py, instead of brownie.

Positions Image

Currently, only yield farming positions are supported, but we plan to integrate lending positions once the functionality for yield farming positions is available on Avalanche and Ethereum.

Use cases include:

  • Algorithmic liquidity management
  • Automated position closing
  • Position analytics

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

    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.

Get in touch: [email protected]

About

Unofficial Python package that wraps the smart contracts governing positions on the Alpha Homora V2 DeFi platform.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages