defi-state-querier 0.4.2__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.
Files changed (47) hide show
  1. defi_services/__init__.py +1 -1
  2. defi_services/constants/entities/vault_constant.py +5 -0
  3. defi_services/constants/entities/vault_services.py +24 -0
  4. defi_services/constants/query_constant.py +1 -0
  5. defi_services/jobs/processors/state_processor.py +4 -2
  6. defi_services/services/lending/aave_v2_services.py +1 -1
  7. defi_services/services/lending/aave_v3_services.py +1 -1
  8. defi_services/services/lending/apeswap_services.py +1 -1
  9. defi_services/services/lending/compound_service.py +1 -1
  10. defi_services/services/lending/compound_v3_services.py +1 -4
  11. defi_services/services/lending/flux_services.py +1 -4
  12. defi_services/services/lending/granary_services.py +1 -4
  13. defi_services/services/lending/iron_bank_service.py +1 -4
  14. defi_services/services/lending/justlend_service.py +6 -6
  15. defi_services/services/lending/lending_info/bsc/liqee_bsc.py +154 -106
  16. defi_services/services/lending/lending_info/ethereum/liqee_eth.py +160 -110
  17. defi_services/services/lending/liqee_service.py +1 -1
  18. defi_services/services/lending/morpho_aave_v2_services.py +1 -1
  19. defi_services/services/lending/morpho_aave_v3_services.py +1 -4
  20. defi_services/services/lending/morpho_compound_services.py +1 -5
  21. defi_services/services/lending/onyx_service.py +1 -4
  22. defi_services/services/lending/radiant_v2_services.py +1 -4
  23. defi_services/services/lending/silo_services.py +1 -1
  24. defi_services/services/lending/strike_service.py +1 -1
  25. defi_services/services/lending/trava_services.py +5 -5
  26. defi_services/services/lending/uwu_services.py +1 -1
  27. defi_services/services/lending/valas_services.py +1 -1
  28. defi_services/services/lending/venus_services.py +6 -6
  29. defi_services/services/lending/wepiggy_services.py +1 -1
  30. defi_services/services/protocol_services.py +34 -2
  31. defi_services/services/vault/__init__.py +0 -0
  32. defi_services/services/vault/trava_vault_services.py +196 -0
  33. defi_services/services/vault/vault_info/__init__.py +0 -0
  34. defi_services/services/vault/vault_info/bsc/__init__.py +0 -0
  35. defi_services/services/vault/vault_info/bsc/trava_bsc.py +41 -0
  36. defi_services/services/vault/vault_info/ethereum/__init__.py +0 -0
  37. defi_services/services/vault/vault_info/ethereum/trava_eth.py +22 -0
  38. defi_services/services/vault/vault_info/fantom/__init__.py +0 -0
  39. defi_services/services/vault/vault_info/fantom/trava_ftm.py +31 -0
  40. defi_services/utils/init_services.py +5 -0
  41. {defi_state_querier-0.4.2.dist-info → defi_state_querier-0.4.3.dist-info}/METADATA +1 -1
  42. {defi_state_querier-0.4.2.dist-info → defi_state_querier-0.4.3.dist-info}/RECORD +45 -36
  43. defi_services/jobs/queriers/cosmos_state_querier.py +0 -82
  44. defi_services/services/cosmos_token_services.py +0 -46
  45. {defi_state_querier-0.4.2.dist-info → defi_state_querier-0.4.3.dist-info}/LICENSE +0 -0
  46. {defi_state_querier-0.4.2.dist-info → defi_state_querier-0.4.3.dist-info}/WHEEL +0 -0
  47. {defi_state_querier-0.4.2.dist-info → defi_state_querier-0.4.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,196 @@
1
+ import logging
2
+
3
+ from defi_services.abis.token.erc20_abi import ERC20_ABI
4
+ from defi_services.abis.vault.trava_vault_abi import TRAVA_VAULT_ABI
5
+ from defi_services.constants.chain_constant import Chain
6
+ from defi_services.constants.entities.vault_constant import Vault
7
+ from defi_services.constants.token_constant import Token
8
+ from defi_services.jobs.queriers.state_querier import StateQuerier
9
+ from defi_services.services.protocol_services import ProtocolServices
10
+ from defi_services.services.vault.vault_info.bsc.trava_bsc import TRAVA_VAULT_BSC
11
+ from defi_services.services.vault.vault_info.ethereum.trava_eth import TRAVA_VAULT_ETH
12
+ from defi_services.services.vault.vault_info.fantom.trava_ftm import TRAVA_VAULT_FTM
13
+
14
+ logger = logging.getLogger("Trava Vault State Service")
15
+
16
+
17
+ class TravaVaultInfo:
18
+ mapping = {
19
+ Chain.bsc: TRAVA_VAULT_BSC,
20
+ Chain.ethereum: TRAVA_VAULT_ETH,
21
+ Chain.fantom: TRAVA_VAULT_FTM
22
+ }
23
+
24
+
25
+ class TravaVaultStateService(ProtocolServices):
26
+ def __init__(self, state_service: StateQuerier, chain_id: str = "0x1"):
27
+ super().__init__()
28
+ self.name = f"{chain_id}_{Vault.trava_vault}"
29
+ self.chain_id = chain_id
30
+ self.pool_info = TravaVaultInfo.mapping.get(chain_id)
31
+
32
+ self.vault_abi = TRAVA_VAULT_ABI
33
+ self.state_service = state_service
34
+
35
+ # BASIC FUNCTION
36
+ def get_service_info(self):
37
+ info = {
38
+ Vault.trava_vault: {
39
+ "chain_id": self.chain_id,
40
+ "type": "vault",
41
+ "protocol_info": self.pool_info
42
+ }
43
+ }
44
+ return info
45
+
46
+ def get_token_list(self):
47
+ reward_token = self.pool_info.get('rewardToken')
48
+
49
+ tokens = []
50
+ if isinstance(reward_token, list):
51
+ tokens += reward_token
52
+ elif isinstance(reward_token, str):
53
+ tokens.append(reward_token)
54
+
55
+ for token, info in self.pool_info.get("reservesList", {}).items():
56
+ asset_address = info['tokenIn']
57
+ if asset_address == Token.native_token:
58
+ tokens.append(Token.wrapped_token.get(self.chain_id))
59
+ else:
60
+ tokens.append(asset_address)
61
+
62
+ tokens = list(set(tokens))
63
+ return tokens
64
+
65
+ # WALLET STAKING BALANCE
66
+ def get_wallet_staking_balance_function_info(
67
+ self,
68
+ wallet: str,
69
+ reserves_info: dict,
70
+ block_number: int = "latest",
71
+ return_reward: bool = False
72
+ ):
73
+ rpc_calls = {}
74
+ for token in reserves_info:
75
+ rpc_calls[f'balanceOf_{token}_{wallet}_{block_number}'.lower()] = self.state_service.get_function_info(
76
+ token, ERC20_ABI, "balanceOf", [wallet], block_number=block_number)
77
+ rpc_calls[f'decimals_{token}_{block_number}'.lower()] = self.state_service.get_function_info(
78
+ token, ERC20_ABI, "decimals", block_number=block_number)
79
+
80
+ if return_reward:
81
+ query_reward_id = f'getTotalRewardsBalance_{token}_{wallet}_{block_number}'.lower()
82
+ rpc_calls[query_reward_id] = self.state_service.get_function_info(
83
+ token, self.vault_abi, "getTotalRewardsBalance", [wallet], block_number=block_number)
84
+
85
+ if return_reward:
86
+ reward_token = self.pool_info["rewardToken"]
87
+ rpc_calls[f'decimals_{reward_token}_{block_number}'.lower()] = self.state_service.get_function_info(
88
+ reward_token, ERC20_ABI, "decimals", block_number=block_number)
89
+
90
+ return rpc_calls
91
+
92
+ def get_wallet_staking_balance(
93
+ self,
94
+ reserves_info: dict,
95
+ token_prices,
96
+ decimals,
97
+ staking_amount,
98
+ return_reward: bool = False,
99
+ rewards: dict = None
100
+ ):
101
+ reward_token = self.pool_info['rewardToken']
102
+
103
+ result = {}
104
+ for token in reserves_info:
105
+ value = reserves_info[token]
106
+ asset_address = value['tokenIn']
107
+
108
+ decimals_token = decimals.get(token)
109
+ staking_amount_wallet = staking_amount.get(token) / 10 ** decimals_token
110
+ result[token] = {
111
+ asset_address: {
112
+ "staking_amount": staking_amount_wallet
113
+ }
114
+ }
115
+ if return_reward:
116
+ result[token][asset_address].update({
117
+ "rewards": {
118
+ reward_token: {'amount': rewards.get(token, 0)}
119
+ }
120
+ })
121
+
122
+ if token_prices:
123
+ staking_amount_in_usd = staking_amount_wallet * token_prices.get(asset_address, 0)
124
+ result[token][asset_address].update({
125
+ "staking_amount_in_usd": staking_amount_in_usd
126
+ })
127
+ if return_reward:
128
+ reward_amount = rewards.get(token, 0)
129
+ reward_in_usd = reward_amount * token_prices.get(reward_token, 0)
130
+ result[token][asset_address]['rewards'][reward_token].update({'value_in_usd': reward_in_usd})
131
+
132
+ return result
133
+
134
+ def calculate_wallet_staking_balance(
135
+ self,
136
+ wallet: str,
137
+ reserves_info: dict,
138
+ decoded_data: dict,
139
+ token_prices: dict,
140
+ block_number: int = 'latest',
141
+ return_reward: bool = False
142
+ ):
143
+ reward_token = self.pool_info['rewardToken']
144
+ get_decimals_id = f"decimals_{reward_token}_{block_number}".lower()
145
+ reward_decimals = decoded_data.get(get_decimals_id, 18)
146
+
147
+ decimals, staking_amount, rewards = {}, {}, {}
148
+ for token in reserves_info:
149
+ get_user_data_id = f"balanceOf_{token}_{wallet}_{block_number}".lower()
150
+ get_decimals_id = f"decimals_{token}_{block_number}".lower()
151
+ staking_amount[token] = decoded_data[get_user_data_id]
152
+ decimals[token] = decoded_data[get_decimals_id]
153
+
154
+ if return_reward:
155
+ get_reward_id = f"getTotalRewardsBalance_{token}_{wallet}_{block_number}".lower()
156
+ rewards[token] = decoded_data[get_reward_id] / 10 ** reward_decimals
157
+
158
+ data = self.get_wallet_staking_balance(
159
+ reserves_info, token_prices, decimals, staking_amount, return_reward=return_reward, rewards=rewards)
160
+
161
+ return data
162
+
163
+ # REWARDS BALANCE
164
+ def get_rewards_balance_function_info(
165
+ self,
166
+ wallet,
167
+ reserves_info: dict = None,
168
+ block_number: int = "latest"
169
+ ):
170
+ rpc_calls = {}
171
+ for token, value in reserves_info.items():
172
+ rpc_calls[f'getTotalRewardsBalance_{token}_{wallet}_{block_number}'.lower()] = self.state_service.get_function_info(
173
+ token, self.vault_abi, "getTotalRewardsBalance", [wallet], block_number=block_number)
174
+
175
+ reward_token = self.pool_info["rewardToken"]
176
+ rpc_calls[f'decimals_{reward_token}_{block_number}'.lower()] = self.state_service.get_function_info(
177
+ reward_token, ERC20_ABI, "decimals", block_number=block_number)
178
+
179
+ return rpc_calls
180
+
181
+ def calculate_rewards_balance(
182
+ self, wallet: str, reserves_info: dict, decoded_data: dict, block_number: int = "latest"):
183
+
184
+ reward_token = self.pool_info['rewardToken']
185
+
186
+ get_decimals_id = f"decimals_{reward_token}_{block_number}".lower()
187
+ decimals = decoded_data[get_decimals_id]
188
+
189
+ reward_amount = 0
190
+ for token in reserves_info:
191
+ get_reward_id = f"getTotalRewardsBalance_{token}_{wallet}_{block_number}".lower()
192
+ reward_amount += decoded_data[get_reward_id] / 10 ** decimals
193
+
194
+ return {
195
+ reward_token: {"amount": reward_amount}
196
+ }
File without changes
@@ -0,0 +1,41 @@
1
+ TRAVA_VAULT_BSC = {
2
+ "name": "Trava Vault",
3
+ "rewardToken": "0x0391be54e72f7e001f6bbc331777710b4f2999ef",
4
+ "reservesList": {
5
+ "0x17b173d4b80b0b5bb7e0f1e99f5962f2d51799eb": {
6
+ "vaultName": "rtrava",
7
+ "tokenIn": "0x170772a06affc0d375ce90ef59c8ec04c7ebf5d2",
8
+ "metadata": {
9
+ "vaultType": "base",
10
+ "token": "0x170772a06affc0d375ce90ef59c8ec04c7ebf5d2"
11
+ }
12
+ },
13
+ "0xc5f0137ce42437d8f5ef25da110f7fd7386178ec": {
14
+ "vaultName": "trava",
15
+ "tokenIn": "0x0391be54e72f7e001f6bbc331777710b4f2999ef",
16
+ "metadata": {
17
+ "vaultType": "base",
18
+ "token": "0x0391be54e72f7e001f6bbc331777710b4f2999ef"
19
+ }
20
+ },
21
+ "0xf04fee30118fdb83c0957c4f6abdfdde977b9aeb": {
22
+ "vaultName": "trava/bnb",
23
+ "tokenIn": "0x865c77d4ff6383e06c58350a2cfb95cca2c0f056",
24
+ "metadata": {
25
+ "vaultType": "lp",
26
+ "base": "0x0391be54e72f7e001f6bbc331777710b4f2999ef",
27
+ "token": "0x865c77d4ff6383e06c58350a2cfb95cca2c0f056"
28
+ }
29
+ },
30
+ "0xd5cc214621395686b972dde8481a7463a0dab962": {
31
+ "vaultName": "orai",
32
+ "tokenIn": "0xa325ad6d9c92b55a3fc5ad7e412b1518f96441c0",
33
+ "metadata": {
34
+ "vaultType": "normal",
35
+ "token_coin_id": "oraichain-token",
36
+ "reward_coin_id": "trava-finance",
37
+ "token": "0xa325ad6d9c92b55a3fc5ad7e412b1518f96441c0"
38
+ }
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,22 @@
1
+ TRAVA_VAULT_ETH = {
2
+ "name": "Trava Vault",
3
+ "rewardToken": "0x186d0ba3dfc3386c464eecd96a61fbb1e2da00bf",
4
+ "reservesList": {
5
+ "0xbf576c63c30e1ebb637138ee1c67a570ff70223d": {
6
+ "vaultName": "rtrava",
7
+ "tokenIn": "0x044ede67afdb0f56d7451bb3aaccaeab3f772fad",
8
+ "metadata": {
9
+ "vaultType": "base",
10
+ "token": "0x044ede67afdb0f56d7451bb3aaccaeab3f772fad"
11
+ }
12
+ },
13
+ "0x84d92a3d61ec158dcf878ff24ebdcf6b2b5ec1fa": {
14
+ "vaultName": "trava",
15
+ "tokenIn": "0x186d0ba3dfc3386c464eecd96a61fbb1e2da00bf",
16
+ "metadata": {
17
+ "vaultType": "base",
18
+ "token": "0x186d0ba3dfc3386c464eecd96a61fbb1e2da00bf"
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,31 @@
1
+ TRAVA_VAULT_FTM = {
2
+ "name": "Trava Vault",
3
+ "rewardToken": "0x477a9d5df9beda06f6b021136a2efe7be242fcc9",
4
+ "reservesList": {
5
+ "0x9709730aad5878040f382968dcb9e66f2f0a964f": {
6
+ "vaultName": "rtrava",
7
+ "tokenIn": "0x1ddec3377347cba814027fbf13a86b6000f201fb",
8
+ "metadata": {
9
+ "vaultType": "base",
10
+ "token": "0x1ddec3377347cba814027fbf13a86b6000f201fb"
11
+ }
12
+ },
13
+ "0x182d67287fda8a7248851ac657e74d5a048310ae": {
14
+ "vaultName": "trava",
15
+ "tokenIn": "0x477a9d5df9beda06f6b021136a2efe7be242fcc9",
16
+ "metadata": {
17
+ "vaultType": "base",
18
+ "token": "0x477a9d5df9beda06f6b021136a2efe7be242fcc9"
19
+ }
20
+ },
21
+ "0xe7c81531db9b13046358e53cca7e16bac80ddd88": {
22
+ "vaultName": "ftm/trava",
23
+ "tokenIn": "0x7af19103e0ecf20acd414d365b1d966c58fe3799",
24
+ "metadata": {
25
+ "vaultType": "lp",
26
+ "base": "0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83",
27
+ "token": "0x477a9d5df9beda06f6b021136a2efe7be242fcc9"
28
+ }
29
+ }
30
+ }
31
+ }
@@ -1,10 +1,15 @@
1
1
  from defi_services.constants.entities.lending_services import LendingServices
2
+ from defi_services.constants.entities.vault_services import VaultServices
2
3
  from defi_services.jobs.queriers.state_querier import StateQuerier
3
4
 
4
5
 
5
6
  def init_services(state_querier: StateQuerier, chain_id: str):
6
7
  services = {}
8
+
7
9
  for protocol, value in LendingServices.mapping.get(chain_id, {}).items():
8
10
  services[protocol] = value(state_querier, chain_id)
9
11
 
12
+ for protocol, value in VaultServices.mapping.get(chain_id, {}).items():
13
+ services[protocol] = value(state_querier, chain_id)
14
+
10
15
  return services
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: defi-state-querier
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Calculate apy, apr, and wallet information,... in decentralized applications.
5
5
  Home-page: https://github.com/Centic-io/defi-state-querier
6
6
  Author: Viet-Bang Pham
@@ -1,4 +1,4 @@
1
- defi_services/__init__.py,sha256=6hfVa12Q-nXyUEXr6SyKpqPEDJW6vlRHyPxlA27PfTs,22
1
+ defi_services/__init__.py,sha256=Nyg0pmk5ea9-SLCAFEIF96ByFx4-TJFtrqYPN-Zn6g4,22
2
2
  defi_services/abis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  defi_services/abis/dex/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  defi_services/abis/dex/biswap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -211,56 +211,56 @@ defi_services/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
211
211
  defi_services/constants/chain_constant.py,sha256=mufCUn3cyDEEFk2Z2x2okBsjQM5AvMwESrVEmdgXLkI,643
212
212
  defi_services/constants/db_constant.py,sha256=gDMFFjhPOgQHuS9sPOTFbsfSdIfdWQEE4tGlxHQhNsE,2566
213
213
  defi_services/constants/mongo_constant.py,sha256=7EjyDPn7lIkjJTRqQ_xeD4zt4zG_Pazc2XKLl8Uhobg,394
214
- defi_services/constants/query_constant.py,sha256=h5burTZ5k-WgMxm9nNQF3IFEEOwin6d-jciYQwqMEgg,701
214
+ defi_services/constants/query_constant.py,sha256=shSnMQVgPvTXvN_TGxeM0JO5grwp-WxgRqJeEHGBwes,739
215
215
  defi_services/constants/time_constant.py,sha256=bC-0pYnfIFFR_0iVvkxhfyHfOclWNw9O3DbdO_nh258,181
216
216
  defi_services/constants/token_constant.py,sha256=K0fm4p2qEmNm54MGinfxsjV0dG1Pi-y3-1TGv_rdBnU,2685
217
217
  defi_services/constants/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
218
218
  defi_services/constants/entities/lending_constant.py,sha256=uUb3CnIlZP0lqdVPUt4IdlUXZwNpsMVDTmqMw0NK47g,1009
219
219
  defi_services/constants/entities/lending_services.py,sha256=XP-Ck9bKmvNvKGOXBx_Xrg8wbD-CkCQHDFpWNjPbyHM,4909
220
+ defi_services/constants/entities/vault_constant.py,sha256=IGGd4--T-BQcm8mlU8XAJ_hkZglrdAeZff5h-oMcMqg,84
221
+ defi_services/constants/entities/vault_services.py,sha256=IMmQc15wS1KA7EuQqM_AraQtCthnZ7hoNee0E_DOyw8,567
220
222
  defi_services/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
221
223
  defi_services/jobs/processors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
222
224
  defi_services/jobs/processors/multi_state_processor.py,sha256=20pYx-vpOvJwYNM4NvRrc149V4DM_RZGhJ6EQDQ0oJw,4749
223
225
  defi_services/jobs/processors/solana_state_processor.py,sha256=szsBYrkEV8kBzuA_iaSVescnwKJ2MHoTbut5kORbWTs,4065
224
- defi_services/jobs/processors/state_processor.py,sha256=u_-veX8SUm-h129lAMpI_MMiyqFz6HB7q_JWRqe4-iI,6463
226
+ defi_services/jobs/processors/state_processor.py,sha256=NTGL_77yddrdRf3sLCQOIAiy8BqeQRcLcBLHGibdbPQ,6622
225
227
  defi_services/jobs/processors/substrate_state_processor.py,sha256=KkiY1NkaxnizNJBTfn4twB-zuQo3fT3akOlbie8VF5g,3940
226
228
  defi_services/jobs/queriers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
227
- defi_services/jobs/queriers/cosmos_state_querier.py,sha256=I0nNzJFPJCO7SbuERMpLvmDh4nMYdVyLu3glLB2v0qs,3199
228
229
  defi_services/jobs/queriers/solana_state_querier.py,sha256=TQELYo6GUoF8s-LfetqYbclNaH8bakQqC7y2ifACIb8,3239
229
230
  defi_services/jobs/queriers/state_querier.py,sha256=uXY73-Zp0bnSszcgvCXB-ptoDpv_JUSJxKbUIatWke0,6829
230
231
  defi_services/jobs/queriers/substrate_state_querier.py,sha256=_T0Dk06sP_uBKaxgj2J_EBtJDoq-hi8jU7Np4iuO0LA,3858
231
232
  defi_services/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
232
- defi_services/services/cosmos_token_services.py,sha256=SAgzaf2oVGNWpo78nJdMDbKv7IRxHD1HUOFhfbFOSFI,1753
233
233
  defi_services/services/nft_services.py,sha256=vKva0OJQTTxgP1lrZ5ij2sw2N44JxN5dfLLtvNJB6aA,2188
234
- defi_services/services/protocol_services.py,sha256=JzdFTLdLthABYJ8MROX_VPYaR2j9aea7-U2g4ukJJJ8,6482
234
+ defi_services/services/protocol_services.py,sha256=3Yca433xGXowcV4EjFoQ90AJHg-SfuOBsDF7aMCJ8Zk,7626
235
235
  defi_services/services/solana_token_services.py,sha256=NQKUHGMBe9eQciOaY3N20rPbIuNz108akrysX-mXfJU,1865
236
236
  defi_services/services/substrate_token_services.py,sha256=HsjceBHo0fxQIcXgDaV0OBANLuggRwXAEPt7ASB0BKk,2904
237
237
  defi_services/services/token_services.py,sha256=ncGdOpATIb9tGFa9cY1dQq3hFRwbhcYwIz0we9tNWNY,2766
238
238
  defi_services/services/lending/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
239
- defi_services/services/lending/aave_v2_services.py,sha256=fZpRfDUe0MnLzJw0_25t1z49p7H0ZKBsCea2VD3zQ1U,21483
240
- defi_services/services/lending/aave_v3_services.py,sha256=IGU9Es_-N6yMM8Vs4RN-cCTBGIFgDKOrWTY7msfXXO8,16126
241
- defi_services/services/lending/apeswap_services.py,sha256=CWZwSZzpgICWagdEU4P5a6wa7Jgr4rgdokMJEPC7cuQ,4710
242
- defi_services/services/lending/compound_service.py,sha256=y0liyLO-PzDxUbRyfaclHzTZ-yBzGxMBSbjQ4JK1VxQ,21281
243
- defi_services/services/lending/compound_v3_services.py,sha256=YBSWUq0WvAioV2IYpij_WLIsrHaxpv-G-N4uqhs_FE8,17049
239
+ defi_services/services/lending/aave_v2_services.py,sha256=yiz12kPSExj8AkTBA3WHzvA9DjSja_Hu0Vju5uJK2BY,21504
240
+ defi_services/services/lending/aave_v3_services.py,sha256=3Kwxa2dBiYv52qFZohC8RoCHVRU9ik33KpgniM4d8UU,16147
241
+ defi_services/services/lending/apeswap_services.py,sha256=pum1i3rcAbpd7HY7WYGHlUNoXsaiIzyi17um1qnt4Eg,4731
242
+ defi_services/services/lending/compound_service.py,sha256=fIvi66X_vL28AKKe5lYYomqCk4LIDQx5s7VRv0LjZU0,21302
243
+ defi_services/services/lending/compound_v3_services.py,sha256=BQ8f6-q_f1JuHwCj1m-FR_pnV6p77K3551GSTnYc7Mc,17034
244
244
  defi_services/services/lending/cream_services.py,sha256=vtah0kMHAxztenWbJp4CxEcBMF0XUBglGRk6p9d-oiU,1644
245
- defi_services/services/lending/flux_services.py,sha256=zkfKcBMpfb4Y2vMsZlBvyFxVFZBq8LDFCaS0mtbmfX4,12021
245
+ defi_services/services/lending/flux_services.py,sha256=eipqDK38186YBWYAQJncP6ganBTZRVtIoNX7FQLlJmw,12006
246
246
  defi_services/services/lending/geist_services.py,sha256=UI5D-MbMqplrt7D4krSFdpaREKOT81k8boD_XhGGpUQ,1035
247
- defi_services/services/lending/granary_services.py,sha256=37W6dVoW8tPGvSssqa8pH3C7uoAU6yzdlf2NboGbpiM,16373
248
- defi_services/services/lending/iron_bank_service.py,sha256=lNfSiTb5Dc8eeHw7bQGfkXlK9xk-2ioNW_3c1RV_OTQ,14986
249
- defi_services/services/lending/justlend_service.py,sha256=9pM9BCODx6EsuCVyGxKY1s_utcA_kOuY_sOk-5--dvQ,8267
250
- defi_services/services/lending/liqee_service.py,sha256=YRjYA1Sj3rzT7B-ci-1FsY0dnwizEQrzjVlRIDsHsls,16971
251
- defi_services/services/lending/morpho_aave_v2_services.py,sha256=YXuRI5yPj1U2okM9uXFfMBu3w09e-hzPufKtqooo6Ak,8449
252
- defi_services/services/lending/morpho_aave_v3_services.py,sha256=8nIHPRk2q3rrWPdvAXBkmYVkehQFmgFBr98ulYEoHWU,8191
253
- defi_services/services/lending/morpho_compound_services.py,sha256=DpqocgrPxStNf3bVazjvJG_h9EirbjLpsdZrEwqx4NY,14851
254
- defi_services/services/lending/onyx_service.py,sha256=ArX8TyfnQdfbH5ogDHRnnFv_OoLwNGGHwIpnfFmIcWY,14824
255
- defi_services/services/lending/radiant_v2_services.py,sha256=U23LB571IxZcK11O5_vVEkB1BGDeI03MPN4uI-aSXOg,3036
256
- defi_services/services/lending/silo_services.py,sha256=5xGBVbT_ZsWxf2Q7e_hDd9WaYJ_xFBdfAQW7s9xETcI,16653
247
+ defi_services/services/lending/granary_services.py,sha256=a99xPdsWKY2MwYETamtR4rGuMijcVUx3DyZSMK_b6uQ,16358
248
+ defi_services/services/lending/iron_bank_service.py,sha256=1oJgUlKGn8te2SgmWe1yNOKp8xO0XCjkt1mgXj0GxNA,14971
249
+ defi_services/services/lending/justlend_service.py,sha256=2jCAbHljtE3XllZTOOjAMIzB_6icowV78bWlAv6BoCw,8262
250
+ defi_services/services/lending/liqee_service.py,sha256=qd1va1w4r6B1-nb8hYB4HMQRtypIMsXjroQUrx6JWPU,16991
251
+ defi_services/services/lending/morpho_aave_v2_services.py,sha256=qUaSVisEck6dqj5f_eETxZseaBNQqvNFZNrOkInphPg,8470
252
+ defi_services/services/lending/morpho_aave_v3_services.py,sha256=yBMXUmWBnJO04idysXu6wNbtmvOfVpVPHE7gV4j_jhE,8176
253
+ defi_services/services/lending/morpho_compound_services.py,sha256=McMcOEFyr4ByeBjnL543LQ3d9bPmDqhKYxUdkdQSJpA,14831
254
+ defi_services/services/lending/onyx_service.py,sha256=WskvimXJ4iVLq6vZOB4RV645bKh5NCH3_Lf3rHx_CVY,14809
255
+ defi_services/services/lending/radiant_v2_services.py,sha256=ywjZ4sb2UQlbc4wBWz7mn9P6y19AvGVsgroDXl46fgc,3021
256
+ defi_services/services/lending/silo_services.py,sha256=xP2RYTl_eOwV5tVX4Von_T5FwwoDWlejCrEl7rZkQgM,16674
257
257
  defi_services/services/lending/spark_services.py,sha256=68_egY0yOT7YIOVbd8rbHJBJEsL0sOr0zSsTSdw0BUY,1042
258
- defi_services/services/lending/strike_service.py,sha256=5VAI1BprultM6mlgvjVv9abRincQNIwNVhzPPUXvvBM,13164
259
- defi_services/services/lending/trava_services.py,sha256=r2sxrz7R8BPgtKiFNxeRkXlbehpRmOfqDf2xlPc7oCM,19013
260
- defi_services/services/lending/uwu_services.py,sha256=ZEGUQNTOuBTpjh4P78Quuf1pu9PonD3kJ5PRj8CG5oc,13715
261
- defi_services/services/lending/valas_services.py,sha256=LfOfzj5ZweWzpMRacpeyMwiIsoqeVI36rWSwZ3X1ok4,22321
262
- defi_services/services/lending/venus_services.py,sha256=ZCvqqdWI4iIUKtzvLni68N8VHKVMSPmUk3UNuKhNKdQ,15455
263
- defi_services/services/lending/wepiggy_services.py,sha256=DbpygEmN5ZbS8NhAZU_4EpNH8k0I2MBj2IaBS-0PjME,15030
258
+ defi_services/services/lending/strike_service.py,sha256=XqKxfPGIDdwmzzWHqhe2KVcm6v83-lCtlH3nOxNYB44,13185
259
+ defi_services/services/lending/trava_services.py,sha256=j1gpZdJSudyAYRHAeQKX7iTKLGahIANDRvsMrz0bmZs,18994
260
+ defi_services/services/lending/uwu_services.py,sha256=IIaFFg1gJ3cqpQbvkglN_sWLQLy8qSBNR_1Zc3DC1TY,13736
261
+ defi_services/services/lending/valas_services.py,sha256=L_eWgziQm0qtL3-WBsRyCikYndSwKCrEo0ch8uT-WNc,22342
262
+ defi_services/services/lending/venus_services.py,sha256=QazU-GQf-DF8izle8yru1eKfjXkz-vpP7vCHjU1l8nk,15450
263
+ defi_services/services/lending/wepiggy_services.py,sha256=BMbP5Wtm571EyfKVytAL4NnTI6OR8_Xuu6HXaart2Vk,15051
264
264
  defi_services/services/lending/lending_info/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
265
265
  defi_services/services/lending/lending_info/arbitrum/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
266
266
  defi_services/services/lending/lending_info/arbitrum/aave_v3_arbitrum.py,sha256=8lpLYjXE2bKijTeWjRQH4XUFhG3s7df3J3r5oZEZcjA,3556
@@ -278,7 +278,7 @@ defi_services/services/lending/lending_info/bsc/__init__.py,sha256=47DEQpj8HBSa-
278
278
  defi_services/services/lending/lending_info/bsc/apeswap_bsc.py,sha256=cbS9R3ArW2ckZBiZOysOAlu3FoRX7xla8GUlUA6C0Q8,2110
279
279
  defi_services/services/lending/lending_info/bsc/cream_bsc.py,sha256=X7CoQxOfRQjsRjsxKhiSBm5W-MO9TXKTXP93oxtwA_c,8372
280
280
  defi_services/services/lending/lending_info/bsc/granary_bsc.py,sha256=OrD7P_YNRtDu0PN5QtCUYVTMojrIKfjQO-YKet_ZN0c,2322
281
- defi_services/services/lending/lending_info/bsc/liqee_bsc.py,sha256=tnsb1Hbl8uw3vlZhTqwlxi-rSDJQr_Ts8u7r8LnuX2o,4659
281
+ defi_services/services/lending/lending_info/bsc/liqee_bsc.py,sha256=eah38sX4DBwQTw-kPUEE_dP-VC8JDodwBDTkLuMEEns,5703
282
282
  defi_services/services/lending/lending_info/bsc/radiant_bsc.py,sha256=1hVXd78h1o_ckoWFtHVnLJB3w0dcORMAUeZor7RcRsk,2415
283
283
  defi_services/services/lending/lending_info/bsc/trava_bsc.py,sha256=TKV62KPn8kxZ3OB6q_aN7wedrmKdNO8_i8Xv000baLA,3845
284
284
  defi_services/services/lending/lending_info/bsc/valas_bsc.py,sha256=Fg6RwssuVflWVUHX_OIf0e2xVDz8zZHnzLA_r-7U4-4,3728
@@ -292,7 +292,7 @@ defi_services/services/lending/lending_info/ethereum/compound_v3_eth.py,sha256=m
292
292
  defi_services/services/lending/lending_info/ethereum/flux_eth.py,sha256=Iw-hvmFc5g9_--drvZCWxtoscvMIkr1mna4pTStrA-g,1270
293
293
  defi_services/services/lending/lending_info/ethereum/granary_eth.py,sha256=AAW4fzyFAUrdaJ86cUk6OJFQnbRghgun70ScWVUXAUM,2059
294
294
  defi_services/services/lending/lending_info/ethereum/iron_bank_eth.py,sha256=PfubpeLx1_qePdXcxUS8o6oN7SdB433eDSX3Njxyoa4,4606
295
- defi_services/services/lending/lending_info/ethereum/liqee_eth.py,sha256=1AqVijItk8yeSIbOwKje8jDrlL4GOF06SE_gzIYtwHo,4839
295
+ defi_services/services/lending/lending_info/ethereum/liqee_eth.py,sha256=hDdPEz6XxNq8ODPoNwiJLOtTXZiQaR9J5ZE5qiGyyqo,5718
296
296
  defi_services/services/lending/lending_info/ethereum/morpho_aave_v2_eth.py,sha256=WDIoK0HtEOVDVGdQ6ok22W-aTapTmQt3C5wvVnM2iC8,2595
297
297
  defi_services/services/lending/lending_info/ethereum/morpho_aave_v3_eth.py,sha256=8yATd43QS8mXPVTx6aME6G6x3BkmnsWKPrudEB_pbpI,3095
298
298
  defi_services/services/lending/lending_info/ethereum/morpho_compound_eth.py,sha256=q9ZpCb0qLi5amKtL7EL27NDxJ6FBkF14iXYEPhMebfo,1879
@@ -321,17 +321,26 @@ defi_services/services/lending/lending_info/polygon/compound_v3_polygon.py,sha25
321
321
  defi_services/services/lending/lending_info/polygon/wepiggy_polygon.py,sha256=2yj2M-VVNbxkGL4zEErIQGUdDIqlnA9gLOqGVX0stWM,2227
322
322
  defi_services/services/lending/lending_info/tron/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
323
323
  defi_services/services/lending/lending_info/tron/justlend_tron.py,sha256=2F4M8zFEE6-gqDKi82M-Xd6kcb2HP8-qmpNzDYorpXE,3741
324
+ defi_services/services/vault/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
325
+ defi_services/services/vault/trava_vault_services.py,sha256=9Sj5W6o7o478MKu7ZOUdqkTtPUzT59eS9yBcU8O4UrM,7705
326
+ defi_services/services/vault/vault_info/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
327
+ defi_services/services/vault/vault_info/bsc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
328
+ defi_services/services/vault/vault_info/bsc/trava_bsc.py,sha256=v1Nv5SmjDYLvCke_H5ZtgdjNXo0_9X-P5OQldezP0XM,1586
329
+ defi_services/services/vault/vault_info/ethereum/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
330
+ defi_services/services/vault/vault_info/ethereum/trava_eth.py,sha256=mHdKDZCMOnjHyf5-sLLAGcPtWhviJpVnmiQrcGeoKcs,776
331
+ defi_services/services/vault/vault_info/fantom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
332
+ defi_services/services/vault/vault_info/fantom/trava_ftm.py,sha256=dy8us4Lt0jrS9ZfaeXD4qz3OA4QwDPMRDkkxyNrJUUU,1165
324
333
  defi_services/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
325
334
  defi_services/utils/apy.py,sha256=zQ9wrID79uccLj9pJI5Q9KhTDWXeBt9JaEVjNnYmnyg,356
326
335
  defi_services/utils/convert_address.py,sha256=UdElOSrUKsKIB90sYbrRPUlO6KfIruf3Q6KiMaL8_4k,1070
327
336
  defi_services/utils/graph_operations.py,sha256=2-onMqflUqOrbVsy7JGFyeTMOcwTgPoZ3uGWruWMA_k,6271
328
- defi_services/utils/init_services.py,sha256=by5TgYBY3Dyl9Fqbf-FCeCYe5FmU28SJNxNWDjElvHY,387
337
+ defi_services/utils/init_services.py,sha256=RRJOLJzbpFPjQTzY4xIYcoQC_zKSY4cpETTePPnzLTk,599
329
338
  defi_services/utils/logger_utils.py,sha256=KxDlmaK9aoMOI1gdroRYjMm383myvFiWqW0iKV0SabY,777
330
339
  defi_services/utils/market_service.py,sha256=imPtPHBkpEx5JnhqeIWYqbCjsIEm8IKBYHNEy6rKjdU,723
331
340
  defi_services/utils/memory_storage.py,sha256=BOT8laB0iVSCGE-oDlpWJQLbSC6X2blKX4zuQbs4inc,851
332
341
  defi_services/utils/thread_proxy.py,sha256=5Z8biAyEReUkh3vfJSvEv7GwMe3CsE5M8CbghkQtePw,2951
333
- defi_state_querier-0.4.2.dist-info/LICENSE,sha256=6jmfxa8nUIwfKnzZUxAHJSJ_IS7h7mpbJq26cWjoo-o,1063
334
- defi_state_querier-0.4.2.dist-info/METADATA,sha256=3Q-t5cXscxNZcGpBoMkhp_P3MA_BAbEsa1FxkfhOOfs,4375
335
- defi_state_querier-0.4.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
336
- defi_state_querier-0.4.2.dist-info/top_level.txt,sha256=C-OTxHK6MknKK-nAbEzCPDUl1M6pktRhgJrmsozdf6g,14
337
- defi_state_querier-0.4.2.dist-info/RECORD,,
342
+ defi_state_querier-0.4.3.dist-info/LICENSE,sha256=6jmfxa8nUIwfKnzZUxAHJSJ_IS7h7mpbJq26cWjoo-o,1063
343
+ defi_state_querier-0.4.3.dist-info/METADATA,sha256=5WmD2szkqUcteZjpptzafAxkIdYecDoeGqywl-nbtxI,4375
344
+ defi_state_querier-0.4.3.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
345
+ defi_state_querier-0.4.3.dist-info/top_level.txt,sha256=C-OTxHK6MknKK-nAbEzCPDUl1M6pktRhgJrmsozdf6g,14
346
+ defi_state_querier-0.4.3.dist-info/RECORD,,
@@ -1,82 +0,0 @@
1
- import logging
2
-
3
- from pycosmicwrap import CosmicWrap
4
- from query_state_lib.base.mappers.eth_json_rpc_mapper import EthJsonRpc
5
-
6
- from defi_services.constants.query_constant import Query
7
-
8
- logger = logging.getLogger("CosmosStateQuerier")
9
-
10
-
11
- class CosmosStateQuerier:
12
- def __init__(self, rpc_uri, lcd_uri, denom="cosmos"):
13
- self.client_querier = CosmicWrap(rpc=rpc_uri, lcd=lcd_uri, denom=denom)
14
-
15
- @staticmethod
16
- def get_function_info(fn_name: str, fn_paras: list = None):
17
- if fn_paras is None:
18
- fn_paras = []
19
- data = {
20
- "function": fn_name,
21
- "params": fn_paras
22
- }
23
-
24
- return data
25
-
26
- def query_state_data(self, queries: dict, batch_size: int = 100, workers: int = 5, ignore_error: bool = False):
27
- """
28
- Args:
29
- queries: dict - defi state queries
30
- - key: str - id of query
31
- - value: dict - input of query
32
- {
33
- function: str - name of the function,
34
- params: list - list parameters of function
35
- }
36
- batch_size: int - number of query in each batch queries
37
- workers: int - maximum number of vCPU used in queries
38
- ignore_error: bool - ignore error when decode result or not
39
-
40
- Return:
41
- + A dictionary result of queries
42
- - key: str - id of query
43
- - value: result of query
44
- """
45
- list_rpc_call, list_call_id = [], []
46
- for key, value in queries.items():
47
- fn_paras = value.get(Query.params)
48
- fn_name = value.get(Query.function)
49
- eth_call = self.add_rpc_call(fn_name=fn_name, fn_paras=fn_paras, call_id=key)
50
- list_call_id.append(key)
51
- list_rpc_call.append(eth_call)
52
-
53
- response_data = self.client_querier.sent_batch_to_provider(list_rpc_call, batch_size, workers)
54
- decoded_data = self.decode_response_data(response_data, list_call_id, ignore_error=ignore_error)
55
- return decoded_data
56
-
57
- @staticmethod
58
- def add_rpc_call(fn_name: str, fn_paras: list = None, call_id: str = None):
59
- solana_call = EthJsonRpc(method=fn_name, params=fn_paras, id=call_id)
60
- return solana_call
61
-
62
- @staticmethod
63
- def decode_response_data(response_data: dict, list_call_id: list, ignore_error=False):
64
- decoded_data = {}
65
- for call_id in list_call_id:
66
- try:
67
- response_datum = response_data.get(call_id)
68
- decoded_datum = response_datum.decode_result()
69
- except Exception as e:
70
- if not ignore_error:
71
- logger.error(f"An exception when decode data from provider: {e}")
72
- raise
73
- else:
74
- logger.error(f"[Ignored] An exception when decode data from provider: {e}")
75
- continue
76
- if isinstance(decoded_datum, int):
77
- decoded_data[call_id] = decoded_datum
78
- elif len(decoded_datum) == 1:
79
- decoded_data[call_id] = decoded_datum[0]
80
- else:
81
- decoded_data[call_id] = decoded_datum
82
- return decoded_data
@@ -1,46 +0,0 @@
1
- from defi_services.constants.token_constant import Token
2
- from defi_services.jobs.queriers.cosmos_state_querier import CosmosStateQuerier
3
-
4
-
5
- class CosmosTokenServices:
6
- def __init__(self, state_service: CosmosStateQuerier, chain_id: str = "solana"):
7
- self.chain_id = chain_id
8
- self.state_service = state_service
9
-
10
- def get_service_info(self):
11
- info = {
12
- "token": {
13
- "chain_id": self.chain_id,
14
- "type": "token"
15
- }
16
- }
17
- return info
18
-
19
- def get_function_info(self, wallet: str, token: str):
20
- result = self.get_function_balance_info(wallet, token)
21
- return result
22
-
23
- def get_function_balance_info(self, wallet, token):
24
- key = f"balanceOf_{wallet}_{token}".lower()
25
- if token == Token.native_token:
26
- params = [wallet]
27
- rpc_call = self.state_service.get_function_info('getBalance', params)
28
- else:
29
- params = [wallet, {"mint": token}, {"encoding": "jsonParsed"}]
30
- rpc_call = self.state_service.get_function_info("getTokenAccountsByOwner", params)
31
- return {key: rpc_call}
32
-
33
- @staticmethod
34
- def get_data(wallet, token, decoded_data, token_prices):
35
- key = f"balanceOf_{wallet}_{token}".lower()
36
- data = decoded_data.get(key)
37
- token_price = token_prices.get(token, 1)
38
- if token == Token.native_token:
39
- balance = data.get("value", 0) * token_price / 10**9
40
- return balance
41
- balance = 0
42
- for item in data.get('value'):
43
- balance_info = item.get('account', {}).get('data', {}).get('parsed').get('info').get('tokenAmount')
44
- balance += balance_info.get("uiAmount", 0) * token_price
45
-
46
- return balance