defi-state-querier 0.3.1__py3-none-any.whl → 0.3.4__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 CHANGED
@@ -1 +1 @@
1
- __version__ = "0.3.1"
1
+ __version__ = "0.3.4"
@@ -78,7 +78,8 @@ class LendingServices:
78
78
  polygon = {
79
79
  Lending.aave_v2: AaveV2StateService,
80
80
  Lending.aave_v3: AaveV3StateService,
81
- Lending.wepiggy: WepiggyStateService
81
+ Lending.wepiggy: WepiggyStateService,
82
+ Lending.compound_v3: CompoundV3StateService
82
83
  }
83
84
 
84
85
  optimism = {
@@ -93,7 +94,8 @@ class LendingServices:
93
94
  Lending.aave_v3: AaveV3StateService,
94
95
  Lending.wepiggy: WepiggyStateService,
95
96
  Lending.granary: GranaryStateService,
96
- Lending.silo: SiloStateService
97
+ Lending.silo: SiloStateService,
98
+ Lending.compound_v3: CompoundV3StateService
97
99
  }
98
100
 
99
101
  tron = {
@@ -8,12 +8,16 @@ from defi_services.constants.time_constant import TimeConstants
8
8
  from defi_services.constants.token_constant import Token
9
9
  from defi_services.jobs.queriers.state_querier import StateQuerier
10
10
  from defi_services.services.lending.compound_service import CompoundStateService
11
+ from defi_services.services.lending.lending_info.arbitrum.compound_v3_arbitrum import COMPOUND_V3_ARBITRUM
11
12
  from defi_services.services.lending.lending_info.ethereum.compound_v3_eth import COMPOUND_V3_ETH
13
+ from defi_services.services.lending.lending_info.polygon.compound_v3_polygon import COMPOUND_V3_POLYGON
12
14
 
13
15
 
14
16
  class CompoundV3Info:
15
17
  mapping = {
16
- Chain.ethereum: COMPOUND_V3_ETH
18
+ Chain.ethereum: COMPOUND_V3_ETH,
19
+ Chain.polygon: COMPOUND_V3_POLYGON,
20
+ Chain.arbitrum: COMPOUND_V3_ARBITRUM
17
21
  }
18
22
 
19
23
 
@@ -0,0 +1,61 @@
1
+ COMPOUND_V3_ARBITRUM = {
2
+ "name": "Compound V3 Lending Pool",
3
+ "rewardToken": "0x354a6da3fcde098f8389cad84b0182725c6c91de",
4
+ "rewardAddress": "0x88730d254a2f7e6ac8388c3198afd694ba9f7fae",
5
+ "factoryAddress": "0xe2aa5194e45b043afdd6e98f467c0b1c13484ae9",
6
+ "poolToken": "0x354a6da3fcde098f8389cad84b0182725c6c91de",
7
+ "type": "LENDING_POOL",
8
+ "forked": "compound-v3",
9
+ "reservesList": {
10
+ "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8": {
11
+ "comet": "0xa5edbdd9646f8dff606d7448e414884c7d905dca",
12
+ "assets": {
13
+ "0x912ce59144191c1204e64559fe8253a0e49e6548": {
14
+ "priceFeed": "0xb2a824043730fe05f3da2efafa1cbbe83fa548d6",
15
+ "loanToValue": 0.55,
16
+ "liquidationThreshold": 0.6
17
+ },
18
+ "0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a": {
19
+ "priceFeed": "0xdb98056fecfff59d032ab628337a4887110df3db",
20
+ "loanToValue": 0.4,
21
+ "liquidationThreshold": 0.45
22
+ },
23
+ "0x82af49447d8a07e3bd95bd0d56f35241523fbab1": {
24
+ "priceFeed": "0x639fe6ab55c921f74e7fac1ee960c0b6293ba612",
25
+ "loanToValue": 0.78,
26
+ "liquidationThreshold": 0.85
27
+ },
28
+ "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f": {
29
+ "priceFeed": "0xd0c7101eacbb49f3decccc166d238410d6d46d57",
30
+ "loanToValue": 0.7,
31
+ "liquidationThreshold": 0.77
32
+ }
33
+ }
34
+ },
35
+ "0xaf88d065e77c8cc2239327c5edb3a432268e5831": {
36
+ "comet": "0x9c4ec768c28520b50860ea7a15bd7213a9ff58bf",
37
+ "assets": {
38
+ "0x912ce59144191c1204e64559fe8253a0e49e6548": {
39
+ "priceFeed": "0xb2a824043730fe05f3da2efafa1cbbe83fa548d6",
40
+ "loanToValue": 0.55,
41
+ "liquidationThreshold": 0.6
42
+ },
43
+ "0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a": {
44
+ "priceFeed": "0xdb98056fecfff59d032ab628337a4887110df3db",
45
+ "loanToValue": 0.4,
46
+ "liquidationThreshold": 0.45
47
+ },
48
+ "0x82af49447d8a07e3bd95bd0d56f35241523fbab1": {
49
+ "priceFeed": "0x639fe6ab55c921f74e7fac1ee960c0b6293ba612",
50
+ "loanToValue": 0.78,
51
+ "liquidationThreshold": 0.85
52
+ },
53
+ "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f": {
54
+ "priceFeed": "0xd0c7101eacbb49f3decccc166d238410d6d46d57",
55
+ "loanToValue": 0.7,
56
+ "liquidationThreshold": 0.77
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,41 @@
1
+ COMPOUND_V3_POLYGON = {
2
+ "name": "Compound V3 Lending Pool",
3
+ "rewardToken": "0x8505b9d2254a7ae468c0e9dd10ccea3a837aef5c",
4
+ "rewardAddress": "0x45939657d1ca34a8fa39a924b71d28fe8431e581",
5
+ "factoryAddress": "0x2f9e3953b2ef89fa265f2a32ed9f80d00229125b",
6
+ "poolToken": "0x8505b9d2254a7ae468c0e9dd10ccea3a837aef5c",
7
+ "type": "LENDING_POOL",
8
+ "forked": "compound-v3",
9
+ "reservesList": {
10
+ "0x2791bca1f2de4661ed88a30c99a7a9449aa84174": {
11
+ "comet": "0xf25212e676d1f7f89cd72ffee66158f541246445",
12
+ "assets": {
13
+ "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619": {
14
+ "priceFeed": "0xf9680d99d6c9589e2a93a78a04a279e509205945",
15
+ "loanToValue": 0.775,
16
+ "liquidationThreshold": 0.825
17
+ },
18
+ "0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6": {
19
+ "priceFeed": "0xde31f8bfbd8c84b5360cfacca3539b938dd78ae6",
20
+ "loanToValue": 0.7,
21
+ "liquidationThreshold": 0.75
22
+ },
23
+ "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270": {
24
+ "priceFeed": "0xab594600376ec9fd91f8e885dadf0ce036862de0",
25
+ "loanToValue": 0.65,
26
+ "liquidationThreshold": 0.7
27
+ },
28
+ "0xfa68fb4628dff1028cfec22b4162fccd0d45efb6": {
29
+ "priceFeed": "0x5d37e4b374e6907de8fc7fb33ee3b0af403c7403",
30
+ "loanToValue": 0.55,
31
+ "liquidationThreshold": 0.6
32
+ },
33
+ "0x3a58a54c066fdc0f2d55fc9c89f0415c92ebf3c4": {
34
+ "priceFeed": "0x97371df4492605486e23da797fa68e55fc38a13f",
35
+ "loanToValue": 0.6,
36
+ "liquidationThreshold": 0.65
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
@@ -180,8 +180,6 @@ class OnyxStateService(CompoundStateService):
180
180
 
181
181
  for token, value in reserves_info.items():
182
182
  underlying = token
183
- ctoken = value.get('cToken')
184
- ctokens.append(Web3.toChecksumAddress(ctoken))
185
183
 
186
184
  if token == Token.native_token:
187
185
  underlying = Token.wrapped_token.get(self.chain_id)
@@ -191,9 +189,9 @@ class OnyxStateService(CompoundStateService):
191
189
  rpc_calls[underlying_decimals_key] = self.state_service.get_function_info(
192
190
  underlying, ERC20_ABI, "decimals", [], block_number
193
191
  )
194
- key = f"oTokenBalancesAll_{self.name}_{wallet}_{block_number}".lower()
195
- rpc_calls[key] = self.get_lens_function_info(
196
- "oTokenBalancesAll", [ctokens, Web3.toChecksumAddress(wallet)])
192
+ key = f"oTokenBalances_{self.name}_{wallet}_{token}_{block_number}".lower()
193
+ rpc_calls[key] = self.get_lens_function_info(
194
+ "oTokenBalances", [value.get("cToken"), Web3.toChecksumAddress(wallet)])
197
195
  return rpc_calls
198
196
 
199
197
  def calculate_wallet_deposit_borrow_balance(
@@ -210,14 +208,9 @@ class OnyxStateService(CompoundStateService):
210
208
  token_prices = {}
211
209
  result = {}
212
210
  total_borrow, total_collateral = 0, 0
213
- key = f"oTokenBalancesAll_{self.name}_{wallet}_{block_number}".lower()
214
- ctoken_balance = {}
215
- for item in decoded_data.get(key):
216
- ctoken_balance[item[0]] = {
217
- "borrow": item[2],
218
- "supply": item[3]
219
- }
220
211
  for token, value in reserves_info.items():
212
+ key = f"oTokenBalances_{self.name}_{wallet}_{token}_{block_number}".lower()
213
+ ctoken_balance = decoded_data.get(key)
221
214
  data = {}
222
215
  underlying = token
223
216
  ctoken = value.get("cToken")
@@ -226,12 +219,8 @@ class OnyxStateService(CompoundStateService):
226
219
 
227
220
  get_decimals_id = f"decimals_{underlying}_{block_number}".lower()
228
221
  decimals = decoded_data.get(get_decimals_id, 0)
229
- if decimals:
230
- deposit_amount = ctoken_balance[ctoken]["supply"] / 10 ** decimals
231
- borrow_amount = ctoken_balance[ctoken]["borrow"] / 10 ** decimals
232
- else:
233
- deposit_amount = ctoken_balance[ctoken]["supply"]
234
- borrow_amount = ctoken_balance[ctoken]["borrow"]
222
+ deposit_amount = ctoken_balance[3] / 10 ** decimals
223
+ borrow_amount = ctoken_balance[2] / 10 ** decimals
235
224
  data[token] = {
236
225
  "borrow_amount": borrow_amount,
237
226
  "deposit_amount": deposit_amount,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: defi-state-querier
3
- Version: 0.3.1
3
+ Version: 0.3.4
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=r4xAFihOf72W9TD-lpMi6ntWSTKTP2SlzKP1ytkjRbI,22
1
+ defi_services/__init__.py,sha256=oYLGMpySamd16KLiaBTfRyrAS7_oyp-TOEHmzmeumwg,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
@@ -109,7 +109,7 @@ defi_services/constants/time_constant.py,sha256=bC-0pYnfIFFR_0iVvkxhfyHfOclWNw9O
109
109
  defi_services/constants/token_constant.py,sha256=AZS5kzQYAVrMRwmQsRCm3lQzfSEHAAjdsngBuwFFwh0,2586
110
110
  defi_services/constants/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
111
111
  defi_services/constants/entities/lending_constant.py,sha256=uUb3CnIlZP0lqdVPUt4IdlUXZwNpsMVDTmqMw0NK47g,1009
112
- defi_services/constants/entities/lending_services.py,sha256=uUF-XcXWcAs-BPmBFc7WxPSPjgkw9lKDKmoGac-CUHs,4803
112
+ defi_services/constants/entities/lending_services.py,sha256=XP-Ck9bKmvNvKGOXBx_Xrg8wbD-CkCQHDFpWNjPbyHM,4909
113
113
  defi_services/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
114
114
  defi_services/jobs/processors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
115
115
  defi_services/jobs/processors/multi_state_processor.py,sha256=20pYx-vpOvJwYNM4NvRrc149V4DM_RZGhJ6EQDQ0oJw,4749
@@ -131,7 +131,7 @@ defi_services/services/lending/aave_v2_services.py,sha256=R7_y2ZvlANhw5q1RpQtwFK
131
131
  defi_services/services/lending/aave_v3_services.py,sha256=oyJZ76nuC5oMQoUAfdRV7phJ1rlAOXiPu-o9Wr2Mt4U,16025
132
132
  defi_services/services/lending/apeswap_services.py,sha256=HPiCFbUK-xImEGbeeNkfe8wcR11EW6aTw1dm7YawB0g,4530
133
133
  defi_services/services/lending/compound_service.py,sha256=WDN7Aq0uuVGfq8jqkX1DOn7SsZsXajU4cxNgwugQrUo,21050
134
- defi_services/services/lending/compound_v3_services.py,sha256=szMuzat1dBiCtteyG96nwMIZu6-s8DJxcjZYdEox51U,16721
134
+ defi_services/services/lending/compound_v3_services.py,sha256=Rg4zv688n2bMmzvCQGWzQR7lDJkYenV3ZHIMYef_1rM,17022
135
135
  defi_services/services/lending/cream_services.py,sha256=vtah0kMHAxztenWbJp4CxEcBMF0XUBglGRk6p9d-oiU,1644
136
136
  defi_services/services/lending/flux_services.py,sha256=VHca92UlEfu5unmbx9O7LBeoQvF8XJcwZl4ycUFCx8c,11791
137
137
  defi_services/services/lending/geist_services.py,sha256=UI5D-MbMqplrt7D4krSFdpaREKOT81k8boD_XhGGpUQ,1035
@@ -142,7 +142,7 @@ defi_services/services/lending/liqee_service.py,sha256=-NIrH4DR7UQRw8NfzRMRh4Phc
142
142
  defi_services/services/lending/morpho_aave_v2_services.py,sha256=2-zMbCwL9x3Py57wiJJtCNVXhe8PRezhukukXzATtgE,8361
143
143
  defi_services/services/lending/morpho_aave_v3_services.py,sha256=8oVuB1N8TRBbCtaICNeSypk46-X-AvWqWeMA_kl6lrU,8098
144
144
  defi_services/services/lending/morpho_compound_services.py,sha256=VcVs3kQn0teXxu7t7gF9ilOFwGv4g5O7Ql37K8pC2UI,14771
145
- defi_services/services/lending/onyx_service.py,sha256=77-TDZriZvBjRoFZaTtc7dH5e-WbHqtHdQr5O3zphiE,15013
145
+ defi_services/services/lending/onyx_service.py,sha256=rEw8J5QwX3NK-WrhkL9eq8_Pr9GH30uruB25kSCCiEg,14593
146
146
  defi_services/services/lending/radiant_v2_services.py,sha256=U23LB571IxZcK11O5_vVEkB1BGDeI03MPN4uI-aSXOg,3036
147
147
  defi_services/services/lending/silo_services.py,sha256=5xGBVbT_ZsWxf2Q7e_hDd9WaYJ_xFBdfAQW7s9xETcI,16653
148
148
  defi_services/services/lending/spark_services.py,sha256=68_egY0yOT7YIOVbd8rbHJBJEsL0sOr0zSsTSdw0BUY,1042
@@ -155,6 +155,7 @@ defi_services/services/lending/wepiggy_services.py,sha256=DvpWA7Nk6-TP-l7dqecrv9
155
155
  defi_services/services/lending/lending_info/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
156
156
  defi_services/services/lending/lending_info/arbitrum/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
157
157
  defi_services/services/lending/lending_info/arbitrum/aave_v3_arbitrum.py,sha256=8lpLYjXE2bKijTeWjRQH4XUFhG3s7df3J3r5oZEZcjA,3556
158
+ defi_services/services/lending/lending_info/arbitrum/compound_v3_arbitrum.py,sha256=lkDHcAee5_EWWbh4t_iiO5fRQqnpt2JkY6ZEWE4kTsw,2766
158
159
  defi_services/services/lending/lending_info/arbitrum/granary_arbitrum.py,sha256=AxMfKkbOhHGObzaDNNqTDv52WpbGA4MIyzZCItXvicg,3355
159
160
  defi_services/services/lending/lending_info/arbitrum/radiant_arbitrum.py,sha256=1iXoZml8c1iVdshqzZ7YRVcS5lc2RK6A2AnPfO4s49U,2662
160
161
  defi_services/services/lending/lending_info/arbitrum/silo_arbitrum.py,sha256=XJWbE3xmIiNP44OF_ElXZ8m4FMIoGpesX_HgoG8AKLo,6513
@@ -207,6 +208,7 @@ defi_services/services/lending/lending_info/optimism/wepiggy_optimism.py,sha256=
207
208
  defi_services/services/lending/lending_info/polygon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
208
209
  defi_services/services/lending/lending_info/polygon/aave_v2_polygon.py,sha256=BIxMIO3iVDZNat7vh0K3wu9Bm5vqwthmCAHA0gEQG84,4536
209
210
  defi_services/services/lending/lending_info/polygon/aave_v3_polygon.py,sha256=2qaU-H8o7-tZRDRSVua72GOwJTUBDpYdVW5DekKMIvs,6907
211
+ defi_services/services/lending/lending_info/polygon/compound_v3_polygon.py,sha256=kgXVIHkrqtnTJ_Sy73TPO9h-BJV5yfRehTR9nfWH6Po,1842
210
212
  defi_services/services/lending/lending_info/polygon/wepiggy_polygon.py,sha256=2yj2M-VVNbxkGL4zEErIQGUdDIqlnA9gLOqGVX0stWM,2227
211
213
  defi_services/services/lending/lending_info/tron/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
212
214
  defi_services/services/lending/lending_info/tron/justlend_tron.py,sha256=2F4M8zFEE6-gqDKi82M-Xd6kcb2HP8-qmpNzDYorpXE,3741
@@ -219,8 +221,8 @@ defi_services/utils/logger_utils.py,sha256=KxDlmaK9aoMOI1gdroRYjMm383myvFiWqW0iK
219
221
  defi_services/utils/market_service.py,sha256=imPtPHBkpEx5JnhqeIWYqbCjsIEm8IKBYHNEy6rKjdU,723
220
222
  defi_services/utils/memory_storage.py,sha256=BOT8laB0iVSCGE-oDlpWJQLbSC6X2blKX4zuQbs4inc,851
221
223
  defi_services/utils/thread_proxy.py,sha256=5Z8biAyEReUkh3vfJSvEv7GwMe3CsE5M8CbghkQtePw,2951
222
- defi_state_querier-0.3.1.dist-info/LICENSE,sha256=6jmfxa8nUIwfKnzZUxAHJSJ_IS7h7mpbJq26cWjoo-o,1063
223
- defi_state_querier-0.3.1.dist-info/METADATA,sha256=cc0D0LnQyKLxyI3yP3jfae-KuMTwcdZl9V2CFqJFk-0,4370
224
- defi_state_querier-0.3.1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
225
- defi_state_querier-0.3.1.dist-info/top_level.txt,sha256=C-OTxHK6MknKK-nAbEzCPDUl1M6pktRhgJrmsozdf6g,14
226
- defi_state_querier-0.3.1.dist-info/RECORD,,
224
+ defi_state_querier-0.3.4.dist-info/LICENSE,sha256=6jmfxa8nUIwfKnzZUxAHJSJ_IS7h7mpbJq26cWjoo-o,1063
225
+ defi_state_querier-0.3.4.dist-info/METADATA,sha256=Xmd6SwtpzDTZHCtrLAiWXuIIVpXCguVYQb_XicEE0Ls,4370
226
+ defi_state_querier-0.3.4.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
227
+ defi_state_querier-0.3.4.dist-info/top_level.txt,sha256=C-OTxHK6MknKK-nAbEzCPDUl1M6pktRhgJrmsozdf6g,14
228
+ defi_state_querier-0.3.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: bdist_wheel (0.41.3)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5