web3-wizzard-lib 1.0.5__py3-none-any.whl → 1.2.0__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/contract/gmx_reward_router.py +22 -0
- web3_wizzard_lib/core/contract/new_rage_contract.py +31 -0
- web3_wizzard_lib/core/modules/concrete_swap.py +13 -2
- web3_wizzard_lib/core/modules/gmx_reward.py +27 -0
- web3_wizzard_lib/core/modules/new_rage_withdraw.py +42 -0
- web3_wizzard_lib/core/modules/swap/odos.py +1 -1
- web3_wizzard_lib/core/modules/swap/woofi.py +1 -1
- web3_wizzard_lib/resources/abi/gmx_reward_router.json +749 -0
- web3_wizzard_lib/resources/abi/new_rage_abi.json +1944 -0
- web3_wizzard_lib/resources/main/contracts.json +4 -2
- {web3_wizzard_lib-1.0.5.dist-info → web3_wizzard_lib-1.2.0.dist-info}/METADATA +1 -1
- {web3_wizzard_lib-1.0.5.dist-info → web3_wizzard_lib-1.2.0.dist-info}/RECORD +15 -9
- {web3_wizzard_lib-1.0.5.data → web3_wizzard_lib-1.2.0.data}/data/requirements.txt +0 -0
- {web3_wizzard_lib-1.0.5.dist-info → web3_wizzard_lib-1.2.0.dist-info}/WHEEL +0 -0
- {web3_wizzard_lib-1.0.5.dist-info → web3_wizzard_lib-1.2.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
from sybil_engine.contract.contract import Contract
|
2
|
+
from sybil_engine.contract.transaction_executor import evm_transaction
|
3
|
+
from sybil_engine.utils.file_loader import load_abi
|
4
|
+
|
5
|
+
abi = load_abi("resources/abi/gmx_reward_router.json")
|
6
|
+
|
7
|
+
|
8
|
+
class GmxRewardRouter(Contract):
|
9
|
+
def __init__(self, contract_address, web3):
|
10
|
+
super().__init__(contract_address, web3, abi)
|
11
|
+
|
12
|
+
@evm_transaction
|
13
|
+
def unstake_and_redeem(self, account, shares):
|
14
|
+
txn_params = self.build_generic_data(account.address, False)
|
15
|
+
|
16
|
+
contract_txn = self.contract.functions.redeem(
|
17
|
+
shares,
|
18
|
+
0,
|
19
|
+
account.address,
|
20
|
+
).build_transaction(txn_params)
|
21
|
+
|
22
|
+
return contract_txn
|
@@ -0,0 +1,31 @@
|
|
1
|
+
from sybil_engine.contract.contract import Contract
|
2
|
+
from sybil_engine.contract.transaction_executor import evm_transaction
|
3
|
+
from sybil_engine.utils.file_loader import load_abi
|
4
|
+
|
5
|
+
abi = load_abi("resources/abi/new_rage_abi.json")
|
6
|
+
|
7
|
+
|
8
|
+
class NewRageContract(Contract):
|
9
|
+
def __init__(self, contract_address, web3):
|
10
|
+
super().__init__(contract_address, web3, abi)
|
11
|
+
|
12
|
+
@evm_transaction
|
13
|
+
def redeem(self, account, shares):
|
14
|
+
txn_params = self.build_generic_data(account.address, False)
|
15
|
+
|
16
|
+
contract_txn = self.contract.functions.redeem(
|
17
|
+
shares,
|
18
|
+
account.address,
|
19
|
+
account.address,
|
20
|
+
).build_transaction(txn_params)
|
21
|
+
|
22
|
+
return contract_txn
|
23
|
+
|
24
|
+
def balance_of(self, account):
|
25
|
+
return self.contract.functions.balanceOf(account.address).call()
|
26
|
+
|
27
|
+
def convert_to_shares(self, amount):
|
28
|
+
return self.contract.functions.convertToShares(amount).call()
|
29
|
+
|
30
|
+
def max_redeem(self, account):
|
31
|
+
return self.contract.functions.maxRedeem(account.address).call()
|
@@ -8,6 +8,7 @@ from sybil_engine.module.module import Module
|
|
8
8
|
from sybil_engine.utils.utils import SwapException
|
9
9
|
from sybil_engine.utils.validation_utils import validate_amount_interval, validate_token
|
10
10
|
from sybil_engine.utils.web3_utils import init_web3
|
11
|
+
from web3 import Web3
|
11
12
|
|
12
13
|
from web3_wizzard_lib.core.modules.swap.swap_list import swap_facade
|
13
14
|
|
@@ -31,10 +32,20 @@ class ConcreteSwap(Module):
|
|
31
32
|
from_token_contract = Erc20Token(chain, from_token, web3)
|
32
33
|
to_token_contract = Erc20Token(chain, to_token, web3)
|
33
34
|
|
35
|
+
if Web3.is_address(from_token):
|
36
|
+
from_token_symbol = from_token_contract.symbol()
|
37
|
+
else:
|
38
|
+
from_token_symbol = from_token
|
39
|
+
|
40
|
+
if Web3.is_address(to_token):
|
41
|
+
to_token_symbol = to_token_contract.symbol()
|
42
|
+
else:
|
43
|
+
to_token_symbol = to_token
|
44
|
+
|
34
45
|
pair_to_swap = self.create_pair_to_swap(
|
35
|
-
|
46
|
+
from_token_symbol,
|
36
47
|
swap_app,
|
37
|
-
|
48
|
+
to_token_symbol,
|
38
49
|
)
|
39
50
|
|
40
51
|
amount_to_swap = amount_to_swap_from_interval(
|
@@ -0,0 +1,27 @@
|
|
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.module.module import Module
|
5
|
+
from sybil_engine.utils.accumulator import add_accumulator
|
6
|
+
from sybil_engine.utils.utils import ConfigurationException
|
7
|
+
from sybil_engine.utils.web3_utils import init_web3
|
8
|
+
|
9
|
+
from web3_wizzard_lib.core.contract.gmx_reward_router import GmxRewardRouter
|
10
|
+
from web3_wizzard_lib.core.contract.new_rage_contract import NewRageContract
|
11
|
+
|
12
|
+
|
13
|
+
class GMXRewardRouter(Module):
|
14
|
+
module_name = 'GMX_REWARD_ROUTER'
|
15
|
+
module_config = None
|
16
|
+
|
17
|
+
def execute(self, account, chain='ARBITRUM'):
|
18
|
+
chain_instance = get_chain_instance(chain)
|
19
|
+
web3 = init_web3(chain_instance, None)
|
20
|
+
|
21
|
+
contract_address = get_contracts_for_chain(chain_instance['chain'])['GMX_REWARD_ROUTER']
|
22
|
+
gmx_reward_router = GmxRewardRouter(contract_address, web3)
|
23
|
+
|
24
|
+
gmx_reward_router.unstake_and_redeem(account)
|
25
|
+
|
26
|
+
def log(self):
|
27
|
+
return "GMX REWARD WITHDRAW"
|
@@ -0,0 +1,42 @@
|
|
1
|
+
from loguru import logger
|
2
|
+
from sybil_engine.data.networks import get_chain_instance
|
3
|
+
from sybil_engine.module.module import Module
|
4
|
+
from sybil_engine.utils.accumulator import add_accumulator_balance, add_accumulator
|
5
|
+
from sybil_engine.utils.utils import ConfigurationException
|
6
|
+
from sybil_engine.utils.web3_utils import init_web3
|
7
|
+
|
8
|
+
from web3_wizzard_lib.core.contract.new_rage_contract import NewRageContract
|
9
|
+
|
10
|
+
|
11
|
+
class NewRageModule(Module):
|
12
|
+
module_name = 'NEW_RAGE_WITHDRAW'
|
13
|
+
module_config = 'new_rage_config'
|
14
|
+
|
15
|
+
def execute(self, token, account, chain='ARBITRUM'):
|
16
|
+
chain_instance = get_chain_instance(chain)
|
17
|
+
web3 = init_web3(chain_instance, None)
|
18
|
+
|
19
|
+
if token == 'USDC':
|
20
|
+
contract_address = "0xf9305009FbA7E381b3337b5fA157936d73c2CF36"
|
21
|
+
elif token == 'GLP':
|
22
|
+
contract_address = "0x8478AB5064EbAC770DdCE77E7D31D969205F041E"
|
23
|
+
else:
|
24
|
+
raise ConfigurationException("No such token supported by Rage withdraw module")
|
25
|
+
rage = NewRageContract(contract_address, web3)
|
26
|
+
|
27
|
+
#balance = rage.balance_of(account)
|
28
|
+
shares = rage.max_redeem(account)
|
29
|
+
|
30
|
+
if shares > 0:
|
31
|
+
logger.info(f"Withdraw {shares} shares {token}")
|
32
|
+
rage.redeem(account, shares)
|
33
|
+
else:
|
34
|
+
logger.info(f"Account {account.address} has 0 balance in Rage")
|
35
|
+
|
36
|
+
#add_accumulator("Total rage withdraw", balance)
|
37
|
+
|
38
|
+
def log(self):
|
39
|
+
return "RAGE WITHDRAW"
|
40
|
+
|
41
|
+
def parse_params(self, module_params):
|
42
|
+
return module_params['token'],
|
@@ -9,7 +9,7 @@ from web3_wizzard_lib.core.contract.odos import Odos
|
|
9
9
|
class OdosSwap(Dex):
|
10
10
|
dex_name = 'odos'
|
11
11
|
swap_contract = 'ODOS'
|
12
|
-
supported_chains = ['ZKSYNC', 'BASE', 'LINEA']
|
12
|
+
supported_chains = ['ZKSYNC', 'BASE', 'LINEA', 'ARBITRUM']
|
13
13
|
|
14
14
|
def __init__(self, chain_instance, web3):
|
15
15
|
super().__init__(chain_instance, web3)
|
@@ -9,7 +9,7 @@ from web3_wizzard_lib.core.contract.woofi_swap import WoofiSwap
|
|
9
9
|
class Woofi(Dex):
|
10
10
|
dex_name = 'woofi'
|
11
11
|
swap_contract = 'WOOFI'
|
12
|
-
supported_chains = ['ZKSYNC', 'BASE', 'LINEA']
|
12
|
+
supported_chains = ['ZKSYNC', 'BASE', 'LINEA', 'ARBITRUM']
|
13
13
|
|
14
14
|
def __init__(self, chain_instance, web3):
|
15
15
|
super().__init__(chain_instance, web3)
|