web3-wizzard-lib 0.0.2__py3-none-any.whl → 0.0.3__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.
Files changed (295) hide show
  1. web3_wizzard_lib/core/modules/linea_appeal.py +12 -45
  2. web3_wizzard_lib/core/modules/stargate/farming.py +1 -1
  3. web3_wizzard_lib/core/utils/ai_utils.py +27 -0
  4. {web3_wizzard_lib-0.0.2.dist-info → web3_wizzard_lib-0.0.3.dist-info}/METADATA +8 -3
  5. {web3_wizzard_lib-0.0.2.dist-info → web3_wizzard_lib-0.0.3.dist-info}/RECORD +8 -294
  6. {web3_wizzard_lib-0.0.2.dist-info → web3_wizzard_lib-0.0.3.dist-info}/WHEEL +1 -1
  7. core/__init__.py +0 -1
  8. core/contract/__init__.py +0 -0
  9. core/contract/aavecontract.py +0 -36
  10. core/contract/alienswap_contract.py +0 -21
  11. core/contract/arena_games_contract.py +0 -16
  12. core/contract/basiliskcontract.py +0 -58
  13. core/contract/bilinear_contract.py +0 -22
  14. core/contract/bungee.py +0 -33
  15. core/contract/coredao_contract.py +0 -35
  16. core/contract/coredao_from_contract.py +0 -40
  17. core/contract/dmail_send_mail.py +0 -18
  18. core/contract/empty_nft.py +0 -18
  19. core/contract/era_name.py +0 -23
  20. core/contract/eralendcontract.py +0 -34
  21. core/contract/eth_scroll_bridge_contract.py +0 -25
  22. core/contract/frog_war_contract.py +0 -48
  23. core/contract/horizondex_quoter.py +0 -14
  24. core/contract/horizondex_router.py +0 -91
  25. core/contract/imagine_contract.py +0 -18
  26. core/contract/izumi.py +0 -63
  27. core/contract/kreatorland_contract.py +0 -21
  28. core/contract/l0_claim.py +0 -254
  29. core/contract/l2_telegraph.py +0 -21
  30. core/contract/layerbank_price.py +0 -18
  31. core/contract/layerbank_token.py +0 -29
  32. core/contract/layerbankcontract.py +0 -59
  33. core/contract/linea_day_2_contract.py +0 -19
  34. core/contract/linea_day_3_contract.py +0 -55
  35. core/contract/linea_ens_names_contract.py +0 -55
  36. core/contract/lineaswaprouter.py +0 -52
  37. core/contract/maverick_multicall.py +0 -52
  38. core/contract/mendi_finance_contract.py +0 -11
  39. core/contract/mendi_token.py +0 -25
  40. core/contract/merkly_minter.py +0 -47
  41. core/contract/micro3_contract.py +0 -18
  42. core/contract/mute_router.py +0 -93
  43. core/contract/nidum_contract.py +0 -44
  44. core/contract/nile_contract.py +0 -60
  45. core/contract/nomis_attest_contract.py +0 -40
  46. core/contract/nomis_contract.py +0 -40
  47. core/contract/octomos.py +0 -31
  48. core/contract/odos.py +0 -104
  49. core/contract/omnisea.py +0 -29
  50. core/contract/orbiter_starknet.py +0 -30
  51. core/contract/pancake_pool.py +0 -19
  52. core/contract/pancake_quoter.py +0 -20
  53. core/contract/pancake_router.py +0 -72
  54. core/contract/rage_claim.py +0 -24
  55. core/contract/reactor_fusion_contract.py +0 -78
  56. core/contract/readon_contract.py +0 -19
  57. core/contract/rubyscore_contract.py +0 -31
  58. core/contract/satoshi_universe_contract.py +0 -29
  59. core/contract/scroll_bridge_contract.py +0 -24
  60. core/contract/scroll_canvas_mint_contract.py +0 -26
  61. core/contract/scroll_oracle.py +0 -11
  62. core/contract/snap_contract.py +0 -16
  63. core/contract/social_scan_contract.py +0 -20
  64. core/contract/stargate_farming.py +0 -37
  65. core/contract/stargate_router.py +0 -84
  66. core/contract/stargate_router_eth.py +0 -41
  67. core/contract/stargate_token_pool.py +0 -46
  68. core/contract/stargate_v2_contract.py +0 -36
  69. core/contract/syncswap_classic_pool.py +0 -15
  70. core/contract/syncswap_classic_pool_factory.py +0 -15
  71. core/contract/syncswap_pool.py +0 -25
  72. core/contract/syncswap_router.py +0 -123
  73. core/contract/tavaera_id.py +0 -18
  74. core/contract/tavaera_mint.py +0 -17
  75. core/contract/townstory_bonus_contract.py +0 -19
  76. core/contract/townstory_contract.py +0 -21
  77. core/contract/velocore_lens.py +0 -44
  78. core/contract/velocore_pool.py +0 -198
  79. core/contract/velocore_router.py +0 -80
  80. core/contract/woofi_swap.py +0 -29
  81. core/contract/xy_finance_contract.py +0 -87
  82. core/contract/yoddlo_contract.py +0 -19
  83. core/contract/yuliverse_contract.py +0 -36
  84. core/contract/zebra_contract.py +0 -68
  85. core/contract/zerolend_contract.py +0 -34
  86. core/contract/zerolend_liq_contract.py +0 -20
  87. core/contract/zkdx_contract.py +0 -40
  88. core/contract/zkdx_data.py +0 -14
  89. core/contract/zks.py +0 -24
  90. core/modules/__init__.py +0 -0
  91. core/modules/ads_import_proxy.py +0 -52
  92. core/modules/airdrop_printer.py +0 -80
  93. core/modules/bank/__init__.py +0 -0
  94. core/modules/bank/aave.py +0 -25
  95. core/modules/bank/bank.py +0 -15
  96. core/modules/bank/bank_module.py +0 -99
  97. core/modules/bank/basilisk.py +0 -25
  98. core/modules/bank/eralend.py +0 -25
  99. core/modules/bank/layerbank.py +0 -116
  100. core/modules/bank/mendi_finance.py +0 -57
  101. core/modules/bank/reactorfusion.py +0 -25
  102. core/modules/bank/zerolend.py +0 -36
  103. core/modules/bridge/__init__.py +0 -0
  104. core/modules/bridge/bridge.py +0 -8
  105. core/modules/bridge/coredao_bridge_sub.py +0 -47
  106. core/modules/bridge/orbiter_sub.py +0 -112
  107. core/modules/bridge/scroll_bridge_sub.py +0 -42
  108. core/modules/bridge/stargate_v2_sub.py +0 -74
  109. core/modules/bridge_module.py +0 -47
  110. core/modules/bungee.py +0 -109
  111. core/modules/cex_sender.py +0 -60
  112. core/modules/cex_subaccount_transfer.py +0 -34
  113. core/modules/cex_withdraw.py +0 -91
  114. core/modules/claimer.py +0 -45
  115. core/modules/claims/__init__.py +0 -0
  116. core/modules/claims/layerzero_claimer.py +0 -64
  117. core/modules/claims/rabby_claimer.py +0 -81
  118. core/modules/concrete_swap.py +0 -97
  119. core/modules/coredao_bridge.py +0 -32
  120. core/modules/coredao_bridge_auto.py +0 -39
  121. core/modules/debank_checker.py +0 -90
  122. core/modules/dmail.py +0 -54
  123. core/modules/erc20_balance.py +0 -42
  124. core/modules/intract/__init__.py +0 -0
  125. core/modules/intract/intract_api.py +0 -212
  126. core/modules/intract/utils.py +0 -81
  127. core/modules/intract_claim.py +0 -104
  128. core/modules/layer_2_20.py +0 -65
  129. core/modules/lending_module.py +0 -134
  130. core/modules/linea_appeal.py +0 -70
  131. core/modules/linea_poh_lxp.py +0 -64
  132. core/modules/liquidity/__init__.py +0 -0
  133. core/modules/liquidity/nile_pool.py +0 -64
  134. core/modules/liquidity/pool.py +0 -16
  135. core/modules/liquidity/syncswap_pool.py +0 -61
  136. core/modules/liquidity/velocore_pool.py +0 -55
  137. core/modules/liquidity/zerolend_liquidity.py +0 -26
  138. core/modules/liquidity_pool.py +0 -60
  139. core/modules/merkly_refuel.py +0 -87
  140. core/modules/modules.py +0 -4
  141. core/modules/nft/__init__.py +0 -0
  142. core/modules/nft/abbys_world.py +0 -22
  143. core/modules/nft/acg_worlds.py +0 -25
  144. core/modules/nft/alienswap_linea.py +0 -22
  145. core/modules/nft/arena_games.py +0 -22
  146. core/modules/nft/asmatch.py +0 -22
  147. core/modules/nft/battlemon.py +0 -25
  148. core/modules/nft/bilinear.py +0 -22
  149. core/modules/nft/bitavatar.py +0 -25
  150. core/modules/nft/culture_satoshi_universe.py +0 -24
  151. core/modules/nft/efrogs.py +0 -26
  152. core/modules/nft/empty_nft.py +0 -22
  153. core/modules/nft/era_domain.py +0 -42
  154. core/modules/nft/frog_war.py +0 -22
  155. core/modules/nft/frog_war_bonus.py +0 -22
  156. core/modules/nft/gamerboom.py +0 -25
  157. core/modules/nft/gamerboom_bonus.py +0 -26
  158. core/modules/nft/imagine.py +0 -32
  159. core/modules/nft/kreatorland_module.py +0 -35
  160. core/modules/nft/l2_telegraph_module.py +0 -22
  161. core/modules/nft/layer3_meta.py +0 -25
  162. core/modules/nft/linea_culture_2_2_linus.py +0 -24
  163. core/modules/nft/linea_culture_2_3_yooldo.py +0 -24
  164. core/modules/nft/linea_culture_2_4_frogwar.py +0 -24
  165. core/modules/nft/linea_culture_2_5_acg.py +0 -25
  166. core/modules/nft/linea_culture_2_6_ascend_the_end.py +0 -25
  167. core/modules/nft/linea_culture_3_1_ascend_the_end.py +0 -25
  168. core/modules/nft/linea_culture_3_2_sending_me.py +0 -25
  169. core/modules/nft/linea_culture_3_3_townstory.py +0 -25
  170. core/modules/nft/linea_culture_3_4_daniele.py +0 -25
  171. core/modules/nft/linea_culture_3_5_demmortal.py +0 -25
  172. core/modules/nft/linea_culture_3_6_foxy.py +0 -25
  173. core/modules/nft/linea_culture_4_1_coop_records.py +0 -60
  174. core/modules/nft/linea_culture_4_2_borja_moskv.py +0 -65
  175. core/modules/nft/linea_culture_4_2_borja_moskv_approve.py +0 -27
  176. core/modules/nft/linea_culture_4_3_fruit.py +0 -66
  177. core/modules/nft/linea_culture_4_4_fruit_crux.py +0 -67
  178. core/modules/nft/linea_culture_4_5_forbidden_fruit.py +0 -67
  179. core/modules/nft/linea_culture_4_6_laurent.py +0 -67
  180. core/modules/nft/linea_culture_day2.py +0 -20
  181. core/modules/nft/linea_culture_day3.py +0 -20
  182. core/modules/nft/linea_ens_names.py +0 -107
  183. core/modules/nft/lucky_cat.py +0 -25
  184. core/modules/nft/merkly_minter_module.py +0 -22
  185. core/modules/nft/micro3.py +0 -23
  186. core/modules/nft/mint_2048.py +0 -28
  187. core/modules/nft/nft_submodule.py +0 -16
  188. core/modules/nft/nidum.py +0 -87
  189. core/modules/nft/nidum_bonus.py +0 -23
  190. core/modules/nft/nomis.py +0 -64
  191. core/modules/nft/nomis_attest.py +0 -66
  192. core/modules/nft/nouns.py +0 -27
  193. core/modules/nft/octomos.py +0 -32
  194. core/modules/nft/omnisea.py +0 -33
  195. core/modules/nft/omnizone.py +0 -25
  196. core/modules/nft/orbiter_claim.py +0 -87
  197. core/modules/nft/readon.py +0 -30
  198. core/modules/nft/rubyscore.py +0 -45
  199. core/modules/nft/sarubol.py +0 -22
  200. core/modules/nft/satoshi_universe.py +0 -22
  201. core/modules/nft/scroll_canvas_attest_year_badge.py +0 -35
  202. core/modules/nft/scroll_canvas_mint.py +0 -51
  203. core/modules/nft/sign.py +0 -32
  204. core/modules/nft/snap.py +0 -25
  205. core/modules/nft/snap_bonus.py +0 -31
  206. core/modules/nft/social_scan.py +0 -22
  207. core/modules/nft/sub_module.py +0 -8
  208. core/modules/nft/tavaera.py +0 -30
  209. core/modules/nft/townstory.py +0 -75
  210. core/modules/nft/townstory_bonus.py +0 -45
  211. core/modules/nft/trusta_reputation.py +0 -48
  212. core/modules/nft/trustaa_poh.py +0 -49
  213. core/modules/nft/uber_poh.py +0 -24
  214. core/modules/nft/wizards_of_linea.py +0 -26
  215. core/modules/nft/yoddlo.py +0 -22
  216. core/modules/nft/yuliverse.py +0 -22
  217. core/modules/nft/zace.py +0 -25
  218. core/modules/nft/zks_domain.py +0 -41
  219. core/modules/nft_minter.py +0 -107
  220. core/modules/orbiter.py +0 -39
  221. core/modules/orbiter_checker.py +0 -26
  222. core/modules/rage.py +0 -54
  223. core/modules/scroll_bridge.py +0 -45
  224. core/modules/sell_all.py +0 -51
  225. core/modules/sleep_module.py +0 -25
  226. core/modules/smart_contract_deployment.py +0 -37
  227. core/modules/stargate/__init__.py +0 -0
  228. core/modules/stargate/auto_bridge.py +0 -91
  229. core/modules/stargate/bridge.py +0 -38
  230. core/modules/stargate/bridge_eth.py +0 -59
  231. core/modules/stargate/bridge_tokens.py +0 -48
  232. core/modules/stargate/classic_bridge.py +0 -34
  233. core/modules/stargate/farming.py +0 -163
  234. core/modules/stargate/l0_data.py +0 -10
  235. core/modules/stargate/pool.py +0 -74
  236. core/modules/stargate/stargate_balance_utils.py +0 -25
  237. core/modules/stargate/stargate_gas_checker.py +0 -68
  238. core/modules/swap/__init__.py +0 -1
  239. core/modules/swap/horizondex.py +0 -38
  240. core/modules/swap/izumi.py +0 -41
  241. core/modules/swap/lineaswap.py +0 -34
  242. core/modules/swap/maverick.py +0 -66
  243. core/modules/swap/mute.py +0 -39
  244. core/modules/swap/odos.py +0 -58
  245. core/modules/swap/one_inch.py +0 -58
  246. core/modules/swap/pancake.py +0 -41
  247. core/modules/swap/swap_facade.py +0 -10
  248. core/modules/swap/syncswap.py +0 -62
  249. core/modules/swap/velocore.py +0 -40
  250. core/modules/swap/woofi.py +0 -38
  251. core/modules/swap/xy_finance.py +0 -43
  252. core/modules/swap/zebra.py +0 -32
  253. core/modules/warm_up.py +0 -98
  254. core/modules/wrapping.py +0 -74
  255. core/modules/zkdx.py +0 -63
  256. tests/core/__init__.py +0 -0
  257. tests/core/contracts/__init__.py +0 -0
  258. tests/core/contracts/test_horizondex_quoter.py +0 -37
  259. tests/core/contracts/test_uniswap_quoter.py +0 -35
  260. tests/core/contracts/test_velocore_lens.py +0 -67
  261. tests/core/contracts/test_velocore_pool.py +0 -57
  262. tests/core/modules/__init__.py +0 -67
  263. tests/core/modules/swap/__init__.py +0 -0
  264. tests/core/modules/swap/test_horizondex.py +0 -37
  265. tests/core/modules/swap/test_lineaswap.py +0 -28
  266. tests/core/modules/swap/test_maverick.py +0 -31
  267. tests/core/modules/swap/test_mute.py +0 -29
  268. tests/core/modules/swap/test_odos.py +0 -36
  269. tests/core/modules/swap/test_pancake.py +0 -54
  270. tests/core/modules/swap/test_syncswap.py +0 -59
  271. tests/core/modules/swap/test_velocore.py +0 -33
  272. tests/core/modules/swap/test_woofi.py +0 -22
  273. tests/core/modules/test_bungee.py +0 -27
  274. tests/core/modules/test_concrete_swap.py +0 -62
  275. tests/core/modules/test_dmail.py +0 -41
  276. tests/core/modules/test_lending.py +0 -122
  277. tests/core/modules/test_nft.py +0 -32
  278. tests/core/modules/test_nft_minter.py +0 -30
  279. tests/core/modules/test_orbiter.py +0 -28
  280. tests/core/modules/test_sellall.py +0 -27
  281. tests/core/modules/test_send_to_cex.py +0 -27
  282. tests/core/modules/test_stargate_auto_bridge.py +0 -32
  283. tests/core/modules/test_stargate_bridge.py +0 -25
  284. tests/core/modules/test_stargate_farming.py +0 -108
  285. tests/core/modules/test_warmup.py +0 -78
  286. tests/core/modules/test_wrapping.py +0 -68
  287. tests/core/scenario/__init__.py +0 -0
  288. tests/core/scenario/module_0_test_config.py +0 -91
  289. tests/core/test_app.py +0 -19
  290. tests/core/test_config.py +0 -34
  291. web3_wizzard_lib/core/modules/modules.py +0 -27
  292. web3_wizzard_lib/core/modules/nft/sub_module.py +0 -8
  293. web3_wizzard_lib/core/modules/swap/swap_facade.py +0 -10
  294. {web3_wizzard_lib-0.0.2.data → web3_wizzard_lib-0.0.3.data}/data/requirements.txt +0 -0
  295. {web3_wizzard_lib-0.0.2.dist-info → web3_wizzard_lib-0.0.3.dist-info}/top_level.txt +0 -0
