From e5e7d5d6ff1a46fddd9413b0f480669355fb8eba Mon Sep 17 00:00:00 2001 From: ccgarant Date: Sun, 28 Jan 2024 20:18:50 -0500 Subject: [PATCH 01/15] updates to systemctl --- README.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/README.md b/README.md index adeb34e..8bc19f7 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,64 @@ If you decide to stop running the off-chain bot indefinitely, follow the steps b By following these steps, you'll terminate the bot and retrieve your setup UTXOs. +## Running Duckpools Off-Chain Bot as a Systemd Service +These steps will setup the off-chain-bot to run in the background upon startup and reboot automatically, unless you shut it down. + +To ensure the Duckpools Off-Chain Bot starts automatically on system boot, you can set it up as a systemd service (Note: this is for a Linux setup). Follow these steps: + +1. **Create a systemd Service File** + + Create a new service file named `duckpools-bot.service` in the `/etc/systemd/system/` directory. + + ```bash + sudo nano /etc/systemd/system/duckpools-bot.service + ``` + +2. **Configure the Service File** + + Add the following configuration to the service file. Be sure to replace with your actual username and /path/to/your/off-chain-bot with the full path to your bot's directory. + + ```bash + [Unit] + Description=Duckpools Off-Chain Bot + After=network.target + + [Service] + User= + WorkingDirectory=/path/to/your/off-chain-bot + ExecStart=/usr/bin/python3 main.py + Restart=always + Environment="API_KEY=your_api_key_value" + Environment="WALLET_PASS=your_wallet_pass_value" + + [Install] + WantedBy=multi-user.target + ``` +3. **Reload, Enable, Start** + + After saving the service file, reload the systemd daemon to apply the new service. Enable the service to start on boot, and then start the service immediately. + + ```bash + sudo systemctl daemon-reload + sudo systemctl enable duckpools-bot.service + sudo systemctl start duckpools-bot.service + ``` + +4. **Verify the system is running** + + ```bash + sudo systemctl status duckpools-bot.service + ``` + + **Note:** Ensure that python3 is the correct path for Python 3.x on your system. Adjust the ExecStart path as needed. The service file assumes that your main.py script is set up to run continuously or as a daemon. + +5. **Check The Logs Realtime** + To check the main.py output realtime, check the live logs using: + + ```bash + sudo journalctl -fu duckpools-bot.service + ``` + ### Disclaimer By running this software, you assume all responsibility and risk associated with its operation. Users are to exercise caution and perform their own due diligence when running the bot, especially in a live environment. From 7a01e069c88fa2f4284b4cde5d0e19a1ed20e319 Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 21:23:14 -0400 Subject: [PATCH 02/15] updated readme to match duckpools main branch --- README.md | 60 +------------------------------------------------------ 1 file changed, 1 insertion(+), 59 deletions(-) diff --git a/README.md b/README.md index b270565..4928c3b 100644 --- a/README.md +++ b/README.md @@ -147,65 +147,7 @@ If you decide to stop running the off-chain bot indefinitely, follow the steps b By following these steps, you'll terminate the bot and retrieve your setup UTXOs. -## Running Duckpools Off-Chain Bot as a Systemd Service -These steps will setup the off-chain-bot to run in the background upon startup and reboot automatically, unless you shut it down. - -To ensure the Duckpools Off-Chain Bot starts automatically on system boot, you can set it up as a systemd service (Note: this is for a Linux setup). Follow these steps: - -1. **Create a systemd Service File** - - Create a new service file named `duckpools-bot.service` in the `/etc/systemd/system/` directory. - - ```bash - sudo nano /etc/systemd/system/duckpools-bot.service - ``` - -2. **Configure the Service File** - - Add the following configuration to the service file. Be sure to replace with your actual username and /path/to/your/off-chain-bot with the full path to your bot's directory. - - ```bash - [Unit] - Description=Duckpools Off-Chain Bot - After=network.target - - [Service] - User= - WorkingDirectory=/path/to/your/off-chain-bot - ExecStart=/usr/bin/python3 main.py - Restart=always - Environment="API_KEY=your_api_key_value" - Environment="WALLET_PASS=your_wallet_pass_value" - - [Install] - WantedBy=multi-user.target - ``` -3. **Reload, Enable, Start** - - After saving the service file, reload the systemd daemon to apply the new service. Enable the service to start on boot, and then start the service immediately. - - ```bash - sudo systemctl daemon-reload - sudo systemctl enable duckpools-bot.service - sudo systemctl start duckpools-bot.service - ``` - -4. **Verify the system is running** - - ```bash - sudo systemctl status duckpools-bot.service - ``` - - **Note:** Ensure that python3 is the correct path for Python 3.x on your system. Adjust the ExecStart path as needed. The service file assumes that your main.py script is set up to run continuously or as a daemon. - -5. **Check The Logs Realtime** - To check the main.py output realtime, check the live logs using: - - ```bash - sudo journalctl -fu duckpools-bot.service - ``` - ### Disclaimer By running this software, you assume all responsibility and risk associated with its operation. Users are to exercise caution and perform their own due diligence when running the bot, especially in a live environment. -The duckpools community welcomes contributions and feedback as we work towards enhancing the functionality and reliability of this project. +The duckpools community welcomes contributions and feedback as we work towards enhancing the functionality and reliability of this project. \ No newline at end of file From 10c762cf43680c3c93fe4c85307bd8fd846d6a8f Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 21:24:44 -0400 Subject: [PATCH 03/15] add try except to catch 0 index check --- erg_pool/e_repay_to_pool.py | 6 +++++- erg_pool/e_withdraw_proxy.py | 7 ++++++- token_pools/t_lend_proxy_sUsd.py | 10 +++++++--- token_pools/t_repay_to_pool_susd.py | 8 ++++++-- token_pools/t_withdraw_proxy_sigusd.py | 10 +++++++--- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/erg_pool/e_repay_to_pool.py b/erg_pool/e_repay_to_pool.py index 47c12d7..15915f3 100644 --- a/erg_pool/e_repay_to_pool.py +++ b/erg_pool/e_repay_to_pool.py @@ -12,7 +12,11 @@ def process_repay_to_pool_box(pool, box, latest_tx): erg_pool_box, borrowed = latest_pool_info(pool, latest_tx) erg_to_give = box["value"] - TX_FEE - final_borrowed = borrowed - int(box["assets"][0]["amount"]) + try: + final_borrowed = borrowed - int(box["assets"][0]["amount"]) + except (IndexError, KeyError, TypeError) as e: + logger.error(f"Error accessing box assets in repay to pool: {e}. Box: {box}") + return None transaction_to_sign = \ { diff --git a/erg_pool/e_withdraw_proxy.py b/erg_pool/e_withdraw_proxy.py index 69958b8..858a8da 100644 --- a/erg_pool/e_withdraw_proxy.py +++ b/erg_pool/e_withdraw_proxy.py @@ -14,9 +14,14 @@ def process_withdraw_proxy_box(pool, box, latest_tx): erg_pool_box, borrowed = latest_pool_info(pool, latest_tx) + try: + user_gives = box["assets"][0]["amount"] + except (IndexError, KeyError, TypeError) as e: + logger.error(f"Error accessing box assets in withdraw proxy: {e}. Box: {box}") + return None + held_erg0 = erg_pool_box["value"] held_tokens = int(erg_pool_box["assets"][1]["amount"]) - user_gives = box["assets"][0]["amount"] circulating_tokens = int(MAX_LP_TOKENS - held_tokens) final_circulating = circulating_tokens - user_gives held_erg1 = ceil(final_circulating * (held_erg0 + borrowed) / circulating_tokens - borrowed) + 1 diff --git a/token_pools/t_lend_proxy_sUsd.py b/token_pools/t_lend_proxy_sUsd.py index 9fff624..78caf5a 100644 --- a/token_pools/t_lend_proxy_sUsd.py +++ b/token_pools/t_lend_proxy_sUsd.py @@ -11,11 +11,15 @@ def process_lend_proxy_box(pool, box, latest_tx): - if box["assets"][0]["tokenId"] != pool["CURRENCY_ID"]: - return latest_tx + try: + if box["assets"][0]["tokenId"] != pool["CURRENCY_ID"]: + return latest_tx + token_amount = box["assets"][0]["amount"] + except (IndexError, KeyError, TypeError) as e: + logger.error(f"Error accessing box assets in lend proxy (SUSD): {e}. Box: {box}") + return None pool_box, borrowed = latest_pool_info(pool, latest_tx) - token_amount = box["assets"][0]["amount"] service_fee = max(calculate_final_amount(token_amount, pool["thresholds"]), 1) assets_to_give = token_amount - service_fee held_tokens = int(pool_box["assets"][1]["amount"]) diff --git a/token_pools/t_repay_to_pool_susd.py b/token_pools/t_repay_to_pool_susd.py index 2de5cda..c8ddd9f 100644 --- a/token_pools/t_repay_to_pool_susd.py +++ b/token_pools/t_repay_to_pool_susd.py @@ -11,8 +11,12 @@ def process_repay_to_pool_box(pool, box, latest_tx): pool_box, borrowed = latest_pool_info(pool, latest_tx) - assets_to_give = box["assets"][1]["amount"] - final_borrowed = borrowed - int(box["assets"][0]["amount"]) + try: + assets_to_give = box["assets"][1]["amount"] + final_borrowed = borrowed - int(box["assets"][0]["amount"]) + except (IndexError, KeyError, TypeError) as e: + logger.error(f"Error accessing box assets in repay to pool (SUSD): {e}. Box: {box}") + return None transaction_to_sign = \ { diff --git a/token_pools/t_withdraw_proxy_sigusd.py b/token_pools/t_withdraw_proxy_sigusd.py index 424b6ae..dc61c5c 100644 --- a/token_pools/t_withdraw_proxy_sigusd.py +++ b/token_pools/t_withdraw_proxy_sigusd.py @@ -11,13 +11,17 @@ def process_withdraw_proxy_box(pool, box, latest_tx): - if box["assets"][0]["tokenId"] != pool["LEND_TOKEN"]: - return latest_tx + try: + if box["assets"][0]["tokenId"] != pool["LEND_TOKEN"]: + return latest_tx + user_gives = box["assets"][0]["amount"] + except (IndexError, KeyError, TypeError) as e: + logger.error(f"Error accessing box assets in withdraw proxy (SUSD): {e}. Box: {box}") + return None pool_box, borrowed = latest_pool_info(pool, latest_tx) held_erg0 = pool_box["assets"][3]["amount"] held_tokens = int(pool_box["assets"][1]["amount"]) - user_gives = box["assets"][0]["amount"] circulating_tokens = int(9000000000000010 - held_tokens) final_circulating = circulating_tokens - user_gives held_erg1 = ceil(final_circulating * (held_erg0 + borrowed) / circulating_tokens - borrowed) + 1 From 5b26fd966dd16067038a0d9c8396a547e7b9d8e4 Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 21:31:59 -0400 Subject: [PATCH 04/15] Added more robust handling and better descriptions --- erg_pool/e_repay_to_pool.py | 4 ++-- erg_pool/e_withdraw_proxy.py | 4 ++-- token_pools/t_lend_proxy_sUsd.py | 4 ++-- token_pools/t_repay_to_pool_susd.py | 4 ++-- token_pools/t_withdraw_proxy_sigusd.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/erg_pool/e_repay_to_pool.py b/erg_pool/e_repay_to_pool.py index 15915f3..82b3b19 100644 --- a/erg_pool/e_repay_to_pool.py +++ b/erg_pool/e_repay_to_pool.py @@ -14,8 +14,8 @@ def process_repay_to_pool_box(pool, box, latest_tx): erg_to_give = box["value"] - TX_FEE try: final_borrowed = borrowed - int(box["assets"][0]["amount"]) - except (IndexError, KeyError, TypeError) as e: - logger.error(f"Error accessing box assets in repay to pool: {e}. Box: {box}") + except (IndexError, KeyError, TypeError, ValueError) as e: + logger.error(f"[Repay to Pool] Error accessing box assets: {e}. Transaction ID: {box.get('transactionId', 'unknown')}, Box: {box}") return None transaction_to_sign = \ diff --git a/erg_pool/e_withdraw_proxy.py b/erg_pool/e_withdraw_proxy.py index 858a8da..a510c27 100644 --- a/erg_pool/e_withdraw_proxy.py +++ b/erg_pool/e_withdraw_proxy.py @@ -16,8 +16,8 @@ def process_withdraw_proxy_box(pool, box, latest_tx): try: user_gives = box["assets"][0]["amount"] - except (IndexError, KeyError, TypeError) as e: - logger.error(f"Error accessing box assets in withdraw proxy: {e}. Box: {box}") + except (IndexError, KeyError, TypeError, ValueError) as e: + logger.error(f"[Withdraw Proxy] Error accessing box assets: {e}. Transaction ID: {box.get('transactionId', 'unknown')}, Box: {box}") return None held_erg0 = erg_pool_box["value"] diff --git a/token_pools/t_lend_proxy_sUsd.py b/token_pools/t_lend_proxy_sUsd.py index 78caf5a..0ed8841 100644 --- a/token_pools/t_lend_proxy_sUsd.py +++ b/token_pools/t_lend_proxy_sUsd.py @@ -15,8 +15,8 @@ def process_lend_proxy_box(pool, box, latest_tx): if box["assets"][0]["tokenId"] != pool["CURRENCY_ID"]: return latest_tx token_amount = box["assets"][0]["amount"] - except (IndexError, KeyError, TypeError) as e: - logger.error(f"Error accessing box assets in lend proxy (SUSD): {e}. Box: {box}") + except (IndexError, KeyError, TypeError, ValueError) as e: + logger.error(f"[Lend Proxy SUSD] Error accessing box assets: {e}. Transaction ID: {box.get('transactionId', 'unknown')}, Box: {box}") return None pool_box, borrowed = latest_pool_info(pool, latest_tx) diff --git a/token_pools/t_repay_to_pool_susd.py b/token_pools/t_repay_to_pool_susd.py index c8ddd9f..e13f3b2 100644 --- a/token_pools/t_repay_to_pool_susd.py +++ b/token_pools/t_repay_to_pool_susd.py @@ -14,8 +14,8 @@ def process_repay_to_pool_box(pool, box, latest_tx): try: assets_to_give = box["assets"][1]["amount"] final_borrowed = borrowed - int(box["assets"][0]["amount"]) - except (IndexError, KeyError, TypeError) as e: - logger.error(f"Error accessing box assets in repay to pool (SUSD): {e}. Box: {box}") + except (IndexError, KeyError, TypeError, ValueError) as e: + logger.error(f"[Repay to Pool SUSD] Error accessing box assets: {e}. Transaction ID: {box.get('transactionId', 'unknown')}, Box: {box}") return None transaction_to_sign = \ diff --git a/token_pools/t_withdraw_proxy_sigusd.py b/token_pools/t_withdraw_proxy_sigusd.py index dc61c5c..e83eb81 100644 --- a/token_pools/t_withdraw_proxy_sigusd.py +++ b/token_pools/t_withdraw_proxy_sigusd.py @@ -15,8 +15,8 @@ def process_withdraw_proxy_box(pool, box, latest_tx): if box["assets"][0]["tokenId"] != pool["LEND_TOKEN"]: return latest_tx user_gives = box["assets"][0]["amount"] - except (IndexError, KeyError, TypeError) as e: - logger.error(f"Error accessing box assets in withdraw proxy (SUSD): {e}. Box: {box}") + except (IndexError, KeyError, TypeError, ValueError) as e: + logger.error(f"[Withdraw Proxy SUSD] Error accessing box assets: {e}. Transaction ID: {box.get('transactionId', 'unknown')}, Box: {box}") return None pool_box, borrowed = latest_pool_info(pool, latest_tx) From c3c758777d49c0f295b0ff6a14b3e6cc53bdd76c Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 21:56:36 -0400 Subject: [PATCH 05/15] more concise logging, with hyperlink, and more robust checks --- erg_pool/e_repay_to_pool.py | 17 ++++++++++++++--- erg_pool/e_withdraw_proxy.py | 14 ++++++++++++-- token_pools/t_lend_proxy_sUsd.py | 15 +++++++++++++-- token_pools/t_repay_to_pool_susd.py | 14 ++++++++++++-- token_pools/t_withdraw_proxy_sigusd.py | 15 +++++++++++++-- 5 files changed, 64 insertions(+), 11 deletions(-) diff --git a/erg_pool/e_repay_to_pool.py b/erg_pool/e_repay_to_pool.py index 82b3b19..98b9538 100644 --- a/erg_pool/e_repay_to_pool.py +++ b/erg_pool/e_repay_to_pool.py @@ -10,12 +10,23 @@ def process_repay_to_pool_box(pool, box, latest_tx): erg_pool_box, borrowed = latest_pool_info(pool, latest_tx) - erg_to_give = box["value"] - TX_FEE + + box_id = box.get('boxId', 'unknown') + transaction_id = box.get('transactionId', 'unknown') + explorer_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + + if "assets" not in box or not box["assets"]: + if explorer_url: + logger.error(f"[Repay to Pool] Box has no assets. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, verify the bot's configuration or contact Duckpools support on Discord.") + else: + logger.error(f"[Repay to Pool] Box has no assets. Transaction ID: {transaction_id}, Box ID: unknown. Unable to provide Erg Explorer link. Please verify the bot's configuration or contact Duckpools support on Discord.") + return None + try: final_borrowed = borrowed - int(box["assets"][0]["amount"]) - except (IndexError, KeyError, TypeError, ValueError) as e: - logger.error(f"[Repay to Pool] Error accessing box assets: {e}. Transaction ID: {box.get('transactionId', 'unknown')}, Box: {box}") + except (ValueError, TypeError) as e: + logger.error(f"[Repay to Pool] Invalid asset amount: {e}. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, contact Duckpools support on Discord.") return None transaction_to_sign = \ diff --git a/erg_pool/e_withdraw_proxy.py b/erg_pool/e_withdraw_proxy.py index a510c27..0b305c8 100644 --- a/erg_pool/e_withdraw_proxy.py +++ b/erg_pool/e_withdraw_proxy.py @@ -13,11 +13,21 @@ def process_withdraw_proxy_box(pool, box, latest_tx): erg_pool_box, borrowed = latest_pool_info(pool, latest_tx) + box_id = box.get('boxId', 'unknown') + transaction_id = box.get('transactionId', 'unknown') + explorer_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + + if "assets" not in box or not box["assets"]: + if explorer_url: + logger.error(f"[Withdraw Proxy] Box has no assets. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, verify the bot's configuration or contact Duckpools support on Discord.") + else: + logger.error(f"[Withdraw Proxy] Box has no assets. Transaction ID: {transaction_id}, Box ID: unknown. Unable to provide Erg Explorer link. Please verify the bot's configuration or contact Duckpools support on Discord.") + return None try: user_gives = box["assets"][0]["amount"] - except (IndexError, KeyError, TypeError, ValueError) as e: - logger.error(f"[Withdraw Proxy] Error accessing box assets: {e}. Transaction ID: {box.get('transactionId', 'unknown')}, Box: {box}") + except (ValueError, TypeError) as e: + logger.error(f"[Withdraw Proxy] Invalid asset amount: {e}. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, contact Duckpools support on Discord.") return None held_erg0 = erg_pool_box["value"] diff --git a/token_pools/t_lend_proxy_sUsd.py b/token_pools/t_lend_proxy_sUsd.py index 0ed8841..ef218e7 100644 --- a/token_pools/t_lend_proxy_sUsd.py +++ b/token_pools/t_lend_proxy_sUsd.py @@ -11,12 +11,23 @@ def process_lend_proxy_box(pool, box, latest_tx): + box_id = box.get('boxId', 'unknown') + transaction_id = box.get('transactionId', 'unknown') + explorer_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + + if "assets" not in box or not box["assets"]: + if explorer_url: + logger.error(f"[Lend Proxy SUSD] Box has no assets. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, verify the bot's configuration or contact Duckpools support on Discord.") + else: + logger.error(f"[Lend Proxy SUSD] Box has no assets. Transaction ID: {transaction_id}, Box ID: unknown. Unable to provide Erg Explorer link. Please verify the bot's configuration or contact Duckpools support on Discord.") + return None + try: if box["assets"][0]["tokenId"] != pool["CURRENCY_ID"]: return latest_tx token_amount = box["assets"][0]["amount"] - except (IndexError, KeyError, TypeError, ValueError) as e: - logger.error(f"[Lend Proxy SUSD] Error accessing box assets: {e}. Transaction ID: {box.get('transactionId', 'unknown')}, Box: {box}") + except (ValueError, TypeError) as e: + logger.error(f"[Lend Proxy SUSD] Invalid asset amount: {e}. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, contact Duckpools support on Discord.") return None pool_box, borrowed = latest_pool_info(pool, latest_tx) diff --git a/token_pools/t_repay_to_pool_susd.py b/token_pools/t_repay_to_pool_susd.py index e13f3b2..409cd6a 100644 --- a/token_pools/t_repay_to_pool_susd.py +++ b/token_pools/t_repay_to_pool_susd.py @@ -10,12 +10,22 @@ def process_repay_to_pool_box(pool, box, latest_tx): pool_box, borrowed = latest_pool_info(pool, latest_tx) + box_id = box.get('boxId', 'unknown') + transaction_id = box.get('transactionId', 'unknown') + explorer_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + + if "assets" not in box or len(box["assets"]) < 2: + if explorer_url: + logger.error(f"[Repay to Pool SUSD] Box has insufficient assets. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, verify the bot's configuration or contact Duckpools support on Discord.") + else: + logger.error(f"[Repay to Pool SUSD] Box has insufficient assets. Transaction ID: {transaction_id}, Box ID: unknown. Unable to provide Erg Explorer link. Please verify the bot's configuration or contact Duckpools support on Discord.") + return None try: assets_to_give = box["assets"][1]["amount"] final_borrowed = borrowed - int(box["assets"][0]["amount"]) - except (IndexError, KeyError, TypeError, ValueError) as e: - logger.error(f"[Repay to Pool SUSD] Error accessing box assets: {e}. Transaction ID: {box.get('transactionId', 'unknown')}, Box: {box}") + except (ValueError, TypeError) as e: + logger.error(f"[Repay to Pool SUSD] Invalid asset amount: {e}. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, contact Duckpools support on Discord.") return None transaction_to_sign = \ diff --git a/token_pools/t_withdraw_proxy_sigusd.py b/token_pools/t_withdraw_proxy_sigusd.py index e83eb81..420a17d 100644 --- a/token_pools/t_withdraw_proxy_sigusd.py +++ b/token_pools/t_withdraw_proxy_sigusd.py @@ -11,12 +11,23 @@ def process_withdraw_proxy_box(pool, box, latest_tx): + box_id = box.get('boxId', 'unknown') + transaction_id = box.get('transactionId', 'unknown') + explorer_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + + if "assets" not in box or not box["assets"]: + if explorer_url: + logger.error(f"[Withdraw Proxy SUSD] Box has no assets. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, verify the bot's configuration or contact Duckpools support on Discord.") + else: + logger.error(f"[Withdraw Proxy SUSD] Box has no assets. Transaction ID: {transaction_id}, Box ID: unknown. Unable to provide Erg Explorer link. Please verify the bot's configuration or contact Duckpools support on Discord.") + return None + try: if box["assets"][0]["tokenId"] != pool["LEND_TOKEN"]: return latest_tx user_gives = box["assets"][0]["amount"] - except (IndexError, KeyError, TypeError, ValueError) as e: - logger.error(f"[Withdraw Proxy SUSD] Error accessing box assets: {e}. Transaction ID: {box.get('transactionId', 'unknown')}, Box: {box}") + except (ValueError, TypeError) as e: + logger.error(f"[Withdraw Proxy SUSD] Invalid asset amount: {e}. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, contact Duckpools support on Discord.") return None pool_box, borrowed = latest_pool_info(pool, latest_tx) From 5df5f3933944254a6e76ee048e1661a9698d02db Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 22:05:34 -0400 Subject: [PATCH 06/15] bullets in logging error, also hyperlink fixes, and newlines --- erg_pool/e_repay_to_pool.py | 32 +++++++++++++++++++++++--- erg_pool/e_withdraw_proxy.py | 32 +++++++++++++++++++++++--- token_pools/t_lend_proxy_sUsd.py | 31 ++++++++++++++++++++++--- token_pools/t_repay_to_pool_susd.py | 31 ++++++++++++++++++++++--- token_pools/t_withdraw_proxy_sigusd.py | 32 +++++++++++++++++++++++--- 5 files changed, 143 insertions(+), 15 deletions(-) diff --git a/erg_pool/e_repay_to_pool.py b/erg_pool/e_repay_to_pool.py index 98b9538..bcb6812 100644 --- a/erg_pool/e_repay_to_pool.py +++ b/erg_pool/e_repay_to_pool.py @@ -8,6 +8,12 @@ logger = set_logger(__name__) +def make_terminal_link(url, text=None): + if not text: + text = url + return f"\033]8;;{url}\033\\{text}\033]8;;\033\\" + + def process_repay_to_pool_box(pool, box, latest_tx): erg_pool_box, borrowed = latest_pool_info(pool, latest_tx) erg_to_give = box["value"] - TX_FEE @@ -18,15 +24,35 @@ def process_repay_to_pool_box(pool, box, latest_tx): if "assets" not in box or not box["assets"]: if explorer_url: - logger.error(f"[Repay to Pool] Box has no assets. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, verify the bot's configuration or contact Duckpools support on Discord.") + link = make_terminal_link(explorer_url, "Erg Explorer") + logger.error( + f"[Repay to Pool] Box has no assets.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: {box_id}\n" + f"- Check the box on {link}\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) else: - logger.error(f"[Repay to Pool] Box has no assets. Transaction ID: {transaction_id}, Box ID: unknown. Unable to provide Erg Explorer link. Please verify the bot's configuration or contact Duckpools support on Discord.") + logger.error( + f"[Repay to Pool] Box has no assets.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: unknown\n" + f"- Unable to provide Erg Explorer link.\n" + f"- Please verify the bot's configuration or contact Duckpools support on Discord.\n" + ) return None try: final_borrowed = borrowed - int(box["assets"][0]["amount"]) except (ValueError, TypeError) as e: - logger.error(f"[Repay to Pool] Invalid asset amount: {e}. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, contact Duckpools support on Discord.") + link = make_terminal_link(explorer_url, "Erg Explorer") if explorer_url else "(no link)" + logger.error( + f"[Repay to Pool] Invalid asset amount: {e}.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: {box_id}\n" + f"- Check the box on {link}\n" + f"- If this persists, contact Duckpools support on Discord.\n" + ) return None transaction_to_sign = \ diff --git a/erg_pool/e_withdraw_proxy.py b/erg_pool/e_withdraw_proxy.py index 0b305c8..81588ba 100644 --- a/erg_pool/e_withdraw_proxy.py +++ b/erg_pool/e_withdraw_proxy.py @@ -11,6 +11,12 @@ logger = set_logger(__name__) +def make_terminal_link(url, text=None): + if not text: + text = url + return f"\033]8;;{url}\033\\{text}\033]8;;\033\\" + + def process_withdraw_proxy_box(pool, box, latest_tx): erg_pool_box, borrowed = latest_pool_info(pool, latest_tx) box_id = box.get('boxId', 'unknown') @@ -19,15 +25,35 @@ def process_withdraw_proxy_box(pool, box, latest_tx): if "assets" not in box or not box["assets"]: if explorer_url: - logger.error(f"[Withdraw Proxy] Box has no assets. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, verify the bot's configuration or contact Duckpools support on Discord.") + link = make_terminal_link(explorer_url, "Erg Explorer") + logger.error( + f"[Withdraw Proxy] Box has no assets.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: {box_id}\n" + f"- Check the box on {link}\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) else: - logger.error(f"[Withdraw Proxy] Box has no assets. Transaction ID: {transaction_id}, Box ID: unknown. Unable to provide Erg Explorer link. Please verify the bot's configuration or contact Duckpools support on Discord.") + logger.error( + f"[Withdraw Proxy] Box has no assets.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: unknown\n" + f"- Unable to provide Erg Explorer link.\n" + f"- Please verify the bot's configuration or contact Duckpools support on Discord.\n" + ) return None try: user_gives = box["assets"][0]["amount"] except (ValueError, TypeError) as e: - logger.error(f"[Withdraw Proxy] Invalid asset amount: {e}. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, contact Duckpools support on Discord.") + link = make_terminal_link(explorer_url, "Erg Explorer") if explorer_url else "(no link)" + logger.error( + f"[Withdraw Proxy] Invalid asset amount: {e}.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: {box_id}\n" + f"- Check the box on {link}\n" + f"- If this persists, contact Duckpools support on Discord.\n" + ) return None held_erg0 = erg_pool_box["value"] diff --git a/token_pools/t_lend_proxy_sUsd.py b/token_pools/t_lend_proxy_sUsd.py index ef218e7..1900ebb 100644 --- a/token_pools/t_lend_proxy_sUsd.py +++ b/token_pools/t_lend_proxy_sUsd.py @@ -10,6 +10,11 @@ logger = set_logger(__name__) +def make_terminal_link(url, text=None): + if not text: + text = url + return f"\033]8;;{url}\033\\{text}\033]8;;\033\\" + def process_lend_proxy_box(pool, box, latest_tx): box_id = box.get('boxId', 'unknown') transaction_id = box.get('transactionId', 'unknown') @@ -17,9 +22,22 @@ def process_lend_proxy_box(pool, box, latest_tx): if "assets" not in box or not box["assets"]: if explorer_url: - logger.error(f"[Lend Proxy SUSD] Box has no assets. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, verify the bot's configuration or contact Duckpools support on Discord.") + link = make_terminal_link(explorer_url, "Erg Explorer") + logger.error( + f"[Lend Proxy SUSD] Box has no assets.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: {box_id}\n" + f"- Check the box on {link}\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) else: - logger.error(f"[Lend Proxy SUSD] Box has no assets. Transaction ID: {transaction_id}, Box ID: unknown. Unable to provide Erg Explorer link. Please verify the bot's configuration or contact Duckpools support on Discord.") + logger.error( + f"[Lend Proxy SUSD] Box has no assets.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: unknown\n" + f"- Unable to provide Erg Explorer link.\n" + f"- Please verify the bot's configuration or contact Duckpools support on Discord.\n" + ) return None try: @@ -27,7 +45,14 @@ def process_lend_proxy_box(pool, box, latest_tx): return latest_tx token_amount = box["assets"][0]["amount"] except (ValueError, TypeError) as e: - logger.error(f"[Lend Proxy SUSD] Invalid asset amount: {e}. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, contact Duckpools support on Discord.") + link = make_terminal_link(explorer_url, "Erg Explorer") if explorer_url else "(no link)" + logger.error( + f"[Lend Proxy SUSD] Invalid asset amount: {e}.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: {box_id}\n" + f"- Check the box on {link}\n" + f"- If this persists, contact Duckpools support on Discord.\n" + ) return None pool_box, borrowed = latest_pool_info(pool, latest_tx) diff --git a/token_pools/t_repay_to_pool_susd.py b/token_pools/t_repay_to_pool_susd.py index 409cd6a..0ddf9b2 100644 --- a/token_pools/t_repay_to_pool_susd.py +++ b/token_pools/t_repay_to_pool_susd.py @@ -8,6 +8,11 @@ logger = set_logger(__name__) +def make_terminal_link(url, text=None): + if not text: + text = url + return f"\033]8;;{url}\033\\{text}\033]8;;\033\\" + def process_repay_to_pool_box(pool, box, latest_tx): pool_box, borrowed = latest_pool_info(pool, latest_tx) box_id = box.get('boxId', 'unknown') @@ -16,16 +21,36 @@ def process_repay_to_pool_box(pool, box, latest_tx): if "assets" not in box or len(box["assets"]) < 2: if explorer_url: - logger.error(f"[Repay to Pool SUSD] Box has insufficient assets. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, verify the bot's configuration or contact Duckpools support on Discord.") + link = make_terminal_link(explorer_url, "Erg Explorer") + logger.error( + f"[Repay to Pool SUSD] Box has insufficient assets.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: {box_id}\n" + f"- Check the box on {link}\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) else: - logger.error(f"[Repay to Pool SUSD] Box has insufficient assets. Transaction ID: {transaction_id}, Box ID: unknown. Unable to provide Erg Explorer link. Please verify the bot's configuration or contact Duckpools support on Discord.") + logger.error( + f"[Repay to Pool SUSD] Box has insufficient assets.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: unknown\n" + f"- Unable to provide Erg Explorer link.\n" + f"- Please verify the bot's configuration or contact Duckpools support on Discord.\n" + ) return None try: assets_to_give = box["assets"][1]["amount"] final_borrowed = borrowed - int(box["assets"][0]["amount"]) except (ValueError, TypeError) as e: - logger.error(f"[Repay to Pool SUSD] Invalid asset amount: {e}. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, contact Duckpools support on Discord.") + link = make_terminal_link(explorer_url, "Erg Explorer") if explorer_url else "(no link)" + logger.error( + f"[Repay to Pool SUSD] Invalid asset amount: {e}.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: {box_id}\n" + f"- Check the box on {link}\n" + f"- If this persists, contact Duckpools support on Discord.\n" + ) return None transaction_to_sign = \ diff --git a/token_pools/t_withdraw_proxy_sigusd.py b/token_pools/t_withdraw_proxy_sigusd.py index 420a17d..d093e01 100644 --- a/token_pools/t_withdraw_proxy_sigusd.py +++ b/token_pools/t_withdraw_proxy_sigusd.py @@ -10,6 +10,12 @@ logger = set_logger(__name__) +def make_terminal_link(url, text=None): + if not text: + text = url + return f"\033]8;;{url}\033\\{text}\033]8;;\033\\" + + def process_withdraw_proxy_box(pool, box, latest_tx): box_id = box.get('boxId', 'unknown') transaction_id = box.get('transactionId', 'unknown') @@ -17,9 +23,22 @@ def process_withdraw_proxy_box(pool, box, latest_tx): if "assets" not in box or not box["assets"]: if explorer_url: - logger.error(f"[Withdraw Proxy SUSD] Box has no assets. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, verify the bot's configuration or contact Duckpools support on Discord.") + link = make_terminal_link(explorer_url, "Erg Explorer") + logger.error( + f"[Withdraw Proxy SUSD] Box has no assets.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: {box_id}\n" + f"- Check the box on {link}\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) else: - logger.error(f"[Withdraw Proxy SUSD] Box has no assets. Transaction ID: {transaction_id}, Box ID: unknown. Unable to provide Erg Explorer link. Please verify the bot's configuration or contact Duckpools support on Discord.") + logger.error( + f"[Withdraw Proxy SUSD] Box has no assets.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: unknown\n" + f"- Unable to provide Erg Explorer link.\n" + f"- Please verify the bot's configuration or contact Duckpools support on Discord.\n" + ) return None try: @@ -27,7 +46,14 @@ def process_withdraw_proxy_box(pool, box, latest_tx): return latest_tx user_gives = box["assets"][0]["amount"] except (ValueError, TypeError) as e: - logger.error(f"[Withdraw Proxy SUSD] Invalid asset amount: {e}. Transaction ID: {transaction_id}, Box ID: {box_id}. Check the box on Erg Explorer: {explorer_url}. If this persists, contact Duckpools support on Discord.") + link = make_terminal_link(explorer_url, "Erg Explorer") if explorer_url else "(no link)" + logger.error( + f"[Withdraw Proxy SUSD] Invalid asset amount: {e}.\n" + f"- Transaction ID: {transaction_id}\n" + f"- Box ID: {box_id}\n" + f"- Check the box on {link}\n" + f"- If this persists, contact Duckpools support on Discord.\n" + ) return None pool_box, borrowed = latest_pool_info(pool, latest_tx) From 3a3e82647aa781838687d9378e270083363aa5a4 Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 22:12:22 -0400 Subject: [PATCH 07/15] bullets in logging error, also hyperlink fixes, and newlines --- erg_pool/e_repay_to_pool.py | 34 +++++++++----------------- erg_pool/e_withdraw_proxy.py | 34 +++++++++----------------- token_pools/t_lend_proxy_sUsd.py | 34 +++++++++----------------- token_pools/t_repay_to_pool_susd.py | 34 +++++++++----------------- token_pools/t_withdraw_proxy_sigusd.py | 34 +++++++++----------------- 5 files changed, 60 insertions(+), 110 deletions(-) diff --git a/erg_pool/e_repay_to_pool.py b/erg_pool/e_repay_to_pool.py index bcb6812..9386bb9 100644 --- a/erg_pool/e_repay_to_pool.py +++ b/erg_pool/e_repay_to_pool.py @@ -20,37 +20,27 @@ def process_repay_to_pool_box(pool, box, latest_tx): box_id = box.get('boxId', 'unknown') transaction_id = box.get('transactionId', 'unknown') - explorer_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + box_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None + box_link = make_terminal_link(box_url, box_id) if box_url else box_id + tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id if "assets" not in box or not box["assets"]: - if explorer_url: - link = make_terminal_link(explorer_url, "Erg Explorer") - logger.error( - f"[Repay to Pool] Box has no assets.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: {box_id}\n" - f"- Check the box on {link}\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" - ) - else: - logger.error( - f"[Repay to Pool] Box has no assets.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: unknown\n" - f"- Unable to provide Erg Explorer link.\n" - f"- Please verify the bot's configuration or contact Duckpools support on Discord.\n" - ) + logger.error( + f"[Repay to Pool] Box has no assets, the pool wallet needs to be refilled.\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) return None try: final_borrowed = borrowed - int(box["assets"][0]["amount"]) except (ValueError, TypeError) as e: - link = make_terminal_link(explorer_url, "Erg Explorer") if explorer_url else "(no link)" logger.error( f"[Repay to Pool] Invalid asset amount: {e}.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: {box_id}\n" - f"- Check the box on {link}\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" f"- If this persists, contact Duckpools support on Discord.\n" ) return None diff --git a/erg_pool/e_withdraw_proxy.py b/erg_pool/e_withdraw_proxy.py index 81588ba..e175b8f 100644 --- a/erg_pool/e_withdraw_proxy.py +++ b/erg_pool/e_withdraw_proxy.py @@ -21,37 +21,27 @@ def process_withdraw_proxy_box(pool, box, latest_tx): erg_pool_box, borrowed = latest_pool_info(pool, latest_tx) box_id = box.get('boxId', 'unknown') transaction_id = box.get('transactionId', 'unknown') - explorer_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + box_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None + box_link = make_terminal_link(box_url, box_id) if box_url else box_id + tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id if "assets" not in box or not box["assets"]: - if explorer_url: - link = make_terminal_link(explorer_url, "Erg Explorer") - logger.error( - f"[Withdraw Proxy] Box has no assets.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: {box_id}\n" - f"- Check the box on {link}\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" - ) - else: - logger.error( - f"[Withdraw Proxy] Box has no assets.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: unknown\n" - f"- Unable to provide Erg Explorer link.\n" - f"- Please verify the bot's configuration or contact Duckpools support on Discord.\n" - ) + logger.error( + f"[Withdraw Proxy] Box has no assets, the pool wallet needs to be refilled.\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) return None try: user_gives = box["assets"][0]["amount"] except (ValueError, TypeError) as e: - link = make_terminal_link(explorer_url, "Erg Explorer") if explorer_url else "(no link)" logger.error( f"[Withdraw Proxy] Invalid asset amount: {e}.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: {box_id}\n" - f"- Check the box on {link}\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" f"- If this persists, contact Duckpools support on Discord.\n" ) return None diff --git a/token_pools/t_lend_proxy_sUsd.py b/token_pools/t_lend_proxy_sUsd.py index 1900ebb..898a41c 100644 --- a/token_pools/t_lend_proxy_sUsd.py +++ b/token_pools/t_lend_proxy_sUsd.py @@ -18,26 +18,18 @@ def make_terminal_link(url, text=None): def process_lend_proxy_box(pool, box, latest_tx): box_id = box.get('boxId', 'unknown') transaction_id = box.get('transactionId', 'unknown') - explorer_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + box_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None + box_link = make_terminal_link(box_url, box_id) if box_url else box_id + tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id if "assets" not in box or not box["assets"]: - if explorer_url: - link = make_terminal_link(explorer_url, "Erg Explorer") - logger.error( - f"[Lend Proxy SUSD] Box has no assets.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: {box_id}\n" - f"- Check the box on {link}\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" - ) - else: - logger.error( - f"[Lend Proxy SUSD] Box has no assets.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: unknown\n" - f"- Unable to provide Erg Explorer link.\n" - f"- Please verify the bot's configuration or contact Duckpools support on Discord.\n" - ) + logger.error( + f"[Lend Proxy SUSD] Box has no assets, the pool wallet needs to be refilled.\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) return None try: @@ -45,12 +37,10 @@ def process_lend_proxy_box(pool, box, latest_tx): return latest_tx token_amount = box["assets"][0]["amount"] except (ValueError, TypeError) as e: - link = make_terminal_link(explorer_url, "Erg Explorer") if explorer_url else "(no link)" logger.error( f"[Lend Proxy SUSD] Invalid asset amount: {e}.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: {box_id}\n" - f"- Check the box on {link}\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" f"- If this persists, contact Duckpools support on Discord.\n" ) return None diff --git a/token_pools/t_repay_to_pool_susd.py b/token_pools/t_repay_to_pool_susd.py index 0ddf9b2..c4f9502 100644 --- a/token_pools/t_repay_to_pool_susd.py +++ b/token_pools/t_repay_to_pool_susd.py @@ -17,38 +17,28 @@ def process_repay_to_pool_box(pool, box, latest_tx): pool_box, borrowed = latest_pool_info(pool, latest_tx) box_id = box.get('boxId', 'unknown') transaction_id = box.get('transactionId', 'unknown') - explorer_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + box_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None + box_link = make_terminal_link(box_url, box_id) if box_url else box_id + tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id if "assets" not in box or len(box["assets"]) < 2: - if explorer_url: - link = make_terminal_link(explorer_url, "Erg Explorer") - logger.error( - f"[Repay to Pool SUSD] Box has insufficient assets.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: {box_id}\n" - f"- Check the box on {link}\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" - ) - else: - logger.error( - f"[Repay to Pool SUSD] Box has insufficient assets.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: unknown\n" - f"- Unable to provide Erg Explorer link.\n" - f"- Please verify the bot's configuration or contact Duckpools support on Discord.\n" - ) + logger.error( + f"[Repay to Pool SUSD] Box has no assets, the pool wallet needs to be refilled.\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) return None try: assets_to_give = box["assets"][1]["amount"] final_borrowed = borrowed - int(box["assets"][0]["amount"]) except (ValueError, TypeError) as e: - link = make_terminal_link(explorer_url, "Erg Explorer") if explorer_url else "(no link)" logger.error( f"[Repay to Pool SUSD] Invalid asset amount: {e}.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: {box_id}\n" - f"- Check the box on {link}\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" f"- If this persists, contact Duckpools support on Discord.\n" ) return None diff --git a/token_pools/t_withdraw_proxy_sigusd.py b/token_pools/t_withdraw_proxy_sigusd.py index d093e01..cb2f127 100644 --- a/token_pools/t_withdraw_proxy_sigusd.py +++ b/token_pools/t_withdraw_proxy_sigusd.py @@ -19,26 +19,18 @@ def make_terminal_link(url, text=None): def process_withdraw_proxy_box(pool, box, latest_tx): box_id = box.get('boxId', 'unknown') transaction_id = box.get('transactionId', 'unknown') - explorer_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + box_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None + box_link = make_terminal_link(box_url, box_id) if box_url else box_id + tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id if "assets" not in box or not box["assets"]: - if explorer_url: - link = make_terminal_link(explorer_url, "Erg Explorer") - logger.error( - f"[Withdraw Proxy SUSD] Box has no assets.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: {box_id}\n" - f"- Check the box on {link}\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" - ) - else: - logger.error( - f"[Withdraw Proxy SUSD] Box has no assets.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: unknown\n" - f"- Unable to provide Erg Explorer link.\n" - f"- Please verify the bot's configuration or contact Duckpools support on Discord.\n" - ) + logger.error( + f"[Withdraw Proxy SUSD] Box has no assets, the pool wallet needs to be refilled.\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) return None try: @@ -46,12 +38,10 @@ def process_withdraw_proxy_box(pool, box, latest_tx): return latest_tx user_gives = box["assets"][0]["amount"] except (ValueError, TypeError) as e: - link = make_terminal_link(explorer_url, "Erg Explorer") if explorer_url else "(no link)" logger.error( f"[Withdraw Proxy SUSD] Invalid asset amount: {e}.\n" - f"- Transaction ID: {transaction_id}\n" - f"- Box ID: {box_id}\n" - f"- Check the box on {link}\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" f"- If this persists, contact Duckpools support on Discord.\n" ) return None From 0d96fecfe15ba0ff60f6e84d2a45b943735ae829 Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 22:14:45 -0400 Subject: [PATCH 08/15] same logic applied to clean log files for WARN failed to process or refund txn obj --- erg_pool/e_borrow_proxy.py | 19 ++++++++++++++++--- erg_pool/e_lend_proxy.py | 1 + erg_pool/e_repay_proxy.py | 18 ++++++++++++++++-- erg_pool/e_withdraw_proxy.py | 18 +++++++++++++++--- token_pools/t_borrow_proxy_susd.py | 19 ++++++++++++++++--- token_pools/t_lend_proxy_sUsd.py | 19 +++++++++++++++---- token_pools/t_repay_proxy_susd.py | 18 ++++++++++++++++-- token_pools/t_withdraw_proxy_sigusd.py | 18 +++++++++++++++--- 8 files changed, 110 insertions(+), 20 deletions(-) diff --git a/erg_pool/e_borrow_proxy.py b/erg_pool/e_borrow_proxy.py index 498bc57..6c5f58e 100644 --- a/erg_pool/e_borrow_proxy.py +++ b/erg_pool/e_borrow_proxy.py @@ -8,6 +8,7 @@ get_pool_param_box from helpers.serializer import encode_int_tuple, encode_long, encode_long_pair from logger import set_logger +from helpers.terminal_link import make_terminal_link logger = set_logger(__name__) @@ -152,9 +153,21 @@ def process_borrow_proxy_box(pool, box, latest_tx, fee=TX_FEE): if tx_id != -1: logger.info("Successfully submitted refund transaction with ID: %s", tx_id) else: - logger.warning("Failed to process or refund transaction object: %s Failed Refund txID quoted as: %s", - json.dumps(transaction_to_sign), tx_id) - return latest_tx + box_id = box.get('boxId', 'unknown') + transaction_id = box.get('transactionId', 'unknown') + box_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None + box_link = make_terminal_link(box_url, box_id) if box_url else box_id + tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id + logger.warning( + f"Failed to process or refund transaction.\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" + f"- Refund txID: -1\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) + logger.debug(f"Full transaction object: {transaction_to_sign}") + return latest_tx return obj diff --git a/erg_pool/e_lend_proxy.py b/erg_pool/e_lend_proxy.py index 385da79..528d293 100644 --- a/erg_pool/e_lend_proxy.py +++ b/erg_pool/e_lend_proxy.py @@ -7,6 +7,7 @@ from helpers.node_calls import tree_to_address, box_id_to_binary, sign_tx from helpers.platform_functions import calculate_final_amount, get_pool_param_box from logger import set_logger +from helpers.terminal_links import make_terminal_link logger = set_logger(__name__) diff --git a/erg_pool/e_repay_proxy.py b/erg_pool/e_repay_proxy.py index f5ddfcb..8de2f21 100644 --- a/erg_pool/e_repay_proxy.py +++ b/erg_pool/e_repay_proxy.py @@ -7,6 +7,7 @@ from helpers.platform_functions import get_parent_box, get_head_child, get_children_boxes, get_base_child, \ get_interest_box from logger import set_logger +from helpers.terminal_links import make_terminal_link logger = set_logger(__name__) @@ -36,8 +37,21 @@ def refund_repay_proxy_box(box): if tx_id != -1: logger.info("Successfully submitted refund transaction with ID: %s", tx_id) else: - logger.warning("Failed to process or refund transaction object: %s Failed Refund txID quoted as: %s", - json.dumps(transaction_to_sign), tx_id) + box_id = box.get('boxId', 'unknown') + transaction_id = box.get('transactionId', 'unknown') + box_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None + box_link = make_terminal_link(box_url, box_id) if box_url else box_id + tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id + logger.warning( + f"Failed to process or refund transaction.\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" + f"- Refund txID: -1\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) + logger.debug(f"Full transaction object: {transaction_to_sign}") + return latest_tx def process_repay_proxy_box(pool, box, empty): diff --git a/erg_pool/e_withdraw_proxy.py b/erg_pool/e_withdraw_proxy.py index e175b8f..d409495 100644 --- a/erg_pool/e_withdraw_proxy.py +++ b/erg_pool/e_withdraw_proxy.py @@ -154,9 +154,21 @@ def process_withdraw_proxy_box(pool, box, latest_tx): if tx_id != ERROR: logger.info("Successfully submitted refund transaction with ID: %s", tx_id) else: - logger.warning("Failed to process or refund transaction object: %s Failed Refund txID quoted as: %s", - json.dumps(transaction_to_sign), tx_id) - return latest_tx + box_id = box.get('boxId', 'unknown') + transaction_id = box.get('transactionId', 'unknown') + box_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None + box_link = make_terminal_link(box_url, box_id) if box_url else box_id + tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id + logger.warning( + f"Failed to process or refund transaction.\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" + f"- Refund txID: -1\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) + logger.debug(f"Full transaction object: {transaction_to_sign}") + return latest_tx return obj diff --git a/token_pools/t_borrow_proxy_susd.py b/token_pools/t_borrow_proxy_susd.py index 55503a9..3a177af 100644 --- a/token_pools/t_borrow_proxy_susd.py +++ b/token_pools/t_borrow_proxy_susd.py @@ -6,6 +6,7 @@ from helpers.platform_functions import get_dex_box, get_parent_box, get_head_child, get_pool_param_box from helpers.serializer import encode_int_tuple, encode_long, encode_long_pair from logger import set_logger +from helpers.terminal_link import make_terminal_link logger = set_logger(__name__) @@ -143,9 +144,21 @@ def process_borrow_proxy_box(pool, box, latest_tx, fee=TX_FEE): if tx_id != -1: logger.info("Successfully submitted refund transaction with ID: %s", tx_id) else: - logger.warning("Failed to process or refund transaction object: %s Failed Refund txID quoted as: %s", - json.dumps(transaction_to_sign), tx_id) - return latest_tx + box_id = box.get('boxId', 'unknown') + transaction_id = box.get('transactionId', 'unknown') + box_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None + box_link = make_terminal_link(box_url, box_id) if box_url else box_id + tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id + logger.warning( + f"Failed to process or refund transaction.\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" + f"- Refund txID: -1\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) + logger.debug(f"Full transaction object: {transaction_to_sign}") + return latest_tx return obj diff --git a/token_pools/t_lend_proxy_sUsd.py b/token_pools/t_lend_proxy_sUsd.py index 898a41c..ae00af4 100644 --- a/token_pools/t_lend_proxy_sUsd.py +++ b/token_pools/t_lend_proxy_sUsd.py @@ -159,10 +159,21 @@ def process_lend_proxy_box(pool, box, latest_tx): if tx_id != -1: logger.info("Successfully submitted refund transaction with ID: %s", tx_id) else: - logger.warning("Failed to process or refund transaction object: %s Failed Refund txID quoted as: %s", - json.dumps(transaction_to_sign), tx_id) - - return latest_tx + box_id = box.get('boxId', 'unknown') + transaction_id = box.get('transactionId', 'unknown') + box_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None + box_link = make_terminal_link(box_url, box_id) if box_url else box_id + tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id + logger.warning( + f"Failed to process or refund transaction.\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" + f"- Refund txID: -1\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) + logger.debug(f"Full transaction object: {transaction_to_sign}") + return latest_tx return obj diff --git a/token_pools/t_repay_proxy_susd.py b/token_pools/t_repay_proxy_susd.py index a9b213f..dfdd9f6 100644 --- a/token_pools/t_repay_proxy_susd.py +++ b/token_pools/t_repay_proxy_susd.py @@ -7,6 +7,7 @@ from helpers.platform_functions import get_parent_box, get_head_child, get_children_boxes, get_base_child, \ get_interest_box from logger import set_logger +from helpers.terminal_links import make_terminal_link logger = set_logger(__name__) @@ -40,8 +41,21 @@ def refund_repay_proxy_box(box): if tx_id != -1: logger.info("Successfully submitted refund transaction with ID: %s", tx_id) else: - logger.warning("Failed to process or refund transaction object: %s Failed Refund txID quoted as: %s", - json.dumps(transaction_to_sign), tx_id) + box_id = box.get('boxId', 'unknown') + transaction_id = box.get('transactionId', 'unknown') + box_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None + box_link = make_terminal_link(box_url, box_id) if box_url else box_id + tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id + logger.warning( + f"Failed to process or refund transaction.\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" + f"- Refund txID: -1\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) + logger.debug(f"Full transaction object: {transaction_to_sign}") + return latest_tx def process_repay_proxy_box(pool, box, empty): diff --git a/token_pools/t_withdraw_proxy_sigusd.py b/token_pools/t_withdraw_proxy_sigusd.py index cb2f127..8d63d65 100644 --- a/token_pools/t_withdraw_proxy_sigusd.py +++ b/token_pools/t_withdraw_proxy_sigusd.py @@ -159,9 +159,21 @@ def process_withdraw_proxy_box(pool, box, latest_tx): if tx_id != -1: logger.info("Successfully submitted refund transaction with ID: %s", tx_id) else: - logger.warning("Failed to process or refund transaction object: %s Failed Refund txID quoted as: %s", - json.dumps(transaction_to_sign), tx_id) - return latest_tx + box_id = box.get('boxId', 'unknown') + transaction_id = box.get('transactionId', 'unknown') + box_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None + box_link = make_terminal_link(box_url, box_id) if box_url else box_id + tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id + logger.warning( + f"Failed to process or refund transaction.\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" + f"- Refund txID: -1\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) + logger.debug(f"Full transaction object: {transaction_to_sign}") + return latest_tx return obj From 38a6bebed1cf88112a27ceddf941d0ecf9792f5b Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 22:17:31 -0400 Subject: [PATCH 09/15] fixed terminal.link error --- erg_pool/e_repay_to_pool.py | 7 +------ erg_pool/e_withdraw_proxy.py | 7 +------ helpers/terminal_link.py | 8 ++++++++ token_pools/t_lend_proxy_sUsd.py | 6 +----- token_pools/t_repay_to_pool_susd.py | 6 +----- token_pools/t_withdraw_proxy_sigusd.py | 7 +------ 6 files changed, 13 insertions(+), 28 deletions(-) create mode 100644 helpers/terminal_link.py diff --git a/erg_pool/e_repay_to_pool.py b/erg_pool/e_repay_to_pool.py index 9386bb9..6490a80 100644 --- a/erg_pool/e_repay_to_pool.py +++ b/erg_pool/e_repay_to_pool.py @@ -4,16 +4,11 @@ from helpers.job_helpers import latest_pool_info, job_processor from helpers.node_calls import box_id_to_binary, sign_tx from logger import set_logger +from helpers.terminal_link import make_terminal_link logger = set_logger(__name__) -def make_terminal_link(url, text=None): - if not text: - text = url - return f"\033]8;;{url}\033\\{text}\033]8;;\033\\" - - def process_repay_to_pool_box(pool, box, latest_tx): erg_pool_box, borrowed = latest_pool_info(pool, latest_tx) erg_to_give = box["value"] - TX_FEE diff --git a/erg_pool/e_withdraw_proxy.py b/erg_pool/e_withdraw_proxy.py index d409495..a1fca2a 100644 --- a/erg_pool/e_withdraw_proxy.py +++ b/erg_pool/e_withdraw_proxy.py @@ -7,16 +7,11 @@ from helpers.node_calls import tree_to_address, box_id_to_binary, sign_tx from helpers.platform_functions import calculate_service_fee, get_pool_param_box from logger import set_logger +from helpers.terminal_link import make_terminal_link logger = set_logger(__name__) -def make_terminal_link(url, text=None): - if not text: - text = url - return f"\033]8;;{url}\033\\{text}\033]8;;\033\\" - - def process_withdraw_proxy_box(pool, box, latest_tx): erg_pool_box, borrowed = latest_pool_info(pool, latest_tx) box_id = box.get('boxId', 'unknown') diff --git a/helpers/terminal_link.py b/helpers/terminal_link.py new file mode 100644 index 0000000..a48a872 --- /dev/null +++ b/helpers/terminal_link.py @@ -0,0 +1,8 @@ +def make_terminal_link(url, text=None): + """ + Returns an OSC 8 hyperlink for supported terminals (iTerm2, GNOME Terminal, etc). + If not supported, the text will just display as normal. + """ + if not text: + text = url + return f"\033]8;;{url}\033\\{text}\033]8;;\033\\" \ No newline at end of file diff --git a/token_pools/t_lend_proxy_sUsd.py b/token_pools/t_lend_proxy_sUsd.py index ae00af4..a691ada 100644 --- a/token_pools/t_lend_proxy_sUsd.py +++ b/token_pools/t_lend_proxy_sUsd.py @@ -6,15 +6,11 @@ from helpers.node_calls import tree_to_address, box_id_to_binary, sign_tx, current_height from helpers.platform_functions import calculate_final_amount, get_pool_param_box from logger import set_logger +from helpers.terminal_link import make_terminal_link logger = set_logger(__name__) -def make_terminal_link(url, text=None): - if not text: - text = url - return f"\033]8;;{url}\033\\{text}\033]8;;\033\\" - def process_lend_proxy_box(pool, box, latest_tx): box_id = box.get('boxId', 'unknown') transaction_id = box.get('transactionId', 'unknown') diff --git a/token_pools/t_repay_to_pool_susd.py b/token_pools/t_repay_to_pool_susd.py index c4f9502..d8e9164 100644 --- a/token_pools/t_repay_to_pool_susd.py +++ b/token_pools/t_repay_to_pool_susd.py @@ -4,15 +4,11 @@ from helpers.job_helpers import latest_pool_info, job_processor from helpers.node_calls import box_id_to_binary, sign_tx from logger import set_logger +from helpers.terminal_link import make_terminal_link logger = set_logger(__name__) -def make_terminal_link(url, text=None): - if not text: - text = url - return f"\033]8;;{url}\033\\{text}\033]8;;\033\\" - def process_repay_to_pool_box(pool, box, latest_tx): pool_box, borrowed = latest_pool_info(pool, latest_tx) box_id = box.get('boxId', 'unknown') diff --git a/token_pools/t_withdraw_proxy_sigusd.py b/token_pools/t_withdraw_proxy_sigusd.py index 8d63d65..5d5944b 100644 --- a/token_pools/t_withdraw_proxy_sigusd.py +++ b/token_pools/t_withdraw_proxy_sigusd.py @@ -6,16 +6,11 @@ from helpers.node_calls import tree_to_address, box_id_to_binary, sign_tx, current_height from helpers.platform_functions import calculate_service_fee, get_pool_param_box from logger import set_logger +from helpers.terminal_link import make_terminal_link logger = set_logger(__name__) -def make_terminal_link(url, text=None): - if not text: - text = url - return f"\033]8;;{url}\033\\{text}\033]8;;\033\\" - - def process_withdraw_proxy_box(pool, box, latest_tx): box_id = box.get('boxId', 'unknown') transaction_id = box.get('transactionId', 'unknown') From 08cd3e58b904c057f00628de159de2cf4772decf Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 22:21:38 -0400 Subject: [PATCH 10/15] fixed typo links to link --- erg_pool/e_lend_proxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erg_pool/e_lend_proxy.py b/erg_pool/e_lend_proxy.py index 528d293..6973f67 100644 --- a/erg_pool/e_lend_proxy.py +++ b/erg_pool/e_lend_proxy.py @@ -7,7 +7,7 @@ from helpers.node_calls import tree_to_address, box_id_to_binary, sign_tx from helpers.platform_functions import calculate_final_amount, get_pool_param_box from logger import set_logger -from helpers.terminal_links import make_terminal_link +from helpers.terminal_link import make_terminal_link logger = set_logger(__name__) From fcd0bc5ab4a48eb4d48130b3ce11724b6d0a4fd8 Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 22:24:13 -0400 Subject: [PATCH 11/15] fixed typo links to link --- erg_pool/e_repay_proxy.py | 2 +- token_pools/t_repay_proxy_susd.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erg_pool/e_repay_proxy.py b/erg_pool/e_repay_proxy.py index 8de2f21..4c01cb3 100644 --- a/erg_pool/e_repay_proxy.py +++ b/erg_pool/e_repay_proxy.py @@ -7,7 +7,7 @@ from helpers.platform_functions import get_parent_box, get_head_child, get_children_boxes, get_base_child, \ get_interest_box from logger import set_logger -from helpers.terminal_links import make_terminal_link +from helpers.terminal_link import make_terminal_link logger = set_logger(__name__) diff --git a/token_pools/t_repay_proxy_susd.py b/token_pools/t_repay_proxy_susd.py index dfdd9f6..34392b5 100644 --- a/token_pools/t_repay_proxy_susd.py +++ b/token_pools/t_repay_proxy_susd.py @@ -7,7 +7,7 @@ from helpers.platform_functions import get_parent_box, get_head_child, get_children_boxes, get_base_child, \ get_interest_box from logger import set_logger -from helpers.terminal_links import make_terminal_link +from helpers.terminal_link import make_terminal_link logger = set_logger(__name__) From f434ff8eb1e8c91b1635a6f7bf83a8ea5c7d5c99 Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 22:27:38 -0400 Subject: [PATCH 12/15] Updated warning --- erg_pool/e_lend_proxy.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/erg_pool/e_lend_proxy.py b/erg_pool/e_lend_proxy.py index 6973f67..e8c7339 100644 --- a/erg_pool/e_lend_proxy.py +++ b/erg_pool/e_lend_proxy.py @@ -124,10 +124,21 @@ def process_lend_proxy_box(pool, box, latest_tx): if tx_id != ERROR: logger.info("Successfully submitted refund transaction with ID: %s", tx_id) else: - logger.warning("Failed to process or refund transaction object: %s Failed Refund txID quoted as: %s", - json.dumps(transaction_to_sign), tx_id) - - return latest_tx + box_id = box.get('boxId', 'unknown') + transaction_id = box.get('transactionId', 'unknown') + box_url = f"https://ergexplorer.com/boxes#{box_id}" if box_id != 'unknown' else None + tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None + box_link = make_terminal_link(box_url, box_id) if box_url else box_id + tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id + logger.warning( + f"Failed to process or refund transaction.\n" + f"- Transaction ID: {tx_link}\n" + f"- Box ID: {box_link}\n" + f"- Refund txID: -1\n" + f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + ) + logger.debug(f"Full transaction object: {transaction_to_sign}") + return latest_tx return obj From b823a08c7af1b971f97863679f8b691c0dbd72d1 Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 22:30:22 -0400 Subject: [PATCH 13/15] tab indent on bullets --- erg_pool/e_borrow_proxy.py | 8 ++++---- erg_pool/e_lend_proxy.py | 8 ++++---- erg_pool/e_repay_proxy.py | 8 ++++---- token_pools/t_borrow_proxy_susd.py | 8 ++++---- token_pools/t_repay_proxy_susd.py | 8 ++++---- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/erg_pool/e_borrow_proxy.py b/erg_pool/e_borrow_proxy.py index 6c5f58e..005b0fe 100644 --- a/erg_pool/e_borrow_proxy.py +++ b/erg_pool/e_borrow_proxy.py @@ -161,10 +161,10 @@ def process_borrow_proxy_box(pool, box, latest_tx, fee=TX_FEE): tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id logger.warning( f"Failed to process or refund transaction.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- Refund txID: -1\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- Refund txID: -1\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" ) logger.debug(f"Full transaction object: {transaction_to_sign}") return latest_tx diff --git a/erg_pool/e_lend_proxy.py b/erg_pool/e_lend_proxy.py index e8c7339..074b73c 100644 --- a/erg_pool/e_lend_proxy.py +++ b/erg_pool/e_lend_proxy.py @@ -132,10 +132,10 @@ def process_lend_proxy_box(pool, box, latest_tx): tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id logger.warning( f"Failed to process or refund transaction.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- Refund txID: -1\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- Refund txID: -1\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" ) logger.debug(f"Full transaction object: {transaction_to_sign}") return latest_tx diff --git a/erg_pool/e_repay_proxy.py b/erg_pool/e_repay_proxy.py index 4c01cb3..8f439da 100644 --- a/erg_pool/e_repay_proxy.py +++ b/erg_pool/e_repay_proxy.py @@ -45,10 +45,10 @@ def refund_repay_proxy_box(box): tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id logger.warning( f"Failed to process or refund transaction.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- Refund txID: -1\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- Refund txID: -1\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" ) logger.debug(f"Full transaction object: {transaction_to_sign}") return latest_tx diff --git a/token_pools/t_borrow_proxy_susd.py b/token_pools/t_borrow_proxy_susd.py index 3a177af..fd381a7 100644 --- a/token_pools/t_borrow_proxy_susd.py +++ b/token_pools/t_borrow_proxy_susd.py @@ -152,10 +152,10 @@ def process_borrow_proxy_box(pool, box, latest_tx, fee=TX_FEE): tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id logger.warning( f"Failed to process or refund transaction.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- Refund txID: -1\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- Refund txID: -1\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" ) logger.debug(f"Full transaction object: {transaction_to_sign}") return latest_tx diff --git a/token_pools/t_repay_proxy_susd.py b/token_pools/t_repay_proxy_susd.py index 34392b5..e1cdb9a 100644 --- a/token_pools/t_repay_proxy_susd.py +++ b/token_pools/t_repay_proxy_susd.py @@ -49,10 +49,10 @@ def refund_repay_proxy_box(box): tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id logger.warning( f"Failed to process or refund transaction.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- Refund txID: -1\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- Refund txID: -1\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" ) logger.debug(f"Full transaction object: {transaction_to_sign}") return latest_tx From 04fe792a7996f66f5bf8970ed6f34a33cc739995 Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 22:32:31 -0400 Subject: [PATCH 14/15] added duckpools.io hyperlink to logging for contact jump off point --- erg_pool/e_borrow_proxy.py | 3 ++- erg_pool/e_lend_proxy.py | 3 ++- erg_pool/e_repay_proxy.py | 3 ++- token_pools/t_borrow_proxy_susd.py | 3 ++- token_pools/t_repay_proxy_susd.py | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/erg_pool/e_borrow_proxy.py b/erg_pool/e_borrow_proxy.py index 005b0fe..a9eca19 100644 --- a/erg_pool/e_borrow_proxy.py +++ b/erg_pool/e_borrow_proxy.py @@ -159,12 +159,13 @@ def process_borrow_proxy_box(pool, box, latest_tx, fee=TX_FEE): tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None box_link = make_terminal_link(box_url, box_id) if box_url else box_id tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.warning( f"Failed to process or refund transaction.\n" f"\t- Transaction ID: {tx_link}\n" f"\t- Box ID: {box_link}\n" f"\t- Refund txID: -1\n" - f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord. Visit {duckpools_link}\n" ) logger.debug(f"Full transaction object: {transaction_to_sign}") return latest_tx diff --git a/erg_pool/e_lend_proxy.py b/erg_pool/e_lend_proxy.py index 074b73c..824a3fb 100644 --- a/erg_pool/e_lend_proxy.py +++ b/erg_pool/e_lend_proxy.py @@ -130,12 +130,13 @@ def process_lend_proxy_box(pool, box, latest_tx): tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None box_link = make_terminal_link(box_url, box_id) if box_url else box_id tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.warning( f"Failed to process or refund transaction.\n" f"\t- Transaction ID: {tx_link}\n" f"\t- Box ID: {box_link}\n" f"\t- Refund txID: -1\n" - f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord. Visit {duckpools_link}\n" ) logger.debug(f"Full transaction object: {transaction_to_sign}") return latest_tx diff --git a/erg_pool/e_repay_proxy.py b/erg_pool/e_repay_proxy.py index 8f439da..2ca17c0 100644 --- a/erg_pool/e_repay_proxy.py +++ b/erg_pool/e_repay_proxy.py @@ -43,12 +43,13 @@ def refund_repay_proxy_box(box): tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None box_link = make_terminal_link(box_url, box_id) if box_url else box_id tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.warning( f"Failed to process or refund transaction.\n" f"\t- Transaction ID: {tx_link}\n" f"\t- Box ID: {box_link}\n" f"\t- Refund txID: -1\n" - f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord. Visit {duckpools_link}\n" ) logger.debug(f"Full transaction object: {transaction_to_sign}") return latest_tx diff --git a/token_pools/t_borrow_proxy_susd.py b/token_pools/t_borrow_proxy_susd.py index fd381a7..5007aa3 100644 --- a/token_pools/t_borrow_proxy_susd.py +++ b/token_pools/t_borrow_proxy_susd.py @@ -150,12 +150,13 @@ def process_borrow_proxy_box(pool, box, latest_tx, fee=TX_FEE): tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None box_link = make_terminal_link(box_url, box_id) if box_url else box_id tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.warning( f"Failed to process or refund transaction.\n" f"\t- Transaction ID: {tx_link}\n" f"\t- Box ID: {box_link}\n" f"\t- Refund txID: -1\n" - f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord. Visit {duckpools_link}\n" ) logger.debug(f"Full transaction object: {transaction_to_sign}") return latest_tx diff --git a/token_pools/t_repay_proxy_susd.py b/token_pools/t_repay_proxy_susd.py index e1cdb9a..8f2a515 100644 --- a/token_pools/t_repay_proxy_susd.py +++ b/token_pools/t_repay_proxy_susd.py @@ -47,12 +47,13 @@ def refund_repay_proxy_box(box): tx_url = f"https://ergexplorer.com/transactions#{transaction_id}" if transaction_id != 'unknown' else None box_link = make_terminal_link(box_url, box_id) if box_url else box_id tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.warning( f"Failed to process or refund transaction.\n" f"\t- Transaction ID: {tx_link}\n" f"\t- Box ID: {box_link}\n" f"\t- Refund txID: -1\n" - f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord. Visit {duckpools_link}\n" ) logger.debug(f"Full transaction object: {transaction_to_sign}") return latest_tx From dd885c70f089363cedae2e371c1a47ab7db280aa Mon Sep 17 00:00:00 2001 From: ccgarant Date: Mon, 30 Jun 2025 22:37:03 -0400 Subject: [PATCH 15/15] added bullet tab indent for ERRORs too --- erg_pool/e_repay_to_pool.py | 14 ++++++++------ erg_pool/e_withdraw_proxy.py | 14 ++++++++------ token_pools/t_lend_proxy_sUsd.py | 14 ++++++++------ token_pools/t_repay_to_pool_susd.py | 14 ++++++++------ token_pools/t_withdraw_proxy_sigusd.py | 14 ++++++++------ 5 files changed, 40 insertions(+), 30 deletions(-) diff --git a/erg_pool/e_repay_to_pool.py b/erg_pool/e_repay_to_pool.py index 6490a80..8a9b026 100644 --- a/erg_pool/e_repay_to_pool.py +++ b/erg_pool/e_repay_to_pool.py @@ -21,22 +21,24 @@ def process_repay_to_pool_box(pool, box, latest_tx): tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id if "assets" not in box or not box["assets"]: + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.error( f"[Repay to Pool] Box has no assets, the pool wallet needs to be refilled.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord. Visit {duckpools_link}\n" ) return None try: final_borrowed = borrowed - int(box["assets"][0]["amount"]) except (ValueError, TypeError) as e: + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.error( f"[Repay to Pool] Invalid asset amount: {e}.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- If this persists, contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- If this persists, contact Duckpools support on Discord. Visit {duckpools_link}\n" ) return None diff --git a/erg_pool/e_withdraw_proxy.py b/erg_pool/e_withdraw_proxy.py index a1fca2a..e970317 100644 --- a/erg_pool/e_withdraw_proxy.py +++ b/erg_pool/e_withdraw_proxy.py @@ -22,22 +22,24 @@ def process_withdraw_proxy_box(pool, box, latest_tx): tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id if "assets" not in box or not box["assets"]: + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.error( f"[Withdraw Proxy] Box has no assets, the pool wallet needs to be refilled.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord. Visit {duckpools_link}\n" ) return None try: user_gives = box["assets"][0]["amount"] except (ValueError, TypeError) as e: + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.error( f"[Withdraw Proxy] Invalid asset amount: {e}.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- If this persists, contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- If this persists, contact Duckpools support on Discord. Visit {duckpools_link}\n" ) return None diff --git a/token_pools/t_lend_proxy_sUsd.py b/token_pools/t_lend_proxy_sUsd.py index a691ada..ed6fb25 100644 --- a/token_pools/t_lend_proxy_sUsd.py +++ b/token_pools/t_lend_proxy_sUsd.py @@ -20,11 +20,12 @@ def process_lend_proxy_box(pool, box, latest_tx): tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id if "assets" not in box or not box["assets"]: + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.error( f"[Lend Proxy SUSD] Box has no assets, the pool wallet needs to be refilled.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord. Visit {duckpools_link}\n" ) return None @@ -33,11 +34,12 @@ def process_lend_proxy_box(pool, box, latest_tx): return latest_tx token_amount = box["assets"][0]["amount"] except (ValueError, TypeError) as e: + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.error( f"[Lend Proxy SUSD] Invalid asset amount: {e}.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- If this persists, contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- If this persists, contact Duckpools support on Discord. Visit {duckpools_link}\n" ) return None pool_box, borrowed = latest_pool_info(pool, latest_tx) diff --git a/token_pools/t_repay_to_pool_susd.py b/token_pools/t_repay_to_pool_susd.py index d8e9164..09a8bd5 100644 --- a/token_pools/t_repay_to_pool_susd.py +++ b/token_pools/t_repay_to_pool_susd.py @@ -19,11 +19,12 @@ def process_repay_to_pool_box(pool, box, latest_tx): tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id if "assets" not in box or len(box["assets"]) < 2: + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.error( f"[Repay to Pool SUSD] Box has no assets, the pool wallet needs to be refilled.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord. Visit {duckpools_link}\n" ) return None @@ -31,11 +32,12 @@ def process_repay_to_pool_box(pool, box, latest_tx): assets_to_give = box["assets"][1]["amount"] final_borrowed = borrowed - int(box["assets"][0]["amount"]) except (ValueError, TypeError) as e: + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.error( f"[Repay to Pool SUSD] Invalid asset amount: {e}.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- If this persists, contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- If this persists, contact Duckpools support on Discord. Visit {duckpools_link}\n" ) return None diff --git a/token_pools/t_withdraw_proxy_sigusd.py b/token_pools/t_withdraw_proxy_sigusd.py index 5d5944b..b3e18cd 100644 --- a/token_pools/t_withdraw_proxy_sigusd.py +++ b/token_pools/t_withdraw_proxy_sigusd.py @@ -20,11 +20,12 @@ def process_withdraw_proxy_box(pool, box, latest_tx): tx_link = make_terminal_link(tx_url, transaction_id) if tx_url else transaction_id if "assets" not in box or not box["assets"]: + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.error( f"[Withdraw Proxy SUSD] Box has no assets, the pool wallet needs to be refilled.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- If this persists, verify the bot's configuration or contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- If this persists, verify the bot's configuration or contact Duckpools support on Discord. Visit {duckpools_link}\n" ) return None @@ -33,11 +34,12 @@ def process_withdraw_proxy_box(pool, box, latest_tx): return latest_tx user_gives = box["assets"][0]["amount"] except (ValueError, TypeError) as e: + duckpools_link = make_terminal_link("https://www.duckpools.io/", "www.duckpools.io") logger.error( f"[Withdraw Proxy SUSD] Invalid asset amount: {e}.\n" - f"- Transaction ID: {tx_link}\n" - f"- Box ID: {box_link}\n" - f"- If this persists, contact Duckpools support on Discord.\n" + f"\t- Transaction ID: {tx_link}\n" + f"\t- Box ID: {box_link}\n" + f"\t- If this persists, contact Duckpools support on Discord. Visit {duckpools_link}\n" ) return None pool_box, borrowed = latest_pool_info(pool, latest_tx)