web3-wizzard-lib 1.13.3__py3-none-any.whl → 1.13.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ from sybil_engine.data.pairs import Pairs
6
6
  from sybil_engine.domain.balance.balance_utils import verify_balance, amount_to_swap_from_interval
7
7
  from sybil_engine.domain.balance.tokens import Erc20Token
8
8
  from sybil_engine.module.module import Order, RepeatableModule
9
- from sybil_engine.utils.utils import interval_to_int, randomized_sleeping, SwapException
9
+ from sybil_engine.utils.utils import interval_to_int, randomized_sleeping, SwapException, ConfigurationException
10
10
  from sybil_engine.utils.validation_utils import validate_amount_interval_possible_empty, validate_token, \
11
11
  validate_interval, validate_dex_list
12
12
  from sybil_engine.utils.web3_utils import init_web3
@@ -31,36 +31,41 @@ class WarmUp(RepeatableModule):
31
31
 
32
32
  if len(pair_names) > 0:
33
33
  logger.info(f"Warmup pairs {pair_names}")
34
-
35
34
  pair = Pairs(swap_facade)
36
35
 
37
- pair_swaps = pair.get_warmup_pair_swaps(allowed_dex, chain, pair_names, swap_amount, warm_token)
38
- random.shuffle(pair_swaps)
39
- self._warm_up(chain_instance, pair_swaps, sell_tokens, sleep_interval, swap_amount_interval, account, web3)
36
+ try:
37
+ pair_swaps = pair.get_warmup_pair_swaps(allowed_dex, chain, pair_names, swap_amount, warm_token)
38
+ random.shuffle(pair_swaps)
39
+ pair, swaps = random.choice(pair_swaps)
40
+ except ConfigurationException as e:
41
+ pair_name = random.choice(pair_names)
42
+ from_token = pair_name.split('>')[0]
43
+ to_token = pair_name.split('>')[1]
44
+ pair = self.create_pair_to_swap(from_token, allowed_dex, to_token)
45
+ swaps = allowed_dex
40
46
 
41
- def _warm_up(self, chain_instance, pair_swaps, sell_tokens, sleep_interval, swap_amount_interval, account, web3):
42
- pair, swaps = random.choice(pair_swaps)
43
- random.shuffle(swaps)
47
+ self._warm_up(chain_instance, pair, swaps, sell_tokens, sleep_interval, swap_amount_interval, account, web3)
44
48
 
49
+ def _warm_up(self, chain_instance, pair, swaps, sell_tokens, sleep_interval, swap_amount_interval, account, web3):
45
50
  native_balance = verify_balance(self.min_native_balance, chain_instance, account, web3)
46
- buy_dex, sell_dex = swaps[0], swaps[-1]
51
+ buy_dex = random.choice(swaps)
52
+ sell_dex = random.choice(swaps)
47
53
 
48
54
  self._warm_up_pair(buy_dex, sell_dex, native_balance, swap_amount_interval, chain_instance, pair, sell_tokens,
49
55
  sleep_interval, account, web3)
50
-
51
56
  randomized_sleeping(sleep_interval)
52
57
 
53
58
  def _warm_up_pair(self, buy_dex, sell_dex, native_balance, swap_amount_interval, chain_instance, pair, sell_tokens,
54
59
  sleep_interval, account, web3):
55
- warm_up_token = pair['tokens'][0]
56
- token = pair['tokens'][1]
60
+ from_token = pair['tokens'][0]
61
+ to_token = pair['tokens'][1]
57
62
 
58
63
  amount_to_swap = amount_to_swap_from_interval(account, chain_instance['chain'], self.min_native_balance,
59
- native_balance, swap_amount_interval, warm_up_token, web3)
60
- swap_facade.swap(account, amount_to_swap, chain_instance, pair, buy_dex, warm_up_token, token, web3)
61
- randomized_sleeping(sleep_interval)
64
+ native_balance, swap_amount_interval, from_token, web3)
65
+ swap_facade.swap(account, amount_to_swap, chain_instance, pair, buy_dex, from_token, to_token, web3)
62
66
 
63
67
  if sell_tokens:
68
+ randomized_sleeping(sleep_interval)
64
69
  try:
65
70
  self.execute_sell(chain_instance, pair, sell_dex, account, web3)
66
71
  except SwapException as e:
