Algofi Python SDK is useful for developers who want to programatically interact with the Algofi lending protocol

Overview

algofi-py-sdk

Algofi Python SDK

Documentation

https://algofi-py-sdk.readthedocs.io/en/latest/index.html

Design Goal

This SDK is useful for developers who want to programatically interact with the Algofi lending protocol.

Status

This SDK is currently under active early development and should not be considered stable.

Installation

algofi-py-sdk is not yet released on PYPI. It can be installed directly from this repository with pip:

pip install git+https://github.com/Algofiorg/algofi-py-sdk

To run examples:

  1. create an examples/.env file mnemonic=[25 char mnemonic] storage_mnemonic="" (leave empty string, examples/setup.py will set)
  2. Fund the account for mnemonic with 20 test ALGO
  3. Run python3 examples/setup.py
  4. Run examples e.g. examples/add_collateral.py

Examples

Add liquidity (mint)

mint.py This example shows how to add liquidity to the platform

Burn asset (burn)

burn.py This example shows how to burn bank assets to redeem for underlying liquidity

Add collateral (add_collateral)

add_collateral.py This example shows how to add minted bank assets to collateral

Add liquidity to collateral (mint_to_collateral)

mint_to_collateral.py This example shows how to add liquidity to the platform collateral

Remove collateral (remove_collateral)

remove_collateral.py This example shows how to remove bank asset collateral from platform

Remove collateral to underlying (remove_collateral_underlying)

remove_collateral_underlying.py This example shows how to remove bank asset collateral from platform to underlying asset

Borrow (borrow)

borrow.py This example shows how to borrow an underlying asset against provided collateral

Repay Borrow (repay_borrow)

repay_borrow.py This example shows how to repay borrowed assets

Staking (stake & unstake)

staking.py This example shows how to stake and unstake in a staking contract

License

algofi-py-sdk is licensed under a MIT license except for the exceptions listed below. See the LICENSE file for details.

Comments
  • feature/PriceUpdateOption

    feature/PriceUpdateOption

    Added optional price update in relevant methods of Client and Asset classes. To maintain the old behaviour, it defaults to True. This little change gives the user the ability to fetch new data only when needed.

    opened by aleve99 2
  • fix examples/example_utils.py/print_user_state

    fix examples/example_utils.py/print_user_state

    In the print_user_state function of the exampl_utils module the function is trying to get asset information from a market object. Suggestion is to get the asset object from the market object before printing out the information.

    opened by Alec-Schneider 2
  • 'get_storage_state' is not defined

    'get_storage_state' is not defined

    Hi,

    In the algofi/v1/manager module the get_user_state function of the Manager class returns the get_storage_state function, however it needs to be calling self.get_storage_state. Please let me know if you would like me to contribute the fix! Error message below

    ####################################

    NameError Traceback (most recent call last) in 6 print("~"*100) 7 print_market_state(client.get_market(symbol)) ----> 8 print_user_state(client, symbol, sender)

    ~/algorand/algofi-py-sdk/examples/example_utils.py in print_user_state(client, symbol, address) 12 13 def print_user_state(client, symbol, address): ---> 14 user_state = client.get_user_state(address) 15 for key, value in user_state["manager"].items(): 16 print(key, "=", value)

    ~/.local/lib/python3.8/site-packages/algofi/v1/client.py in get_user_state(self, address) 169 if not address: 170 address = self.user_address --> 171 result["manager"] = self.manager.get_user_state(address) 172 storage_address = self.manager.get_storage_address(address) 173 for symbol in self.active_ordered_symbols:

    ~/.local/lib/python3.8/site-packages/algofi/v1/manager.py in get_user_state(self, address) 93 result = {} 94 storage_address = self.get_storage_address(address) ---> 95 return get_storage_state(storage_address) 96 97 def get_storage_state(self, storage_address):

    NameError: name 'get_storage_state' is not defined

    opened by Alec-Schneider 2
  • Fix fee for claiming staking rewards

    Fix fee for claiming staking rewards

    This is regarding the stability STBL-USDC-LP staking rewards.

    Based on the txns I see on the webapp, the last txn (text: "Manager: Claim rewards") requires a fee of 3000 microalgo, but the sdk uses the default fee.

    With the default fee I get this algod error

    Exception: TransactionPool.Remember: transaction 3MSIFV62ZCLL5N7WXE4M5IDEVCQIBYWZYTOC5YZUZJO3L44IEFRA: logic eval error: fee too small
    

    Do the other staking pools also require 3000?

    opened by guanzo 1
  • Division by zero error when trying to unstake stability contract.

    Division by zero error when trying to unstake stability contract.

    storageAddress = '...'
    contractInfo = { 'managerAppId': 705663269, 'marketAppId': 705657303 }
    contract = StakingContract(indexer, indexer, contractInfo)
    state = contract.get_storage_state(storageAddress) # errors here
    

    https://github.com/Algofiorg/algofi-py-sdk/blob/65c60f27742016717ec20f6d4614495c04f06cbe/algofi/v1/rewards_program.py#L160

    relevant part of stack trace

        rewards_distributed_to_market = (rewards_issued * market_weighted_tvl_usd[market]) / total_weighted_tvl_usd
    ZeroDivisionError: division by zero
    

    seems like total_weighted_tvl_usd is zero.

    opened by guanzo 1