core/modules/swap/mute.py DELETED
@@ -1,39 +0,0 @@
1
- from sybil_engine.domain.dex import Dex
2
-
3
- from web3_wizzard_lib.core.contract.mute_router import MuteRouter
4
-
5
-
6
- class Mute(Dex):
7
- dex_name = 'mute'
8
- swap_contract = "MUTE_ROUTER"
9
- supported_chains = ['ZKSYNC']
10
-
11
- def __init__(self, chain_instance, web3):
12
- super().__init__(chain_instance, web3)
13
- self.weth_address = self.tokens['WETH']
14
- mute_contract = self.chain_contracts[self.swap_contract]
15
- self.mute_router = MuteRouter(mute_contract, self.web3)
16
-
17
- def swap_native_for_token(self, account, amount_to_swap, slippage, to_token_address):
18
- amount_out_min = int(self.get_amount_out_min(amount_to_swap, self.weth_address, to_token_address) * slippage)
19
-
20
- args = [account, amount_to_swap, self.weth_address, to_token_address, amount_out_min]
21
- func = self.mute_router.swap_exact_eth_for_tokens_supporting_fee_on_transfer_tokens
22
- return args, func
23
-
24
- def swap_token_for_native(self, account, amount_to_swap, from_token_address, slippage):
25
- amount_out_min = int(self.get_amount_out_min(amount_to_swap, from_token_address, self.weth_address) * slippage)
26
-
27
- args = [account, amount_to_swap, from_token_address, self.weth_address, amount_out_min]
28
- func = self.mute_router.swap_exact_tokens_for_eth_supporting_fee_on_transfer_tokens
29
- return args, func
30
-
31
- def swap_token_for_token(self, account, amount_to_swap, slippage, from_token_address, to_token_address):
32
- amount_out_min = int(self.get_amount_out_min(amount_to_swap, from_token_address, to_token_address) * slippage)
33
-
34
- args = [account, amount_to_swap, from_token_address, to_token_address, amount_out_min]
35
- func = self.mute_router.swap_exact_tokens_for_tokens_supporting_fee_on_transfer_tokens
36
- return args, func
37
-
38
- def get_amount_out_min(self, amount_to_swap, from_token_address, to_token_address):
39
- return self.mute_router.get_amount_out(amount_to_swap, from_token_address, to_token_address)
core/modules/swap/odos.py DELETED
@@ -1,58 +0,0 @@
1
- from loguru import logger
2
- from sybil_engine.domain.dex import Dex
3
- from sybil_engine.utils.retry import retry
4
- from sybil_engine.utils.utils import AccountException
5
-
6
- from web3_wizzard_lib.core.contract.odos import Odos
7
-
8
-
9
- class OdosSwap(Dex):
10
- dex_name = 'odos'
11
- swap_contract = 'ODOS'
12
- supported_chains = ['ZKSYNC', 'BASE', 'LINEA']
13
-
14
- def __init__(self, chain_instance, web3):
15
- super().__init__(chain_instance, web3)
16
- self.odos_router_contract = self.chain_contracts[self.swap_contract]
17
- self.odos_router = Odos(self.odos_router_contract, self.web3)
18
-
19
- @retry(max_attempts=10, retry_interval={'from': 10, 'to': 20})
20
- def swap(self, amount_to_swap, from_token, to_token, slippage, account):
21
- logger.info(
22
- f"Swap {amount_to_swap.log_line()}->{to_token.symbol()} in {self.dex_name} ({self.chain_instance['chain']})")
23
-
24
- if amount_to_swap.token == 'ETH':
25
- from_token_address = '0x0000000000000000000000000000000000000000'
26
- else:
27
- from_token_address = from_token.erc20_contract.contract_address
28
-
29
- if to_token.token == 'ETH':
30
- to_token_address = '0x0000000000000000000000000000000000000000'
31
- else:
32
- to_token_address = to_token.erc20_contract.contract_address
33
-
34
- quote_data = self.odos_router.quote(
35
- account, from_token_address, to_token_address, amount_to_swap.wei, slippage, self.chain_instance['chain']
36
- )
37
-
38
- if amount_to_swap.token == 'ETH':
39
- transaction_data = self.odos_router.assemble(account, quote_data["pathId"])
40
-
41
- func = self.odos_router.swap
42
- else:
43
- balance = from_token.balance(account)
44
-
45
- if balance.wei < amount_to_swap.wei:
46
- raise AccountException(f"Balance {balance} < {amount_to_swap}")
47
-
48
- if from_token.allowance(account, self.odos_router_contract) < amount_to_swap.wei:
49
- from_token.approve(account, self.odos_router_contract)
50
-
51
- transaction_data = self.odos_router.assemble(account, quote_data["pathId"])
52
-
53
- if to_token.token == 'ETH':
54
- func = self.odos_router.swap
55
- else:
56
- raise Exception('Not supported')
57
-
58
- func(account, transaction_data)
@@ -1,58 +0,0 @@
1
- import requests
2
- from sybil_engine.contract.transaction_executor import evm_transaction
3
- from sybil_engine.domain.dex import Dex
4
- from sybil_engine.utils.gas_utils import l1_gas_price
5
- from sybil_engine.utils.utils import randomized_sleeping, SwapException
6
- from web3 import Web3
7
-
8
-
9
- class OneInch(Dex):
10
- dex_name = '1inch'
11
- swap_contract = '1INCH'
12
- supported_chains = ['BASE', 'ZKSYNC', 'OPTIMISM', 'ARBITRUM']
13
-
14
- def __init__(self, chain_instance, web3):
15
- super().__init__(chain_instance, web3)
16
- self.weth_address = self.tokens['WETH']
17
- self.base_url = 'https://api.1inch.dev/swap'
18
- self.inch_version = 5.2
19
-
20
- @l1_gas_price
21
- def swap(self, amount_to_swap, from_token, to_token, slippage, account):
22
- if amount_to_swap.wei == 0:
23
- raise SwapException(f"Can't swap 0 of {amount_to_swap.token}")
24
-
25
- self.get_txn(account, amount_to_swap, from_token, to_token)
26
-
27
- def get_api_call_data(self, url):
28
- response = requests.get(url, headers={'Authorization': "DuagMR3vHpYc9JBNqM0Wx9mSWA7VzwuH"})
29
-
30
- return response.json()
31
-
32
- @evm_transaction
33
- def get_txn(self, account, amount_to_swap, from_token, to_token):
34
- spender_json = self.get_api_call_data(
35
- f'{self.base_url}/v{self.inch_version}/{self.web3.eth.chain_id}/approve/spender')
36
- spender = Web3.to_checksum_address(spender_json['address'])
37
-
38
- if from_token.symbol() != 'ETH' and from_token.allowance(account, spender) < amount_to_swap.wei:
39
- from_token.approve(account, spender)
40
-
41
- randomized_sleeping({'from': 1, 'to': 5})
42
-
43
- _1inchurl = f"{self.base_url}/v{self.inch_version}/{self.web3.eth.chain_id}/swap?fromTokenAddress={from_token.address()}&toTokenAddress={to_token.address()}&amount={amount_to_swap.wei}&fromAddress={account.address}&slippage=5"
44
- json_data = self.get_api_call_data(_1inchurl)
45
-
46
- if json_data is False:
47
- raise Exception(json_data['description'])
48
-
49
- contract_txn = json_data['tx']
50
- contract_txn['from'] = Web3.to_checksum_address(contract_txn['from'])
51
- contract_txn['chainId'] = self.web3.eth.chain_id
52
- contract_txn['nonce'] = self.web3.eth.get_transaction_count(account.address)
53
- contract_txn['to'] = Web3.to_checksum_address(contract_txn['to'])
54
- contract_txn['gasPrice'] = int(contract_txn['gasPrice'])
55
- contract_txn['gas'] = int(contract_txn['gas'])
56
- contract_txn['value'] = int(contract_txn['value'])
57
-
58
- return contract_txn
@@ -1,41 +0,0 @@
1
- from sybil_engine.domain.dex import Dex
2
-
3
- from web3_wizzard_lib.core.contract.pancake_quoter import PancakeQuoter
4
- from web3_wizzard_lib.core.contract.pancake_router import PancakeRouter
5
-
6
-
7
- class Pancake(Dex):
8
- dex_name = 'pancake'
9
- swap_contract = "PANCAKE_ROUTER"
10
- supported_chains = ['ZKSYNC', 'BASE', 'LINEA', 'ARBITRUM']
11
-
12
- def __init__(self, chain_instance, web3):
13
- super().__init__(chain_instance, web3)
14
- self.weth_address = self.tokens['WETH']
15
- self.pancake_router_contract = self.chain_contracts[self.swap_contract]
16
- self.pancake_router = PancakeRouter(self.pancake_router_contract, self.web3)
17
-
18
- def swap_native_for_token(self, account, amount_to_swap, slippage, to_token_address):
19
-
20
- amount_out_min = int(self.get_amount_out_min(amount_to_swap, self.weth_address, to_token_address) * slippage)
21
- args = [account, amount_to_swap, self.weth_address, to_token_address, amount_out_min]
22
- func = self.pancake_router.swap_to_token
23
-
24
- return args, func
25
-
26
- def swap_token_for_native(self, account, amount_to_swap, from_token_address, slippage):
27
- amount_out_min = int(
28
- self.get_amount_out_min(amount_to_swap, from_token_address, self.weth_address) * slippage)
29
-
30
- args = [account, amount_to_swap, from_token_address, self.weth_address, amount_out_min]
31
- func = self.pancake_router.swap_to_eth
32
- return args, func
33
-
34
- def swap_token_for_token(self, account, amount_to_swap, slippage, from_token_address, to_token_address):
35
- raise Exception('Not supported')
36
-
37
- def get_amount_out_min(self, amount_to_swap, from_token_address, to_token_address):
38
- pancake_quoter_contract = self.chain_contracts["PANCAKE_QUOTER"]
39
- pancake_quoter = PancakeQuoter(pancake_quoter_contract, self.web3)
40
-
41
- return pancake_quoter.quote_exact_input_single(from_token_address, to_token_address, amount_to_swap.wei)
@@ -1,10 +0,0 @@
1
- from sybil_engine.domain.dex import Dex
2
- from sybil_engine.domain.swap_facade import SwapFacade
3
- from sybil_engine.utils.package_import_utils import get_all_subclasses, import_all_modules_in_directory
4
-
5
-
6
- def get_swap_classes():
7
- import_all_modules_in_directory("core.modules.swap")
8
- return get_all_subclasses(Dex)
9
-
10
- swap_facade = SwapFacade(get_swap_classes())
@@ -1,62 +0,0 @@
1
- from sybil_engine.domain.dex import Dex
2
-
3
- from web3_wizzard_lib.core.contract.syncswap_classic_pool_factory import SyncSwapClassicPoolFactory
4
- from web3_wizzard_lib.core.contract.syncswap_pool import SyncSwapPoolContract
5
- from web3_wizzard_lib.core.contract.syncswap_router import SyncSwapRouter
6
-
7
-
8
- class Syncswap(Dex):
9
- dex_name = 'syncswap'
10
- swap_contract = 'SYNCSWAP'
11
- supported_chains = ['ZKSYNC', 'LINEA', 'SCROLL']
12
-
13
- def __init__(self, chain_instance, web3):
14
- super().__init__(chain_instance, web3)
15
- self.weth_address = self.tokens['WETH']
16
- self.pool_classic_pool_factory_address = self.chain_contracts['SYNCSWAP_CLASSIC_POOL_FACTORY']
17
- self.syncswap_contract_address = self.chain_contracts[self.swap_contract]
18
- self.syncswap_router = SyncSwapRouter(self.syncswap_contract_address, self.web3)
19
-
20
- def swap_native_for_token(self, account, amount_to_swap, slippage, to_token_address):
21
- token_in_data_address = self.weth_address
22
- token_in_address = self.tokens['ZERO_ADDRESS']
23
-
24
- amount_out_min = int(
25
- self.get_amount_out_min(account, amount_to_swap, token_in_data_address, to_token_address) * slippage
26
- )
27
-
28
- args = [
29
- account,
30
- amount_to_swap,
31
- self.weth_address,
32
- token_in_address,
33
- self.get_pool_address(token_in_data_address, to_token_address),
34
- amount_out_min
35
- ]
36
-
37
- return args, self.syncswap_router.swap
38
-
39
- def swap_token_for_native(self, account, amount_to_swap, from_token_address, slippage):
40
- token_in_data_address = self.tokens[amount_to_swap.token]
41
- token_in_address = self.tokens[amount_to_swap.token]
42
-
43
- amount_out_min = int(
44
- self.get_amount_out_min(account, amount_to_swap, token_in_data_address, self.weth_address) * slippage)
45
-
46
- args = [account, amount_to_swap, token_in_address, token_in_data_address, self.get_pool_address(token_in_data_address, self.weth_address), amount_out_min]
47
-
48
- return args, self.syncswap_router.swap
49
-
50
- def get_amount_out_min(self, account, amount_to_swap, token_in_data_address, to_token_address):
51
- pool_address = self.get_pool_address(token_in_data_address, to_token_address)
52
-
53
- if isinstance(pool_address, str):
54
- syncswap_pool = SyncSwapPoolContract(pool_address, self.web3)
55
- else:
56
- syncswap_pool = SyncSwapPoolContract(list(pool_address.items())[0][1], self.web3)
57
-
58
- return syncswap_pool.get_amount_out(account, amount_to_swap, token_in_data_address)
59
-
60
- def get_pool_address(self, token_in_data_address, to_token_address):
61
- pool_factory = SyncSwapClassicPoolFactory(self.pool_classic_pool_factory_address, self.web3)
62
- return pool_factory.get_pool(token_in_data_address, to_token_address)
@@ -1,40 +0,0 @@
1
- from sybil_engine.domain.dex import Dex
2
-
3
- from web3_wizzard_lib.core.contract.velocore_router import VelocoreRouter
4
-
5
-
6
- class Velocore(Dex):
7
- dex_name = 'velocore'
8
- swap_contract = "VELOCORE_ROUTER"
9
- supported_chains = ['ZKSYNC']
10
-
11
- def __init__(self, chain_instance, web3):
12
- super().__init__(chain_instance, web3)
13
- self.weth_address = self.tokens['WETH']
14
- self.velocore_router = VelocoreRouter(self.chain_contracts[self.swap_contract], self.web3)
15
-
16
- def swap_native_for_token(self, account, amount_to_swap, slippage, to_token_address):
17
- amount_out_min = int(self.get_amount_out_min(amount_to_swap, self.weth_address, to_token_address) * slippage)
18
-
19
- args = [account, amount_to_swap, self.weth_address, to_token_address, amount_out_min]
20
- func = self.velocore_router.swap_exact_eth_for_tokens
21
-
22
- return args, func
23
-
24
- def get_amount_out_min(self, amount_to_swap, from_token_address, to_token_address):
25
- return self.velocore_router.get_amount_out(amount_to_swap, from_token_address, to_token_address)
26
-
27
- def swap_token_for_native(self, account, amount_to_swap, from_token_address, slippage):
28
- amount_out_min = int(self.get_amount_out_min(amount_to_swap, from_token_address, self.weth_address) * slippage)
29
-
30
- args = [account, amount_to_swap, from_token_address, self.weth_address, amount_out_min]
31
- func = self.velocore_router.swap_exact_tokens_for_eth
32
- return args, func
33
-
34
- def swap_token_for_token(self, account, amount_to_swap, slippage, from_token_address, to_token_address):
35
- amount_out_min = int(self.get_amount_out_min(amount_to_swap, from_token_address, to_token_address) * slippage)
36
-
37
- args = [account, amount_to_swap, from_token_address, to_token_address, amount_out_min]
38
- func = self.velocore_router.swap_exact_tokens_for_tokens
39
-
40
- return args, func
@@ -1,38 +0,0 @@
1
- from sybil_engine.domain.balance.tokens import Erc20Token
2
- from sybil_engine.domain.dex import Dex
3
- from sybil_engine.utils.gas_utils import l1_gas_price
4
- from sybil_engine.utils.utils import AccountException
5
-
6
- from web3_wizzard_lib.core.contract.woofi_swap import WoofiSwap
7
-
8
-
9
- class Woofi(Dex):
10
- dex_name = 'woofi'
11
- swap_contract = 'WOOFI'
12
- supported_chains = ['ZKSYNC', 'BASE', 'LINEA']
13
-
14
- def __init__(self, chain_instance, web3):
15
- super().__init__(chain_instance, web3)
16
- self.contract_address = self.chain_contracts[self.swap_contract]
17
- self.woofi_swap = WoofiSwap(self.contract_address, self.web3)
18
-
19
- @l1_gas_price
20
- def swap(self, amount_to_swap, from_token, to_token, slippage, account):
21
- if amount_to_swap.wei == 0:
22
- raise AccountException(f"{amount_to_swap.token} balance is 0")
23
-
24
- token_in_address = self.tokens[amount_to_swap.token]
25
- token_out_address = self.tokens[to_token.token]
26
-
27
- erc20_from_token = Erc20Token(self.chain_instance['chain'], amount_to_swap.token, self.web3)
28
-
29
- if amount_to_swap.token != 'ETH':
30
- if erc20_from_token.allowance(account, self.contract_address) < amount_to_swap.wei:
31
- erc20_from_token.approve(account, self.contract_address)
32
-
33
- amount_out_min = int(self.get_amount_out_min(amount_to_swap, token_in_address, token_out_address) * slippage)
34
-
35
- self.woofi_swap.swap(account, amount_to_swap, token_in_address, token_out_address, amount_out_min)
36
-
37
- def get_amount_out_min(self, amount_to_swap, token_in_address, token_out_address):
38
- return self.woofi_swap.query_swap(token_in_address, token_out_address, amount_to_swap)
@@ -1,43 +0,0 @@
1
- from loguru import logger
2
- from sybil_engine.domain.balance.tokens import Erc20Token
3
- from sybil_engine.domain.dex import Dex
4
- from sybil_engine.utils.gas_utils import l1_gas_price
5
- from sybil_engine.utils.utils import AccountException
6
-
7
- from web3_wizzard_lib.core.contract.xy_finance_contract import XYSwapContract
8
-
9
-
10
- class XyFinance(Dex):
11
- dex_name = 'xy.finance'
12
- swap_contract = 'XY_FINANCE'
13
- supported_chains = ['SCROLL']
14
-
15
- def __init__(self, chain_instance, web3):
16
- super().__init__(chain_instance, web3)
17
- self.contract_address = self.chain_contracts[self.swap_contract]
18
- self.xy_swap_contract = XYSwapContract(self.contract_address, self.web3)
19
-
20
- @l1_gas_price
21
- def swap(self, amount_to_swap, from_token, to_token, slippage, account):
22
- if amount_to_swap.wei == 0:
23
- raise AccountException(f"{amount_to_swap.token} balance is 0")
24
-
25
- token_in_address = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" if from_token == "ETH" else self.tokens[from_token]
26
- token_out_address = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" if to_token == "ETH" else self.tokens[to_token]
27
-
28
- logger.info(f"Swap {amount_to_swap.log_line()}->{to_token} in {self.dex_name} ({self.chain_instance['chain']})")
29
-
30
- erc20_from_token = Erc20Token(self.chain_instance['chain'], amount_to_swap.token, self.web3)
31
-
32
- if amount_to_swap.token != 'ETH':
33
- if erc20_from_token.allowance(account, self.contract_address) < amount_to_swap.wei:
34
- erc20_from_token.approve(account, self.contract_address)
35
-
36
- slippage = int((1 - slippage) * 100)
37
-
38
- amount_out_min = self.get_amount_out_min(amount_to_swap, token_in_address, token_out_address, slippage)
39
-
40
- self.xy_swap_contract.swap(account, amount_to_swap, token_in_address, token_out_address, amount_out_min, slippage)
41
-
42
- def get_amount_out_min(self, amount_to_swap, token_in_address, token_out_address, slippage):
43
- return self.xy_swap_contract.get_quote(token_in_address, token_out_address, amount_to_swap, slippage)
@@ -1,32 +0,0 @@
1
- from sybil_engine.domain.dex import Dex
2
-
3
- from web3_wizzard_lib.core.contract.zebra_contract import ZebraContract
4
-
5
-
6
- class Zebra(Dex):
7
- dex_name = 'zebra'
8
- swap_contract = "ZEBRA"
9
- supported_chains = ['SCROLL']
10
-
11
- def __init__(self, chain_instance, web3):
12
- super().__init__(chain_instance, web3)
13
- self.weth_address = self.tokens['WETH']
14
- zebra_contract = self.chain_contracts[self.swap_contract]
15
- self.zebra = ZebraContract(zebra_contract, self.web3)
16
-
17
- def swap_native_for_token(self, account, amount_to_swap, slippage, to_token_address):
18
- amount_out_min = int(self.get_amount_out_min(amount_to_swap, self.tokens['ETH'], to_token_address) * slippage)
19
-
20
- args = [account, amount_to_swap, self.tokens['ETH'], to_token_address, amount_out_min]
21
- func = self.zebra.swap_to_token
22
- return args, func
23
-
24
- def swap_token_for_native(self, account, amount_to_swap, from_token_address, slippage):
25
- amount_out_min = int(self.get_amount_out_min(amount_to_swap, from_token_address, self.weth_address) * slippage)
26
-
27
- args = [account, amount_to_swap, from_token_address, self.tokens['ETH'], amount_out_min]
28
- func = self.zebra.swap_to_eth
29
- return args, func
30
-
31
- def get_amount_out_min(self, amount_to_swap, from_token_address, to_token_address):
32
- return self.zebra.get_min_amount_out(amount_to_swap, from_token_address, to_token_address)
core/modules/warm_up.py DELETED
@@ -1,98 +0,0 @@
1
- import random
2
-
3
- from loguru import logger
4
- from sybil_engine.data.networks import get_chain_instance
5
- from sybil_engine.data.pairs import Pairs
6
- from sybil_engine.domain.balance.balance_utils import verify_balance, amount_to_swap_from_interval
7
- from sybil_engine.domain.balance.tokens import Erc20Token
8
- from sybil_engine.module.module import Order, RepeatableModule
9
- from sybil_engine.utils.utils import interval_to_int, randomized_sleeping, SwapException
10
- from sybil_engine.utils.validation_utils import validate_amount_interval_possible_empty, validate_token, \
11
- validate_interval, validate_dex_list
12
- from sybil_engine.utils.web3_utils import init_web3
13
-
14
- from web3_wizzard_lib.core.modules import swap_facade
15
-
16
-
17
- class WarmUp(RepeatableModule):
18
- module_name = 'WARMUP'
19
- module_config = 'warmup_config'
20
- allowed_chains = ['ZKSYNC', 'LINEA', 'BASE', 'SCROLL', 'ARBITRUM']
21
- random_order = Order.RANDOM
22
- repeat_conf = 'amount_of_warmups'
23
-
24
- @RepeatableModule.repeatable_log
25
- def execute(self, chain, swap_amount_interval, warm_token, amount_of_warmups, allowed_dex, pair_names: list,
26
- sell_tokens, sleep_interval, account):
27
- chain_instance = get_chain_instance(chain)
28
- web3 = init_web3(chain_instance, account.proxy)
29
-
30
- swap_amount = interval_to_int(amount_of_warmups)
31
-
32
- if len(pair_names) > 0:
33
- logger.info(f"Warmup pairs {pair_names}")
34
-
35
- pair = Pairs(swap_facade)
36
-
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)
40
-
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)
44
-
45
- native_balance = verify_balance(self.min_native_balance, chain_instance, account, web3)
46
- buy_dex, sell_dex = swaps[0], swaps[-1]
47
-
48
- self._warm_up_pair(buy_dex, sell_dex, native_balance, swap_amount_interval, chain_instance, pair, sell_tokens,
49
- sleep_interval, account, web3)
50
-
51
- randomized_sleeping(sleep_interval)
52
-
53
- def _warm_up_pair(self, buy_dex, sell_dex, native_balance, swap_amount_interval, chain_instance, pair, sell_tokens,
54
- sleep_interval, account, web3):
55
- warm_up_token = pair['tokens'][0]
56
- token = pair['tokens'][1]
57
-
58
- 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)
62
-
63
- if sell_tokens:
64
- try:
65
- self.execute_sell(chain_instance, pair, sell_dex, account, web3)
66
- except SwapException as e:
67
- logger.error(e)
68
- self.execute_sell(chain_instance, pair, buy_dex, account, web3)
69
-
70
- def execute_sell(self, chain_instance, pair, sell_dex, account, web3):
71
- amount_to_swap = Erc20Token(chain_instance['chain'], pair['tokens'][1], web3).balance(account)
72
- swap_facade.swap(account, amount_to_swap, chain_instance, pair, sell_dex, amount_to_swap.token,
73
- pair['tokens'][0], web3)
74
-
75
- def parse_params(self, module_params):
76
- self.validate_supported_chain(module_params['chain'])
77
- validate_amount_interval_possible_empty(module_params["swap_amount_interval"])
78
- validate_token(module_params["token"])
79
- validate_interval(module_params["amount_of_warmups"])
80
- validate_dex_list(module_params["allowed_dex"])
81
- validate_interval(module_params["pair_sleep_interval"])
82
-
83
- return (
84
- module_params["chain"],
85
- module_params["swap_amount_interval"],
86
- module_params["token"],
87
- module_params["amount_of_warmups"],
88
- module_params["allowed_dex"],
89
- module_params["warmup_pairs"],
90
- module_params["sell_tokens"],
91
- module_params["pair_sleep_interval"]
92
- )
93
-
94
- def log(self):
95
- return "WARM UP"
96
-
97
- def sleep_after(self):
98
- return False
core/modules/wrapping.py DELETED
@@ -1,74 +0,0 @@
1
- from loguru import logger
2
- from sybil_engine.contract.weth import WETH
3
- from sybil_engine.data.networks import get_chain_instance
4
- from sybil_engine.data.tokens import get_tokens_for_chain
5
- from sybil_engine.domain.balance.balance import NotEnoughNativeBalance
6
- from sybil_engine.domain.balance.balance_utils import interval_to_eth_balance, verify_balance, interval_to_weth_balance
7
- from sybil_engine.module.module import Module
8
- from sybil_engine.utils.utils import ConfigurationException
9
- from sybil_engine.utils.validation_utils import validate_amount_interval
10
- from sybil_engine.utils.web3_utils import init_web3
11
-
12
-
13
- class Wrapping(Module):
14
- module_name = 'WRAPPING'
15
- module_config = 'wrap_config'
16
- allowed_chains = ['ZKSYNC', 'LINEA', 'BASE', 'SCROLL', 'ARBITRUM']
17
- sleep_after_var = True
18
-
19
- def execute(self, wrapping_chain, swap_amount_interval, action, account):
20
- self.sleep_after_var = True
21
- chain_instance = get_chain_instance(wrapping_chain)
22
- web3 = init_web3(chain_instance, account.proxy)
23
-
24
- weth_contract = get_tokens_for_chain(chain_instance['chain'])['WETH']
25
- weth = WETH(weth_contract, web3)
26
-
27
- if action == 'WRAP':
28
- amount_to_wrap = interval_to_eth_balance(swap_amount_interval, account, chain_instance['chain'], web3)
29
-
30
- logger.info(f"{action} {str(amount_to_wrap)}")
31
-
32
- native_balance = verify_balance(self.min_native_balance, chain_instance, account, web3)
33
-
34
- if swap_amount_interval == 'all_balance':
35
- amount_to_wrap = amount_to_wrap.minus(self.min_native_balance)
36
-
37
- if amount_to_wrap.wei > native_balance.wei:
38
- raise NotEnoughNativeBalance(
39
- f"Account balance {native_balance} < {amount_to_wrap} amount to wrap.")
40
-
41
- weth.deposit(account, amount_to_wrap)
42
- elif action == 'UNWRAP':
43
- if swap_amount_interval == '':
44
- swap_amount_interval = 'all_balance'
45
-
46
- amount_to_unwrap = interval_to_weth_balance(
47
- swap_amount_interval,
48
- account,
49
- chain_instance['chain'],
50
- web3
51
- )
52
-
53
- if amount_to_unwrap.wei < 1000:
54
- logger.info(f"WETH balance is {amount_to_unwrap}, skip unwrapping")
55
- self.sleep_after_var = False
56
- return
57
-
58
- logger.info(f"{action} {amount_to_unwrap}")
59
-
60
- weth.withdraw(account, amount_to_unwrap)
61
- else:
62
- raise ConfigurationException(f'Wrong Action {action}')
63
-
64
- def parse_params(self, module_params):
65
- self.validate_supported_chain(module_params['chain'])
66
- validate_amount_interval(module_params['amount_interval'])
67
-
68
- return module_params['chain'], module_params['amount_interval'], module_params['action']
69
-
70
- def log(self):
71
- return "WRAPPING"
72
-
73
- def sleep_after(self):
74
- return self.sleep_after_var
core/modules/zkdx.py DELETED
@@ -1,63 +0,0 @@
1
- from loguru import logger
2
- from sybil_engine.data.contracts import get_contracts_for_chain
3
- from sybil_engine.data.networks import get_chain_instance
4
- from sybil_engine.domain.balance.balance_utils import interval_to_erc20_balance
5
- from sybil_engine.domain.balance.tokens import Erc20Token
6
- from sybil_engine.module.module import Module
7
- from sybil_engine.utils.app_account_utils import AppAccount
8
- from sybil_engine.utils.utils import AccountException
9
- from sybil_engine.utils.web3_utils import init_web3
10
-
11
- from web3_wizzard_lib.core.contract.zkdx_contract import ZKDXContract
12
- from web3_wizzard_lib.core.contract.zkdx_data import ZKDXDataContract
13
-
14
-
15
- class ZKDX(Module):
16
- module_name = 'ZKDX'
17
- module_config = 'zkdx_config'
18
-
19
- def execute(self, action, amount_interval, account: AppAccount, chain='LINEA'):
20
- chain_instance = get_chain_instance(chain)
21
- web3 = init_web3(chain_instance, account.proxy)
22
-
23
- zkdx_contract = get_contracts_for_chain(chain)['ZKDX']
24
- zkdx_data_contract = get_contracts_for_chain(chain)['ZKDX_DATA']
25
-
26
- zkdx = ZKDXContract(zkdx_contract, web3)
27
-
28
- if action == 'DEPOSIT':
29
- amount = interval_to_erc20_balance(amount_interval, account, 'USDC', chain, web3)
30
-
31
- erc20 = Erc20Token(chain, 'USDC', web3)
32
-
33
- if erc20.allowance(account, zkdx_contract) < erc20.balance(account).wei:
34
- erc20.approve(account, zkdx_contract)
35
-
36
- logger.info(f"Deposit {amount} to ZKDX")
37
- zkdx.swap_to_zkdx(account, amount)
38
- if action == 'WITHDRAW':
39
- zkdx_data = ZKDXDataContract(zkdx_data_contract, web3)
40
- balance = zkdx_data.get_balance(account)[0]
41
-
42
- if balance == 0:
43
- raise AccountException("ZKDX Balance is 0, skip")
44
-
45
- logger.info(f"WITHDRAW {balance / 10 ** 18} ZUSD to ZKDX")
46
- zkdx.swap_from_zkdx(account, balance)
47
- else:
48
- raise Exception(f"{action} action not supported")
49
-
50
- def log(self):
51
- return "ZKDX"
52
-
53
- def parse_params(self, module_params):
54
- return [
55
- module_params['action'],
56
- module_params['amount_interval']
57
- ]
58
-
59
-
60
- class EmptyDepositException(Exception):
61
- def __init__(self, message):
62
- self.message = message
63
- super().__init__(self.message)
tests/core/__init__.py DELETED
File without changes
File without changes