algofi¶
- v1
- client
AlgofiMainnetClient
AlgofiTestnetClient
Client
Client.get_active_asset_ids()
Client.get_active_assets()
Client.get_active_bank_asset_ids()
Client.get_active_market_addresses()
Client.get_active_market_app_ids()
Client.get_active_markets()
Client.get_active_oracle_app_ids()
Client.get_active_ordered_symbols()
Client.get_asset()
Client.get_default_params()
Client.get_manager()
Client.get_market()
Client.get_max_atomic_opt_in_market_app_ids()
Client.get_prices()
Client.get_raw_prices()
Client.get_staking_contract()
Client.get_staking_contracts()
Client.get_storage_accounts()
Client.get_storage_state()
Client.get_user_balance()
Client.get_user_balances()
Client.get_user_info()
Client.get_user_staking_contract_state()
Client.get_user_state()
Client.is_opted_into_app()
Client.is_opted_into_asset()
Client.prepare_add_collateral_transactions()
Client.prepare_borrow_transactions()
Client.prepare_burn_transactions()
Client.prepare_claim_rewards_transactions()
Client.prepare_claim_staking_rewards_transactions()
Client.prepare_liquidate_transactions()
Client.prepare_mint_to_collateral_transactions()
Client.prepare_mint_transactions()
Client.prepare_optin_transactions()
Client.prepare_remove_algos_from_vault_transactions()
Client.prepare_remove_collateral_transactions()
Client.prepare_remove_collateral_underlying_transactions()
Client.prepare_repay_borrow_transactions()
Client.prepare_send_governance_commitment_transactions()
Client.prepare_send_governance_vote_transactions()
Client.prepare_send_keyreg_offline_transactions()
Client.prepare_send_keyreg_online_transactions()
Client.prepare_stake_transactions()
Client.prepare_staking_contract_optin_transactions()
Client.prepare_supply_algos_to_vault_transactions()
Client.prepare_sync_vault_transactions()
Client.prepare_unstake_transactions()
Client.submit()
- manager
Manager
Manager.get_manager_address()
Manager.get_manager_app_id()
Manager.get_rewards_program()
Manager.get_storage_address()
Manager.get_storage_state()
Manager.get_storage_unrealized_rewards()
Manager.get_supported_market_count()
Manager.get_user_address()
Manager.get_user_state()
Manager.get_user_unrealized_rewards()
Manager.update_global_state()
- market
Market
Market.get_active_collateral()
Market.get_asset()
Market.get_bank_circulation()
Market.get_bank_to_underlying_exchange()
Market.get_collateral_factor()
Market.get_liquidation_incentive()
Market.get_market_address()
Market.get_market_app_id()
Market.get_market_counter()
Market.get_outstanding_borrow_shares()
Market.get_storage_state()
Market.get_total_borrow_interest_rate()
Market.get_underlying_borrowed()
Market.get_underlying_cash()
Market.get_underlying_reserves()
Market.get_underlying_supplied()
Market.update_global_state()
- staking_contract
StakingContract
StakingContract.get_asset()
StakingContract.get_manager()
StakingContract.get_manager_address()
StakingContract.get_manager_app_id()
StakingContract.get_market()
StakingContract.get_market_address()
StakingContract.get_market_app_id()
StakingContract.get_oracle_app_id()
StakingContract.get_rewards_program()
StakingContract.get_staked()
StakingContract.get_storage_address()
StakingContract.get_storage_state()
StakingContract.get_user_state()
StakingContract.update_global_state()
- asset
Asset
Asset.get_bank_asset_id()
Asset.get_bank_asset_info()
Asset.get_decimal_amount()
Asset.get_oracle_app_id()
Asset.get_oracle_price_field()
Asset.get_oracle_price_scale_factor()
Asset.get_price()
Asset.get_raw_price()
Asset.get_scaled_amount()
Asset.get_underlying_asset_id()
Asset.get_underlying_asset_info()
Asset.get_underlying_decimals()
Asset.to_usd()
- rewards_program
RewardsProgram
RewardsProgram.get_latest_rewards_time()
RewardsProgram.get_rewards_amount()
RewardsProgram.get_rewards_asset_id()
RewardsProgram.get_rewards_asset_ids()
RewardsProgram.get_rewards_per_second()
RewardsProgram.get_rewards_program_number()
RewardsProgram.get_rewards_secondary_asset_id()
RewardsProgram.get_rewards_secondary_ratio()
RewardsProgram.get_storage_unrealized_rewards()
- client
utils¶
- class algofi.utils.TransactionGroup(transactions)¶
Bases:
object
- sign_with_private_key(address, private_key)¶
Signs the transactions with specified private key and saves to class state
- Parameters:
address (string) – account address of the user
private_key (string) – private key of user
- sign_with_private_keys(private_keys)¶
Signs the transactions with specified list of private keys and saves to class state
- Parameters:
private_key (string) – private key of user
- submit(algod, wait=False)¶
Submits the signed transactions to network using the algod client
- Parameters:
algod (
AlgodClient
) – algod clientwait (boolean, optional) – wait for txn to complete, defaults to False
- Returns:
dict of transaction id
- Return type:
dict
- class algofi.utils.Transactions(value)¶
Bases:
Enum
An enumeration.
- ADD_COLLATERAL = 3¶
- BORROW = 7¶
- BURN = 5¶
- CLAIM_REWARDS = 10¶
- LIQUIDATE = 9¶
- MINT = 1¶
- MINT_TO_COLLATERAL = 2¶
- REMOVE_ALGOS_FROM_VAULT = 12¶
- REMOVE_COLLATERAL = 4¶
- REMOVE_COLLATERAL_UNDERLYING = 6¶
- REPAY_BORROW = 8¶
- SEND_GOVERNANCE_TXN = 14¶
- SEND_KEYREG_OFFLINE_TXN = 16¶
- SEND_KEYREG_ONLINE_TXN = 15¶
- SUPPLY_ALGOS_TO_VAULT = 11¶
- SYNC_VAULT = 13¶
- algofi.utils.encode_value(value, type)¶
- algofi.utils.encode_varint(number)¶
- algofi.utils.format_state(state)¶
Returns state dict formatted to human-readable strings
- Parameters:
state (dict) – dict of state returned by read_local_state or read_global_state
- Returns:
dict of state with keys + values formatted from bytes to utf-8 strings
- Return type:
dict
- algofi.utils.get_accounts_opted_into_app(indexer, app_id)¶
Submits the signed transactions to network using the algod client :param indexer: indexer client :type indexer:
IndexerClient
:param app_id: application id :type app_id: int :return: list of accounts opted into app :rtype: list
- algofi.utils.get_global_state_field(indexer_client, app_id, field_name, block=None)¶
Returns field of global state for application with the given app_id
- Parameters:
indexer_client (
IndexerClient
) – indexer clientapp_id (int) – id of the application
block (int, optional) – block at which to query historical data
- Returns:
value of global state variable for app
- Return type:
dict
- algofi.utils.get_init_round(chain)¶
Returns init round of algofi protocol for a specified chain. Pulled from hardcoded values in contracts.json.
- Parameters:
chain (string e.g. 'testnet') – network to query data for
- Returns:
init round of algofi protocol on specified chain
- Return type:
string
- algofi.utils.get_manager_app_id(chain)¶
Returns app id of manager for the specified chain. Pulled from hardcoded values in contracts.json.
- Parameters:
chain (string e.g. 'testnet') – network to query data for
- Returns:
manager app id
- Return type:
int
- algofi.utils.get_market_app_id(chain, symbol)¶
Returns market app id of symbol for the specified chain. Pulled from hardcoded values in contracts.json.
- Parameters:
chain (string e.g. 'testnet') – network to query data for
symbol (string e.g. 'ALGO') – symbol to get market data for
- Returns:
market app id
- Return type:
int
- algofi.utils.get_new_account()¶
Returns a tuple with a new key, address and passphrase.
- Returns:
tuple of key, address, passphrase for a new algorand account
- Return type:
tuple
- algofi.utils.get_ordered_symbols(chain, max=False, max_atomic_opt_in=False)¶
Returns list of supported symbols for the specified chain. Pulled from hardcoded values in contracts.json.
- Parameters:
chain (string e.g. 'testnet') – network to query data for
max (boolean) – max assets?
- Returns:
list of supported symbols for algofi’s protocol on chain
- Return type:
list
- algofi.utils.get_program(definition, variables=None)¶
Return a byte array to be used in LogicSig.
- algofi.utils.get_staking_contracts(chain)¶
Returns list of supported staking contracts for the specified chain. Pulled from hardcoded values in contracts.json.
- Parameters:
chain (string e.g. 'testnet') – network to query data for
- Returns:
list of supported staking contracts
- Return type:
list
- algofi.utils.get_state_bytes(state, key)¶
- algofi.utils.get_state_int(state, key)¶
- algofi.utils.int_to_bytes(num)¶
- algofi.utils.prepare_payment_transaction(sender, suggested_params, receiver, amount, rekey_to=None)¶
Returns a
TransactionGroup
object representing a payment group transaction for a given sender, receiver, amount and ability to rekey.- Parameters:
sender (string) – account address for the sender
suggested_params (
algosdk.transaction.SuggestedParams
object) – suggested transaction paramsreceiver (string) – account address for the receiver
amount (string) – amount of algos to send
amount – address to rekey sender to after payment
- Returns:
TransactionGroup
object representing a payment group transaction- Return type:
- algofi.utils.read_global_state(indexer_client, app_id, block=None)¶
Returns dict of global state for application with the given app_id
- Parameters:
indexer_client (
IndexerClient
) – indexer clientapp_id (int) – id of the application
block (int, optional) – block at which to query historical data
- Returns:
dict of global state for application with id app_id
- Return type:
dict
- algofi.utils.read_local_state(indexer_client, address, app_id, block=None)¶
Returns dict of local state for address for application with id app_id
- Parameters:
indexer_client (
IndexerClient
) – indexer clientaddress (string) – address of account for which to get state
app_id (int) – id of the application
block (int, optional) – block at which to get the historical local state
- Returns:
dict of local state of address for application with id app_id
- Return type:
dict
- algofi.utils.sign_and_submit_transactions(client, transactions, signed_transactions, sender, sender_sk)¶
- algofi.utils.wait_for_confirmation(client, txid)¶
Waits for a transaction with id txid to complete. Returns dict with transaction information after completion.
- Parameters:
client (
AlgodClient
) – algod clienttxid (string) – id of the sent transaction
- Returns:
dict of transaction information
- Return type:
dict