Skip to content

Commit

Permalink
feat: also check if the maximum bet amount is available
Browse files Browse the repository at this point in the history
Also check if the maximum bet amount is available before sending a request, in case that the service is not using the kelly criterion. If the sum of the maximum bet amount and the mech price cannot be covered, then wait until the safe is refilled.
  • Loading branch information
Adamantios committed Nov 15, 2023
1 parent 820fd7f commit 4d0fcf1
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ def n_slots_supported(self) -> bool:

@property
def xdai_deficit(self) -> int:
"""Get the amount of missing xDAI for sending the request."""
return self.price - self.wallet_balance
"""Get the amount of missing xDAI for sending the request plus betting the maximum amount."""
max_bet_amount = 0 if self.params.using_kelly else self.params.max_bet_amount
return (self.price + max_bet_amount) - self.wallet_balance

@property
def multisend_optional(self) -> bool:
Expand Down Expand Up @@ -207,10 +208,14 @@ def _check_unwrap(self) -> WaitableConditionType:
yield from self.wait_for_condition_with_sleep(self._build_unwrap_tx)
return True

self.context.logger.warning(
"The balance is not enough to pay for the mech's price. "
f"Please refill the safe with at least {self.wei_to_native(missing)} xDAI or wxDAI."
)
balance_info = "The balance is not enough to pay for the mech's price"
refill_info = f". Please refill the safe with at least {self.wei_to_native(missing)} xDAI or wxDAI."
if not self.params.using_kelly:
balance_info += " and place the maximum bet amount"
refill_info += (
" Alternatively, you could decrease the configured bet amounts."
)
self.context.logger.warning(balance_info + refill_info)
self.sleep(self.params.sleep_time)
return False

Expand Down

0 comments on commit 4d0fcf1

Please sign in to comment.