Choice = client.fetch_asset(297995609)
ALGO = client.fetch_asset(0)
pool = client.fetch_pool(Choice, ALGO)
quote = pool.fetch_fixed_input_swap_quote(ALGO(1_000_000), slippage=0.01)
print(f'Choice per ALGO: {quote.price}')
print(f'Choice per ALGO (worst case): {quote.price_with_slippage}')
print("Do you still want to go through this transaction? Type Y for 'Yes' and N for 'No'")
new = int(input("How much ALGO do you want to spend? ")) * 1000000
quote = pool.fetch_fixed_input_swap_quote(ALGO(new), slippage=0.01)
print(f'Swapping {quote.amount_in} to {quote.amount_out_with_slippage}')
transaction_group = pool.prepare_swap_transactions_from_quote(quote)
# Sign the group with our key
transaction_group.sign_with_private_key(address, private_key)
# Submit transactions to the network and wait for confirmation
result = client.submit(transaction_group, wait=True)
# Check if any excess remaining after the swap
excess = pool.fetch_excess_amounts()
print(f'Excess: {amount}')
transaction_group = pool.prepare_redeem_transactions(amount)
transaction_group.sign_with_private_key(address, private_key)
result = client.submit(transaction_group, wait=True)
print('Returning to wrapper home')