@@ -72,6 +77,15 @@ class WarmUp(RepeatableModule):
72
77
  swap_facade.swap(account, amount_to_swap, chain_instance, pair, sell_dex, amount_to_swap.token,
73
78
  pair['tokens'][0], web3)
74
79
 
80
+ def create_pair_to_swap(self, from_token, swap_app, to_token):
81
+ pair_to_swap = {
82
+ 'name': f'{from_token}>{to_token}',
83
+ 'tokens': [from_token, to_token],
84
+ 'slippage': 2,
85
+ 'app': swap_app
86
+ }
87
+ return pair_to_swap
88
+
75
89
  def parse_params(self, module_params):
76
90
  self.validate_supported_chain(module_params['chain'])
77
91
  validate_amount_interval_possible_empty(module_params["swap_amount_interval"])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: web3-wizzard-lib
3
- Version: 1.13.3
3
+ Version: 1.13.4
4
4
  Summary: Engine for web3 smart contracts automatization.
5
5
  Author-email: Indeoo <indeooars@gmail.com>
6
6
  License: MIT
@@ -122,7 +122,7 @@ web3_wizzard_lib/core/modules/scroll_bridge.py,sha256=xYu3pkutvzgFp93SZFZX3-Idd_
122
122
  web3_wizzard_lib/core/modules/sell_all.py,sha256=_2dRvz-uAJm3y4sUEbjqr9QP_SuLV1XFtROblxamRq4,1924
123
123
  web3_wizzard_lib/core/modules/sleep_module.py,sha256=0mhW_WUPT9CNkVMj-KK9WbKzhtFFAK_-rAfGYE0EdpU,699
124
124
  web3_wizzard_lib/core/modules/smart_contract_deployment.py,sha256=OD1V0gGE7clnCunTI9Q-v3s-t318H16ljtGUoCpjX5I,17427
125
- web3_wizzard_lib/core/modules/warm_up.py,sha256=jzLWEJgMQO0u612S294T0aYdH7hVoEJ9aoX5jl_yyGE,4402
125
+ web3_wizzard_lib/core/modules/warm_up.py,sha256=Z0SFz0R3NRNzbwfK8d19SqAfw-O3kn-23LDvJ5uumFg,5034
126
126
  web3_wizzard_lib/core/modules/wrapping.py,sha256=mlk5id2_rpsIJ-j90LdjfyS1Qc407v5Quv0KeXnlpxA,2928
127
127
  web3_wizzard_lib/core/modules/zkdx.py,sha256=ao3JHla_iRv0r9cmUj0QVq8yw9q2kiqWIv5COt6z5Iw,2310
128
128
  web3_wizzard_lib/core/modules/bank/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -373,7 +373,7 @@ web3_wizzard_lib/resources/main/pairs.json,sha256=uvIFvY46Ctiw8hjGd9e-1WE0qLf_du
373
373
  web3_wizzard_lib/resources/main/tokens.json,sha256=AoZz_I6AVoZuecNdyX5L-SnGm6TREuPrsYd2i9PJr7U,5707
374
374
  web3_wizzard_lib/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
375
375
  web3_wizzard_lib/utils/debank_utils.py,sha256=y4eMvmxHcagqd-jtZFDfHw80bS6jbC0pC6znhDaz0pU,484
376
- web3_wizzard_lib-1.13.3.dist-info/METADATA,sha256=1_02Sy--6muK9g2qsNcMiodHwCz7t56QDPmykIcuHhQ,369
377
- web3_wizzard_lib-1.13.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
378
- web3_wizzard_lib-1.13.3.dist-info/top_level.txt,sha256=31sEPHxuJ1p5fpc75vHQJ8eJdSs80aCZeeT3L8YAHNg,17
379
- web3_wizzard_lib-1.13.3.dist-info/RECORD,,
376
+ web3_wizzard_lib-1.13.4.dist-info/METADATA,sha256=zgtjPVLSueM6Xq5HDZ7aSkQSQfwu6XCx2CzSv9JoT84,369
377
+ web3_wizzard_lib-1.13.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
378
+ web3_wizzard_lib-1.13.4.dist-info/top_level.txt,sha256=31sEPHxuJ1p5fpc75vHQJ8eJdSs80aCZeeT3L8YAHNg,17
379
+ web3_wizzard_lib-1.13.4.dist-info/RECORD,,