Package: alpha-homora-v2
Alpha-Homora-V2-PythonA Python3.9+ package that wraps Alpha Homora V2 positions to simplify interaction with their smart contracts in your Python projects.Current FeaturesRewards Value | Position Value | Debt & Leverage Ratio | Pool Info | Current APYHarvest Rewards | Close Position | Add & Remove LiquidityCurrent Supported NetworksAvalancheEthereum(WIP)Table of ContentsInstallationUsageAvalancheUninstallationRoadmapContributionInstallationThis package is set up to be installed using thepippackage manager.Ensure that you have Python 3.9+ installed. If not, you can downloadhere. The syntax is dependent on features added in this recent version.Install the package using pip:pipinstall--upgradealpha-homora-v2After install, the package will be available to you in your local Python environment asalpha-homora-v2When 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.UsageHow to use the package:Avalanche:Import the AvalanchePosition class into your Python script:fromalpha_homora_v2importAvalanchePositionCreating anAvalanchePositioninstance requires the following:Your position ID (an integer)This ID should match your position on Alpha Homora, without the "#"your public wallet key(Optional)your private wallet keyYour private key is required to sign transactional methodsOnce 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 4Alternatively, get all open positions (AvalanchePositionobjects) by owner wallet address:fromalpha_homora_v2.positionimportget_avax_positions_by_ownerpositions=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).Use your position instance(s) to interact with the Alpha Homora V2 position smart contracts on the network:Transactional Methods:Return aTransactionReceiptobject upon successPrivate wallet keyrequiredfor use to sign transactionsSee the documentation in theAvalanchePositionclass for function parameters.# Add liquidity to the LPposition.add(params)# Remove liquidity from the LPposition.remove(params)# Harvest available rewards:position.harvest()# Close the position:position.close()Informational MethodsReturn JSON dataPrivate wallet keynot requiredfor useSeeexamples/position_info.ipynbfor output examples.# 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 APYposition.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.poolUninstallation:Uninstall the package like any other Python package using the pip uninstall command:pipuninstallalpha-homora-v2Features:Avalanche:Get all open positions by owner wallet addressHarvest Position RewardsClose PositionGet position value of equity and debtGet current debt ratioGet outstanding rewards value in native rewards token and USDAdd LiquidityRemove LiquidityGet aggregate pool APY (incl. borrowAPY)Ethereum:Get all open positions by owner wallet addressHarvest Position RewardsClose PositionGet position value of equity and debtGet current debt ratioGet outstanding rewards value in native rewards token and USDAdd LiquidityRemove LiquidityGet aggregate pool APY (incl. borrowAPY)Contribution:Contributions are welcome! Please read thecontribution guidelinesto learn more about how to contribute to this project.