Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ By following these steps, you'll terminate the bot and retrieve your setup UTXOs
### 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.
20 changes: 17 additions & 3 deletions erg_pool/e_borrow_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -152,9 +153,22 @@ 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
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. Visit {duckpools_link}\n"
)
logger.debug(f"Full transaction object: {transaction_to_sign}")
return latest_tx
return obj


Expand Down
21 changes: 17 additions & 4 deletions erg_pool/e_lend_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_link import make_terminal_link

logger = set_logger(__name__)

Expand Down Expand Up @@ -123,10 +124,22 @@ 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
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. Visit {duckpools_link}\n"
)
logger.debug(f"Full transaction object: {transaction_to_sign}")
return latest_tx
return obj


Expand Down
19 changes: 17 additions & 2 deletions erg_pool/e_repay_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_link import make_terminal_link

logger = set_logger(__name__)

Expand Down Expand Up @@ -36,8 +37,22 @@ 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
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. Visit {duckpools_link}\n"
)
logger.debug(f"Full transaction object: {transaction_to_sign}")
return latest_tx


def process_repay_proxy_box(pool, box, empty):
Expand Down
32 changes: 30 additions & 2 deletions erg_pool/e_repay_to_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,43 @@
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 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"])

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

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"\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"\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

transaction_to_sign = \
{
Expand Down
48 changes: 44 additions & 4 deletions erg_pool/e_withdraw_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,44 @@
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 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')
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"]:
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"\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"\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

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
Expand Down Expand Up @@ -123,9 +151,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


Expand Down
8 changes: 8 additions & 0 deletions helpers/terminal_link.py
Original file line number Diff line number Diff line change
@@ -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\\"
20 changes: 17 additions & 3 deletions token_pools/t_borrow_proxy_susd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -143,9 +144,22 @@ 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
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. Visit {duckpools_link}\n"
)
logger.debug(f"Full transaction object: {transaction_to_sign}")
return latest_tx
return obj


Expand Down
53 changes: 46 additions & 7 deletions token_pools/t_lend_proxy_sUsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,44 @@
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 process_lend_proxy_box(pool, box, latest_tx):
if box["assets"][0]["tokenId"] != pool["CURRENCY_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

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"\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:
if box["assets"][0]["tokenId"] != pool["CURRENCY_ID"]:
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"\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)

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"])
Expand Down Expand Up @@ -129,10 +157,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


Expand Down
19 changes: 17 additions & 2 deletions token_pools/t_repay_proxy_susd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_link import make_terminal_link

logger = set_logger(__name__)

Expand Down Expand Up @@ -40,8 +41,22 @@ 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
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. Visit {duckpools_link}\n"
)
logger.debug(f"Full transaction object: {transaction_to_sign}")
return latest_tx


def process_repay_proxy_box(pool, box, empty):
Expand Down
Loading