Skip to content

Commit b2db0bd

Browse files
authored
eigen_layer support (HemeraProtocol#166)
* add eigen_layer
1 parent 2876d8f commit b2db0bd

File tree

12 files changed

+582
-2
lines changed

12 files changed

+582
-2
lines changed

enumeration/entity_type.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from indexer.modules.custom.blue_chip.domain.feature_blue_chip import BlueChipHolder
2222
from indexer.modules.custom.deposit_to_l2.domain.address_token_deposit import AddressTokenDeposit
2323
from indexer.modules.custom.deposit_to_l2.domain.token_deposit_transaction import TokenDepositTransaction
24+
from indexer.modules.custom.eigen_layer.eigen_layer_domain import EigenLayerActionD, EigenLayerAddressCurrentD
2425
from indexer.modules.custom.hemera_ens.ens_domain import (
2526
ENSAddressChangeD,
2627
ENSAddressD,
@@ -65,6 +66,8 @@ class EntityType(IntFlag):
6566

6667
ENS = 1 << 10
6768

69+
EIGEN_LAYER = 1 << 13
70+
6871
EXPLORER = EXPLORER_BASE | EXPLORER_TOKEN | EXPLORER_TRACE
6972

7073
@staticmethod
@@ -182,3 +185,7 @@ def generate_output_types(entity_types):
182185
if entity_types & EntityType.OPEN_SEA:
183186
yield AddressOpenseaTransaction
184187
yield OpenseaOrder
188+
189+
if entity_types & EntityType.EIGEN_LAYER:
190+
yield EigenLayerActionD
191+
yield EigenLayerAddressCurrentD

indexer/domain/transaction.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,6 @@ def fill_with_receipt(self, receipt: Receipt):
6666
self.receipt = receipt
6767
if self.to_address is None:
6868
self.to_address = self.receipt.contract_address
69+
70+
def get_method_id(self):
71+
return self.input[0:10] if self.input and len(self.input) > 10 else None

indexer/modules/custom/address_index/models/address_contract_operation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def model_domain_mapping():
4343

4444

4545
Index(
46-
"address_contract_operations_address_block_timestamp_block_number_t_idx",
46+
"address_contract_operations_address_block_tn_t_idx",
4747
AddressContractOperations.address,
4848
desc(AddressContractOperations.block_timestamp),
4949
desc(AddressContractOperations.block_number),

indexer/modules/custom/address_index/models/address_internal_transaciton.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def model_domain_mapping():
4343

4444

4545
Index(
46-
"address_internal_transactions_address_block_timestamp_block_number_t_idx",
46+
"address_internal_transactions_address_nt_t_idx",
4747
AddressInternalTransactions.address,
4848
desc(AddressInternalTransactions.block_timestamp),
4949
desc(AddressInternalTransactions.block_number),
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Time 2024/9/23 17:12
4+
# @Author will
5+
# @File __init__.py.py
6+
# @Brief
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Time 2024/9/23 18:37
4+
# @Author will
5+
# @File eigen_layer_abi.py
6+
# @Brief
7+
import json
8+
from typing import cast
9+
10+
from web3.types import ABIEvent, ABIFunction
11+
12+
from indexer.utils.abi import event_log_abi_to_topic, function_abi_to_4byte_selector_str
13+
14+
DEPOSIT_EVENT = cast(
15+
ABIEvent,
16+
json.loads(
17+
"""{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"}
18+
"""
19+
),
20+
)
21+
DEPOSIT_EVENT_SIG = event_log_abi_to_topic(DEPOSIT_EVENT)
22+
23+
WITHDRAWAL_QUEUED_EVENT = cast(
24+
ABIEvent,
25+
json.loads(
26+
"""
27+
{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"withdrawalRoot","type":"bytes32"},{"components":[{"internalType":"address","name":"staker","type":"address"},{"internalType":"address","name":"delegatedTo","type":"address"},{"internalType":"address","name":"withdrawer","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint32","name":"startBlock","type":"uint32"},{"internalType":"contract IStrategy[]","name":"strategies","type":"address[]"},{"internalType":"uint256[]","name":"shares","type":"uint256[]"}],"indexed":false,"internalType":"struct Withdrawal","name":"withdrawal","type":"tuple"}],"name":"WithdrawalQueued","type":"event"}
28+
"""
29+
),
30+
)
31+
WITHDRAWAL_QUEUED_EVENT_SIG = event_log_abi_to_topic(WITHDRAWAL_QUEUED_EVENT)
32+
33+
WITHDRAWAL_QUEUED_EVENT_2 = cast(
34+
ABIEvent,
35+
json.loads(
36+
"""{"type":"event","name":"WithdrawalQueued","inputs":[{"type":"address","name":"depositor","indexed":false},{"type":"uint96","name":"nonce","indexed":false},{"type":"address","name":"withdrawer","indexed":false},{"type":"address","name":"delegatedAddress","indexed":false},{"type":"bytes32","name":"withdrawalRoot","indexed":false}],"anonymous":false}
37+
"""
38+
),
39+
)
40+
41+
SHARE_WITHDRAW_QUEUED = cast(
42+
ABIEvent,
43+
json.loads(
44+
"""{"anonymous":false,"inputs":[{"indexed":false,"name":"depositor","type":"address"},{"indexed":false,"name":"nonce","type":"uint96"},{"indexed":false,"name":"strategy","type":"address"},{"indexed":false,"name":"shares","type":"uint256"}],"name":"ShareWithdrawalQueued","type":"event"}"""
45+
),
46+
)
47+
48+
WITHDRAWAL_COMPLETED_EVENT = cast(
49+
ABIEvent,
50+
json.loads(
51+
"""{"type":"event","name":"WithdrawalCompleted","inputs":[{"type":"bytes32","name":"withdrawalRoot","indexed":false}],"anonymous":false}
52+
"""
53+
),
54+
)
55+
WITHDRAWAL_COMPLETED_EVENT_SIG = event_log_abi_to_topic(WITHDRAWAL_COMPLETED_EVENT)
56+
57+
58+
FINISH_WITHDRAWAL_FUNCTION = cast(
59+
ABIFunction,
60+
json.loads(
61+
"""{"inputs":[{"components":[{"internalType":"address","name":"staker","type":"address"},{"internalType":"address","name":"delegatedTo","type":"address"},{"internalType":"address","name":"withdrawer","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint32","name":"startBlock","type":"uint32"},{"internalType":"address[]","name":"strategies","type":"address[]"},{"internalType":"uint256[]","name":"shares","type":"uint256[]"}],"internalType":"struct Withdrawal[]","name":"withdrawals","type":"tuple[]"},{"internalType":"address[][]","name":"tokens","type":"address[][]"},{"internalType":"uint256[]","name":"middlewareTimesIndexes","type":"uint256[]"},{"internalType":"bool[]","name":"receiveAsTokens","type":"bool[]"}],"name":"completeQueuedWithdrawals","outputs":[],"stateMutability":"nonpayable","type":"function"}"""
62+
),
63+
)
64+
FINISH_WITHDRAWAL_FUNCTION_4SIG = function_abi_to_4byte_selector_str(FINISH_WITHDRAWAL_FUNCTION)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Time 2024/9/23 18:37
4+
# @Author will
5+
# @File eigen_layer_conf.py
6+
# @Brief
7+
CHAIN_CONTRACT = {
8+
1: {
9+
"DEPOSIT": {
10+
"address": "0x858646372cc42e1a627fce94aa7a7033e7cf075a",
11+
"topic": "0x7cfff908a4b583f36430b25d75964c458d8ede8a99bd61be750e97ee1b2f3a96",
12+
},
13+
"START_WITHDRAW": {
14+
"address": "0x39053d51b77dc0d36036fc1fcc8cb819df8ef37a",
15+
"topic": "0x9009ab153e8014fbfb02f2217f5cde7aa7f9ad734ae85ca3ee3f4ca2fdd499f9",
16+
},
17+
"START_WITHDRAW_2": {
18+
"address": "0x858646372cc42e1a627fce94aa7a7033e7cf075a",
19+
"topic": "0x32cf9fc97155f52860a59a99879a2e89c1e53f28126a9ab6a2ff29344299e674",
20+
"prev_topic": "0xcf1c2370141bbd0a6d971beb0e3a2455f24d6e773ddc20ccc1c4e32f3dd9f9f7",
21+
},
22+
"FINISH_WITHDRAW": {
23+
"address": "0x39053d51b77dc0d36036fc1fcc8cb819df8ef37a",
24+
"topic": "0xc97098c2f658800b4df29001527f7324bcdffcf6e8751a699ab920a1eced5b1d",
25+
},
26+
}
27+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from dataclasses import dataclass
2+
from typing import Optional
3+
4+
from indexer.domain import FilterData
5+
6+
7+
@dataclass
8+
class EigenLayerActionD(FilterData):
9+
transaction_hash: str
10+
log_index: int
11+
transaction_index: int
12+
internal_idx: Optional[int] = 0
13+
block_number: Optional[int] = None
14+
block_timestamp: Optional[int] = None
15+
method: Optional[str] = None
16+
event_name: Optional[str] = None
17+
topic0: Optional[str] = None
18+
from_address: Optional[str] = None
19+
to_address: Optional[str] = None
20+
21+
token: Optional[str] = None
22+
strategy: Optional[str] = None
23+
shares: Optional[int] = None
24+
staker: Optional[str] = None
25+
withdrawer: Optional[str] = None
26+
withdrawroot: Optional[str] = None
27+
28+
29+
@dataclass
30+
class EigenLayerAddressCurrentD(FilterData):
31+
address: Optional[str] = None
32+
strategy: Optional[str] = None
33+
token: Optional[str] = None
34+
deposit_amount: Optional[int] = None
35+
start_withdraw_amount: Optional[int] = None
36+
finish_withdraw_amount: Optional[int] = None
37+
38+
39+
def eigen_layer_address_current_factory():
40+
return EigenLayerAddressCurrentD(
41+
address=None,
42+
strategy=None,
43+
token=None,
44+
deposit_amount=0,
45+
start_withdraw_amount=0,
46+
finish_withdraw_amount=0,
47+
)

0 commit comments

Comments
 (0)