web3-wizzard-lib 1.13.3__py3-none-any.whl → 1.13.5__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.
- web3_wizzard_lib/core/modules/swap/metamusk.py +8 -1
- web3_wizzard_lib/core/modules/warm_up.py +29 -15
- {web3_wizzard_lib-1.13.3.dist-info → web3_wizzard_lib-1.13.5.dist-info}/METADATA +1 -1
- {web3_wizzard_lib-1.13.3.dist-info → web3_wizzard_lib-1.13.5.dist-info}/RECORD +6 -6
- {web3_wizzard_lib-1.13.3.dist-info → web3_wizzard_lib-1.13.5.dist-info}/WHEEL +0 -0
- {web3_wizzard_lib-1.13.3.dist-info → web3_wizzard_lib-1.13.5.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,5 @@
|
|
1
1
|
import random
|
2
|
+
from json import JSONDecodeError
|
2
3
|
|
3
4
|
import requests
|
4
5
|
from loguru import logger
|
@@ -58,6 +59,12 @@ class MetamuskSwap(Dex):
|
|
58
59
|
}
|
59
60
|
)
|
60
61
|
|
61
|
-
|
62
|
+
try:
|
63
|
+
response = response.json()
|
64
|
+
except JSONDecodeError as e:
|
65
|
+
logger.error(response.content.decode('utf-8'))
|
66
|
+
raise e
|
67
|
+
|
68
|
+
choice = random.choice(response)
|
62
69
|
data = choice['trade']['data']
|
63
70
|
return data
|
@@ -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
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
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
|
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
|
-
|
56
|
-
|
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,
|
60
|
-
swap_facade.swap(account, amount_to_swap, chain_instance, pair, buy_dex,
|
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"])
|
@@ -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=
|
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
|
@@ -248,7 +248,7 @@ web3_wizzard_lib/core/modules/swap/horizondex.py,sha256=GKn4CjNt85P_xUmdK5mZzfTk
|
|
248
248
|
web3_wizzard_lib/core/modules/swap/izumi.py,sha256=j9jUsaENyoz1Tldao0h5lSMcQtxwxktc4PVfscq09Wc,1730
|
249
249
|
web3_wizzard_lib/core/modules/swap/lineaswap.py,sha256=2Br3ELyLktZx6BZh9O0qWm2VaHbJuXQDK0LY_75QC5s,1625
|
250
250
|
web3_wizzard_lib/core/modules/swap/maverick.py,sha256=tn0mVaoJxxWgDpTLXxhSv5Kf0b0cZcRRuZtjqIm1aKo,3080
|
251
|
-
web3_wizzard_lib/core/modules/swap/metamusk.py,sha256=
|
251
|
+
web3_wizzard_lib/core/modules/swap/metamusk.py,sha256=okGr9zQphfTx6U7NhkczWsCu1koXK1E7cxXNLvLB13s,2679
|
252
252
|
web3_wizzard_lib/core/modules/swap/mute.py,sha256=uwyuNVAqUxWruL19mE3U6ccLU15_E-6TajlGpd58uLo,1973
|
253
253
|
web3_wizzard_lib/core/modules/swap/odos.py,sha256=c9vaWo1WyUap9CgzLQhXWKnylEMocm5kqMBm0_ZEGuk,2281
|
254
254
|
web3_wizzard_lib/core/modules/swap/one_inch.py,sha256=VHc36z6CvfUYD2nZxk1jj1COPAFp3p6uJmiyIOjjrVU,2513
|
@@ -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.
|
377
|
-
web3_wizzard_lib-1.13.
|
378
|
-
web3_wizzard_lib-1.13.
|
379
|
-
web3_wizzard_lib-1.13.
|
376
|
+
web3_wizzard_lib-1.13.5.dist-info/METADATA,sha256=U4nkw6swFGB2GI6fXCFZdJb0zOLqIsuZMagbHu-ZLxM,369
|
377
|
+
web3_wizzard_lib-1.13.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
378
|
+
web3_wizzard_lib-1.13.5.dist-info/top_level.txt,sha256=31sEPHxuJ1p5fpc75vHQJ8eJdSs80aCZeeT3L8YAHNg,17
|
379
|
+
web3_wizzard_lib-1.13.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|