diff --git a/ShowAllAccounts.ipynb b/ShowAllAccounts.ipynb index e0089ba..302812b 100644 --- a/ShowAllAccounts.ipynb +++ b/ShowAllAccounts.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "behind-fundamental", + "id": "freelance-bailey", "metadata": {}, "source": [ "# ⚠ Warning\n", @@ -16,7 +16,7 @@ }, { "cell_type": "markdown", - "id": "extended-sense", + "id": "current-teaching", "metadata": {}, "source": [ "# 🥭 Show All Accounts\n", @@ -28,7 +28,7 @@ }, { "cell_type": "markdown", - "id": "atmospheric-brother", + "id": "northern-patrol", "metadata": {}, "source": [ "## How To Use This Page\n", @@ -39,7 +39,7 @@ { "cell_type": "code", "execution_count": null, - "id": "distinguished-arbitration", + "id": "critical-integration", "metadata": { "jupyter": { "source_hidden": true @@ -59,7 +59,7 @@ { "cell_type": "code", "execution_count": null, - "id": "corporate-scene", + "id": "parental-economy", "metadata": {}, "outputs": [], "source": [ @@ -72,12 +72,12 @@ " markets = list(map(lambda market: Market.load(default_context.client, market.spot), group.markets))\n", " print(\"Markets:\", markets)\n", "\n", - " vaults = default_context.load_multiple_accounts([token.vault for token in group.tokens])\n", + " vaults = default_context.load_multiple_accounts([token.vault for token in group.basket_tokens])\n", " print(\"Vaults:\", vaults)\n", "\n", " for index, vault in enumerate(vaults):\n", " token = TokenAccount.parse(vault.data, vault.address)\n", - " decimals = group.tokens[index].decimals\n", + " decimals = group.basket_tokens[index].decimals\n", " amount = token.amount / (10 ** decimals)\n", " print(f\"Vault token amount[{index}]: {amount:,.8f}\")\n", "\n", diff --git a/bin/group-balance-wallet b/bin/group-balance-wallet index 77c193f..4aecf99 100755 --- a/bin/group-balance-wallet +++ b/bin/group-balance-wallet @@ -83,8 +83,9 @@ try: logging.info(f"Wallet address: {wallet.address}") group = Group.load(context) + tokens = [basket_token.token for basket_token in group.basket_tokens] - balance_parser = TargetBalanceParser(group.tokens) + balance_parser = TargetBalanceParser(tokens) targets = list(map(balance_parser.parse, args.target)) logging.info(f"Targets: {targets}") @@ -96,7 +97,7 @@ try: else: trade_executor = SerumImmediateTradeExecutor(context, wallet, group, adjustment_factor, print) - wallet_balancer = LiveWalletBalancer(context, wallet, trade_executor, action_threshold, group.tokens, targets) + wallet_balancer = LiveWalletBalancer(context, wallet, trade_executor, action_threshold, tokens, targets) wallet_balancer.balance(prices) logging.info("Balancing completed.") diff --git a/bin/group-balances b/bin/group-balances index 284fc5e..97aa4ba 100755 --- a/bin/group-balances +++ b/bin/group-balances @@ -73,9 +73,9 @@ try: print("Balances:") print(f" SOL balance: {context.fetch_sol_balance(wallet.address):>18,.8f}") group = Group.load(context) - for token in group.tokens: - balance = context.fetch_token_balance(wallet.address, token.mint) or Decimal(0) - print(f"{token.name:>7} balance: {balance:>18,.8f}") + for basket_token in group.basket_tokens: + balance = context.fetch_token_balance(wallet.address, basket_token.token.mint) or Decimal(0) + print(f"{basket_token.token.name:>7} balance: {balance:>18,.8f}") except Exception as exception: logging.critical(f"group-balances stopped because of exception: {exception} - {traceback.format_exc()}") except: diff --git a/bin/liquidate-single-account b/bin/liquidate-single-account index 2d85a5e..1184219 100755 --- a/bin/liquidate-single-account +++ b/bin/liquidate-single-account @@ -92,8 +92,8 @@ try: print("Wallet Balances Before:") print(f" SOL balance: {context.fetch_sol_balance(wallet.address):>18,.8f}") - for token in group.tokens: - print(f"{token.name:>7} balance: {context.fetch_token_balance(wallet.address, token.mint):>18,.8f}") + for basket_token in group.basket_tokens: + print(f"{basket_token.token.name:>7} balance: {context.fetch_token_balance(wallet.address, basket_token.token.mint):>18,.8f}") prices = group.fetch_token_prices() margin_account = MarginAccount.load(context, margin_account_address, group) @@ -120,8 +120,8 @@ try: print("Margin Account After:", intrinsic_balance_sheets_after) print("Wallet Balances After:") print(f" SOL balance: {context.fetch_sol_balance(wallet.address):>18,.8f}") - for token in group.tokens: - print(f"{token.name:>7} balance: {context.fetch_token_balance(wallet.address, token.mint):>18,.8f}") + for basket_token in group.basket_tokens: + print(f"{basket_token.token.name:>7} balance: {context.fetch_token_balance(wallet.address, basket_token.token.mint):>18,.8f}") except Exception as exception: logging.critical(f"Liquidator stopped because of exception: {exception} - {traceback.format_exc()}") diff --git a/bin/liquidator b/bin/liquidator index ed20f59..938318b 100755 --- a/bin/liquidator +++ b/bin/liquidator @@ -91,6 +91,7 @@ try: logging.info(f"Wallet address: {wallet.address}") group = Group.load(context) + tokens = [basket_token.token for basket_token in group.basket_tokens] logging.info("Checking wallet accounts.") scout = AccountScout() @@ -109,10 +110,10 @@ try: if args.dry_run or (args.target is None) or (len(args.target) == 0): wallet_balancer: WalletBalancer = NullWalletBalancer() else: - balance_parser = TargetBalanceParser(group.tokens) + balance_parser = TargetBalanceParser(tokens) targets = list(map(balance_parser.parse, args.target)) trade_executor = SerumImmediateTradeExecutor(context, wallet, group, adjustment_factor) - wallet_balancer = LiveWalletBalancer(context, wallet, trade_executor, action_threshold, group.tokens, targets) + wallet_balancer = LiveWalletBalancer(context, wallet, trade_executor, action_threshold, tokens, targets) stop = False liquidator = PollingLiquidator(context, wallet, account_liquidator, wallet_balancer)