defi-state-querier 0.4.1__py3-none-any.whl → 0.4.3__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- defi_services/__init__.py +1 -1
- defi_services/constants/chain_constant.py +4 -1
- defi_services/constants/entities/vault_constant.py +5 -0
- defi_services/constants/entities/vault_services.py +24 -0
- defi_services/constants/query_constant.py +1 -0
- defi_services/jobs/processors/state_processor.py +4 -2
- defi_services/services/lending/aave_v2_services.py +1 -1
- defi_services/services/lending/aave_v3_services.py +1 -1
- defi_services/services/lending/apeswap_services.py +5 -2
- defi_services/services/lending/compound_service.py +7 -2
- defi_services/services/lending/compound_v3_services.py +1 -4
- defi_services/services/lending/flux_services.py +6 -5
- defi_services/services/lending/granary_services.py +1 -4
- defi_services/services/lending/iron_bank_service.py +17 -6
- defi_services/services/lending/justlend_service.py +21 -6
- defi_services/services/lending/lending_info/bsc/liqee_bsc.py +154 -106
- defi_services/services/lending/lending_info/ethereum/liqee_eth.py +160 -110
- defi_services/services/lending/liqee_service.py +7 -4
- defi_services/services/lending/morpho_aave_v2_services.py +1 -1
- defi_services/services/lending/morpho_aave_v3_services.py +1 -4
- defi_services/services/lending/morpho_compound_services.py +1 -5
- defi_services/services/lending/onyx_service.py +7 -5
- defi_services/services/lending/radiant_v2_services.py +1 -4
- defi_services/services/lending/silo_services.py +1 -1
- defi_services/services/lending/strike_service.py +7 -2
- defi_services/services/lending/trava_services.py +5 -5
- defi_services/services/lending/uwu_services.py +1 -1
- defi_services/services/lending/valas_services.py +1 -1
- defi_services/services/lending/venus_services.py +28 -16
- defi_services/services/lending/wepiggy_services.py +7 -2
- defi_services/services/protocol_services.py +34 -2
- defi_services/services/vault/__init__.py +0 -0
- defi_services/services/vault/trava_vault_services.py +196 -0
- defi_services/services/vault/vault_info/__init__.py +0 -0
- defi_services/services/vault/vault_info/bsc/__init__.py +0 -0
- defi_services/services/vault/vault_info/bsc/trava_bsc.py +41 -0
- defi_services/services/vault/vault_info/ethereum/__init__.py +0 -0
- defi_services/services/vault/vault_info/ethereum/trava_eth.py +22 -0
- defi_services/services/vault/vault_info/fantom/__init__.py +0 -0
- defi_services/services/vault/vault_info/fantom/trava_ftm.py +31 -0
- defi_services/utils/init_services.py +5 -0
- {defi_state_querier-0.4.1.dist-info → defi_state_querier-0.4.3.dist-info}/METADATA +1 -1
- {defi_state_querier-0.4.1.dist-info → defi_state_querier-0.4.3.dist-info}/RECORD +46 -37
- defi_services/jobs/queriers/cosmos_state_querier.py +0 -83
- defi_services/services/cosmos_token_services.py +0 -46
- {defi_state_querier-0.4.1.dist-info → defi_state_querier-0.4.3.dist-info}/LICENSE +0 -0
- {defi_state_querier-0.4.1.dist-info → defi_state_querier-0.4.3.dist-info}/WHEEL +0 -0
- {defi_state_querier-0.4.1.dist-info → defi_state_querier-0.4.3.dist-info}/top_level.txt +0 -0
@@ -1,113 +1,163 @@
|
|
1
1
|
LIQEE_ETH = {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
"
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
2
|
+
"comptrollerAddress": "",
|
3
|
+
"controllerAddress": "0x8b53ab2c0df3230ea327017c91eb909f815ad113",
|
4
|
+
"forked": "compound",
|
5
|
+
"lendingDataAddress": "0x4b30c26d61be2f76bc7d9f2c5edbacba84982358",
|
6
|
+
"lensAddress": "",
|
7
|
+
"name": "Liqee Lending Pool",
|
8
|
+
"poolToken": "0x431ad2ff6a9c365805ebad47ee021148d6f7dbe0",
|
9
|
+
"reservesList": {
|
10
|
+
"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599": {
|
11
|
+
"cToken": "0x5812fcf91adc502a765e5707ebb3f36a07f63c02",
|
12
|
+
"exchangeRate": 1.000012067974307,
|
13
|
+
"liquidationThreshold": 0.8,
|
14
|
+
"loanToValue": 0.8
|
15
|
+
},
|
16
|
+
"0x0000000000000000000000000000000000000000": {
|
17
|
+
"cToken": "0x5acd75f21659a59ffab9aebaf350351a8bfaabc0",
|
18
|
+
"exchangeRate": 1.0092559004684867,
|
19
|
+
"liquidationThreshold": 0.85,
|
20
|
+
"loanToValue": 0.85
|
21
|
+
},
|
22
|
+
"0xdac17f958d2ee523a2206206994597c13d831ec7": {
|
23
|
+
"cToken": "0x1180c114f7fadcb6957670432a3cf8ef08ab5354",
|
24
|
+
"exchangeRate": 1.0653006831932572,
|
25
|
+
"liquidationThreshold": 0.85,
|
26
|
+
"loanToValue": 0.85
|
27
|
+
},
|
28
|
+
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": {
|
29
|
+
"cToken": "0x2f956b2f801c6dad74e87e7f45c94f6283bf0f45",
|
30
|
+
"exchangeRate": 1.0618162566733447,
|
31
|
+
"liquidationThreshold": 0.85,
|
32
|
+
"loanToValue": 0.85
|
33
|
+
},
|
34
|
+
"0x6b175474e89094c44da98b954eedeac495271d0f": {
|
35
|
+
"cToken": "0x298f243ad592b6027d4717fbe9decda668e3c3a8",
|
36
|
+
"exchangeRate": 1.0671526314936417,
|
37
|
+
"liquidationThreshold": 0.85,
|
38
|
+
"loanToValue": 0.85
|
39
|
+
},
|
40
|
+
"0x4fabb145d64652a948d72533023f6e7a623c7c53": {
|
41
|
+
"cToken": "0x24677e213dec0ea53a430404cf4a11a6dc889fce",
|
42
|
+
"exchangeRate": 1.000000000000008,
|
43
|
+
"liquidationThreshold": 0.75,
|
44
|
+
"loanToValue": 0.75
|
45
|
+
},
|
46
|
+
"0x0316eb71485b0ab14103307bf65a021042c6d380": {
|
47
|
+
"cToken": "0x47566acd7af49d2a192132314826ed3c3c5f3698",
|
48
|
+
"exchangeRate": 1,
|
49
|
+
"liquidationThreshold": 0.8,
|
50
|
+
"loanToValue": 0.8
|
51
|
+
},
|
52
|
+
"0x431ad2ff6a9c365805ebad47ee021148d6f7dbe0": {
|
53
|
+
"cToken": "0xb3dc7425e63e1855eb41107134d471dd34d7b239",
|
54
|
+
"exchangeRate": 1.0001004296452365,
|
55
|
+
"liquidationThreshold": 0.6,
|
56
|
+
"loanToValue": 0.6
|
57
|
+
},
|
58
|
+
"0x355c665e101b9da58704a8fddb5feef210ef20c0": {
|
59
|
+
"cToken": "0x164315ea59169d46359baa4bcc6479bb421764b6",
|
60
|
+
"exchangeRate": 1,
|
61
|
+
"liquidationThreshold": 0.8,
|
62
|
+
"loanToValue": 0.8
|
63
|
+
},
|
64
|
+
"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984": {
|
65
|
+
"cToken": "0xbec9a824d6da8d0f923fd9fbec4faa949d396320",
|
66
|
+
"exchangeRate": 1,
|
67
|
+
"liquidationThreshold": 0.7,
|
68
|
+
"loanToValue": 0.7
|
69
|
+
},
|
70
|
+
"0x0a5e677a6a24b2f1a2bf4f3bffc443231d2fdec8": {
|
71
|
+
"cToken": "0xd1254d280e7504836e1b0e36535ebff248483cee",
|
72
|
+
"exchangeRate": 1,
|
73
|
+
"liquidationThreshold": 0.7,
|
74
|
+
"loanToValue": 0.7
|
75
|
+
},
|
76
|
+
"0xb986f3a2d91d3704dc974a24fb735dcc5e3c1e70": {
|
77
|
+
"cToken": "0x591595bfae3f5d51a820ecd20a1e3fbb6638f34b",
|
78
|
+
"exchangeRate": 1,
|
79
|
+
"liquidationThreshold": 0.7,
|
80
|
+
"loanToValue": 0.7
|
81
|
+
},
|
82
|
+
"0x527ec46ac094b399265d1d71eff7b31700aa655d": {
|
83
|
+
"cToken": "0xfa2e831c674b61475c175b2206e81a5938b298dd",
|
84
|
+
"exchangeRate": 1,
|
85
|
+
"liquidationThreshold": 0.7,
|
86
|
+
"loanToValue": 0.7
|
87
|
+
},
|
88
|
+
"0x8d2cb35893c01fa8b564c84bd540c5109d9d278e": {
|
89
|
+
"cToken": "0x028db7a9d133301bd49f27b5e41f83f56ab0faa6",
|
90
|
+
"exchangeRate": 1,
|
91
|
+
"liquidationThreshold": 0.7,
|
92
|
+
"loanToValue": 0.7
|
93
|
+
},
|
94
|
+
"0x514910771af9ca656af840dff83e8264ecf986ca": {
|
95
|
+
"cToken": "0xa3068aa78611ed29d381e640bb2c02abcf3ca7de",
|
96
|
+
"exchangeRate": 1,
|
97
|
+
"liquidationThreshold": 0.7,
|
98
|
+
"loanToValue": 0.7
|
99
|
+
},
|
100
|
+
"0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2": {
|
101
|
+
"cToken": "0x039e7ef6a674f3ec1d88829b8215ed45385c24bc",
|
102
|
+
"exchangeRate": 1,
|
103
|
+
"liquidationThreshold": 0.7,
|
104
|
+
"loanToValue": 0.7
|
105
|
+
},
|
106
|
+
"0x0000000000085d4780b73119b644ae5ecd22b376": {
|
107
|
+
"cToken": "0x6e6a689a5964083dff9fd7a0f788baf620ea2dbe",
|
108
|
+
"exchangeRate": 1,
|
109
|
+
"liquidationThreshold": 0,
|
110
|
+
"loanToValue": 0
|
111
|
+
},
|
112
|
+
"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0": {
|
113
|
+
"cToken": "0xbfd291da8a403daaf7e5e9dc1ec0aceacd4848b9",
|
114
|
+
"exchangeRate": 1,
|
115
|
+
"liquidationThreshold": 0.825,
|
116
|
+
"loanToValue": 0.825
|
117
|
+
},
|
118
|
+
"0x853d955acef822db058eb8505911ed77f175b99e": {
|
119
|
+
"cToken": "0x71173e3c6999c2c72ccf363f4ae7b67bcc7e8f63",
|
120
|
+
"exchangeRate": 1.000056097645922,
|
121
|
+
"liquidationThreshold": 0,
|
122
|
+
"loanToValue": 0
|
123
|
+
},
|
124
|
+
"0x956f47f50a910163d8bf957cf5846d573e7f87ca": {
|
125
|
+
"cToken": "0x47c19a2ab52da26551a22e2b2aeed5d19ef4022f",
|
126
|
+
"exchangeRate": 1,
|
127
|
+
"liquidationThreshold": 0,
|
128
|
+
"loanToValue": 0
|
129
|
+
},
|
130
|
+
"0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9": {
|
131
|
+
"cToken": "0x3e5cb932d7a1c0ca096b71cc486b2ad7e0dc3d0e",
|
132
|
+
"exchangeRate": 1,
|
133
|
+
"liquidationThreshold": 0.7,
|
134
|
+
"loanToValue": 0.7
|
135
|
+
},
|
136
|
+
"0xd533a949740bb3306d119cc777fa900ba034cd52": {
|
137
|
+
"cToken": "0xe39672dfa87c824bcb3b38aa480ef684687cbc09",
|
138
|
+
"exchangeRate": 1,
|
139
|
+
"liquidationThreshold": 0.65,
|
140
|
+
"loanToValue": 0.65
|
141
|
+
},
|
142
|
+
"0xd5147bc8e386d91cc5dbe72099dac6c9b99276f5": {
|
143
|
+
"cToken": "0x59055220e00da46c891283ea1d79363c769158b9",
|
144
|
+
"exchangeRate": 1,
|
145
|
+
"liquidationThreshold": 0,
|
146
|
+
"loanToValue": 0
|
147
|
+
},
|
148
|
+
"0x83f20f44975d03b1b09e64809b757c47f942beea": {
|
149
|
+
"cToken": "0x5f02fb5f1203a502c701a12fd409548993f795ba",
|
150
|
+
"exchangeRate": 1,
|
151
|
+
"liquidationThreshold": 0.85,
|
152
|
+
"loanToValue": 0.85
|
153
|
+
},
|
154
|
+
"0xae78736cd615f374d3085123a210448e74fc6393": {
|
155
|
+
"cToken": "0x33b5edc15e05d3dac27fccad77cf550c5f3f02aa",
|
156
|
+
"exchangeRate": 1,
|
157
|
+
"liquidationThreshold": 0.7,
|
158
|
+
"loanToValue": 0.7
|
112
159
|
}
|
160
|
+
},
|
161
|
+
"rewardToken": "0x431ad2ff6a9c365805ebad47ee021148d6f7dbe0",
|
162
|
+
"type": "LENDING_POOL"
|
113
163
|
}
|
@@ -60,14 +60,17 @@ class LiqeeStateService(CompoundStateService):
|
|
60
60
|
reserves_info = {}
|
61
61
|
for token in ctokens:
|
62
62
|
address = _w3.toChecksumAddress(token)
|
63
|
-
contract = _w3.eth.contract(
|
64
|
-
address=address, abi=self.lquee_token_abi)
|
63
|
+
contract = _w3.eth.contract(address=address, abi=self.lquee_token_abi)
|
65
64
|
underlying = contract.functions.underlying().call(block_identifier=block_number)
|
66
65
|
liquidation_threshold = comptroller_contract.functions.markets(address).call(block_identifier=block_number)
|
67
|
-
liquidation_threshold = liquidation_threshold[0] / 10**18
|
66
|
+
liquidation_threshold = liquidation_threshold[0] / 10 ** 18
|
67
|
+
|
68
|
+
exchange_rate = contract.functions.exchangeRateStored().call(block_identifier=block_number)
|
69
|
+
exchange_rate = exchange_rate / 10 ** 18
|
68
70
|
|
69
71
|
reserves_info[underlying.lower()] = {
|
70
72
|
"cToken": token.lower(),
|
73
|
+
"exchangeRate": exchange_rate,
|
71
74
|
"liquidationThreshold": liquidation_threshold,
|
72
75
|
"loanToValue": liquidation_threshold
|
73
76
|
}
|
@@ -184,7 +187,7 @@ class LiqeeStateService(CompoundStateService):
|
|
184
187
|
get_reward_id = f"getAccountRewardAmount_{self.name}_{wallet}_{block_number}".lower()
|
185
188
|
return {get_reward_id: rpc_call}
|
186
189
|
|
187
|
-
def calculate_rewards_balance(self,
|
190
|
+
def calculate_rewards_balance(self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
|
188
191
|
get_reward_id = f"getAccountRewardAmount_{self.name}_{wallet}_{block_number}".lower()
|
189
192
|
rewards = decoded_data.get(get_reward_id) / 10 ** 18
|
190
193
|
reward_token = self.pool_info.get("rewardToken")
|
@@ -180,7 +180,7 @@ class MorphoAaveV2StateService(MorphoCompoundStateService):
|
|
180
180
|
):
|
181
181
|
return {}
|
182
182
|
|
183
|
-
def calculate_rewards_balance(self,
|
183
|
+
def calculate_rewards_balance(self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
|
184
184
|
return {}
|
185
185
|
|
186
186
|
def get_function_lending_pool_info(self, fn_name: str, fn_paras=None, block_number: int = 'latest'):
|
@@ -111,10 +111,7 @@ class MorphoAaveV3StateService(MorphoCompoundStateService):
|
|
111
111
|
return {}
|
112
112
|
|
113
113
|
def calculate_rewards_balance(
|
114
|
-
self,
|
115
|
-
decoded_data: dict,
|
116
|
-
wallet: str,
|
117
|
-
block_number: int = "latest"):
|
114
|
+
self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
|
118
115
|
return {}
|
119
116
|
|
120
117
|
# WALLET DEPOSIT BORROW BALANCE
|
@@ -204,11 +204,7 @@ class MorphoCompoundStateService(ProtocolServices):
|
|
204
204
|
return {get_reward_id: rpc_call}
|
205
205
|
|
206
206
|
def calculate_rewards_balance(
|
207
|
-
self,
|
208
|
-
decoded_data: dict,
|
209
|
-
wallet: str,
|
210
|
-
block_number: int = "latest"
|
211
|
-
):
|
207
|
+
self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
|
212
208
|
get_reward_id = f"getUserUnclaimedRewards_{self.name}_{wallet}_{block_number}".lower()
|
213
209
|
rewards = decoded_data.get(get_reward_id) / 10 ** 18
|
214
210
|
reward_token = self.pool_info.get("rewardToken")
|
@@ -8,7 +8,7 @@ from defi_services.abis.lending.onyx.onyx_token_abi import ONYX_TOKEN_ABI
|
|
8
8
|
from defi_services.abis.token.erc20_abi import ERC20_ABI
|
9
9
|
from defi_services.constants.chain_constant import Chain, BlockTime
|
10
10
|
from defi_services.constants.entities.lending_constant import Lending
|
11
|
-
from defi_services.constants.token_constant import
|
11
|
+
from defi_services.constants.token_constant import Token
|
12
12
|
from defi_services.jobs.queriers.state_querier import StateQuerier
|
13
13
|
from defi_services.services.lending.compound_service import CompoundStateService
|
14
14
|
from defi_services.services.lending.lending_info.ethereum.onyx_eth import ONYX_ETH
|
@@ -68,8 +68,13 @@ class OnyxStateService(CompoundStateService):
|
|
68
68
|
ctoken = data[0].lower()
|
69
69
|
lt = data[10] / 10 ** 18
|
70
70
|
ltv = data[10] / 10 ** 18
|
71
|
+
|
72
|
+
underlying_decimal = int(data[13])
|
73
|
+
exchange_rate = data[1] / 10 ** (18 - 8 + underlying_decimal)
|
74
|
+
|
71
75
|
reserves_info[underlying] = {
|
72
76
|
"cToken": ctoken,
|
77
|
+
"exchangeRate": exchange_rate,
|
73
78
|
"liquidationThreshold": lt,
|
74
79
|
"loanToValue": ltv
|
75
80
|
}
|
@@ -156,10 +161,7 @@ class OnyxStateService(CompoundStateService):
|
|
156
161
|
return {get_reward_id: rpc_call}
|
157
162
|
|
158
163
|
def calculate_rewards_balance(
|
159
|
-
self,
|
160
|
-
decoded_data: dict,
|
161
|
-
wallet: str,
|
162
|
-
block_number: int = "latest"):
|
164
|
+
self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
|
163
165
|
get_reward_id = f"xcnAccrued_{self.name}_{wallet}_{block_number}".lower()
|
164
166
|
rewards = decoded_data.get(get_reward_id) / 10 ** 18
|
165
167
|
reward_token = self.pool_info.get("rewardToken")
|
@@ -72,10 +72,7 @@ class RadiantStateService(ValasStateService):
|
|
72
72
|
return rpc_calls
|
73
73
|
|
74
74
|
def calculate_rewards_balance(
|
75
|
-
self,
|
76
|
-
decoded_data: dict,
|
77
|
-
wallet: str,
|
78
|
-
block_number: int = "latest"):
|
75
|
+
self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
|
79
76
|
reward_token = self.pool_info['rewardToken']
|
80
77
|
key = f"allPendingRewards_{self.name}_{wallet}_{block_number}".lower()
|
81
78
|
rewards = decoded_data.get(key) / 10 ** 18
|
@@ -240,7 +240,7 @@ class SiloStateService(ProtocolServices):
|
|
240
240
|
decimals_id = f"decimals_{self.name}_{reward_token}_{block_number}".lower()
|
241
241
|
return {get_reward_id: rpc_call, decimals_id: decimals_call}
|
242
242
|
|
243
|
-
def calculate_rewards_balance(self,
|
243
|
+
def calculate_rewards_balance(self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
|
244
244
|
reward_token = self.pool_info.get("rewardToken")
|
245
245
|
get_reward_id = f"getUserUnclaimedRewards_{self.name}_{wallet}_{block_number}".lower()
|
246
246
|
decimals_id = f"decimals_{self.name}_{reward_token}_{block_number}".lower()
|
@@ -7,7 +7,7 @@ from defi_services.abis.lending.strike.strike_lens_abi import STRIKE_LENS_ABI
|
|
7
7
|
from defi_services.abis.token.erc20_abi import ERC20_ABI
|
8
8
|
from defi_services.constants.chain_constant import Chain, BlockTime
|
9
9
|
from defi_services.constants.entities.lending_constant import Lending
|
10
|
-
from defi_services.constants.token_constant import
|
10
|
+
from defi_services.constants.token_constant import Token
|
11
11
|
from defi_services.jobs.queriers.state_querier import StateQuerier
|
12
12
|
from defi_services.services.lending.compound_service import CompoundStateService
|
13
13
|
from defi_services.services.lending.lending_info.ethereum.strike_eth import STRIKE_ETH
|
@@ -66,8 +66,13 @@ class StrikeStateService(CompoundStateService):
|
|
66
66
|
ctoken = data[0].lower()
|
67
67
|
lt = data[10] / 10 ** 18
|
68
68
|
ltv = data[10] / 10 ** 18
|
69
|
+
|
70
|
+
underlying_decimal = int(data[13])
|
71
|
+
exchange_rate = data[1] / 10 ** (18 - 8 + underlying_decimal)
|
72
|
+
|
69
73
|
reserves_info[underlying] = {
|
70
74
|
"cToken": ctoken,
|
75
|
+
"exchangeRate": exchange_rate,
|
71
76
|
"liquidationThreshold": lt,
|
72
77
|
"loanToValue": ltv
|
73
78
|
}
|
@@ -118,7 +123,7 @@ class StrikeStateService(CompoundStateService):
|
|
118
123
|
return {get_reward_id: rpc_call}
|
119
124
|
|
120
125
|
def calculate_rewards_balance(
|
121
|
-
self,
|
126
|
+
self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
|
122
127
|
get_reward_id = f"strikeAccrued_{self.name}_{wallet}_{block_number}".lower()
|
123
128
|
rewards = decoded_data.get(get_reward_id) / 10 ** 18
|
124
129
|
reward_token = self.pool_info.get("rewardToken")
|
@@ -388,7 +388,7 @@ class TravaStateService(ProtocolServices):
|
|
388
388
|
# REWARDS BALANCE
|
389
389
|
def get_rewards_balance_function_info(
|
390
390
|
self,
|
391
|
-
|
391
|
+
wallet,
|
392
392
|
reserves_info: dict = None,
|
393
393
|
block_number: int = "latest"
|
394
394
|
):
|
@@ -397,16 +397,16 @@ class TravaStateService(ProtocolServices):
|
|
397
397
|
for token, value in reserves_info.items():
|
398
398
|
atoken, debt_token = Web3.toChecksumAddress(value['tToken']), Web3.toChecksumAddress(value['dToken'])
|
399
399
|
tokens += [atoken, debt_token]
|
400
|
-
key = f"getRewardsBalance_{self.name}_{
|
400
|
+
key = f"getRewardsBalance_{self.name}_{wallet}_{block_number}".lower()
|
401
401
|
rpc_calls[key] = self.get_function_incentive_info(
|
402
|
-
"getRewardsBalance", [tokens,
|
402
|
+
"getRewardsBalance", [tokens, wallet], block_number)
|
403
403
|
|
404
404
|
return rpc_calls
|
405
405
|
|
406
406
|
def calculate_rewards_balance(
|
407
|
-
self,
|
407
|
+
self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
|
408
408
|
reward_token = self.pool_info['rewardToken']
|
409
|
-
key = f"getRewardsBalance_{self.name}_{
|
409
|
+
key = f"getRewardsBalance_{self.name}_{wallet}_{block_number}".lower()
|
410
410
|
rewards = decoded_data.get(key) / 10 ** 18
|
411
411
|
result = {
|
412
412
|
reward_token: {"amount": rewards}
|
@@ -295,7 +295,7 @@ class UwuStateService(ProtocolServices):
|
|
295
295
|
return rpc_calls
|
296
296
|
|
297
297
|
def calculate_rewards_balance(
|
298
|
-
self,
|
298
|
+
self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
|
299
299
|
reward_token = self.pool_info['rewardToken']
|
300
300
|
key = f"claimableReward_{self.name}_{wallet}_{block_number}".lower()
|
301
301
|
rewards = sum(decoded_data.get(key)) / 10 ** 18
|
@@ -443,7 +443,7 @@ class ValasStateService(ProtocolServices):
|
|
443
443
|
return rpc_calls
|
444
444
|
|
445
445
|
def calculate_rewards_balance(
|
446
|
-
self,
|
446
|
+
self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
|
447
447
|
reward_token = self.pool_info['rewardToken']
|
448
448
|
key = f"earnedBalances_{self.name}_{wallet}_{block_number}".lower()
|
449
449
|
rewards = decoded_data.get(key)[0] / 10 ** 18
|
@@ -8,7 +8,7 @@ from defi_services.abis.lending.venus.vtoken_abi import VTOKEN_ABI
|
|
8
8
|
from defi_services.abis.token.erc20_abi import ERC20_ABI
|
9
9
|
from defi_services.constants.chain_constant import Chain
|
10
10
|
from defi_services.constants.entities.lending_constant import Lending
|
11
|
-
from defi_services.constants.token_constant import
|
11
|
+
from defi_services.constants.token_constant import Token
|
12
12
|
from defi_services.jobs.queriers.state_querier import StateQuerier
|
13
13
|
from defi_services.services.lending.compound_service import CompoundStateService
|
14
14
|
from defi_services.services.lending.lending_info.bsc.venus_bsc import VENUS_BSC
|
@@ -62,25 +62,37 @@ class VenusStateService(CompoundStateService):
|
|
62
62
|
tokens = [Web3.toChecksumAddress(i) for i in ctokens]
|
63
63
|
queries = {}
|
64
64
|
for token in tokens:
|
65
|
-
key = f"underlying_{token}
|
65
|
+
key = f"underlying_{token}_{block_number}".lower()
|
66
66
|
queries[key] = {
|
67
|
-
"address": token,
|
68
|
-
"
|
69
|
-
"params": [],
|
70
|
-
"function": "underlying",
|
71
|
-
"block_number": "latest"
|
67
|
+
"address": token, "abi": self.vtoken_abi, "params": [],
|
68
|
+
"function": "underlying", "block_number": block_number
|
72
69
|
}
|
73
|
-
|
70
|
+
|
71
|
+
exchange_rate_query_id = f'exchangeRateStored_{token}_{block_number}'
|
72
|
+
queries[exchange_rate_query_id] = self.get_ctoken_function_info(
|
73
|
+
ctoken=token, fn_name='exchangeRateStored', block_number=block_number)
|
74
|
+
|
75
|
+
markets = f"markets_{token}_{block_number}".lower()
|
74
76
|
queries[markets] = self.get_comptroller_function_info("markets", [token])
|
75
77
|
decoded_data = self.state_service.query_state_data(queries)
|
76
78
|
for token in tokens:
|
77
|
-
key = f"underlying_{token}
|
79
|
+
key = f"underlying_{token}_{block_number}".lower()
|
78
80
|
underlying = decoded_data.get(key).lower()
|
79
|
-
markets = f"markets_{token}
|
81
|
+
markets = f"markets_{token}_{block_number}".lower()
|
80
82
|
liquidation_threshold = decoded_data.get(markets)[1] / 10 ** 18
|
81
83
|
ltv = liquidation_threshold
|
84
|
+
|
85
|
+
if underlying != Token.native_token:
|
86
|
+
underlying_contract = _w3.eth.contract(address=Web3.toChecksumAddress(underlying), abi=ERC20_ABI)
|
87
|
+
underlying_decimal = underlying_contract.functions.decimals().call()
|
88
|
+
else:
|
89
|
+
underlying_decimal = Chain.native_decimals.get(self.chain_id, 18)
|
90
|
+
exchange_rate_query_id = f'exchangeRateStored_{token}_{block_number}'
|
91
|
+
exchange_rate = decoded_data.get(exchange_rate_query_id) / 10 ** (18 - 8 + underlying_decimal)
|
92
|
+
|
82
93
|
reserves_info[underlying] = {
|
83
94
|
'cToken': token.lower(),
|
95
|
+
"exchangeRate": exchange_rate,
|
84
96
|
"liquidationThreshold": liquidation_threshold,
|
85
97
|
"loanToValue": ltv
|
86
98
|
}
|
@@ -128,17 +140,17 @@ class VenusStateService(CompoundStateService):
|
|
128
140
|
# REWARDS BALANCE
|
129
141
|
def get_rewards_balance_function_info(
|
130
142
|
self,
|
131
|
-
|
143
|
+
wallet: str,
|
132
144
|
reserves_info: dict = None,
|
133
145
|
block_number: int = "latest",
|
134
146
|
):
|
135
|
-
rpc_call = self.get_comptroller_function_info("venusAccrued", [
|
136
|
-
get_reward_id = f"venusAccrued_{self.name}_{
|
147
|
+
rpc_call = self.get_comptroller_function_info("venusAccrued", [wallet], block_number)
|
148
|
+
get_reward_id = f"venusAccrued_{self.name}_{wallet}_{block_number}".lower()
|
137
149
|
return {get_reward_id: rpc_call}
|
138
150
|
|
139
|
-
def calculate_rewards_balance(
|
140
|
-
|
141
|
-
get_reward_id = f"venusAccrued_{self.name}_{
|
151
|
+
def calculate_rewards_balance(
|
152
|
+
self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
|
153
|
+
get_reward_id = f"venusAccrued_{self.name}_{wallet}_{block_number}".lower()
|
142
154
|
rewards = decoded_data.get(get_reward_id) / 10 ** 18
|
143
155
|
reward_token = self.pool_info.get("rewardToken")
|
144
156
|
result = {
|
@@ -8,7 +8,7 @@ from defi_services.abis.lending.wepiggy.wepiggy_lens_abi import WEPIGGY_LENS_ABI
|
|
8
8
|
from defi_services.abis.token.erc20_abi import ERC20_ABI
|
9
9
|
from defi_services.constants.chain_constant import Chain, BlockTime
|
10
10
|
from defi_services.constants.entities.lending_constant import Lending
|
11
|
-
from defi_services.constants.token_constant import
|
11
|
+
from defi_services.constants.token_constant import Token
|
12
12
|
from defi_services.jobs.queriers.state_querier import StateQuerier
|
13
13
|
from defi_services.services.lending.compound_service import CompoundStateService
|
14
14
|
from defi_services.services.lending.lending_info.arbitrum.wepiggy_arbitrum import WEPIGGY_ARB
|
@@ -80,8 +80,13 @@ class WepiggyStateService(CompoundStateService):
|
|
80
80
|
ctoken = data[0].lower()
|
81
81
|
lt = data[10] / 10 ** 18
|
82
82
|
ltv = data[10] / 10 ** 18
|
83
|
+
|
84
|
+
underlying_decimal = int(data[3])
|
85
|
+
exchange_rate = data[6] / 10 ** (18 - 8 + underlying_decimal)
|
86
|
+
|
83
87
|
reserves_info[underlying] = {
|
84
88
|
"cToken": ctoken,
|
89
|
+
"exchangeRate": exchange_rate,
|
85
90
|
"liquidationThreshold": lt,
|
86
91
|
"loanToValue": ltv
|
87
92
|
}
|
@@ -135,7 +140,7 @@ class WepiggyStateService(CompoundStateService):
|
|
135
140
|
get_reward_id = f"wpcAccrued_{self.name}_{wallet}_{block_number}".lower()
|
136
141
|
return {get_reward_id: rpc_call}
|
137
142
|
|
138
|
-
def calculate_rewards_balance(self,
|
143
|
+
def calculate_rewards_balance(self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
|
139
144
|
get_reward_id = f"wpcAccrued_{self.name}_{wallet}_{block_number}".lower()
|
140
145
|
rewards = decoded_data.get(get_reward_id) / 10 ** 18
|
141
146
|
reward_token = self.pool_info.get("rewardToken")
|