Skip to content

Commit

Permalink
No longer checking for min txn amount, due to clear error from pypechain
Browse files Browse the repository at this point in the history
  • Loading branch information
slundqui committed Oct 23, 2024
1 parent 77ab86e commit 57a6d4e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 389 deletions.
44 changes: 0 additions & 44 deletions src/agent0/core/hyperdrive/crash_report/known_error_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def check_for_known_errors(trade_result: TradeResult, interface: HyperdriveReadI
trade_result = check_for_invalid_balance(trade_result, interface)
trade_result = check_for_insufficient_allowance(trade_result, interface)
trade_result = check_for_slippage(trade_result)
trade_result = check_for_min_txn_amount(trade_result)
trade_result = check_for_long_proceeds_less_than_fees(trade_result, interface)
return trade_result

Expand Down Expand Up @@ -303,49 +302,6 @@ def check_for_slippage(trade_result: TradeResult) -> TradeResult:
return trade_result


def check_for_min_txn_amount(trade_result: TradeResult) -> TradeResult:
"""Detects minimum transaction amount errors in trade_result and adds additional information to the
exception in trade_result
Arguments
---------
trade_result: TradeResult
The trade result object from trading
Returns
-------
TradeResult
A modified trade_result that has a custom exception argument message prepended
"""

assert trade_result.pool_config is not None
assert trade_result.trade_object is not None

trade_type = trade_result.trade_object.market_action.action_type
add_arg = None
is_min_txn_amount = False

# Redeem withdrawal shares is not subject to minimum transaction amounts
if trade_type != HyperdriveActionType.REDEEM_WITHDRAW_SHARE:
min_txn_amount = trade_result.pool_config["minimum_transaction_amount"]
trade_amount = trade_result.trade_object.market_action.trade_amount
if trade_amount < min_txn_amount:
add_arg = (
f"Minimum Transaction Amount: {trade_type.name} for {trade_amount}, "
f"minimum transaction amount is {min_txn_amount}."
)
is_min_txn_amount = True

# Prepend balance error argument to exception args
if is_min_txn_amount:
assert add_arg is not None
assert trade_result.exception is not None
trade_result.exception.args = (add_arg,) + trade_result.exception.args
trade_result.is_min_txn_amount = True

return trade_result


def check_for_long_proceeds_less_than_fees(
trade_result: TradeResult, interface: HyperdriveReadInterface
) -> TradeResult:
Expand Down
Loading

0 comments on commit 57a6d4e

Please sign in to comment.