defi-state-querier 0.5.22__py3-none-any.whl → 0.5.24__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/abis/lending/ionic/__init__.py +0 -0
- defi_services/abis/lending/ionic/ionic_ctoken_abi.py +1108 -0
- defi_services/abis/lending/moonwell/__init__.py +0 -0
- defi_services/abis/lending/moonwell/moonwell_comptroller_abi.py +1500 -0
- defi_services/abis/lending/moonwell/moonwell_ctoken_abi.py +1431 -0
- defi_services/constants/chain_constant.py +2 -1
- defi_services/constants/entities/lending_constant.py +10 -5
- defi_services/constants/entities/lending_services.py +17 -4
- defi_services/services/lending/granary_services.py +3 -1
- defi_services/services/lending/ionic_service.py +167 -0
- defi_services/services/lending/lending_info/base/granary_base.py +62 -0
- defi_services/services/lending/lending_info/base/ionic_base.py +173 -0
- defi_services/services/lending/lending_info/base/moonwell_base.py +80 -2
- defi_services/services/lending/lending_info/base/radiant_v2_base.py +54 -0
- defi_services/services/lending/lending_info/base/sonne_base.py +53 -0
- defi_services/services/lending/lending_info/base/zerolend_base.py +99 -99
- defi_services/services/lending/moonwell_service.py +120 -0
- defi_services/services/lending/radiant_v2_services.py +3 -1
- defi_services/services/lending/sonne_service.py +64 -0
- defi_services/services/lending/zerolend_services.py +1 -1
- {defi_state_querier-0.5.22.dist-info → defi_state_querier-0.5.24.dist-info}/METADATA +1 -1
- {defi_state_querier-0.5.22.dist-info → defi_state_querier-0.5.24.dist-info}/RECORD +26 -14
- {defi_state_querier-0.5.22.dist-info → defi_state_querier-0.5.24.dist-info}/LICENSE +0 -0
- {defi_state_querier-0.5.22.dist-info → defi_state_querier-0.5.24.dist-info}/WHEEL +0 -0
- {defi_state_querier-0.5.22.dist-info → defi_state_querier-0.5.24.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
SONNE_BASE = {
|
2
|
+
"name": "Sonne Finance Lending Pool",
|
3
|
+
"rewardToken": "0x22a2488fe295047ba13bd8cccdbc8361dbd8cf7c",
|
4
|
+
"comptrollerAddress": "0x1db2466d9f5e10d7090e7152b68d62703a2245f0",
|
5
|
+
"lensAddress": "",
|
6
|
+
"poolToken": "0x22a2488fe295047ba13bd8cccdbc8361dbd8cf7c",
|
7
|
+
"type": "LENDING_POOL",
|
8
|
+
"forked": "compound",
|
9
|
+
"reservesList": {
|
10
|
+
"0x50c5725949a6f0c72e6c4a641f24049a917db0cb": {
|
11
|
+
"cToken": "0xb864ba2aab1f53bc3af7ae49a318202dd3fd54c2",
|
12
|
+
"exchangeRate": 0.023083559152306903,
|
13
|
+
"liquidationThreshold": 0.85,
|
14
|
+
"loanToValue": 0.85
|
15
|
+
},
|
16
|
+
"0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca": {
|
17
|
+
"cToken": "0x225886c9beb5eee254f79d58bbd80cf9f200d4d0",
|
18
|
+
"exchangeRate": 0.0250658201249789,
|
19
|
+
"liquidationThreshold": 0.85,
|
20
|
+
"loanToValue": 0.85
|
21
|
+
},
|
22
|
+
"0x4200000000000000000000000000000000000006": {
|
23
|
+
"cToken": "0x5f5c479fe590cd4442a05ae4a941dd991a633b8e",
|
24
|
+
"exchangeRate": 0.020423843905669113,
|
25
|
+
"liquidationThreshold": 0.7,
|
26
|
+
"loanToValue": 0.7
|
27
|
+
},
|
28
|
+
"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913": {
|
29
|
+
"cToken": "0xfd68f92b45b633bbe0f475294c1a86aecd62985a",
|
30
|
+
"exchangeRate": 0.0234603622944371,
|
31
|
+
"liquidationThreshold": 0.85,
|
32
|
+
"loanToValue": 0.85
|
33
|
+
},
|
34
|
+
"0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22": {
|
35
|
+
"cToken": "0x6c91beeceedda2089307fab818e12757948bf489",
|
36
|
+
"exchangeRate": 0.02066126030128981,
|
37
|
+
"liquidationThreshold": 0.65,
|
38
|
+
"loanToValue": 0.65
|
39
|
+
},
|
40
|
+
"0xc1cba3fcea344f92d9239c08c0568f6f2f0ee452": {
|
41
|
+
"cToken": "0x7a6468053cdcd7e8fe507d7edb77336f5057d206",
|
42
|
+
"exchangeRate": 0.020397422935249394,
|
43
|
+
"liquidationThreshold": 0.6,
|
44
|
+
"loanToValue": 0.6
|
45
|
+
},
|
46
|
+
"0x940181a94a35a4569e4529a3cdfb74e38fd98631": {
|
47
|
+
"cToken": "0xfa78196ace4048c4ccce6d3d97890d7b6c8f59da",
|
48
|
+
"exchangeRate": 0.021779276987867538,
|
49
|
+
"liquidationThreshold": 0.3,
|
50
|
+
"loanToValue": 0.3
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
@@ -7,103 +7,103 @@ ZEROLEND_BASE = {
|
|
7
7
|
"type": "LENDING_POOL",
|
8
8
|
"forked": "aave-v3",
|
9
9
|
"reservesList": {
|
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
|
-
|
10
|
+
"0x4200000000000000000000000000000000000006": {
|
11
|
+
"tToken": "0x4677201dbb575d485ad69e5c5b1e7e7888c3ab29",
|
12
|
+
"sdToken": "0xb375197dc09e06382a05be306df6a551f08a3b7b",
|
13
|
+
"dToken": "0xfec889b48d8cb51bfd988bf211d4cfe854af085c",
|
14
|
+
"loanToValue": 0.8,
|
15
|
+
"liquidationThreshold": 0.825
|
16
|
+
},
|
17
|
+
"0x940181a94a35a4569e4529a3cdfb74e38fd98631": {
|
18
|
+
"tToken": "0x3c2b86d6308c24632bb8716ed013567c952b53ae",
|
19
|
+
"sdToken": "0xe37b9dd1cdf9f411a9f6bb8d0c1fa2af6b960a47",
|
20
|
+
"dToken": "0x98ef767a6184323bf2788a0936706432698d3400",
|
21
|
+
"loanToValue": 0.8,
|
22
|
+
"liquidationThreshold": 0.9
|
23
|
+
},
|
24
|
+
"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913": {
|
25
|
+
"tToken": "0xd09600475435cab0e40dabdb161fb5a3311efcb3",
|
26
|
+
"sdToken": "0x1d32fd6f0dda3f3ef74e5bc3da3166febdd698b5",
|
27
|
+
"dToken": "0xa397391b718f3c7f21c63e8beb09b66607419c38",
|
28
|
+
"loanToValue": 0.8,
|
29
|
+
"liquidationThreshold": 0.85
|
30
|
+
},
|
31
|
+
"0x0a27e060c0406f8ab7b64e3bee036a37e5a62853": {
|
32
|
+
"tToken": "0x2e1f66d89a95a88afe594f6ed936b1ca76efb74c",
|
33
|
+
"sdToken": "0x6017b28d5b8a46474673ad7a4914318ad5e6db5e",
|
34
|
+
"dToken": "0x5e4043a302a827bfa4cb51fa18c66109683d08ee",
|
35
|
+
"loanToValue": 0.0,
|
36
|
+
"liquidationThreshold": 0.0
|
37
|
+
},
|
38
|
+
"0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22": {
|
39
|
+
"tToken": "0x1f3f89ffc8cd686cecc845b5f52246598f1e3196",
|
40
|
+
"sdToken": "0x65d178978a458ff3ca39bc3df3ad9d0a0957d1bd",
|
41
|
+
"dToken": "0x371cfa36ef5e33c46d1e0ef2111862d5ff9f78cd",
|
42
|
+
"loanToValue": 0.8,
|
43
|
+
"liquidationThreshold": 0.825
|
44
|
+
},
|
45
|
+
"0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf": {
|
46
|
+
"tToken": "0x4433cf6e9458027ff0833f22a3cf73318908e48e",
|
47
|
+
"sdToken": "0xf29fab0a70ad1f8aa88b2b389d4c84083f73301e",
|
48
|
+
"dToken": "0x7e1b2ac5339e8bba83c67a9444e9ee981c46ce42",
|
49
|
+
"loanToValue": 0.7,
|
50
|
+
"liquidationThreshold": 0.75
|
51
|
+
},
|
52
|
+
"0x6cdcb1c4a4d1c3c6d054b27ac5b77e89eafb971d": {
|
53
|
+
"tToken": "0xb6ccd85f92fb9a8bbc99b55091855714aaeebfee",
|
54
|
+
"sdToken": "0xcd18e7d74d8ae9228c3405149725d7813363fcde",
|
55
|
+
"dToken": "0x80e898e5ad81940fe094ac3159b08a3494198570",
|
56
|
+
"loanToValue": 0.8,
|
57
|
+
"liquidationThreshold": 0.95
|
58
|
+
},
|
59
|
+
"0x1097dfe9539350cb466df9ca89a5e61195a520b0": {
|
60
|
+
"tToken": "0x89bb87137afe8bae03f4ab286de667a513ceebdd",
|
61
|
+
"sdToken": "0x6bb22ac00925f75e0a089178835cb98239b0ad30",
|
62
|
+
"dToken": "0x6b0b75c223ddd146b213ef4e35bc61d1de7b46a4",
|
63
|
+
"loanToValue": 0.8,
|
64
|
+
"liquidationThreshold": 0.95
|
65
|
+
},
|
66
|
+
"0x04d5ddf5f3a8939889f11e97f8c4bb48317f1938": {
|
67
|
+
"tToken": "0x9357e7f1c49e6d0094287f882fc47774fd3bc291",
|
68
|
+
"sdToken": "0xa5760c5e8927ddff5fe77719890522d5432a7c3a",
|
69
|
+
"dToken": "0x19887e3d984cbbd75805dfdbc9810efe923b897f",
|
70
|
+
"loanToValue": 0.75,
|
71
|
+
"liquidationThreshold": 0.8
|
72
|
+
},
|
73
|
+
"0xe31ee12bdfdd0573d634124611e85338e2cbf0cf": {
|
74
|
+
"tToken": "0xf382e613ff8ee69f3f7557424e7cfd48792286c5",
|
75
|
+
"sdToken": "0x1f69f0a0204f059527eae5df451460a1cbe4b54f",
|
76
|
+
"dToken": "0x591d8d962278bd35182decb2852de50f83dd29d0",
|
77
|
+
"loanToValue": 0.75,
|
78
|
+
"liquidationThreshold": 0.9
|
79
|
+
},
|
80
|
+
"0xdbfefd2e8460a6ee4955a68582f85708baea60a3": {
|
81
|
+
"tToken": "0xe48d605bb303f7e88561a9b09640af4323c5b921",
|
82
|
+
"sdToken": "0xe126b8ecaf14c5485b31dfdc29241d0f9141be73",
|
83
|
+
"dToken": "0xd6290195faab4b78f43eb38554e36f243218f334",
|
84
|
+
"loanToValue": 0.75,
|
85
|
+
"liquidationThreshold": 0.9
|
86
|
+
},
|
87
|
+
"0xf469fbd2abcd6b9de8e169d128226c0fc90a012e": {
|
88
|
+
"tToken": "0x4759417285100f0a11846304af76d1ed8d9ad253",
|
89
|
+
"sdToken": "0xe4616a793e4533c1b3069afd70161c31fd323b5a",
|
90
|
+
"dToken": "0x95beb0d11951e3e4140f1265b3df76f685740e18",
|
91
|
+
"loanToValue": 0.75,
|
92
|
+
"liquidationThreshold": 0.9
|
93
|
+
},
|
94
|
+
"0x7fcd174e80f264448ebee8c88a7c4476aaf58ea6": {
|
95
|
+
"tToken": "0x134efc999957fc7984c5ab91bc7ec0f0d373b71e",
|
96
|
+
"sdToken": "0xe3f7084849029144233f00036611245d638033ed",
|
97
|
+
"dToken": "0x1c7f3d9d02ad5fefd1a8feed65957be1ea5f649c",
|
98
|
+
"loanToValue": 0.8,
|
99
|
+
"liquidationThreshold": 0.9
|
100
|
+
},
|
101
|
+
"0xecac9c5f704e954931349da37f60e39f515c11c1": {
|
102
|
+
"tToken": "0xbbb4080b4d4510ace168d1ff8c5cc256ab74e1fb",
|
103
|
+
"sdToken": "0x33a0a85a3f184e75333b8c25307acfb9a5e4cb57",
|
104
|
+
"dToken": "0x8307952247925a2ed9f5729eaf67172a77e08999",
|
105
|
+
"loanToValue": 0.8,
|
106
|
+
"liquidationThreshold": 0.85
|
107
|
+
}
|
108
|
+
}
|
108
109
|
}
|
109
|
-
}
|
@@ -0,0 +1,120 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from defi_services.abis.lending.moonwell.moonwell_comptroller_abi import MOONWELL_COMPTROLLER_ABI
|
4
|
+
from defi_services.abis.lending.moonwell.moonwell_ctoken_abi import MOONWELL_CTOKEN_ABI
|
5
|
+
from defi_services.abis.token.erc20_abi import ERC20_ABI
|
6
|
+
from defi_services.constants.chain_constant import Chain
|
7
|
+
from defi_services.constants.entities.lending_constant import Lending
|
8
|
+
from defi_services.constants.token_constant import Token
|
9
|
+
from defi_services.jobs.queriers.state_querier import StateQuerier
|
10
|
+
from defi_services.services.lending.lending_info.base.moonwell_base import MOONWELL_BASE
|
11
|
+
from defi_services.services.lending.venus_services import VenusStateService
|
12
|
+
|
13
|
+
logger = logging.getLogger("MoonWell Lending Pool State Service")
|
14
|
+
|
15
|
+
|
16
|
+
class MoonWellInfo:
|
17
|
+
mapping = {
|
18
|
+
Chain.base: MOONWELL_BASE
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
class MoonWellStateService(VenusStateService):
|
23
|
+
def __init__(self, state_service: StateQuerier, chain_id: str = "0x38"):
|
24
|
+
super().__init__(state_service, chain_id)
|
25
|
+
self.name = f"{chain_id}_{Lending.moonwell}"
|
26
|
+
self.chain_id = chain_id
|
27
|
+
self.pool_info = MoonWellInfo.mapping.get(chain_id)
|
28
|
+
self.state_service = state_service
|
29
|
+
self.comptroller_abi = MOONWELL_COMPTROLLER_ABI
|
30
|
+
self.vtoken_abi = MOONWELL_CTOKEN_ABI
|
31
|
+
|
32
|
+
def get_service_info(self):
|
33
|
+
info = {
|
34
|
+
Lending.moonwell: {
|
35
|
+
"chain_id": self.chain_id,
|
36
|
+
"type": "lending",
|
37
|
+
"protocol_info": self.pool_info
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return info
|
41
|
+
|
42
|
+
def get_apy_lending_pool_function_info(
|
43
|
+
self,
|
44
|
+
reserves_info: dict,
|
45
|
+
block_number: int = "latest"
|
46
|
+
):
|
47
|
+
rpc_calls = {}
|
48
|
+
for token_address, reserve_info in reserves_info.items():
|
49
|
+
if token_address != Token.native_token:
|
50
|
+
query_id = f"decimals_{token_address}_{block_number}".lower()
|
51
|
+
rpc_calls[query_id] = self.state_service.get_function_info(token_address, ERC20_ABI, "decimals", [], block_number)
|
52
|
+
|
53
|
+
ctoken = reserve_info.get("cToken")
|
54
|
+
for fn_name in ['decimals', 'totalSupply', 'totalBorrows', 'supplyRatePerTimestamp', 'borrowRatePerTimestamp', 'exchangeRateStored']:
|
55
|
+
query_id = f"{fn_name}_{ctoken}_{block_number}".lower()
|
56
|
+
rpc_calls[query_id] = self.get_ctoken_function_info(
|
57
|
+
ctoken=ctoken,
|
58
|
+
fn_name=fn_name,
|
59
|
+
block_number=block_number
|
60
|
+
)
|
61
|
+
|
62
|
+
return rpc_calls
|
63
|
+
|
64
|
+
def get_reserve_tokens_metadata(
|
65
|
+
self,
|
66
|
+
decoded_data: dict,
|
67
|
+
reserves_info: dict,
|
68
|
+
block_number: int = "latest"
|
69
|
+
):
|
70
|
+
reserve_tokens_info = []
|
71
|
+
for token_address, reserve_info in reserves_info.items():
|
72
|
+
if token_address != Token.native_token:
|
73
|
+
underlying_decimals_query_id = f"decimals_{token_address}_{block_number}".lower()
|
74
|
+
underlying_decimals = decoded_data.get(underlying_decimals_query_id)
|
75
|
+
else:
|
76
|
+
underlying_decimals = Chain.native_decimals.get(self.chain_id, 18)
|
77
|
+
|
78
|
+
ctoken = reserve_info.get("cToken")
|
79
|
+
ctoken_decimals_query_id = f"decimals_{ctoken}_{block_number}".lower()
|
80
|
+
total_supply_query_id = f"totalSupply_{ctoken}_{block_number}".lower()
|
81
|
+
total_borrow_query_id = f"totalBorrows_{ctoken}_{block_number}".lower()
|
82
|
+
supply_rate_query_id = f"supplyRatePerTimestamp_{ctoken}_{block_number}".lower()
|
83
|
+
borrow_rate_query_id = f"borrowRatePerTimestamp_{ctoken}_{block_number}".lower()
|
84
|
+
exchange_rate_query_id = f"exchangeRateStored_{ctoken}_{block_number}".lower()
|
85
|
+
|
86
|
+
reserve_tokens_info.append({
|
87
|
+
"token": ctoken,
|
88
|
+
"token_decimals": decoded_data.get(ctoken_decimals_query_id),
|
89
|
+
"borrow_rate": decoded_data.get(borrow_rate_query_id),
|
90
|
+
"supply_rate": decoded_data.get(supply_rate_query_id),
|
91
|
+
"supply": decoded_data.get(total_supply_query_id),
|
92
|
+
"borrow": decoded_data.get(total_borrow_query_id),
|
93
|
+
"exchange_rate": decoded_data.get(exchange_rate_query_id),
|
94
|
+
"underlying_decimals": underlying_decimals,
|
95
|
+
"underlying": token_address
|
96
|
+
})
|
97
|
+
return reserve_tokens_info
|
98
|
+
|
99
|
+
@classmethod
|
100
|
+
def _calculate_interest_rates(
|
101
|
+
cls, token_info: dict, pool_decimals: int, apx_block_speed_in_seconds: float):
|
102
|
+
exchange_rate = float(token_info["exchange_rate"]) / 10 ** (18 - 8 + token_info["underlying_decimals"])
|
103
|
+
|
104
|
+
total_borrow = float(token_info["borrow"]) / 10 ** int(token_info["underlying_decimals"])
|
105
|
+
total_supply = float(token_info["supply"]) * exchange_rate / 10 ** int(token_info["token_decimals"])
|
106
|
+
|
107
|
+
supply_apy = ((token_info["supply_rate"] / 10 ** pool_decimals) * 86400 + 1) ** 365 - 1
|
108
|
+
borrow_apy = ((token_info["borrow_rate"] / 10 ** pool_decimals) * 86400 + 1) ** 365 - 1
|
109
|
+
|
110
|
+
return {
|
111
|
+
'deposit_apy': supply_apy,
|
112
|
+
'borrow_apy': borrow_apy,
|
113
|
+
'total_deposit': total_supply,
|
114
|
+
'total_borrow': total_borrow
|
115
|
+
}
|
116
|
+
|
117
|
+
def get_ctoken_function_info(self, ctoken: str, fn_name: str, fn_paras: list = None, block_number: int = "latest"):
|
118
|
+
return self.state_service.get_function_info(
|
119
|
+
ctoken, self.vtoken_abi, fn_name, fn_paras, block_number
|
120
|
+
)
|
@@ -5,6 +5,7 @@ from defi_services.constants.chain_constant import Chain
|
|
5
5
|
from defi_services.constants.entities.lending_constant import Lending
|
6
6
|
from defi_services.jobs.queriers.state_querier import StateQuerier
|
7
7
|
from defi_services.services.lending.lending_info.arbitrum.radiant_arbitrum import RADIANT_ARB
|
8
|
+
from defi_services.services.lending.lending_info.base.radiant_v2_base import RADIANT_BASE
|
8
9
|
from defi_services.services.lending.lending_info.bsc.radiant_bsc import RADIANT_BSC
|
9
10
|
from defi_services.services.lending.lending_info.ethereum.radiant_eth import RADIANT_ETH
|
10
11
|
from defi_services.services.lending.valas_services import ValasStateService
|
@@ -17,7 +18,8 @@ class RadiantInfo:
|
|
17
18
|
mapping = {
|
18
19
|
Chain.arbitrum: RADIANT_ARB,
|
19
20
|
Chain.bsc: RADIANT_BSC,
|
20
|
-
Chain.ethereum: RADIANT_ETH
|
21
|
+
Chain.ethereum: RADIANT_ETH,
|
22
|
+
Chain.base: RADIANT_BASE
|
21
23
|
}
|
22
24
|
|
23
25
|
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from defi_services.abis.lending.venus.venus_comptroller_abi import VENUS_COMPTROLLER_ABI
|
4
|
+
from defi_services.abis.lending.venus.vtoken_abi import VTOKEN_ABI
|
5
|
+
from defi_services.constants.chain_constant import Chain
|
6
|
+
from defi_services.constants.entities.lending_constant import Lending
|
7
|
+
from defi_services.jobs.queriers.state_querier import StateQuerier
|
8
|
+
from defi_services.services.lending.lending_info.base.sonne_base import SONNE_BASE
|
9
|
+
from defi_services.services.lending.venus_services import VenusStateService
|
10
|
+
|
11
|
+
logger = logging.getLogger("Ionic Lending Pool State Service")
|
12
|
+
|
13
|
+
|
14
|
+
class SonneInfo:
|
15
|
+
mapping = {
|
16
|
+
Chain.base: SONNE_BASE
|
17
|
+
}
|
18
|
+
|
19
|
+
|
20
|
+
class SonneStateService(VenusStateService):
|
21
|
+
def __init__(self, state_service: StateQuerier, chain_id: str = "0x38"):
|
22
|
+
super().__init__(state_service, chain_id)
|
23
|
+
self.name = f"{chain_id}_{Lending.sonne}"
|
24
|
+
self.chain_id = chain_id
|
25
|
+
self.pool_info = SonneInfo.mapping.get(chain_id)
|
26
|
+
self.state_service = state_service
|
27
|
+
self.comptroller_abi = VENUS_COMPTROLLER_ABI
|
28
|
+
self.vtoken_abi = VTOKEN_ABI
|
29
|
+
|
30
|
+
def get_service_info(self):
|
31
|
+
info = {
|
32
|
+
Lending.sonne: {
|
33
|
+
"chain_id": self.chain_id,
|
34
|
+
"type": "lending",
|
35
|
+
"protocol_info": self.pool_info
|
36
|
+
}
|
37
|
+
}
|
38
|
+
return info
|
39
|
+
|
40
|
+
def calculate_apy_lending_pool_function_call(
|
41
|
+
self,
|
42
|
+
reserves_info: dict,
|
43
|
+
decoded_data: dict,
|
44
|
+
token_prices: dict,
|
45
|
+
pool_token_price: float,
|
46
|
+
pool_decimals: int = 18,
|
47
|
+
block_number: int = "latest",
|
48
|
+
):
|
49
|
+
reserve_tokens_info = self.get_reserve_tokens_metadata(decoded_data, reserves_info, block_number)
|
50
|
+
|
51
|
+
data = {}
|
52
|
+
for token_info in reserve_tokens_info:
|
53
|
+
underlying_token = token_info['underlying']
|
54
|
+
c_token = token_info['token']
|
55
|
+
|
56
|
+
assets = {
|
57
|
+
underlying_token: self._calculate_interest_rates(
|
58
|
+
token_info, pool_decimals=pool_decimals,
|
59
|
+
apx_block_speed_in_seconds=1
|
60
|
+
)
|
61
|
+
}
|
62
|
+
data[c_token] = assets
|
63
|
+
|
64
|
+
return data
|
@@ -1,4 +1,4 @@
|
|
1
|
-
defi_services/__init__.py,sha256=
|
1
|
+
defi_services/__init__.py,sha256=c7RXwaEocvh6Nr9are6JiEVuN0mRThB698HD5t9DIPA,23
|
2
2
|
defi_services/abis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
defi_services/abis/multicall_v3_abi.py,sha256=0aPxjrJJFU17fODjvYFRDn5Y5J1yi_AJKc8v1uohNGY,12352
|
4
4
|
defi_services/abis/dex/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -138,6 +138,8 @@ defi_services/abis/lending/cream/cream_comptroller_abi.py,sha256=lHcdsXy99bltWfH
|
|
138
138
|
defi_services/abis/lending/cream/cream_lens_abi.py,sha256=IP5xv3YG2pgqlzldUJCzQ8PXhzlD5BnHTuFf0qypms8,20100
|
139
139
|
defi_services/abis/lending/granary/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
140
140
|
defi_services/abis/lending/granary/granary_rewarder_abi.py,sha256=Ad04T91om5blSUF-VPOaE0SZ5p5HYuKtYSs_sdyuPXU,15882
|
141
|
+
defi_services/abis/lending/ionic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
142
|
+
defi_services/abis/lending/ionic/ionic_ctoken_abi.py,sha256=bctYY8RT8N8f1f874fMf31xsn7gf4wc9cyJQyJBdw88,27357
|
141
143
|
defi_services/abis/lending/iron_bank/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
142
144
|
defi_services/abis/lending/iron_bank/ctoken_abi.py,sha256=GbIYuz-PDQ2BhYYmyS-QjAxPLpD_XMh7U7RKLwn3ffA,28022
|
143
145
|
defi_services/abis/lending/iron_bank/iron_comptroller_abi.py,sha256=-XyRNrmxyI_-cjY2rFBWRN2J7sV_LzI_SATyp2Evdcw,44932
|
@@ -150,6 +152,9 @@ defi_services/abis/lending/liqee/liqee_comptroller_abi.py,sha256=UbMnkWmApWs2oBU
|
|
150
152
|
defi_services/abis/lending/liqee/liqee_event_abi.py,sha256=scyf1cGK9xBjPcPXv-bqh3WTP5LR2Gh8n-JeserCAeA,3787
|
151
153
|
defi_services/abis/lending/liqee/liqee_lending_data_abi.py,sha256=qs7_ynzZxuG0AtKRRU8SAh4zXxKpcoVT7zkuU_sNOrc,17504
|
152
154
|
defi_services/abis/lending/liqee/liqee_token_abi.py,sha256=ApFOMcmdskkX1dPJIxofQTqlguBlDyzrKYcVOGlCEW4,28252
|
155
|
+
defi_services/abis/lending/moonwell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
156
|
+
defi_services/abis/lending/moonwell/moonwell_comptroller_abi.py,sha256=8_EPWs5hA8Ys2YaSs6W_r9vAeKeJzbN7_MELOBJp-O0,37598
|
157
|
+
defi_services/abis/lending/moonwell/moonwell_ctoken_abi.py,sha256=37cB--8fzHnzavAmSGsnEfL_Gf9kxdE7l8xJXNlojX0,35846
|
153
158
|
defi_services/abis/lending/morpho/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
154
159
|
defi_services/abis/lending/morpho/morpho_aave_v2_comptroller_abi.py,sha256=3ThdzPUy5B_nwVHNCoDpJ9L4y1_EyAbrinu6KGCjNqk,45749
|
155
160
|
defi_services/abis/lending/morpho/morpho_aave_v2_lens_abi.py,sha256=IjNp8W8AU8awn-cwgShNQrsllxk_n2Vze2IG92Qxk38,24940
|
@@ -295,7 +300,7 @@ defi_services/abis/vault/lido/lido_withdrawl_queue.py,sha256=qKdsXQLKlNU3a_Nk68q
|
|
295
300
|
defi_services/abis/vault/lido/lido_wsteth.py,sha256=DJhMToJS43vV2r5WP2kZSiagt7R8MtKFT8u1xJBjZKU,8780
|
296
301
|
defi_services/abis/vault/lido/lidor_accounting_oracle_hash_consensus.py,sha256=TWCLaccDgvWJZZKLAeoznYgGi3g3M_hFqoo3KE_L7K8,21039
|
297
302
|
defi_services/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
298
|
-
defi_services/constants/chain_constant.py,sha256=
|
303
|
+
defi_services/constants/chain_constant.py,sha256=zA17Ihi5b8K99H0DsraAL-8-a_5_h37DbJ0OKA2qRys,1221
|
299
304
|
defi_services/constants/cosmos_decimals_constant.py,sha256=SjFkFbkvxVAk0jtok_1EaBh69ZE8S1fFAbVn6bdJO4s,13635
|
300
305
|
defi_services/constants/db_constant.py,sha256=gDMFFjhPOgQHuS9sPOTFbsfSdIfdWQEE4tGlxHQhNsE,2566
|
301
306
|
defi_services/constants/mongo_constant.py,sha256=qsDIq2Gg5MkBGaEOh4Fd9y6fOOidF4gGPnQwtaPon3E,398
|
@@ -308,8 +313,8 @@ defi_services/constants/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRk
|
|
308
313
|
defi_services/constants/entities/dex_constant.py,sha256=oCt8RS-0KjFW5zR5IU1Ys49nYCCAraY8pTivOpXoyvs,343
|
309
314
|
defi_services/constants/entities/dex_info_constant.py,sha256=gFjF6gWLZ-e_iLoUeSF-bPZKOwbmxVoMeyaA2wGZESM,1653
|
310
315
|
defi_services/constants/entities/dex_services.py,sha256=Ip3ww6OBA3RQHMrtPE86uoPv2iv-oLh38cKGPtrpKMA,2383
|
311
|
-
defi_services/constants/entities/lending_constant.py,sha256=
|
312
|
-
defi_services/constants/entities/lending_services.py,sha256=
|
316
|
+
defi_services/constants/entities/lending_constant.py,sha256=ufSzWJ8bCqSsdiB21kmqD3ZBQKB8XtqTaqX9rIDQGDc,1145
|
317
|
+
defi_services/constants/entities/lending_services.py,sha256=zo4fkFYoBSPcnHKRY1NAJrRLRxG1syYOUZnqQKo-yWw,5980
|
313
318
|
defi_services/constants/entities/vault_constant.py,sha256=XaFp2VpmePfym42Gn-5IeT8qnQBq1JcRNrH7r2_tWxo,122
|
314
319
|
defi_services/constants/entities/vault_services.py,sha256=uwcvxwnyXNU3_3mcI6PGWyvGe40tzHmTrmigotLWeMM,752
|
315
320
|
defi_services/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -366,16 +371,19 @@ defi_services/services/lending/compound_v3_services.py,sha256=SlqYIOIRBg61sOPvZU
|
|
366
371
|
defi_services/services/lending/cream_services.py,sha256=vtah0kMHAxztenWbJp4CxEcBMF0XUBglGRk6p9d-oiU,1644
|
367
372
|
defi_services/services/lending/flux_services.py,sha256=C9WJ2MIBK4xTaXIHF3yBVu52xGCNzO4Ed5DWyxWTTeE,12617
|
368
373
|
defi_services/services/lending/geist_services.py,sha256=UI5D-MbMqplrt7D4krSFdpaREKOT81k8boD_XhGGpUQ,1035
|
369
|
-
defi_services/services/lending/granary_services.py,sha256=
|
374
|
+
defi_services/services/lending/granary_services.py,sha256=n9ovzFXzMa26ZbGxARJiAiWhMdvuuuMF3iSfWgAg4E0,16581
|
375
|
+
defi_services/services/lending/ionic_service.py,sha256=gwGySZzs3-FVF1ct6zJOY4AHelaSpWL9AVABSyB0wJg,7529
|
370
376
|
defi_services/services/lending/iron_bank_service.py,sha256=GuXoXEbR4gkkNYfAyFkDtVeI3-knq3kFnLBeWVuUvv8,15585
|
371
377
|
defi_services/services/lending/justlend_service.py,sha256=az1OxDAqDKjT7jZ2CiNS4sfKXjhS04kD6FWB4ZT16mQ,8874
|
372
378
|
defi_services/services/lending/liqee_service.py,sha256=dBMlQpREqSzZY2_JCpJDxnWl9A8fWxa56KhsDNd--as,17140
|
379
|
+
defi_services/services/lending/moonwell_service.py,sha256=V8UCQPN8jv_QwvXLsTUpbpgYk4_JmdhNhyckvNONErI,5468
|
373
380
|
defi_services/services/lending/morpho_aave_v2_services.py,sha256=C8mfClb_KVbSr08YReVjhPzP4FTurGsitE9a4isEMn8,8471
|
374
381
|
defi_services/services/lending/morpho_aave_v3_services.py,sha256=5p-_1rpFnjaY55gRJWxdQ1qHuKDrQDMY-6PdRDpfJIo,8268
|
375
382
|
defi_services/services/lending/morpho_compound_services.py,sha256=38AXwi-7yxSrRghS3OCRZrOy9cfJnC3k-yNf1Ep27Ds,14912
|
376
383
|
defi_services/services/lending/onyx_service.py,sha256=CqQcenVidyKYIxNlaTliaYmSI8zV7_zxK_wCQE5s-r4,15401
|
377
|
-
defi_services/services/lending/radiant_v2_services.py,sha256=
|
384
|
+
defi_services/services/lending/radiant_v2_services.py,sha256=Kk417nQkWXaZctx6mtUgXecb-Ni0BULBKnRjq28ll44,3271
|
378
385
|
defi_services/services/lending/silo_services.py,sha256=yLw90u_IXEqE3NbfhVAhG1y8qQqo26xSbYXXlh4lL3g,16726
|
386
|
+
defi_services/services/lending/sonne_service.py,sha256=KQ0CbMVLK-peJZE2_xJtFTK2lBx6Mnijhlwo0BVU4ug,2203
|
379
387
|
defi_services/services/lending/spark_services.py,sha256=68_egY0yOT7YIOVbd8rbHJBJEsL0sOr0zSsTSdw0BUY,1042
|
380
388
|
defi_services/services/lending/strike_service.py,sha256=ZQ9B6Xngo64njwqABOO3CH-ESFmUmQWbisCgVXYKjak,13797
|
381
389
|
defi_services/services/lending/trava_services.py,sha256=XakGhWzEcrEbKxPsAzZz-X8JVtMBkU2hem-AGWTHCvk,19101
|
@@ -383,7 +391,7 @@ defi_services/services/lending/uwu_services.py,sha256=umv1YKsFBrOybPgX69ybzzEVOk
|
|
383
391
|
defi_services/services/lending/valas_services.py,sha256=KlguY7dg58jK2LbJn79c6Tsu_gYmIlSLfC3U81YfI5E,22445
|
384
392
|
defi_services/services/lending/venus_services.py,sha256=LhSG2H16kZn8AqIS7DAOy0kxP8N2O_ZUAEl9Eho4Ujo,16523
|
385
393
|
defi_services/services/lending/wepiggy_services.py,sha256=x10QkYpn47wgNvmDeMGgmzJxv7WPte6hqR3MCBRgMbM,15684
|
386
|
-
defi_services/services/lending/zerolend_services.py,sha256=
|
394
|
+
defi_services/services/lending/zerolend_services.py,sha256=7ESBKXhUtV-xCnbx_Om8ys3X6ChTICNzbljWnPHBn-k,1334
|
387
395
|
defi_services/services/lending/lending_info/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
388
396
|
defi_services/services/lending/lending_info/arbitrum/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
389
397
|
defi_services/services/lending/lending_info/arbitrum/aave_v3_arbitrum.py,sha256=VfEs1oLTSqs4GTnghtHrkqcCBHd7C_xyzD849TOwmd0,3553
|
@@ -401,8 +409,12 @@ defi_services/services/lending/lending_info/avalanche/iron_bank_avalanche.py,sha
|
|
401
409
|
defi_services/services/lending/lending_info/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
402
410
|
defi_services/services/lending/lending_info/base/aave_v3_base.py,sha256=2BvRCl5V44ElBh0fHzoMcgC2Ze3K7Hedq-s1ftd1tzY,2893
|
403
411
|
defi_services/services/lending/lending_info/base/compound_v3_base.py,sha256=tL-hRHmlOvtbUAReyt53Hhp14xg36SAHQFpF2stzwdM,5363
|
404
|
-
defi_services/services/lending/lending_info/base/
|
405
|
-
defi_services/services/lending/lending_info/base/
|
412
|
+
defi_services/services/lending/lending_info/base/granary_base.py,sha256=YUB8YXgKeH7beX1fjZdVBXuTe_Az8gUxLh2WFOeTlRM,2785
|
413
|
+
defi_services/services/lending/lending_info/base/ionic_base.py,sha256=W03N7CHWVS6lKBwDKrpWO569sM-6Rzp6VPthutaixsg,7227
|
414
|
+
defi_services/services/lending/lending_info/base/moonwell_base.py,sha256=XjZW7PYLnwLsUkHfqbfsltdofY4jA2wDfXMrUzWYFCo,3717
|
415
|
+
defi_services/services/lending/lending_info/base/radiant_v2_base.py,sha256=82rd8ntQHij79FFpfnqIXV31VvJCtV0mOHriIFcKn18,2510
|
416
|
+
defi_services/services/lending/lending_info/base/sonne_base.py,sha256=7t2XMWhlTgAdx-v6Z9GSKLwap1ENjcTeHHZkPo0ldvA,2165
|
417
|
+
defi_services/services/lending/lending_info/base/zerolend_base.py,sha256=rOaAXq0LYGOKcTI79B77prvID3PLHwF4rXKMOaUCxyk,5198
|
406
418
|
defi_services/services/lending/lending_info/bsc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
407
419
|
defi_services/services/lending/lending_info/bsc/aave_v3_bsc.py,sha256=g4A6fJVqzx6ly5qcI1Ifx7yECa4UuoX9Qa282vP3KD0,3168
|
408
420
|
defi_services/services/lending/lending_info/bsc/apeswap_bsc.py,sha256=cbS9R3ArW2ckZBiZOysOAlu3FoRX7xla8GUlUA6C0Q8,2110
|
@@ -491,8 +503,8 @@ defi_services/utils/memory_storage.py,sha256=BOT8laB0iVSCGE-oDlpWJQLbSC6X2blKX4z
|
|
491
503
|
defi_services/utils/sqrt_price_math.py,sha256=9lgUeWFT4wjl3Vq3b7-jZ2bGvvZx7dDBSfVnM3lsZ8o,5575
|
492
504
|
defi_services/utils/thread_proxy.py,sha256=5Z8biAyEReUkh3vfJSvEv7GwMe3CsE5M8CbghkQtePw,2951
|
493
505
|
defi_services/utils/ton_decode_address.py,sha256=EWKwmC7KtbXpdKgiNK-5j-5lX7fCr17I4EWYs9b43eU,443
|
494
|
-
defi_state_querier-0.5.
|
495
|
-
defi_state_querier-0.5.
|
496
|
-
defi_state_querier-0.5.
|
497
|
-
defi_state_querier-0.5.
|
498
|
-
defi_state_querier-0.5.
|
506
|
+
defi_state_querier-0.5.24.dist-info/LICENSE,sha256=6jmfxa8nUIwfKnzZUxAHJSJ_IS7h7mpbJq26cWjoo-o,1063
|
507
|
+
defi_state_querier-0.5.24.dist-info/METADATA,sha256=Xyn7wQ4_erZkMqoI1VhXK1RG-zY4qDXbkpVHUGIlQ-4,4631
|
508
|
+
defi_state_querier-0.5.24.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
509
|
+
defi_state_querier-0.5.24.dist-info/top_level.txt,sha256=C-OTxHK6MknKK-nAbEzCPDUl1M6pktRhgJrmsozdf6g,14
|
510
|
+
defi_state_querier-0.5.24.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|