Owner
Algofi
Algofi
It is a useful project for developers that includes useful tools for Instagram

InstagramIG It is a useful project for developers that includes useful tools for Instagram Installation : pip install InstagramIG Logan Usage from In

Sidra ELEzz 14 Mar 14, 2022
FTX auto lending bot with python

FTX auto lending bot Get the API key Check my article for step by step + screenshots Setup & Run Install python 3 Install dependency pip install -r re

Patompong Manprasatkul 1 Dec 24, 2021
Discord-Lite - A light weight discord client written in Python, for developers, by developers.

Discord-Lite - A light weight discord client written in Python, for developers, by developers.

Sachit 142 Jan 7, 2023
Smilecreator4 - This site is for people who want to hack or want to learn it!

smilecreator4 This site is for people who want to hack or want to learn it! Furthermore, this program does not work without turning off Antivirus or W

null 1 Jan 4, 2022
Graviti-python-sdk - Graviti Data Platform Python SDK

Graviti Python SDK Graviti Python SDK is a python library to access Graviti Data

Graviti 13 Dec 15, 2022
The official wrapper for spyse.com API, written in Python, aimed to help developers build their integrations with Spyse.

Python wrapper for Spyse API The official wrapper for spyse.com API, written in Python, aimed to help developers build their integrations with Spyse.

Spyse 15 Nov 22, 2022
CRUD database for python discord bot developers that stores data on discord text channels

Discord Database A CRUD (Create Read Update Delete) database for python Discord bot developers. All data is stored in key-value pairs directly on disc

Ankush Singh 7 Oct 22, 2022
Asyncevents: a small library to help developers perform asynchronous event handling in Python

asyncevents - Asynchronous event handling for modern Python asyncevents is a small library to help developers perform asynchronous event handling in m

Mattia 5 Aug 7, 2022
pyDuinoCoin is a simple python integration for the DuinoCoin REST API, that allows developers to communicate with DuinoCoin Master Server

PyDuinoCoin PyDuinoCoin is a simple python integration for the DuinoCoin REST API, that allows developers to communicate with DuinoCoin Main Server. I

BackrndSource 6 Jul 14, 2022
A python library created to make life easier for Telegram API Developers.

opentele A python library created to make life easier for Telegram API Developers. Read the documentation Features Convert Telegram Desktop tdata sess

null 103 Jan 2, 2023
GitPython is a python library used to interact with Git repositories.

Gitoxide: A peek into the future… I started working on GitPython in 2009, back in the days when Python was 'my thing' and I had great plans with it. O

null 3.8k Jan 3, 2023
Python library to interact with a Z-Wave JS server.

zwave-js-server-python Python library for communicating with zwave-js-server. Goal for this library is to replicate the structure and the events of Z-

Home Assistant Libraries 54 Dec 18, 2022
Python API to interact with Uwazi

Python Uwazi API Quick Start To use the API install the requirements pip3 install -r requirements.txt and use it like this: uwazi_adapter = UwaziAdap

HURIDOCS 2 Dec 16, 2021
Autodrive is designed to make it as easy as possible to interact with the Google Drive and Sheets APIs via Python

Autodrive Autodrive is designed to make it as easy as possible to interact with the Google Drive and Sheets APIs via Python. It is especially designed

Chris Larabee 1 Oct 2, 2021
A python library to interact with the EarnApp API

EarnApp.py Table of contents General info Documentation Setup General info A python library to interact with the EarnApp API. Documentation First, imp

null 3 Dec 14, 2022
An async python wrapper to interact with the Steam API and its CMs

steam.py A modern, easy to use, and async ready package to interact with the Steam API. Heavily inspired by discord.py and borrowing functionality fro

James Hilton-Balfe 90 Dec 15, 2022
A Telegram Repo For Devs To Controll The Bots Under Maintenance.This Bot Is For Developers, If Your Bot Is Down, Use This Repo To Give Your Dear Subscribers Some Support By Providing Them Response.

Maintenance Bot A Telegram Repo For Devs To Controll The Bots Under Maintenance About This Bot This Bot Is For Developers, If Your Bot Is Down, Use Th

Vɪᴠᴇᴋ 47 Dec 29, 2022
A Telegram Repo For Devs To Controll The Bots Under Maintenance.This Bot Is For Developers, If Your Bot Is Down, Use This Repo To Give Your Dear Subscribers Some Support By Providing Them Response.

Maintenance Bot A Telegram Repo For Devs To Controll The Bots Under Maintenance About This Bot This Bot Is For Developers, If Your Bot Is Down, Use Th

Vɪᴠᴇᴋ 47 Dec 29, 2022