Created
June 19, 2025 18:00
-
-
Save algolog/69bf2129c825b148c7f381c6df32bafc to your computer and use it in GitHub Desktop.
Withdraw algo collateral from algofi v1 lending protocol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from algosdk import mnemonic, account | |
from algosdk.v2client.algod import AlgodClient | |
from algosdk.v2client.indexer import IndexerClient | |
from algofi.v1.client import AlgofiMainnetClient | |
USER_ADDRESS = "ST7KA2KB76LN3P6ZSJMV2K4D55BTEWP2GZACJCJIQV7FV7NZ2CQLXUQDYE" | |
SIGNING_MNEMONIC="bounce genre fabric rude mention once silent daring burger wool armed hundred twelve traffic oblige assist piano bless dignity trade useless shallow spatial abstract layer" | |
key = mnemonic.to_private_key(SIGNING_MNEMONIC) | |
sender = USER_ADDRESS | |
algod = AlgodClient("", "https://mainnet-api.algonode.cloud") | |
indexer = IndexerClient("", "https://mainnet-idx.algonode.cloud") | |
client = AlgofiMainnetClient(algod_client=algod, indexer_client=indexer, user_address=sender) | |
user_state = client.get_user_state(sender) | |
# remove ALGO from lending | |
symbol = 'ALGO' | |
amount = user_state[symbol]['active_collateral_bank'] | |
txn = client.prepare_remove_collateral_underlying_transactions(symbol, amount) | |
txn.sign_with_private_key(sender, key) | |
txn.submit(client.algod, wait=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment