web3-wizzard-lib 1.6.12__py3-none-any.whl → 1.6.15__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/__init__.py +1 -0
- web3_wizzard_lib/core/contract/__init__.py +0 -0
- web3_wizzard_lib/core/contract/aavecontract.py +36 -0
- web3_wizzard_lib/core/contract/alienswap_contract.py +21 -0
- web3_wizzard_lib/core/contract/arena_games_contract.py +16 -0
- web3_wizzard_lib/core/contract/basiliskcontract.py +58 -0
- web3_wizzard_lib/core/contract/bilinear_contract.py +22 -0
- web3_wizzard_lib/core/contract/bungee.py +33 -0
- web3_wizzard_lib/core/contract/coredao_contract.py +34 -0
- web3_wizzard_lib/core/contract/coredao_from_contract.py +40 -0
- web3_wizzard_lib/core/contract/dmail_send_mail.py +18 -0
- web3_wizzard_lib/core/contract/empty_nft.py +18 -0
- web3_wizzard_lib/core/contract/era_name.py +23 -0
- web3_wizzard_lib/core/contract/eralendcontract.py +34 -0
- web3_wizzard_lib/core/contract/eth_scroll_bridge_contract.py +25 -0
- web3_wizzard_lib/core/contract/frog_war_contract.py +48 -0
- web3_wizzard_lib/core/contract/gmx_reward_router.py +22 -0
- web3_wizzard_lib/core/contract/horizondex_quoter.py +14 -0
- web3_wizzard_lib/core/contract/horizondex_router.py +91 -0
- web3_wizzard_lib/core/contract/imagine_contract.py +18 -0
- web3_wizzard_lib/core/contract/izumi.py +63 -0
- web3_wizzard_lib/core/contract/kreatorland_contract.py +21 -0
- web3_wizzard_lib/core/contract/l0_claim.py +254 -0
- web3_wizzard_lib/core/contract/l2_telegraph.py +21 -0
- web3_wizzard_lib/core/contract/layerbank_price.py +18 -0
- web3_wizzard_lib/core/contract/layerbank_token.py +29 -0
- web3_wizzard_lib/core/contract/layerbankcontract.py +59 -0
- web3_wizzard_lib/core/contract/linea_day_2_contract.py +19 -0
- web3_wizzard_lib/core/contract/linea_day_3_contract.py +55 -0
- web3_wizzard_lib/core/contract/linea_ens_names_contract.py +55 -0
- web3_wizzard_lib/core/contract/lineaswaprouter.py +52 -0
- web3_wizzard_lib/core/contract/maverick_multicall.py +52 -0
- web3_wizzard_lib/core/contract/mendi_finance_contract.py +11 -0
- web3_wizzard_lib/core/contract/mendi_token.py +25 -0
- web3_wizzard_lib/core/contract/merkly_minter.py +47 -0
- web3_wizzard_lib/core/contract/micro3_contract.py +18 -0
- web3_wizzard_lib/core/contract/mute_router.py +93 -0
- web3_wizzard_lib/core/contract/new_rage_contract.py +31 -0
- web3_wizzard_lib/core/contract/nidum_contract.py +44 -0
- web3_wizzard_lib/core/contract/nile_contract.py +60 -0
- web3_wizzard_lib/core/contract/nomis_attest_contract.py +40 -0
- web3_wizzard_lib/core/contract/nomis_contract.py +40 -0
- web3_wizzard_lib/core/contract/octomos.py +31 -0
- web3_wizzard_lib/core/contract/odos.py +104 -0
- web3_wizzard_lib/core/contract/omnisea.py +29 -0
- web3_wizzard_lib/core/contract/orbiter_starknet.py +30 -0
- web3_wizzard_lib/core/contract/pancake_pool.py +19 -0
- web3_wizzard_lib/core/contract/pancake_quoter.py +20 -0
- web3_wizzard_lib/core/contract/pancake_router.py +72 -0
- web3_wizzard_lib/core/contract/rage_claim.py +24 -0
- web3_wizzard_lib/core/contract/reactor_fusion_contract.py +78 -0
- web3_wizzard_lib/core/contract/readon_contract.py +19 -0
- web3_wizzard_lib/core/contract/rubyscore_contract.py +31 -0
- web3_wizzard_lib/core/contract/satoshi_universe_contract.py +29 -0
- web3_wizzard_lib/core/contract/scroll_bridge_contract.py +24 -0
- web3_wizzard_lib/core/contract/scroll_canvas_mint_contract.py +26 -0
- web3_wizzard_lib/core/contract/scroll_oracle.py +11 -0
- web3_wizzard_lib/core/contract/snap_contract.py +16 -0
- web3_wizzard_lib/core/contract/social_scan_contract.py +20 -0
- web3_wizzard_lib/core/contract/stargate_farming.py +37 -0
- web3_wizzard_lib/core/contract/stargate_router.py +84 -0
- web3_wizzard_lib/core/contract/stargate_router_eth.py +41 -0
- web3_wizzard_lib/core/contract/stargate_token_pool.py +45 -0
- web3_wizzard_lib/core/contract/stargate_v2_contract.py +36 -0
- web3_wizzard_lib/core/contract/syncswap_classic_pool.py +15 -0
- web3_wizzard_lib/core/contract/syncswap_classic_pool_factory.py +15 -0
- web3_wizzard_lib/core/contract/syncswap_pool.py +25 -0
- web3_wizzard_lib/core/contract/syncswap_router.py +123 -0
- web3_wizzard_lib/core/contract/tavaera_id.py +18 -0
- web3_wizzard_lib/core/contract/tavaera_mint.py +17 -0
- web3_wizzard_lib/core/contract/townstory_bonus_contract.py +19 -0
- web3_wizzard_lib/core/contract/townstory_contract.py +21 -0
- web3_wizzard_lib/core/contract/velocore_lens.py +44 -0
- web3_wizzard_lib/core/contract/velocore_pool.py +198 -0
- web3_wizzard_lib/core/contract/velocore_router.py +80 -0
- web3_wizzard_lib/core/contract/woofi_swap.py +29 -0
- web3_wizzard_lib/core/contract/xy_finance_contract.py +87 -0
- web3_wizzard_lib/core/contract/yoddlo_contract.py +19 -0
- web3_wizzard_lib/core/contract/yuliverse_contract.py +36 -0
- web3_wizzard_lib/core/contract/zebra_contract.py +68 -0
- web3_wizzard_lib/core/contract/zerolend_contract.py +34 -0
- web3_wizzard_lib/core/contract/zerolend_liq_contract.py +20 -0
- web3_wizzard_lib/core/contract/zkdx_contract.py +40 -0
- web3_wizzard_lib/core/contract/zkdx_data.py +14 -0
- web3_wizzard_lib/core/contract/zks.py +24 -0
- web3_wizzard_lib/core/modules/__init__.py +0 -0
- web3_wizzard_lib/core/modules/ads_import_proxy.py +52 -0
- web3_wizzard_lib/core/modules/airdrop_printer.py +81 -0
- web3_wizzard_lib/core/modules/bank/__init__.py +0 -0
- web3_wizzard_lib/core/modules/bank/aave.py +25 -0
- web3_wizzard_lib/core/modules/bank/bank.py +15 -0
- web3_wizzard_lib/core/modules/bank/basilisk.py +25 -0
- web3_wizzard_lib/core/modules/bank/eralend.py +25 -0
- web3_wizzard_lib/core/modules/bank/layerbank.py +116 -0
- web3_wizzard_lib/core/modules/bank/mendi_finance.py +57 -0
- web3_wizzard_lib/core/modules/bank/reactorfusion.py +25 -0
- web3_wizzard_lib/core/modules/bank/zerolend.py +36 -0
- web3_wizzard_lib/core/modules/bank_module.py +99 -0
- web3_wizzard_lib/core/modules/bridge/__init__.py +0 -0
- web3_wizzard_lib/core/modules/bridge/bridge.py +8 -0
- web3_wizzard_lib/core/modules/bridge/coredao_bridge_sub.py +47 -0
- web3_wizzard_lib/core/modules/bridge/orbiter_sub.py +112 -0
- web3_wizzard_lib/core/modules/bridge/scroll_bridge_sub.py +42 -0
- web3_wizzard_lib/core/modules/bridge/stargate_v2_sub.py +74 -0
- web3_wizzard_lib/core/modules/bridge_module.py +47 -0
- web3_wizzard_lib/core/modules/bungee.py +109 -0
- web3_wizzard_lib/core/modules/cex_sender.py +60 -0
- web3_wizzard_lib/core/modules/cex_subaccount_transfer.py +34 -0
- web3_wizzard_lib/core/modules/cex_withdraw.py +91 -0
- web3_wizzard_lib/core/modules/claimer.py +45 -0
- web3_wizzard_lib/core/modules/claims/__init__.py +0 -0
- web3_wizzard_lib/core/modules/claims/layerzero_claimer.py +64 -0
- web3_wizzard_lib/core/modules/claims/rabby_claimer.py +81 -0
- web3_wizzard_lib/core/modules/concrete_swap.py +108 -0
- web3_wizzard_lib/core/modules/coredao_bridge.py +32 -0
- web3_wizzard_lib/core/modules/coredao_bridge_auto.py +39 -0
- web3_wizzard_lib/core/modules/debank_checker.py +78 -0
- web3_wizzard_lib/core/modules/dmail.py +54 -0
- web3_wizzard_lib/core/modules/erc20_balance.py +42 -0
- web3_wizzard_lib/core/modules/gmx_reward.py +25 -0
- web3_wizzard_lib/core/modules/intract/__init__.py +0 -0
- web3_wizzard_lib/core/modules/intract/intract_api.py +212 -0
- web3_wizzard_lib/core/modules/intract/utils.py +81 -0
- web3_wizzard_lib/core/modules/intract_claim.py +101 -0
- web3_wizzard_lib/core/modules/layer_2_20.py +65 -0
- web3_wizzard_lib/core/modules/lending_module.py +134 -0
- web3_wizzard_lib/core/modules/linea_appeal.py +98 -0
- web3_wizzard_lib/core/modules/linea_poh_lxp.py +65 -0
- web3_wizzard_lib/core/modules/liquidity/__init__.py +0 -0
- web3_wizzard_lib/core/modules/liquidity/nile_pool.py +64 -0
- web3_wizzard_lib/core/modules/liquidity/pool.py +16 -0
- web3_wizzard_lib/core/modules/liquidity/syncswap_pool.py +61 -0
- web3_wizzard_lib/core/modules/liquidity/velocore_pool.py +55 -0
- web3_wizzard_lib/core/modules/liquidity/zerolend_liquidity.py +26 -0
- web3_wizzard_lib/core/modules/liquidity_pool.py +60 -0
- web3_wizzard_lib/core/modules/merkly_refuel.py +87 -0
- web3_wizzard_lib/core/modules/new_rage_withdraw.py +41 -0
- web3_wizzard_lib/core/modules/nft/__init__.py +0 -0
- web3_wizzard_lib/core/modules/nft/abbys_world.py +22 -0
- web3_wizzard_lib/core/modules/nft/acg_worlds.py +25 -0
- web3_wizzard_lib/core/modules/nft/alienswap_linea.py +22 -0
- web3_wizzard_lib/core/modules/nft/arena_games.py +22 -0
- web3_wizzard_lib/core/modules/nft/asmatch.py +22 -0
- web3_wizzard_lib/core/modules/nft/battlemon.py +25 -0
- web3_wizzard_lib/core/modules/nft/bilinear.py +22 -0
- web3_wizzard_lib/core/modules/nft/bitavatar.py +25 -0
- web3_wizzard_lib/core/modules/nft/culture_satoshi_universe.py +24 -0
- web3_wizzard_lib/core/modules/nft/efrogs.py +26 -0
- web3_wizzard_lib/core/modules/nft/empty_nft.py +22 -0
- web3_wizzard_lib/core/modules/nft/era_domain.py +42 -0
- web3_wizzard_lib/core/modules/nft/frog_war.py +22 -0
- web3_wizzard_lib/core/modules/nft/frog_war_bonus.py +22 -0
- web3_wizzard_lib/core/modules/nft/gamerboom.py +25 -0
- web3_wizzard_lib/core/modules/nft/gamerboom_bonus.py +26 -0
- web3_wizzard_lib/core/modules/nft/imagine.py +32 -0
- web3_wizzard_lib/core/modules/nft/kreatorland_module.py +35 -0
- web3_wizzard_lib/core/modules/nft/l2_telegraph_module.py +22 -0
- web3_wizzard_lib/core/modules/nft/layer3_meta.py +25 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_2_2_linus.py +24 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_2_3_yooldo.py +24 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_2_4_frogwar.py +24 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_2_5_acg.py +25 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_2_6_ascend_the_end.py +25 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_3_1_ascend_the_end.py +25 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_3_2_sending_me.py +25 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_3_3_townstory.py +25 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_3_4_daniele.py +25 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_3_5_demmortal.py +25 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_3_6_foxy.py +25 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_4_1_coop_records.py +60 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_4_2_borja_moskv.py +65 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_4_2_borja_moskv_approve.py +27 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_4_3_fruit.py +66 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_4_4_fruit_crux.py +67 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_4_5_forbidden_fruit.py +67 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_4_6_laurent.py +67 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_day2.py +20 -0
- web3_wizzard_lib/core/modules/nft/linea_culture_day3.py +20 -0
- web3_wizzard_lib/core/modules/nft/linea_ens_names.py +107 -0
- web3_wizzard_lib/core/modules/nft/lucky_cat.py +25 -0
- web3_wizzard_lib/core/modules/nft/merkly_minter_module.py +22 -0
- web3_wizzard_lib/core/modules/nft/micro3.py +23 -0
- web3_wizzard_lib/core/modules/nft/mint_2048.py +28 -0
- web3_wizzard_lib/core/modules/nft/nft_submodule.py +16 -0
- web3_wizzard_lib/core/modules/nft/nidum.py +87 -0
- web3_wizzard_lib/core/modules/nft/nidum_bonus.py +23 -0
- web3_wizzard_lib/core/modules/nft/nomis.py +64 -0
- web3_wizzard_lib/core/modules/nft/nomis_attest.py +66 -0
- web3_wizzard_lib/core/modules/nft/nouns.py +27 -0
- web3_wizzard_lib/core/modules/nft/octomos.py +32 -0
- web3_wizzard_lib/core/modules/nft/omnisea.py +33 -0
- web3_wizzard_lib/core/modules/nft/omnizone.py +25 -0
- web3_wizzard_lib/core/modules/nft/orbiter_claim.py +87 -0
- web3_wizzard_lib/core/modules/nft/readon.py +30 -0
- web3_wizzard_lib/core/modules/nft/rubyscore.py +45 -0
- web3_wizzard_lib/core/modules/nft/sarubol.py +22 -0
- web3_wizzard_lib/core/modules/nft/satoshi_universe.py +22 -0
- web3_wizzard_lib/core/modules/nft/scroll_canvas_attest_year_badge.py +35 -0
- web3_wizzard_lib/core/modules/nft/scroll_canvas_mint.py +51 -0
- web3_wizzard_lib/core/modules/nft/sign.py +32 -0
- web3_wizzard_lib/core/modules/nft/snap.py +25 -0
- web3_wizzard_lib/core/modules/nft/snap_bonus.py +31 -0
- web3_wizzard_lib/core/modules/nft/social_scan.py +22 -0
- web3_wizzard_lib/core/modules/nft/tavaera.py +30 -0
- web3_wizzard_lib/core/modules/nft/townstory.py +75 -0
- web3_wizzard_lib/core/modules/nft/townstory_bonus.py +45 -0
- web3_wizzard_lib/core/modules/nft/trusta_reputation.py +48 -0
- web3_wizzard_lib/core/modules/nft/trustaa_poh.py +49 -0
- web3_wizzard_lib/core/modules/nft/uber_poh.py +24 -0
- web3_wizzard_lib/core/modules/nft/wizards_of_linea.py +26 -0
- web3_wizzard_lib/core/modules/nft/yoddlo.py +22 -0
- web3_wizzard_lib/core/modules/nft/yuliverse.py +22 -0
- web3_wizzard_lib/core/modules/nft/zace.py +25 -0
- web3_wizzard_lib/core/modules/nft/zks_domain.py +41 -0
- web3_wizzard_lib/core/modules/nft_minter.py +107 -0
- web3_wizzard_lib/core/modules/orbiter.py +39 -0
- web3_wizzard_lib/core/modules/orbiter_checker.py +26 -0
- web3_wizzard_lib/core/modules/rage.py +54 -0
- web3_wizzard_lib/core/modules/scroll_bridge.py +45 -0
- web3_wizzard_lib/core/modules/sell_all.py +51 -0
- web3_wizzard_lib/core/modules/sleep_module.py +25 -0
- web3_wizzard_lib/core/modules/smart_contract_deployment.py +37 -0
- web3_wizzard_lib/core/modules/stargate/__init__.py +0 -0
- web3_wizzard_lib/core/modules/stargate/auto_bridge.py +91 -0
- web3_wizzard_lib/core/modules/stargate/bridge.py +38 -0
- web3_wizzard_lib/core/modules/stargate/bridge_eth.py +59 -0
- web3_wizzard_lib/core/modules/stargate/bridge_tokens.py +48 -0
- web3_wizzard_lib/core/modules/stargate/classic_bridge.py +34 -0
- web3_wizzard_lib/core/modules/stargate/farming.py +163 -0
- web3_wizzard_lib/core/modules/stargate/l0_data.py +10 -0
- web3_wizzard_lib/core/modules/stargate/pool.py +74 -0
- web3_wizzard_lib/core/modules/stargate/stargate_balance_utils.py +25 -0
- web3_wizzard_lib/core/modules/stargate/stargate_gas_checker.py +68 -0
- web3_wizzard_lib/core/modules/swap/__init__.py +1 -0
- web3_wizzard_lib/core/modules/swap/horizondex.py +38 -0
- web3_wizzard_lib/core/modules/swap/izumi.py +41 -0
- web3_wizzard_lib/core/modules/swap/lineaswap.py +34 -0
- web3_wizzard_lib/core/modules/swap/maverick.py +66 -0
- web3_wizzard_lib/core/modules/swap/mute.py +39 -0
- web3_wizzard_lib/core/modules/swap/odos.py +58 -0
- web3_wizzard_lib/core/modules/swap/one_inch.py +58 -0
- web3_wizzard_lib/core/modules/swap/pancake.py +41 -0
- web3_wizzard_lib/core/modules/swap/swap_list.py +11 -0
- web3_wizzard_lib/core/modules/swap/syncswap.py +62 -0
- web3_wizzard_lib/core/modules/swap/velocore.py +40 -0
- web3_wizzard_lib/core/modules/swap/woofi.py +38 -0
- web3_wizzard_lib/core/modules/swap/xy_finance.py +43 -0
- web3_wizzard_lib/core/modules/swap/zebra.py +32 -0
- web3_wizzard_lib/core/modules/warm_up.py +98 -0
- web3_wizzard_lib/core/modules/wrapping.py +74 -0
- web3_wizzard_lib/core/modules/zkdx.py +63 -0
- web3_wizzard_lib/core/utils/__init__.py +0 -0
- web3_wizzard_lib/core/utils/ai_utils.py +45 -0
- web3_wizzard_lib/core/utils/benchmark_utils.py +12 -0
- web3_wizzard_lib/core/utils/module_memory.py +28 -0
- web3_wizzard_lib/core/utils/statistic_utils.py +150 -0
- web3_wizzard_lib/core/utils/sub_module.py +8 -0
- web3_wizzard_lib/data/__init__.py +0 -0
- web3_wizzard_lib/data/config_default.py +52 -0
- web3_wizzard_lib/data/module_config_default.py +209 -0
- web3_wizzard_lib/utils/__init__.py +0 -0
- web3_wizzard_lib/utils/debank_utils.py +19 -0
- {web3_wizzard_lib-1.6.12.dist-info → web3_wizzard_lib-1.6.15.dist-info}/METADATA +2 -2
- web3_wizzard_lib-1.6.15.dist-info/RECORD +369 -0
- web3_wizzard_lib-1.6.12.dist-info/RECORD +0 -107
- {web3_wizzard_lib-1.6.12.dist-info → web3_wizzard_lib-1.6.15.dist-info}/WHEEL +0 -0
- {web3_wizzard_lib-1.6.12.dist-info → web3_wizzard_lib-1.6.15.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
from sybil_engine.module.module import Module, Order
|
2
|
+
|
3
|
+
from web3_wizzard_lib.core.modules.stargate.bridge import StargateBridge
|
4
|
+
|
5
|
+
|
6
|
+
class StargateBridgeModule(Module):
|
7
|
+
module_name = 'STARGATE_CLASSIC_BRIDGE'
|
8
|
+
module_config = 'stargate_classic_config'
|
9
|
+
random_order = Order.STRICT
|
10
|
+
|
11
|
+
def execute(self, bridge_amount_interval, bridge_token, retry_interval, from_chain, to_chain, account):
|
12
|
+
StargateBridge(retry_interval).bridge(
|
13
|
+
self.min_native_balance,
|
14
|
+
account,
|
15
|
+
bridge_amount_interval,
|
16
|
+
bridge_token,
|
17
|
+
from_chain,
|
18
|
+
to_chain
|
19
|
+
)
|
20
|
+
|
21
|
+
def log(self):
|
22
|
+
return "STARGATE CLASSIC"
|
23
|
+
|
24
|
+
def parse_params(self, module_params):
|
25
|
+
if 'retry_interval' not in module_params:
|
26
|
+
module_params['retry_interval'] = {'from': 60 * 5, 'to': 60 * 10}
|
27
|
+
|
28
|
+
return (
|
29
|
+
module_params['bridge_amount_interval'],
|
30
|
+
module_params['bridge_token'],
|
31
|
+
module_params['retry_interval'],
|
32
|
+
module_params['from_chain'],
|
33
|
+
module_params['to_chain']
|
34
|
+
)
|
@@ -0,0 +1,163 @@
|
|
1
|
+
from loguru import logger
|
2
|
+
from sybil_engine.config.app_config import get_network
|
3
|
+
from sybil_engine.data.contracts import get_contracts_for_chain
|
4
|
+
from sybil_engine.data.networks import get_chain_instance
|
5
|
+
from sybil_engine.domain.balance.balance import Erc20Balance, NativeBalance
|
6
|
+
from sybil_engine.domain.balance.balance_utils import get_native_balance, interval_to_eth_balance
|
7
|
+
from sybil_engine.domain.balance.tokens import Erc20Token
|
8
|
+
from sybil_engine.module.module import Module
|
9
|
+
from sybil_engine.utils.utils import randomized_sleeping
|
10
|
+
from sybil_engine.utils.web3_utils import init_web3, get_amount_to_bridge_usdc, get_max_balance_data
|
11
|
+
|
12
|
+
from web3_wizzard_lib.core.contract.stargate_farming import StargateFarming
|
13
|
+
from web3_wizzard_lib.core.contract.stargate_router import StargateRouter
|
14
|
+
from web3_wizzard_lib.core.modules.stargate.pool import add_to_pool, find_max_pool_chain, get_pool_token_name, get_pool_balances
|
15
|
+
from web3_wizzard_lib.core.modules.stargate.stargate_balance_utils import StargatePoolToken
|
16
|
+
|
17
|
+
all_chains = {
|
18
|
+
'MAIN': {
|
19
|
+
'USDC': ['ARBITRUM', 'BASE', 'BSC', 'POLYGON', 'AVALANCHE', 'OPTIMISM', 'FANTOM'],
|
20
|
+
'ETH': ['ARBITRUM', 'BASE', 'LINEA', 'OPTIMISM']
|
21
|
+
},
|
22
|
+
'LOCAL': {
|
23
|
+
'USDC': ['BASE'],
|
24
|
+
'ETH': ['BASE']
|
25
|
+
},
|
26
|
+
'GOERLI': {
|
27
|
+
'USDC': ['LINEA', 'BASE'],
|
28
|
+
'ETH': ['LINEA', 'BASE']
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
|
33
|
+
class StargateFarmingModule(Module):
|
34
|
+
module_name = 'STARGATE_FARMING'
|
35
|
+
module_config = 'stargate_farming_config'
|
36
|
+
|
37
|
+
def execute(self, bridge_amount_interval, chain, operation, all_balance_mode, token, operation_sleep_interval,
|
38
|
+
account):
|
39
|
+
try:
|
40
|
+
logger.info(f"=============== Stargate staking: {account.address} ===============")
|
41
|
+
|
42
|
+
chains = all_chains[get_network()][token]
|
43
|
+
|
44
|
+
if 'ADD_TO_POOL' in operation:
|
45
|
+
self.add_to_pool_logic(account, all_balance_mode, bridge_amount_interval, chain, chains, token)
|
46
|
+
randomized_sleeping(operation_sleep_interval)
|
47
|
+
|
48
|
+
if 'DEPOSIT' in operation:
|
49
|
+
self.deposit_logic(account, chains, token)
|
50
|
+
randomized_sleeping(operation_sleep_interval)
|
51
|
+
|
52
|
+
if 'WITHDRAW' in operation:
|
53
|
+
self.withdraw_logic(account, chains, token)
|
54
|
+
randomized_sleeping(operation_sleep_interval)
|
55
|
+
|
56
|
+
if 'REDEEM_FROM_POOL' in operation:
|
57
|
+
self.redeem_from_pool_logic(account, chains, token)
|
58
|
+
randomized_sleeping(operation_sleep_interval)
|
59
|
+
except Exception as e:
|
60
|
+
logger.info(f"Error during farming: {e}")
|
61
|
+
|
62
|
+
def redeem_from_pool_logic(self, account, chains, token):
|
63
|
+
pool_balances = get_pool_balances(token, account, chains)
|
64
|
+
chain, pool_balance, web3 = find_max_pool_chain(pool_balances)
|
65
|
+
chain_instance = get_chain_instance(chain)
|
66
|
+
stargate_router = StargateRouter(get_contracts_for_chain(chain)["STARGATE_ROUTER"], web3)
|
67
|
+
logger.info(f"Redeem from {chain} pool {pool_balance}")
|
68
|
+
if token == 'USDC':
|
69
|
+
stargate_pool_id = chain_instance['stargate_usdc_pool']
|
70
|
+
else:
|
71
|
+
stargate_pool_id = chain_instance['stargate_eth_pool']
|
72
|
+
if pool_balance.wei > 0:
|
73
|
+
stargate_router.instant_redeem(account, pool_balance.wei, stargate_pool_id)
|
74
|
+
else:
|
75
|
+
logger.info(f"Pool is empty, ignoring")
|
76
|
+
|
77
|
+
def withdraw_logic(self, account, chains, token):
|
78
|
+
logger.info("Withdraw from farming")
|
79
|
+
farm_balances = self.get_farm_balances(account, token, chains)
|
80
|
+
chain, farm_balance, web3 = find_max_pool_chain(farm_balances)
|
81
|
+
farming_address = get_contracts_for_chain(chain)['STARGATE_FARMING']
|
82
|
+
stargate_farming = StargateFarming(farming_address, web3)
|
83
|
+
logger.info(f"Balance in farming {farm_balance}, withdrawing all")
|
84
|
+
if farm_balance.wei > 0:
|
85
|
+
stargate_farming.withdraw(account, farm_balance.wei)
|
86
|
+
else:
|
87
|
+
logger.info(f"Farming balance is empty, ignoring")
|
88
|
+
|
89
|
+
def deposit_logic(self, account, chains, token):
|
90
|
+
logger.info("Deposit to farm")
|
91
|
+
|
92
|
+
pool_balances = get_pool_balances(token, account, chains)
|
93
|
+
chain, pool_balance, web3 = find_max_pool_chain(pool_balances)
|
94
|
+
|
95
|
+
chain_instance = get_chain_instance(chain)
|
96
|
+
farming_address = get_contracts_for_chain(chain)['STARGATE_FARMING']
|
97
|
+
|
98
|
+
stargate_farming = StargateFarming(farming_address, web3)
|
99
|
+
logger.info(f"Amount in {chain} pool {pool_balance}")
|
100
|
+
|
101
|
+
pool_token_name = get_pool_token_name(token)
|
102
|
+
stargate_pool_token = StargatePoolToken(chain, pool_token_name, web3)
|
103
|
+
|
104
|
+
if stargate_pool_token.allowance(account, farming_address) < pool_balance.wei:
|
105
|
+
stargate_pool_token.approve(account, farming_address)
|
106
|
+
|
107
|
+
stargate_farming.deposit(account, pool_balance)
|
108
|
+
|
109
|
+
def add_to_pool_logic(self, account, all_balance_mode, bridge_amount_interval, chain, chains, token):
|
110
|
+
|
111
|
+
def get_balance_to_pool(token_type, chain_instance, web3):
|
112
|
+
if token_type == 'USDC':
|
113
|
+
stargate_token = Erc20Token(chain, 'USDC', web3)
|
114
|
+
return stargate_token.balance(account)
|
115
|
+
else:
|
116
|
+
return get_native_balance(account, web3, chain_instance)
|
117
|
+
|
118
|
+
if bridge_amount_interval == 'all_balance':
|
119
|
+
if all_balance_mode == 0:
|
120
|
+
max_balance_chain, amount_to_pool, native_balance, web3 = get_max_balance_data(token, chains, account)
|
121
|
+
chain_instance = get_chain_instance(max_balance_chain)
|
122
|
+
amount_to_pool = native_balance
|
123
|
+
else:
|
124
|
+
chain_instance = get_chain_instance(chain)
|
125
|
+
web3 = init_web3(chain_instance, account.proxy)
|
126
|
+
amount_to_pool = get_balance_to_pool(token, chain_instance, web3)
|
127
|
+
amount_to_pool = amount_to_pool.minus(self.min_native_balance)
|
128
|
+
else:
|
129
|
+
chain_instance = get_chain_instance(chain)
|
130
|
+
web3 = init_web3(chain_instance, account.proxy)
|
131
|
+
amount_to_pool = get_amount_to_bridge_usdc(
|
132
|
+
bridge_amount_interval) if token == 'USDC' else interval_to_eth_balance(bridge_amount_interval, account,
|
133
|
+
chain_instance['chain'], web3)
|
134
|
+
|
135
|
+
logger.info(f"Adding to stargate {chain_instance['chain']} pool")
|
136
|
+
add_to_pool(account, amount_to_pool, token, chain_instance, web3)
|
137
|
+
|
138
|
+
def get_farm_balances(self, account, token, chains):
|
139
|
+
|
140
|
+
def get_balance_for_chain(chain):
|
141
|
+
web3 = init_web3(get_chain_instance(chain), account.proxy)
|
142
|
+
farming_address = get_contracts_for_chain(chain)['STARGATE_FARMING']
|
143
|
+
farming = StargateFarming(farming_address, web3)
|
144
|
+
|
145
|
+
if token == 'USDC':
|
146
|
+
return chain, Erc20Balance(farming.user_info(account), chain, token), web3
|
147
|
+
else:
|
148
|
+
return chain, NativeBalance(farming.user_info(account), chain, token), web3
|
149
|
+
|
150
|
+
return [get_balance_for_chain(chain) for chain in chains]
|
151
|
+
|
152
|
+
def log(self):
|
153
|
+
return "STARGATE FARMING"
|
154
|
+
|
155
|
+
def parse_params(self, module_params):
|
156
|
+
return (
|
157
|
+
module_params['bridge_amount_interval'],
|
158
|
+
module_params['chain'],
|
159
|
+
module_params['operation'],
|
160
|
+
module_params['all_balance_mode'],
|
161
|
+
module_params['token'],
|
162
|
+
module_params['operation_sleep_interval']
|
163
|
+
)
|
@@ -0,0 +1,74 @@
|
|
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 get_native_balance
|
5
|
+
from sybil_engine.domain.balance.tokens import Erc20Token
|
6
|
+
from sybil_engine.utils.utils import ModuleException
|
7
|
+
from sybil_engine.utils.web3_utils import init_web3
|
8
|
+
|
9
|
+
from web3_wizzard_lib.core.contract.stargate_router import StargateRouter
|
10
|
+
from web3_wizzard_lib.core.contract.stargate_router_eth import StargateRouterEth
|
11
|
+
from web3_wizzard_lib.core.modules.stargate.stargate_balance_utils import StargatePoolToken
|
12
|
+
|
13
|
+
|
14
|
+
def add_to_pool(account, amount_to_pool, bridge_token, chain_instance, web3):
|
15
|
+
def get_router_details(token_type, chain_inst):
|
16
|
+
contracts = get_contracts_for_chain(chain_inst['chain'])
|
17
|
+
if token_type == 'ETH':
|
18
|
+
return StargateRouterEth(contracts["STARGATE_ROUTER_ETH"], web3), None
|
19
|
+
else:
|
20
|
+
erc20 = Erc20Token(chain_inst['chain'], token_type, web3)
|
21
|
+
|
22
|
+
if erc20.allowance(account, contracts["STARGATE_ROUTER"]) < erc20.balance(account).wei:
|
23
|
+
erc20.approve(account, contracts["STARGATE_ROUTER"])
|
24
|
+
return StargateRouter(contracts["STARGATE_ROUTER"], web3), erc20
|
25
|
+
|
26
|
+
logger.info(f"======= Adding liquidity {bridge_token} {chain_instance['chain']} ::: {account.address} =======")
|
27
|
+
|
28
|
+
native_balance = get_native_balance(account, web3, chain_instance)
|
29
|
+
logger.info(f"Native balance: {native_balance}")
|
30
|
+
|
31
|
+
stargate_router, erc20 = get_router_details(bridge_token, chain_instance)
|
32
|
+
|
33
|
+
balance = native_balance if bridge_token == 'ETH' else erc20.balance(account)
|
34
|
+
if bridge_token != 'ETH':
|
35
|
+
logger.info(f"Balance: {balance}")
|
36
|
+
|
37
|
+
verify_balance(amount_to_pool, balance, native_balance)
|
38
|
+
|
39
|
+
func = stargate_router.add_liquidity_eth if bridge_token == 'ETH' else stargate_router.add_liquidity
|
40
|
+
|
41
|
+
logger.info(f"Pooling: {amount_to_pool}")
|
42
|
+
func(account, amount_to_pool)
|
43
|
+
|
44
|
+
|
45
|
+
def verify_balance(amount_to_pool, balance, erc20_token):
|
46
|
+
if amount_to_pool.wei > balance.wei:
|
47
|
+
raise Exception(f"Account balance ({amount_to_pool}) is lower than amount to pool.")
|
48
|
+
|
49
|
+
if balance.wei == 0:
|
50
|
+
logger.info(f"{erc20_token.token} balance is 0")
|
51
|
+
raise ModuleException("")
|
52
|
+
|
53
|
+
|
54
|
+
def find_max_pool_chain(balances):
|
55
|
+
max_usdc_balance = max(balances, key=lambda x: x[1].wei)
|
56
|
+
|
57
|
+
if max_usdc_balance[1] == 0:
|
58
|
+
raise Exception("Can't bridge tokens, all chain USDC balances are zero")
|
59
|
+
|
60
|
+
return max_usdc_balance
|
61
|
+
|
62
|
+
|
63
|
+
def get_pool_token_name(token_type):
|
64
|
+
return 'STARGATE_ETH_POOL' if token_type == 'ETH' else 'STARGATE_USDT_POOL'
|
65
|
+
|
66
|
+
|
67
|
+
def get_pool_balances(token, account, chains):
|
68
|
+
return [get_pool_balance_for_chain(chain, token, account) for chain in chains]
|
69
|
+
|
70
|
+
|
71
|
+
def get_pool_balance_for_chain(chain, pool_token_name, account):
|
72
|
+
web3 = init_web3(get_chain_instance(chain), account.proxy)
|
73
|
+
pool_token_instance = StargatePoolToken(chain, get_pool_token_name(pool_token_name), web3)
|
74
|
+
return chain, pool_token_instance.balance(account), web3
|
@@ -0,0 +1,25 @@
|
|
1
|
+
from sybil_engine.data.tokens import get_tokens_for_chain
|
2
|
+
from sybil_engine.domain.balance.balance import Erc20Balance, NativeBalance
|
3
|
+
|
4
|
+
from web3_wizzard_lib.core.contract.stargate_token_pool import StargateTokenPool
|
5
|
+
|
6
|
+
|
7
|
+
class StargatePoolToken:
|
8
|
+
def __init__(self, chain, token, web3):
|
9
|
+
self.chain = chain
|
10
|
+
self.token = token
|
11
|
+
self.web3 = web3
|
12
|
+
self.token_pool_contract = StargateTokenPool(get_tokens_for_chain(self.chain)[self.token], self.web3)
|
13
|
+
|
14
|
+
def balance(self, account):
|
15
|
+
if self.token == 'STARGATE_USDC_POOL':
|
16
|
+
return Erc20Balance(self.token_pool_contract.balance_of(account), self.chain, self.token)
|
17
|
+
else:
|
18
|
+
return NativeBalance(self.token_pool_contract.balance_of(account), self.chain, self.token)
|
19
|
+
|
20
|
+
def approve(self, account, contract_on_approve):
|
21
|
+
return self.token_pool_contract.approve(account, contract_on_approve)
|
22
|
+
|
23
|
+
def allowance(self, account, allowance_contract):
|
24
|
+
return self.token_pool_contract.allowance(account, allowance_contract)
|
25
|
+
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import functools
|
2
|
+
|
3
|
+
from loguru import logger
|
4
|
+
from sybil_engine.data.contracts import get_contracts_for_chain
|
5
|
+
from sybil_engine.domain.balance.balance import NativeBalance, NotEnoughNativeBalance
|
6
|
+
from sybil_engine.domain.balance.balance_utils import get_native_balance, from_eth_to_wei
|
7
|
+
from sybil_engine.utils.l0_utils import L0FeeToHigh
|
8
|
+
from sybil_engine.utils.utils import randomized_sleeping
|
9
|
+
|
10
|
+
|
11
|
+
def stargate_check_gas(token):
|
12
|
+
def decorator(func):
|
13
|
+
@functools.wraps(func)
|
14
|
+
def wrapper(self, *args):
|
15
|
+
check_gas(token, self.chain_instance, args[-1], args[0], self.web3)
|
16
|
+
return func(self, *args)
|
17
|
+
|
18
|
+
return wrapper
|
19
|
+
|
20
|
+
return decorator
|
21
|
+
|
22
|
+
|
23
|
+
def check_gas(token, chain_instance, to_chain_instance, account, web3):
|
24
|
+
while True:
|
25
|
+
try:
|
26
|
+
verify_stargate_fee(token, chain_instance, to_chain_instance, account, web3)
|
27
|
+
return
|
28
|
+
except L0FeeToHigh as e:
|
29
|
+
logger.info(e)
|
30
|
+
randomized_sleeping({'from': 60 * 4, 'to': 60 * 8})
|
31
|
+
except Exception as e:
|
32
|
+
raise StargateBridgeException("Stargate bridge error") from e
|
33
|
+
|
34
|
+
|
35
|
+
def verify_stargate_fee(token, from_chain_instance, to_chain_instance, account, web3):
|
36
|
+
native_balance = get_native_balance(account, web3, from_chain_instance)
|
37
|
+
native_fee_balance = get_native_fee_balance(token, native_balance, from_chain_instance, to_chain_instance, account,
|
38
|
+
web3)
|
39
|
+
|
40
|
+
logger.info(f"Native LayerZero fee: {native_fee_balance.log_line()}")
|
41
|
+
if native_fee_balance.wei > native_balance.wei:
|
42
|
+
raise NotEnoughNativeBalance(
|
43
|
+
f"Native balance ({native_balance.log_line()}) < Native LayerZero required fee")
|
44
|
+
if native_fee_balance.wei > from_eth_to_wei(from_chain_instance['max_l0_fee']):
|
45
|
+
raise L0FeeToHigh(f"Native LayerZero fee is to high")
|
46
|
+
|
47
|
+
|
48
|
+
def get_native_fee_balance(token, native_balance, from_chain_instance, to_chain_instance, account, web3):
|
49
|
+
chain_contracts = get_contracts_for_chain(from_chain_instance['chain'])
|
50
|
+
|
51
|
+
if token in ['ETH', 'USDC']:
|
52
|
+
from web3_wizzard_lib.core.contract.stargate_router import StargateRouter
|
53
|
+
stargate_router = StargateRouter(chain_contracts["STARGATE_ROUTER"], web3)
|
54
|
+
|
55
|
+
wei_balance = stargate_router.count_native_fee_stargate(
|
56
|
+
to_chain_instance['stargate_chain_id'],
|
57
|
+
account.address
|
58
|
+
)
|
59
|
+
else:
|
60
|
+
raise Exception("Token not supported")
|
61
|
+
|
62
|
+
return NativeBalance(wei_balance, native_balance.chain, native_balance.token)
|
63
|
+
|
64
|
+
|
65
|
+
class StargateBridgeException(Exception):
|
66
|
+
def __init__(self, message):
|
67
|
+
self.message = message
|
68
|
+
super().__init__(self.message)
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
from sybil_engine.domain.dex import Dex
|
2
|
+
|
3
|
+
from web3_wizzard_lib.core.contract.horizondex_router import HorizonDexRouter
|
4
|
+
from ...contract.horizondex_quoter import HorizonDexQuoter
|
5
|
+
|
6
|
+
|
7
|
+
class Horizondex(Dex):
|
8
|
+
dex_name = 'horizondex'
|
9
|
+
swap_contract = 'HORIZONDEX'
|
10
|
+
supported_chains = ['BASE', 'LINEA']
|
11
|
+
|
12
|
+
def __init__(self, chain_instance, web3):
|
13
|
+
super().__init__(chain_instance, web3)
|
14
|
+
self.weth_address = self.tokens['WETH']
|
15
|
+
self.horizondex_router = HorizonDexRouter(self.chain_contracts[self.swap_contract], self.web3)
|
16
|
+
|
17
|
+
def swap_token_for_native(self, account, amount_to_swap, from_token_address, slippage):
|
18
|
+
amount_out_min = int(self.get_amount_out_min(amount_to_swap, from_token_address, self.weth_address) * slippage)
|
19
|
+
args = [account, amount_to_swap, amount_out_min, from_token_address, self.weth_address]
|
20
|
+
func = self.horizondex_router.multicall
|
21
|
+
|
22
|
+
return args, func
|
23
|
+
|
24
|
+
def swap_native_for_token(self, account, amount_to_swap, slippage, to_token_address):
|
25
|
+
amount_out_min = int(self.get_amount_out_min(amount_to_swap, self.weth_address, to_token_address) * slippage)
|
26
|
+
args = [account, amount_to_swap, amount_out_min, self.weth_address, to_token_address]
|
27
|
+
func = self.horizondex_router.swap_exact_input_single
|
28
|
+
|
29
|
+
return args, func
|
30
|
+
|
31
|
+
def swap_token_for_token(self, account, amount_to_swap, slippage, from_token_address, to_token_address):
|
32
|
+
raise Exception("Not supported yet")
|
33
|
+
|
34
|
+
def get_amount_out_min(self, amount_to_swap, from_token_address, to_token_address):
|
35
|
+
horizondex_quoter_contract = self.chain_contracts["HORIZONDEX_QUOTER"]
|
36
|
+
horizondex_quoter = HorizonDexQuoter(horizondex_quoter_contract, self.web3)
|
37
|
+
|
38
|
+
return horizondex_quoter.quote_exact_input_single(amount_to_swap.wei, from_token_address, to_token_address)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
from sybil_engine.domain.dex import Dex
|
2
|
+
|
3
|
+
from ...contract.izumi import IzumiRouter
|
4
|
+
|
5
|
+
|
6
|
+
class Izumi(Dex):
|
7
|
+
dex_name = 'izumi'
|
8
|
+
swap_contract = 'IZUMI'
|
9
|
+
supported_chains = ['LINEA']
|
10
|
+
|
11
|
+
def __init__(self, chain_instance, web3):
|
12
|
+
super().__init__(chain_instance, web3)
|
13
|
+
self.weth_address = self.tokens['WETH']
|
14
|
+
self.izumi = IzumiRouter(self.chain_contracts[self.swap_contract], self.web3)
|
15
|
+
|
16
|
+
def swap_token_for_native(self, account, amount_to_swap, from_token_address, slippage):
|
17
|
+
amount_out_min = int(self.get_amount_out_min(amount_to_swap, from_token_address, self.weth_address) * slippage)
|
18
|
+
args = [account, amount_to_swap, amount_out_min, from_token_address, self.weth_address]
|
19
|
+
func = self.izumi.multicall
|
20
|
+
|
21
|
+
return args, func
|
22
|
+
|
23
|
+
def swap_native_for_token(self, account, amount_to_swap, slippage, to_token_address):
|
24
|
+
amount_out_min = int(self.get_amount_out_min(amount_to_swap, self.weth_address, to_token_address) * slippage)
|
25
|
+
args = [account, amount_to_swap, amount_out_min, self.weth_address, to_token_address]
|
26
|
+
func = self.izumi.multicall
|
27
|
+
|
28
|
+
return args, func
|
29
|
+
|
30
|
+
def swap_token_for_token(self, account, amount_to_swap, slippage, from_token_address, to_token_address):
|
31
|
+
raise Exception("Not supported yet")
|
32
|
+
|
33
|
+
def get_amount_out_min(self, amount_to_swap, from_token_address, to_token_address):
|
34
|
+
izumi = self.chain_contracts["IZUMI"]
|
35
|
+
izumi_router = IzumiRouter(izumi, self.web3)
|
36
|
+
|
37
|
+
if amount_to_swap.token == 'ETH':
|
38
|
+
return int((izumi_router.quote_price('weETH') * amount_to_swap.wei) * 0.999)
|
39
|
+
else:
|
40
|
+
return int((izumi_router.quote_price('ETH') * amount_to_swap.wei) * 0.999)
|
41
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
from sybil_engine.domain.dex import Dex
|
2
|
+
|
3
|
+
from web3_wizzard_lib.core.contract.lineaswaprouter import LineaSwapRouter
|
4
|
+
|
5
|
+
|
6
|
+
class LineaSwap(Dex):
|
7
|
+
dex_name = 'lineaswap'
|
8
|
+
swap_contract = "LINEASWAP"
|
9
|
+
supported_chains = ['BASE', 'LINEA']
|
10
|
+
|
11
|
+
def __init__(self, chain_instance, web3):
|
12
|
+
super().__init__(chain_instance, web3)
|
13
|
+
self.linea_swap_router = LineaSwapRouter(self.chain_contracts[self.swap_contract], self.web3)
|
14
|
+
self.weth_address = self.tokens['WETH']
|
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
|
+
args = [account, amount_to_swap, self.weth_address, to_token_address, amount_out_min]
|
19
|
+
func = self.linea_swap_router.swap_exact_eth_for_tokens
|
20
|
+
|
21
|
+
return args, func
|
22
|
+
|
23
|
+
def swap_token_for_native(self, account, amount_to_swap, from_token_address, slippage):
|
24
|
+
amount_out_min = int(self.get_amount_out_min(amount_to_swap, from_token_address, self.weth_address) * slippage)
|
25
|
+
args = [account, amount_to_swap, from_token_address, self.weth_address, amount_out_min]
|
26
|
+
func = self.linea_swap_router.swap_exact_tokens_for_eth
|
27
|
+
|
28
|
+
return args, func
|
29
|
+
|
30
|
+
def swap_token_for_token(self, account, amount_to_swap, slippage, from_token_address, to_token_address):
|
31
|
+
raise Exception("Not supported")
|
32
|
+
|
33
|
+
def get_amount_out_min(self, amount_to_swap, from_token_address, to_token_address):
|
34
|
+
return self.linea_swap_router.get_amount_out(amount_to_swap, from_token_address, to_token_address)
|
@@ -0,0 +1,66 @@
|
|
1
|
+
from sybil_engine.domain.balance.tokens import Erc20Token
|
2
|
+
from sybil_engine.domain.dex import Dex
|
3
|
+
|
4
|
+
from web3_wizzard_lib.core.contract.maverick_multicall import MaverickMulticall
|
5
|
+
from ...contract.pancake_pool import PancakePool
|
6
|
+
from ...contract.pancake_quoter import PancakeQuoter
|
7
|
+
|
8
|
+
pool_addresses = {
|
9
|
+
'ZKSYNC': {
|
10
|
+
"ETH>USDC": "0x41c8cf74c27554a8972d3bf3d2bd4a14d8b604ab"
|
11
|
+
},
|
12
|
+
'BASE': {
|
13
|
+
"ETH>USDbC": "0x06e6736ca9e922766279a22b75a600fe8b8473b6",
|
14
|
+
"ETH>USDC": "0x06e6736ca9e922766279a22b75a600fe8b8473b6"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
|
19
|
+
class Maverick(Dex):
|
20
|
+
dex_name = 'maverick'
|
21
|
+
swap_contract = 'MAV_ROUTER'
|
22
|
+
supported_chains = ['ZKSYNC', 'BASE']
|
23
|
+
|
24
|
+
def __init__(self, chain_instance, web3):
|
25
|
+
self.chain_instance = chain_instance
|
26
|
+
super().__init__(chain_instance, web3)
|
27
|
+
self.weth_contract = self.tokens['WETH']
|
28
|
+
self.pancake_pool = PancakePool(self.chain_contracts["PANCAKE_FACTORY"], self.web3)
|
29
|
+
self.maverick_router = MaverickMulticall(self.chain_contracts[self.swap_contract], self.web3)
|
30
|
+
|
31
|
+
def swap_native_for_token(self, account, amount_to_swap, slippage, to_token_address):
|
32
|
+
erc20_token = Erc20Token(self.chain_instance['chain'], to_token_address, self.web3)
|
33
|
+
pair_name = f"{self.chain_instance['gas_token']}>{erc20_token.symbol()}"
|
34
|
+
maverick_pool_address = pool_addresses[self.chain_instance['chain']][pair_name]
|
35
|
+
|
36
|
+
pool = self.pancake_pool.get_pool(self.weth_contract, to_token_address)
|
37
|
+
|
38
|
+
if pool == self.tokens['ZERO_ADDRESS']:
|
39
|
+
raise Exception(f"[{account.address}] Swap path {self.weth_contract} to {to_token_address} not found!")
|
40
|
+
|
41
|
+
amount_out = int(self.get_amount_out_min(amount_to_swap, self.weth_contract, to_token_address) * slippage)
|
42
|
+
|
43
|
+
args = [account, amount_to_swap, amount_out, self.weth_contract, maverick_pool_address, to_token_address]
|
44
|
+
|
45
|
+
return args, self.maverick_router.multicall
|
46
|
+
|
47
|
+
def swap_token_for_native(self, account, amount_to_swap, from_token_address, slippage):
|
48
|
+
pair_name = f'{self.chain_instance["gas_token"]}>{amount_to_swap.token}'
|
49
|
+
maverick_pool_address = pool_addresses[self.chain_instance['chain']][pair_name]
|
50
|
+
|
51
|
+
pool = self.pancake_pool.get_pool(from_token_address, self.weth_contract)
|
52
|
+
|
53
|
+
if pool == self.tokens['ZERO_ADDRESS']:
|
54
|
+
raise Exception(f"[{account.address}] Swap path {from_token_address} to {self.weth_contract} not found!")
|
55
|
+
|
56
|
+
amount_out = int(self.get_amount_out_min(amount_to_swap, from_token_address, self.weth_contract) * slippage)
|
57
|
+
|
58
|
+
args = [account, amount_to_swap, amount_out, from_token_address, maverick_pool_address, self.weth_contract]
|
59
|
+
|
60
|
+
return args, self.maverick_router.multicall
|
61
|
+
|
62
|
+
def get_amount_out_min(self, amount_to_swap, token_in_address, token_out_address):
|
63
|
+
pancake_quoter_contract = self.chain_contracts["PANCAKE_QUOTER"]
|
64
|
+
pancake_quoter = PancakeQuoter(pancake_quoter_contract, self.web3)
|
65
|
+
|
66
|
+
return pancake_quoter.quote_exact_input_single(token_in_address, token_out_address, amount_to_swap.wei)
|
@@ -0,0 +1,39 @@
|
|
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)
|
@@ -0,0 +1,58 @@
|
|
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', 'ARBITRUM']
|
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)
|