web3-wizzard-lib 1.8.0__py3-none-any.whl → 1.9.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/compound_v3.py +13 -0
- web3_wizzard_lib/core/modules/bank/bank.py +3 -0
- web3_wizzard_lib/core/modules/bank/cog_bank.py +3 -6
- web3_wizzard_lib/core/modules/bank/compound_v3.py +14 -1
- web3_wizzard_lib/core/modules/bank_module.py +8 -2
- {web3_wizzard_lib-1.8.0.dist-info → web3_wizzard_lib-1.9.0.dist-info}/METADATA +1 -1
- {web3_wizzard_lib-1.8.0.dist-info → web3_wizzard_lib-1.9.0.dist-info}/RECORD +9 -9
- {web3_wizzard_lib-1.8.0.dist-info → web3_wizzard_lib-1.9.0.dist-info}/WHEEL +0 -0
- {web3_wizzard_lib-1.8.0.dist-info → web3_wizzard_lib-1.9.0.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,5 @@
|
|
1
1
|
from sybil_engine.contract.contract import Contract
|
2
|
+
from sybil_engine.contract.transaction_executor import evm_transaction
|
2
3
|
from sybil_engine.utils.file_loader import load_abi
|
3
4
|
|
4
5
|
abi = load_abi("resources/abi/compound_v3.json")
|
@@ -8,6 +9,18 @@ class CompoundV3Contract(Contract):
|
|
8
9
|
def __init__(self, contract_address, web3):
|
9
10
|
super().__init__(contract_address, web3, abi)
|
10
11
|
|
12
|
+
def borrow_balance_of(self, account):
|
13
|
+
return self.contract.functions.borrowBalanceOf(account.address).call()
|
14
|
+
|
15
|
+
@evm_transaction
|
16
|
+
def supply(self, account, amount, token_address):
|
17
|
+
txn_params = self.build_generic_data(account.address, set_contract_address=False)
|
18
|
+
|
19
|
+
return self.contract.functions.supply(
|
20
|
+
token_address,
|
21
|
+
amount
|
22
|
+
).build_transaction(txn_params)
|
23
|
+
|
11
24
|
def user_collateral(self, account, token_address):
|
12
25
|
return self.contract.functions.userCollateral(
|
13
26
|
account.address,
|
@@ -1,5 +1,4 @@
|
|
1
1
|
from sybil_engine.data.contracts import get_contracts_for_chain
|
2
|
-
from sybil_engine.data.networks import get_ids_chain
|
3
2
|
from sybil_engine.utils.utils import ConfigurationException
|
4
3
|
|
5
4
|
from web3_wizzard_lib.core.contract.cog_erc20 import CogErc20Contract
|
@@ -11,8 +10,8 @@ class Cog(Bank):
|
|
11
10
|
supported_chains = ['SCROLL']
|
12
11
|
|
13
12
|
def __init__(self, chain, web3):
|
14
|
-
contract_address = get_contracts_for_chain(chain)[self.app_name]
|
15
|
-
self.contract = CogErc20Contract(contract_address, web3)
|
13
|
+
self.contract_address = get_contracts_for_chain(chain)[self.app_name]
|
14
|
+
self.contract = CogErc20Contract(self.contract_address, web3)
|
16
15
|
|
17
16
|
def supply(self, account, amount):
|
18
17
|
raise ConfigurationException("Only redeem supported for Compound V3")
|
@@ -21,6 +20,4 @@ class Cog(Bank):
|
|
21
20
|
self.contract.redeem(account, amount)
|
22
21
|
|
23
22
|
def get_deposit_amount(self, account, token):
|
24
|
-
|
25
|
-
|
26
|
-
return CogErc20Contract(cog_usdc_token, self.contract.web3).balance_of(account)
|
23
|
+
return self.contract.balance_of(account)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from sybil_engine.data.contracts import get_contracts_for_chain
|
2
2
|
from sybil_engine.data.networks import get_ids_chain
|
3
3
|
from sybil_engine.data.tokens import get_tokens_for_chain
|
4
|
+
from sybil_engine.domain.balance.tokens import Erc20Token
|
4
5
|
from sybil_engine.utils.utils import ConfigurationException
|
5
6
|
|
6
7
|
from web3_wizzard_lib.core.contract.compound_v3 import CompoundV3Contract
|
@@ -21,8 +22,20 @@ class CompoundV3(Bank):
|
|
21
22
|
def supply(self, account, amount):
|
22
23
|
raise ConfigurationException("Only redeem supported for Compound V3")
|
23
24
|
|
25
|
+
def get_repay_borrow_amount(self, account):
|
26
|
+
return self.contract.borrow_balance_of(account)
|
27
|
+
|
28
|
+
def repay_borrow(self, account, amount):
|
29
|
+
erc20_token = Erc20Token(self.contract.chain_instance['chain'], "USDC", self.contract.web3)
|
30
|
+
|
31
|
+
if erc20_token.allowance(account, self.contract.contract_address) < 100:
|
32
|
+
erc20_token.approve(account, self.contract.contract_address)
|
33
|
+
|
34
|
+
return self.contract.supply(account, amount, erc20_token.erc20_contract.contract_address)
|
35
|
+
|
24
36
|
def redeem(self, account, amount, token):
|
25
|
-
|
37
|
+
actions = '0x414354494f4e5f57495448445241575f41535345540000000000000000000000'
|
38
|
+
self.contract_bulker.invoke(account, amount, actions)
|
26
39
|
|
27
40
|
def get_deposit_amount(self, account, token):
|
28
41
|
token_address = get_tokens_for_chain(get_ids_chain()[self.contract.web3.eth.chain_id])[token]
|
@@ -49,7 +49,13 @@ class Banking(Module):
|
|
49
49
|
elif action == 'BORROW':
|
50
50
|
bank_app.borrow(account, amount)
|
51
51
|
elif action == 'REPAY':
|
52
|
-
bank_app.
|
52
|
+
amount = bank_app.get_repay_borrow_amount(account)
|
53
|
+
|
54
|
+
if amount > 0:
|
55
|
+
logger.info(f"Repay {amount} {token} in {bank_app.app_name}")
|
56
|
+
bank_app.repay_borrow(account, amount)
|
57
|
+
else:
|
58
|
+
logger.info(f"{token} borrow balance is 0")
|
53
59
|
elif action == 'REDEEM':
|
54
60
|
amount = bank_app.get_deposit_amount(account, token)
|
55
61
|
|
@@ -57,7 +63,7 @@ class Banking(Module):
|
|
57
63
|
logger.info(f"Redeem {amount} of {token} from {bank_app.app_name}")
|
58
64
|
bank_app.redeem(account, amount, token)
|
59
65
|
else:
|
60
|
-
logger.info(f"{
|
66
|
+
logger.info(f"{token} balance is 0")
|
61
67
|
else:
|
62
68
|
raise ConfigurationException("Unsupported action")
|
63
69
|
|
@@ -10,7 +10,7 @@ web3_wizzard_lib/core/contract/basiliskcontract.py,sha256=-r8nvZnLu9C5Y-CF_2NLyd
|
|
10
10
|
web3_wizzard_lib/core/contract/bilinear_contract.py,sha256=pCTkNQa4I1TqIAn_J6WgBWi8KF-iaBqJfSDI72CH2bw,729
|
11
11
|
web3_wizzard_lib/core/contract/bungee.py,sha256=vkuZmLhtdqvGOTkVe7MnIHsDGHUtm8zdqD-YYxVfkQ8,891
|
12
12
|
web3_wizzard_lib/core/contract/cog_erc20.py,sha256=wkfKC7bqBHpgZGL5xZ4737pMaD5m8oEw0huw36ssX1M,1674
|
13
|
-
web3_wizzard_lib/core/contract/compound_v3.py,sha256=
|
13
|
+
web3_wizzard_lib/core/contract/compound_v3.py,sha256=ehsO6o53Av5s1dUknxj_6X4FBP4eNtZ_ZVMtvBzfTus,973
|
14
14
|
web3_wizzard_lib/core/contract/compund_v3_bulker.py,sha256=HLfBLIgJ3zCDW64XGyq18uVCcVACMQenB6BAl2cR020,1408
|
15
15
|
web3_wizzard_lib/core/contract/coredao_contract.py,sha256=-M7gBYtVCxHLtoPfhNOwUaC9gHWuZMbd_xAbt7N66Tc,1035
|
16
16
|
web3_wizzard_lib/core/contract/coredao_from_contract.py,sha256=cvQlLGjuri-1lhNKtnKJ79MDFcp_wXRFWlJRORt4ZEA,1221
|
@@ -92,7 +92,7 @@ web3_wizzard_lib/core/contract/zks.py,sha256=QN9dKfWfA4cFKxzA8qcMnNBcdKmBmZMPeNq
|
|
92
92
|
web3_wizzard_lib/core/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
93
93
|
web3_wizzard_lib/core/modules/ads_import_proxy.py,sha256=6i_ZJ400Wg1_CLVqnhVHgRoJsjEYyOpMDUDNwtd2wIQ,1809
|
94
94
|
web3_wizzard_lib/core/modules/airdrop_printer.py,sha256=k1w1m8WAS9MnQ7LkKaYlx5xgi10pf12lcGJ0SrVA1OE,2862
|
95
|
-
web3_wizzard_lib/core/modules/bank_module.py,sha256=
|
95
|
+
web3_wizzard_lib/core/modules/bank_module.py,sha256=UFwHoN1ncsWywzoxTiBnFDi9_mmjwPGST2VtD02L6dk,4229
|
96
96
|
web3_wizzard_lib/core/modules/bridge_module.py,sha256=ZoO80ody9cP_ezhah680ezTAEdM2VyxRqmmUH7b2xHE,2011
|
97
97
|
web3_wizzard_lib/core/modules/bungee.py,sha256=CVjZH5_nmBWO5Vg5Xx-_dDzfaJ7oCDgFp0gG8VHd76E,4881
|
98
98
|
web3_wizzard_lib/core/modules/cex_sender.py,sha256=2akfVhaMvHnuKUBfiCTqnVuP3VWrJIStArBqQKpiU2I,2723
|
@@ -127,10 +127,10 @@ web3_wizzard_lib/core/modules/wrapping.py,sha256=mlk5id2_rpsIJ-j90LdjfyS1Qc407v5
|
|
127
127
|
web3_wizzard_lib/core/modules/zkdx.py,sha256=ao3JHla_iRv0r9cmUj0QVq8yw9q2kiqWIv5COt6z5Iw,2310
|
128
128
|
web3_wizzard_lib/core/modules/bank/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
129
129
|
web3_wizzard_lib/core/modules/bank/aave.py,sha256=q8dR64TviR5o8NzJJXIgbWkLqPxin93WrSTHb2TPIyU,874
|
130
|
-
web3_wizzard_lib/core/modules/bank/bank.py,sha256=
|
130
|
+
web3_wizzard_lib/core/modules/bank/bank.py,sha256=LNz1C720_dG2gih2w4nG5dtRL-q43_yep5mv1Okc2qw,362
|
131
131
|
web3_wizzard_lib/core/modules/bank/basilisk.py,sha256=IsfylmROKyqssosF-ouCA_vkm5kVIRIM3L9Uam461gM,909
|
132
|
-
web3_wizzard_lib/core/modules/bank/cog_bank.py,sha256=
|
133
|
-
web3_wizzard_lib/core/modules/bank/compound_v3.py,sha256=
|
132
|
+
web3_wizzard_lib/core/modules/bank/cog_bank.py,sha256=v12iY78EESqJmZX3dJghU9HulkrK9G6T2H7tDOm3q0o,828
|
133
|
+
web3_wizzard_lib/core/modules/bank/compound_v3.py,sha256=lpxAQztFfM_WdB4WRfIh5Nno3h3VO2UIFs66AtSgvbQ,2205
|
134
134
|
web3_wizzard_lib/core/modules/bank/eralend.py,sha256=2aVH4KMYCBwTYSslaULF0t_pQQwq9YBNOVV1_ailXS4,887
|
135
135
|
web3_wizzard_lib/core/modules/bank/layerbank.py,sha256=btJr2GA8MY7R9jLoppTLddbtgHATKIck6sbhCeKUl_I,4547
|
136
136
|
web3_wizzard_lib/core/modules/bank/mendi_finance.py,sha256=GAaTMop6tyxBe3HvsFxChNM4mNFk9vLzec5BpN0RcK0,1958
|
@@ -371,7 +371,7 @@ web3_wizzard_lib/resources/main/pairs.json,sha256=uvIFvY46Ctiw8hjGd9e-1WE0qLf_du
|
|
371
371
|
web3_wizzard_lib/resources/main/tokens.json,sha256=AoZz_I6AVoZuecNdyX5L-SnGm6TREuPrsYd2i9PJr7U,5707
|
372
372
|
web3_wizzard_lib/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
373
373
|
web3_wizzard_lib/utils/debank_utils.py,sha256=CE2SUN9RpFK_j9KjJgxf7a__VRJ75tLIw9tLrVNrn3c,484
|
374
|
-
web3_wizzard_lib-1.
|
375
|
-
web3_wizzard_lib-1.
|
376
|
-
web3_wizzard_lib-1.
|
377
|
-
web3_wizzard_lib-1.
|
374
|
+
web3_wizzard_lib-1.9.0.dist-info/METADATA,sha256=AQS4lL433HwPWy-qUMv8u34Z3u3pELEsUU2Vs_l-24Q,339
|
375
|
+
web3_wizzard_lib-1.9.0.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
376
|
+
web3_wizzard_lib-1.9.0.dist-info/top_level.txt,sha256=31sEPHxuJ1p5fpc75vHQJ8eJdSs80aCZeeT3L8YAHNg,17
|
377
|
+
web3_wizzard_lib-1.9.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|